/* ═══════════════════════════════════════════════════════════════
   Interior Moderna — Modern Theme
   Ultra-clean, architectural ops dashboard redesign
   Loaded last — overrides all prior stylesheets
   ═══════════════════════════════════════════════════════════════ */

/* ── Jost, self-hosted ──────────────────────────────────────────────
   Served from this repo, never fonts.googleapis.com. That host does not
   resolve behind the GFW and Lucy works the dashboard from China, so a
   render-blocking <link> to it cost her the brand face AND stalled the boot.
   index.html has carried a comment saying "keep the authenticated shell
   self-hosted" throughout — the Google <link> was added two lines above it.

   Weight coverage, measured against the CSS that actually uses it:
     400 (22 rules)  — exact
     600 (728 rules) — exact
     300 (0 rules)   — shipped only because the old Google request asked for it
     500 (175 rules) — NO static instance exists in brand/fonts, so it resolves
                       to 400 by normal CSS font matching: one step lighter than
                       before, never missing. Mapping it to 600 instead would
                       merge it with the single most-used weight in the app.
     700 (350 rules) — was never in the Google request either, so it resolved to
                       600 before this change and still does. Unchanged.

   Sources are brand/fonts/Jost-*-static.ttf (real static instances — verified
   OS/2 usWeightClass matches each filename), converted to woff2 with fontTools.
   61KB TTF -> ~18KB woff2 each; 60KB total for all three.
   ──────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('fonts/Jost-300.woff2') format('woff2');
}
@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/Jost-400.woff2') format('woff2');
}
@font-face {
  /* 500 (medium) — added 2026-08-16. The self-hosting pass shipped 300/400/600,
     but the stylesheet asks for `font-weight: 500` in 252 places, so every one
     of those was being SYNTHESISED by the browser from a neighbouring weight.
     That is the failure mode this whole change exists to avoid: the page looks
     almost right, so nobody reports it. */
  font-family: 'Jost';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/Jost-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/Jost-600.woff2') format('woff2');
}

/* ── Design tokens ── */
:root {
  /* Jost is the brand typeface (brand/tokens.json + the live theme's own
     custom-im.css). --font is declared as Inter in dashboard.css:31; this file
     loads LAST, so this is the declaration that wins. Do not "fix" it there —
     editing dashboard.css alone silently does nothing. */
  --font: 'Jost', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  /* Ground — brand/tokens.json cream. Cards stay white: dense tables need the
     contrast, and cream-on-cream loses the edge that makes a table scannable. */
  --bg: #eeecea;
  --surface: #ffffff;
  --surface-2: #e4e3df;   /* paper */
  --surface-3: #d9d8d3;

  /* Borders — the guidelines' hairline, opaque so it survives over both grounds */
  --border: #dedcd6;
  --border-hover: #c2c0b9;

  /* Text — carbon is the darkest permitted value; no pure black */
  --text: #0d0d0b;
  --text-muted: #6b6c64;  /* mid — 4.51:1 on cream, the body-safe grey */
  --text-dim: #7a7b72;    /* glow, NOT stone (#98998F is 2.45:1 and display-only) */

  /* Accent — the single warm terracotta, used sparingly */
  --accent: #b0664a;
  --accent-dim: rgba(176, 102, 74, 0.10);
  --accent-strong: #8a4e38;

  /* Shared shell copy must remain readable at compact label sizes. */
  --shell-secondary-text: var(--text-muted);

  /* Status.
     2026-09-03: --green and --yellow were the only two of the four status
     colours that failed 4.5:1 as TEXT on --surface — measured 3.30:1 and
     3.35:1, against --red at 4.83 and --blue at 5.17. So the palette's own
     intent was already ~5:1 and these two were simply off; they are used as
     `color:` on roughly 1,200 call sites across css/ and js/views, so fixing
     the token fixes all of them at once rather than editing 1,200 lines.
     #15803d is 5.02:1 and #a16207 is 4.92:1 — the same hues, one step darker,
     now sitting beside their siblings. Where either is a BACKGROUND it pairs
     with #fff, which goes from 3.30 to 5.02 too, so that direction improves as
     well. Dark mode is untouched: it defines its own lighter values, which are
     already ~7-9:1 on the dark surface. */
  --green: #15803d;
  --green-dim: rgba(22, 163, 74, 0.09);
  --green-strong: #166534;
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.08);
  --yellow: #a16207;
  --yellow-dim: rgba(201, 122, 6, 0.09);
  --yellow-strong: #854d0e;
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.08);
  --purple: #7c3aed;
  --purple-dim: rgba(124, 58, 237, 0.08);
  --emerald: #059669;
  --emerald-dim: rgba(5, 150, 105, 0.09);
  --orange: #ea6c00;
  --orange-dim: rgba(234, 108, 0, 0.09);
  --orange-strong: #9a3412;

  /* Radius */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.09), 0 2px 6px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.13), 0 4px 16px rgba(0, 0, 0, 0.07);

  /* Sidebar tokens — light mode: white panel matching main content */
  --sidebar-bg: var(--surface);
  --sidebar-border: var(--border);
  --sidebar-text: var(--text-muted);
  --sidebar-text-hover: var(--text);
  --sidebar-text-active: var(--text);
  --sidebar-hover-bg: var(--surface-2);
  --sidebar-active-bg: var(--surface-2);
  --sidebar-section-title: var(--shell-secondary-text);

  /* Alias fixes — maps legacy/view-specific var names → design tokens */
  --text-primary: var(--text);
  --text-secondary: var(--text-muted);
  --surface-1: var(--surface);
  --surface-raised: var(--surface);
  --surface-alt: var(--surface-2);       /* legacy dark-surface alias */
  --bg-hover: var(--surface-2);
  --hover-bg: var(--surface-2);          /* analytics-dash chart track — also override in dark */
  --card-bg: var(--surface);
  --bg-secondary: var(--surface-2);
  --primary: var(--accent);
  --danger: var(--red);
  --danger-dim: var(--red-dim);
  --success: var(--green);
  --warning: var(--yellow);
  --info: var(--blue);
  --bg-card: var(--surface);
  --bg-primary: var(--bg);
  --bg-tertiary: var(--surface-3);
  --bg2: var(--surface-2);
  --border-color: var(--border);
  --border-light: var(--border);
  --danger-color: var(--red);
  --surface-hover: var(--surface-2);

  /* Semantic status dims (aliases to the color dims) */
  --success-dim: var(--green-dim);
  --warning-dim: var(--yellow-dim);
  --info-dim: var(--blue-dim);

  /* ── Spacing scale (4px base) ──
     The app previously had NO spacing tokens — every padding/margin was a
     magic number, which is the main reason rhythm drifts view to view. New
     work should reach for these; existing magic numbers get migrated over time. */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ── Type scale ──
     Note: --text/--text-muted/--text-dim above are COLORS (legacy naming).
     These --fs-* tokens are the font-SIZE scale. */
  --fs-2xs: 10px;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 18px;
  --fs-2xl: 22px;
  --fs-3xl: 28px;

  /* ── Font weights ── */
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* ── Line heights ── */
  --leading-tight: 1.2;
  --leading-normal: 1.45;
  --leading-relaxed: 1.6;

  /* ── Motion tokens ──
     The app had ~14 distinct one-off transition durations + duplicate easings.
     These are the canonical set; new work references them. */
  --dur-fast: 0.12s;
  --dur: 0.18s;
  --dur-slow: 0.3s;
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-decel: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ─────────────────────────────────────────────────────────────
   GLOBAL BASE
   ───────────────────────────────────────────────────────────── */

body {
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─────────────────────────────────────────────────────────────
   LAYOUT
   ───────────────────────────────────────────────────────────── */

.app {
  grid-template-columns: 192px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
}

/* ─────────────────────────────────────────────────────────────
   HEADER
   ───────────────────────────────────────────────────────────── */

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 8px 20px;
  min-height: 52px;
  height: auto;
}

.header-left {
  flex: 0 1 auto;
  min-width: 0;
  gap: 12px;
}

.header-left > div {
  min-width: 0;
}

.header-right {
  flex: 1 1 720px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.header-status-group,
.header-action-group,
.header-account-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.header-status-group {
  flex: 1 1 420px;
}

.header-action-group,
.header-account-group {
  flex: 0 1 auto;
}

/* Fold the whole header onto ONE row on desktop — no wrapping to a second line
   (Cole/Nicolas 2026-07-18: save vertical space). The nav-hub strip is the
   flexible middle that shrinks + scrolls horizontally if things get tight, so
   the account cluster (View-as + user + sign out) stays on the same line.
   Mobile (≤768px, css/mobile.css) keeps its own stacked layout. */
@media (min-width: 769px) {
  .header { flex-wrap: nowrap; }
  .header-right { flex-wrap: nowrap; min-width: 0; }
  .header-status-group,
  .header-action-group,
  .header-account-group { flex-wrap: nowrap; min-width: 0; }
  /* The status group defaults to flex:1 1 420px and GROWS, stealing width from
     the rest of the row. Stop it growing so everything stays on one line. */
  .header-status-group { flex: 0 1 auto; }
  /* The hamburger is phone-only. dashboard.css's combined `.icon-btn,
     .mobile-menu-btn.icon-btn { display:inline-flex }` rule (2-class
     specificity) was overriding `.mobile-menu-btn { display:none }` (1-class),
     so the hamburger showed on EVERY desktop width next to the already-open
     sidebar — the "half a hamburger" glitch. Force it hidden on desktop; the
     sidebar rail is the only nav here (feedback_no-hamburger-on-desktop.md).
     !important because dashboard.css sets `display:inline-flex !important` on
     the combined `.icon-btn` rule. */
  .header .mobile-menu-btn.icon-btn { display: none !important; }
}

.logo {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
}

.logo-sub {
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--shell-secondary-text);
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
}

.refresh-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 11px;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease, opacity 0.14s ease;
  letter-spacing: 0;
}

.refresh-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text);
}

.sync-now-btn {
  background: transparent;
  border-color: rgba(37, 99, 235, 0.3);
  color: var(--blue);
}

.sync-now-btn:hover {
  background: var(--blue-dim);
  border-color: var(--blue);
}

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 10.5px;
  color: var(--text-dim);
  gap: 5px;
  white-space: nowrap;
}

.sync-dot {
  width: 5px;
  height: 5px;
}

.notification-bell-container {
  display: flex;
  align-items: center;
}

.notification-bell-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  flex-shrink: 0;
}

.notification-badge {
  top: -2px;
  right: -1px;
}

.notification-panel {
  width: min(360px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
}

.header-freshness-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  white-space: nowrap;
}

.header-freshness-label {
  font-size: 11px;
  color: var(--text-muted);
}

#data-freshness-dot,
.header-freshness-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  min-height: 8px;
  border-radius: 50%;
  display: block;
  background: #6b7280;
  transition: background 0.3s;
  flex-shrink: 0;
}

.freshness-tooltip,
.health-popover,
.api-health-panel {
  max-width: calc(100vw - 24px);
}

.freshness-tooltip {
  width: min(320px, calc(100vw - 24px));
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  gap: 5px;
  font-size: 10.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.live-indicator.active {
  border-color: rgba(22, 163, 74, 0.18);
}

.live-indicator.refreshing {
  border-color: rgba(166, 124, 82, 0.2);
}

.health-dot-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  flex-shrink: 0;
}

.health-dot {
  width: 8px;
  height: 8px;
}

.api-health-wrap {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.api-health-panel {
  width: min(440px, calc(100vw - 24px));
}

/* ═══════════════════════════════════════════════════════════
   R1 DESIGN — Unified header status rail
   The freshness / sync / live / health / API indicators were six
   separate floating pills, reading as a scattered row of "rainbow"
   dots. Group them into one calm segmented instrument rail: a single
   hairline-bordered surface with thin dividers between segments.
   Status colour stays on the inner dots (where it carries meaning).
   Visual only — no markup or behaviour change. Desktop only; the
   whole group is hidden under 768px (mobile.css).
   ═══════════════════════════════════════════════════════════ */
.header-status-group {
  flex: 0 1 auto;
  gap: 0;
  flex-wrap: nowrap;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.header-status-group > .notification-bell-container,
.header-status-group > .header-freshness-wrap,
.header-status-group > .sync-status,
.header-status-group > .live-indicator,
.header-status-group > .health-dot-wrap,
.header-status-group > .api-health-wrap {
  border: none;
  background: transparent;
  box-shadow: none;
  min-height: 30px;
  border-radius: 999px;
}
/* the bell / health are bordered circles in their own right — flatten
   them into the rail too */
.header-status-group .notification-bell-btn,
.header-status-group > .health-dot-wrap {
  border: none;
  background: transparent;
  box-shadow: none;
}
/* hairline dividers between segments (every segment after the first) */
.header-status-group > .header-freshness-wrap,
.header-status-group > .sync-status,
.header-status-group > .live-indicator,
.header-status-group > .health-dot-wrap,
.header-status-group > .api-health-wrap {
  border-left: 1px solid var(--border);
}

/* ── Consolidated system-status chip ─────────────────────────────────────
   The five raw indicators (freshness / sync / live / health / api) are rolled
   up into ONE readable "● System" chip. The originals stay in the DOM so their
   pollers keep running — hidden here — and #systemStatusChip reads their state.
   !important because #healthDotWrap toggles its own inline display. */
.header-status-group > .header-freshness-wrap,
.header-status-group > .sync-status,
.header-status-group > .live-indicator,
.header-status-group > .health-dot-wrap,
.header-status-group > .api-health-wrap {
  display: none !important;
}
.header-system-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 11px;
  border-left: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text-muted);
  transition: color 0.14s;
}
.header-system-chip:hover,
.header-system-chip[aria-expanded="true"] { color: var(--text); }
.header-system-chip:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.sys-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--text-muted);
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent);
}
.sys-chip-dot--ok      { background: #16a34a; }
.sys-chip-dot--warn    { background: #f59e0b; }
.sys-chip-dot--bad     { background: #dc2626; box-shadow: 0 0 0 3px color-mix(in srgb, #dc2626 22%, transparent); }
.sys-chip-dot--unknown { background: #a09d97; }
.sys-chip-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
/* Dropdown panel */
.sys-chip-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1200;
  width: 268px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,0.16));
  color: var(--text);
}
.sys-chip-panel[hidden] { display: none; }
.sys-chip-panel-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 6px 8px 8px;
}
.sys-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
}
.sys-row + .sys-row { border-top: 1px solid var(--border); }
.sys-row-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.sys-row-dot--ok      { background: #16a34a; }
.sys-row-dot--warn    { background: #f59e0b; }
.sys-row-dot--bad     { background: #dc2626; }
.sys-row-dot--unknown { background: #a09d97; }
.sys-row-name  { font-size: 12px; font-weight: 600; flex: 0 0 auto; }
.sys-row-detail {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sign out button */
.refresh-btn,
.sign-out-btn {
  min-height: 34px;
  border-radius: 6px;
  font-size: 10.5px;
  padding: 4px 10px;
  white-space: nowrap;
}

.shell-search-btn {
  gap: 6px;
  display: inline-flex;
  align-items: center;
}

/* Mobile-only header buttons are HIDDEN on desktop (2026-08-13, Cole: "why is
   there a refresh circle button, another refresh button, and a sync now
   button? This seems really excessive"). css/mobile.css turns these on inside
   its ≤768px media query; only .mobile-messages-btn had the matching base
   `display:none` (css/messages.css), so the refresh + Jarvis icons leaked onto
   desktop and duplicated the text "⟳ Refresh" button beside them. Any NEW
   .mobile-*-btn added to the header must be listed here too. */
.header .mobile-refresh-btn.icon-btn,
.header .mobile-jarvis-btn.icon-btn {
  display: none !important;
}

.theme-toggle-btn {
  width: 34px;
  height: 34px;
}

.user-info {
  min-height: 34px;
  padding-left: 12px;
  gap: 8px;
  min-width: 0;
}

/* Long names (or zh strings) truncate instead of pushing the row wide. */
.user-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-as-switcher {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

/* Tiny eyebrow that names each pill group — "Dashboards" vs "View as"
   (2026-07-18: the two rows looked identical; you couldn't tell which one
   you were clicking into). */
.switcher-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 4px 0 8px;
  white-space: nowrap;
  user-select: none;
}

/* View-as gets an accent-tinted frame so it reads as a different control
   from the plain dashboard tabs. */
.view-as-switcher#viewAsSwitcher {
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

/* "View as Supplier" factory dropdown */
.supplier-view-wrap {
  position: relative;
  display: inline-flex;
}

.supplier-view-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 300;
  min-width: 200px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg, 0 10px 30px rgba(0, 0, 0, 0.2));
  padding: 6px;
}

.supplier-view-hint {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 4px 8px 6px;
}

.supplier-view-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.supplier-view-item:hover {
  background: var(--accent-dim);
}

.supplier-view-item.active {
  background: var(--accent);
  color: var(--accent-contrast, #fff);
}

.supplier-view-loading {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-dim);
}

/* The dashboard quick-switcher (Brief/Warehouse/Factory/…) scrolls within
   its slot rather than forcing the row wider than the viewport. */
.dashboard-switcher {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
}

.dashboard-switcher::-webkit-scrollbar {
  display: none;
}

.view-mode-indicator {
  min-height: 34px;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────
   SIDEBAR — DARK
   ───────────────────────────────────────────────────────────── */

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 0 0 28px;
  overflow-y: auto;
}

.sidebar-mobile-account {
  display: none;
}

.sidebar > .nav-section:first-of-type {
  margin-top: 4px;
}

/* Nav section containers */
.nav-section {
  margin-bottom: 1px;
}

/* Section header (collapsible title row) */
.nav-section-header {
  padding: 5px 12px;
  transition: background 0.14s;
}

.nav-section-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.nav-section-title {
  font-size: 9.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--sidebar-section-title);
  padding: 0;
  margin: 0;
}

.nav-section-arrow {
  color: var(--sidebar-section-title);
  font-size: 8px;
}

/* Section items container */
.nav-section-items {
  padding: 1px 8px;
}

.nav-section-items.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* Nav items */
.nav-item {
  color: var(--sidebar-text);
  padding: 5px 8px;
  border-radius: 6px;
  gap: 8px;
  font-size: 12px;
  margin: 1px 0;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-hover);
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  font-weight: 500;
}

.nav-item.active::before {
  background: var(--accent);
  left: -8px;
  width: 2.5px;
  border-radius: 0 2px 2px 0;
}

.nav-item .icon {
  font-size: 12.5px;
  opacity: 0.65;
  width: 16px;
}

.nav-item.active .icon {
  opacity: 1;
}

/* Nav badges */
.nav-item .badge {
  background: var(--red-dim);
  color: var(--red);
  border-radius: 8px;
  font-size: 9.5px;
  padding: 1px 6px;
}

.nav-item .badge.green {
  background: var(--green-dim);
  color: var(--green);
}

/* Pinned section */
.nav-section-pinned {
  border-bottom: 1px solid var(--sidebar-border);
  padding-bottom: 6px;
  margin-bottom: 6px;
}

.nav-section-pinned .nav-section-title {
  color: rgba(166, 124, 82, 0.6);
}

/* Dark sidebar scrollbar */
.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: #2a2a27;
  border-radius: 2px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: #3a3a37;
}

/* ─────────────────────────────────────────────────────────────
   MAIN CONTENT AREA
   ───────────────────────────────────────────────────────────── */

/* 2026-07-30 density pass: measured across six data views at 1280x800, the
   space spent before the FIRST data row ran 82-411px. Refunds was the worst —
   411px, over half the screen, of which ~58px was band gaps and 22px was this
   top padding. Trimming the two GLOBAL contributors (this and .page-header
   below) recovers height on every view at once, which is better leverage than
   fixing one view's filter block. The bottom 80px stays: it is what keeps the
   last row clear of the floating dock/launcher. */
.main {
  background: var(--bg);
  padding: 14px 24px;
  padding-bottom: 80px;
}

/* ─────────────────────────────────────────────────────────────
   PAGE HEADER
   ───────────────────────────────────────────────────────────── */

.page-header {
  margin-bottom: 12px;
}

.page-header--compact {
  margin-bottom: 12px;
}

.page-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 400;
  letter-spacing: 0;
}

.compact-copy-hidden {
  display: none !important;
}

/* Data freshness bar */
.data-freshness {
  font-size: 10.5px;
  margin: -2px 0 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  letter-spacing: 0;
}

/* ─────────────────────────────────────────────────────────────
   STAT CARDS
   ───────────────────────────────────────────────────────────── */

.stats-row {
  gap: 10px;
  margin-bottom: 18px;
}

/* KPI card grid — base layout. Several views inject their own (often unscoped)
   .kpi-grid rule, so a view loaded BEFORE one of those would lose its grid and
   stack the cards vertically. This base rule guarantees the grid everywhere;
   per-view injected styles still override gap/margin. (mobile.css narrows the
   column count under media queries.) */
.kpi-grid { display: grid; gap: var(--space-4); }
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-5 { grid-template-columns: repeat(5, 1fr); }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

/* Owner 2026-07-11: numbers should sit centered under their label on every
   stat card, everywhere in the dashboard — this is the single shared base
   these views extend (directly, or via a per-view ".xyz-stat-card .stat-*"
   rule that only overrides size/color, never alignment), so centering here
   cascades app-wide without per-view edits. */
.stat-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
  text-align: center;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.1;
  text-align: center;
}

.stat-detail {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 5px;
  text-align: center;
}

/* Owner 2026-07-11 (part 2): "every subtab everywhere" — many views name
   their stat tiles with per-view prefixes (.sys-stat-value, .rm-stat-label,
   .rt-stat-value, .sc-stat-label, …) that do NOT inherit from the shared
   .stat-* base above, but render the same label-above-number shape. The
   substring match sweeps them all; #mainContent qualification out-ranks the
   per-view class rules so stray text-aligns can't win. A tile that genuinely
   must be left-aligned can override with its own #mainContent-qualified rule. */
#mainContent [class*="stat-label"],
#mainContent [class*="stat-value"],
#mainContent [class*="stat-detail"] {
  text-align: center;
}

/* ─────────────────────────────────────────────────────────────
   TABLE
   ───────────────────────────────────────────────────────────── */

/* `clip`, not `hidden`, and the difference is the whole point. Both clip the
   table's square background to this card's 10px radius — that is what the
   property is here for, since neither `table` nor `thead th` carries a radius
   of its own. But `overflow: hidden` ALSO makes this box a scroll container,
   and a scroll container is what `position: sticky` resolves against. So the
   global `thead th { position: sticky; top: 0 }` rule was pinning headers to
   an inert, never-scrolling box: 20 tables wrapped in a bare `.table-container`
   with no inner `.table-scroll` had no working sticky header on desktop.
   `overflow: clip` clips identically and creates NO scroll container, so those
   headers now pin against the page — which is also what `_applyStickyTheadWraps`
   in js/ui-enhancements.js says it wants ("keeps the page as the only
   scroller"), and it still adds no 74vh wrapper here because `clip` does not
   match its /(auto|scroll)/ test. Verified 2026-09-03: `.table-scroll` already
   carries `overflow-y: auto` at base (dashboard.css), so the far more common
   nested pattern was never affected either way. */
.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: clip;
}

th {
  background: var(--surface-2);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

th:hover {
  color: var(--text-muted);
}

td {
  padding: 10px 14px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tr:hover td {
  background: var(--bg-hover);
}

tr:last-child td {
  border-bottom: none;
}

/* ─────────────────────────────────────────────────────────────
   STATUS PILLS / BADGES
   ───────────────────────────────────────────────────────────── */

.pill {
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  display: inline-block;
}

/* Container Ship Hold picklists — auto-created from a container receive
   close, units are pre-ordered + need to ship today. Orange = urgency
   (matches the warning palette without screaming red). 2026-05-26. */
/* Measured 2026-09-03: #fff on #ea580c is 3.56:1 and on #f97316 is 2.80:1 —
   both under the 4.5:1 body-text bar, in BOTH themes. This is a pill a picker
   reads to decide something ships today, so it has to be legible in a bright
   warehouse. #c2410c is 5.18:1 and still unmistakably the urgency orange. */
.pl-ship-hold-pill {
  background: #c2410c;
  color: #fff;
  margin-left: 6px;
}
[data-theme="dark"] .pl-ship-hold-pill {
  background: #c2410c;
  color: #fff;
}

/* Waiting badge on Container Ship Hold rows — days since order date.
   Rows rank oldest-first (2026-07-18); the badge shows the picker why.
   Tiers: ≤14d muted, 15-30d warning, >30d critical. */
.pld-wait-badge { margin-left: 4px; }
.pld-wait-ok { background: var(--surface-2); color: var(--text-muted); }
.pld-wait-warn { background: var(--yellow-dim); color: var(--yellow); }
.pld-wait-crit { background: var(--red-dim); color: var(--red); }

/* ─────────────────────────────────────────────────────────────
   TOOLBAR / FILTERS
   ───────────────────────────────────────────────────────────── */

.toolbar {
  gap: 8px;
  margin-bottom: 14px;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  padding: 7px 12px;
  transition: border-color 0.14s, box-shadow 0.14s;
  color: var(--text);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(166, 124, 82, 0.10);
  outline: none;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  padding: 6px 13px;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}

.filter-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text);
}

.filter-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.14s;
}

.filter-select:focus {
  border-color: var(--border-hover);
}

.form-input {
  font-size: 13px;
}

@media (max-width: 768px) {
  .search-input,
  .filter-select,
  .form-input {
    font-size: 16px !important;
  }
}

/* Toggle group */
.toggle-group {
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.toggle-btn {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  padding: 6px 13px;
  border-right: 1px solid var(--border);
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}

.toggle-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.toggle-btn.active {
  background: var(--text);
  color: var(--surface);
  font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────
   BUTTONS
   ───────────────────────────────────────────────────────────── */

.action-btn {
  background: var(--text);
  border: 1px solid var(--text);
  color: var(--surface);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease, opacity 0.14s ease;
}

.action-btn:hover {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* Expand button in table rows */
.expand-btn {
  border-radius: 4px;
  color: var(--text-dim);
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}

.expand-btn:hover {
  background: var(--surface-2);
  color: var(--text-muted);
}

/* ─────────────────────────────────────────────────────────────
   PAGINATION
   ───────────────────────────────────────────────────────────── */

.pagination {
  padding: 11px 14px;
  font-size: 11.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.pagination-btns button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 11px;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}

.pagination-btns button:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text);
}

/* ─────────────────────────────────────────────────────────────
   LOADING / SPINNER
   ───────────────────────────────────────────────────────────── */

.spinner {
  border-color: var(--border);
  border-top-color: var(--accent);
  width: 18px;
  height: 18px;
}

/* Skeleton shimmer — warmer tones */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
}

/* ─────────────────────────────────────────────────────────────
   SCROLLBARS (content area)
   ───────────────────────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-thumb {
  background: #d4d1cb;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #b8b5af;
}

/* ─────────────────────────────────────────────────────────────
   LOGIN SCREEN
   ───────────────────────────────────────────────────────────── */

.login-overlay {
  background: #0f0f0e;
}

.login-card {
  background: #1a1a18;
  border: 1px solid #2a2a27;
  border-radius: 14px;
  padding: 44px 40px;
  width: 360px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.login-logo {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #f0ede8;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 11px;
  letter-spacing: 0.8px;
  color: #5a5a57;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.login-card input[type="password"] {
  background: #111110;
  border: 1px solid #2a2a27;
  border-radius: 8px;
  color: #f0ede8;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-card input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(166, 124, 82, 0.15);
}

.login-card input[type="password"]::placeholder {
  color: #3a3a37;
  letter-spacing: 3px;
}

/* The login card carries its OWN fixed dark palette, independent of
   data-theme — but this one button pulled the theme-variable --accent, so with
   the app set to dark it rendered #fff on #c99079: 2.71:1, on the sign-in
   action. Fixed to the light-theme accent value it was designed against
   (4.33:1), darkened to 6.28:1 so it clears the bar on its own dark card. */
.login-card button {
  background: #8f4f38;
  color: #fff;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  transition: opacity 0.14s, transform 0.14s;
}

.login-card button:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
}

.login-error {
  color: #f87171;
}

/* ─────────────────────────────────────────────────────────────
   NOTIFICATION BELL (header)
   ───────────────────────────────────────────────────────────── */

/* .jarvis-notification-bell — full definition later in file (line ~1263) */

/* ─────────────────────────────────────────────────────────────
   HEALTH / STATUS DOTS (header)
   ───────────────────────────────────────────────────────────── */

.health-popover {
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}

.freshness-tooltip {
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}

/* ─────────────────────────────────────────────────────────────
   CRITICAL ALERT BANNER
   ───────────────────────────────────────────────────────────── */

#critical-alerts-banner {
  background: #991b1b;
}

/* ─────────────────────────────────────────────────────────────
   MOBILE
   ───────────────────────────────────────────────────────────── */

/* Single-column + drawer-styled sidebar is PHONE-only (≤768px, where the
   sidebar actually becomes a position:fixed slide-in drawer). This was ≤900px,
   which collapsed .app to one column at 769–900 while the sidebar was still an
   inline rail — so it stacked as a short block with the main view full-width
   below it (the "dashboard starts halfway down" break). 769–900 now keeps the
   2-column rail (dashboard.css tablet squeeze). */
@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    width: 256px;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.6);
  }

  .main {
    padding: 14px;
  }
}

/* ─────────────────────────────────────────────────────────────
   MODAL / OVERLAY PANELS
   ───────────────────────────────────────────────────────────── */

.modal-backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.modal {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
}

/* ─────────────────────────────────────────────────────────────
   VIEW FADE-IN ANIMATION
   ───────────────────────────────────────────────────────────── */

/* viewFadeIn — defined once later in "BETTER PAGE TRANSITION" section */

/* ─────────────────────────────────────────────────────────────
   SECTION CARDS (panel / card wrappers used across views)
   ───────────────────────────────────────────────────────────── */

.card,
[class*="-card"]:not(.login-card):not(.stat-card) {
  border-radius: var(--radius);
}

/* ─────────────────────────────────────────────────────────────
   SIDEBAR MOBILE OVERLAY
   ───────────────────────────────────────────────────────────── */

.sidebar-overlay {
  background: rgba(0, 0, 0, 0.65);
}

/* ─────────────────────────────────────────────────────────────
   COMMAND PALETTE / GLOBAL SEARCH
   ───────────────────────────────────────────────────────────── */

/* .command-palette — full definition later in file (line ~1851) */

/* ─────────────────────────────────────────────────────────────
   EMPTY STATES
   ───────────────────────────────────────────────────────────── */

/* .empty-state — full definition later in file (line ~3432) */

/* ─────────────────────────────────────────────────────────────
   APPROVAL QUEUE / ACTION ITEMS special accent
   ───────────────────────────────────────────────────────────── */

.action-row:hover td {
  background: rgba(166, 124, 82, 0.04);
}

/* ─────────────────────────────────────────────────────────────
   TABS
   ───────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.14s, border-color 0.14s;
  letter-spacing: 0;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────
   SIDE PANEL (detail drawer)
   ───────────────────────────────────────────────────────────── */

.side-panel-overlay {
  background: rgba(0, 0, 0, 0.35);
}

/* ⛔ THE FLOATING LAUNCHERS DO NOT SIT ON TOP OF A DRAWER'S BUTTONS.
   Cole 2026-09-06, with a screenshot of the Messages bubble (badge 12) and the
   Jarvis "J" pill printed straight across the words "Open full page":
   "There's an overlap between the messages bubble and the Jarvis icon, and then
   the 'Open in Price Menu' / 'Open that item in the real page' button. Let's not
   let that happen."

   🔑 It is a STACKING mismatch, not a layout one, and z-index cannot settle it.
   `#imFloatingControls` is `position: fixed` on <body> at z-index 8900; every
   `.side-panel` is 202 and `.msg-actdrawer` is 41 inside #msgShell — so the
   launchers paint over both, and they land in the bottom-right corner, which is
   exactly where a right-anchored drawer puts its footer actions. (Recorded as a
   known overlap on 2026-08-20 and left alone; this is the fix.) Raising the
   drawer instead would only trade the problem: the scrim is 60% translucent, so
   the launchers would still show through, greyed and dead.

   A drawer is a modal reading surface and the launchers are ambient, so they
   stand down while one is open — the ordinary convention, and reversible the
   moment it closes (a `.side-panel` only exists in the DOM while open). An OPEN
   dock is exempt: that is a conversation the reader is in, not ambient chrome.
   Each selector is paired with a `> body` child form for the orphan case, where
   a launcher never got reparented into the shared wrapper (the 2026-08-17
   mount race — see js/jarvis-assistant.js ensureFloatingControlsHome).
   `!important` because the dock injects its own `display` rules at runtime,
   after every linked stylesheet. */
body:has(.side-panel) #imFloatingControls:not(:has(#imTeamChatDock.is-open)),
body:has(#msgActDrawer) #imFloatingControls:not(:has(#imTeamChatDock.is-open)),
body:has(.side-panel) > .jarvis-assistant-btn,
body:has(#msgActDrawer) > .jarvis-assistant-btn,
body:has(.side-panel) > #imTeamChatDock:not(.is-open),
body:has(#msgActDrawer) > #imTeamChatDock:not(.is-open),
/* The Iris coach pill (js/cs-coach-dock.js, "N rulings waiting") sat over the
   Admin Queue case sheet's Done / Reject on a phone (2026-09-11). Collapsed it
   is ambient like the rest; an open coach panel is exempt, as the dock is. */
body:has(.side-panel) > #imCsCoachDock:not(:has(.csc-panel)),
body:has(#msgActDrawer) > #imCsCoachDock:not(:has(.csc-panel)) {
  display: none !important;
}

.side-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.1);
  width: 440px;
}

.side-panel-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.side-panel-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.side-panel-email {
  font-size: 11.5px;
  color: var(--text-muted);
}

.close-btn {
  color: var(--text-dim);
  font-size: 20px;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s, color 0.14s;
}

.close-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.side-panel-stats {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  gap: 1px;
}

.sp-stat {
  background: var(--surface);
  padding: 12px 10px;
}

.sp-stat-val {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sp-stat-label {
  font-size: 9px;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 2px;
}

.side-panel-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.sp-section-title {
  font-size: 9.5px;
  letter-spacing: 0.9px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.sp-order-card {
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
}

.sp-order-note {
  background: var(--accent-dim);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11px;
}

/* ─────────────────────────────────────────────────────────────
   ROW DETAIL EXPANSION PANEL
   ───────────────────────────────────────────────────────────── */

.row-detail-panel {
  background: var(--bg);
  border-radius: var(--radius);
  margin: 4px 12px 4px;
  border: 1px solid var(--border);
  padding: 14px 16px;
}

.row-detail-section {
  margin-bottom: 12px;
}

.row-detail-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 5px;
}

/* ─────────────────────────────────────────────────────────────
   NOTE EDITOR POPUP
   ───────────────────────────────────────────────────────────── */

.note-editor-popup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.note-editor-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.note-textarea {
  background: var(--bg);
  border: none;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.6;
}

.note-textarea::placeholder {
  color: var(--text-dim);
}

.note-editor-footer {
  border-top: 1px solid var(--border);
  padding: 8px 12px;
}

.note-save-btn {
  background: var(--accent) !important;
  color: #fff !important;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 14px;
}

/* ─────────────────────────────────────────────────────────────
   MORNING BRIEF CARDS
   ───────────────────────────────────────────────────────────── */

.brief-grid {
  gap: 12px;
  margin-bottom: 16px;
}

.brief-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.18s, border-color 0.18s;
}

.brief-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
}

.brief-card.urgent {
  border-color: var(--red);
  border-width: 1px;
  box-shadow: 0 0 0 1px var(--red), var(--shadow-xs);
}

.brief-card.stale {
  border-color: var(--yellow);
  opacity: 0.75;
}

.brief-card-title {
  font-size: 9.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.brief-metric {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.1;
}

.brief-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* .brief-urgent-item — full definition later in file */

.brief-agent-dot {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11.5px;
}

/* Aging / SLA bars */
.aging-bar-track {
  background: var(--surface-2);
  border-radius: 4px;
  height: 18px;
}

/* ─────────────────────────────────────────────────────────────
   TREND INDICATORS
   ───────────────────────────────────────────────────────────── */

.trend-up {
  color: var(--green);
  font-size: 10.5px;
  font-weight: 600;
}

.trend-down {
  color: var(--red);
  font-size: 10.5px;
  font-weight: 600;
}

.trend-flat {
  color: var(--text-dim);
  font-size: 10.5px;
}

/* ─────────────────────────────────────────────────────────────
   FORM INPUTS (modal forms)
   ───────────────────────────────────────────────────────────── */

.form-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 9px 12px;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(166, 124, 82, 0.10);
}

.form-input::placeholder {
  color: var(--text-dim);
}

/* ─────────────────────────────────────────────────────────────
   ACTIVITY FEED
   ───────────────────────────────────────────────────────────── */

.feed-item {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  gap: 10px;
}

.feed-item:hover {
  background: var(--bg-hover);
}

.feed-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 13px;
  flex-shrink: 0;
}

.feed-desc {
  font-size: 12.5px;
}

.feed-meta {
  font-size: 10.5px;
  color: var(--text-muted);
}

.feed-filter-btn {
  border-radius: 20px;
  font-size: 11px;
  padding: 3px 11px;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}

.feed-filter-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}

/* ─────────────────────────────────────────────────────────────
   JARVIS NOTIFICATION PANEL
   ───────────────────────────────────────────────────────────── */

.jarvis-notif-wrap {
  position: relative;
}

.jarvis-notification-bell {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  color: var(--text-muted);
  transition: background 0.14s, color 0.14s;
}

.jarvis-notification-bell:hover {
  background: var(--surface-2);
  color: var(--text);
}

.jarvis-notification-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 380px;
}

.jarvis-notif-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.jarvis-notif-panel-title {
  font-size: 12.5px;
  font-weight: 600;
}

.jarvis-notif-dismiss-all {
  font-size: 10.5px;
  color: var(--text-muted);
  border-radius: 5px;
  padding: 3px 8px;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}

.jarvis-notif-dismiss-all:hover {
  background: var(--surface-2);
  color: var(--text);
}

.jarvis-notification-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  transition: background 0.12s;
}

.jarvis-notification-item:hover {
  background: var(--bg-hover);
}

.jarvis-notification-item.unread {
  background: rgba(166, 124, 82, 0.03);
}

/* Priority border indicators */
.jarvis-notification-item.priority-border-critical { border-left-color: var(--red); }
.jarvis-notification-item.priority-border-high { border-left-color: var(--yellow); }
.jarvis-notification-item.priority-border-warning { border-left-color: var(--yellow); }
.jarvis-notification-item.priority-border-medium { border-left-color: var(--blue); }
.jarvis-notification-item.priority-border-low { border-left-color: var(--border); }
.jarvis-notification-item.priority-border-info { border-left-color: var(--blue); }

.jarvis-notif-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12px;
}

.jarvis-notif-title {
  font-size: 12px;
  font-weight: 500;
}

.jarvis-notif-message {
  font-size: 11px;
  color: var(--text-muted);
}

.jarvis-notif-meta {
  font-size: 10px;
  color: var(--text-dim);
}

.jarvis-notif-cluster-item {
  background: var(--surface-2);
  border-radius: 5px;
  font-size: 11px;
}

/* ─────────────────────────────────────────────────────────────
   JARVIS GLOBAL CHAT PANEL
   ───────────────────────────────────────────────────────────── */

.jarvis-global-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.09);
  width: 420px;
}

.jg-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
}

.jg-header-icon {
  background: linear-gradient(135deg, #a67c52 0%, #c9a96e 100%);
  border-radius: 9px;
  width: 34px;
  height: 34px;
  font-size: 15px;
}

.jg-header-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.jg-header-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

.jg-header-btn {
  border-radius: 6px;
  font-size: 11px;
  padding: 4px 8px;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}

.jg-header-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hover);
}

#jg-messages {
  background: var(--bg);
  padding: 16px 16px;
  gap: 12px;
}

.jg-msg-bubble {
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 13px;
}

.jg-msg-user .jg-msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.jg-msg-assistant .jg-msg-bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}

.jg-suggested-action {
  border-radius: 16px;
  font-size: 11px;
  padding: 3px 10px;
}

.jg-data-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-xs);
}

/* Input area */
.jg-input-area {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 14px;
}

.jg-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 9px 12px;
  transition: border-color 0.14s, box-shadow 0.14s;
  resize: none;
  outline: none;
}

.jg-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(166, 124, 82, 0.10);
}

.jg-send-btn {
  background: var(--accent);
  border: none;
  border-radius: 7px;
  color: #fff;
  width: 32px;
  height: 32px;
  transition: opacity 0.14s, transform 0.14s;
}

.jg-send-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.05);
}

/* Typing indicator dots */
.jg-typing-dot {
  background: var(--text-dim);
  border-radius: 50%;
}

/* ─────────────────────────────────────────────────────────────
   APPROVAL BUTTONS
   ───────────────────────────────────────────────────────────── */

.jarvis-approve-btn {
  background: var(--green-dim);
  border: 1px solid rgba(22, 163, 74, 0.25);
  color: var(--green);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  cursor: pointer;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}

.jarvis-approve-btn:hover {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.jarvis-reject-btn {
  background: var(--red-dim);
  border: 1px solid rgba(220, 38, 38, 0.2);
  color: var(--red);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  cursor: pointer;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}

.jarvis-reject-btn:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.jarvis-ask-btn,
.jarvis-ask-inline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}

.jarvis-ask-btn:hover,
.jarvis-ask-inline:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hover);
}

/* ─────────────────────────────────────────────────────────────
   ACTION ITEMS KANBAN (ai2-*)
   ───────────────────────────────────────────────────────────── */

.ai2-board {
  gap: 10px;
}

.ai2-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ai2-col-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(166, 124, 82, 0.2);
}

.ai2-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.ai2-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
}

.ai2-priority-pill {
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  letter-spacing: 0.3px;
}

/* ─────────────────────────────────────────────────────────────
   GORGIAS TICKET CARDS
   ───────────────────────────────────────────────────────────── */

.gorgias-ticket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s;
  margin-bottom: 8px;
}

.gorgias-ticket-card:hover {
  box-shadow: var(--shadow-sm);
}

.ticket-header {
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
}

.sentiment-badge {
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
}

.message-bubble {
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.5;
}

.message-customer .message-bubble {
  background: var(--surface-2);
  border-bottom-left-radius: 2px;
}

.message-agent .message-bubble {
  background: var(--accent-dim);
  border-bottom-right-radius: 2px;
}

/* ─────────────────────────────────────────────────────────────
   JOURNEY / ORDER TIMELINE MODAL
   ───────────────────────────────────────────────────────────── */

.journey-overlay {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.journey-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.journey-node {
  transition: transform 0.15s;
}

.journey-node:hover {
  transform: scale(1.03);
}

/* ─────────────────────────────────────────────────────────────
   VIEW-AS SWITCHER (header)
   ───────────────────────────────────────────────────────────── */

.view-as-switcher {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 3px;
  gap: 2px;
}

.view-as-btn {
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
  color: var(--shell-secondary-text);
  padding: 3px 11px;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}

/* Admin "View as" role preview — a single compact labeled dropdown (replaced
   the 4-pill row so it sits on one line and no longer visually duplicates the
   Warehouse nav hub). Blends into the .view-as-switcher pill container. */
.view-as-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--shell-secondary-text);
  padding-left: 9px;
  white-space: nowrap;
}
.view-as-select {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 16px;
  padding: 3px 4px 3px 6px;
  margin-left: 2px;
  cursor: pointer;
  font-family: inherit;
  appearance: auto;
}
.view-as-select:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

/* ─────────────────────────────────────────────────────────────
   API HEALTH INDICATOR (header)
   ───────────────────────────────────────────────────────────── */

.api-health-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

/* ─────────────────────────────────────────────────────────────
   LABEL GENERATOR PROVIDER TOGGLE
   ───────────────────────────────────────────────────────────── */

/* ─────────────────────────────────────────────────────────────
   MARGIN BAR (mini progress bar)
   ───────────────────────────────────────────────────────────── */

.margin-bar {
  background: var(--surface-2);
  border-radius: 3px;
  height: 5px;
}

.margin-bar-fill {
  border-radius: 3px;
}

/* ─────────────────────────────────────────────────────────────
   CONFIDENCE / PROGRESS BARS
   ───────────────────────────────────────────────────────────── */

.confidence-bar,
.confidence-bar-fill {
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─────────────────────────────────────────────────────────────
   DECISIONS DASHBOARD CARDS
   ───────────────────────────────────────────────────────────── */

.decisions-card-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.decisions-card-item:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
}

.decision-type-badge,
.decision-status-badge {
  border-radius: 5px;
  font-size: 9.5px;
  font-weight: 600;
  padding: 2px 7px;
  letter-spacing: 0.2px;
}

/* ─────────────────────────────────────────────────────────────
   CHANNEL / MARKETING CARDS
   ───────────────────────────────────────────────────────────── */

.channel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.channel-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
}

/* ─────────────────────────────────────────────────────────────
   EVENT LOG ACTOR BADGES
   ───────────────────────────────────────────────────────────── */

.el-badge-ai,
.el-badge-claude,
.el-badge-human {
  border-radius: 5px;
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 7px;
  letter-spacing: 0.3px;
}

/* ─────────────────────────────────────────────────────────────
   SUPPLIER SCORECARD METRICS
   ───────────────────────────────────────────────────────────── */

.score-bar-track {
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar-fill {
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─────────────────────────────────────────────────────────────
   GLOBAL SEARCH / COMMAND PALETTE
   ───────────────────────────────────────────────────────────── */

.command-palette {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

/* ─────────────────────────────────────────────────────────────
   MISC VIEW CONTAINERS (Jarvis intel panels)
   ───────────────────────────────────────────────────────────── */

/* Common panel wrapper used by logistics, customer, finance panels */
.jarvis-logistics-panel,
.jarvis-customer-panel,
.jarvis-finance-panel,
.jarvis-inventory-panel,
.jarvis-marketing-panel,
.jarvis-pnl-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

/* ─────────────────────────────────────────────────────────────
   LIVE INDICATOR (header)
   ───────────────────────────────────────────────────────────── */

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: livePulse 2.5s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ─────────────────────────────────────────────────────────────
   PRINT OVERRIDES
   ───────────────────────────────────────────────────────────── */

/* print rules consolidated below */

/* ═══════════════════════════════════════════════════════════════
   DARK MODE
   Full dark theme — activated via [data-theme="dark"] on <html>
   Respects system preference via JS; persisted in localStorage
   ═══════════════════════════════════════════════════════════════ */

:root[data-theme="dark"] {
  color-scheme: dark;

  /* Backgrounds — brand deep as the ground */
  --bg: #161614;
  --surface: #1f1f1c;
  --surface-2: #272724;
  --surface-3: #30302c;

  /* Borders */
  --border: #34342f;
  --border-hover: #45453f;

  /* Text — snow on deep, ash as the muted tone (9.31:1 on card) */
  --text: #f4f3ee;
  --text-muted: #c2c3bd;
  --text-dim: #98998f;   /* stone reads fine on dark: 5.73:1 */

  /* Accent — clay, the lighter terracotta, for dark grounds */
  --accent: #c99079;
  --accent-dim: rgba(201, 144, 121, 0.13);
  --accent-strong: #dcae9b;
  /* --accent-alpha and --accent-bg removed (unused) */

  /* Status colors — brighter/more saturated for dark bg */
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.12);
  --green-strong: #86efac;
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251, 191, 36, 0.12);
  --yellow-strong: #fde047;
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --emerald: #34d399;
  --emerald-dim: rgba(52, 211, 153, 0.12);
  --orange: #fb923c;
  --orange-dim: rgba(251, 146, 60, 0.12);
  --orange-strong: #fdba74;

  /* Shadows — more dramatic on dark */
  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.65);

  /* Sidebar — deeper in dark mode */
  --sidebar-bg: #0a0a09;
  --sidebar-border: #1a1a18;
  --sidebar-text: #908e89;  /* raised from #5a5855 — was 3:1, now ~5.5:1 on #0a0a09 */
  --sidebar-text-hover: #9a9790;
  --sidebar-text-active: #f0ede8;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.04);
  --sidebar-active-bg: rgba(255, 255, 255, 0.07);
  --shell-secondary-text: var(--sidebar-text);
  --sidebar-section-title: var(--shell-secondary-text);

  /* Aliases */
  --text-primary: var(--text);
  --text-secondary: var(--text-muted);
  --surface-1: var(--surface);
  --surface-raised: var(--surface);
  --bg-hover: rgba(255, 255, 255, 0.04);
  --hover-bg: rgba(255, 255, 255, 0.04);
  --card-bg: var(--surface);
  --bg-secondary: var(--surface-2);
  --primary: var(--accent);
  --danger: var(--red);
  --danger-dim: var(--red-dim);
  --success: var(--green);
  --warning: var(--yellow);
  --info: var(--blue);
  --bg-card: var(--surface);
  --bg-primary: var(--bg);
  --bg-tertiary: var(--surface-3);
  --bg2: var(--surface-2);
  --border-color: var(--border);
  --border-light: var(--border);
  --danger-color: var(--red);
  --surface-hover: var(--surface-2);
}

/* ── Dark mode specific element overrides ── */

[data-theme="dark"] body {
  background: var(--bg);
}

[data-theme="dark"] .header {
  background: var(--surface);
  border-bottom-color: var(--border);
}

/* Header font controls live on --surface-2, so the ordinary dark
   --text-muted value falls just below WCAG AA at this compact size. */
.font-scale-btn {
  color: var(--shell-secondary-text);
}

/* The Messages toolbar controls the shared dock. Its active state uses the
   same theme-adaptive inverse pair as the floating launcher. */
.msg-dock-toggle.is-active {
  background: var(--accent-strong) !important;
  border-color: var(--accent-strong) !important;
  color: var(--surface) !important;
}

/* Table headers use surface-2 (already variable but need to ensure no bleed) */
[data-theme="dark"] th {
  background: var(--surface-2);
  color: var(--text-dim);
}

[data-theme="dark"] td {
  border-bottom-color: var(--border);
}

/* Jarvis chat message area */
[data-theme="dark"] #jg-messages {
  background: var(--bg);
}

[data-theme="dark"] .jg-msg-assistant .jg-msg-bubble {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

/* Morning brief cards */
[data-theme="dark"] .brief-card.urgent {
  box-shadow: 0 0 0 1px var(--red), 0 0 16px rgba(248, 113, 113, 0.15);
}

/* Notification panel */
[data-theme="dark"] .jarvis-notification-panel {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .jarvis-notification-item.unread {
  background: rgba(192, 154, 106, 0.04);
}

/* Note textarea */
[data-theme="dark"] .note-textarea {
  background: var(--surface-2);
  color: var(--text);
}

/* Row detail */
[data-theme="dark"] .row-detail-panel {
  background: var(--surface-2);
  border-color: var(--border);
}

/* Command palette */
[data-theme="dark"] .command-palette {
  background: var(--surface);
  border-color: var(--border);
}

/* Journey modal */
[data-theme="dark"] .journey-modal {
  background: var(--surface);
  border-color: var(--border);
}

/* Side panel */
[data-theme="dark"] .side-panel {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .side-panel-header {
  background: var(--surface);
  border-bottom-color: var(--border);
}

[data-theme="dark"] .sp-stat {
  background: var(--surface);
}

[data-theme="dark"] .side-panel-stats {
  background: var(--border);
}

/* Toolbar inputs */
[data-theme="dark"] .search-input,
[data-theme="dark"] .filter-select {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .filter-btn {
  background: var(--surface-2);
  border-color: var(--border);
}

[data-theme="dark"] .toggle-btn {
  background: var(--surface-2);
  border-right-color: var(--border);
}

[data-theme="dark"] .toggle-group {
  border-color: var(--border);
}

/* Pagination */
[data-theme="dark"] .pagination-btns button {
  background: var(--surface-2);
  border-color: var(--border);
}

/* Login — already dark, keep as is but tweak */
[data-theme="dark"] .login-overlay {
  background: #0a0a09;
}

[data-theme="dark"] .login-card {
  background: #161614;
  border-color: #262624;
}

/* Scrollbars in dark */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #303030;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #404040;
}

/* Gorgias ticket */
[data-theme="dark"] .message-customer .message-bubble {
  background: var(--surface-2);
}

[data-theme="dark"] .message-agent .message-bubble {
  background: rgba(192, 154, 106, 0.1);
}

/* Kanban */
[data-theme="dark"] .ai2-col {
  background: var(--surface-2);
  border-color: var(--border);
}

[data-theme="dark"] .ai2-card {
  background: var(--surface);
  border-color: var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   THEME TOGGLE BUTTON
   ═══════════════════════════════════════════════════════════════ */

.theme-toggle-btn {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.14s, border-color 0.14s, color 0.14s, transform 0.14s;
}

.theme-toggle-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text);
  transform: rotate(12deg);
}

.theme-toggle-btn:active {
  transform: rotate(20deg) scale(0.93);
}

/* Sun icon visible in light mode, hidden in dark */
.theme-toggle-btn .icon-sun { display: block; }
.theme-toggle-btn .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle-btn .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle-btn .icon-moon { display: block; }

/* ═══════════════════════════════════════════════════════════════
   SMOOTH THEME TRANSITIONS
   Applied to specific elements — not * (too broad)
   ═══════════════════════════════════════════════════════════════ */

body,
.header,
.sidebar,
.main,
.stat-card,
.brief-card,
.table-container,
.side-panel,
.nav-item,
.filter-btn,
.toggle-btn,
.action-btn,
.refresh-btn,
.theme-toggle-btn,
.pill,
.channel-card,
.gorgias-ticket-card,
.jarvis-notification-panel,
.jarvis-notification-item,
.command-palette,
.journey-modal,
.login-card,
.row-detail-panel,
.note-editor-popup,
.ai2-card,
.ai2-col,
.jg-msg-bubble,
.search-input,
.filter-select,
.form-input,
th, td {
  transition:
    background-color 0.22s ease,
    border-color 0.22s ease,
    color 0.18s ease,
    box-shadow 0.22s ease;
}

/* Exclude elements where transition would look wrong */
.spinner,
.sync-dot,
.live-dot,
.health-dot,
.freshness-dot,
.agent-dot,
.skeleton,
.bar-fill,
.confidence-bar-fill,
.margin-bar-fill,
[class$="-fill"] {
  transition: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   STAT CARDS — calm & uniform (uses CSS :has())
   Premium dashboards keep cards visually uniform and let semantic color
   live in the VALUE text (.stat-value.green/red/…), not in card chrome.
   The previous build drew a bright 2px top border per value-color, which
   turned every stat grid into a rainbow and read as "admin template."
   We now keep a restrained top accent ONLY for genuine attention states
   (red / yellow caution); positive + informational cards stay neutral so
   the eye goes to what actually needs action. The colored numbers are
   untouched, so no at-a-glance signal is lost.
   ═══════════════════════════════════════════════════════════════ */

.stat-card:has(.stat-value.red) {
  border-top: 2px solid var(--red);
}

.stat-card:has(.stat-value.yellow) {
  border-top: 2px solid var(--yellow);
}

/* Brief cards: same restraint — accent only for attention states. */
.brief-card:has(.brief-metric.red)    { border-top: 2px solid var(--red); }
.brief-card:has(.brief-metric.yellow) { border-top: 2px solid var(--yellow); }

/* ═══════════════════════════════════════════════════════════════
   GLASSMORPHISM — Notification panel + Command palette
   ═══════════════════════════════════════════════════════════════ */

.jarvis-notification-panel,
.api-health-panel,
.health-popover,
.freshness-tooltip {
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  background: rgba(255, 255, 255, 0.88) !important;
}

[data-theme="dark"] .jarvis-notification-panel,
[data-theme="dark"] .api-health-panel,
[data-theme="dark"] .health-popover,
[data-theme="dark"] .freshness-tooltip {
  background: rgba(28, 28, 26, 0.88) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

/* ═══════════════════════════════════════════════════════════════
   TABULAR NUMBERS — system-wide for all numeric data
   ═══════════════════════════════════════════════════════════════ */

.stat-value,
.brief-metric,
td,
.sp-stat-val,
.fin-card-gross,
.fin-net-value {
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════
   MODERN FOCUS STATES — replaces browser default outlines
   ═══════════════════════════════════════════════════════════════ */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible,
.nav-item:focus-visible,
.filter-btn:focus-visible,
.toggle-btn:focus-visible,
.action-btn:focus-visible,
.refresh-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   CRITICAL / URGENT GLOW EFFECTS
   ═══════════════════════════════════════════════════════════════ */

/* Pills with glow on urgent states */
.pill.out,
.pill.high,
.pill.claim,
.pill.chargeback {
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.25);
}

[data-theme="dark"] .pill.out,
[data-theme="dark"] .pill.high,
[data-theme="dark"] .pill.claim,
[data-theme="dark"] .pill.chargeback {
  box-shadow: 0 0 6px rgba(248, 113, 113, 0.3);
}

/* Critical alert banner pulse */
#critical-alerts-banner {
  animation: criticalPulse 3s ease-in-out infinite;
}

@keyframes criticalPulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 2px 20px rgba(153, 27, 27, 0.4); }
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATED GRADIENT SIDEBAR LOGO AREA
   ═══════════════════════════════════════════════════════════════ */

/* Subtle branded top section of sidebar */
.sidebar::before {
  content: none;
}

/* ═══════════════════════════════════════════════════════════════
   ENHANCED SKELETON LOADING
   ═══════════════════════════════════════════════════════════════ */

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-3) 40%,
    var(--surface-2) 80%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: 5px;
}

/* ═══════════════════════════════════════════════════════════════
   DATA UPDATE FLASH — applied via JS when values change
   ═══════════════════════════════════════════════════════════════ */

@keyframes valueFlash {
  0% { background: transparent; }
  25% { background: rgba(166, 124, 82, 0.15); border-radius: 4px; }
  100% { background: transparent; }
}

/* ═══════════════════════════════════════════════════════════════
   ENHANCED TABLE — alternating row micro-tint
   ═══════════════════════════════════════════════════════════════ */

/* Very subtle alternating rows for long tables */
tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.012);
}

[data-theme="dark"] tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.012);
}

/* Override for rows that have explicit hover */
tbody tr:hover td {
  background: var(--bg-hover) !important;
}

/* Tabular figures across data cells so currency/quantity columns line up at
   a consistent glyph width instead of wobbling. Affects only digit glyphs —
   harmless on text cells. */
#mainContent th,
#mainContent td {
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════
   PILL REFINEMENTS — outlined style for dark mode
   ═══════════════════════════════════════════════════════════════ */

[data-theme="dark"] .pill.unfulfilled  { background: rgba(251, 191, 36, 0.15);  color: #fbbf24; }
[data-theme="dark"] .pill.fulfilled    { background: rgba(74, 222, 128, 0.12);  color: #4ade80; }
[data-theme="dark"] .pill.in_transit   { background: rgba(96, 165, 250, 0.12);  color: #60a5fa; }
[data-theme="dark"] .pill.low          { background: rgba(248, 113, 113, 0.12); color: #f87171; }
[data-theme="dark"] .pill.out          { background: rgba(248, 113, 113, 0.15); color: #f87171; }
[data-theme="dark"] .pill.ok           { background: rgba(74, 222, 128, 0.12);  color: #4ade80; }
[data-theme="dark"] .pill.high         { background: rgba(248, 113, 113, 0.15); color: #f87171; }
[data-theme="dark"] .pill.medium       { background: rgba(251, 191, 36, 0.13);  color: #fbbf24; }
[data-theme="dark"] .pill.booked       { background: rgba(251, 191, 36, 0.13);  color: #fbbf24; }
[data-theme="dark"] .pill.arrived      { background: rgba(74, 222, 128, 0.12);  color: #4ade80; }
[data-theme="dark"] .pill.partially_fulfilled { background: rgba(96, 165, 250, 0.12); color: #60a5fa; }

/* ═══════════════════════════════════════════════════════════════
   ENHANCED HOVER ROW HIGHLIGHT (table rows w/ actions)
   ═══════════════════════════════════════════════════════════════ */

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover td {
  background: var(--bg-hover) !important;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR ACTIVE ITEM — gradient glow
   ═══════════════════════════════════════════════════════════════ */

.nav-item.active {
  position: relative;
}

/* Subtle warm glow behind active item */
.nav-item.active::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: radial-gradient(ellipse at left center, rgba(192, 154, 106, 0.12), transparent 70%);
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════
   ENHANCED APPROVAL / ACTION BUTTONS
   ═══════════════════════════════════════════════════════════════ */

/* Approve button — filled green on hover */
.jarvis-approve-btn {
  position: relative;
  overflow: hidden;
}

.jarvis-approve-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--green);
  opacity: 0;
  transition: opacity 0.14s;
}

.jarvis-approve-btn:hover::before { opacity: 1; }
.jarvis-approve-btn:hover { color: #fff; border-color: var(--green); }
.jarvis-approve-btn span { position: relative; z-index: var(--z-base); }

/* ═══════════════════════════════════════════════════════════════
   ENHANCED BADGE ANIMATION
   ═══════════════════════════════════════════════════════════════ */

.nav-item .badge {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item:hover .badge {
  transform: scale(1.1);
}

/* ═══════════════════════════════════════════════════════════════
   STAT CARD NUMBER — gradient text for accent values
   ═══════════════════════════════════════════════════════════════ */

/* Accent-colored stat values get gradient text treatment */
.stat-value.accent {
  background: linear-gradient(135deg, var(--accent) 0%, #d4a96a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="dark"] .stat-value.accent {
  background: linear-gradient(135deg, #c09a6a 0%, #e8c084 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ═══════════════════════════════════════════════════════════════
   HERO BRIEF CARD — full-width morning brief emphasis
   ═══════════════════════════════════════════════════════════════ */

.brief-card.full-width {
  background: linear-gradient(
    135deg,
    var(--surface) 0%,
    color-mix(in srgb, var(--surface) 96%, var(--accent) 4%) 100%
  );
  border-color: var(--border);
  position: relative;
  overflow: hidden;
}

.brief-card.full-width::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════════════════════
   JARVIS FAB BUTTON — enhanced
   ═══════════════════════════════════════════════════════════════ */

.jarvis-floating-btn {
  box-shadow: 0 4px 16px rgba(166, 124, 82, 0.35), 0 1px 4px rgba(0,0,0,0.1) !important;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease !important;
}

.jarvis-floating-btn:hover {
  transform: scale(1.08) !important;
  box-shadow: 0 8px 28px rgba(166, 124, 82, 0.45), 0 2px 8px rgba(0,0,0,0.15) !important;
}

[data-theme="dark"] .jarvis-floating-btn {
  box-shadow: 0 4px 20px rgba(192, 154, 106, 0.4), 0 1px 4px rgba(0,0,0,0.3) !important;
}

/* ═══════════════════════════════════════════════════════════════
   ENHANCED EMPTY STATES
   ═══════════════════════════════════════════════════════════════ */

/* Legacy ghost-icon child rule. Layout/padding for .empty-state is
   owned by the centered flex block further down (~line 3385); only the
   .icon child styling lives here. Opacity raised 0.15 → 0.4 so the icon
   is actually visible (was a near-invisible ghost). */
.empty-state .icon {
  font-size: 44px;
  opacity: 0.4;
  margin-bottom: 14px;
  display: block;
}

.empty-state h3,
.empty-state p {
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════
   BETTER PAGE TRANSITION ANIMATION
   ═══════════════════════════════════════════════════════════════ */

@keyframes viewFadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Faster, crisper page transitions */
.main > *:not(.loading):not(.spinner):not(#loginScreen) {
  animation: viewFadeIn 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   AUDIT BUG FIXES — v3
   All issues found in comprehensive 5-agent audit
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   FIX: prefers-reduced-motion
   Disables all animations/transitions for motion-sensitive users
   ───────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .skeleton {
    animation: none !important;
    background: var(--surface-2) !important;
  }

  .sync-dot,
  .live-dot,
  .health-dot,
  .freshness-dot,
  .agent-dot,
  #critical-alerts-banner {
    animation: none !important;
  }

  .main > *:not(.loading):not(.spinner) {
    animation: none !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   FIX: .btn-active — !important override (dashboard.css uses
   !important so we must too)
   ───────────────────────────────────────────────────────────── */

.btn-active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

[data-theme="dark"] .btn-active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

.decisions-pill-active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: color:#000 on buttons — all become invisible in dark mode
   These buttons have colored backgrounds (accent/green/purple)
   and need white text, not black
   ───────────────────────────────────────────────────────────── */

[data-theme="dark"] .scan-mode-btn.active.mode-in,
[data-theme="dark"] .mo-step-num,
[data-theme="dark"] .wjs-run-btn,
[data-theme="dark"] .ret-btn-label:hover,
[data-theme="dark"] .ret-btn-close:hover,
[data-theme="dark"] .pck-confirm-btn:hover,
[data-theme="dark"] .pck-done-close-btn:hover,
[data-theme="dark"] .ret-filter-btn.active,
[data-theme="dark"] .um-modal-save.yellow,
[data-theme="dark"] .mo-reconnect-btn:hover,
[data-theme="dark"] .note-save-btn,
[data-theme="dark"] .login-card button {
  color: #fff !important;
}

/* SEO grade badges — dark text on colored bg is fine in light mode,
   but need white in dark mode */
[data-theme="dark"] .seo-grade-a,
[data-theme="dark"] .seo-grade-b,
[data-theme="dark"] .seo-grade-c {
  color: #fff !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: Light badge backgrounds — invisible in dark mode
   ───────────────────────────────────────────────────────────── */

[data-theme="dark"] .rl-svc-badge {
  background: rgba(255, 255, 255, 0.07) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: var(--text-muted) !important;
}

[data-theme="dark"] .rl-svc-badge.rl-svc-warn {
  background: var(--yellow-dim) !important;
  border-color: rgba(251, 191, 36, 0.25) !important;
  color: var(--yellow) !important;
}

[data-theme="dark"] .rl-rate-rec {
  background: var(--green-dim) !important;
  border-color: rgba(74, 222, 128, 0.2) !important;
  color: var(--green) !important;
}

[data-theme="dark"] .rl-conf-med {
  background: var(--yellow-dim) !important;
  color: var(--yellow) !important;
}

[data-theme="dark"] .rl-conf-low {
  background: var(--red-dim) !important;
  color: var(--red) !important;
}

[data-theme="dark"] .rl-rates-freight-warn {
  background: var(--yellow-dim) !important;
  color: var(--yellow) !important;
}

[data-theme="dark"] .lbl-result-order-badge {
  background: var(--blue-dim) !important;
  color: var(--blue) !important;
  border-color: rgba(96, 165, 250, 0.2) !important;
}

[data-theme="dark"] .hub-judgeme-btn {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}

[data-theme="dark"] .hub-judgeme-btn:hover {
  background: var(--surface-3) !important;
  color: var(--text) !important;
}

[data-theme="dark"] .rf-horizon-btn {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}

[data-theme="dark"] .hub-cp-order-status.unfulfilled {
  background: rgba(251, 191, 36, 0.12) !important;
  color: var(--yellow) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: .jg-entity-link — hardcoded #a67c52 (light-mode tan)
   Should use the CSS variable so dark mode gets the brighter
   accent value
   ───────────────────────────────────────────────────────────── */

.jg-entity-link {
  color: var(--accent) !important;
}

.jg-entity-link:hover {
  color: var(--accent) !important;
  opacity: 0.8;
}

.jg-dollar {
  color: var(--green) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: VIP customer card hardcoded gold color (#b8860b)
   ───────────────────────────────────────────────────────────── */

[data-theme="dark"] .jcp-summary-card.vip,
[data-theme="dark"] .jcp-profile-card.vip {
  color: var(--yellow) !important;
  border-left-color: var(--yellow) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: Minimum font sizes — 8px elements raised to 10px
   ───────────────────────────────────────────────────────────── */

/* .state-tile .tile-count (dashboard.css line 1974 — 8px) */
.state-tile .tile-count {
  font-size: 10px !important;
}

/* .rev-bar-lbl (dashboard.css line 4039 — 8px) */
.rev-bar-lbl {
  font-size: 10px !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: Missing :focus-visible on interactive elements
   Covers the worst accessibility gaps found in audit
   ───────────────────────────────────────────────────────────── */

/* Table header sort buttons */
.matrix-table thead th.loc-col:focus-visible,
.matrix-table tbody td.title-cell:focus-visible,
table th:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 3px;
}

/* View-specific filter and action buttons */
.ret-filter-btn:focus-visible,
.hub-action-btn:focus-visible,
.wizard-toggle-btn:focus-visible,
.hr-toggle-btn:focus-visible,
.feed-filter-btn:focus-visible,
.tab:focus-visible,
.expand-btn:focus-visible,
.note-icon:focus-visible,
.jarvis-approve-btn:focus-visible,
.jarvis-reject-btn:focus-visible,
.jarvis-ask-btn:focus-visible,
.close-btn:focus-visible,
.nav-section-header:focus-visible,
.ai2-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ─────────────────────────────────────────────────────────────
   FIX: Z-index — standardize stacking hierarchy
   Prevents sidebar from appearing above modals on some views
   ───────────────────────────────────────────────────────────── */

/* Sidebar at --z-header was documented — ensure modals beat it */
.journey-overlay {
  z-index: var(--z-overlay) !important;
}

/* Side panels ride ABOVE the Messages dock (--z-dock). At --z-overlay (200)
   they sat 8700 below it, so the dock covered every drawer it overlapped —
   the order panel, the SKU drawer, the right-hand columns of any wide table
   behind them. Reported on the SKU drawer, but it was never drawer-specific. */
.side-panel-overlay {
  z-index: var(--z-side-panel) !important;
}

.journey-modal {
  z-index: calc(var(--z-overlay) + 1) !important;
}

.side-panel {
  z-index: calc(var(--z-side-panel) + 2) !important;
}

/* Command palette sits above everything */
.command-palette {
  z-index: calc(var(--z-palette) + 1) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: Dark mode — nav-section-title black text
   (dashboard.css line 899 has color: #000 in some contexts)
   ───────────────────────────────────────────────────────────── */

[data-theme="dark"] .nav-section-title {
  color: var(--sidebar-section-title) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: .sr-row-selected — !important defensive override
   ───────────────────────────────────────────────────────────── */

.sr-row-selected {
  background: color-mix(in srgb, var(--accent) 8%, transparent) !important;
}

[data-theme="dark"] .sr-row-selected {
  background: rgba(192, 154, 106, 0.1) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: Dark mode — Jarvis marketing & finance panel badges
   ───────────────────────────────────────────────────────────── */

[data-theme="dark"] .jarvis-marketing-panel .jm-header-badge {
  color: #fff !important;
}

[data-theme="dark"] .jm-rec-card {
  background: var(--surface-2);
  border-color: var(--border);
}

/* ─────────────────────────────────────────────────────────────
   FUTURE-PROOF: cursor:not-allowed on all disabled states
   ───────────────────────────────────────────────────────────── */

button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
[disabled] {
  cursor: not-allowed !important;
  opacity: 0.45 !important;
}

/* ─────────────────────────────────────────────────────────────
   ENHANCEMENT: Table padding bump — 10px → 12px for readability
   ───────────────────────────────────────────────────────────── */

td {
  padding: 11px 14px;
}

th {
  padding: 11px 14px;
}

/* ─────────────────────────────────────────────────────────────
   ENHANCEMENT: Active row left border accent on click
   ───────────────────────────────────────────────────────────── */

tr.expanded-row td:first-child {
  border-left: 2px solid var(--accent);
}

/* ─────────────────────────────────────────────────────────────
   ENHANCEMENT: Sidebar search hint (bottom of sidebar)
   Subtle "⌘K to search" reminder
   ───────────────────────────────────────────────────────────── */

.sidebar::after {
  content: '⌘K to search';
  display: block;
  text-align: center;
  font-size: 10px;
  color: var(--sidebar-section-title);
  padding: 12px 0 4px;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

html[lang="zh-CN"] .sidebar::after {
  content: '⌘K 搜索';
}

html[lang="es"] .sidebar::after {
  content: '⌘K para buscar';
}

/* ─────────────────────────────────────────────────────────────
   ENHANCEMENT: Jarvis floating button glow pulse in dark mode
   ───────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  [data-theme="dark"] .jarvis-floating-btn {
    animation: fabGlow 4s ease-in-out infinite;
  }

  @keyframes fabGlow {
    0%, 100% { box-shadow: 0 4px 20px rgba(192, 154, 106, 0.4); }
    50%       { box-shadow: 0 4px 28px rgba(192, 154, 106, 0.6), 0 0 0 3px rgba(192, 154, 106, 0.1); }
  }
}

/* ═══════════════════════════════════════════════════════════════
   PART 5 — UI ENHANCEMENTS
   Sidebar live search · Recently visited · Global toasts ·
   Page progress bar · Button press states · Modal animations ·
   Skeleton loaders · Empty state CTAs
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   SIDEBAR LIVE SEARCH
   ───────────────────────────────────────────────────────────── */

/* search icon */
/* Highlight matched text in nav items during search */
.nav-highlight {
  background: rgba(192,154,106,0.35);
  color: #fff;
  border-radius: 2px;
  padding: 0 1px;
}

/* Slash-key hint below search */
/* ─────────────────────────────────────────────────────────────
   RECENTLY VISITED SECTION
   ───────────────────────────────────────────────────────────── */

#sidebar-recent {
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

#sidebar-recent .nav-section-title {
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 8px 14px 4px;
}

/* ─────────────────────────────────────────────────────────────
   GLOBAL TOAST SYSTEM
   ───────────────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 320px;
  max-width: calc(100vw - 40px);
}

.im-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2, #fff);
  border: 1px solid var(--border, #e0ddd7);
  border-radius: 9px;
  padding: 11px 14px;
  font-size: 13px;
  color: var(--text, #1a1917);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06);
  pointer-events: all;
  /* enter: start invisible and shifted */
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34,1.56,0.64,1);
  will-change: transform, opacity;
  border-left: 3px solid var(--accent, #c09a6a);
}

.im-toast--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.im-toast__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: currentColor;
  opacity: 0.85;
}

.im-toast__msg {
  flex: 1;
  line-height: 1.45;
}

.im-toast__close {
  background: none;
  border: none;
  color: var(--text-muted, #7a7770);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.1s;
}
.im-toast__close:hover { color: var(--text, #1a1917); }

/* Type variants */
.im-toast--success { border-left-color: var(--green); }
.im-toast--success .im-toast__icon { color: var(--green); }

.im-toast--error { border-left-color: var(--red); }
.im-toast--error .im-toast__icon { color: var(--red); }

.im-toast--warning { border-left-color: var(--yellow); }
.im-toast--warning .im-toast__icon { color: var(--yellow); }

.im-toast--info { border-left-color: var(--accent, #c09a6a); }
.im-toast--info .im-toast__icon { color: var(--accent, #c09a6a); }

/* Dark mode toasts */
[data-theme="dark"] .im-toast {
  background: var(--surface-2, #1e1e1b);
  border-color: var(--border, #2e2e2a);
  color: var(--text, #e8e5e0);
  box-shadow: 0 4px 24px rgba(0,0,0,0.45);
}

[data-theme="dark"] .im-toast__close { color: var(--text-muted, #908e89); }
[data-theme="dark"] .im-toast__close:hover { color: var(--text, #e8e5e0); }

/* ─────────────────────────────────────────────────────────────
   PAGE PROGRESS BAR
   ───────────────────────────────────────────────────────────── */

#page-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent, #c09a6a), #e8c080);
  z-index: var(--z-jarvis);
  pointer-events: none;
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px rgba(192,154,106,0.5);
}

@media (prefers-reduced-motion: reduce) {
  #page-progress-bar { transition: none !important; }
}

/* ─────────────────────────────────────────────────────────────
   BUTTON PRESS STATES (all interactive buttons)
   ───────────────────────────────────────────────────────────── */

.btn:active,
.refresh-btn:active,
.sync-now-btn:active,
.theme-toggle-btn:active,
.sign-out-btn:active,
.jarvis-notif-dismiss-all:active,
.wjs-run-btn:active,
.hub-action-btn:active,
.filter-btn:active,
button[class*="-btn"]:active {
  transform: translateY(1px) scale(0.99);
  transition: transform 0.06s ease !important;
}

@media (prefers-reduced-motion: reduce) {
  .btn:active,
  button[class*="-btn"]:active { transform: none !important; }
}

/* ─────────────────────────────────────────────────────────────
   MODAL OPEN/CLOSE ANIMATIONS (journey modal, side panel)
   ───────────────────────────────────────────────────────────── */

/* Journey modal — scale + fade in */
.journey-modal {
  animation: modalIn 0.22s cubic-bezier(0.34,1.4,0.64,1) both;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Overlay fade */
.journey-overlay {
  animation: overlayIn 0.18s ease both;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Side panel slide-in from right */
.side-panel {
  animation: sidePanelIn 0.22s cubic-bezier(0.4,0,0.2,1) both;
}

@keyframes sidePanelIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .journey-modal,
  .journey-overlay,
  .side-panel { animation: none !important; }
}

/* ─────────────────────────────────────────────────────────────
   SKELETON LOADING STATES
   Usage: add class="skeleton-line" or "skeleton-block" to elements
   Use renderSkeletonTable(rows, cols) from JS.
   ───────────────────────────────────────────────────────────── */

@keyframes skeletonShimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

.skeleton-line,
.skeleton-block,
.skeleton-table-row td {
  background: linear-gradient(
    90deg,
    var(--surface-2, #f0eee8) 25%,
    var(--bg-hover, #e8e6e0) 50%,
    var(--surface-2, #f0eee8) 75%
  );
  background-size: 800px 100%;
  animation: skeletonShimmer 1.6s ease-in-out infinite;
  border-radius: 4px;
  color: transparent !important;
  user-select: none;
}

.skeleton-line {
  display: block;
  height: 14px;
  margin-bottom: 8px;
  width: 100%;
}
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 65%; }

.skeleton-block {
  display: block;
  height: 80px;
  width: 100%;
  border-radius: 8px;
}

/* Skeleton table */
.skeleton-table-row td {
  height: 15px;
  padding: 10px 12px;
  border-bottom: 1px solid transparent;
}

/* Dark skeleton */
[data-theme="dark"] .skeleton-line,
[data-theme="dark"] .skeleton-block,
[data-theme="dark"] .skeleton-circle,
[data-theme="dark"] .skeleton-table-row td {
  background: linear-gradient(
    90deg,
    var(--surface-2, #222220) 25%,
    var(--bg-hover, #2a2a27) 50%,
    var(--surface-2, #222220) 75%
  );
  background-size: 800px 100%;
  animation: skeletonShimmer 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-line,
  .skeleton-block,
  .skeleton-table-row td { animation: none !important; }
}

/* ─────────────────────────────────────────────────────────────
   ENHANCED EMPTY STATES
   ───────────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  text-align: center;
  gap: 12px;
}

/* Gallery-grade empty state: the icon becomes a framed "object of presence"
   (a calm circular surface tile) instead of a faded glyph. Covers both the
   modern `.empty-state-icon` and the legacy `.empty-state .icon` markup so
   every view's empty/error state reads the same. */
.empty-state-icon,
.empty-state .icon {
  font-size: var(--fs-2xl);
  line-height: 1;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  opacity: 1;
  margin: 0 0 var(--space-2);
}
.empty-state-icon svg,
.empty-state .icon svg {
  width: 22px;
  height: 22px;
}

.empty-state-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  color: var(--text, #1a1917);
  margin: 0;
}

.empty-state-desc {
  font-size: var(--fs-base);
  color: var(--text-dim, #7a7770);
  max-width: 340px;
  line-height: var(--leading-relaxed);
  margin: 0;
}

.empty-state-cta {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-5);
  background: var(--accent, #c09a6a);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--dur) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
  font-family: inherit;
}
.empty-state-cta:hover { background: var(--accent-hover, #a8845a); }
.empty-state-cta:active { transform: translateY(1px); }

[data-theme="dark"] .empty-state-title { color: var(--text, #e8e5e0); }
[data-theme="dark"] .empty-state-desc  { color: var(--text-muted, #908e89); }

/* ─────────────────────────────────────────────────────────────
   NAV SECTION ITEMS — smooth collapse transition
   ───────────────────────────────────────────────────────────── */

.nav-section-items {
  overflow: hidden;
  transition: max-height 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ─────────────────────────────────────────────────────────────
   MICRO-POLISH: Card hover lift
   ───────────────────────────────────────────────────────────── */

/* .stat-card transition/hover — consolidated into base rule (line ~381) */

@media (prefers-reduced-motion: reduce) {
  .stat-card { transition: none !important; }
  .stat-card:hover { transform: none; }
}

/* ─────────────────────────────────────────────────────────────
   MICRO-POLISH: Pill active click ripple
   ───────────────────────────────────────────────────────────── */

.filter-pill {
  position: relative;
  overflow: hidden;
}

.filter-pill:active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.2);
  border-radius: inherit;
  animation: pillRipple 0.3s ease forwards;
}

@keyframes pillRipple {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .filter-pill:active::after { display: none; }
}

/* ─────────────────────────────────────────────────────────────
   MICRO-POLISH: Table sort indicator
   ───────────────────────────────────────────────────────────── */

th[data-sort] { cursor: pointer; user-select: none; }

th[data-sort]::after {
  content: ' ↕';
  font-size: 10px;
  opacity: 0.3;
  transition: opacity 0.12s;
}
th[data-sort="asc"]::after  { content: ' ↑'; opacity: 0.7; }
th[data-sort="desc"]::after { content: ' ↓'; opacity: 0.7; }
th[data-sort]:hover::after  { opacity: 0.6; }

/* ─────────────────────────────────────────────────────────────
   MICRO-POLISH: Responsive sidebar search on narrow viewports
   ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  #toast-container { bottom: 16px; right: 12px; left: 12px; width: auto; }
}

/* ═══════════════════════════════════════════════════════════════
   ANALYTICS DASHBOARD — Museum-grade KPI + chart redesign
   ═══════════════════════════════════════════════════════════════ */

.ana-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.ana-kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-xs);
  border-left: 3px solid var(--border);
  transition: box-shadow 0.18s, border-color 0.18s, transform 0.18s;
}
.ana-kpi-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.ana-kpi-card.kpi-revenue    { border-left-color: var(--green); }
.ana-kpi-card.kpi-orders     { border-left-color: var(--blue); }
.ana-kpi-card.kpi-aov        { border-left-color: var(--accent); }
.ana-kpi-card.kpi-week       { border-left-color: var(--emerald); }
.ana-kpi-card.kpi-week-orders{ border-left-color: var(--purple); }

.ana-kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.ana-kpi-label {
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 6px;
}

.ana-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.ana-section-title {
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* Revenue chart bars */
.ana-chart-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 440px;
  overflow-y: auto;
}
.ana-chart-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  padding: 3px 0;
  border-radius: 4px;
  transition: background 0.12s;
}
.ana-chart-row:hover {
  background: var(--surface-2);
}
.ana-chart-date {
  width: 48px;
  text-align: right;
  color: var(--text-dim);
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  flex-shrink: 0;
}
.ana-chart-bar-wrap {
  flex: 1;
  height: 20px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.ana-chart-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #c8a06a);
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
  min-width: 2px;
}
.ana-chart-val {
  width: 76px;
  text-align: right;
  color: var(--text);
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}


/* Anomaly alerts */
.ana-anomalies-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 440px;
  overflow-y: auto;
}
.ana-anomaly-row {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--text-dim);
  transition: box-shadow 0.15s;
}
.ana-anomaly-row:hover {
  box-shadow: var(--shadow-sm);
}
.ana-anomaly-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ana-anomaly-metric {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.ana-anomaly-time {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.ana-anomaly-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.45;
}
.ana-anomaly-values {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  font-family: var(--font-mono, monospace);
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════
   MORNING BRIEF — Modernized card grid + components
   ═══════════════════════════════════════════════════════════════ */

.ana-summarize-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s, opacity 0.15s;
  font-family: inherit;
}
.ana-summarize-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.brief-card.full-width {
  grid-column: 1 / -1;
}

.mb-card-clickable {
  cursor: pointer;
  transition: box-shadow 0.18s, border-color 0.18s, transform 0.18s;
}
.mb-card-clickable:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.brief-agent-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px 4px 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.agent-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.agent-dot.ok    { background: var(--green); box-shadow: 0 0 4px var(--green); }
.agent-dot.error { background: var(--red); box-shadow: 0 0 4px var(--red); }
.agent-dot.stale { background: var(--yellow); }

.sla-alert {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  background: var(--red-dim);
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 6px;
}
.sla-alert.ok {
  background: var(--green-dim);
  color: var(--green);
}
.sla-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.mb-stockout-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.mb-stockout-row:last-child {
  border-bottom: none;
}
.mb-stockout-sku {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--text-muted);
  min-width: 100px;
  flex-shrink: 0;
}

.jarvis-ask-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}
.jarvis-ask-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
  font-family: inherit;
}
.jarvis-ask-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* Brief urgent items */
.brief-urgent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.brief-urgent-item:last-child { border-bottom: none; }

.mb-dismiss-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.5;
  transition: opacity 0.12s, color 0.12s;
}
.mb-dismiss-btn:hover {
  opacity: 1;
  color: var(--red);
}

/* ═══════════════════════════════════════════════════════════════
   CUSTOMER HUB — Modernized inbox + compose
   ═══════════════════════════════════════════════════════════════ */

.hub-container {
  display: grid;
  grid-template-columns: 320px 1fr 280px;
  height: calc(100vh - 52px);
  overflow: hidden;
}

.hub-sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hub-sidebar-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.hub-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.hub-header-stats {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 11px;
}
.hub-stat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.hub-stat-badge.priority {
  background: var(--red-dim);
  color: var(--red);
}
.hub-stat-badge.open {
  background: var(--accent-dim, rgba(166,124,82,0.1));
  color: var(--accent);
}
.hub-stat-label {
  color: var(--text-dim);
  font-size: 11px;
}
.hub-stat-sep {
  color: var(--text-dim);
  font-size: 10px;
}

/* View tabs */
.hub-view-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
  overflow-x: auto;
}
.hub-view-tab {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.14s, border-color 0.14s;
  font-family: inherit;
}
.hub-view-tab:hover {
  color: var(--text);
}
.hub-view-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Channel filter bar */
.hub-channel-bar {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.hub-ch-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
  font-family: inherit;
  white-space: nowrap;
}
.hub-ch-btn:hover {
  background: var(--surface-2);
}
.hub-ch-btn.active {
  background: var(--accent-dim, rgba(166,124,82,0.1));
  color: var(--accent);
  border-color: var(--accent);
}

/* Search */
.hub-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.hub-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim, rgba(166,124,82,0.1));
}

/* Ticket list */
.hub-ticket-list {
  flex: 1;
  overflow-y: auto;
}

/* Main thread area */
.hub-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.hub-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  padding: 40px;
}
.hub-empty-icon {
  color: var(--text-dim);
  opacity: 0.4;
}
.hub-empty-text {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
}

/* Compose area */
.hub-compose {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.hub-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}
.hub-mode-bar.draft {
  background: var(--yellow-dim);
}
.hub-mode-bar.live {
  background: var(--green-dim);
}
.hub-mode-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 10px;
}
.hub-mode-bar.draft .hub-mode-indicator { color: var(--yellow); }
.hub-mode-bar.live .hub-mode-indicator  { color: var(--green); }

.hub-mode-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.hub-mode-bar.draft .hub-mode-dot { background: var(--yellow); }
.hub-mode-bar.live .hub-mode-dot  { background: var(--green); }

.hub-mode-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}
.hub-mode-toggle:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.hub-compose-top {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.hub-compose-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
  font-family: inherit;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
}
.hub-compose-btn:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
  color: var(--text);
}
/* AI Draft button gets accent treatment */
.hub-compose-btn:first-child {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim, rgba(166,124,82,0.08));
}
.hub-compose-btn:first-child:hover {
  background: var(--accent);
  color: #fff;
}

.hub-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px 14px;
  border: none;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.55;
  resize: vertical;
}
.hub-textarea:focus {
  outline: none;
}

.hub-compose-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}
.hub-compose-left {
  display: flex;
  gap: 4px;
}

.hub-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}
.hub-action-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text);
}
.hub-action-btn.escalate:hover {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}
.hub-action-btn.resolve:hover {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.hub-send-btn {
  padding: 7px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
  font-family: inherit;
}
.hub-send-btn.draft {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.hub-send-btn.draft:hover {
  background: var(--surface-3);
  color: var(--text);
}
.hub-send-btn.live {
  background: var(--accent);
  color: #fff;
}
.hub-send-btn.live:hover {
  filter: brightness(1.1);
}

/* Customer panel */
.hub-customer-panel {
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  padding: 16px;
}
.hub-customer-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* Assignee select */
.hub-assignee-wrap {
  margin-left: auto;
}
.hub-assignee-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

/* Thread wrap */
.hub-thread-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.hub-thread-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.hub-thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}

/* Modals */
.hub-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}
.hub-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 480px;
  width: 90%;
  max-height: 70vh;
  overflow: hidden;
}
.hub-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
.hub-modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
}
.hub-modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  max-height: 50vh;
}

/* Snooze options */
.hub-snooze-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hub-snooze-opt {
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s, opacity 0.14s;
}
.hub-snooze-opt:hover {
  background: var(--accent-dim, rgba(166,124,82,0.08));
  border-color: var(--accent);
}
.hub-snooze-custom {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hub-snooze-custom label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.hub-snooze-custom input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

/* Follow-up badge */
.hub-fu-badge {
  margin-left: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Hub loading msg */
.hub-loading-msg {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* ─── Dark mode overrides for new hub styles ─── */
[data-theme="dark"] .hub-sidebar { background: var(--surface); }
[data-theme="dark"] .hub-compose { background: var(--surface); }
[data-theme="dark"] .hub-customer-panel { background: var(--surface); }
[data-theme="dark"] .hub-thread-header { background: var(--surface); }
[data-theme="dark"] .hub-modal { background: var(--surface); }
[data-theme="dark"] .hub-search { background: var(--bg); }
[data-theme="dark"] .hub-textarea { background: var(--surface); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE: Hub collapses to single column on mobile
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 960px) {
  .hub-container {
    grid-template-columns: 1fr;
  }
  .hub-customer-panel {
    display: none;
  }
}

@media (max-width: 640px) {
  .ana-kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .brief-grid {
    grid-template-columns: 1fr;
  }
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE: Tablet (1024px)
   ───────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  /* Scale down font sizes slightly */
  body { font-size: 12.5px; }

  /* Reduce grid gaps */
  .stat-grid,
  .stats-row {
    gap: 10px;
  }

  /* Charts should never overflow */
  .acc-chart-container,
  .cust-rev-chart,
  .cust-freq-chart,
  .sla-volume-chart,
  .hub-analytics-charts,
  canvas {
    max-width: 100%;
  }

  /* Finance grids collapse earlier */
  .fin-income-grid,
  .fin-pl-grid { grid-template-columns: repeat(2, 1fr); }

  /* Location layout stack */
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE: Mobile (768px)
   ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Font size scale-down for mobile */
  body { font-size: 13px; }
  .page-title { font-size: 16px; }
  .page-subtitle { font-size: 12px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 11px; }

  /* Padding reduction */
  .main { padding: 10px; padding-bottom: 80px; }
  .card { padding: 12px; }
  .stat-card { padding: 10px; }

  /* ALL tables: horizontal scroll wrapper */
  .table-container,
  .table-scroll,
  .rev-table-scroll,
  [class*="-table-wrap"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-container table,
  .table-scroll table,
  .rev-table-scroll table,
  .main table {
    min-width: 580px;
  }

  /* Grid layouts collapse to single column */
  .fin-income-grid,
  .fin-pl-grid,
  .fin-exp-layout,
  .hub-analytics-charts,
  .ret-form-grid-3,
  .rcv-body-cols.rcv-has-po {
    grid-template-columns: 1fr !important;
  }

  /* Finance category row stack */
  .fin-cat-row { grid-template-columns: 1fr; gap: 4px; }

  /* Charts responsive */
  .acc-chart-container,
  .cust-rev-chart,
  .cust-freq-chart,
  .sla-volume-chart,
  .hub-analytics-charts,
  canvas {
    max-width: 100%;
    overflow-x: auto;
  }
  .cust-rev-chart,
  .cust-freq-chart {
    height: auto;
    min-height: 120px;
  }

  /* Modals: full-width on mobile */
  .modal-480,
  .modal-680,
  .modal-420,
  .modal-380,
  .modal-320,
  .rcv-po-picker-modal,
  .hub-modal,
  .hub-return-modal,
  .cp-modal {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    margin: 12px auto;
  }

  /* Customer hub layout */
  .hub-container { grid-template-columns: 1fr; }
  .hub-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 40vh; }
  .hub-customer-panel { display: none; }

  /* Responder sidebar stacks below */
  .responder-sidebar { width: 100%; }

  /* Reduce header padding */
  .header { padding: 0 10px; }
  .header-right { gap: 4px; }

  /* Toolbars stack */
  .toolbar,
  .lbl-tools-row {
    flex-direction: column;
    align-items: stretch;
  }
  .lbl-tools-row > * { flex: none; }

  /* Tab groups scroll horizontally */
  .tab-group,
  .tabs,
  [class*="-tabs"],
  [class*="-tab-group"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  /* Morning brief grid */
  .mb-pl-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE: Small Mobile (480px)
   ───────────────────────────────────────────────────────────── */

@media (max-width: 1360px) {
  .header {
    padding-inline: 16px;
  }

  .header-status-group {
    /* Labels are hidden in this band (below), so the rail is just the status
       dots — size the pill to its content instead of reserving a fixed 320px
       that left it visibly half-empty next to the logo. */
    flex: 0 0 auto;
  }

  .header-right {
    gap: 6px 8px;
  }

  .shell-search-btn .shell-kbd,
  .header-freshness-label,
  .api-health-label,
  .sync-status span,
  .live-indicator span,
  /* Drop the redundant "View as:" prefix when cramped — the dropdown already
     shows the active role, so the switcher shrinks to just that control. */
  .view-as-label {
    display: none;
  }

  .header-freshness-wrap,
  .sync-status,
  .live-indicator,
  .api-health-wrap {
    padding-inline: 9px;
  }
}

/* Below this the header splits into a 2-row grid (status rail on its own row).
   Lowered 1120 → 1080 once the status cluster collapsed to the compact "System"
   chip: the header now fits on ONE row down to ~1080px, so it no longer needs
   to double its height at tablet-ish widths. */
@media (max-width: 1080px) {
  .header {
    align-items: center;
    gap: 8px 12px;
  }

  /* ⛔ ONE ROW, ALWAYS — Cole 2026-08-31: "sometimes when I get smaller, it
     shows it as two rows, whereas it should always show it as only one row …
     let's make this better permanently."
     MEASURED before the change: at 950px the header was 99px tall with
     `.header-right` on two lines, because THIS rule set `flex-wrap: wrap` and,
     sitting later in the file, beat the `@media (min-width: 769px)` nowrap
     above. The wrap band ran the width of this query.

     The July 2026 reason for wrapping still stands and is respected: fixed
     grid columns let nowrap groups spill UNDER their neighbour (role pills
     over Refresh/Sync/中文, worse in zh where every string is a different
     width), and wrapping made overlap structurally impossible.

     🔑 So the fix is not "nowrap and hope". Overlap happens when children
     CANNOT shrink — the measurement showed the three groups summing to 887px
     inside an 880px box at `flex: 0 0 auto`, i.e. 7px of shortfall with no
     give anywhere, which is exactly when a flex row either wraps or spills.
     Every group here is therefore shrinkable (`min-width: 0`, `flex: 0 1
     auto`) and the lowest-priority one SCROLLS instead of growing. A flex row
     whose children can all shrink to zero cannot overlap either. */
  .header-right {
    flex: 1 1 auto;
    flex-basis: auto;
    width: auto;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px 10px;
    min-width: 0;
  }

  .header-status-group,
  .header-action-group,
  .header-account-group {
    width: auto;
    min-width: 0;
    flex-wrap: nowrap;
    flex: 0 1 auto;
  }

  /* The action strip is the give in the row: it compresses first and scrolls
     rather than pushing anyone to a second line. Scrollbar hidden — a visible
     one inside a 40px toolbar reads as a rendering fault. */
  .header-action-group {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .header-action-group::-webkit-scrollbar { display: none; }

  /* Identity is the last thing to give up space: you must always be able to
     see who you are signed in as and how to sign out. */
  .header-account-group { flex: 0 0 auto; }

  /* The tagline under the wordmark is the cheapest thing to drop — it is
     decoration, and dropping it buys the row real width in exactly the band
     that was breaking. */
  .header .logo-sub { display: none; }

  /* Status cluster is now just the compact "● System" chip + bell, so it sits
     inline in column 1 (hugging its content via justify-self:start — NOT
     stretched across the row, which produced a giant mostly-empty pill). The
     action + account clusters share the same row on the right. */
  .header-status-group {
    grid-column: 1 / 2;
    justify-self: start;
    width: max-content;
    max-width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  /* ⛔ NOT `flex-wrap: wrap`. This rule sits later in the same 1080px query
     than the nowrap above and quietly won it back, so the ACCOUNT group kept
     breaking to a second line on its own — measured at 950px: `.header-right`
     one line, `.header-account-group` 73px tall inside it. Two rules in one
     media query disagreeing is why this kept coming back. */
  .header-action-group,
  .header-account-group {
    justify-content: flex-end;
    flex-wrap: nowrap;
    flex: 0 1 auto;
    min-width: 0;
  }

  .header-status-group::-webkit-scrollbar {
    display: none;
  }

  .user-info {
    border-left: none;
    padding-left: 0;
  }
}

@media (max-width: 980px) {
  .header-freshness-wrap,
  .sync-status,
  .api-health-wrap {
    display: none;
  }

  .header-status-group {
    gap: 6px;
  }

  .view-mode-indicator {
    display: none;
  }
}

@media (max-width: 860px) {
  .header-status-group {
    display: none;
  }

  /* Third place the wrap crept back in. Below 860 the status chip is hidden
     entirely and the view-as switcher and user name go with it, so the row
     has plenty of give — it does not need to wrap, and wrapping here is what
     produced the tall header on a narrow laptop. */
  .header-right {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 6px 8px;
    min-width: 0;
  }

  .header-action-group,
  .header-account-group {
    width: auto;
  }

  .view-as-switcher {
    display: none !important;
  }

  .user-name {
    display: none;
  }
}

/* ── The header can never overlap, structurally ────────────────────────────
   Cole 2026-08-31: "this keeps breaking and looking ugly on the top and
   glitchy … let's make this better permanently."

   Going single-row re-opened the 2026-07-18 failure that wrapping had papered
   over: with `nowrap`, a container that shrinks below its content and has
   `overflow: visible` lets that content ESCAPE onto its neighbour. Measured at
   950px: `.view-as-switcher` was 184px wide holding 190px of children, and the
   Supplier button rendered on top of the Brands link.

   🔑 A flex row does not overlap because it wraps; it overlaps because a child
   cannot shrink AND cannot be clipped. So both are fixed here, and both are
   needed — shrinking alone still spills at the extreme, clipping alone throws
   content away that had room to compress.

   This sits OUTSIDE any media query on purpose: the old rules disagreed with
   each other across three breakpoints, which is why the bug kept coming back
   in a different band each time. */
.view-as-switcher {
  min-width: 0;
  overflow: hidden;          /* the backstop: nothing escapes this box */
}
.view-as-switcher > * {
  min-width: 0;
  flex: 0 1 auto;            /* compress before anyone is clipped */
}
.view-as-select,
.view-as-btn {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The BRAND LOCKUP is the other place this bit, and only on Interior Moderna:
   `.logo` is `white-space: nowrap`, so its min-content width is the whole
   wordmark. Measured at 950px on the IM shell, "Interior Moderna" rendered
   12→167 while the notification bell began at 163 — a 4px overlap that the
   Pepper Row shell never showed, because its wordmark is shorter. Verifying
   one brand's header would have missed it entirely. */
.header-left {
  overflow: hidden;
}
/* The wordmark sits inside an unclassed wrapper div. `.header-left` clipping
   alone is not enough: that wrapper kept its full 155px BOX (overflow
   visible), so its geometry still ran past the notification bell even though
   the paint was clipped — hit-testing at the contested pixels returned the
   BELL, not the wordmark, so nothing was visually wrong. Geometry is what a
   layout audit measures though, and a box that lies is a finding somebody has
   to re-derive later. Descendant selector, not child: the chain is
   header-left > brand-lockup > div > .logo, so `>` missed the wrapper. */
.header-left div {
  overflow: hidden;
  max-width: 100%;
}
.header .logo,
.header .logo-sub {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Identity text gives up width gracefully rather than pushing Sign Out out of
   the row — you can always still see the badge and the button. */
.header .user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Header fit contract ────────────────────────────────────────────────────
   Long notification titles were already ellipsized, but the desktop shell
   still kept every following control at full label width until 1080px. At
   browser zoom / 125%-150% display scaling, a physically wide screen can have
   a 1200-1600 CSS-pixel viewport, which made those fixed clusters paint over
   one another. Compact the REDUNDANT labels before space becomes critical;
   every control keeps its icon, tooltip and aria-label. The existing <=1080
   wrapping layout remains the structural last line of defence. */
@media (min-width: 769px) and (max-width: 1700px) {
  .header { padding-inline: 12px; gap-inline: 12px; }
  .header-right { gap-inline: 6px; }
  .header-status-group { flex: 1 1 150px; max-width: 330px; }
  .team-notif-tickerwrap { flex: 1 1 100px; max-width: 220px; }
  .team-notif-ticker { width: 100%; max-width: 100%; }
  .header-action-group { gap: 5px; flex: 0 0 auto; }
  .header-account-group { gap: 5px; }
  .header-action-group > .refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0 !important;
  }
  .header-action-group .header-control-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .header-control-icon { flex: 0 0 auto; line-height: 1; }
  .user-name { max-width: 110px; }
}

@media (min-width: 769px) and (max-width: 1450px) {
  .header-left .logo-sub { display: none; }
  .header-status-group { max-width: 250px; }
  .team-notif-tickerwrap { max-width: 150px; }
  .team-notif-ticker-count { display: none; }
}

@media (min-width: 769px) and (max-width: 1220px) {
  .team-notif-tickerwrap { display: none !important; }
  .header-status-group { flex: 0 0 auto; max-width: none; }
}

@media (max-width: 480px) {
  body { font-size: 13px; }

  .main { padding: 8px; padding-bottom: 72px; }

  /* Stat bands: compact 2-col, NOT single column (2026-07-16 density pass —
     the 1fr blanket here was a second escape hatch stacking stat tiles
     one-per-row on phones; the real treatment lives in css/mobile.css
     MOBILE DENSITY LAYER). .mb-pl-grid keeps 1fr (long P&L label rows). */
  .stat-grid,
  .stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .mb-pl-grid {
    grid-template-columns: 1fr !important;
  }

  /* Morning brief top3 compact */
  .mb-top3-container { padding: 12px; }
  .mb-top3-item { padding: 8px 10px; }

  /* Table min-width smaller for tiny screens */
  .table-container table,
  .table-scroll table,
  .main table {
    min-width: 480px;
  }

  /* Modals truly full-width */
  .modal-480,
  .modal-680,
  .modal-420,
  .modal-380,
  .modal-320,
  .rcv-po-picker-modal,
  .hub-modal,
  .hub-return-modal {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    border-radius: var(--radius-sm);
  }

  /* Charts tighter */
  .cust-rev-chart,
  .cust-freq-chart {
    min-height: 100px;
    gap: 8px;
  }
  .acc-chart-body { height: 140px; }

  /* Header even more compact */
  .header { padding: 0 8px; }
  .logo { font-size: 12px; letter-spacing: 0.8px; }
}

/* ─────────────────────────────────────────────────────────────
   PRINT — hide toast + progress bar
   ───────────────────────────────────────────────────────────── */

@media print {
  .sidebar, .header, .theme-toggle-btn,
  #toast-container, #page-progress-bar,
  .main { padding: 0 !important; }
  .app { display: block !important; }
  [data-theme="dark"] { filter: invert(1) hue-rotate(180deg); }
}

/* ─────────────────────────────────────────────────────────────
   iOS-STYLE TOGGLE SWITCH (.im-switch)
   Used on the Returns Stock refurbished row to flip a unit between
   "listed on Shopify" and "not listed" in one click. Replaces the
   old List for Sale / Unlist button pair. Keep the DOM minimal —
   a single <button> with ::after for the thumb — so it works in
   any table cell without extra wrapper structure.
   ───────────────────────────────────────────────────────────── */
.im-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  padding: 0;
  /* Use a concrete mid-grey for the OFF track instead of surface-2 —
     surface-2 matched the card/hover background on Returns Stock and
     made the toggle disappear on hover. A hard 1px border keeps the
     track visible against any background. */
  background: #cbd5e1;
  border: 1px solid #94a3b8;
  border-radius: 12px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
  flex-shrink: 0;
  vertical-align: middle;
}

.im-switch:hover {
  background: #b6c0cc;
  border-color: #64748b;
}

.im-switch::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 150ms ease;
}

.im-switch.on {
  background: #2563eb;
  border-color: #1d4ed8;
}

.im-switch.on:hover {
  background: #1d4ed8;
  border-color: #1e40af;
}

.im-switch.on::after {
  transform: translateX(18px);
}

.im-switch.disabled,
.im-switch[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.im-switch:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.im-switch-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
}

.im-switch-label.on {
  color: #16a34a;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   MODERNIZATION LAYER (2026-06-17) — micro-interactions & depth
   Additive only. The global prefers-reduced-motion rule earlier in
   this file zeroes every transition below for motion-sensitive users.
   ═══════════════════════════════════════════════════════════════ */
:root {
  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
  --motion-fast: 0.13s;
  --motion: 0.2s;
}

/* Consistent, smooth interaction feedback across every control */
button, .btn, .nav-item, .filter-btn, .toggle-btn, .action-btn, .refresh-btn,
.pill, .badge, a, input, select, textarea, summary,
[role="button"], [data-action],
[class*="-card"][onclick], [class*="-card"][role="button"],
.mb-kpi-card, .cp-agent-card, .stat-card {
  transition: background-color var(--motion) ease,
              border-color var(--motion) ease,
              color var(--motion) ease,
              box-shadow var(--motion) ease,
              transform var(--motion-fast) var(--ease-out),
              opacity var(--motion) ease;
}

/* Tactile press feedback on buttons */
button:active:not(:disabled), .btn:active:not(:disabled),
.filter-btn:active, .action-btn:active, .refresh-btn:active,
[role="button"]:active {
  transform: translateY(1px);
}

/* Inputs: clearer accent focus ring */
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}

/* Interactive cards lift on hover — modern, responsive depth */
[class*="-card"][onclick]:hover,
[class*="-card"][role="button"]:hover,
.mb-kpi-card:hover,
.cp-agent-card:hover,
a[class*="-card"]:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Smooth table-row hover */
tbody tr { transition: background-color var(--motion) ease; }

/* Modern thin scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-hover) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); background-clip: padding-box; }

/* Smooth in-page anchor scrolling (reduced-motion override above wins for opt-outs) */
html { scroll-behavior: smooth; }

/* ═══════════════════════════════════════════════════════════
   Theme crossfade — active ONLY during the ~280ms toggle.
   toggleTheme() adds `.theme-anim` to <html>, flips data-theme, then
   removes the class. Scoping the transition to that temporary class means
   normal interactions are never slowed, and the whole surface (backgrounds,
   borders, text, icon fills, shadows) eases between light/dark instead of
   hard-cutting in a single frame.
   ═══════════════════════════════════════════════════════════ */
html.theme-anim,
html.theme-anim * {
  transition: background-color .26s ease, border-color .26s ease,
              color .26s ease, fill .26s ease, box-shadow .26s ease !important;
}
@media (prefers-reduced-motion: reduce) {
  html.theme-anim,
  html.theme-anim * { transition: none !important; }
}

/* ═══════════════════════════════════════════════════════════
   Route-load skeleton — shown by loadView() on navigation instead of a
   centered spinner. A layout-matched placeholder (title + stat tiles +
   rows) means content arrives into the same shape, killing the
   blank-then-pop flash and reducing layout shift. Uses the existing
   .skeleton shimmer. Respects prefers-reduced-motion via .skeleton's own
   reduced-motion opt-out elsewhere in this file.
   ═══════════════════════════════════════════════════════════ */
.view-skeleton { padding: 10px 4px 24px; }
.view-skeleton .vsk-title { height: 28px; width: 220px; margin: 6px 0 20px; }
.view-skeleton .vsk-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.view-skeleton .vsk-stat { height: 84px; }
.view-skeleton .vsk-row { height: 46px; margin-bottom: 10px; }
@media (max-width: 900px) { .view-skeleton .vsk-stats { grid-template-columns: repeat(2, 1fr); } }

/* ═══════════════════════════════════════════════════════════
   CANONICAL BADGES — Tier 1
   Unifies the 165 color-named badges onto tokenized colors and adds SEMANTIC
   aliases (success/warning/danger/info/neutral) so new code expresses meaning,
   not color. Shape is applied to the semantic + color-named variants but NOT
   to bare `.badge` (which the nav-count bubbles rely on for their own circular
   layout). Loads last, so these win over the scattered legacy definitions.
   ═══════════════════════════════════════════════════════════ */
.badge-green,  .badge-success { background: var(--success-dim); color: var(--green);  }
.badge-red,    .badge-danger  { background: var(--danger-dim);  color: var(--red);    }
.badge-yellow, .badge-warning { background: var(--warning-dim); color: var(--yellow); }
.badge-blue,   .badge-info    { background: var(--info-dim);    color: var(--blue);   }
.badge-purple                 { background: var(--purple-dim);  color: var(--purple); }
.badge-accent                 { background: var(--accent-dim);  color: var(--accent); }
.badge-gray, .badge-grey, .badge-neutral {
  background: var(--surface-2); color: var(--text-muted);
}
/* Consistent pill shape for the color-named + semantic variants. Excludes bare
   `.badge` so contextual badges (nav counts, inbox headers) keep their layout. */
.badge-green, .badge-red, .badge-yellow, .badge-blue, .badge-purple,
.badge-accent, .badge-gray, .badge-grey, .badge-neutral,
.badge-success, .badge-danger, .badge-warning, .badge-info {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.5;
  letter-spacing: 0.01em;
  white-space: nowrap;
  vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════
   Tier 2 — generalized overlay/modal motion + consistent close controls
   Only the command palette + journey modal animated their entrance before;
   most of the ~34 modal/drawer families popped in instantly. Apply an
   OPACITY-ONLY fade (never a transform — so it can't fight a modal's own
   centering transform) to the common generic families. Reduced-motion safe.
   ═══════════════════════════════════════════════════════════ */
.modal-overlay,
.drawer-overlay,
.modal-backdrop { animation: overlayIn 0.16s ease both; }
.modal,
.modal-content,
.modal-card,
.drawer-panel { animation: overlayIn 0.18s ease both; }
@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .drawer-overlay, .modal-backdrop,
  .modal, .modal-content, .modal-card, .drawer-panel { animation: none !important; }
}

/* Consistent close control across modals/drawers/panels (glyph stays whatever
   the markup uses; this unifies size, hit-area, color, and hover). */
.modal-close,
.drawer-close,
.panel-close,
.btn-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard);
}
.modal-close:hover,
.drawer-close:hover,
.panel-close:hover,
.btn-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Button tail — fold color/size one-offs onto the canonical semantics so the
   button family reads consistently (the base .btn/.btn-primary/etc. are fine). */
.btn-green   { background: var(--green); color: #fff; border-color: var(--green); }
.btn-red     { background: var(--red);   color: #fff; border-color: var(--red); }
.btn-small   { padding: 3px 8px; font-size: var(--fs-xs); border-radius: var(--radius-sm); }

/* ═══════════════════════════════════════════════════════════
   Tier 2 — sticky data-table headers
   Long P&L / inventory / cashflow tables lost their header on scroll, and the
   sticky snippet was copy-pasted per-view with drifting z-index/background.
   One canonical rule on .data-table. Opaque background + inset shadow border
   (border-bottom doesn't render reliably on a sticky cell under
   border-collapse). Short tables never scroll, so this is invisible there.
   ═══════════════════════════════════════════════════════════ */
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
}

/* ═══════════════════════════════════════════════════════════
   A11y — keyboard focus safety net
   The app has 40+ :focus-visible rules but several controls (notably the
   support inbox inputs in inbox-v2.css) strip their outline with no keyboard
   replacement. This generic ring applies ONLY where a more specific
   :focus-visible rule doesn't already win, and ONLY for keyboard focus
   (:focus-visible never matches mouse clicks), so it never disturbs the
   designed states or mouse interaction.
   ═══════════════════════════════════════════════════════════ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Support inbox (inbox-v2) strips input/button outlines on :focus with no
   keyboard replacement (audit P1). Restore a ring for KEYBOARD focus only —
   !important + :focus-visible beats the more-specific `.iv2-*:focus{outline:none}`
   without affecting mouse focus. */
[class*="iv2-"]:focus-visible,
.iv2 input:focus-visible,
.iv2 textarea:focus-visible,
.iv2 button:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 1px;
}

/* ═══════════════════════════════════════════════════════════
   Sticky table headers — dashboard-wide (owner 2026-07-07)
   Column titles stay pinned while the data scrolls, on every tab.

   How it works with our layout: #mainContent is the app's ONE scroll
   container (body is overflow:hidden), but almost every table sits inside
   its own overflow:auto wrapper — and a sticky thead only sticks within its
   NEAREST scroll container. Inside a wrapper that grows with the table,
   sticky never engages. So js/ui-enhancements.js (initStickyTableHeaders)
   caps any scrollable wrapper that contains a table (.sticky-thead-wrap,
   max-height below) so the wrapper itself scrolls and the header pins to
   its top. Tables NOT in a wrapper stick against #mainContent naturally.

   Low specificity ON PURPOSE: any view with its own `.x thead th` styling
   (background, padding) still wins for those properties; `position` is not
   set by view styles, so stickiness applies everywhere. th needs an opaque
   background or the rows show through while pinned — this fallback only
   applies where no view rule paints one.
   ═══════════════════════════════════════════════════════════ */
thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface-2);
}
.sticky-thead-wrap {
  max-height: 74vh;
  overflow: auto;
}
/* Dashboard-wide sortable table headers. Ordinary tables are hydrated by
   ui-enhancements.js; server-backed views keep their own sort indicators. */
#mainContent th.dashboard-sortable {
  cursor: pointer;
  user-select: none;
}

#mainContent th.dashboard-sortable::after {
  content: " ↕";
  color: var(--text-muted);
  font-size: .88em;
  opacity: .72;
}

#mainContent th.dashboard-sortable[aria-sort="ascending"]::after {
  content: " ↑";
  color: var(--accent);
  opacity: 1;
}

#mainContent th.dashboard-sortable[aria-sort="descending"]::after {
  content: " ↓";
  color: var(--accent);
  opacity: 1;
}

#mainContent th.dashboard-sortable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
