:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --sidebar: #0f172a;
  --sidebar-soft: #172033;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-2: #06b6d4;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex: 0 0 248px;
  background: radial-gradient(circle at 20% 0%, #1e293b 0%, var(--sidebar) 45%);
  color: #cbd5e1;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 8px;
  color: #fff;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; letter-spacing: 0.5px; }
.brand-text span { font-size: 11px; color: #94a3b8; letter-spacing: 0.8px; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: #cbd5e1;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-decoration: none;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.95), rgba(6, 182, 212, 0.75));
  color: #fff;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.28);
}

.nav-icon { width: 18px; text-align: center; opacity: 0.9; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #64748b;
  font-size: 12px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 26px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.global-search { flex: 1; max-width: 620px; display: flex; }
.global-search input {
  width: 100%;
  height: 38px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%2364748b' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center;
  font: inherit;
  color: var(--text);
  outline: none;
}
.global-search input:focus { border-color: #93c5fd; background-color: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: #334155;
  font-size: 13px;
}

.user-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.logout-form { display: inline; }
.link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 6px 8px;
}
.link-button:hover { color: var(--danger); }

.content { padding: 26px; max-width: 1920px; width: 100%; margin: 0 auto; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-head h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.3px; }
.page-head p { margin: 0; color: var(--muted); }

.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.page-head .actions .btn-back,
.detail-head .actions .btn-back { color: #475569; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fff;
  color: #334155;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}
.btn-primary:hover { background: linear-gradient(135deg, #1d4ed8, #0284c7); }
.btn-danger { border-color: #fecaca; background: #fef2f2; color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-lg { height: 46px; padding: 0 22px; border-radius: 11px; font-size: 15px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 18px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.card-head h2, .card-head h3 { margin: 0; font-size: 16px; }
.card-head .sub { color: var(--muted); font-size: 12px; }

.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -30px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(6, 182, 212, 0.06));
}
.stat-label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -0.8px; line-height: 1.1; }
.stat-hint { color: #94a3b8; font-size: 11px; margin-top: 6px; }

.stat-card.tab-card { transition: border-color .15s, box-shadow .15s, transform .15s; }
.stat-card.tab-card:hover { border-color: #93c5fd; box-shadow: 0 6px 18px rgba(37, 99, 235, 0.12); transform: translateY(-1px); }
.stat-card.tab-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12); }
.stat-card.tab-card.active .stat-label { color: var(--accent); }

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  border-radius: 16px;
  background: linear-gradient(120deg, #0f172a 0%, #172554 55%, #0e7490 100%);
  color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
}
.hero h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -0.4px; }
.hero p { margin: 0; color: #cbd5e1; max-width: 720px; }
.hero-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.hero-pill {
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: #e2e8f0;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-form input[type="text"], .filter-form input[type="search"], .filter-form select {
  height: 38px;
  min-width: 300px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  font: inherit;
  outline: none;
}
.filter-form input:focus, .filter-form select:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.filter-form .btn { height: 38px; }

/* Report filter row: compact date range plus a single-line selector. */
.report-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.report-filters .form-field { gap: 6px; }
.report-filters .form-field.compact { flex: 0 0 158px; max-width: 158px; }
.report-filters .form-field.compact input { min-height: 38px; padding: 7px 9px; }
.report-filters .form-field select { min-height: 38px; min-width: 200px; }
.report-filters-actions { display: flex; gap: 8px; margin-left: auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: center;
  padding: 11px 14px;
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.2px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: #334155;
  white-space: nowrap;
  font-size: 13px;
}
table.data-table td.cell-wrap,
table.data-table td .cell-wrap,
table.data-table .cell-wrap {
  white-space: normal;
  min-width: 220px;
  max-width: 460px;
  word-break: break-word;
}
table.data-table td.cell-date,
table.data-table td .cell-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data-table tbody tr:hover { background: #f8fbff; }
table.data-table tbody tr.row-muted { background: #f1f5f9; }
table.data-table tbody tr.row-muted:hover { background: #e2e8f0; }
table.data-table tbody tr.row-muted td { color: #64748b; }
table.data-table tbody tr.row-muted td.actions { background: #f1f5f9; }
table.data-table tbody tr:last-child td { border-bottom: 0; }
table.data-table .actions { text-align: right; white-space: nowrap; }
table.data-table th.actions,
table.data-table td.actions {
  position: sticky;
  right: 0;
  z-index: 2;
  background: #fff;
  box-shadow: -10px 0 14px -12px rgba(15, 23, 42, 0.35);
}
table.data-table th.actions { background: #f8fafc; z-index: 3; }
table.data-table tbody tr:hover td.actions { background: #f8fbff; }
table.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data-table .strong { font-weight: 700; color: var(--text); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.success { background: #ecfdf5; color: #047857; }
.badge.warning { background: #fffbeb; color: #b45309; }
.badge.danger { background: #fef2f2; color: #b91c1c; }
.badge.muted { background: #f1f5f9; color: #475569; }

.select-col {
  width: 38px;
  text-align: center;
  padding-left: 12px !important;
  padding-right: 6px !important;
}

.select-col input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.row-action-head,
.row-action-cell {
  width: 46px;
  text-align: right;
  padding-left: 4px !important;
  padding-right: 10px !important;
}

.row-menu-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #475569;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.row-menu-btn:hover { border-color: #93c5fd; color: var(--accent); background: #eff6ff; }

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
  color: #1e40af;
  font-size: 13px;
}
.bulk-bar[hidden] { display: none; }
.bulk-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bulk-actions form { display: inline; margin: 0; }

.floating-row-menu {
  position: fixed;
  z-index: 1000;
  min-width: 160px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
}
.floating-row-menu[hidden] { display: none; }
.floating-row-menu form { margin: 0; }
.floating-row-menu .row-menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #334155;
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.floating-row-menu .row-menu-item:hover { background: #f1f5f9; text-decoration: none; }
.floating-row-menu .row-menu-item.danger { color: var(--danger); }
.floating-row-menu .row-menu-item.danger:hover { background: #fef2f2; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}
.pagination .pages { display: flex; align-items: center; gap: 6px; }
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: #475569;
}
.pagination a:hover { border-color: #93c5fd; color: var(--accent); text-decoration: none; }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}
.info-item {
  padding: 13px 15px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 68px;
}
.info-item .label { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.info-item .value { font-weight: 600; color: #1e293b; word-break: break-word; }
.info-item .value.empty { color: #cbd5e1; font-weight: 400; }

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  border-bottom: 1px solid var(--border);
}
.detail-head h1 { margin: 0 0 6px; font-size: 25px; letter-spacing: -0.4px; }
.detail-head .sub { color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.detail-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section { margin-top: 20px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
.section-title h2 { margin: 0; font-size: 16px; }
.section-title .sub { color: var(--muted); font-size: 12px; }

.form-card { max-width: 980px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12px; font-weight: 700; color: #475569; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  font: inherit;
  color: var(--text);
  outline: none;
}
.form-field textarea { resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-field > input[type="checkbox"],
.form-field > input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: #2563eb;
}
.form-field .errorlist { margin: 0; padding: 0; list-style: none; color: var(--danger); font-size: 12px; }
.form-field .helptext { color: #94a3b8; font-size: 11px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }

.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.message {
  padding: 10px 13px;
  border-radius: 9px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
  font-size: 13px;
}
.message.success { border-color: #a7f3d0; background: #ecfdf5; color: #047857; }
.message.error { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.message.warning { border-color: #fde68a; background: #fffbeb; color: #b45309; }

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-state strong { display: block; color: #334155; margin-bottom: 4px; }

.list-clean { margin: 0; padding: 0; list-style: none; }
.list-clean li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #f1f5f9;
}
.list-clean li:last-child { border-bottom: 0; }
.list-clean .main-text { font-weight: 600; color: #1e293b; }
.list-clean .sub-text { color: var(--muted); font-size: 12px; margin-top: 2px; }
.list-clean .right { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }

.module-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.module-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.module-card:hover { border-color: #93c5fd; transform: translateY(-1px); text-decoration: none; }
.module-card .title { font-weight: 700; }
.module-card .sub { color: var(--muted); font-size: 12px; }
.pms-primary-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.module-card-lg { padding: 20px 18px; border-radius: 14px; background: linear-gradient(180deg, #ffffff, #f8fbff); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
.module-card-lg .title { font-size: 18px; }
.module-card-lg .sub { font-size: 13px; line-height: 1.5; }
@media (max-width: 900px) { .pms-primary-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .pms-primary-actions { grid-template-columns: 1fr; } }

.progress {
  height: 7px;
  border-radius: 99px;
  background: #eef2f7;
  overflow: hidden;
  min-width: 80px;
}
.progress > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #2563eb, #06b6d4); }

.split-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); gap: 18px; }

.tab-links { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab-link {
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
}
.tab-link.active { border-color: var(--accent); background: #eff6ff; color: var(--accent); }
.tab-link:hover { text-decoration: none; border-color: #93c5fd; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 20% 10%, #1e3a8a 0%, #0f172a 45%, #082f49 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 18px;
  padding: 30px;
  box-shadow: 0 30px 70px rgba(2, 6, 23, 0.45);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-brand .brand-mark { width: 42px; height: 42px; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; }
.login-card .form-field { margin-bottom: 14px; }
.login-card .btn { width: 100%; height: 42px; margin-top: 6px; }
.remember-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #334155; cursor: pointer; user-select: none; }
.remember-row input { width: 16px; height: 16px; }

.footer-note { margin-top: 18px; color: #94a3b8; font-size: 11px; text-align: center; }

@media (max-width: 1280px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .module-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .sidebar { width: 74px; flex-basis: 74px; padding: 18px 8px; }
  .brand-text, .nav-item span:not(.nav-icon), .sidebar-footer { display: none; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .brand { justify-content: center; padding: 0; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px; }
  .grid-2, .grid-3, .grid-4, .split-2 { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .filter-form input[type="text"], .filter-form input[type="search"] { min-width: 0; width: 100%; }
  .btn-lg { height: 42px; padding: 0 16px; font-size: 14px; }
}

/* Inline table editing and quick stock actions */
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.inline-import {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.inline-import input[type="file"] {
  max-width: 210px;
  font-size: 12px;
  color: #475569;
}
.inline-table td {
  vertical-align: middle;
}
.inline-table { min-width: 1500px; }
.code-cell { white-space: nowrap; font-size: 12px; font-variant-numeric: tabular-nums; }
.code-cell a { white-space: nowrap; }
.spec-matrix { min-width: 1600px; }
.spec-matrix .spec-product-col { position: sticky; left: 0; z-index: 2; background: #fff; min-width: 230px; max-width: 300px; }
.spec-matrix thead .spec-product-col { background: #f8fafc; z-index: 3; }
.spec-matrix .spec-sub { font-size: 11px; color: #64748b; padding: 6px 8px; }
.spec-matrix th small { display: block; font-weight: 400; color: #94a3b8; }
.spec-matrix td .inline-input { min-width: 70px; }
.check-row { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check-row label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: #334155; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.checkbox-grid > div { flex: 0 0 auto; }
.checkbox-grid label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: #334155;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
}
.checkbox-grid input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: #2563eb;
}
table.data-table td input[type="checkbox"] { vertical-align: middle; }
.inline-input {
  width: 100%;
  min-width: 70px;
  height: 32px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #0f172a;
  font: inherit;
  font-size: 13px;
}
.inline-input:hover { border-color: #cbd5e1; background: #f8fafc; }
.inline-input:focus { outline: none; border-color: #60a5fa; background: #fff; box-shadow: 0 0 0 3px rgba(96, 165, 250, .16); }
.inline-input.is-warning { border-color: #f59e0b; background: #fffbeb; }
.inline-input.is-warning:focus { border-color: #d97706; box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
td.is-warning-cell { background: #fffbeb; color: #b45309; font-weight: 600; }
.inline-number { text-align: left; }
.inline-saving { border-color: #93c5fd !important; background: #eff6ff !important; }
.inline-saved { border-color: #86efac !important; background: #f0fdf4 !important; }
.inline-error { border-color: #fca5a5 !important; background: #fef2f2 !important; }
.hidden-csrf { display: none; }
.stock-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }

.app-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .25);
}
.app-dialog::backdrop { background: rgba(15, 23, 42, .45); }

/* Full-page material picker shared by the formula editors and the BOM detail
   forms.  The dialog fills the viewport and its table area scrolls so every
   material column stays visible. */
.material-picker-dialog {
  inset: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
}
.material-picker-dialog[open] { display: flex; }
.material-picker-dialog::backdrop { background: rgba(15, 23, 42, .55); }
.material-picker-shell { display: flex; flex-direction: column; width: 100%; height: 100%; background: var(--panel, #fff); }
.material-picker-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid #e2e8f0; }
.material-picker-head h2 { margin: 0; }
.material-picker-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 20px; border-bottom: 1px solid #e2e8f0; }
.material-picker-toolbar input[type=search] { flex: 1; min-width: 220px; }
.material-picker-table-wrap { flex: 1; overflow: auto; padding: 0 20px; }
.material-picker-table { min-width: 1400px; }
.material-picker-table th { position: sticky; top: 0; z-index: 1; background: #f8fafc; }
.material-picker-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 20px; border-top: 1px solid #e2e8f0; }
.material-picker-table tr { cursor: pointer; }
.material-picker-table tr.mp-selected { background: #eff6ff; }
[data-theme="dark"] .material-picker-shell { background: #0f172a; }
[data-theme="dark"] .material-picker-head,
[data-theme="dark"] .material-picker-toolbar,
[data-theme="dark"] .material-picker-foot { border-color: #334155; }
[data-theme="dark"] .material-picker-table th { background: #1e293b; }
[data-theme="dark"] .material-picker-table tr.mp-selected { background: #1e3a5f; }

.dialog-form { padding: 20px; }
.dialog-form h2 { margin: 0 0 6px; font-size: 18px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.dialog-form .inline-error { min-height: 18px; margin-top: 10px; color: #dc2626; font-size: 12px; }

.announcement-stack { display: grid; gap: 10px; margin-bottom: 16px; }
.announcement-bar { display: flex; justify-content: space-between; gap: 16px; padding: 12px 16px; border: 1px solid #bfdbfe; border-radius: 10px; background: #eff6ff; color: #1e3a8a; }
.announcement-bar .small { margin-top: 4px; color: #1e40af; font-size: 12px; }
.role-bars { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 16px; }
.role-bar { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border: 1px solid #e2e8f0; border-radius: 8px; background: #f8fafc; font-size: 13px; }
.role-bar strong { color: #0f172a; }
.form-grid-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.formula-editor-card { max-width: none; }
.formula-editor-card .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.input-suffix { position: relative; display: flex; align-items: center; }
.input-suffix .unit-input { padding-right: 78px; }
.input-suffix .unit-suffix {
  position: absolute;
  right: 10px;
  color: #64748b;
  font-size: 12px;
  pointer-events: none;
  background: #f8fafc;
  padding-left: 6px;
}
@media (max-width: 1400px) { .formula-editor-card .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .formula-editor-card .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .formula-editor-card .form-grid { grid-template-columns: 1fr; } }
.list-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.list-layout .table-card { min-width: 0; }
.list-sidebar { position: sticky; top: 16px; }
.list-sidebar .card-body { padding: 14px 16px; }
@media (max-width: 1100px) { .list-layout { grid-template-columns: 1fr; } .list-sidebar { position: static; } }
.compact-stat { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid #f1f5f9; }
.compact-stat:last-child { border-bottom: 0; }
.compact-stat strong { font-size: 18px; }
.editor-summary { position: sticky; top: 10px; z-index: 5; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 26px; padding: 13px 18px; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 6px 18px rgba(15, 23, 42, .05); }
.editor-summary.is-warning { border-color: #f59e0b; background: #fffbeb; }
.editor-summary-item { display: flex; align-items: baseline; gap: 6px; }
.editor-summary-item span { color: #64748b; font-size: 13px; }
.editor-summary-item strong { font-size: 22px; color: #0f172a; }
.editor-summary-item em { font-style: normal; color: #64748b; font-size: 12px; }
.editor-summary .muted { margin-left: auto; }
@media (max-width: 700px) { .editor-summary { position: static; } .editor-summary .muted { margin-left: 0; } }
.process-editor-card { max-width: none; }
.process-editor-card .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.check-list ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; max-height: 420px; overflow: auto; }
.check-list li label { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: #334155; }
.check-list input[type="checkbox"] { margin-top: 3px; }
.msds-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.msds-sidebar { position: sticky; top: 16px; }
.msds-sidebar .compact-stat strong { font-size: 16px; }
.msds-sidebar #check-preview { max-height: 240px; overflow: auto; border-top: 1px solid #e2e8f0; padding-top: 8px; }
@media (max-width: 1200px) { .msds-layout { grid-template-columns: 1fr; } .msds-sidebar { position: static; } }
@media (max-width: 1000px) { .process-editor-card .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .process-editor-card .form-grid { grid-template-columns: 1fr; } }


.ai-context { white-space: pre-wrap; word-break: break-word; padding: 14px; border-radius: 9px; background: #f8fafc; border: 1px solid #e2e8f0; color: #334155; font-size: 12px; line-height: 1.7; }
.ai-result { white-space: pre-wrap; line-height: 1.8; color: #0f172a; }

.chart-row { display: grid; grid-template-columns: 120px 1fr 42px; gap: 10px; align-items: center; margin: 9px 0; font-size: 13px; }
.chart-track { height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.chart-track i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #38bdf8, #2563eb); }
.chart-row strong { text-align: right; color: #0f172a; }
.pie-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.pie { width: 160px; height: 160px; border-radius: 50%; flex: 0 0 160px; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08); }
.pie-legend { display: grid; gap: 6px; font-size: 12px; color: #475569; min-width: 150px; }
.pie-legend div { display: flex; align-items: center; gap: 6px; }
.pie-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.pie-legend strong { color: #0f172a; }
.pie-legend span { color: #94a3b8; }

.ai-filled { background: #fffbeb !important; border-color: #fde68a !important; }
.ai-filled:focus { background: #fff !important; border-color: #f59e0b !important; }

.ai-suggested { background: #eff6ff !important; border-color: #93c5fd !important; }
.ai-suggested:focus { background: #fff !important; border-color: #2563eb !important; }

.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--primary, #2563eb); }
.sort-indicator { display: inline-block; margin-left: 4px; font-size: 11px; color: #94a3b8; }
.sort-link:hover .sort-indicator { color: inherit; }

.btn-small { padding: 5px 10px; font-size: 12px; }
.actions form { display: inline-flex; margin: 0; }

.schedule-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.schedule-summary-item { background: #fff; border: 1px solid var(--border, #e2e8f0); border-radius: 10px; padding: 10px 12px; }
.schedule-summary-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 12px; color: #64748b; }
.schedule-summary-head strong { color: #0f172a; }
.schedule-board-wrap { overflow: auto; border: 1px solid var(--border, #e2e8f0); border-radius: 12px; background: #fff; }
.schedule-board { width: 100%; min-width: 1500px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.schedule-board th, .schedule-board td { border-right: 1px solid #eef2f7; border-bottom: 1px solid #eef2f7; }
.schedule-board thead th { position: sticky; top: 0; z-index: 2; background: #f8fafc; padding: 8px 6px; font-size: 12px; font-weight: 600; color: #475569; text-align: center; }
.schedule-board thead th small { display: block; margin-top: 2px; color: #94a3b8; font-weight: 400; }
.schedule-line-head, .schedule-line-cell { position: sticky; left: 0; z-index: 1; width: 130px; min-width: 130px; background: #f8fafc; padding: 10px; text-align: left; font-size: 12px; color: #334155; }
.schedule-line-cell { vertical-align: top; }
.schedule-cell { width: 105px; min-width: 105px; height: 92px; padding: 5px; vertical-align: top; background: #fff; transition: background .15s, box-shadow .15s; }
.schedule-cell.drag-over { background: #eff6ff; box-shadow: inset 0 0 0 2px #60a5fa; }
.schedule-cell.schedule-today { background: #fffdf5; }
.schedule-cell.is-nonwork { background-image: repeating-linear-gradient(135deg, rgba(148, 163, 184, .10) 0 6px, rgba(255, 255, 255, 0) 6px 12px); }
.schedule-cell.is-occupied { background-color: #e0ecff; }
.schedule-cell.is-occupied.schedule-today { background-color: #fdf3d8; }
.schedule-cell.is-nonwork.is-occupied { background-color: #dbe7f6; }
.schedule-board thead th.schedule-weekend { color: #b45309; background: #fef7e8; }
#schedule-unscheduled.drag-over { box-shadow: inset 0 0 0 2px #60a5fa; background: #eff6ff; }
.schedule-card.spanning { border-left-color: #2563eb; box-shadow: 0 0 0 1px rgba(37, 99, 235, .18); }
.schedule-card { background: #f8fafc; border: 1px solid #dbe4f0; border-left: 3px solid #64748b; border-radius: 7px; padding: 6px 7px; margin-bottom: 5px; font-size: 11px; line-height: 1.35; cursor: grab; }
.schedule-card[draggable="false"] { cursor: default; }
.schedule-card:hover { background: #fff; box-shadow: 0 2px 8px rgba(15, 23, 42, .08); }
.schedule-card:active { cursor: grabbing; }

/* Read-only detail pages: tighter spacing and smaller type so everything fits on one screen. */
.detail-compact .detail-head { padding: 12px 16px; }
.detail-compact .detail-head h1 { font-size: 19px; margin-bottom: 3px; }
.detail-compact .detail-head .sub { font-size: 12px; gap: 6px; }
.detail-compact .detail-head .actions { gap: 6px; flex-wrap: wrap; }
.detail-compact .detail-head .actions .btn { padding: 4px 9px; font-size: 12px; }
.detail-compact .info-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.detail-compact .info-item { padding: 6px 10px; min-height: 0; }
.detail-compact .info-item .label { font-size: 10px; margin-bottom: 2px; }
.detail-compact .info-item .value { font-size: 12px; font-weight: 500; line-height: 1.35; }
.detail-compact .card-head { padding: 8px 12px; }
.detail-compact .card-head h2 { font-size: 13px; }
.detail-compact .card-head .sub { font-size: 10px; }
.detail-compact .section { margin-top: 10px; }
.detail-compact table.data-table { font-size: 11px; }
.detail-compact table.data-table th { padding: 4px 7px; font-size: 10px; }
.detail-compact table.data-table td { padding: 4px 7px; font-size: 11px; line-height: 1.3; }
.detail-compact .empty-state { padding: 8px; font-size: 11px; }
.detail-compact .card-pad { padding: 10px 12px; }
.detail-compact .card-body.tight { padding: 0; }
.detail-compact .badge { font-size: 9px; padding: 1px 6px; }

@media (max-width: 1100px) {
  .detail-compact .info-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .detail-compact .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.schedule-card.dragging { opacity: .45; }
.schedule-card.saving { opacity: .6; }
.schedule-card.overdue { border-left-color: #dc2626; background: #fef2f2; }
.schedule-card a { display: block; color: #1d4ed8; font-weight: 600; text-decoration: none; margin-bottom: 2px; }
.schedule-product { color: #0f172a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-meta { color: #64748b; margin-top: 2px; }
.unscheduled-list { display: flex; flex-wrap: wrap; gap: 8px; }
.unscheduled-list .schedule-card { width: 190px; margin: 0; }

/* BOM dilution helpers */
.bom-context-menu {
  position: fixed;
  z-index: 60;
  min-width: 150px;
  padding: 4px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
}
.bom-context-menu button {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #0f172a;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.bom-context-menu button:hover { background: #f1f5f9; }
.bom-context-menu button.danger { color: #b91c1c; }
.bom-dilution.is-warning { color: #94a3b8; }

.schedule-day-loads { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; }
.schedule-day-load { border: 1px solid #eef2f7; border-radius: 8px; padding: 7px; background: #f8fafc; }
.schedule-day-head { display: flex; justify-content: space-between; gap: 4px; font-size: 12px; margin-bottom: 5px; }
.schedule-day-head strong { color: #0f172a; }

.json-mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.json-mini-table th, .json-mini-table td { border-bottom: 1px solid #eef2f7; padding: 4px 6px; text-align: left; vertical-align: top; }
.json-mini-table th { color: #64748b; font-weight: 500; width: 38%; white-space: nowrap; }
.json-mini-list { margin: 0; padding-left: 18px; font-size: 12px; }
.json-mini-list li { margin: 2px 0; }

.ai-material-table { min-width: 1900px; }
.ai-material-table td { vertical-align: middle; }
.ai-material-table .inline-input { min-width: 90px; }
.ai-suggested { background: #fffbeb; }

.msds-table { table-layout: fixed; min-width: 900px; }
.msds-table th, .msds-table td { padding: 6px 7px; }
.msds-table .msds-check-col { width: 42px; }
.msds-raw-table th:nth-child(2) { width: 25%; }
.msds-raw-table th:nth-child(3) { width: 22%; }
.msds-raw-table th:nth-child(4) { width: 16%; }
.msds-raw-table th:nth-child(5) { width: 11%; }
.msds-aux-table th:nth-child(2) { width: 25%; }
.msds-aux-table th:nth-child(3) { width: 20%; }
.msds-aux-table th:nth-child(4) { width: 14%; }
.msds-aux-table th:nth-child(5) { width: 13%; }
.msds-table input.inline-number, .msds-table input[type="number"] { width: 100%; min-width: 0; }
.msds-table input:not([type="number"]):not([type="checkbox"]) { width: 100%; min-width: 0; }
.msds-unit-cell { white-space: nowrap; color: #475569; font-size: 12px; }
.msds-unit-col { width: 64px; }
.msds-alias-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid #e2e8f0; }

.diss-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.diss-record-panel { max-height: 760px; display: flex; flex-direction: column; }
.diss-record-list { overflow: auto; padding: 4px 12px 12px; }
.diss-record-item { display: flex; gap: 8px; align-items: flex-start; padding: 8px 4px; border-bottom: 1px solid #f1f5f9; font-size: 12px; cursor: pointer; }
.diss-record-item span { display: grid; gap: 2px; }
.diss-record-item small { color: #64748b; }
.diss-select-all { display: flex; gap: 8px; align-items: center; padding: 8px 16px 4px; font-size: 12px; color: #334155; }
.diss-controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 10px; font-size: 12px; color: #334155; }
.diss-controls label { display: grid; gap: 4px; }
.diss-controls input[type="number"] { width: 82px; height: 32px; padding: 0 6px; border: 1px solid #e2e8f0; border-radius: 8px; }
.diss-controls select { height: 32px; padding: 0 6px; border: 1px solid #e2e8f0; border-radius: 8px; }
.diss-controls .diss-check { display: flex; align-items: center; gap: 5px; padding-bottom: 8px; }
.diss-chart-wrap { width: 100%; overflow: hidden; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; }
#dissolution-chart { width: 100%; height: auto; display: block; }
.print-report-head { display: none; }
.print-only { display: none; }
@media (max-width: 1100px) { .diss-layout { grid-template-columns: 1fr; } .diss-record-panel { max-height: 320px; } }
@media print {
  .print-hide, .sidebar, .topbar, nav, .toolbar, .page-head { display: none !important; }
  .print-report-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; border-bottom: 2px solid #0f172a; padding-bottom: 8px; }
  .print-only { display: block; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .diss-layout { display: block; }
  .diss-chart-panel { border: none; padding: 0; }
  .diss-chart-wrap { border: 1px solid #cbd5e1; }
  .card { box-shadow: none; }
  table.data-table td, table.data-table th { white-space: normal; word-break: break-word; }
  table.data-table th.actions, table.data-table td.actions { position: static; box-shadow: none; }
}

/* Home page manual entry */
.manual-entry-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.manual-entry-head h3 { margin: 0 0 4px; font-size: 18px; }
.manual-entry-head p { margin: 0; color: #64748b; font-size: 13px; line-height: 1.7; max-width: 760px; }
.manual-entry-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.manual-entry-tabs a { display: inline-flex; align-items: center; padding: 5px 12px; border: 1px solid #e2e8f0; border-radius: 999px; background: #f8fafc; color: #334155; font-size: 12.5px; }
.manual-entry-tabs a:hover { border-color: #0f766e; color: #0f766e; background: #f0fdfa; }
