/* ============================================================================
   SYSTEM.CSS — the single source of truth for the Restock Notify design system.

   STATUS: LIVE AND LOAD-BEARING. Step B shipped — base.html's inline block is
   deleted and every page extending base.html renders from this file. (An older
   version of this header said "INERT"; that was stale and misled the lane.)

   Migration plan:
     Step A (done): extracted verbatim from base.html, linked above the inline block.
     Step B (done): inline block deleted from base.html; this file is canonical.
     Step C (next): delete the drifted per-page <style> copies page-by-page and
                    the 2,300+ inline style="" attributes on the worst offenders,
                    promoting genuinely reusable patterns into this file once.

   Tokens: semantic names (--accent/--good/--warn/--bad) are canonical. Brand
   aliases (--brass/--rust/--sage) will be bridged here when marketing pages
   (v2.css) migrate onto the system.
   ============================================================================ */

/* ---- App-feel: cross-document View Transitions (memo item 99) -------------
   Server-rendered page loads crossfade instead of white-flashing — the whole
   app reads as one continuous surface. Progressive enhancement: browsers
   without support simply navigate as before. Held to 180ms with the standard
   easing per the motion rules; disabled entirely under reduced motion. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation-duration: 180ms; animation-timing-function: cubic-bezier(0.2, 0, 0, 1); }
::view-transition-new(root) { animation-duration: 180ms; animation-timing-function: cubic-bezier(0.2, 0, 0, 1); }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

    /* ============================================================
       DESIGN SYSTEM — Linear polish + Pitchbook gravitas.
       Light by default; [data-theme="dark"] overrides.
       ============================================================ */
    :root[data-theme="light"] {
      --bg:           #F4EFE4;     /* warm cream (luxury) */
      --bg-2:         #FFFFFF;     /* clean white card */
      --bg-3:         #ECE3D0;     /* subtle hover / fill */
      --line:         rgba(22, 35, 62, 0.14);
      --border-input: rgba(22, 35, 62, 0.52);  /* 3:1+ vs cream — inputs must be findable (WCAG 1.4.11) */
      --line-strong:  rgba(22, 35, 62, 0.24);
      --text:         #16233E;     /* deep slate near-black */
      --text-dim:     #2E3A52;     /* slate */
      --muted:        #4A5568;     /* secondary copy — WCAG AA on cream */
      --subtle:       #5B6472;     /* tertiary — 5.2:1 on cream, 4.7:1 on bg-3 (computed, not assumed) */
      --accent:       #1F3A5C;     /* deep emerald */
      --accent-hover: #162C46;
      --accent-soft:  rgba(31, 58, 92, 0.10);
      --accent-fg:    #F4EFE4;
      --good:         #2F5D45;     /* emerald — positive */
      --good-soft:    rgba(47, 93, 69, 0.12);
      --warn:         #B5743E;     /* amber-gold */
      --warn-soft:    rgba(181, 116, 62, 0.12);
      --bad:          #8E3B3B;
      --bad-soft:     rgba(142, 59, 59, 0.10);
      --gold:         #8F5A30;     /* deep champagne — tiers */
      --gold-soft:    rgba(231, 220, 196, 0.45);
      --violet:       #2E3A52;     /* slate — secondary accent */
      --violet-soft:  rgba(22, 35, 62, 0.10);
      --shadow-sm:    0 1px 2px rgba(22, 35, 62, 0.05);
      --shadow:       0 1px 3px rgba(22, 35, 62, 0.07), 0 1px 2px rgba(22, 35, 62, 0.05);
      --shadow-md:    0 4px 14px rgba(31, 58, 92, 0.08), 0 1px 4px rgba(22, 35, 62, 0.05);
      --shadow-lg:    0 18px 40px rgba(22, 35, 62, 0.12), 0 4px 8px rgba(22, 35, 62, 0.07);
      --ring:         0 0 0 3px rgba(31, 58, 92, 0.20);
      --gradient-hero:linear-gradient(135deg, #E7DCC4 0%, #F4EFE4 100%);
    }
    :root[data-theme="dark"] {
      --bg:           #11192B;     /* deep slate-charcoal */
      --bg-2:         #18233A;
      --bg-3:         #22304A;
      --line:         rgba(231, 220, 196, 0.12);
      --border-input: rgba(231, 220, 196, 0.45);
      --line-strong:  rgba(231, 220, 196, 0.22);
      --text:         #F4EFE4;     /* cream */
      --text-dim:     #D2CAB8;
      --muted:        #A6AEBE;
      --subtle:       #79829A;
      --accent:       #6E9BC9;     /* lifted emerald for dark */
      --accent-hover: #8DB4D6;
      --accent-soft:  rgba(110, 155, 201, 0.18);
      --accent-fg:    #11192B;
      --good:         #5FA37E;
      --good-soft:    rgba(95, 163, 126, 0.14);
      --warn:         #D69A5A;
      --warn-soft:    rgba(214, 154, 90, 0.14);
      --bad:          #D77B7B;
      --bad-soft:     rgba(215, 123, 123, 0.14);
      --gold:         #E7DCC4;     /* champagne pops on dark */
      --gold-soft:    rgba(231, 220, 196, 0.16);
      --violet:       #9CC0E2;     /* light slate */
      --violet-soft:  rgba(156, 192, 226, 0.16);
      --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.5);
      --shadow:       0 1px 3px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.45);
      --shadow-md:    0 4px 14px rgba(0, 0, 0, 0.5), 0 1px 4px rgba(0, 0, 0, 0.35);
      --shadow-lg:    0 18px 40px rgba(0, 0, 0, 0.6), 0 4px 8px rgba(0, 0, 0, 0.45);
      --ring:         0 0 0 3px rgba(110, 155, 201, 0.30);
      --gradient-hero:linear-gradient(135deg, #243A33 0%, #18233A 100%);
    }
    :root {
      --radius:       8px;
      --radius-sm:    6px;
      --radius-lg:    12px;
      --font:         'General Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      --font-serif:   'Fraunces', Georgia, 'Times New Roman', serif;
      --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    }

    * { box-sizing: border-box; }
    body {
      font-family: var(--font); margin: 0; min-height: 100vh;
      background: var(--bg); color: var(--text);
      font-feature-settings: 'cv11', 'ss01';
      -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
      line-height: 1.5;
    }

    /* Paper-grain texture + warm vignette — tactile "good stationery" feel */
    body::before {
      content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 1000;
      background-image:
        radial-gradient(rgba(22, 35, 62, 0.045) 1px, transparent 1px),
        radial-gradient(rgba(181, 116, 62, 0.035) 1px, transparent 1px);
      background-size: 3px 3px, 5px 5px;
      background-position: 0 0, 1.5px 1.5px;
      mix-blend-mode: multiply; opacity: 0.7;
    }
    body::after {
      content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 999;
      background:
        radial-gradient(ellipse at 15% 0%, rgba(231, 220, 196, 0.16), transparent 55%),
        radial-gradient(ellipse at 85% 100%, rgba(31, 58, 92, 0.05), transparent 50%);
    }
    [data-theme="dark"] body::before { opacity: 0.28; }

    /* Brand: confident serif for major headings */
    h1, h2 {
      font-family: var(--font-serif);
      font-weight: 500;
      letter-spacing: -0.02em;
      font-variation-settings: "opsz" 110, "SOFT" 60;
    }

    /* ===== HEADER ===== */
    header {
      background: var(--bg-2);
      border-bottom: 1px solid var(--line);
      padding: 0 24px; height: 56px;
      display: flex; align-items: center; gap: 24px;
      position: sticky; top: 0; z-index: 300; /* above page content + animated cards so nav dropdowns never render behind the page */
    }
    header h1 { font-size: 14px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
    header h1 a {
      color: var(--text); text-decoration: none;
      display: inline-flex; align-items: center; gap: 8px;
    }
    header h1 .logo-mark {
      width: 26px; height: 26px; border-radius: 50%;
      background: var(--accent); color: var(--accent-fg);
      display: inline-flex; align-items: center; justify-content: center;
      font-family: var(--font-serif); font-style: italic; font-weight: 500; font-size: 13px;
      box-shadow: inset 0 0 0 1px rgba(231, 220, 196, 0.45), 0 0 0 1px rgba(181, 116, 62, 0.40);
    }
    nav { display: flex; gap: 2px; align-items: center; }
    nav a {
      color: var(--text-dim); text-decoration: none; font-size: 13px;
      font-weight: 500; padding: 6px 12px; border-radius: var(--radius-sm);
      transition: background 0.12s, color 0.12s;
    }
    nav a:hover { color: var(--text); background: var(--bg-3); }

    /* Beta-locked nav item: present but visibly closed. The tab stays so the
       owner can see what exists; the dimming + 🔒 make the locked page an
       expectation instead of a dead end. Replaces the old inline
       style="opacity:.6" / style="font-size:11px" pair (Rule 8). */
    nav a.nav-locked, .nav-dropdown a.nav-locked { opacity: 0.6; }
    nav a.nav-locked .nav-lock { font-size: 11px; }

    /* Cockpit header link. Same look as its inline-styled siblings, as a class —
       new markup doesn't add inline styles (Rule 8). */
    .cockpit-link { font-size: 13px; color: var(--muted); }

    /* ===== INTEGRATIONS · Square card ===== */
    /* The branch that built this predated the inline-style ratchet; these classes
       replace its inline styles (Rule 8). The sibling cards still carry inline
       styles — grandfathered, migrated only when touched. */
    .intg-tight { margin-top: 0; }
    .intg-row { display: flex; gap: 16px; align-items: center; }
    .intg-sub { font-size: 13px; }
    .intg-spacer { flex: 1; }
    .intg-danger { background: #b91c1c; color: #fff; }
    .intg-note { font-size: 12px; margin-top: 8px; }

    /* ===== ADMIN · BETA INVITES (/admin/invites) ===== */
    .inv-h { margin: 0; }
    .inv-sub { margin: 4px 0 0; font-size: 13px; }
    .inv-headlinks { display: flex; gap: 14px; }
    .inv-headlinks a { font-size: 13px; color: var(--muted); }
    .inv-formtitle { margin: 0 0 10px; font-size: 15px; }
    .inv-meta { font-size: 12px; }
    .inv-dead { font-size: 12px; }
    /* nowrap so Send and Revoke sit side by side instead of stacking into a
       column when the cell gets narrow. */
    .inv-actions { text-align: right; white-space: nowrap; }

    .inv-new { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
    .inv-new input[type="text"] { flex: 1; min-width: 220px; }
    .inv-new input[type="email"] { flex: 1; min-width: 200px; }
    .inv-hint { margin: 10px 0 0; font-size: 12px; }
    /* The note spans the full width on its own row — it's a sentence, not a field. */
    .inv-note { flex-basis: 100%; }
    .inv-warn { color: var(--accent, #e0a458); }
    .inv-inline { display: inline-block; }
    .inv-new input[type="text"], .inv-new input[type="email"], .inv-new select {
      background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
      border-radius: 8px; padding: 8px 10px; font-family: inherit; font-size: 13px;
    }
    .inv-new button {
      background: var(--accent, #7aa2f7); color: #0b1020; border: 0;
      border-radius: 8px; padding: 8px 16px; font-family: inherit;
      font-size: 13px; font-weight: 600; cursor: pointer;
    }

    /* The link is the credential — monospace so a shop owner reading it back
       over the phone can tell l from 1 and O from 0. */
    .inv-link {
      font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
      font-size: 11.5px; color: var(--text-dim); word-break: break-all;
      background: var(--bg-3); border-radius: 6px; padding: 2px 6px; cursor: pointer;
    }
    .inv-copy, .inv-revoke {
      background: transparent; border: 1px solid var(--line); color: var(--text-dim);
      border-radius: 6px; padding: 3px 9px; font-family: inherit; font-size: 11.5px;
      cursor: pointer; margin-left: 6px;
    }
    .inv-copy:hover { color: var(--text); border-color: var(--text-dim); }
    .inv-revoke:hover { color: #ff6b6b; border-color: #ff6b6b; }

    .inv-badge { font-size: 12px; font-weight: 600; white-space: nowrap; }
    .inv-badge.used    { color: var(--ok, #6ccf7d); }
    .inv-badge.unused  { color: var(--text-dim); }
    .inv-badge.revoked { color: #ff6b6b; }
    .inv-badge.expired { color: var(--muted); }

    .inv-empty { text-align: center; padding: 30px 16px; }
    .inv-empty-icon { font-size: 26px; margin-bottom: 6px; }
    .inv-empty h3 { margin: 0 0 4px; font-size: 15px; }
    .inv-empty p { margin: 0 auto; max-width: 44ch; font-size: 13px; }

    /* ===== NAV DROPDOWNS ===== */
    .nav-group { position: relative; }
    .nav-group > .nav-trigger {
      display: inline-flex; align-items: center; gap: 4px;
      color: var(--text-dim); font-size: 13px; font-weight: 500;
      padding: 6px 12px; border-radius: var(--radius-sm);
      cursor: pointer; user-select: none;
      background: transparent; border: 0;
      font-family: inherit; line-height: inherit;
      transition: background 0.12s, color 0.12s;
    }
    .nav-group > .nav-trigger::after {
      content: ''; display: inline-block;
      width: 0; height: 0; margin-left: 2px;
      border-left: 4px solid transparent;
      border-right: 4px solid transparent;
      border-top: 4px solid currentColor;
      opacity: 0.6; transition: transform 0.12s, opacity 0.12s;
    }
    .nav-group:hover > .nav-trigger,
    .nav-group:focus-within > .nav-trigger {
      color: var(--text); background: var(--bg-3);
    }
    .nav-group:hover > .nav-trigger::after,
    .nav-group:focus-within > .nav-trigger::after {
      transform: rotate(180deg); opacity: 1;
    }
    .nav-dropdown {
      position: absolute; top: calc(100% + 4px); left: 0;
      min-width: 200px; padding: 6px;
      background: var(--bg-2); border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow-lg);
      display: none; flex-direction: column; gap: 1px;
      z-index: 100;
    }
    .nav-group:hover > .nav-dropdown,
    .nav-group:focus-within > .nav-dropdown {
      display: flex;
    }
    /* Tap-to-open (touch + keyboard) — JS toggles .open */
    .nav-group.open > .nav-dropdown { display: flex; }
    .nav-group.open > .nav-trigger { color: var(--text); background: var(--bg-3); }
    .nav-group.open > .nav-trigger::after { transform: rotate(180deg); opacity: 1; }
    .nav-toggle {
      display: none; background: transparent; border: 1px solid var(--line);
      border-radius: var(--radius-sm); width: 34px; height: 34px;
      align-items: center; justify-content: center; cursor: pointer;
      color: var(--text-dim); padding: 0;
    }
    .nav-toggle:hover { background: var(--bg-3); color: var(--text); }
    .nav-dropdown a {
      padding: 8px 12px; font-size: 13px;
      color: var(--text-dim); border-radius: calc(var(--radius) - 4px);
      display: flex; align-items: center; justify-content: space-between;
      gap: 8px; white-space: nowrap;
    }
    .nav-dropdown a:hover { background: var(--bg-3); color: var(--text); }
    .nav-dropdown a .hint {
      font-size: 11px; color: var(--muted); font-weight: 400;
    }
    .nav-dropdown .nav-section-label {
      font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
      color: var(--subtle); font-weight: 700;
      padding: 6px 12px 2px;
    }
    header .spacer { flex: 1; }
    header .who {
      font-size: 12px; color: var(--text-dim); font-weight: 600;
      padding: 6px 10px; border-radius: var(--radius-sm);
      text-decoration: none; transition: background 0.12s;
    }
    header .who:hover { background: var(--bg-3); color: var(--text); }
    header button.linkbtn {
      background: transparent; color: var(--muted);
      border: 1px solid var(--line); padding: 5px 10px; font-size: 12px;
      font-weight: 500; border-radius: var(--radius-sm);
      cursor: pointer; font-family: inherit; transition: all 0.12s;
    }
    header button.linkbtn:hover { color: var(--bad); border-color: var(--bad); }
    .theme-toggle {
      background: transparent; border: 1px solid var(--line);
      width: 32px; height: 32px; border-radius: var(--radius-sm);
      display: inline-flex; align-items: center; justify-content: center;
      cursor: pointer; color: var(--text-dim); transition: all 0.12s;
      padding: 0;
    }
    .theme-toggle:hover { color: var(--text); background: var(--bg-3); }
    .theme-toggle svg { width: 16px; height: 16px; }
    [data-theme="light"] .theme-toggle .moon-icon { display: block; }
    [data-theme="light"] .theme-toggle .sun-icon { display: none; }
    [data-theme="dark"] .theme-toggle .moon-icon { display: none; }
    [data-theme="dark"] .theme-toggle .sun-icon { display: block; }

    main { max-width: 1200px; margin: 32px auto; padding: 0 24px; }

    /* ===== TYPOGRAPHY ===== */
    h2 {
      font-size: 22px; font-weight: 700; color: var(--text);
      letter-spacing: -0.02em; margin: 0 0 16px;
    }
    h3 { font-size: 16px; font-weight: 600; color: var(--text); margin: 0 0 12px; }
    a { color: var(--accent); text-decoration: none; }
    a:hover { color: var(--accent-hover); text-decoration: underline; }
    /* Visible keyboard focus everywhere (WCAG 2.4.7) */
    a:focus-visible, button:focus-visible, summary:focus-visible,
    [tabindex]:focus-visible, .filter-chip:focus-visible, .tag-chip:focus-visible,
    .kpi:focus-visible, .nav-trigger:focus-visible, select:focus-visible {
      outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm);
    }
    /* Respect the OS reduced-motion preference */
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important; scroll-behavior: auto !important;
      }
    }
    code {
      background: var(--bg-3); color: var(--text);
      padding: 1px 6px; border-radius: 4px; font-size: 0.875em;
      font-family: var(--font-mono); border: 1px solid var(--line);
    }
    .muted { color: var(--muted); font-size: 13px; }

    /* ===== CARDS ===== */
    .card {
      background: var(--bg-2); border: 1px solid var(--line);
      border-radius: var(--radius-lg); padding: 20px 22px; margin-bottom: 16px;
      box-shadow: var(--shadow-sm);
    }

    /* ===== STATS (legacy) ===== */
    .stats { display: flex; flex-wrap: wrap; gap: 12px; }
    .stat {
      background: var(--bg-2); border: 1px solid var(--line);
      border-radius: var(--radius); padding: 14px 18px;
      min-width: 130px; max-width: 220px;
    }
    .stat .num { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
    .stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
    .stat .desc { font-size: 12px; color: var(--subtle); margin-top: 4px; }

    /* ===== TABLES ===== */
    table { width: 100%; border-collapse: collapse; }
    th, td {
      text-align: left; padding: 11px 12px;
      border-bottom: 1px solid var(--line);
      font-size: 13.5px; color: var(--text);
    }
    th {
      color: var(--muted); font-size: 11px; letter-spacing: 0.04em;
      text-transform: uppercase; font-weight: 600;
    }
    tr:hover td { background: var(--bg-3); }
    td a { color: var(--accent); }
    td a:hover { color: var(--accent-hover); }
    td strong { color: var(--text); font-weight: 600; }

    /* ===== INPUTS + BUTTONS ===== */
    input, select, textarea {
      padding: 8px 12px; border: 1px solid var(--border-input);
      background: var(--bg-2); color: var(--text);
      border-radius: var(--radius-sm); font-size: 16px;
      margin: 4px 6px 4px 0; font-family: inherit; outline: none;
      transition: border-color 0.12s, box-shadow 0.12s;
    }
    input::placeholder, textarea::placeholder { color: var(--subtle); }
    input:focus, select:focus, textarea:focus {
      border-color: var(--accent); box-shadow: var(--ring);
    }
    label.check {
      font-size: 13px; color: var(--text-dim);
      display: inline-flex; align-items: center; gap: 4px;
    }

    button {
      background: var(--accent); color: var(--accent-fg);
      border: 1px solid var(--accent); border-radius: var(--radius-sm);
      padding: 8px 14px; font-size: 13px; font-weight: 600;
      cursor: pointer; font-family: inherit;
      transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
    }
    button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
    button:focus-visible { box-shadow: var(--ring); }
    button.secondary {
      background: var(--bg-2); color: var(--text);
      border: 1px solid var(--line);
    }
    button.secondary:hover { background: var(--bg-3); border-color: var(--line-strong); }
    form.inline { display: inline; }

    /* ===== FLASH MESSAGES ===== */
    .flash {
      padding: 12px 16px; border-radius: var(--radius); margin-bottom: 14px;
      font-size: 13.5px; border: 1px solid;
      display: flex; align-items: center; gap: 10px;
    }
    .flash.success { background: var(--good-soft); color: var(--good); border-color: rgba(21, 128, 61, 0.2); }
    .flash.error   { background: var(--bad-soft);  color: var(--bad);  border-color: rgba(185, 28, 28, 0.2); }
    .flash.warn, .flash.warning { background: rgba(234, 179, 8, 0.10); color: #92400e; border-color: rgba(234, 179, 8, 0.30); }  /* routes flash both 'warn' and 'warning' */
    [data-theme="dark"] .flash.success { border-color: rgba(74, 222, 128, 0.25); }
    [data-theme="dark"] .flash.error   { border-color: rgba(248, 113, 113, 0.25); }
    [data-theme="dark"] .flash.warn, [data-theme="dark"] .flash.warning { color: #fbbf24; border-color: rgba(251, 191, 36, 0.35); }
    .flash.warn .pastdue-actions { margin-left: auto; display: flex; gap: 8px; }
    .flash.warn form.inline button.linkbtn,
    .flash.warn a.linkbtn {
      background: transparent; border: 1px solid currentColor;
      color: inherit; padding: 4px 10px; border-radius: var(--radius-sm);
      font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: none;
    }

    /* ===== PILLS ===== */
    .pill {
      font-size: 11px; padding: 2px 10px; border-radius: 999px;
      font-weight: 600; letter-spacing: 0.01em;
      display: inline-flex; align-items: center;
    }
    .pill.in     { background: var(--good-soft); color: var(--good); }
    .pill.out    { background: var(--bg-3); color: var(--muted); }
    .pill.queued { background: var(--warn-soft); color: var(--warn); }
    .pill.sent   { background: var(--good-soft); color: var(--good); }
    .pill.good   { background: var(--good-soft); color: var(--good); }
    .pill.low    { background: var(--warn-soft); color: var(--warn); }
    .pill.zero   { background: var(--bad-soft);  color: var(--bad); }
    .pill.new    { background: var(--violet-soft); color: var(--violet); }
    .pill.gold   { background: var(--gold-soft); color: var(--gold); }
    .pill.silver { background: var(--bg-3); color: var(--text-dim); }
    .pill.bronze { background: rgba(180, 83, 9, 0.10); color: #b45309; }
    [data-theme="dark"] .pill.bronze { color: #f59e0b; }
    .pill.seg-champion { background: var(--violet-soft); color: var(--violet); }
    .pill.seg-loyal    { background: var(--accent-soft); color: var(--accent); }
    .pill.seg-big      { background: var(--gold-soft); color: var(--gold); }
    .pill.seg-new      { background: var(--accent-soft); color: var(--accent); }
    .pill.seg-at-risk  { background: var(--warn-soft); color: var(--warn); }
    .pill.seg-lost     { background: var(--bad-soft); color: var(--bad); }
    .pill.seg-active   { background: var(--bg-3); color: var(--muted); }

    /* ---- Family 1 unification: caps modifier + semantic state aliases + status dot ----
       Absorbs the ~10 hand-rolled uppercase status pills (emp-status-pill, stock-pill,
       tpl-badge, status-pill, sf-pill, log-badge, cbadge…) into .pill.caps + a state. */
    .pill.caps    { text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
    .pill.warn    { background: var(--warn-soft);   color: var(--warn); }   /* alias of .low */
    .pill.bad     { background: var(--bad-soft);    color: var(--bad); }    /* alias of .zero */
    .pill.neutral { background: var(--bg-3);        color: var(--muted); }  /* alias of .out */
    .pill.info    { background: var(--accent-soft); color: var(--accent); }
    .pill.outline { background: transparent; border: 1px solid currentColor; }
    .dot-status        { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
    .dot-status.good   { background: var(--good); }
    .dot-status.warn   { background: var(--warn); }
    .dot-status.bad    { background: var(--bad); }
    .dot-status.info   { background: var(--accent); }
    .dot-status.neutral{ background: var(--muted); }

    /* ===== HERO (legacy bizhero) ===== */
    .bizhero {
      background: var(--gradient-hero);
      border: 1px solid var(--line);
      border-radius: var(--radius-lg); padding: 28px 32px; margin-bottom: 22px;
      box-shadow: var(--shadow-sm);
    }
    .bizhero .bizname {
      font-size: 28px; font-weight: 700; color: var(--text);
      letter-spacing: -0.025em;
    }
    .bizhero .biztag { color: var(--text-dim); margin-top: 4px; font-size: 14px; }

    /* ===== GALLERY + TILES ===== */
    .gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
    .tile { text-decoration: none; color: var(--text); }
    .tile .thumb {
      width: 100%; aspect-ratio: 1/1; border-radius: var(--radius);
      background-size: cover; background-position: center;
      background-color: var(--bg-3); border: 1px solid var(--line);
      display: flex; align-items: center; justify-content: center;
      color: var(--subtle); font-size: 12px;
    }
    .tile .thumb.empty { border-style: dashed; }
    .tile .tname { font-weight: 600; margin-top: 8px; font-size: 13px; }

    /* ===== HUB grid ===== */
    .hub { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
    .hub a {
      display: block; background: var(--bg-2); border: 1px solid var(--line);
      border-radius: var(--radius-lg); padding: 22px; text-decoration: none;
      color: var(--text); box-shadow: var(--shadow-sm);
      transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
    }
    .hub a:hover {
      border-color: var(--accent); transform: translateY(-1px);
      box-shadow: var(--shadow-md);
    }
    .hub a .t {
      font-size: 15px; font-weight: 700; margin-bottom: 6px;
      color: var(--text); letter-spacing: -0.01em;
    }
    .hub a .d { color: var(--muted); font-size: 13px; }

    /* ===== CUSTOMER DETAIL HERO ===== */
    .cust-hero {
      background: var(--bg-2); border: 1px solid var(--line);
      border-radius: var(--radius-lg); padding: 22px 24px; margin-bottom: 16px;
      box-shadow: var(--shadow-sm);
    }
    .cust-hero h2 { margin: 0; font-size: 22px; }
    .cust-hero h2 .pill { vertical-align: middle; font-size: 11px; margin-left: 6px; }
    .cust-hero-meta {
      display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px;
      margin-top: 12px; align-items: center; color: var(--muted);
    }
    .iconlink {
      color: var(--accent); text-decoration: none; padding: 2px 6px;
      border-radius: 4px; font-weight: 500;
    }
    .iconlink:hover { background: var(--accent-soft); }
    .cc-wrap { display: inline-flex; align-items: center; gap: 2px; }
    .cc-btn {
      background: transparent; border: 0; color: var(--subtle);
      font-size: 14px; cursor: pointer; padding: 2px 6px; border-radius: 4px;
    }
    .cc-btn:hover { background: var(--bg-3); color: var(--accent); }
    .cc-btn.copied { color: var(--good); }

    /* ===== QUICK-ACTION TOOLBAR ===== */
    .quick-actions {
      display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px;
      padding-top: 16px; border-top: 1px solid var(--line);
    }
    .qa-btn {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 7px 14px; border-radius: var(--radius-sm); font-size: 13px;
      text-decoration: none; font-weight: 600; cursor: pointer;
      background: var(--bg-2); color: var(--text); border: 1px solid var(--line);
      transition: all 0.12s; box-shadow: var(--shadow-sm);
    }
    .qa-btn:hover {
      border-color: var(--line-strong); background: var(--bg-3);
      text-decoration: none;
    }
    .qa-primary {
      background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
    }
    .qa-primary:hover {
      background: var(--accent-hover); color: var(--accent-fg);
      border-color: var(--accent-hover);
    }

    /* ===== MICROSIGNALS ===== */
    .microsig {
      display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
      font-size: 11px; margin-top: 4px; line-height: 1.3;
    }
    .microsig .rec {
      font-weight: 600; padding: 1px 7px; border-radius: 4px; font-size: 11px;
    }
    .rec-hot   { background: var(--good-soft); color: var(--good); }
    .rec-warm  { background: var(--warn-soft); color: var(--warn); }
    .rec-drift { background: var(--warn-soft); color: var(--warn); }
    .rec-cold  { background: var(--bad-soft); color: var(--bad); }
    .microsig .muted { font-size: 11px; color: var(--muted); }
    .spark {
      display: inline-flex; gap: 1px; align-items: flex-end; height: 16px;
      margin-left: 4px; padding-left: 4px; border-left: 1px solid var(--line);
    }
    .spark .bar {
      width: 3px; background: var(--accent); border-radius: 1px;
      min-height: 2px; opacity: 0.6;
    }

    /* ===== SOURCE BAR ===== */
    .src-bar {
      display: flex; height: 28px; border-radius: var(--radius-sm); overflow: hidden;
      font-size: 11px; color: #fff; font-weight: 600;
      border: 1px solid var(--line);
    }
    .src-seg {
      display: flex; align-items: center; justify-content: center;
      padding: 0 8px; white-space: nowrap; overflow: hidden;
    }
    .src-walk-in   { background: var(--accent); }
    .src-referral  { background: #15803d; }
    .src-etsy      { background: #c2410c; }
    .src-instagram { background: #c026d3; }
    .src-web       { background: #0e7490; }
    .src-other     { background: #57534e; }
    .src-unknown   { background: #a8a29e; color: #1c1917; }

    /* ===== DETAILS / SUMMARY ===== */
    summary { cursor: pointer; color: var(--text); }
    summary:hover { color: var(--accent); }
    .edit-card summary { padding: 6px 0; }
    .edit-card[open] summary { margin-bottom: 14px; }

    /* ===== MONTHLY SPENDING BARS ===== */
    .month-bars { display: flex; flex-direction: column; gap: 6px; }
    .month-row {
      display: grid; grid-template-columns: 90px 1fr 1.2fr;
      align-items: center; gap: 12px; font-size: 13px;
    }
    .month-label { color: var(--text-dim); font-weight: 600; }
    .month-track {
      position: relative; height: 22px; background: var(--bg-3);
      border-radius: var(--radius-sm); overflow: hidden;
    }
    .month-fill {
      height: 100%;
      background: linear-gradient(90deg, var(--accent), var(--accent-hover));
      border-radius: var(--radius-sm);
    }
    .month-amount {
      position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
      font-size: 11px; font-weight: 700; color: var(--text);
    }
    .month-products {
      font-size: 12px; color: var(--muted); overflow: hidden;
      text-overflow: ellipsis; white-space: nowrap;
    }

    /* ===== COHORT HEATMAP ===== */
    .cohort-card summary { padding: 4px 0; }
    .cohort-table { width: auto; margin-top: 10px; }
    .cohort-table th, .cohort-table td {
      text-align: center; padding: 6px 10px; font-size: 11px;
      border-bottom: 1px solid var(--line);
    }
    .cohort-cell { color: var(--text); font-weight: 600; }
    .cohort-na { color: var(--subtle); }

    /* ===== TAG CHIPS ===== */
    .tag-row {
      display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px;
      align-items: center;
    }
    .tag-chip {
      display: inline-block; padding: 3px 10px; border-radius: 999px;
      font-size: 11px; text-decoration: none;
      background: var(--bg-3); color: var(--text-dim);
      border: 1px solid var(--line); margin: 1px;
      transition: all 0.12s;
    }
    .tag-chip:hover {
      background: var(--accent-soft); color: var(--accent);
      border-color: var(--accent); text-decoration: none;
    }
    .tag-chip.active {
      background: var(--accent); color: var(--accent-fg);
      border-color: var(--accent);
    }
    .tag-chip.row-tag { font-size: 10px; padding: 1px 8px; }

    /* ===== MESSAGE BUBBLES ===== */
    .thread-mini {
      max-height: 320px; overflow-y: auto; padding: 8px;
      background: var(--bg-3); border: 1px solid var(--line);
      border-radius: var(--radius); margin-bottom: 10px;
      display: flex; flex-direction: column; gap: 6px;
    }
    .msg-bubble {
      padding: 9px 13px; border-radius: var(--radius); font-size: 13px;
      border: 1px solid transparent;
    }
    .msg-outbound {
      background: var(--accent-soft); border-color: var(--accent-soft);
      color: var(--text); align-self: flex-end;
    }
    .msg-inbound {
      background: var(--bg-2); border-color: var(--line);
      color: var(--text); align-self: flex-start;
    }
    .msg-meta { font-size: 10.5px; color: var(--muted); margin-bottom: 3px; }
    .msg-meta strong { color: var(--text); margin-right: 6px; }
    .msg-subject { font-weight: 600; margin-bottom: 2px; color: var(--text); }
    .msg-body { white-space: pre-wrap; }

    /* ===== BADGES ===== */
    .bday-badge {
      display: inline-block; font-size: 11px; padding: 1px 8px;
      background: var(--violet-soft); color: var(--violet);
      border-radius: 4px; margin-left: 6px; font-weight: 600;
    }
    .due {
      font-size: 11px; padding: 2px 7px; border-radius: 4px; font-weight: 600;
    }
    .due-soon    { background: var(--warn-soft); color: var(--warn); }
    .due-overdue { background: var(--bad-soft); color: var(--bad); }
    .due-future  { background: var(--bg-3); color: var(--muted); }

    .margin-pill {
      display: inline-block; padding: 1px 8px; border-radius: 999px;
      font-size: 10.5px; font-weight: 700;
    }
    .margin-good    { background: var(--good-soft); color: var(--good); }
    .margin-ok      { background: var(--warn-soft); color: var(--warn); }
    .margin-thin    { background: var(--bad-soft); color: var(--bad); }
    .margin-unknown { background: var(--bg-3); color: var(--muted); }

    /* ===== FILTER CHIPS ===== */
    .filter-chip {
      font-size: 12.5px; padding: 6px 12px; border-radius: var(--radius-sm);
      text-decoration: none; color: var(--text-dim); background: var(--bg-2);
      border: 1px solid var(--line); font-weight: 500;
      transition: all 0.12s;
    }
    .filter-chip:hover {
      background: var(--bg-3); color: var(--text);
      border-color: var(--line-strong); text-decoration: none;
    }
    .filter-chip.active {
      background: var(--accent); color: var(--accent-fg);
      border-color: var(--accent);
    }

    /* ===== SORTABLE COLUMN HEADERS ===== */
    th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
    th.sortable:hover { color: var(--accent); }
    th.sortable .caret { font-size: 9px; color: var(--subtle); margin-left: 2px; }
    th.sortable.sort-asc  .caret::after { content: '▲'; color: var(--accent); }
    th.sortable.sort-desc .caret::after { content: '▼'; color: var(--accent); }

    /* ===== BULK-ACTION TOOLBAR ===== */
    .bulk-bar {
      position: sticky; top: 72px; z-index: 20;
      background: var(--bg-2); border: 1px solid var(--accent);
      color: var(--text); padding: 10px 16px;
      border-radius: var(--radius); margin-bottom: 14px;
      display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
      box-shadow: var(--shadow-md);
    }
    .bulk-bar .spacer { flex: 1; }
    .bulk-bar input[type=text], .bulk-bar input[type=number], .bulk-bar select {
      padding: 6px 10px; margin: 0;
    }
    .bulk-bar button { padding: 6px 12px; font-size: 12px; }

    /* ===== KPI STRIP ===== */
    .kpi-strip {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
      gap: 12px; margin-bottom: 20px;
    }
    .kpi {
      background: var(--bg-2); border: 1px solid var(--line);
      border-radius: var(--radius-lg); padding: 16px 18px;
      text-decoration: none; color: inherit;
      display: flex; flex-direction: column; gap: 4px;
      box-shadow: var(--shadow-sm);
      transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
    }
    .kpi:hover {
      border-color: var(--line-strong); box-shadow: var(--shadow-md);
      transform: translateY(-1px);
    }
    .kpi-label {
      font-size: 11px; color: var(--muted); text-transform: uppercase;
      letter-spacing: 0.06em; font-weight: 600;
    }
    .kpi-num {
      font-size: 28px; font-weight: 700; letter-spacing: -0.025em;
      color: var(--text);
    }
    .kpi-sub { font-size: 12px; color: var(--muted); }
    .kpi-headline {
      background: linear-gradient(135deg, var(--warn-soft), var(--bad-soft));
      border-color: var(--warn);
    }
    .kpi-headline .kpi-num { color: var(--warn); }
    .kpi-headline .kpi-sub { color: var(--warn); opacity: 0.85; }

    /* ===== BUBBLE VIEW ===== */
    .bubbles { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; padding: 10px 0; }
    .bubble {
      border-radius: 50%; display: flex; flex-direction: column; align-items: center;
      justify-content: center; text-decoration: none; text-align: center; padding: 6px;
      color: #fff; border: 1px solid rgba(0,0,0,0.08); transition: all 0.12s;
      box-shadow: var(--shadow-sm);
    }
    .bubble:hover { transform: scale(1.05); box-shadow: var(--shadow-md); }
    .bubble .bname { font-size: 11px; font-weight: 700; line-height: 1.15; }
    .bubble .btot  { font-size: 11px; opacity: 0.85; }
    .bubble.gold   { background: radial-gradient(circle at 35% 30%, #fef3c7, #b45309); color: #1c1917; }
    .bubble.silver { background: radial-gradient(circle at 35% 30%, #f5f5f4, #78716c); color: #1c1917; }
    .bubble.bronze { background: radial-gradient(circle at 35% 30%, #fed7aa, #c2410c); color: #1c1917; }
    .bubble.new    { background: radial-gradient(circle at 35% 30%, #E7DCC4, #1F3A5C); color: #fff; }

    /* ===== SUBNAV ===== */
    .subnav {
      display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px;
      align-items: center; border-bottom: 1px solid var(--line);
      padding-bottom: 0;
    }
    .subnav a {
      font-size: 13px; padding: 8px 14px; border-radius: 0; text-decoration: none;
      color: var(--muted); background: transparent;
      border: 0; border-bottom: 2px solid transparent;
      font-weight: 500; margin-bottom: -1px;
      transition: color 0.12s, border-color 0.12s;
    }
    .subnav a:hover { color: var(--text); text-decoration: none; }
    .subnav a.active {
      color: var(--accent); border-bottom-color: var(--accent);
      font-weight: 600;
    }

    /* ===== LEGACY ===== */
    .stockbox { font-size: 18px; font-weight: 700; color: var(--text); }

    /* ===== SCROLLBARS ===== */
    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
    ::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

    /* ===== SELECTION ===== */
    ::selection { background: var(--accent); color: var(--accent-fg); }

    /* ===== GHOST CARDS (locked Pro/Business features) ===== */
    .ghost-card {
      position: relative;
      border: 1.5px dashed var(--line-strong);
      background: linear-gradient(180deg, var(--bg-2) 0%, transparent 100%);
      border-radius: 12px;
      padding: 18px 18px 16px;
      display: flex; flex-direction: column; gap: 8px;
      transition: border-color 0.18s ease, transform 0.18s ease;
      opacity: 0.88;
    }
    .ghost-card:hover { opacity: 1; border-color: var(--accent); transform: translateY(-1px); }
    .ghost-head { display: flex; justify-content: space-between; align-items: center; }
    .ghost-icon { font-size: 18px; }
    .ghost-tier {
      font-family: var(--mono, ui-monospace, monospace);
      font-size: 9.5px;
      font-weight: 700;
      letter-spacing: 0.1em;
      padding: 3px 8px;
      border-radius: 999px;
    }
    .ghost-tier-pro        { background: var(--good-soft); color: var(--good); }
    .ghost-tier-business   { background: var(--accent-soft); color: var(--accent); }
    .ghost-tier-enterprise { background: var(--gold-soft); color: var(--gold); }
    .ghost-tier-addon      { background: var(--gold-soft); color: var(--gold); }
    .ghost-title {
      font-weight: 600; font-size: 15px; color: var(--text-dim);
      margin-top: 2px;
    }
    .ghost-desc {
      font-size: 13px; line-height: 1.5; color: var(--text-dim);
      flex: 1;
    }
    .ghost-cta {
      display: inline-block;
      margin-top: 8px;
      text-decoration: none;
      font-size: 12.5px;
      font-weight: 600;
      color: var(--accent);
    }
    .ghost-cta:hover { text-decoration: underline; }
    .ghost-section-header {
      margin: 24px 0 12px;
      padding-top: 18px;
      border-top: 1px solid var(--line);
    }
    .ghost-section-title {
      font-family: var(--mono, ui-monospace, monospace);
      font-size: 11px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--text-dim);
      font-weight: 600;
    }
    .ghost-section-sub {
      font-size: 13px;
      color: var(--text-dim);
      margin-top: 3px;
    }
    /* ATLAS budget meter — top-of-screen chip showing $X/$Y used this month */
    .atlas-meter {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 5px 12px 5px 10px;
      background: var(--bg-2);
      border: 1px solid var(--line);
      border-radius: 999px;
      text-decoration: none;
      font-size: 12px;
      color: var(--text);
      margin-right: 6px;
      transition: border-color 0.15s, transform 0.15s;
    }
    .atlas-meter:hover {
      border-color: var(--accent);
      transform: translateY(-1px);
      text-decoration: none;
    }
    .atlas-meter-glyph {
      font-size: 13px;
      line-height: 1;
    }
    .atlas-meter-text {
      font-variant-numeric: tabular-nums;
      font-weight: 600;
    }
    .atlas-meter-text strong { font-weight: 700; }
    .atlas-meter-text .muted {
      color: var(--muted);
      font-weight: 500;
      margin-left: 1px;
    }
    .atlas-meter-bar {
      width: 36px;
      height: 5px;
      background: var(--bg-3);
      border-radius: 999px;
      overflow: hidden;
    }
    .atlas-meter-fill {
      display: block;
      height: 100%;
      transition: width 0.3s, background 0.3s;
    }
    @media (max-width: 700px) {
      .atlas-meter-bar { display: none; }
    }

    /* ===== TABLE SCROLL WRAPPER — keeps wide tables from breaking small screens ===== */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* ===== MOBILE NAV — hamburger drawer + tap-to-open dropdowns ===== */
    @media (max-width: 768px) {
      header { flex-wrap: wrap; height: auto; min-height: 56px; padding: 8px 16px; gap: 10px; row-gap: 8px; }
      .nav-toggle { display: inline-flex; }
      header .who { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
      nav#primary-nav {
        order: 10; flex-basis: 100%; width: 100%;
        display: none; flex-direction: column; gap: 2px;
        padding-top: 8px; margin-top: 2px; border-top: 1px solid var(--line);
      }
      header.nav-open nav#primary-nav { display: flex; }
      nav#primary-nav > a, nav#primary-nav .nav-group { width: 100%; }
      nav#primary-nav > a, nav#primary-nav .nav-trigger {
        width: 100%; justify-content: flex-start; padding: 11px 12px; font-size: 14.5px;
      }
      nav#primary-nav .nav-group { position: static; }
      nav#primary-nav .nav-dropdown {
        position: static; display: none; box-shadow: none; border: 0;
        min-width: 0; padding: 2px 0 6px 16px; background: transparent;
      }
      /* On touch, only the tapped (.open) menu shows — disable hover-open */
      nav#primary-nav .nav-group:hover > .nav-dropdown { display: none; }
      nav#primary-nav .nav-group.open > .nav-dropdown { display: flex; }
    }

/* ── UI state components (Track 8 #85) ─────────────────────────────────────
   Canonical empty / loading / error states. Used via templates/_states.html. */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state__icon { font-size: 40px; margin-bottom: 8px; opacity: 0.6; }
.empty-state__title { margin: 0 0 6px; font-size: 18px; color: var(--accent); }
.empty-state__msg { margin: 0 auto 16px; max-width: 380px; line-height: 1.5; }
.empty-state__action, .error-state__action {
  display: inline-block; background: var(--accent); color: var(--accent-fg); text-decoration: none;
  border-radius: 8px; padding: 10px 18px; font-size: 14px;
}
.empty-state__action:hover, .error-state__action:hover { background: var(--accent-hover); }

.loading-state {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  padding: 32px; color: #5b5443;
}
.spinner {
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  border: 2px solid rgba(31, 58, 92, 0.2); border-top-color: #1F3A5C;
  animation: rn-spin 0.7s linear infinite;
}
@keyframes rn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.error-state {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  padding: 20px 24px; border-radius: 10px;
  background: rgba(138, 46, 34, 0.06); color: #8a2e22;
}
.error-state__mark {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%; background: #8a2e22; color: #fff; font-weight: 700;
}
.error-state__msg { margin: 0; }

    /* ============================================================
       COMMAND PALETTE (⌘K) — memo item 37. Token-native, both themes.
       ============================================================ */
    .cmdk-overlay {
      position: fixed; inset: 0; z-index: 800; display: none;
      background: rgba(10, 14, 24, 0.45); backdrop-filter: blur(2px);
      padding-top: 12vh;
    }
    .cmdk-overlay.open { display: block; }
    .cmdk-panel {
      width: min(640px, calc(100vw - 32px)); margin: 0 auto;
      background: var(--bg-2); border: 1px solid var(--line-strong, var(--line));
      border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
      overflow: hidden;
    }
    .cmdk-input {
      width: 100%; box-sizing: border-box; border: none; outline: none;
      border-bottom: 1px solid var(--line); border-radius: 0;
      padding: 16px 18px; margin: 0; font-size: 16px;
      background: var(--bg-2); color: var(--text); font-family: inherit;
    }
    .cmdk-input:focus { box-shadow: none; border-color: var(--line); border-bottom: 1px solid var(--line); }
    .cmdk-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
    .cmdk-section {
      font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
      color: var(--subtle); padding: 10px 12px 4px; font-weight: 700;
    }
    .cmdk-item {
      display: flex; align-items: center; gap: 10px; width: 100%;
      min-height: 44px; padding: 8px 12px; box-sizing: border-box;
      border: none; background: none; text-align: left; cursor: pointer;
      border-radius: var(--radius); color: var(--text); font-size: 14px;
      font-family: inherit; text-decoration: none;
    }
    .cmdk-item .cmdk-kind { margin-left: auto; font-size: 12px; color: var(--subtle); }
    .cmdk-item.active, .cmdk-item:hover { background: var(--accent-soft); }
    .cmdk-item.active { box-shadow: inset 2px 0 0 var(--accent); }
    .cmdk-empty { padding: 18px 14px; color: var(--muted); font-size: 14px; }
    .cmdk-hintbar {
      display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line);
      color: var(--subtle); font-size: 12px; background: var(--bg-3);
    }
    .cmdk-hintbar kbd {
      border: 1px solid var(--line-strong, var(--line)); border-radius: 4px;
      padding: 0 5px; font-family: var(--mono, monospace); font-size: 11px;
      background: var(--bg-2);
    }
    /* Header trigger — discoverability for non-keyboard users */
    .cmdk-trigger {
      display: inline-flex; align-items: center; gap: 6px;
      border: 1px solid var(--line); background: var(--bg-2); color: var(--muted);
      border-radius: var(--radius); padding: 5px 10px; font-size: 12.5px;
      cursor: pointer; font-family: inherit; min-height: 30px;
    }
    .cmdk-trigger:hover { border-color: var(--accent); color: var(--text); }
    .cmdk-trigger kbd { font-family: var(--mono, monospace); font-size: 11px; color: var(--subtle); }

    /* ============================================================
       CONSOLE SURFACE (memo items 16+17) — the sanctioned dark
       sub-theme. /brain stamps its <body> and the ATLAS widget stamps
       its root with data-surface="console"; every rule inside then
       consumes these values through the SAME semantic names the rest
       of the app uses. One system, two expressions: light stationery
       and dark console. Values match the JARVIS palette exactly, so
       adopting tokens changed nothing visually — it made the console
       tunable from here and let the header/nav follow it.
       ============================================================ */
    [data-surface="console"] {
      --bg:           #060a13;     /* deep space */
      --bg-deep:      #02040a;     /* backdrop gradient floor */
      --bg-2:         #0a1322;     /* raised card */
      --bg-3:         #101c30;     /* hover / fill */
      --line:         #18273f;
      --line-strong:  #23375a;
      --border-input: rgba(141, 180, 214, 0.45);
      --text:         #EAD9C2;     /* warm cream on space */
      --text-dim:     #D2CAB8;
      --muted:        #7C97B5;     /* 6.5:1 on --bg (computed) */
      --subtle:       #7C97B5;
      --accent:       #8DB4D6;     /* ice blue */
      --accent-hover: #A9C8E4;
      --accent-soft:  rgba(141, 180, 214, 0.14);
      --accent-fg:    #060a13;
      --good:         #2F8F5B;
      --good-soft:    rgba(47, 143, 91, 0.14);
      --warn:         #B5743E;     /* brass */
      --warn-soft:    rgba(181, 116, 62, 0.14);
      --bad:          #D77B7B;
      --bad-soft:     rgba(215, 123, 123, 0.14);
      --gold:         #E7DCC4;
      --gold-soft:    rgba(231, 220, 196, 0.16);
      --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.5);
      --shadow:       0 1px 3px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.45);
      --shadow-md:    0 4px 14px rgba(0, 0, 0, 0.5), 0 1px 4px rgba(0, 0, 0, 0.35);
      --shadow-lg:    0 18px 40px rgba(0, 0, 0, 0.6), 0 4px 8px rgba(0, 0, 0, 0.45);
      --ring:         0 0 0 3px rgba(141, 180, 214, 0.30);
    }
    /* The paper-grain + vignette belong to the stationery, not to space —
       multiplied over the starfield they just dim the console (F8). */
    body[data-surface="console"]::before,
    body[data-surface="console"]::after { display: none; }

/* ===== Inventory depth (ported from inventory-waiting-leaderboard, PR #13) ===== */

/* ── Waiting demand leaderboard (Inventory › Waiting) ──────────────────────
   Rollup-backed ranked demand. A native <meter> draws the proportional bar,
   so there's no data-driven inline width (Rule 8). */
.demand-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.demand-head__title { margin: 0; }
.demand-head__sub { font-size: 12px; }
.demand-board { display: flex; flex-direction: column; }
.demand-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) minmax(80px, 2fr) auto auto;
  gap: 14px; align-items: center;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.demand-row:last-child { border-bottom: 0; }
.demand-row__name { font-weight: 600; text-decoration: none; color: var(--text); }
.demand-row__name:hover { color: var(--accent); }
.demand-row__meter { width: 100%; height: 16px; background: var(--accent-soft); border-radius: 999px; }
.demand-row__meter::-webkit-meter-bar { background: var(--accent-soft); border: 0; border-radius: 999px; height: 16px; }
.demand-row__meter::-webkit-meter-optimum-value { background: var(--accent); border-radius: 999px; }
.demand-row__meter::-webkit-meter-suboptimum-value { background: var(--accent); border-radius: 999px; }
.demand-row__meter::-moz-meter-bar { background: var(--accent); border-radius: 999px; }
.demand-row__count { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.demand-row__action { white-space: nowrap; }
.demand-waiters { margin: 0; padding: 2px 2px 10px; border-bottom: 1px solid var(--line); }
.demand-waiters__summary { cursor: pointer; font-size: 13px; }
.demand-waiters__item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0 5px 14px; font-size: 13px; }
.demand-waiters__remove { background: none; border: 0; cursor: pointer; color: var(--bad); text-decoration: underline; font-size: 12px; padding: 0; }
@media (max-width: 640px) {
  .demand-row { grid-template-columns: 1fr auto; row-gap: 6px; }
  .demand-row__meter { grid-column: 1 / -1; order: 3; }
  .demand-row__action { grid-column: 1 / -1; order: 4; justify-self: start; }
}

/* ── Order by supplier (Inventory › Order) ─────────────────────────────────
   Groups the reorder worklist by vendor for one combined PO per supplier. */
.vorder-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.vorder-head__title { margin: 0; }
.vorder-head__sub { font-size: 12px; }
.vorder-list { display: flex; flex-direction: column; gap: 10px; }
.vorder { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.vorder__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.vorder__vendor { font-weight: 700; }
.vorder__acct { font-size: 12px; margin-left: 6px; }
.vorder__meta { font-size: 13px; margin-left: 4px; }
.vorder__details { margin-top: 8px; }
.vorder__summary { cursor: pointer; font-size: 12px; }
.vorder__lines { margin-top: 8px; display: flex; flex-direction: column; }
.vorder__line { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.vorder__line:last-child { border-bottom: 0; }
.vorder__line-qty { white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .vorder__head { align-items: flex-start; } }

/* ── Reorder-point health (Inventory › Products) ───────────────────────────
   Velocity-rollup-backed advisory: reorder points that don't fit the pace. */
.rphealth__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.rphealth__title { margin: 0; }
.rphealth__sub { font-size: 12px; }
.rphealth__list { display: flex; flex-direction: column; }
.rphealth__row { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.rphealth__row:last-child { border-bottom: 0; }
.rphealth__main { min-width: 0; }
.rphealth__name { font-weight: 600; text-decoration: none; color: var(--text); }
.rphealth__name:hover { color: var(--accent); }
.rphealth__trend { font-size: 11px; margin-left: 8px; font-weight: 600; }
.rphealth__trend--rising { color: var(--good); }
.rphealth__trend--falling { color: var(--bad); }
.rphealth__trend--new { color: var(--accent); }
.rphealth__trend--steady { color: var(--muted); }
.rphealth__reason { font-size: 12.5px; margin-top: 3px; }
.rphealth__nums { text-align: right; white-space: nowrap; }
.rphealth__badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.rphealth__badge--raise { background: var(--warn-soft); color: var(--warn); }
.rphealth__badge--lower { background: var(--accent-soft); color: var(--accent); }
.rphealth__now { display: block; font-size: 11px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.rphealth__apply { margin-top: 6px; }
.rphealth__apply-btn { font-size: 12px; }
.rphealth__foot { font-size: 12px; margin: 10px 0 0; }
@media (max-width: 600px) { .rphealth__row { flex-direction: column; gap: 6px; } .rphealth__nums { text-align: left; } }

/* ── Stockroom hero + worklist (Inventory › Order) ─────────────────────────
   The opportunity hero, top-picks, count tiles, and reorder worklist were
   inline-styled when ported from the old /restock page; declassed here so the
   whole section is system.css-driven (Rule 8). */
.sroom-wrap { max-width: 1000px; margin: 0 auto; }
.sroom-intro { margin-bottom: 18px; }
.sroom-intro__title { margin: 0 0 4px; }
.sroom-intro__text { margin: 0; color: var(--muted); }
.sroom-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.sroom-head--tight { margin-bottom: 0; }
.sroom-head__title { margin: 0; }
.sroom-head__sub { font-size: 12px; }
.sroom-stats { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.sroom-stat { flex: 1; min-width: 150px; }
.sroom-stat--alarm { background: linear-gradient(135deg, var(--bad-soft), var(--warn-soft)); border-color: var(--bad); }
.sroom-summary { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; font-size: 13.5px; color: var(--muted); padding: 11px 15px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 18px; }
.sroom-summary strong { color: var(--text); font-weight: 700; }
.sroom-summary .sroom-summary__an { margin-left: auto; color: var(--accent); font-weight: 600; }
.sroom-stat__label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.sroom-stat__num { font-size: 30px; font-weight: 700; }
.sroom-stat__num--bad { color: var(--bad); }
.sroom-stat__num--accent { color: var(--accent); }
.sroom-stat__sub { font-size: 12px; color: var(--muted); }
.sroom-picks { margin-bottom: 22px; }
.sroom-pick { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sroom-pick:last-child { border-bottom: 0; }
.sroom-pick__main { display: flex; align-items: center; gap: 12px; min-width: 240px; flex: 1; }
.sroom-pick__rank { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.sroom-pick__name { font-weight: 600; text-decoration: none; }
.sroom-pick__meta { font-size: 12px; margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.sroom-pick__right { display: flex; align-items: center; gap: 14px; }
.sroom-pick__val { text-align: right; }
.sroom-pick__val-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.sroom-pick__val-sub { font-size: 11px; }
.sroom-sort { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.sroom-sort__label { font-size: 12px; }
.sroom-item { margin-bottom: 10px; }
.sroom-item__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.sroom-item__main { flex: 1; min-width: 240px; }
.sroom-item__titlerow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sroom-item__name { font-weight: 600; }
.sroom-item__kind { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.sroom-item__reason { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.sroom-item__facts { font-size: 12px; margin-top: 6px; }
.sroom-item__opp { color: var(--text); }
.sroom-item__actions { margin-top: 8px; }
.sroom-empty { text-align: center; padding: 36px; color: var(--muted); }
/* status-tinted pills (background stays neutral, text carries the state) */
.pill--stat { background: var(--bg-3); }
.pill--urgent { color: var(--bad); }
.pill--reorder { color: var(--warn); }
.pill--ordered { color: var(--accent); }
.pill--watch { color: var(--muted); }
.pill--ok { color: var(--good); }
.pill--waiting { background: var(--accent-soft); color: var(--accent); }
.qa-btn--off { opacity: .5; pointer-events: none; }

/* ── The Worklist (Customers › Worklist, Phase 4b) ─────────────────────────
   One merged "who to reach out to today" list: restock alerts + win-backs +
   reorders, tagged and rank-ordered. Class-based (Rule 8). */
.wl-wrap { max-width: 1040px; margin: 0 auto; }
.wl-intro { margin-bottom: 16px; }
.wl-intro__title { margin: 0 0 4px; }
.wl-intro__text { margin: 0; color: var(--muted); }
.wl-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.wl-tile__label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.wl-tile__num { font-size: 30px; font-weight: 700; }
.wl-tile__num--good { color: var(--good); }
.wl-tile__num--warn { color: var(--warn); }
.wl-tile__sub { font-size: 12px; color: var(--muted); }
.wl-hero { margin-bottom: 16px; border-left: 3px solid var(--good); }
.wl-hero__label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.wl-hero__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.wl-hero__row + .wl-hero__row { border-top: 1px solid var(--line); }
.wl-hero__text { font-size: 14px; }
.wl-hero__form { margin: 0; white-space: nowrap; }
.wl-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.wl-chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font-size: 13px; cursor: pointer; font-family: inherit; }
.wl-chip:hover { background: var(--bg-3); }
.wl-chip.is-active { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.wl-bulk { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.wl-selectall { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.wl-fatigue { font-size: 12px; }
.wl-tablecard { padding: 0; overflow: hidden; }
.wl-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.wl-table thead tr { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.wl-table th { padding: 11px 14px; }
.wl-table th.wl-check { width: 28px; padding: 11px 8px; }
.wl-table th.wl-right, .wl-table td.wl-right { text-align: right; }
.wl-table td { padding: 11px 14px; vertical-align: top; }
.wl-table td.wl-check { text-align: center; padding: 11px 8px; }
.wl-row + .wl-row td { border-top: 1px solid var(--line); }
.wl-row__name { font-weight: 600; text-decoration: none; }
.wl-row__sub { font-size: 11px; color: var(--muted); }
.wl-row__reason { font-size: 12px; color: var(--text-dim); margin-top: 3px; max-width: 320px; }
.wl-worth { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.wl-actions { text-align: right; white-space: nowrap; }
.wl-tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.wl-tag--favourite_back { background: var(--good-soft); color: var(--good); }
.wl-tag--gone_quiet { background: var(--accent-soft); color: var(--accent); }
.wl-tag--overdue_reorder { background: var(--warn-soft); color: var(--warn); }
.wl-tag--seasonal { background: var(--bg-3); color: var(--text-dim); }
.wl-tag--long_tail { background: var(--bg-3); color: var(--muted); }
.wl-empty { text-align: center; padding: 40px 28px; max-width: 560px; margin: 0 auto; }
.wl-empty__icon { font-size: 32px; margin-bottom: 8px; }
.wl-empty__title { font-size: 17px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.wl-empty__text { margin: 0 auto; max-width: 430px; color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.wl-foot { font-size: 12px; color: var(--muted); margin-top: 10px; }
@media (max-width: 640px) { .wl-row__reason { max-width: none; } }

/* ── People context strip (Customers › People, Phase 4c) ───────────────────
   The full customer+revenue KPI board now lives on Home; People keeps a thin
   3-tile context strip that links there. */
.kpi-strip--thin { grid-template-columns: repeat(auto-fit, minmax(150px, 190px)); justify-content: start; align-items: center; }
.kpi-morelink { display: inline-flex; align-items: center; font-size: 13px; font-weight: 500; color: var(--accent); text-decoration: none; padding: 4px 6px; }
.kpi-morelink:hover { text-decoration: underline; }

/* MetricCard (MASTER_SPEC §3) — the one canonical metric tile. Theme-aware via
   existing tokens (no hard-coded colors). The whole card is a drill-down link. */
.metric-card {
  display: block; text-decoration: none; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.metric-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.metric-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.metric-card__label { font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.03em; }
.metric-card__value { font-size: 26px; font-weight: 700; color: var(--text);
  line-height: 1.15; margin: 4px 0 2px; }
.metric-card__comparison { font-size: 13px; color: var(--text-dim); }
.metric-card__action { font-size: 13px; color: var(--accent); margin-top: 6px; }
/* basis is the audit trail — present but quiet; §3.2 requires it, the eye doesn't. */
.metric-card__basis { font-size: 11px; color: var(--subtle); margin-top: 8px;
  padding-top: 8px; border-top: 1px solid var(--line); }
.metric-card__hedge { font-size: 11px; color: var(--warn); margin-top: 6px; font-style: italic; }
