/* ==========================================================================
   Computron Admin — light design system
   Replaces the Tailwind Play CDN (not intended for production) with a small,
   cacheable stylesheet. Calm neutral surfaces, one soft indigo accent,
   generous spacing, and semantic tones for status.
   ========================================================================== */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --border: #e6e8ef;
  --border-strong: #d5d9e3;
  --ink: #1d2433;
  --ink-2: #454e61;
  --muted: #737b8c;
  --faint: #9aa1af;

  --primary: #4f63d9;
  --primary-hover: #4053c4;
  --primary-soft: #eef0fc;
  --primary-ink: #3645ad;

  --green: #16875a;   --green-soft: #e8f6ef;
  --amber: #a86a04;   --amber-soft: #fdf4e3;
  --red: #c2413d;     --red-soft: #fcecec;
  --blue: #2667b8;    --blue-soft: #e9f1fb;
  --violet: #6a4fc4;  --violet-soft: #f1edfb;
  --gray: #5c6475;    --gray-soft: #f0f2f5;

  --brand: #c41e1e;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --sidebar-w: 248px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; }
p { margin: 0; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
@media (min-width: 1025px) {
  /* keep the white sidebar column full-height even on very long pages */
  .app { background: linear-gradient(to right, var(--surface) calc(var(--sidebar-w) - 1px), var(--border) calc(var(--sidebar-w) - 1px), var(--border) var(--sidebar-w), transparent var(--sidebar-w)); }
}
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; font-weight: 800;
  display: grid; place-items: center; font-size: 13px; letter-spacing: .02em;
}
.brand-name { font-weight: 750; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; }
.nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; }
.nav-group { margin-top: 14px; }
.nav-label { font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 0 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 520; font-size: 13.5px; text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 620; }
.nav a svg { width: 17px; height: 17px; flex-shrink: 0; stroke: currentColor; }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 650; background: var(--red-soft); color: var(--red); border-radius: 99px; padding: 1px 7px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 18px 32px; background: var(--bg);
  position: sticky; top: 0; z-index: 30; border-bottom: 1px solid transparent;
}
.topbar.scrolled { background: rgba(245, 246, 250, .92); backdrop-filter: blur(8px); border-bottom-color: var(--border); }
.topbar .titles { flex: 1; min-width: 0; }
.topbar .subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar .menu-btn { display: none; }
.content { padding: 8px 32px 48px; }
.backdrop { display: none; }

/* ---------- Layout helpers ---------- */
.grid { display: grid; gap: 20px; }
.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-kpi { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: 6px } .mt-2 { margin-top: 12px } .mt-3 { margin-top: 20px } .mt-4 { margin-top: 28px }
.mb-2 { margin-bottom: 12px } .mb-3 { margin-bottom: 20px }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12.5px; } .xs { font-size: 11.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; } .center { text-align: center; }
.strong { font-weight: 650; } .nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.hidden { display: none !important; }
.up { color: var(--green); } .down { color: var(--red); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 15px; }
.card-head .hint { font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 12px 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card.flush .card-body { padding: 0; }
.section-title { font-size: 13px; font-weight: 650; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; margin: 4px 0 12px; }

/* ---------- KPI tiles ---------- */
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi-sub { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delta { font-weight: 650; font-size: 12px; padding: 1px 6px; border-radius: 6px; }
.delta.up { background: var(--green-soft); color: var(--green); }
.delta.down { background: var(--red-soft); color: var(--red); }
.delta.flat { background: var(--gray-soft); color: var(--gray); }
a.kpi { color: inherit; text-decoration: none; transition: border-color .15s; }
a.kpi:hover { border-color: var(--border-strong); text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 580; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--red); border-color: #efcaca; }
.btn-danger:hover { background: var(--red-soft); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(.95); background: var(--green); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--gray-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary-ink); cursor: pointer; font-weight: 580; }
.link-btn.danger { color: var(--red); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px;
  font-weight: 600; line-height: 1.6; white-space: nowrap; background: var(--gray-soft); color: var(--gray);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badge.gray { background: var(--gray-soft); color: var(--gray); }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid; font-size: 13.5px; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; stroke: currentColor; }
.alert.success { background: var(--green-soft); border-color: #c6e8d6; color: #0f6644; }
.alert.danger { background: var(--red-soft); border-color: #f1cdcc; color: #9a2f2c; }
.alert.warning { background: var(--amber-soft); border-color: #f2dfb6; color: #7d4f03; }
.alert.info { background: var(--blue-soft); border-color: #cddff4; color: #1d4f8c; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* Business alert list on the dashboard */
.alert-list { display: flex; flex-direction: column; }
.alert-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 20px; border-top: 1px solid var(--border); }
.alert-item:first-child { border-top: 0; }
.alert-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.dot.critical { background: #d03b3b; } .dot.warning { background: #e3a008; } .dot.info { background: var(--blue); } .dot.good { background: #0ca30c; }
.alert-item .t { font-weight: 600; }
.alert-item .d { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.alert-item .go { margin-left: auto; flex-shrink: 0; font-size: 12.5px; font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.table th.right, .table td.right { text-align: right; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--ink); }
.table th[data-sort]::after { content: " ↕"; opacity: .35; font-size: 11px; }
.table th[data-dir="asc"]::after { content: " ↑"; opacity: 1; }
.table th[data-dir="desc"]::after { content: " ↓"; opacity: 1; }
.table.compact td, .table.compact th { padding: 8px 14px; }
.table .thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); }
.table .sub { font-size: 12px; color: var(--muted); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; stroke: var(--faint); margin-bottom: 8px; }
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.bar-cell .bar { height: 6px; border-radius: 3px; background: var(--primary); opacity: .75; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13.5px; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737b8c' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 99, 217, .15); }
.input-sm { height: 32px; font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; }
.errors { color: var(--red); font-size: 12px; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.toolbar .field { min-width: 150px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 550; text-decoration: none; white-space: nowrap;
}
.pill:hover { border-color: var(--border-strong); text-decoration: none; }
.pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pill .n { font-size: 11.5px; opacity: .8; }
.segmented { display: inline-flex; background: var(--gray-soft); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented a { padding: 5px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.segmented a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-weight: 580; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; font-size: 13.5px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--primary-ink); border-bottom-color: var(--primary); }

/* ---------- Definition list ---------- */
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 13.5px; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.totals { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.totals .line { display: flex; justify-content: space-between; }
.totals .grand { border-top: 1px solid var(--border); padding-top: 10px; font-size: 16px; font-weight: 700; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .node { position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.timeline .node.done { background: var(--primary); }
.timeline .node.muted { border-color: var(--border-strong); }
.timeline .node.red { border-color: var(--red); background: var(--red); }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .what { font-weight: 600; }
.timeline .note { font-size: 13px; color: var(--ink-2); margin-top: 2px; }

/* Order progress stepper */
.stepper { display: flex; gap: 0; overflow-x: auto; padding-bottom: 4px; }
.stepper .step { flex: 1; min-width: 88px; text-align: center; position: relative; font-size: 11.5px; color: var(--muted); font-weight: 550; }
.stepper .step::before { content: ""; position: absolute; top: 9px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.stepper .step:first-child::before { display: none; }
.stepper .step .c { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); margin: 0 auto 6px; position: relative; z-index: 1; }
.stepper .step.done { color: var(--ink); }
.stepper .step.done .c { background: var(--primary); border-color: var(--primary); }
.stepper .step.done::before { background: var(--primary); }
.stepper .step.current .c { box-shadow: 0 0 0 4px var(--primary-soft); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination a, .pagination span.p { min-width: 32px; height: 32px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; color: var(--ink-2); text-decoration: none; background: var(--surface); }
.pagination a:hover { border-color: var(--border-strong); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .disabled { opacity: .45; }

/* ---------- Misc ---------- */
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; } .chart-box.lg { height: 340px; }
.legend-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.progress { height: 6px; background: var(--gray-soft); border-radius: 3px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.progress.green > span { background: var(--green); } .progress.amber > span { background: #e3a008; } .progress.red > span { background: var(--red); }
.kbd { font-family: var(--mono); font-size: 11.5px; background: var(--gray-soft); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.tag { display: inline-block; font-size: 11.5px; background: var(--gray-soft); color: var(--ink-2); border-radius: 6px; padding: 1px 7px; margin: 1px 2px 1px 0; }
.insight { display: flex; gap: 14px; padding: 16px 20px; border-top: 1px solid var(--border); }
.insight:first-child { border-top: 0; }
.insight .icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.insight .icon svg { width: 18px; height: 18px; stroke: currentColor; }
.insight .icon.good { background: var(--green-soft); color: var(--green); }
.insight .icon.warning { background: var(--amber-soft); color: var(--amber); }
.insight .icon.critical { background: var(--red-soft); color: var(--red); }
.insight .icon.info { background: var(--blue-soft); color: var(--blue); }
.insight .title { font-weight: 650; }
.insight .detail { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }
.insight .action { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.ai-answer { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; line-height: 1.65; }
.ai-answer p + p { margin-top: 8px; }
.ai-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 650; color: var(--violet); background: var(--violet-soft); padding: 2px 8px; border-radius: 99px; }
.suggestions { display: flex; gap: 8px; flex-wrap: wrap; }
.suggestions button { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.suggestions button:hover { border-color: var(--primary); color: var(--primary-ink); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
details.more summary { cursor: pointer; color: var(--primary-ink); font-weight: 580; font-size: 13px; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
dialog.modal { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--ink); }
dialog.modal::backdrop { background: rgba(29, 36, 51, .35); }
.modal .card-head { border-radius: var(--radius) var(--radius) 0 0; }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 500px at 50% -10%, #e9ecfb, transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; }

/* Print (invoices / reports) */
@media print {
  .sidebar, .topbar .actions, .no-print, .menu-btn { display: none !important; }
  .content { padding: 0; } body { background: #fff; }
  .card { box-shadow: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: span 2; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease, visibility .2s; visibility: hidden; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); visibility: visible; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(29, 36, 51, .3); z-index: 35; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 14px 20px; }
  .content { padding: 8px 20px 40px; }
}
@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4, .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2, .span-3 { grid-column: auto; }
  .topbar { flex-wrap: wrap; }
  .topbar .actions { width: 100%; justify-content: flex-start; }
  .kpi-value { font-size: 19px; }
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .dl { grid-template-columns: 110px 1fr; }
  .card-head, .card-body { padding-left: 16px; padding-right: 16px; }
  .table td, .table th { padding-left: 12px; padding-right: 12px; }
  .toolbar .field { min-width: 0; flex: 1 1 140px; }
}

/* ==========================================================================
   Round 8 — theming, command palette, collapsible rail, board, sparklines
   ========================================================================== */
:root { --row-hover: #fafbfd; --topbar-glass: rgba(245, 246, 250, .92); --chart-grid: #eceef3; --chart-axis: #d5d9e3; color-scheme: light; }

/* Dark theme: same tokens, re-stepped for a dark surface (not an automatic inversion). */
:root[data-theme="dark"] {
  --bg: #0e121c; --surface: #151a27; --surface-2: #1a2030; --border: #252c3f; --border-strong: #323a52;
  --ink: #e7eaf2; --ink-2: #c1c6d4; --muted: #8b92a6; --faint: #697086;
  --primary: #7c8cff; --primary-hover: #8e9cff; --primary-soft: rgba(124, 140, 255, .15); --primary-ink: #b0baff;
  --green: #3fcf8e; --green-soft: rgba(63, 207, 142, .13);
  --amber: #f0b54f; --amber-soft: rgba(240, 181, 79, .13);
  --red: #ff6d68; --red-soft: rgba(255, 109, 104, .13);
  --blue: #6fabff; --blue-soft: rgba(111, 171, 255, .13);
  --violet: #b39fff; --violet-soft: rgba(179, 159, 255, .15);
  --gray: #a4aabb; --gray-soft: rgba(164, 170, 187, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35); --shadow-lg: 0 18px 44px rgba(0, 0, 0, .5);
  --row-hover: #1a2030; --topbar-glass: rgba(14, 18, 28, .88); --chart-grid: #232a3c; --chart-axis: #323a52;
  color-scheme: dark;
}
.table tbody tr:hover { background: var(--row-hover); }
.topbar.scrolled { background: var(--topbar-glass); }
:root[data-theme="dark"] .alert.success { border-color: rgba(63, 207, 142, .3); color: var(--green); }
:root[data-theme="dark"] .alert.danger { border-color: rgba(255, 109, 104, .3); color: var(--red); }
:root[data-theme="dark"] .alert.warning { border-color: rgba(240, 181, 79, .3); color: var(--amber); }
:root[data-theme="dark"] .alert.info { border-color: rgba(111, 171, 255, .3); color: var(--blue); }
:root[data-theme="dark"] .auth-wrap { background: radial-gradient(1200px 500px at 50% -10%, #1b2240, transparent), var(--bg); }
:root[data-theme="dark"] .btn-danger { border-color: rgba(255, 109, 104, .35); }
:root[data-theme="dark"] img.thumb { background: var(--surface-2); }

/* Icon buttons in the top bar */
.icon-btn { width: 36px; padding: 0; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

/* Search trigger (opens the command palette) */
.search-trigger {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 12px; min-width: 240px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted);
  font: inherit; font-size: 13px; cursor: pointer;
}
.search-trigger:hover { border-color: var(--primary); color: var(--ink-2); }
.search-trigger svg { width: 15px; height: 15px; stroke: currentColor; }
.search-trigger .kbd { margin-left: auto; }

/* Command palette */
dialog.cmdk { border: 0; padding: 0; width: min(640px, calc(100vw - 24px)); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); margin-top: 10vh; }
dialog.cmdk::backdrop { background: rgba(10, 14, 24, .45); backdrop-filter: blur(2px); }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cmdk-input svg { width: 18px; height: 18px; stroke: var(--muted); flex-shrink: 0; }
.cmdk-input input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 15px; }
.cmdk-list { max-height: min(60vh, 460px); overflow-y: auto; padding: 6px; }
.cmdk-group { font-size: 11px; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 10px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; cursor: pointer; }
.cmdk-item:hover { text-decoration: none; }
.cmdk-item[aria-selected="true"] { background: var(--primary-soft); color: var(--primary-ink); }
.cmdk-item svg { width: 16px; height: 16px; stroke: currentColor; flex-shrink: 0; opacity: .8; }
.cmdk-item .meta { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.cmdk-item .sub { font-size: 12px; color: var(--muted); }
.cmdk-empty { padding: 28px; text-align: center; color: var(--muted); font-size: 13.5px; }
.cmdk-foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }

/* Collapsible sidebar rail (desktop) */
@media (min-width: 1025px) {
  html.rail { --sidebar-w: 72px; }
  html.rail .brand > div:last-child, html.rail .nav-label, html.rail .nav .lbl, html.rail .sidebar-foot .who, html.rail .nav .count { display: none; }
  html.rail .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  html.rail .nav { padding: 6px 10px; }
  html.rail .nav a { justify-content: center; padding: 10px 0; position: relative; }
  html.rail .nav a[data-count]::after { content: ""; position: absolute; top: 7px; right: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
  html.rail .nav-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
  html.rail .nav-group:first-child { border-top: 0; }
  html.rail .sidebar-foot { flex-direction: column; padding: 12px 8px; }
}
.rail-btn { display: none; }
@media (min-width: 1025px) { .rail-btn { display: inline-flex; } }

/* Live "today" strip */
.live-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0; }
.live-strip > div { padding: 14px 20px; border-left: 1px solid var(--border); }
.live-strip > div:first-child { border-left: 0; }
.live-strip .v { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.live-strip .l { font-size: 12px; color: var(--muted); font-weight: 550; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #0ca30c; display: inline-block; box-shadow: 0 0 0 0 rgba(12, 163, 12, .5); animation: livepulse 2s infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(12, 163, 12, .45); } 70% { box-shadow: 0 0 0 8px rgba(12, 163, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
@media (max-width: 720px) { .live-strip > div { border-left: 0; border-top: 1px solid var(--border); } .live-strip > div:first-child { border-top: 0; } }

/* KPI sparkline */
.spark { display: block; width: 100%; height: 32px; margin-top: 2px; overflow: visible; }
.spark path.line { fill: none; stroke: var(--primary); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.spark path.area { fill: var(--primary-soft); stroke: none; }
.spark circle { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }

/* Fulfilment board */
.board { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 16px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 200px; }
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 650; }
.board-col-head .n { margin-left: auto; font-size: 12px; font-weight: 650; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 0 8px; }
.board-col-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.ocard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; box-shadow: var(--shadow); }
.ocard.late { border-left: 3px solid var(--red); }
.ocard .top { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.ocard .items { font-size: 12.5px; color: var(--ink-2); margin: 6px 0; }
.ocard .foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ocard form { margin-left: auto; }
@media (max-width: 1024px) { .board { grid-template-columns: repeat(4, minmax(240px, 80vw)); } }

/* Status pills with icons for the payments page */
.status-line { display: flex; align-items: center; gap: 8px; }
.status-line .ok { color: var(--green); } .status-line .bad { color: var(--red); }
@media (max-width: 900px) { .hide-sm { display: none !important; } }
.show-sm { display: none !important; }
@media (max-width: 900px) { .show-sm { display: inline-flex !important; } }
