/* ════════════════════════════════════════════════════════════════════════════
   AKUMA 4X4 — INTERNAL HUB DESIGN SYSTEM  v1
   One set of tokens, two themes. Nothing below hardcodes a colour.

   Theme:  <html data-theme="light">  |  "dark"  |  absent = follow the OS
   Type:   Inter for UI, tabular numerals everywhere a figure appears,
           Archivo Black kept for the wordmark only.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── tokens ──────────────────────────────────────────────────────────────── */

:root {
  /* type scale — 14px base, 13px in dense tables */
  --fs-11: 11px;  --fs-12: 12px;  --fs-13: 13px;  --fs-14: 14px;
  --fs-16: 16px;  --fs-18: 18px;  --fs-20: 20px;  --fs-24: 24px;  --fs-30: 30px;
  --lh-tight: 1.25;  --lh: 1.5;  --lh-loose: 1.65;

  /* spacing — 4px base */
  --s1: 4px;  --s2: 8px;  --s3: 12px;  --s4: 16px;  --s5: 20px;
  --s6: 24px; --s7: 32px; --s8: 40px; --s9: 48px;  --s10: 64px;

  --r-sm: 6px;  --r: 8px;  --r-lg: 12px;  --r-full: 999px;

  --ff: "Inter", -apple-system, "Segoe UI Variable Text", "Segoe UI",
        Roboto, system-ui, sans-serif;
  --ff-brand: "Archivo Black", var(--ff);
  --ff-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;

  --nav-w: 232px;
  --topbar-h: 56px;
  --speed: 140ms;
}

/* ── light (default) ─────────────────────────────────────────────────────── */

:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg:            #f5f6f8;
  --surface:       #ffffff;
  --surface-2:     #fafbfc;
  --surface-3:     #f0f2f5;
  --surface-hover: #f5f7fa;

  --border:        #e3e6ea;
  --border-strong: #cfd4db;

  --text:    #14161a;
  --text-2:  #596072;
  --text-3:  #878e9d;
  --text-on-accent: #ffffff;

  --accent:       #d10000;
  --accent-hover: #a80000;
  --accent-soft:  #fdecec;
  --accent-line:  #f6c9c9;

  --ok:        #0b7a45;   --ok-soft:     #e7f6ee;   --ok-line:     #b7e3cb;
  --warn:      #9a5b00;   --warn-soft:   #fdf2df;   --warn-line:   #f2d9a8;
  --danger:    #be1f1f;   --danger-soft: #fdeaea;   --danger-line: #f4c4c4;
  --info:      #1560c4;   --info-soft:   #e8f1fd;   --info-line:   #bcd7f7;

  --shadow-1: 0 1px 2px rgba(16,20,30,.06), 0 1px 3px rgba(16,20,30,.04);
  --shadow-2: 0 2px 6px rgba(16,20,30,.07), 0 8px 20px rgba(16,20,30,.06);
  --shadow-3: 0 10px 34px rgba(16,20,30,.14);
  --ring: 0 0 0 3px rgba(209,0,0,.16);
}

/* ── dark ────────────────────────────────────────────────────────────────── */

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:            #0c0d10;
  --surface:       #15171c;
  --surface-2:     #1a1d23;
  --surface-3:     #21252c;
  --surface-hover: #1f232a;

  --border:        #262a32;
  --border-strong: #363c46;

  --text:    #eceef2;
  --text-2:  #a0a8b6;
  --text-3:  #757d8c;
  --text-on-accent: #ffffff;

  --accent:       #ff453a;
  --accent-hover: #ff6961;
  --accent-soft:  #2a1010;
  --accent-line:  #4d1c1c;

  --ok:        #3ecf8e;   --ok-soft:     #0f2a1e;   --ok-line:     #1d5138;
  --warn:      #f0a92b;   --warn-soft:   #2d2109;   --warn-line:   #554112;
  --danger:    #ff6b5e;   --danger-soft: #2d1211;   --danger-line: #542120;
  --info:      #5aa2ff;   --info-soft:   #0f1e33;   --info-line:   #1e3c63;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 2px 8px rgba(0,0,0,.45), 0 10px 26px rgba(0,0,0,.35);
  --shadow-3: 0 12px 38px rgba(0,0,0,.6);
  --ring: 0 0 0 3px rgba(255,69,58,.26);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:#0c0d10; --surface:#15171c; --surface-2:#1a1d23; --surface-3:#21252c;
    --surface-hover:#1f232a; --border:#262a32; --border-strong:#363c46;
    --text:#eceef2; --text-2:#a0a8b6; --text-3:#757d8c;
    --accent:#ff453a; --accent-hover:#ff6961; --accent-soft:#2a1010; --accent-line:#4d1c1c;
    --ok:#3ecf8e; --ok-soft:#0f2a1e; --ok-line:#1d5138;
    --warn:#f0a92b; --warn-soft:#2d2109; --warn-line:#554112;
    --danger:#ff6b5e; --danger-soft:#2d1211; --danger-line:#542120;
    --info:#5aa2ff; --info-soft:#0f1e33; --info-line:#1e3c63;
    --shadow-1:0 1px 2px rgba(0,0,0,.4);
    --shadow-2:0 2px 8px rgba(0,0,0,.45), 0 10px 26px rgba(0,0,0,.35);
    --shadow-3:0 12px 38px rgba(0,0,0,.6);
    --ring:0 0 0 3px rgba(255,69,58,.26);
  }
}

/* ── base ────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-14)/var(--lh) var(--ff);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Figures line up in columns. This is the single biggest readability win
   in a system where people scan quantities down a page. */
.num, td.num, th.num, .stat-v, .tnum, input[type="number"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv05" 1;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: var(--lh-tight); letter-spacing: -.011em; }
h1 { font-size: var(--fs-20); }
h2 { font-size: var(--fs-16); }
h3 { font-size: var(--fs-14); }
p  { margin: 0 0 var(--s3); }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd, .mono { font-family: var(--ff-mono); font-size: .92em; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

.muted   { color: var(--text-2); }
.faint   { color: var(--text-3); }
.small   { font-size: var(--fs-12); }
.label   { font-size: var(--fs-11); font-weight: 600; letter-spacing: .06em;
           text-transform: uppercase; color: var(--text-3); }
.right   { text-align: right; }
.nowrap  { white-space: nowrap; }
.spacer  { flex: 1; }
.hide    { display: none !important; }

/* ── app shell ───────────────────────────────────────────────────────────── */

.app { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }

.nav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.nav-brand {
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s4); border-bottom: 1px solid var(--border); flex: none;
}
.nav-brand .mark {
  font-family: var(--ff-brand); font-size: var(--fs-13); letter-spacing: .02em;
  color: var(--text);
}
.nav-brand .mark b { color: var(--accent); }

.nav-group { padding: var(--s4) var(--s2) var(--s1); }
.nav-group .label { padding: 0 var(--s3) var(--s2); display: block; }

.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3); margin: 1px var(--s1);
  border-radius: var(--r-sm); color: var(--text-2);
  font-size: var(--fs-13); font-weight: 500;
  cursor: pointer; border: 0; background: none; width: calc(100% - var(--s2));
  text-align: left; transition: background var(--speed), color var(--speed);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.on    { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ico  { width: 16px; height: 16px; flex: none; opacity: .85; }
.nav-item .count {
  margin-left: auto; font-size: var(--fs-11); font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
  padding: 1px 7px; border-radius: var(--r-full);
}
.nav-item.on .count { background: var(--accent); color: var(--text-on-accent); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s6);
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: var(--fs-16); }
.topbar .sub { font-size: var(--fs-12); color: var(--text-3); }

.content { padding: var(--s6); max-width: 1400px; width: 100%; }
.content.wide { max-width: none; }

.page-head { margin-bottom: var(--s5); }
.page-head h1 { margin-bottom: var(--s1); }
.page-head p  { color: var(--text-2); margin: 0; font-size: var(--fs-13); }

/* ── cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.card + .card { margin-top: var(--s4); }
.card-head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border);
}
.card-head h2 { flex: none; }
.card-head .sub { font-size: var(--fs-12); color: var(--text-3); }
.card-body { padding: var(--s5); }
.card-body.flush { padding: 0; }
.card-foot {
  padding: var(--s3) var(--s5); border-top: 1px solid var(--border);
  background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg);
  font-size: var(--fs-12); color: var(--text-2);
}

/* ── stat tiles ──────────────────────────────────────────────────────────── */

.stats { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s4) var(--s5);
  box-shadow: var(--shadow-1); text-align: left;
  cursor: default; transition: border-color var(--speed), box-shadow var(--speed);
}
.stat.click { cursor: pointer; }
.stat.click:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.stat.on { border-color: var(--accent); box-shadow: var(--ring); }
.stat-v { font-size: var(--fs-24); font-weight: 660; line-height: 1.1; letter-spacing: -.02em; }
.stat-k { font-size: var(--fs-12); color: var(--text-2); margin-top: var(--s1); }
.stat.is-danger .stat-v { color: var(--danger); }
.stat.is-warn   .stat-v { color: var(--warn); }
.stat.is-ok     .stat-v { color: var(--ok); }

/* ── tables ──────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
table.t th {
  text-align: left; font-size: var(--fs-11); font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; color: var(--text-3);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border);
  background: var(--surface-2); position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
table.t th.sortable { cursor: pointer; user-select: none; }
table.t th.sortable:hover { color: var(--text); }
table.t th .arrow { opacity: .4; margin-left: 3px; }
table.t td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); vertical-align: top; }
table.t tbody tr:hover { background: var(--surface-hover); }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t .strong { font-weight: 600; color: var(--text); }
table.t .sub { font-size: var(--fs-12); color: var(--text-3); margin-top: 2px; }
table.t .sku { font-family: var(--ff-mono); font-size: var(--fs-12); font-weight: 600; }

/* ── badges ──────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: var(--fs-11); font-weight: 600; line-height: 1.6;
  border: 1px solid var(--border); background: var(--surface-3); color: var(--text-2);
  white-space: nowrap;
}
.badge.ok     { background: var(--ok-soft);     color: var(--ok);     border-color: var(--ok-line); }
.badge.warn   { background: var(--warn-soft);   color: var(--warn);   border-color: var(--warn-line); }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.badge.info   { background: var(--info-soft);   color: var(--info);   border-color: var(--info-line); }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* ── buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 8px 14px; border-radius: var(--r-sm);
  font: 600 var(--fs-13)/1.2 var(--ff);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background var(--speed), border-color var(--speed), transform var(--speed);
}
.btn:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--text-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--text-on-accent);
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: var(--fs-12); }
.btn.icon { padding: 7px; }

.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

/* ── forms ───────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > .label { margin: 0; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  font: var(--fs-13)/1.4 var(--ff);
  padding: 8px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  width: 100%; min-width: 0;
  transition: border-color var(--speed), box-shadow var(--speed);
}
input:hover:not(:disabled), select:hover:not(:disabled) { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder { color: var(--text-3); }
input:disabled, select:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 8l3-3.5' stroke='%23878e9d' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.check { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; font-size: var(--fs-13); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; margin: 0; }

.toolbar {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  padding: var(--s3) var(--s5); border-bottom: 1px solid var(--border);
  background: var(--surface-2); border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.toolbar .search { min-width: 200px; flex: 1; max-width: 340px; }

/* ── notices ─────────────────────────────────────────────────────────────── */

.notice {
  display: flex; gap: var(--s3); padding: var(--s3) var(--s4);
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2); font-size: var(--fs-13); color: var(--text-2);
  margin-bottom: var(--s4);
}
.notice b { color: var(--text); }
/* The tint and the rule carry the meaning. Body text stays at full
   readability — a whole sentence in accent colour reads as a link. */
.notice::before { content: ""; width: 3px; border-radius: 2px; flex: none; background: var(--border-strong); }
.notice.ok     { background: var(--ok-soft);     border-color: var(--ok-line); }
.notice.warn   { background: var(--warn-soft);   border-color: var(--warn-line); }
.notice.danger { background: var(--danger-soft); border-color: var(--danger-line); }
.notice.info   { background: var(--info-soft);   border-color: var(--info-line); }
.notice.ok::before     { background: var(--ok); }
.notice.warn::before   { background: var(--warn); }
.notice.danger::before { background: var(--danger); }
.notice.info::before   { background: var(--info); }
.notice.ok b     { color: var(--ok); }
.notice.warn b   { color: var(--warn); }
.notice.danger b { color: var(--danger); }
.notice.info b   { color: var(--info); }

.empty { padding: var(--s9) var(--s5); text-align: center; color: var(--text-3); }
.empty h3 { color: var(--text-2); margin-bottom: var(--s2); }

/* ── tabs ────────────────────────────────────────────────────────────────── */

.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: var(--s3) var(--s4); border: 0; background: none; cursor: pointer;
  font: 600 var(--fs-13)/1.2 var(--ff); color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }

/* ── misc ────────────────────────────────────────────────────────────────── */

.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: var(--s2) var(--s4); font-size: var(--fs-13); }
.kv dt { color: var(--text-3); font-size: var(--fs-12); }
.kv dd { margin: 0; color: var(--text); }

.bar { height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

.theme-toggle { margin-left: auto; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .8s linear infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .45 } }
.skeleton { background: var(--surface-3); border-radius: var(--r-sm); animation: pulse 1.4s ease-in-out infinite; }

/* ── mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .nav {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, var(--nav-w));
    z-index: 60; transform: translateX(-100%);
    transition: transform var(--speed) ease-out; box-shadow: var(--shadow-3);
  }
  .nav.open { transform: none; }
  .nav-scrim {
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    z-index: 50; opacity: 0; pointer-events: none; transition: opacity var(--speed);
  }
  .nav-scrim.on { opacity: 1; pointer-events: auto; }
  .topbar { padding: 0 var(--s4); }
  .content { padding: var(--s4); }
  .nav-burger { display: inline-flex !important; }

  /* dense tables become cards — each cell labelled by its column */
  table.t.stack thead { display: none; }
  table.t.stack, table.t.stack tbody, table.t.stack tr, table.t.stack td { display: block; width: 100%; }
  table.t.stack tr {
    border: 1px solid var(--border); border-radius: var(--r);
    margin-bottom: var(--s3); padding: var(--s2) var(--s3); background: var(--surface);
  }
  table.t.stack td {
    border: 0; padding: var(--s1) 0;
    display: grid; grid-template-columns: 88px 1fr; gap: var(--s3); align-items: baseline;
  }
  table.t.stack td::before {
    content: attr(data-label);
    font-size: var(--fs-11); font-weight: 600; letter-spacing: .05em;
    text-transform: uppercase; color: var(--text-3); line-height: 1.7;
  }
  table.t.stack td.num { text-align: left; }
  table.t.stack td > * { grid-column: 2; justify-self: start; }
  table.t.stack td .sub { margin-top: 1px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
  .stat-v { font-size: var(--fs-20); }
}
.nav-burger { display: none; }

@media (min-width: 901px) { .nav-scrim { display: none; } }

@media print {
  .nav, .topbar, .toolbar, .btn, .nav-scrim { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ════════════════════════════════════════════════════════════════════════════
   v2 — the layer that makes it feel like a product rather than a page
   ════════════════════════════════════════════════════════════════════════════ */

:root {
  --nav-w: 248px;
  /* depth: a real surface has an edge catching light, not just a drop shadow */
  --lift: inset 0 1px 0 rgba(255,255,255,.7);
  --ease: cubic-bezier(.2,.7,.3,1);
}
:root[data-theme="dark"] { --lift: inset 0 1px 0 rgba(255,255,255,.045); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --lift: inset 0 1px 0 rgba(255,255,255,.045); }
}

.card, .stat { box-shadow: var(--shadow-1), var(--lift); }

/* ── nav: icons, sections, footer ────────────────────────────────────────── */

.nav-brand { gap: var(--s3); }
.nav-logo {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font: 800 11px/1 var(--ff); letter-spacing: -.03em;
  box-shadow: 0 1px 2px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.28);
}
.nav-brand .mark { font-size: var(--fs-13); line-height: 1.1; }
.nav-brand .who { font-size: var(--fs-11); color: var(--text-3); font-family: var(--ff); }

.nav-item .ico { width: 17px; height: 17px; flex: none; opacity: .75; stroke-width: 1.6; }
.nav-item.on .ico { opacity: 1; }
.nav-item { position: relative; }
.nav-item.on::before {
  content: ""; position: absolute; left: -5px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-foot { margin-top: auto; padding: var(--s3); border-top: 1px solid var(--border); }

.kbd {
  font: 600 10px/1 var(--ff-mono); color: var(--text-3);
  background: var(--surface-3); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 4px; padding: 3px 5px; white-space: nowrap;
}

/* ── command palette ─────────────────────────────────────────────────────── */

.cmdk-scrim {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: start center;
  padding-top: 12vh; background: rgba(10,12,16,.44);
  backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity 120ms;
}
.cmdk-scrim.on { opacity: 1; pointer-events: auto; }
.cmdk {
  width: min(640px, 92vw); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); overflow: hidden;
  transform: translateY(-8px) scale(.985); transition: transform 160ms var(--ease);
}
.cmdk-scrim.on .cmdk { transform: none; }
.cmdk-in { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5);
           border-bottom: 1px solid var(--border); }
.cmdk-in input {
  border: 0; padding: 0; background: none; font-size: var(--fs-16); box-shadow: none !important;
}
.cmdk-list { max-height: 46vh; overflow-y: auto; padding: var(--s2); }
.cmdk-sec { padding: var(--s3) var(--s3) var(--s1); }
.cmdk-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3); border-radius: var(--r-sm); cursor: pointer; font-size: var(--fs-13);
}
.cmdk-row .ico { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.cmdk-row .meta { margin-left: auto; font-size: var(--fs-12); color: var(--text-3); }
.cmdk-row.sel { background: var(--accent-soft); color: var(--accent); }
.cmdk-row.sel .ico, .cmdk-row.sel .meta { color: var(--accent); }
.cmdk-foot {
  display: flex; gap: var(--s4); padding: var(--s3) var(--s5);
  border-top: 1px solid var(--border); background: var(--surface-2);
  font-size: var(--fs-11); color: var(--text-3); align-items: center;
}

/* ── inline data: sparkline, coverage meter, delta ───────────────────────── */

.spark { display: block; overflow: visible; }
.spark path { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark .fill { stroke: none; }
.spark .tip { r: 2.6; }

.meter { display: flex; align-items: center; gap: var(--s2); }
.meter .track {
  position: relative; flex: 1; min-width: 54px; height: 6px;
  border-radius: var(--r-full); background: var(--surface-3); overflow: hidden;
}
.meter .track > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--text-3); }
.meter.ok     .track > i { background: var(--ok); }
.meter.warn   .track > i { background: var(--warn); }
.meter.danger .track > i { background: var(--danger); }
.meter .lead {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: var(--text); opacity: .5; border-radius: 1px;
}
.meter .v { font-size: var(--fs-12); color: var(--text-2); min-width: 42px; }

.delta { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-12); font-weight: 600; }
.delta.up   { color: var(--danger); }   /* demand rising = a supply problem */
.delta.down { color: var(--ok); }
.delta.flat { color: var(--text-3); font-weight: 500; }

/* ── row actions reveal on hover ─────────────────────────────────────────── */

table.t tbody tr { transition: background 90ms var(--ease); }
.row-act { opacity: 0; transition: opacity 120ms var(--ease); display: flex; gap: 4px; justify-content: flex-end; }
tr:hover .row-act, tr:focus-within .row-act { opacity: 1; }
@media (hover: none) { .row-act { opacity: 1; } }

/* ── slide-over detail panel ─────────────────────────────────────────────── */

.sheet-scrim {
  position: fixed; inset: 0; z-index: 90; background: rgba(10,12,16,.4);
  opacity: 0; pointer-events: none; transition: opacity 160ms;
}
.sheet-scrim.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 100;
  width: min(560px, 100vw); background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 200ms var(--ease);
}
.sheet.on { transform: none; }
.sheet-head {
  padding: var(--s5); border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: var(--s3);
}
.sheet-body { padding: var(--s5); overflow-y: auto; flex: 1; }
.sheet-foot {
  padding: var(--s3) var(--s5); border-top: 1px solid var(--border);
  background: var(--surface-2); display: flex; gap: var(--s2);
}
@media (max-width: 640px) { .sheet { width: 100vw; border-left: 0; } }

/* ── segmented control & filter chips ────────────────────────────────────── */

.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button {
  border: 0; background: none; cursor: pointer; border-radius: 5px;
  padding: 5px 11px; font: 600 var(--fs-12)/1.3 var(--ff); color: var(--text-2);
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 10px; border-radius: var(--r-full);
  border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent);
  font-size: var(--fs-12); font-weight: 600;
}
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 2px; line-height: 1; opacity: .7; }
.chip button:hover { opacity: 1; }

/* ── toast ───────────────────────────────────────────────────────────────── */

.toasts { position: fixed; bottom: var(--s5); right: var(--s5); z-index: 300;
          display: flex; flex-direction: column; gap: var(--s2); }
.toast {
  display: flex; align-items: center; gap: var(--s3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: var(--s3) var(--s4);
  box-shadow: var(--shadow-2), var(--lift); font-size: var(--fs-13);
  animation: toast-in 220ms var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.toast .ico { width: 16px; height: 16px; flex: none; }
.toast.ok .ico { color: var(--ok); }

/* ── stat tile with its own trend ────────────────────────────────────────── */

.stat { position: relative; overflow: hidden; }
.stat .spark { position: absolute; right: 0; bottom: 0; left: 0; height: 30px; opacity: .5; }
.stat-top { display: flex; align-items: baseline; gap: var(--s2); }
.stat-rel { position: relative; z-index: 1; }

@media (max-width: 900px) { .toasts { left: var(--s4); right: var(--s4); bottom: var(--s4); } }

/* ── status is never colour alone ─────────────────────────────────────────
   Red, amber and green are precisely the axis red-green colour blindness
   collapses: our "order soon" amber and "out" red measure ΔE 1.2 apart under
   deuteranopia — indistinguishable. No hue at this lightness fixes that, so
   each state carries its own GLYPH and its own weight of ink. The badge then
   reads in greyscale, printed, and on a sunlit phone. */

.badge .gi { width: 12px; height: 12px; flex: none; stroke-width: 2.2; }
.badge.ok     { font-weight: 600; }
.badge.warn   { font-weight: 650; }
.badge.danger { font-weight: 700; }
.badge.danger { border-width: 1px; box-shadow: inset 0 0 0 1px var(--danger-line); }

/* the tile's trend line sits in a band beneath the text, never through it */
.stat { padding: var(--s4) var(--s5) var(--s7); }
.stat .spark { height: 24px; opacity: .4; }
.stat .spark path { stroke-width: 1.8; }

/* the topbar subtitle is a desk-screen luxury; on a phone the title wins */
@media (max-width: 560px) {
  .topbar .sub { display: none; }
  .topbar h1 { font-size: var(--fs-14); }
}
