/* =============================================================================
   ecomexsaas — "Notion" design system (clean monochrome).

   Rules:
     - Clean white surfaces (--color-bg #FFFFFF) with subtle neutral greys; warm
       charcoal text (#37352F). Dark mode = Notion neutral near-black (#191919).
     - Primary button is near-black (--color-accent #191919) — the Notion "black
       button"; dark mode flips it to white. Notion is MONOCHROME: --color-brand
       tracks the ink (#37352F) so links, active nav, the send button, the Juno
       mark and focus rings stay charcoal, never a colored highlight.
     - Typography = the Boardroom exhibit grammar, app-wide (owner pick
       2026-07-19): --font-display (Lora) titles, --font-label (IBM Plex
       Mono) uppercase kickers, --font-body (Inter) everything else; values
       are body-semibold + tabular nums. font-family is assigned ONLY in the
       TYPE ROLES section after the reset — change the three role tokens and
       the whole SaaS follows (scripts/check_font_roles.py enforces this).
       Table headers are consulting-style: small uppercase label-face, subtle
       ink, hairline rule, no fill.
     - Radius scale: 4 / 6 / 8 / 16 (xl, for the chat composer + welcome icon).
     - Semantic colours are muted / "silent" and carry meaning only:
         success #0F7B6C (profit)  warning #CB912F  error #E03E3E (loss)
   ============================================================================= */

/* ---------- Tokens (light) ----------------------------------------------- */
:root {
  /* "Notion" — clean monochrome: white surfaces, warm-charcoal text, a near-black
     primary button, and subtle neutral greys. Notion is monochrome, so the
     accent tracks the ink (links / active nav / send button / focus rings stay
     charcoal, not colored). Muted semantics carry meaning only. */
  --color-bg:           #FFFFFF;   /* clean white — Notion canvas */
  --color-bg-subtle:    #F7F7F5;
  --color-bg-muted:     #EFEEEC;   /* Notion hover grey */
  --color-surface:      #FFFFFF;
  --color-text:         #37352F;   /* Notion warm charcoal */
  --color-text-muted:   #787774;   /* Notion muted grey */
  --color-text-subtle:  #9B9A97;
  --color-border:       #E9E9E7;   /* Notion divider */
  --color-border-strong:#DCDCDA;

  --color-accent:       #191919;   /* primary button = near-black (the Notion "black button") */
  --color-accent-hover: #2C2C2C;
  --color-accent-text:  #FFFFFF;

  /* Monochrome accent — tracks the ink so links, active nav, the send button,
     the Juno mark and focus rings stay charcoal, never a colored highlight. */
  --color-brand:        #37352F;
  --color-brand-hover:  #191919;
  --color-brand-text:   #FFFFFF;
  --color-brand-soft:   rgba(55, 53, 47, 0.09);   /* focus-ring / soft tint */

  --color-success: #0F7B6C;   /* Notion green — profit */
  --color-warning: #CB912F;   /* Notion amber */
  --color-error:   #E03E3E;   /* Notion red — loss */

  --color-success-bg: rgba(15, 123, 108, 0.10);
  --color-warning-bg: rgba(203, 145, 47, 0.12);
  --color-error-bg:   rgba(224, 62, 62, 0.10);

  /* FONT ROLES — the three knobs for the whole SaaS. Swap a stack here (and
     the Google-Fonts <link> in templates/base.html) and every page follows:
     assignments live ONLY in the TYPE ROLES section below the reset, and
     scripts/check_font_roles.py blocks font-family anywhere else. */
  --font-display: "Lora", Georgia, "Times New Roman", serif;                                       /* titles */
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;   /* UI + text */
  --font-label:   "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; /* kickers + figures chrome */

  /* Legacy aliases — old names keep resolving so any stray reference
     (including JS getComputedStyle readers) follows the roles above. */
  --font-sans:  var(--font-body);
  --font-serif: var(--font-display);
  --font-mono:  var(--font-label);

  --fs-xs:  12px;
  --fs-sm:  13px;
  --fs-md:  14px;
  --fs-lg:  16px;
  --fs-xl:  20px;
  --fs-2xl: 24px;
  --fs-3xl: 32px;

  --fw-normal:   400;
  --fw-medium:   500;
  --fw-semibold: 600;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 16px;   /* Claude chat composer + welcome icon */

  --shadow-none: none;
  --shadow-xs:   0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm:   0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-md:   0 6px 24px rgba(0, 0, 0, 0.10);  /* sidebar hover-overlay + composer lift */

  --sidebar-w:           260px;
  --sidebar-w-collapsed: 56px;
  --topbar-h:            48px;
  --content-max:         1200px;
  --chat-max:            740px;   /* Juno message column + composer width */
  --content-pad-y: 32px;
  --content-pad-x: 24px;

  --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;

  /* Read by JS via getComputedStyle so charts auto-darken in dark mode. */
  --chart-grid: var(--color-border);
  --chart-axis: var(--color-text-muted);

  /* Height of the impersonation banner when active. Defaults to 0 so the
     topbar's `top: var(--impersonation-banner-h)` is harmless when not
     impersonating. Bumped via the body[data-impersonating] selector below. */
  --impersonation-banner-h: 0px;
}

body[data-impersonating="true"] {
  --impersonation-banner-h: 40px;
}

/* ---------- Tokens (dark) ------------------------------------------------ */
[data-theme="dark"] {
  --color-bg:           #191919;   /* Notion neutral near-black */
  --color-bg-subtle:    #1F1F1F;
  --color-bg-muted:     #252525;
  --color-surface:      #1F1F1F;
  --color-text:         #EDEDEC;
  --color-text-muted:   #9B9A97;
  --color-text-subtle:  #6E6E6C;
  --color-border:       #2D2D2C;
  --color-border-strong:#3B3B3A;

  --color-accent:       #FFFFFF;   /* primary button flips to white in dark (Notion) */
  --color-accent-hover: #E0E0DF;
  --color-accent-text:  #191919;

  --color-brand:        #D4D4D2;   /* monochrome accent = light ink in dark */
  --color-brand-hover:  #FFFFFF;
  --color-brand-text:   #191919;
  --color-brand-soft:   rgba(255, 255, 255, 0.10);

  /* Brighten the muted semantics in dark so profit/loss figures stay crisp. */
  --color-success: #4DAB9A;
  --color-warning: #E3B341;
  --color-error:   #FF7369;

  --color-success-bg: rgba(77, 171, 154, 0.16);
  --color-warning-bg: rgba(227, 179, 65, 0.16);
  --color-error-bg:   rgba(255, 115, 105, 0.16);
}

/* ---------- Reset / base ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  color: var(--color-text);
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p  { margin: 0; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--color-border); margin: var(--space-4) 0; }

/* =========================================================================
   TYPE ROLES — the ONLY place font-family is ever assigned (enforced by the
   scripts/check_font_roles.py pre-commit guard). The Boardroom exhibit
   grammar, app-wide:

     --font-display → action titles: pages, cards, panels, hero figures
     --font-body    → everything else. It inherits from body; the re-assert
                      list below exists only where the UA breaks inheritance
                      (inputs, textareas, svg text) or a component must
                      opt back out of a parent role.
     --font-label   → kickers: uppercase micro-labels, eyebrows, section
                      heads, table heads, mono figures chrome.

   Weight floor: Lora loads at 500/600 and IBM Plex Mono at 400/500 (see the
   Google-Fonts link in templates/base.html) — keep display ≤ --fw-semibold
   and label ≤ --fw-medium or browsers will faux-bold.
   TYPE-ROLES:BEGIN */
body { font-family: var(--font-body); }

/* body re-asserts — UA inheritance breaks or opt-outs */
.ai-memory-body,
.chat-msg-text,
.chat-composer textarea,
.chat-composer .chat-composer-input,
.public-chat-input,
.assistant-input,
.assistant-chip,
.dod-dialog-text,
.dash-goal-input,
.lp-page,
.lp-viz-card svg text {
  font-family: var(--font-body);
}

/* display — action titles */
h1, h2, h3, h4, h5, h6,
.page-title, .card-title, .auth-title, .preview-title, .empty-state-title,
.datahub-card-title, .dh-dropzone-title,
.pnl-title, .pnl-panel-title, .pnl-findings-title, .pnl-settle-title,
.sb-map-upload-title, .ad-upload-title, .template-group-title,
.snap-source-title, .snap-note-title,
.pnl-welcome-title, .pnl-hero-figure, .pnl-stat-v,
.pnl-line.is-net .pnl-line-amt,
.public-chat-welcome-title, .assistant-welcome-title,
.brief-headline, .exhibit-title, .sr-practice-headline,
.legal-h1, .lp-serif-i, .error-code {
  font-family: var(--font-display);
}

/* label — uppercase kickers, eyebrows, table heads, mono figures chrome */
.font-mono, .error-path,
.nav-section, .label-eyebrow, .stat-label,
.table thead th, .cascade-table th, .comp-row-labels,
.sku-table thead th, .stock-table thead th,
.abc-tier-letter,
.pivot-summary strong, .hierarchy-toggle,
.health-section-title, .my-day-section-title,
.dash-hero-label, .dash-section-title, .dash-card-label, .dash-alerts-label,
.kpi-range-note, .kpi-section-title, .kpi-tile-label,
.cc-finding-impact, .exhibit-kicker, .owner-chip, .tape-label,
.pnl-rail-title, .pnl-hero-eyebrow, .pnl-tax-title, .pnl-perunit-title,
.pnl-mom-label, .snap-recent-title,
.sb-map-input, .sku-pnl-sku,
.lp-svgmono, .lp-eyebrow, .lp-drawer-title, .lp-hero-eyebrow, .lp-hero-trust,
.lp-viz-card svg text.lp-svgmono, .lp-viz-card svg .lp-svgmono text, .lp-viz-title,
.lp-stat-val, .lp-stat-delta, .lp-wrow-top, .lp-wlegend, .lp-pl-chip,
.lp-cr-row, .lp-briefing-bar, .lp-price, .lp-price-old, .lp-trial-note,
.lp-faq summary::after, .lp-composer-prompt,
.neg-block > summary::before, .neg-block-meta, .neg-paste-label, .neg-paste {
  font-family: var(--font-label);
}
/* TYPE-ROLES:END */

/* ---------- Buttons ------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 6px 12px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: 1;
  cursor: pointer;
  transition: background 80ms ease, border-color 80ms ease, color 80ms ease;
  user-select: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--color-accent);
  color: var(--color-accent-text);
  border-color: var(--color-accent);
}
.btn-primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }

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

.btn-ghost { background: transparent; color: var(--color-text); }
.btn-ghost:hover { background: var(--color-bg-muted); }

.btn-danger {
  background: transparent;
  color: var(--color-error);
  border-color: var(--color-border-strong);
}
.btn-danger:hover { background: var(--color-error-bg); border-color: var(--color-error); }

.btn-sm { height: 26px; padding: 4px 10px; font-size: var(--fs-xs); }
.btn-lg { height: 38px; padding: 8px 16px; font-size: var(--fs-md); }
.btn-block { display: flex; width: 100%; }

/* ---------- Cards -------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
/* Card action titles — the .exhibit-title recipe (Boardroom grammar). */
.card-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  line-height: 1.35;
  margin: 0;
  text-wrap: balance;
}
.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: var(--space-5); }
.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ---------- Forms -------------------------------------------------------- */
.form-group { margin-bottom: var(--space-4); }
.form-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="date"],
textarea,
select {
  display: block;
  width: 100%;
  font: inherit;
  font-size: var(--fs-md);
  padding: 7px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 80ms ease, box-shadow 80ms ease;
}
.form-control:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(25, 25, 25, 0.08);
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}
.form-help  { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: 4px; }
.form-error { font-size: var(--fs-xs); color: var(--color-error); margin-top: 4px; }
.form-control[aria-invalid="true"],
.form-control.is-invalid,
input.is-invalid { border-color: var(--color-error); }

.checkbox-row { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); }
.checkbox-row input { width: auto; }

.form-control-sm { padding: 4px 8px; font-size: var(--fs-xs); height: 28px; }
.form-control-num { width: 88px; }
.form-label-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.form-label-inline input[type="number"],
.form-label-inline select {
  width: auto;
}

/* ---------- Tables ------------------------------------------------------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
/* Consulting-table headers (Boardroom .cascade-table grammar): small
   uppercase subtle ink over a strong hairline, no header fill. */
.table thead th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-subtle);
  background: transparent;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-strong);
}
.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--color-bg-subtle); }
/* Currently drilled-into row (e.g. selected country/state in Order Analysis). */
.table tbody tr.row-active { background: var(--color-bg-muted); }
.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ---------- Badges ------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
  letter-spacing: 0.01em;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-error   { background: var(--color-error-bg);   color: var(--color-error);   }
.badge-neutral { background: var(--color-bg-muted);   color: var(--color-text-muted); }

/* ---------- Alerts ------------------------------------------------------- */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  background: var(--color-bg-muted);
  color: var(--color-text);
  margin-bottom: var(--space-3);
}
.alert-success { background: var(--color-success-bg); color: var(--color-success); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.alert-error   { background: var(--color-error-bg);   color: var(--color-error);   }
.alert-info    { background: var(--color-bg-subtle); color: var(--color-text); border: 1px solid var(--color-border); }

.row-dismissed td { opacity: 0.55; }
.table th.col-check, .table td.col-check { width: 32px; }

/* ---------- Tabs --------------------------------------------------------- */
.tabs {
  display: flex;
  gap: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
}
.tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tab:hover { color: var(--color-text); text-decoration: none; }
.tab.active { color: var(--color-text); border-bottom-color: var(--color-accent); }

/* ---------- Modal -------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.32);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  padding: var(--space-4);
}
.modal-overlay.is-open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-sm);
}
.modal-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-body   { padding: var(--space-5); }
.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ---------- Toasts ------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 1100;
  pointer-events: none;
}
.toast {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
  min-width: 260px;
  box-shadow: var(--shadow-sm);
  pointer-events: auto;
  animation: toast-in 200ms ease;
}
.toast-success { border-left: 3px solid var(--color-success); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-error   { border-left: 3px solid var(--color-error); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Toggle switch ----------------------------------------------- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 32px; height: 18px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch-slider {
  position: absolute; inset: 0;
  background: var(--color-border-strong);
  border-radius: 999px;
  transition: background 120ms ease;
  cursor: pointer;
}
.toggle-switch-slider::before {
  content: "";
  position: absolute;
  height: 14px; width: 14px;
  left: 2px; top: 2px;
  background: var(--color-bg);
  border-radius: 50%;
  transition: transform 120ms ease;
}
.toggle-switch input:checked + .toggle-switch-slider { background: var(--color-accent); }
.toggle-switch input:checked + .toggle-switch-slider::before { transform: translateX(14px); }

/* ---------- Empty state ------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
  color: var(--color-text-muted);
}
.empty-state-title {
  font-size: var(--fs-md);
  color: var(--color-text);
  font-weight: var(--fw-medium);
  margin-bottom: var(--space-2);
}
.empty-state-hint {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

/* ---------- Avatar ------------------------------------------------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--color-bg-muted);
  color: #FFFFFF;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  flex-shrink: 0;
  letter-spacing: 0;
}
.avatar-lg { width: 40px; height: 40px; font-size: var(--fs-md); }
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }

/* ---------- Layout: app shell ------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}
.app-sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  display: flex;
  flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
}
.app-sidebar-header {
  height: var(--topbar-h);
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}
.app-sidebar-brand {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.sidebar-collapse-toggle { flex: 0 0 auto; }
.sidebar-collapse-toggle .icon { transition: transform 0.15s ease; transform: rotate(180deg); }
@media (max-width: 900px) { .sidebar-collapse-toggle { display: none; } }
.app-sidebar-nav { flex: 1; padding: var(--space-3) var(--space-2); }
.nav-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-subtle);
  padding: var(--space-3) var(--space-3) var(--space-2);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  cursor: pointer;
}
.nav-link:hover { background: var(--color-bg-muted); color: var(--color-text); text-decoration: none; }
.nav-link.active { background: var(--color-bg-muted); color: var(--color-text); font-weight: var(--fw-medium); }
.nav-link .icon { color: var(--color-text-subtle); }
.nav-link.active .icon { color: var(--color-text); }

/* Claude-style sidebar: New-chat button + collapsible module groups +
   a recent-chats list. Reuses .nav-link / .nav-section / .btn tokens. */
.sidebar-new-chat {
  width: 100%;
  justify-content: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.sidebar-group { border: none; }
.sidebar-group-summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3) var(--space-2);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-subtle);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.sidebar-group-summary::-webkit-details-marker { display: none; }
.sidebar-group-summary:hover { color: var(--color-text-muted); }
.sidebar-group-summary .icon {
  flex: 0 0 auto;
  color: var(--color-text-subtle);
  transition: transform 0.12s ease-in-out;
}
.sidebar-group[open] > .sidebar-group-summary .icon { transform: rotate(90deg); }
.sidebar-group-body { display: flex; flex-direction: column; gap: 1px; }
/* The recent-chats list flows in the scrolling sidebar (the sidebar owns
   the scroll), unlike the old fixed-height rail. */
.app-sidebar .sidebar-chats { flex: 0 0 auto; overflow: visible; }

/* ---- Sidebar space switcher (Home · Team · Data) + panes --------------- */
/* Segmented control, one pill per space; the active pill lifts to the canvas
   colour like a Notion/Claude toggle. Settings is reached from the footer gear,
   not a fourth pill. Panes are swapped by static/js/theme.js (switchSpace). */
.sidebar-spaces {
  display: flex;
  gap: 2px;
  margin: var(--space-2) var(--space-2) 0;
  padding: 3px;
  background: var(--color-bg-muted);
  border-radius: var(--radius-md);
}
.sidebar-space-tab {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 6px 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-space-tab .icon { flex: 0 0 auto; color: var(--color-text-subtle); }
.sidebar-space-tab:hover { color: var(--color-text); }
.sidebar-space-tab.is-active {
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}
.sidebar-space-tab.is-active .icon { color: var(--color-text); }

/* Only the active space's pane is in the flow; the others are hidden. */
.sidebar-pane { display: none; flex-direction: column; }
.sidebar-pane.is-active { display: flex; }

/* The footer gear that opens the Settings pane; lit while Settings is active. */
.sidebar-settings-toggle.is-active { background: var(--color-bg-muted); color: var(--color-text); }
.sidebar-settings-toggle.is-active .icon { color: var(--color-brand); }

.app-sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.app-sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
}
.app-sidebar-user-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-sidebar-user-email { font-size: var(--fs-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Account menu — native <details> popover opened from the sidebar footer
   avatar, Claude.ai-style (Settings / Support / Policies / Log out). Opens
   upward since the trigger sits at the bottom of the sidebar. */
.user-menu { position: relative; flex: 1 1 auto; min-width: 0; }
.user-menu-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 1200;
  min-width: 220px;
  max-width: 280px;
  padding: var(--space-1);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 6px var(--space-2);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  font-size: var(--fs-sm);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.user-menu-item:hover { background: var(--color-bg-muted); text-decoration: none; }
.user-menu-item-sub { padding-left: var(--space-5); font-size: var(--fs-xs); color: var(--color-text-muted); }
.user-menu-section-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2) 0;
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.user-menu-divider { height: 1px; margin: var(--space-1) 0; background: var(--color-border); }
.user-menu form { margin: 0; }

/* ---- Sidebar: Claude clay active accent + collapsible icon rail -------- */
.app-shell { position: relative; }   /* anchor for the hover-peek overlay */
.nav-link.active .icon { color: var(--color-brand); }
.assistant-convo-row.active { box-shadow: inset 2px 0 0 var(--color-brand); }

@media (min-width: 901px) {
  /* Collapsed: the grid reserves only the slim rail; the sidebar fills it. */
  body[data-sidebar-collapsed="true"] .app-shell {
    grid-template-columns: var(--sidebar-w-collapsed) 1fr;
  }
  /* Rail (collapsed + not hovered): show only the New-chat icon, the toggle
     and the account avatar — labels, groups and chats hide. */
  body[data-sidebar-collapsed="true"] .app-sidebar:not(:hover) .app-sidebar-brand,
  body[data-sidebar-collapsed="true"] .app-sidebar:not(:hover) .nav-section,
  body[data-sidebar-collapsed="true"] .app-sidebar:not(:hover) .sidebar-group,
  body[data-sidebar-collapsed="true"] .app-sidebar:not(:hover) .sidebar-chats,
  body[data-sidebar-collapsed="true"] .app-sidebar:not(:hover) .app-sidebar-user,
  body[data-sidebar-collapsed="true"] .app-sidebar:not(:hover) .sidebar-spaces,
  body[data-sidebar-collapsed="true"] .app-sidebar:not(:hover) .sidebar-settings-toggle,
  body[data-sidebar-collapsed="true"] .app-sidebar:not(:hover) .app-sidebar-footer form {
    display: none;
  }
  body[data-sidebar-collapsed="true"] .app-sidebar:not(:hover) .sidebar-new-chat {
    font-size: 0;
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }
  body[data-sidebar-collapsed="true"] .app-sidebar:not(:hover) .app-sidebar-header {
    justify-content: center;
    padding: 0;
  }
  body[data-sidebar-collapsed="true"] .app-sidebar:not(:hover) .app-sidebar-footer {
    justify-content: center;
  }
  /* Hover-peek: float the full sidebar out over the content (no reflow —
     the 56px grid track stays reserved). */
  body[data-sidebar-collapsed="true"] .app-sidebar:hover {
    position: absolute;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-w);
    box-shadow: var(--shadow-md);
    z-index: 30;
  }
  /* Toggle chevron points right (expand) when collapsed. */
  body[data-sidebar-collapsed="true"] .sidebar-collapse-toggle .icon { transform: rotate(0deg); }
}

.app-topbar {
  grid-area: topbar;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  padding: 0 var(--space-5);
  /* Honor the iPhone notch when launched as a standalone PWA. */
  padding-left:  max(var(--space-5), env(safe-area-inset-left));
  padding-right: max(var(--space-5), env(safe-area-inset-right));
  gap: var(--space-3);
  position: sticky;
  /* Sits below the impersonation banner when one is shown. */
  top: var(--impersonation-banner-h);
  z-index: 10;
}
.topbar-left  { flex: 1; display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: var(--space-2); }

/* Store / workspace switcher — native <details> dropdown in the topbar. */
.ws-switcher { position: relative; }
.ws-switcher-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 26px;
  padding: 4px 10px;
  max-width: 220px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1;
  cursor: pointer;
  user-select: none;
  list-style: none;            /* hide the native disclosure triangle */
}
.ws-switcher-trigger::-webkit-details-marker { display: none; }
.ws-switcher-trigger:hover,
.ws-switcher[open] .ws-switcher-trigger { background: var(--color-bg-muted); }
.ws-switcher-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-switcher-trigger svg:last-child { transition: transform 120ms ease; }
.ws-switcher[open] .ws-switcher-trigger svg:last-child { transform: rotate(180deg); }
.ws-switcher-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1200;
  min-width: 220px;
  max-width: 280px;
  padding: var(--space-1);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.ws-switcher-heading {
  padding: var(--space-1) var(--space-2);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.ws-switcher-form { margin: 0; }
.ws-switcher-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 6px var(--space-2);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
}
.ws-switcher-item:hover { background: var(--color-bg-muted); text-decoration: none; }
.ws-switcher-item.is-current { font-weight: var(--fw-medium); cursor: default; }
.ws-switcher-item.is-current:hover { background: transparent; }
.ws-switcher-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-switcher-tick { width: 14px; height: 14px; flex: none; }   /* aligns rows under the check icon */
.ws-switcher-sep { height: 1px; margin: var(--space-1) 0; background: var(--color-border); }
.ws-switcher-action { color: var(--color-text-muted); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  min-width: 0;
}
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-text); }
.breadcrumb-current { color: var(--color-text); font-weight: var(--fw-medium); }
.breadcrumb-sep { color: var(--color-text-subtle); }

.icon-button {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
}
.icon-button:hover { background: var(--color-bg-muted); color: var(--color-text); }
.icon-button .icon { display: block; }
.icon-button-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 6px; height: 6px;
  background: var(--color-error);
  border-radius: 50%;
  border: 2px solid var(--color-bg);
}

/* Show only the relevant icon for the current theme — used by the dark-mode
   toggle to swap between moon (light theme) and sun (dark theme). */
body[data-theme="light"] [data-theme-only="dark"]  { display: none; }
body[data-theme="dark"]  [data-theme-only="light"] { display: none; }

/* ---------- Impersonation banner ---------------------------------------- */
.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 1200;          /* above topbar, below modal */
  height: var(--impersonation-banner-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  background: var(--color-warning-bg);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-warning);
  font-size: var(--fs-sm);
}
.impersonation-banner .badge-warning {
  background: var(--color-warning);
  color: var(--color-bg);
}

.app-main {
  grid-area: main;
  padding: var(--content-pad-y) var(--content-pad-x);
  /* Bottom inset for the iPhone home indicator when running standalone. */
  padding-bottom: max(var(--content-pad-y), calc(var(--content-pad-y) + env(safe-area-inset-bottom)));
  width: 100%;
  background: var(--color-bg);
  min-width: 0;
}
.app-main-inner { max-width: var(--content-max); margin: 0 auto; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}
.page-title    { font-size: var(--fs-2xl); }
.page-subtitle { color: var(--color-text-muted); font-size: var(--fs-sm); margin-top: 4px; }

/* ---------- Auth screens (no sidebar) ----------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  background: var(--color-bg-subtle);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
}
.auth-brand {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--space-6);
  letter-spacing: -0.01em;
}
.auth-title    { font-size: var(--fs-xl); margin-bottom: var(--space-2); }
.auth-subtitle { font-size: var(--fs-sm); color: var(--color-text-muted); margin-bottom: var(--space-6); }
.auth-footer   { margin-top: var(--space-6); font-size: var(--fs-sm); color: var(--color-text-muted); text-align: center; }

/* MFA enrolment / verification (auth-card surface). */
.mfa-qr { display: flex; justify-content: center; margin: var(--space-4) 0; }
.mfa-recovery-list {
  list-style: none; padding: var(--space-3); margin: var(--space-4) 0;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-bg); columns: 2; column-gap: var(--space-4);
  font-size: var(--fs-sm); line-height: 1.9;
}
.mfa-email-fallback { margin-top: var(--space-3); }

/* ---------- Stat tiles --------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
}
.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}
.stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}
.stat-value { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.stat-value.stat-value-sm { font-size: var(--fs-md); }
.stat-hint  { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: var(--space-2); }

/* ---------- Mobile sidebar ---------------------------------------------- */
.topbar-mobile-toggle { display: none; }
.app-sidebar-overlay  { display: none; }

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "main";
    /* Contain horizontal overflow (e.g. a topbar wider than a phone) so the
       page can't scroll sideways or expand the layout viewport — otherwise the
       fixed full-screen Juno chat gets dragged partly off-screen. */
    overflow-x: clip;
  }
  .app-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    /* Drawer respects the home-indicator inset so the footer never gets
       clipped on a standalone PWA launched on iPhone. */
    padding-bottom: env(safe-area-inset-bottom);
  }
  .app-sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-sm); }
  .app-sidebar-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.32);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
  }
  .app-sidebar-overlay.is-open { opacity: 1; pointer-events: auto; }
  .topbar-mobile-toggle { display: inline-flex; }
  .app-main {
    padding: var(--space-5) var(--space-4);
    padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
  }
  /* Bigger touch targets on mobile — feels native, hits Apple/Google a11y guidance. */
  .icon-button { width: 40px; height: 40px; }
  .nav-link    { padding: 10px 12px; }
}

/* When launched from the home screen we're in display-mode: standalone.
   Hide things that obviously belong in a web context (e.g. "Log in" links
   on landing) and tighten the layout so the app feels native, not like a
   page in a browser. */
@media (display-mode: standalone) {
  /* Reserved hook — keep selectors minimal here for now. */
}

/* ---------- Utilities --------------------------------------------------- */
.text-muted   { color: var(--color-text-muted); }
.text-subtle  { color: var(--color-text-subtle); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error   { color: var(--color-error); }

/* Weekly Report — analysis bullet lists (takeaways, health-at-a-glance). */
.report-list { margin: 0; padding-left: 1.2rem; list-style: disc; }
.report-list li { margin: 0.25rem 0; line-height: 1.5; }
.text-xs  { font-size: var(--fs-xs); }
.text-sm  { font-size: var(--fs-sm); }
.text-md  { font-size: var(--fs-md); }
.text-lg  { font-size: var(--fs-lg); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.font-medium   { font-weight: var(--fw-medium); }
.font-semibold { font-weight: var(--fw-semibold); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.justify-center  { justify-content: center; }
.flex-1          { flex: 1; }
.flex-shrink-0   { flex-shrink: 0; }
.min-w-0         { min-width: 0; }
.flex-wrap       { flex-wrap: wrap; }
/* Compact numeric input (window-size fields on the calculator skills). */
.input-num       { width: 5rem; }
/* Stock-projection: a month cell where the SKU is projected to run out. */
.stockout-cell   { background: var(--color-error-soft, rgba(168, 71, 62, 0.10)); }
.no-underline    { text-decoration: none; }
.truncate        { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-inline        { display: inline; }
.align-middle    { vertical-align: middle; }
.cursor-pointer  { cursor: pointer; }

/* Max-width helpers — closed set; used by auth cards, modals, dialogs. */
.max-w-xs { max-width: 320px; }
.max-w-sm { max-width: 400px; }
.max-w-md { max-width: 520px; }
.max-w-lg { max-width: 580px; }
.max-w-xl { max-width: 640px; }

/* "Eyebrow" label style — small uppercase letter-spaced text used as a
   section header above grouped content (capability categories, scope picker, etc.). */
.label-eyebrow {
  font-size: 11px;
  font-weight: var(--fw-medium);   /* Plex Mono ships 400/500 only */
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

/* Two-column grids used by template editors and member-edit.
   1-2 ratio → "narrow form, wide content"; 1-1 → equal halves. */
.grid-2col-1-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: var(--space-6);
}
.grid-3col-1-1-1 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}
.flex-spacer { flex: 1 1 auto; }
.tr-clickable { cursor: pointer; }
.border-l-success { border-left: 3px solid var(--color-success); }
.border-l-accent  { border-left: 3px solid var(--color-accent); }
.border-l-warning { border-left: 3px solid var(--color-warning); }

/* Drag-and-drop reorder helpers (catalogue template builder, image gallery). */
.drag-handle {
  display: inline-flex;
  align-items: center;
  cursor: grab;
  color: var(--color-text-muted);
}
.drag-handle:active { cursor: grabbing; }
.drag-source { opacity: 0.4; }

/* Image gallery card. Reused by product + A+ galleries. */
.image-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}
.image-card-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
}
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

/* Diff view — added/removed/modified row colors. */
.diff-row-added    { background: var(--color-success-bg); }
.diff-row-removed  { background: var(--color-error-bg); }
.diff-row-modified { background: var(--color-warning-bg); }
.diff-text-before  { text-decoration: line-through; color: var(--color-text-muted); }

/* Auto-save indicator pill (entry editor). */
.autosave-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--fs-xs);
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
}

/* Marketplace preview frames — emulate Amazon's product detail page. */
.preview-desktop, .preview-mobile {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: var(--content-max);
  margin: 0 auto;
}
.preview-mobile { max-width: 420px; }
.preview-title    { font-size: var(--fs-xl); font-weight: var(--fw-semibold); margin-bottom: var(--space-2); }
.preview-bullets  { list-style: disc inside; padding-left: 0; margin: var(--space-3) 0; }
.preview-bullets li { margin-bottom: var(--space-2); }

.grid-2col-1-1 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-6);
}

/* Scrollable bordered box — used by the scope picker for long checklists. */
.scrollbox {
  max-height: 200px;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.scrollbox-sm { max-height: 160px; }

/* Multi-line button variant — used by the workspace-picker buttons in
   tenant select, where the row is taller than the standard btn height. */
.btn-multiline { height: auto; padding: 12px 16px; }

/* Singletons that come up enough to deserve a class */
.m-0  { margin: 0; }
.ml-2 { margin-left: var(--space-2); }
.mr-2 { margin-right: var(--space-2); }
.tracking-tight { letter-spacing: -0.02em; }

/* Marketing-headline size used on landing only. Beyond the standard fs scale
   on purpose — landing is the only place we want a 32px display heading. */
.text-display { font-size: var(--fs-3xl); letter-spacing: -0.02em; }

.gap-xs { gap: var(--space-1); }
.gap-sm { gap: var(--space-2); }
.gap-md { gap: var(--space-3); }
.gap-lg { gap: var(--space-4); }
.gap-xl { gap: var(--space-6); }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.w-full { width: 100%; }
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* ---------------------------------------------------------------------------
   Catalog (products) module — Phase 1
   --------------------------------------------------------------------------- */

/* Hub: clickable count tiles. */
.grid-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  text-decoration: none;
  color: inherit;
  transition: border-color 80ms ease, background 80ms ease;
}
.tile:hover { border-color: var(--color-text); }
.tile-icon  { color: var(--color-text-muted); }
.tile-label { font-size: var(--fs-sm); color: var(--color-text-muted); }
.tile-value { font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -0.02em; }

/* Filter bar above list pages — search box + selects + apply button on one row.
   Compactness rules:
     - Selects + date inputs: fixed width, no grow.
     - Search / text inputs: grow to fill remaining space (still capped
       by the row).
     - Buttons + checkboxes never stretch.
   Form widgets carry `class="input"` so these rules apply even when
   Django's default block-level styling would otherwise force them to
   full width. */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-top: var(--space-3);
}
.filter-bar select,
.filter-bar select.input { flex: 0 0 auto; width: auto; min-width: 140px; max-width: 220px; }
.filter-bar input[type="date"],
.filter-bar input[type="date"].input { flex: 0 0 auto; width: auto; min-width: 130px; max-width: 160px; }
.filter-bar input[type="number"],
.filter-bar input[type="number"].input { flex: 0 0 auto; width: auto; min-width: 90px; max-width: 120px; }
.filter-bar input[type="search"],
.filter-bar input[type="text"],
.filter-bar input[type="search"].input,
.filter-bar input[type="text"].input {
  flex: 1 1 220px; min-width: 0; max-width: 320px;
}
.filter-bar .input { min-width: 0; }
.filter-bar .btn { flex-shrink: 0; }
.filter-bar label { flex: 0 0 auto; white-space: nowrap; }

/* Vertical form scaffolding — used by all catalog forms. */
.form-stack { display: flex; flex-direction: column; gap: var(--space-4); }
.form-row   { display: flex; flex-direction: column; gap: var(--space-1); }
.form-row-narrow { max-width: 280px; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* Pagination row at the bottom of long lists. */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}

.text-danger { color: var(--color-error); }

/* Catalog phase 2 — variation chips, dimension grid, image thumbnails. */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  font-size: var(--fs-xs);
  white-space: nowrap;
}
.chip-sm { font-size: 11px; padding: 1px 6px; }
.chip-x {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.chip-x:hover { color: var(--color-error); }

.grid-4col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-3);
}

.thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  display: block;
}
.thumb-empty { background: var(--color-bg-muted); }
.thumb-lg { width: 80px; height: 80px; }
.cell-thumb { width: 48px; }

/* Recipe builder column widths (BOM table). */
.col-qty    { width: 120px; }
.col-action { width: 60px; }

/* ===========================================================================
   Stock Statement — flat SKU table (Reports + Skills)
   A flat list of SKU rows (no hierarchy grouping) — users narrow it with the
   filters. Sorted best-selling first. The toolbar/summary classes below are
   shared; the table itself is .sku-table (further down) so it doesn't collide
   with the P&L .stock-table.
   =========================================================================== */

/* Slim summary caption above the pivot. */
.pivot-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-5);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
.pivot-summary .pivot-metric { display: inline-flex; align-items: baseline; gap: var(--space-2); }
.pivot-summary strong {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-lg);
  color: var(--color-text);
}

/* Toolbar: segmented altitude control. */
.pivot-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

/* Segmented control — the altitude toggle (Listing / Product / Parts). */
.segmented {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  background: var(--color-bg-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.segmented a,
.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1;
  padding: 6px 12px;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  white-space: nowrap;
}
.segmented a:hover,
.segmented button:hover { color: var(--color-text); text-decoration: none; }
.segmented a.active,
.segmented button.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-xs);
}

/* ---- Shared stock-table primitives (P&L payment-type table + others) ------
   A pinned header + sticky first column + indent levels + collapsible
   hierarchy rows. Kept generic so any hierarchy table can reuse them; the
   Stock Statement uses its OWN .sku-table below and never touches these. */
.stock-table-wrap {
  overflow: auto;
  max-height: 70vh;
}
.stock-table thead th {
  position: sticky; top: 0;
  background: var(--color-bg);
  z-index: 2;
}
.stock-table .sticky-col {
  position: sticky; left: 0;
  background: var(--color-bg);
  z-index: 1;
}
.stock-table thead th.sticky-col { z-index: 3; }
.stock-table .indent-1 { padding-left: var(--space-4); }
.stock-table .indent-2 { padding-left: calc(var(--space-4) * 2); }
.stock-table .indent-3 { padding-left: calc(var(--space-4) * 3); }
.stock-table .lvl-3 td { font-size: var(--fs-xs); }
.stock-table .grand-total td {
  border-top: 2px solid var(--color-border);
  background: var(--color-bg-subtle);
}
.hierarchy-toggle {
  appearance: none; border: 0; background: transparent;
  cursor: pointer; padding: 0 6px 0 0;
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
}
.hierarchy-toggle:hover { color: var(--color-text); }
.trend-up   { color: var(--color-success); margin-left: 4px; font-size: 10px; }
.trend-down { color: var(--color-error);   margin-left: 4px; font-size: 10px; }
.btn.active { background: var(--color-bg-muted); color: var(--color-text); }
.datahub-card-grid-narrow { display: flex; gap: var(--space-2); }

/* ---- Stock Statement — flat SKU table (Reports + Skills) -------------------
   Its own class so it never disturbs the shared .stock-table primitives.
   Frozen header + first column, a pinned grand-total, dimmed zeros, and the
   locations │ FC·Total │ 30d·DRR·DaysCover column groups. */
.sku-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}
.sku-table thead th {
  position: sticky; top: 0;
  z-index: 2;
  background: var(--color-bg-subtle);
  color: var(--color-text-subtle);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-strong);
  white-space: nowrap;
}
.sku-table tbody td {
  padding: 7px var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  color: var(--color-text);
  background: var(--color-surface);
}
.sku-table td.num.pv-zero { color: var(--color-text-subtle); }
.sku-table .sticky-col {
  position: sticky; left: 0;
  z-index: 1;
  min-width: 240px;
}
.sku-table thead th.sticky-col { z-index: 3; }
.sku-table .pv-sep { border-left: 1px solid var(--color-border); }
.sku-table .pv-total {
  border-left: 1px solid var(--color-border);
  font-weight: var(--fw-semibold);
}
.sku-table td.pv-muted { color: var(--color-text-subtle); }   /* NA / — cells */
.sku-table tbody tr:nth-child(even):not(.grand-total) > td { background: var(--color-bg-subtle); }
.sku-table tbody tr:not(.grand-total):hover > td { background: var(--color-brand-soft); }
.sku-table tr.grand-total td {
  position: sticky; bottom: 0;
  z-index: 2;
  background: var(--color-bg-muted);
  border-top: 2px solid var(--color-border-strong);
  font-weight: var(--fw-semibold);
}
.sku-table tr.grand-total td.sticky-col { z-index: 3; }

/* Reports phase 2 — sparklines, line charts, coverage strip. */
.sparkline { color: var(--color-text); display: inline-block; vertical-align: middle; }
.line-chart { width: 100%; height: auto; max-width: 100%; }
.line-chart .chart-grid { stroke: var(--color-border); stroke-dasharray: 2 4; }
.line-chart .chart-axis-text { fill: var(--color-text-muted); font-size: 11px; }
.line-chart .chart-line.series-primary { stroke: var(--color-text); }
.line-chart .chart-line.series-secondary { stroke: var(--color-text-muted); stroke-dasharray: 4 3; }
.line-chart .chart-line.series-accent { stroke: var(--color-success); }
.line-chart .chart-area { opacity: 0.10; }
.line-chart .chart-area.series-primary { fill: var(--color-text); }
.line-chart .chart-area.series-secondary { fill: var(--color-text-muted); }
.line-chart .chart-area.series-accent { fill: var(--color-success); }

.coverage-strip {
  display: flex;
  gap: 1px;
  height: 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.coverage-day {
  flex: 1 1 auto;
  min-width: 2px;
  background: var(--color-success);
}
.coverage-missing { background: var(--color-error); }
.coverage-present { background: var(--color-success); }

.reports-subnav,
.catalog-subnav { gap: var(--space-1); flex-wrap: wrap; }
.reports-subnav-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--color-border);
  margin: 0 var(--space-1);
}

/* P&L builder — toggleable lines, excluded rows, custom-cost name input. */
.builder-line {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}
.is-excluded { opacity: 0.45; }
.is-excluded .font-mono { text-decoration: line-through; }
.pnl-name-input { min-width: 240px; }

/* Sales pivot grid — sticky first column + horizontal scroll. */
.pivot-scroll {
  overflow-x: auto;
  max-width: 100%;
}
.pivot-table { min-width: max-content; }
.pivot-table th.pivot-row-header,
.pivot-table td.pivot-row-header {
  position: sticky;
  left: 0;
  background: var(--color-bg);
  z-index: 1;
  border-right: 1px solid var(--color-border);
  white-space: nowrap;
}
.pivot-table th.pivot-row-total,
.pivot-table td.pivot-row-total {
  border-left: 1px solid var(--color-border);
  font-weight: 600;
}
.pivot-table tfoot th { background: var(--color-bg-muted); }

/* Integration credential status pill (Amazon Settings page). */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
}
.status-badge.status-valid {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-color: var(--color-success);
}
.status-badge.status-invalid {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: var(--color-error);
}
.status-badge.status-pending {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-color: var(--color-warning);
}
.status-badge.status-approved,
.status-badge.status-completed {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-color: var(--color-success);
}
.status-badge.status-rejected {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: var(--color-error);
}
.status-badge.status-cancelled {
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
}
.status-badge.status-in_progress {
  background: var(--color-bg-muted);
  color: var(--color-text);
  border-color: var(--color-border);
}

/* Account Health metric statuses — green/yellow/orange/red severity
   ladder matching Amazon's own Account Health colour cues. Reuses
   the semantic-color variables so dark mode + brand changes
   propagate from the :root block. */
.status-badge.status-good {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-color: var(--color-success);
}
.status-badge.status-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-color: var(--color-warning);
}
.status-badge.status-at_risk {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-color: var(--color-warning);
}
.status-badge.status-critical {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: var(--color-error);
}
.status-badge.status-unknown {
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
/* Snapshot lifecycle statuses on history + detail pages. */
.status-badge.status-pending_review {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-color: var(--color-warning);
}
.status-badge.status-extracted {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-color: var(--color-success);
}
.status-badge.status-failed {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: var(--color-error);
}
.status-badge.status-discarded {
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

/* ---------------------------------------------------------------- */
/* Account Health — Amazon-style 3-section card layout.              */
/* Mirrors the seller-central Account Health page: Customer Service  */
/* / Policy Compliance / Shipping Performance side-by-side, each     */
/* with a status pill in the header, per-channel sub-columns where   */
/* Amazon shows them, and a horizontal AHR gauge with coloured bands.*/
/* ---------------------------------------------------------------- */
.health-sections {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-top: var(--space-3);
}
@media (min-width: 1024px) {
  .health-sections {
    grid-template-columns: 1fr 1fr 1fr;
    align-items: start;
  }
}

.health-section-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.health-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}
.health-section-title {
  font-size: 11px;
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.health-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}
.health-metric:last-child { border-bottom: 0; padding-bottom: 0; }
.health-metric-label {
  font-size: var(--fs-sm);
  color: var(--color-text);
  font-weight: 500;
}
.health-metric-target {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.health-metric-meta {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}
.health-metric-channels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-1);
}
.health-metric-channel {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
}
.health-metric-channel-name {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.health-metric-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.health-metric-value.is-na {
  color: var(--color-text-muted);
  font-weight: 400;
}

.health-submetrics-head {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
  margin-bottom: var(--space-1);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}

/* AHR gauge — horizontal bar with the Amazon score-band colors. */
.ahr-gauge {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: var(--space-2) 0;
}
.ahr-score {
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.ahr-score-na {
  font-size: 18px;
  font-weight: 500;
  text-align: center;
  color: var(--color-text-muted);
}
.ahr-bar {
  position: relative;
  height: 10px;
  border-radius: var(--radius-sm);
  /* 0-100 red, 100-200 amber, 200-1000 green. */
  background: linear-gradient(
    to right,
    var(--color-error)   0%,
    var(--color-error)   10%,
    var(--color-warning) 10%,
    var(--color-warning) 20%,
    var(--color-success) 20%,
    var(--color-success) 100%
  );
  border: 1px solid var(--color-border);
}
.ahr-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  background: var(--color-text);
  border-radius: 1px;
  transform: translateX(-50%);
}
.ahr-scale {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.ahr-scale span {
  position: relative;
  flex: 0 0 auto;
}

/* Account Health — structural classes that replace one-off inline styles.
   The centralized-styling rule forbids style="..."; everything visual
   lives here. */

/* Two-column page grid used by detail.html + intake.html. Mirrors
   `grid-2col-1-1` but with a tighter 16px gap. */
.health-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-3);
}
@media (max-width: 768px) {
  .health-detail-grid { grid-template-columns: 1fr; }
}

/* Screenshot preview image — used in detail.html + intake.html. */
.health-screenshot-img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

/* Subtle row highlight on a metric the user has manually overridden
   on the preview/edit page. */
.health-row-overridden {
  background: var(--color-success-bg);
}

/* Per-metric annotation summary (the "Add note" / "Edit note" toggle).
   Cursor + muted color without inline style. */
.health-note-summary {
  cursor: pointer;
  color: var(--color-text-muted);
}

/* Settings page — frequency + warning + active row, flex-wrap. */
.health-settings-row {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* Notifications list row — the body column flexes to fill. */
.health-notification-body { flex: 1; }
/* Badge to the right of the title in a notification row. */
.health-notification-kind-badge { margin-left: var(--space-1); }

/* AHR gauge — SVG version (no inline styles). Bands + marker + scale
   labels are SVG primitives whose colors come from these CSS rules. */
.ahr-gauge-svg {
  width: 100%;
  height: 30px;
  display: block;
  margin: var(--space-2) 0;
}
.ahr-gauge-svg .ahr-band-red    { fill: var(--color-error); }
.ahr-gauge-svg .ahr-band-amber  { fill: var(--color-warning); }
.ahr-gauge-svg .ahr-band-green  { fill: var(--color-success); }
.ahr-gauge-svg .ahr-marker-line {
  stroke: var(--color-text);
  stroke-width: 3;
  stroke-linecap: round;
  /* Keep stroke pixel-width constant regardless of viewBox scale. */
  vector-effect: non-scaling-stroke;
}

/* AHR scale labels below the SVG — positioned at the band thresholds
   (10% = 100, 20% = 200, 100% = 1000) so they line up with the
   coloured bands above. */
.ahr-scale-row {
  position: relative;
  height: 14px;
  font-size: 10px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.ahr-scale-row span { position: absolute; }
.ahr-scale-row .ahr-tick-0    { left: 0; }
.ahr-scale-row .ahr-tick-100  { left: 10%; transform: translateX(-50%); }
.ahr-scale-row .ahr-tick-200  { left: 20%; transform: translateX(-50%); }
.ahr-scale-row .ahr-tick-1000 { right: 0; }

/* Variant on .health-submetrics-head — drops the top border + spacing
   when it's used as the first child of a section card. */
.health-submetrics-head.is-first {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

/* Generic visibility utility — used by the intake dropzone to swap
   between empty + preview states. */
.is-hidden { display: none !important; }

/* Intake dropzone — paste / drop / click target on the new-intake
   start page. Big neutral border with hover + drag-over states. */
.intake-dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  background: var(--color-bg-subtle);
}
.intake-dropzone:hover {
  border-color: var(--color-text);
}
.intake-dropzone.is-drag-over {
  border-color: var(--color-text);
  background: var(--color-bg-muted);
}
.intake-dropzone-icon {
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}
.intake-dropzone-headline {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-text);
}
.intake-dropzone-sub {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: 4px;
  line-height: 1.4;
}
#intake-preview-img {
  max-width: 100%;
  max-height: 240px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}
.intake-preview-filename {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin: var(--space-1) 0;
}

/* Trend delta chip — small "↑ 0.3pp" / "↓ 12%" badge next to a metric
   value, color-coded green when the change is "good for this KPI"
   (lower-is-better semantics flip the green/red sense) and red when
   it's worse. */
.delta-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
  margin-left: 6px;
}
.delta-chip.is-good {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-color: var(--color-success);
}
.delta-chip.is-bad {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: var(--color-error);
}
.delta-chip.is-flat {
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

/* Sparkline cell next to each metric value. Inherits currentColor. */
.health-metric-trend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  color: var(--color-text-muted);
}
.health-metric-trend .sparkline {
  width: 90px;
  height: 18px;
}

/* Drilldown link under a metric — "See returns →" style. */
.health-metric-drill {
  font-size: var(--fs-xs);
  margin-top: 2px;
}
.health-metric-drill a {
  color: var(--color-text-muted);
  text-decoration: none;
}
.health-metric-drill a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

/* User note (improvement #7) — small italic box under a metric row. */
.health-metric-note {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  font-style: italic;
  margin-top: 4px;
  padding: 4px 8px;
  background: var(--color-bg-subtle);
  border-left: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
}

/* Notifications list page. */
.health-notification-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}
.health-notification-row:last-child { border-bottom: 0; }
.health-notification-row.is-unread {
  background: var(--color-bg-subtle);
  margin-left: -8px;
  padding-left: 8px;
  border-left: 3px solid var(--color-warning);
}
.health-notification-meta {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Snapshot diff table — two columns + delta, mirrors the Amazon
   layout's tabular numeric style. */
.health-diff-table { width: 100%; border-collapse: collapse; }
.health-diff-table th,
.health-diff-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--fs-sm);
}
.health-diff-table th {
  text-align: left;
  font-weight: 600;
  color: var(--color-text-muted);
}
.health-diff-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.health-diff-table td.delta-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.health-diff-section-head td {
  padding-top: var(--space-3);
  font-weight: 600;
  color: var(--color-text);
  font-size: var(--fs-sm);
  border-bottom: 1px solid var(--color-border);
}

/* Policy issues list — Amazon shows each policy item as a flat row
   with the label on the left and a count on the right. */
.health-policy-issues {
  display: flex;
  flex-direction: column;
}
.health-policy-issue {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--fs-sm);
}
.health-policy-issue:last-child { border-bottom: 0; }
.health-policy-issue-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--color-text);
}
.health-policy-issue-count.is-zero {
  color: var(--color-text-muted);
  font-weight: 400;
}
.health-policy-issue-count.is-flagged {
  color: var(--color-error);
}

/* Chat-thread layout (Approvals + Work updates). One stream of
   alternating system rows + message bubbles. Reused across both
   modules; do not duplicate inside a per-module CSS file. */
.thread-stream {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.thread-system {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-1) var(--space-2);
}
.thread-system-approve { color: var(--color-success); }
.thread-system-reject  { color: var(--color-error); }

/* AI polish bar — sits between the chat textarea and the Post
   button. Shared by Approvals + Work Updates; do not duplicate. */
.polish-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.polish-banner {
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.polish-banner-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}
.polish-banner-error {
  background: var(--color-error-bg);
  color: var(--color-error);
}
.thread-message {
  align-self: flex-start;
  max-width: 70%;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.thread-message.thread-message-mine {
  align-self: flex-end;
  background: var(--color-bg-subtle);
}
.thread-message-head {
  font-size: var(--fs-xs);
  margin-bottom: var(--space-1);
}
.thread-message-body { white-space: pre-wrap; }
.thread-message-file { margin-top: var(--space-1); }

/* Data-freshness signal (used on Reports / Orders / Returns pages). */
.freshness-signal {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* AI narrative card — distinguishable from data cards via subtle
   left accent. Stays monochrome to match the design system. */
.ai-narrative-card {
  border-left: 2px solid var(--color-text);
}
.ai-narrative-card .filter-bar { justify-content: space-between; }

/* Compact key/value table — used on the Orders customer-service page
   for the ship-to + metadata cards. Reused across modules that need a
   skinny two-column "label : value" layout inside a card. */
.table-kv th {
  width: 38%;
  font-weight: 500;
  color: var(--color-text-muted);
  background: transparent;
  vertical-align: top;
  white-space: nowrap;
}
.table-kv td { word-break: break-word; }

/* Status pill variants for Orders customer-service cases. Compose
   from existing semantic-color variables (no new colors). */
.status-badge.status-open {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-color: var(--color-warning);
}
.status-badge.status-resolved {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-color: var(--color-success);
}

/* Product group member-search dropdown. */
.member-search-wrap { position: relative; }
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 280px;
  overflow: auto;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.search-dropdown-row {
  display: block;
  width: 100%;
  text-align: left;
  appearance: none;
  border: 0;
  background: transparent;
  padding: var(--space-2) var(--space-3);
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.search-dropdown-row:hover { background: var(--color-bg-muted); }

/* Bulk-action toolbar — appears above list tables when ≥1 row selected. */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  margin-top: var(--space-3);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.bulk-bar .bulk-count {
  font-weight: 600;
  font-size: var(--fs-sm);
}
.bulk-bar .spacer { flex: 1; }
.col-checkbox { width: 28px; }

/* DataHub — category-coded cards on the hub. Six categories, six pill
   accents — kept monochrome-friendly (no rainbow) per the design rules. */
.datahub-category { }
.datahub-category-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.datahub-cat-pill {
  display: inline-block;
  padding: 2px var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.datahub-cat-inventory       { background: var(--color-bg-subtle); }
.datahub-cat-operational     { background: var(--color-bg-muted);  }
.datahub-cat-sp              { background: var(--color-bg-subtle); border-style: dashed; }
.datahub-cat-sb              { background: var(--color-bg-subtle); border-style: dashed; }
.datahub-cat-sd              { background: var(--color-bg-subtle); border-style: dashed; }
.datahub-cat-brand_analytics { background: var(--color-bg-muted);  border-style: dotted; }
.datahub-cat-subscribe_save  { background: var(--color-bg-subtle); }
.datahub-cat-health_reviews  { background: var(--color-bg-muted);  }

.datahub-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-3);
}
.datahub-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  text-decoration: none;
  color: inherit;
  transition: border-color 80ms ease, transform 80ms ease;
}
.datahub-card:hover { border-color: var(--color-text); }
.datahub-card-soon { opacity: 0.7; }
.datahub-card-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
}
.datahub-card-desc {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.datahub-card-stats {
  font-size: var(--fs-xs);
  color: var(--color-text);
  margin-top: var(--space-1);
}

/* ===== DataHub intake — dropzone + Inbox + Health Cockpit ============== */
.dh-file-input { display: none; }
.dh-dropzone {
  position: relative;
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-subtle);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  transition: border-color 80ms ease, background 80ms ease;
}
.dh-dropzone.is-dragover { border-color: var(--color-text); background: var(--color-bg-muted); }
.dh-dropzone.is-busy { opacity: 0.6; pointer-events: none; }
.dh-dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.dh-dropzone-icon { color: var(--color-text-muted); }
.dh-dropzone-title { font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--color-text); }
.dh-dropzone-sub { font-size: var(--fs-sm); color: var(--color-text-muted); }
.dh-link {
  border: none; background: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--color-text); text-decoration: underline;
}

/* Inbox */
.dh-inbox { margin-top: var(--space-4); }
.dh-inbox-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-2);
}
.dh-inbox-list { display: flex; flex-direction: column; gap: var(--space-2); }
.intake-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); background: var(--color-bg);
}
.intake-row-amber { border-color: var(--color-warning); background: var(--color-warning-bg); }
.intake-row-main { flex: 1 1 auto; min-width: 0; }
.intake-row-file {
  display: block; font-size: var(--fs-sm); font-weight: var(--fw-medium);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.intake-row-meta { display: flex; align-items: center; gap: var(--space-2); margin-top: 2px; flex-wrap: wrap; }
.intake-row-bits { font-size: var(--fs-xs); color: var(--color-text-muted); }
.intake-row-reason { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: 2px; }
.intake-row-guess { color: var(--color-text-subtle); }
.intake-row-actions { flex: 0 0 auto; display: flex; align-items: center; gap: var(--space-2); }

/* Status dots (fresh / stale / missing) — reuse semantic tokens */
.dh-status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  flex: 0 0 auto; background: var(--color-text-subtle);
}
.dh-status-fresh   { background: var(--color-success); color: var(--color-success); }
.dh-status-stale   { background: var(--color-warning); color: var(--color-warning); }
.dh-status-missing { background: var(--color-error);   color: var(--color-error); }
span.dh-status { background: none; font-weight: var(--fw-medium); text-transform: capitalize; }

/* Cockpit */
.dh-blocked { display: flex; gap: var(--space-2); align-items: flex-start; }
.dh-blocked-list { margin: var(--space-1) 0 0; padding-left: var(--space-4); font-size: var(--fs-sm); }
.dh-tile-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3); margin-top: var(--space-2);
}
.dh-tile {
  border: 1px solid var(--color-border); border-left-width: 3px;
  border-radius: var(--radius-md); background: var(--color-bg);
  padding: var(--space-3);
}
.dh-tile-fresh   { border-left-color: var(--color-success); }
.dh-tile-stale   { border-left-color: var(--color-warning); }
.dh-tile-missing { border-left-color: var(--color-error); }
.dh-tile-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.dh-tile-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.dh-tile-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dh-tile-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  font: inherit;
  font-size: var(--fs-xs);
  text-align: left;
  border: none;
  background: transparent;
  color: inherit;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.dh-tile-item:hover { background: var(--color-bg-muted); }
.dh-tile-item-label {
  flex: 1 1 auto; min-width: 0; color: var(--color-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dh-tile-item-age { color: var(--color-text-subtle); }

/* Manual per-report upload form (report detail page + cockpit modal). */
.upload-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-6) var(--space-4);
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-bg-subtle);
  text-align: center;
  cursor: pointer;
}
.upload-dropzone.is-dragover { border-color: var(--color-brand); background: var(--color-bg-muted); }
.upload-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.upload-dropzone-icon { color: var(--color-text-muted); }
.upload-dropzone-text { font-size: var(--fs-sm); color: var(--color-text); }
.upload-dropzone-hint { font-size: var(--fs-xs); color: var(--color-text-subtle); }

/* ===== Public legal pages (privacy / terms / refund / cookies) ========= */
.legal-wrap { display: flex; flex-direction: column; min-height: 100vh; background: var(--color-bg); }
.legal-container { width: 100%; max-width: 820px; margin: 0 auto; padding: 0 var(--space-5); }
.legal-topbar { border-bottom: 1px solid var(--color-border); }
.legal-topbar .legal-container { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.legal-brand { font-weight: var(--fw-semibold); font-size: var(--fs-lg); color: var(--color-text); text-decoration: none; letter-spacing: -0.02em; }
.legal-back { font-size: var(--fs-sm); color: var(--color-text-muted); text-decoration: none; }
.legal-back:hover { color: var(--color-text); }
.legal-main { flex: 1 1 auto; padding-top: var(--space-10); padding-bottom: var(--space-12); }
.legal-h1 { font-size: var(--fs-3xl); font-weight: var(--fw-normal); letter-spacing: -0.01em; margin: 0 0 var(--space-2); }
.legal-meta { font-size: var(--fs-sm); color: var(--color-text-muted); margin: 0 0 var(--space-8); }
.legal-page { font-size: var(--fs-md); line-height: 1.7; color: var(--color-text); }
.legal-page h2 { font-size: var(--fs-xl); margin: var(--space-8) 0 var(--space-3); }
.legal-page h3 { font-size: var(--fs-lg); margin: var(--space-5) 0 var(--space-2); }
.legal-page p { margin: 0 0 var(--space-3); }
.legal-page ul, .legal-page ol { margin: 0 0 var(--space-3); padding-left: var(--space-5); }
.legal-page li { margin-bottom: var(--space-1); }
.legal-page a { color: var(--color-brand); text-decoration: underline; }
.legal-page strong { font-weight: var(--fw-semibold); }
.legal-page table { width: 100%; border-collapse: collapse; margin: 0 0 var(--space-4); font-size: var(--fs-sm); }
.legal-page th, .legal-page td { border: 1px solid var(--color-border); padding: var(--space-2) var(--space-3); text-align: left; vertical-align: top; }
.legal-page th { background: var(--color-bg-subtle); font-weight: var(--fw-semibold); }
.legal-footer { border-top: 1px solid var(--color-border); padding: var(--space-6) 0; }
.legal-footer-links { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-bottom: var(--space-3); }
.legal-footer-links a { font-size: var(--fs-sm); color: var(--color-text-muted); text-decoration: none; }
.legal-footer-links a:hover { color: var(--color-text); }
.legal-fineprint { font-size: var(--fs-xs); color: var(--color-text-subtle); margin: 0; }
.public-chat-legal { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); margin-top: var(--space-2); }
.public-chat-legal a { font-size: var(--fs-xs); color: var(--color-text-subtle); text-decoration: none; }
.public-chat-legal a:hover { color: var(--color-text); text-decoration: underline; }

.input-sm { padding: 4px 8px; font-size: var(--fs-xs); }

/* ---------- Calendar grid (Promotions, future scheduling pages) -------- */
/* Generic 7-column month view: weekday header + 6 weeks of day cells.
   Uses existing tokens — no calendar-specific colors. */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.cal-weekday {
  background: var(--color-bg-subtle);
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}
.cal-day {
  background: var(--color-bg);
  min-height: 96px;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-day-out  { background: var(--color-bg-subtle); }
.cal-day-today .cal-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 999px;
  background: var(--color-accent);
  color: var(--color-accent-text);
}
.cal-day-num {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--color-text-muted);
}
.cal-day-out .cal-day-num { color: var(--color-text-subtle); }
.cal-bar {
  display: block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-muted);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}
.cal-bar:hover { text-decoration: none; border: 0; }

/* ---------------------------------------------------------------- *
 * Tasks module — chat thread, briefing, bell badge, kanban board.
 * Uses existing tokens; no module-specific colors.
 * ---------------------------------------------------------------- */

/* Conversation thread on the task detail page. */
.chat-thread { display: flex; flex-direction: column; gap: var(--space-3); }
.chat-row { display: flex; flex-direction: column; gap: 2px; }
.chat-bubble {
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  white-space: pre-wrap;
}
.chat-row-ai_message .chat-bubble {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

/* Daily AI briefing — bullets read like a calm executive update. */
.briefing-bullets {
  margin: 0;
  padding-left: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.briefing-bullets li { line-height: 1.4; }

/* Bell-icon unread badge. Sits on top of the bell glyph. */
.badge-count {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: 10px;
  font-weight: var(--fw-medium);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Topbar uses .icon-button — make it positional so the badge anchors. */
.app-topbar .icon-button { position: relative; }

/* Inline form helper — used inside table cells / filter-bars where
 * a default block-level <form> would push siblings to the next row.
 * Replaces inline style="display:inline" so the no-inline-style hook
 * stays clean.
 */
.form-inline { display: inline; }

/* Narrow icon-only table column — 24px wide. */
.col-icon { width: 24px; }

/* filter-bar variant: stretch children apart. The base .filter-bar is
 * left-aligned with gap; this modifier lets a header sit on the left
 * and an action button on the right. */
.filter-bar-between { justify-content: space-between; }

/* Kanban board — 5-column horizontal scroller for narrow screens. */
.kanban-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
  overflow-x: auto;
}
.kanban-column { min-height: 200px; }
.kanban-column h3 {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-2) 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kanban-card {
  display: block;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  text-decoration: none;
  color: var(--color-text);
}
.kanban-card:hover { border-color: var(--color-border-strong); }
.kanban-card-title { font-weight: var(--fw-medium); }
.kanban-card-meta {
  display: flex;
  gap: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* AI Memory module — topic tile grid + entry detail layout.
   Composes existing tokens; no new colors, no new radii. */
.ai-memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-3);
}
.ai-memory-tile {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 0.12s ease;
}
.ai-memory-tile:hover { border-color: var(--color-border-strong); }
.ai-memory-tile-icon {
  flex-shrink: 0;
  color: var(--color-text-muted);
}
.ai-memory-tile-body { flex: 1; min-width: 0; }
.ai-memory-tile-title {
  font-weight: var(--fw-medium);
  margin-bottom: 2px;
}
.ai-memory-tile-desc {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}
.ai-memory-tile-count {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.ai-memory-body {
  white-space: pre-wrap;
  font-size: var(--fs-sm);
  line-height: 1.55;
  margin: 0;
}
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
  margin: 0;
}
.meta-grid dt { margin-bottom: 2px; }
.meta-grid dd { margin: 0; font-size: var(--fs-sm); }

/* Seller Support — Claude-style chat layout.
   Two-pane on desktop (chat + context aside); single column on mobile.
   All tokens composed from existing variables. */
.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: var(--space-4);
  align-items: start;
}
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; }
}
.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 60vh;
  min-width: 0;
}
.chat-aside { min-width: 0; }

.chat-shell {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 760px;
}

.chat-stream {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  min-height: 50vh;
  max-height: 70vh;
  overflow-y: auto;
}
.chat-stream-empty { min-height: 0; }

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 85%;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}
.chat-msg-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-xs);
}
.chat-msg-head strong { font-weight: var(--fw-medium); }
.chat-msg-text {
  margin: 0;
  white-space: pre-wrap;
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.chat-msg-body { min-width: 0; }
.chat-msg-file { font-size: var(--fs-xs); display: flex; align-items: center; gap: 4px; }

/* User messages — right-aligned, accented border. */
.chat-msg-user {
  align-self: flex-end;
  background: var(--color-bg-muted, var(--color-bg));
  border-color: var(--color-border-strong, var(--color-border));
}

/* AI messages — left-aligned. */
.chat-msg-ai { align-self: flex-start; }

/* The actual support draft — emphasised with a subtle accent. */
.chat-msg-draft {
  border-color: var(--color-text);
  background: var(--color-surface);
}
.chat-msg-placeholder-warn {
  margin-top: var(--space-2);
  padding: 4px 8px;
  font-size: var(--fs-xs);
  color: var(--color-text);
  background: var(--color-warning-bg, rgba(203, 145, 47, 0.12));
  border: 1px solid var(--color-warning, #CB912F);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* AI brief — collapsible, plain. */
.chat-msg-thinking {
  align-self: flex-start;
  border: 1px dashed var(--color-border);
  background: transparent;
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-xs);
  max-width: 85%;
}
.chat-msg-thinking summary { cursor: pointer; color: var(--color-text-muted); }
.chat-msg-thinking pre { margin-top: var(--space-2); }

/* System events + notes — quiet, full-width, no border. */
.chat-msg-system {
  align-self: stretch;
  background: transparent;
  border: none;
  padding: 0;
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
}
.chat-msg-note {
  align-self: stretch;
  background: var(--color-bg-muted, var(--color-bg));
  border-style: dashed;
}

/* Composer — sticky-feeling textarea pinned under the stream. */
.chat-composer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
.chat-composer textarea,
.chat-composer .chat-composer-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  resize: vertical;
  font-size: var(--fs-sm);
}
.chat-composer textarea:focus { outline: 2px solid var(--color-text); outline-offset: 0; }
.chat-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.chat-copy-btn { margin-left: auto; }

/* Seller Support — status panel "promote to playbook" toggle. */
.resolve-promote-label { margin-right: 4px; }

/* Public front-door chat (/chat/, and ecomex.app/) — a native-app-style
   full-height chat with a Claude-like centered welcome. No app chrome.
   Reuses .chat-msg* bubbles; everything else composed from existing tokens. */
.public-chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;            /* mobile: tracks the visible viewport */
  background: var(--color-bg);
}
.public-chat-bar {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  padding-top: calc(var(--space-3) + env(safe-area-inset-top));
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}
.public-chat-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--fw-medium);
  color: var(--color-text);
  text-decoration: none;
}
.public-chat-actions { display: flex; align-items: center; gap: var(--space-2); }

/* Scrollable message area — fills all space between the bar and the dock. */
.public-chat-main {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

/* Claude-style centered welcome — shown until the first message. */
.public-chat-welcome {
  margin: auto;
  max-width: 600px;
  padding: var(--space-8) var(--space-5);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
.public-chat-welcome-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--color-bg-muted);
  color: var(--color-text);
}
.public-chat-welcome-title {
  margin: 0;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-medium);
  line-height: 1.25;
  color: var(--color-text);
}
.public-chat-welcome-sub {
  margin: 0;
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--color-text-muted);
}
.public-chat-welcome-link { font-size: var(--fs-sm); }

/* Message stream — centered column of .chat-msg bubbles. */
.public-chat-stream {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
}
.public-chat-stream .chat-msg { max-width: 100%; }

/* Bottom dock — composer pinned above the home indicator. */
.public-chat-dock {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
}
.public-chat-counter {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  text-align: center;
  margin: 0 0 var(--space-2);
}
.public-chat-composer {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  max-width: 720px;
  margin: 0 auto;
}
.public-chat-input {
  flex: 1 1 auto;
  resize: none;
  max-height: 160px;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--fs-md);
  line-height: 1.5;
  background: var(--color-surface);
  color: var(--color-text);
}
.public-chat-input:focus { outline: 2px solid var(--color-text); outline-offset: 0; }
.public-chat-send {
  flex: 0 0 auto;
  height: 40px;
  width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.public-chat-foot {
  max-width: 720px;
  margin: var(--space-2) auto 0;
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  text-align: center;
}
@media (max-width: 600px) {
  .public-chat-welcome-title { font-size: var(--fs-xl); }
}

/* Assistant — Claude-style chat inside the app shell. The shell fills
   the viewport below the topbar: a slim conversation rail on the left,
   and a chat column that shows a centered welcome + composer until the
   first message (`.assistant-empty`), then a scrolling thread with the
   composer docked at the bottom. Bubble overrides are scoped under
   .assistant-stream so the generic .chat-msg* classes used by other
   modules are untouched. */
.assistant-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - (2 * var(--content-pad-y)));
  height: calc(100dvh - var(--topbar-h) - (2 * var(--content-pad-y)));
  min-height: 420px;
}

/* Recent-chats list. Lives in the global sidebar now (the rail was
   merged in); the .assistant-convo-* classes are shared so the
   live-prepend JS and styling carry across. */
.assistant-convo-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.assistant-convo-row {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: background 0.08s ease-in-out;
}
.assistant-convo-row:hover,
.assistant-convo-row.active { background: var(--color-bg-muted, var(--color-bg)); }
.assistant-convo-row.active { box-shadow: inset 2px 0 0 var(--color-text); }
.assistant-convo-link {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px var(--space-2);
  color: inherit;
  text-decoration: none;
}
.assistant-convo-link:hover { text-decoration: none; }
.assistant-convo-title {
  display: block;
  font-size: var(--fs-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.assistant-convo-delete {
  flex: 0 0 auto;
  margin-right: 2px;
  opacity: 0;
  transition: opacity 0.08s ease-in-out;
}
.assistant-convo-row:hover .assistant-convo-delete,
.assistant-convo-delete:focus-within { opacity: 1; }
.assistant-convo-delete .icon-button { width: 24px; height: 24px; }
.assistant-rail-empty { padding: var(--space-2) var(--space-2); }

/* Chat column — fills the single-column shell. */
.assistant-chat {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}
.assistant-chat-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
}
.assistant-chat-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.assistant-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

/* Centered welcome — shown until the first message. */
.assistant-welcome {
  margin: auto;
  max-width: 560px;
  padding: var(--space-6) var(--space-4);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
.assistant-welcome-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  background: var(--color-bg-muted);
  color: var(--color-brand);
}
.assistant-welcome-title {
  margin: 0;
  font-size: 30px;
  font-weight: var(--fw-normal);
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
.assistant-welcome-sub {
  margin: 0;
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--color-text-muted);
}

/* New-chat state: pull the welcome + composer together into the middle
   of the column, Claude-style. JS drops .assistant-empty on first send
   and the dock falls back to the bottom. */
.assistant-empty .assistant-scroll { flex: 0 0 auto; margin-top: auto; }
.assistant-empty .assistant-dock { margin-bottom: auto; }

/* Message thread — a centered reading column. AI turns are plain text
   on the background (no bubble); user turns get a soft right-aligned
   bubble. */
.assistant-stream {
  width: 100%;
  max-width: var(--chat-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-3);
}
.assistant-stream .chat-msg {
  max-width: 100%;
  border: none;
  background: transparent;
  padding: 0;
}
.assistant-stream .chat-msg-user {
  align-self: flex-end;
  max-width: 75%;
  padding: var(--space-3) var(--space-4);
  border: none;
  border-radius: var(--radius-lg);
  background: var(--color-bg-muted);
}
.assistant-stream .chat-msg-ai { align-self: stretch; }
.assistant-stream .chat-msg-text {
  font-size: var(--fs-lg);
  line-height: 1.65;
  /* Long tokens (URLs, ASIN/SKU strings from data answers) must wrap, or
     they push the column past a narrow phone's width. pre-wrap alone keeps
     long unbroken runs on one line. */
  overflow-wrap: anywhere;
  word-break: break-word;
}
.assistant-msg-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: 4px;
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  opacity: 0;
  transition: opacity 0.12s ease-in-out;
}
.assistant-stream .chat-msg-ai:hover .assistant-msg-meta,
.assistant-msg-meta:focus-within { opacity: 1; }

/* Feedback (thumbs) → Juno Trainer. The chosen thumb keeps the brand accent
   so the seller can see their rating stuck even after the meta row fades. */
.chat-fb-btn { padding-left: 6px; padding-right: 6px; }
.chat-fb-btn.is-active { color: var(--color-brand); opacity: 1; }
.assistant-msg-meta:has(.chat-fb-btn.is-active) { opacity: 1; }

/* Composer dock. */
.assistant-dock { flex: 0 0 auto; padding-top: var(--space-3); }
/* Flat 3-child grid (textarea · attach · actions). Desktop = two rows
   (textarea spans the top; attach bottom-left, actions bottom-right). Mobile
   reflows the SAME markup into a single-row pill (see the ≤768px block). */
.assistant-composer {
  max-width: var(--chat-max);
  margin: 0 auto;
  display: grid;
  /* minmax(0,1fr) lets the middle (textarea) track shrink below its
     intrinsic width; without it the composer forces the whole chat column
     wider than a phone and the thread gets clipped at the right edge. */
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "input  input  input"
    "attach .      actions";
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}
.assistant-composer:focus-within { border-color: var(--color-brand); }
.assistant-input {
  grid-area: input;
  width: 100%;
  min-width: 0;          /* allow the grid track to shrink on narrow phones */
  border: none;
  background: transparent;
  resize: none;
  padding: 0;
  max-height: 200px;
  font-size: var(--fs-lg);
  line-height: 1.5;
  color: var(--color-text);
}
.assistant-input:focus { outline: none; border: none; box-shadow: none; }
/* Composer controls: attach (left) + skill-level picker & send (right). */
.composer-attach {
  grid-area: attach;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.08s ease, color 0.08s ease;
}
.composer-attach:hover { background: var(--color-bg-muted); color: var(--color-text); }
.composer-actions { grid-area: actions; justify-self: end; display: flex; align-items: center; gap: var(--space-2); }

/* Skill-level picker — custom dropdown so each option shows the name (bigger)
   over its capability (small). Opens upward (composer sits at the bottom). */
.model-picker { position: relative; }
.model-picker-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}
.model-picker-trigger::-webkit-details-marker { display: none; }
.model-picker-trigger:hover { background: var(--color-bg-muted); color: var(--color-text); }
.model-picker-current { font-weight: var(--fw-medium); }
.model-picker-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  padding: var(--space-1);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 40;
}
.model-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.model-option:hover,
.model-option.is-selected { background: var(--color-bg-muted); }
.model-option-name { font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--color-text); }
.model-option.is-selected .model-option-name { color: var(--color-brand); }
.model-option-desc { font-size: var(--fs-xs); color: var(--color-text-muted); }
.assistant-send {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: var(--color-brand);
  color: var(--color-brand-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.assistant-send:hover { background: var(--color-brand-hover); }

/* Suggestion chips under the composer on the welcome screen. */
.assistant-suggest {
  max-width: var(--chat-max);
  margin: var(--space-3) auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}
.assistant-chip {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.08s ease-in-out;
}
.assistant-chip:hover { background: var(--color-bg-muted, var(--color-bg)); color: var(--color-text); }
.assistant-foot {
  max-width: var(--chat-max);
  margin: var(--space-2) auto 0;
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  text-align: center;
}

@media (max-width: 900px) {
  .assistant-stream .chat-msg-user { max-width: 90%; }
  .assistant-welcome-title { font-size: var(--fs-xl); }
}

/* ============================================================================
   Juno — NATIVE MOBILE CHAT APP (≤768px)
   ----------------------------------------------------------------------------
   Below the drawer breakpoint the Assistant becomes a full-screen, Claude-app
   style chat: a fixed surface owning the whole viewport (covering the global
   topbar), a native top bar (menu · title · new chat), a scrolling thread, and
   a SINGLE-ROW PILL composer docked just above the on-screen keyboard.
   DESKTOP IS UNTOUCHED — every layout rule lives inside the max-width:768px
   query. The keyboard is handled in assistant_chat.js via the VisualViewport
   API (feeds --assistant-vh / --assistant-top) so the composer rides above the
   keyboard on both iOS and Android.
   ========================================================================== */

/* Default (desktop): the native-only top-bar buttons don't render. */
.assistant-bar-menu,
.assistant-bar-new { display: none; }

@media (max-width: 768px) {
  /* Own the viewport, escaping the app-main padding + global topbar. */
  .assistant-shell {
    position: fixed;
    inset: 0 0 auto 0;
    height: 100dvh;                         /* fallback before JS sets the var */
    height: var(--assistant-vh, 100dvh);    /* visual-viewport height (keyboard-aware) */
    transform: translateY(var(--assistant-top, 0px));
    min-height: 0;
    z-index: 60;                            /* over topbar (10), under the drawer (100) */
    background: var(--color-bg);
  }
  .assistant-chat { min-height: 0; }

  /* Phones keep the composer pinned at the bottom even on a new chat (the
     desktop centres welcome + composer; the mobile app does not). */
  .assistant-empty .assistant-scroll { flex: 1 1 auto; margin-top: 0; }
  .assistant-empty .assistant-dock { margin-bottom: 0; }

  /* --- Native top bar: menu · title · new chat -------------------------- */
  .assistant-chat-bar {
    flex: 0 0 auto;
    justify-content: space-between;
    gap: var(--space-1);
    height: calc(52px + env(safe-area-inset-top));
    padding: 0 4px;
    padding-top: env(safe-area-inset-top);
    padding-left: max(4px, env(safe-area-inset-left));
    padding-right: max(4px, env(safe-area-inset-right));
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
  }
  .assistant-bar-menu,
  .assistant-bar-new { display: inline-flex; flex: 0 0 auto; width: 40px; height: 40px; }
  .assistant-chat-title {
    flex: 1 1 auto;
    text-align: center;
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
  }
  /* Credits live in the drawer/account on mobile — keep the bar clean. */
  .assistant-bar-credit { display: none; }

  /* --- Scroll area + thread -------------------------------------------- */
  .assistant-scroll { overscroll-behavior: contain; overflow-x: hidden; }
  .assistant-stream {
    gap: var(--space-4);
    padding: var(--space-4);
    padding-bottom: var(--space-3);
    padding-left: max(var(--space-4), env(safe-area-inset-left));
    padding-right: max(var(--space-4), env(safe-area-inset-right));
  }
  .assistant-stream .chat-msg-user {
    max-width: 85%;
    padding: 9px 14px;
    border-radius: 20px;
    border-bottom-right-radius: 6px;        /* iMessage-style tail */
  }
  .assistant-stream .chat-msg-text { font-size: var(--fs-lg); }

  /* --- Welcome (new chat) ---------------------------------------------- */
  /* Honour the `hidden` attribute on a phone (author display:flex otherwise
     overrides the UA rule) so a short thread never shows a stray greeting.
     Mobile-only — desktop behaviour is left exactly as it was. */
  .assistant-welcome[hidden] { display: none; }
  .assistant-welcome { padding: var(--space-5); gap: var(--space-2); }
  .assistant-welcome-icon { width: 48px; height: 48px; }
  .assistant-welcome-title { font-size: var(--fs-xl); }
  .assistant-welcome-sub { font-size: var(--fs-sm); }

  /* --- Composer: single-row pill, docked above the keyboard ------------- */
  .assistant-dock {
    padding: var(--space-2) var(--space-3);
    padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
    padding-left: max(var(--space-3), env(safe-area-inset-left));
    padding-right: max(var(--space-3), env(safe-area-inset-right));
    background: var(--color-bg);
  }
  /* Reflow the SAME 3-child grid into one row: [+] [textarea] [picker·send] */
  .assistant-composer {
    grid-template-areas: "attach input actions";
    align-items: end;
    gap: 6px;
    padding: 6px;
    border-radius: 24px;
    box-shadow: var(--shadow-sm);
  }
  /* 16px input keeps iOS from zooming the page on focus. */
  .assistant-input { font-size: var(--fs-lg); max-height: 120px; padding: 7px 4px; }
  .composer-attach { width: 36px; height: 36px; }
  .assistant-send { width: 36px; height: 36px; }
  .composer-actions { gap: 4px; }
  .model-picker-trigger { padding: 6px 8px; font-size: var(--fs-xs); }
  .model-picker-menu { min-width: min(260px, 80vw); }

  /* Suggestion chips: horizontal pill row, like an iOS app. */
  .assistant-suggest {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-top: var(--space-2);
  }
  .assistant-suggest::-webkit-scrollbar { display: none; }
  .assistant-chip { flex: 0 0 auto; padding: 8px 14px; font-size: var(--fs-sm); }

  /* The disclaimer crowds a phone — the drawer footer covers trust copy. */
  .assistant-foot { display: none; }

  /* Press feedback for a native tap feel. */
  .assistant-chip:active,
  .assistant-send:active,
  .composer-attach:active,
  .assistant-bar-menu:active,
  .assistant-bar-new:active { transform: scale(0.94); }
}

/* Tasks 2.0 — My Day homepage. */
.my-day-section { margin-top: var(--space-4); }
.my-day-section-title {
  font-size: 11px;
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}
.my-day-briefing {
  margin: 0;
  padding-left: var(--space-4);
  font-size: var(--fs-sm);
  color: var(--color-text);
}
.my-day-briefing li { margin-bottom: 4px; }
.my-day-rows {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.my-day-row {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  color: inherit;
  text-decoration: none;
  transition: background 0.08s ease-in-out;
}
.my-day-row:hover {
  background: var(--color-bg-muted, var(--color-bg));
  text-decoration: none;
}
.my-day-row-priority {
  width: 4px;
  height: 100%;
  min-height: 28px;
  border-radius: 2px;
  background: var(--color-border);
}
.my-day-row-urgent .my-day-row-priority { background: var(--color-error, #EB5757); }
.my-day-row-high   .my-day-row-priority { background: var(--color-warning, #CB912F); }
.my-day-row-medium .my-day-row-priority { background: var(--color-text-muted); }
.my-day-row-low    .my-day-row-priority { background: var(--color-border-strong, var(--color-border)); }
.my-day-row-main { min-width: 0; }
.my-day-row-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.my-day-row-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: 2px;
  flex-wrap: wrap;
}
.my-day-row-due { white-space: nowrap; }
.my-day-row-overdue .my-day-row-title { color: var(--color-error, #EB5757); }
.my-day-row-done {
  opacity: 0.6;
}
.my-day-row-done .my-day-row-title {
  text-decoration: line-through;
}
.my-day-row-check {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-success, #0F7B6C);
}
.my-day-upcoming-day { margin-bottom: var(--space-3); }
.my-day-upcoming-date {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  margin-bottom: var(--space-1);
  color: var(--color-text);
}

/* Tasks 2.0 — Linear-style label chips. */
.task-label {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.5;
  background: var(--color-bg-muted, #f5f5f4);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  white-space: nowrap;
}
.task-label-gray   { background: #f4f4f5; color: #52525b; border-color: #e4e4e7; }
.task-label-red    { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.task-label-orange { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.task-label-yellow { background: #fefce8; color: #854d0e; border-color: #fde68a; }
.task-label-green  { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.task-label-teal   { background: #f0fdfa; color: #0f766e; border-color: #99f6e4; }
.task-label-blue   { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.task-label-indigo { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.task-label-purple { background: #faf5ff; color: #7c3aed; border-color: #ddd6fe; }
.task-label-pink   { background: #fdf2f8; color: #be185d; border-color: #fbcfe8; }
[data-theme="dark"] .task-label-gray   { background: #27272a; color: #d4d4d8; border-color: #3f3f46; }
[data-theme="dark"] .task-label-red    { background: #450a0a; color: #fecaca; border-color: #7f1d1d; }
[data-theme="dark"] .task-label-orange { background: #431407; color: #fed7aa; border-color: #7c2d12; }
[data-theme="dark"] .task-label-yellow { background: #422006; color: #fde68a; border-color: #713f12; }
[data-theme="dark"] .task-label-green  { background: #052e16; color: #bbf7d0; border-color: #14532d; }
[data-theme="dark"] .task-label-teal   { background: #042f2e; color: #99f6e4; border-color: #134e4a; }
[data-theme="dark"] .task-label-blue   { background: #172554; color: #bfdbfe; border-color: #1e3a8a; }
[data-theme="dark"] .task-label-indigo { background: #1e1b4b; color: #c7d2fe; border-color: #312e81; }
[data-theme="dark"] .task-label-purple { background: #2e1065; color: #ddd6fe; border-color: #4c1d95; }
[data-theme="dark"] .task-label-pink   { background: #500724; color: #fbcfe8; border-color: #831843; }

/* Tasks 2.0 — priority badge chips for the intake summary + board. */
.task-priority-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  border: 1px solid var(--color-border);
}
.task-priority-urgent {
  background: #fef2f2; color: #b91c1c; border-color: #fecaca;
}
.task-priority-high {
  background: #fff7ed; color: #c2410c; border-color: #fed7aa;
}
.task-priority-medium {
  background: var(--color-bg-muted, #f5f5f4); color: var(--color-text-muted);
}
.task-priority-low {
  background: transparent; color: var(--color-text-muted);
}
[data-theme="dark"] .task-priority-urgent {
  background: #450a0a; color: #fecaca; border-color: #7f1d1d;
}
[data-theme="dark"] .task-priority-high {
  background: #431407; color: #fed7aa; border-color: #7c2d12;
}

/* Tasks 2.0 — label admin color picker. */
.label-color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.label-color-swatch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
}
.label-color-swatch input { display: none; }
.label-color-swatch input:checked + .task-label {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* Tasks 2.0 — drag-and-drop kanban board hooks. */
.kanban-card.kanban-card-dragging {
  opacity: 0.4;
  cursor: grabbing;
}
.kanban-column.kanban-column-dropzone {
  background: var(--color-bg-muted, #f5f5f4);
  outline: 2px dashed var(--color-text-muted);
  outline-offset: -2px;
}
.kanban-card { cursor: grab; }
.kanban-card:active { cursor: grabbing; }
.kanban-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}
.kanban-card-link:hover { text-decoration: none; }
.kanban-card-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.kanban-column-body {
  min-height: 60px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.kanban-column-empty { padding: var(--space-2); }

/* DoD confirmation dialog for drag-to-in-review. */
.dod-dialog {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  max-width: 480px;
  width: 92%;
  background: var(--color-surface);
  color: var(--color-text);
}
.dod-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}
.dod-dialog-text {
  white-space: pre-wrap;
  background: var(--color-bg-muted, var(--color-bg));
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-3);
}

/* Client-side home dashboard ( / ) — comprehensive snapshot. */

/* Dashboard 3.0 — hero metrics (Today / MTD) with an inline real
   trend chart, replacing the old equal-weight card wall's top row. */
.dash-hero-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-3);
}
.dash-hero {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.dash-hero-danger  { border-color: var(--color-error); background: var(--color-error-bg); }
.dash-hero-warning { border-color: var(--color-warning); background: var(--color-warning-bg); }
.dash-hero-label {
  font-size: 10.5px;
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}
.dash-hero-value {
  font-size: 2.25rem;
  line-height: 1.15;
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}
.dash-hero-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}
.dash-hero-chart { margin-top: var(--space-2); }

/* Inventory Dashboard — stock-age funnel (stacked bar, segment widths
   set via JS flex-grow from data-count so no inline `style=` is
   needed in the template) + ABC-tier stat chips. */
.stock-funnel-bar {
  display: flex;
  height: 28px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg-muted, var(--color-bg));
}
.stock-funnel-seg { min-width: 3px; transition: flex-grow 0.3s ease-out; }
.stock-funnel-oos      { background: var(--color-error); }
.stock-funnel-critical { background: var(--color-warning); }
.stock-funnel-warning  { background: var(--color-warning); opacity: .55; }
.stock-funnel-healthy  { background: var(--color-success); }
.stock-funnel-excess   { background: var(--color-text-subtle, var(--color-text-muted)); }
.stock-funnel-legend {
  display: flex; flex-wrap: wrap; gap: var(--space-4);
  margin-top: var(--space-2); font-size: var(--fs-xs); color: var(--color-text-muted);
}
.stock-funnel-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.stock-funnel-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.stock-funnel-dot.stock-funnel-oos      { background: var(--color-error); }
.stock-funnel-dot.stock-funnel-critical { background: var(--color-warning); }
.stock-funnel-dot.stock-funnel-warning  { background: var(--color-warning); opacity: .55; }
.stock-funnel-dot.stock-funnel-healthy  { background: var(--color-success); }
.stock-funnel-dot.stock-funnel-excess   { background: var(--color-text-subtle, var(--color-text-muted)); }

.abc-tier-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-2); }
.abc-tier-chip {
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: var(--space-2); background: var(--color-bg-muted, var(--color-bg));
  text-align: center;
}
.abc-tier-letter { font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: .05em; color: var(--color-text-muted); }
.abc-tier-count { font-size: 1.25rem; font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }

/* Critical Dashboard — ranked exception rows. */
.issue-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.issue-row:last-child { border-bottom: none; }
.issue-icon { flex-shrink: 0; margin-top: 2px; }
.issue-row.is-critical .issue-icon { color: var(--color-error); }
.issue-row.is-warning .issue-icon { color: var(--color-warning); }
.issue-row.is-watch .issue-icon { color: var(--color-text-muted); }
.issue-body { flex: 1 1 auto; min-width: 0; }
.issue-text { font-size: var(--fs-sm); }
.issue-impact { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: 2px; }
.issue-link { flex-shrink: 0; font-size: var(--fs-xs); white-space: nowrap; }
.issue-section-count {
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
  padding: 2px 9px; border-radius: 999px;
}
.issue-section-count.is-critical { background: var(--color-error-bg); color: var(--color-error); }
.issue-section-count.is-warning  { background: var(--color-warning-bg); color: var(--color-warning); }
.issue-section-count.is-watch    { background: var(--color-bg-muted); color: var(--color-text-muted); }

/* Section headers between dashboard groups — quieter than a card. */
.dash-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: var(--space-5) 0 var(--space-2);
}
.dash-section-title {
  font-size: 11px;
  font-weight: var(--fw-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dash-grid {
  display: grid;
  gap: var(--space-3);
}
.dash-grid-2 { grid-template-columns: 1fr 1fr; }
.dash-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) {
  .dash-grid-2, .dash-grid-3 { grid-template-columns: 1fr; }
}

.dash-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dash-card-tall { min-height: 200px; }
.dash-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.dash-card-label {
  font-size: 10.5px;
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}
.dash-card-value {
  font-size: 1.75rem;
  line-height: 1.15;
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}
.dash-card-sub {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.dash-card-divider {
  border-top: 1px solid var(--color-border);
  margin: var(--space-2) 0;
}
.dash-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}
.dash-card-text {
  font-size: var(--fs-sm);
  color: var(--color-text);
  line-height: 1.5;
}
.dash-card-mini-label {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.dash-card-mini-value {
  font-size: 1.1rem;
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}
.dash-card-mini-sub {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

/* Inventory tile grid (4-6 columns of mini-cards). */
.dash-inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.dash-inv-tile {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  background: var(--color-bg-muted, var(--color-bg));
}
.dash-inv-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}
@media (max-width: 600px) {
  .dash-inv-summary { grid-template-columns: 1fr; }
}

/* Workload + PO tile grid — clickable mini cards. */
.dash-workload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.dash-workload-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  background: var(--color-bg-muted, var(--color-bg));
  color: inherit;
  text-decoration: none;
  transition: background 0.1s ease-in-out;
}
.dash-workload-tile:hover {
  background: var(--color-surface);
  text-decoration: none;
}

.dash-tile-accent { border-color: var(--color-text); }
.dash-tile-danger { border-color: var(--color-error, #EB5757); }
.dash-tile-warning { border-color: var(--color-warning, #CB912F); }

/* P&L card — 5 micro stats in a row, gross margin emphasised. */
.dash-pnl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.dash-pnl-margin .dash-card-mini-value {
  font-weight: var(--fw-bold, 600);
}

/* Account Health AHR display + summary line. */
.dash-ahr-row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-2);
}
.dash-ahr-score {
  text-align: center;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-muted, var(--color-bg));
  min-width: 84px;
}
.dash-ahr-value {
  font-size: 1.5rem;
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}
.dash-ahr-sub {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.dash-ahr-meta { flex: 1 1 auto; }

.empty-state-inline {
  text-align: left;
  padding: var(--space-3) 0;
}

/* 7-day sparkline bars. */
.dash-sparkline {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: var(--space-2);
  height: 70px;
}
.dash-spark-bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  position: relative;
}
.dash-spark-fill {
  width: 60%;
  background: var(--color-text-muted);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: background 0.15s ease-in-out;
}
.dash-spark-bar:hover .dash-spark-fill { background: var(--color-text); }
.dash-spark-label {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Dashboard 2.1 additions — alerts strip, AI brief, delta badges,
   goal bar, sales-event countdown, returns sparkline. */
.dash-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-warning, #CB912F);
  border-radius: var(--radius-md);
  background: var(--color-warning-bg, rgba(203, 145, 47, 0.08));
}
.dash-alerts-label {
  font-size: 11px;
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text);
}
.dash-alert {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: inherit;
  text-decoration: none;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}
.dash-alert:hover { background: var(--color-bg-muted, var(--color-bg)); text-decoration: none; }
.dash-alert-danger { color: var(--color-error, #EB5757); border-color: var(--color-error, #EB5757); }
.dash-alert-warning { color: var(--color-warning, #CB912F); border-color: var(--color-warning, #CB912F); }
.dash-alert-info { color: var(--color-text); }

.dash-ai-brief { border-color: var(--color-text); }
.dash-ai-bullets {
  list-style: none;
  margin: var(--space-2) 0 0 0;
  padding: 0;
}
.dash-ai-bullets li {
  position: relative;
  padding-left: 18px;
  padding-bottom: 6px;
  font-size: var(--fs-sm);
  line-height: 1.5;
}
.dash-ai-bullets li::before {
  content: "•";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--color-text-muted);
}
.dash-ai-bullets li:last-child { padding-bottom: 0; }

.dash-delta {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}
.dash-delta-up   { color: var(--color-success, #0F7B6C); }
.dash-delta-down { color: var(--color-error, #EB5757); }
.dash-delta-flat { color: var(--color-text-muted); }

.dash-goal {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dash-goal-meta {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
}
.dash-goal-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--color-bg-muted, var(--color-bg));
  border: 1px solid var(--color-border);
  overflow: hidden;
}
.dash-goal-fill {
  height: 100%;
  transition: width 0.4s ease-out;
  background: var(--color-text-muted);
}
.dash-goal-on-pace { background: var(--color-success, #0F7B6C); }
.dash-goal-behind  { background: var(--color-warning, #CB912F); }
.dash-goal-set summary { padding: 4px 0; }
.dash-goal-input {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  flex: 1 1 auto;
  max-width: 200px;
}

.dash-sales-event { border-color: var(--color-text); }
.dash-event-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-2);
}
.dash-event-name {
  font-size: 1.1rem;
  font-weight: var(--fw-medium);
}
.dash-event-countdown {
  text-align: center;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-muted, var(--color-bg));
  min-width: 72px;
}
.dash-event-days {
  font-size: 1.5rem;
  font-weight: var(--fw-medium);
  line-height: 1;
}

.dash-returns-spark {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: var(--space-2);
  height: 48px;
}
.text-success { color: var(--color-success, #0F7B6C); }
.text-warning { color: var(--color-warning, #CB912F); }

/* My Account / Profile pages. */
.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--space-4);
  align-items: start;
}
@media (max-width: 900px) {
  .profile-layout { grid-template-columns: 1fr; }
}
.profile-main  { min-width: 0; }
.profile-aside { min-width: 0; }
.profile-name {
  margin-top: var(--space-2);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
}
.profile-memberships {
  list-style: none;
  margin: 0;
  padding: 0;
}
.profile-memberships li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-2);
}
.profile-memberships li:last-child { border-bottom: none; }

.prefs-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.prefs-list li {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-2) 0;
}
.prefs-list li:last-child { border-bottom: none; }
.prefs-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: var(--space-2);
  align-items: start;
  cursor: pointer;
  margin: 0;
}
.prefs-row input[type="checkbox"] {
  margin-top: 4px;
  width: 16px;
  height: 16px;
}

/* Avatar links — preserve underline-free hover, keep focus ring. */
.topbar-avatar-link,
.app-sidebar-user-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.topbar-avatar-link:hover,
.app-sidebar-user-link:hover { text-decoration: none; }
.app-sidebar-user-link {
  flex: 1 1 auto;
  min-width: 0;
  /* It's a <summary> (opens the account popover) now, not a plain link. */
  cursor: pointer;
  list-style: none;
}
.app-sidebar-user-link::-webkit-details-marker { display: none; }

/* Approvals + WorkUpdates intake — chat-first "new" page. */
.intake-attach-label { cursor: pointer; }
.intake-summary {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}
.intake-summary dt {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.intake-summary dd {
  margin: 0 0 var(--space-2) 0;
  font-size: var(--fs-sm);
  color: var(--color-text);
  word-break: break-word;
}
.intake-summary dd:last-child { margin-bottom: 0; }

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


/* =============================================================================
   Marketing landing (ecomex.app/tour/)

   "The only color on the page is your money."
   Monochrome ink page built on the global Notion tokens above; the single
   permitted color pair is money-green (profit the AI found) and loss-red
   (waste the AI flagged). Every figure is set in --font-mono, like an
   analyst's terminal. The hero and final CTA sit on a constant dark ink
   panel in BOTH themes (deliberate single-look surfaces).
   ============================================================================= */

.lp-page {
  --lp-money: #0E8A4E;
  --lp-money-soft: #E5F3EC;
  --lp-loss: #C2455A;
  --lp-loss-soft: #F9E9EC;
  --lp-panel: #0E1114;
  --lp-panel-2: #15191D;
  --lp-panel-line: #262B30;
  --lp-panel-ink: #E8E8E4;
  --lp-panel-ink-2: #9BA0A3;
  --lp-panel-money: #3ECF8E;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}
[data-theme="dark"] .lp-page {
  --lp-money: #3ECF8E;
  --lp-money-soft: #12291E;
  --lp-loss: #F0808F;
  --lp-loss-soft: #301A1F;
}

.lp-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}
.lp-page a:focus-visible,
.lp-page button:focus-visible,
.lp-page summary:focus-visible {
  outline: 2px solid var(--lp-money);
  outline-offset: 2px;
}

/* Type helpers ------------------------------------------------------------- */
.lp-svgmono {
  font-variant-numeric: tabular-nums;
}
.lp-serif-i {
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.lp-eyebrow {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 12px;
}
.lp-h2 {
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.12;
  margin: 0 0 14px;
  text-wrap: balance;
}
.lp-line {
  color: var(--color-text-muted);
  font-size: 16.5px;
  margin: 0;
  max-width: 560px;
}

/* ---- Top nav -------------------------------------------------------------- */
.lp-nav {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
}
.lp-nav-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 58px;
}
.lp-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--color-text);
  text-decoration: none;
}
.lp-brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--color-text);
  flex: none;
}
.lp-brand-mute { color: var(--color-text-muted); }
.lp-nav-links {
  display: flex;
  gap: 22px;
  margin-left: auto;
}
.lp-nav-links a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 14px;
}
.lp-nav-links a:hover { color: var(--color-text); }
.lp-nav-burger {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  padding: 6px 8px;
  cursor: pointer;
}
@media (max-width: 900px) {
  .lp-nav-links { display: none; }
  .lp-nav-cta-desktop { display: none; }
  .lp-nav-burger { display: inline-flex; }
}

/* ---- Mobile drawer -------------------------------------------------------- */
.lp-mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 86vw);
  background: var(--color-bg);
  border-left: 1px solid var(--color-border);
  z-index: 80;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.lp-mobile-drawer.is-open { transform: translateX(0); }
.lp-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.lp-drawer-title {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.lp-drawer-close {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  padding: 6px 8px;
  cursor: pointer;
}
.lp-drawer-link {
  color: var(--color-text);
  text-decoration: none;
  font-size: 16px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--color-border);
}
.lp-drawer-cta { margin-top: 18px; text-align: center; }
.lp-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.45);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.lp-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ---- Buttons on dark panels ----------------------------------------------- */
.lp-btn-light {
  background: #F4F4F1;
  color: #101114;
}
.lp-btn-light:hover { background: #FFFFFF; color: #101114; }
.lp-btn-ghost {
  background: transparent;
  color: var(--lp-panel-ink);
  border: 1px solid var(--lp-panel-line);
}
.lp-btn-ghost:hover { border-color: var(--lp-panel-ink-2); color: #FFFFFF; }

/* ---- Hero ------------------------------------------------------------------ */
.lp-hero {
  background: var(--lp-panel);
  color: var(--lp-panel-ink);
  padding: 72px 0 0;
  overflow: hidden;
}
.lp-hero-eyebrow {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lp-panel-ink-2);
  text-align: center;
  margin: 0 0 20px;
}
.lp-h1 {
  font-size: clamp(34px, 5.2vw, 56px);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.08;
  text-align: center;
  margin: 0 auto 18px;
  max-width: 760px;
  text-wrap: balance;
  color: #FFFFFF;   /* pure white on the ink hero (owner spec) */
}
.lp-hero-lede {
  color: var(--lp-panel-ink-2);
  font-size: clamp(16px, 2vw, 18px);
  text-align: center;
  max-width: 620px;
  margin: 0 auto 30px;
  text-wrap: balance;
}
.lp-hero-ctas {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.lp-hero-trust {
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: var(--lp-panel-ink-2);
  text-align: center;
  margin: 0 0 44px;
  padding: 0 16px;
}

/* The machine diagram */
.lp-machine {
  max-width: 1120px;
  margin: 0 auto;
  overflow-x: auto;
}
.lp-machine svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 860px;
}
.lp-flow {
  stroke-dasharray: 5 7;
  animation: lp-flow 2.6s linear infinite;
}
@keyframes lp-flow {
  to { stroke-dashoffset: -48; }
}
.lp-spin {
  transform-origin: 560px 262px;
  animation: lp-spin 14s linear infinite;
}
@keyframes lp-spin {
  to { transform: rotate(360deg); }
}

/* ---- Sections ---------------------------------------------------------------- */
.lp-section {
  padding: 88px 0;
  border-bottom: 1px solid var(--color-border);
}
.lp-sec-head {
  max-width: 640px;
  margin-bottom: 44px;
}

.lp-viz-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 28px;
  overflow-x: auto;
}
.lp-viz-card svg {
  display: block;
  width: 100%;
  height: auto;
}
.lp-viz-card svg.lp-svg-wide { min-width: 560px; }

.lp-viz-title {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 18px;
}
.lp-viz-title.mt { margin-top: 24px; }
.lp-viz-foot {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0;
}

.lp-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 800px) {
  .lp-split { grid-template-columns: 1fr; }
}

/* ---- Stat tiles ----------------------------------------------------------------- */
.lp-stats {
  display: grid;
  gap: 12px;
}
.lp-stats-6 {
  grid-template-columns: repeat(6, 1fr);
  margin-bottom: 20px;
}
.lp-stats-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) {
  .lp-stats-6 { grid-template-columns: repeat(3, 1fr); }
  .lp-stats-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .lp-stats-6 { grid-template-columns: repeat(2, 1fr); }
}
.lp-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px 16px;
  min-width: 0;
}
.lp-stat-label {
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lp-stat-val {
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.lp-stat-delta {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  margin-top: 2px;
  color: var(--color-text-muted);
}
.lp-stat-delta.good { color: var(--lp-money); }
.lp-stat.flag {
  background: var(--lp-loss-soft);
  border-color: var(--lp-loss);
}
.lp-stat.flag .lp-stat-label,
.lp-stat.flag .lp-stat-val { color: var(--lp-loss); }

/* ---- Waste finder bars ----------------------------------------------------------- */
.lp-wrow { margin-bottom: 20px; }
.lp-wrow-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}
.lp-wname { color: var(--color-text-muted); }
.lp-wamt {
  color: var(--lp-loss);
  font-weight: 600;
  white-space: nowrap;
}
.lp-wtrack {
  height: 18px;
  border-radius: 4px;
  background: var(--color-border);
  overflow: hidden;
}
.lp-wfill {
  height: 100%;
  border-radius: 4px;
  background: var(--color-text-muted);
  position: relative;
}
.lp-wfill-a { width: 78%; }
.lp-wfill-b { width: 56%; }
.lp-wfill-c { width: 87%; }
.lp-wwaste {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  background: var(--lp-loss);
  border-radius: 0 4px 4px 0;
}
.lp-wwaste-a { width: 15%; }
.lp-wwaste-b { width: 9%; }
.lp-wwaste-c { width: 25%; }
.lp-wlegend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 12px;
  margin: 24px 0 16px;
}
.lp-wlegend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-muted);
}
.lp-wlegend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.lp-k-spend { background: var(--color-text-muted); }
.lp-k-waste { background: var(--lp-loss); }

/* ---- Placement & creative ---------------------------------------------------------- */
.lp-pl-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.lp-pl-chip {
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  padding: 8px 12px;
  border-radius: 5px;
  background: var(--color-border);
  color: var(--color-text-muted);
  white-space: nowrap;
}
.lp-pl-chip.good {
  background: var(--lp-money-soft);
  color: var(--lp-money);
}
.lp-pl-chip.bad {
  background: var(--lp-loss-soft);
  color: var(--lp-loss);
}
.lp-cr-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--color-text-muted);
  padding: 8px 0;
  border-top: 1px solid var(--color-border);
}
.lp-cr-row .best { color: var(--lp-money); }

/* ---- Briefing bar -------------------------------------------------------------------- */
.lp-briefing-bar {
  margin-top: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 9px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.lp-briefing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lp-money);
  flex: none;
}

/* ---- Trust band ------------------------------------------------------------------------ */
.lp-trust-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
@media (max-width: 1000px) {
  .lp-trust-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .lp-trust-grid { grid-template-columns: 1fr; }
}
.lp-trust-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 24px;
}
.lp-trust-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  margin-bottom: 14px;
}
.lp-trust-title {
  font-size: 15.5px;
  font-weight: 650;
  margin: 0 0 6px;
}
.lp-trust-body {
  color: var(--color-text-muted);
  font-size: 14px;
  margin: 0;
}

/* ---- Pricing ------------------------------------------------------------------------------ */
.lp-pricing {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 900px) {
  .lp-pricing {
    grid-template-columns: 1fr;
    max-width: 480px;
  }
}
.lp-plan {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 30px;
  display: flex;
  flex-direction: column;
}
.lp-plan-name {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 650;
  text-wrap: balance;
}
.lp-price-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 2px;
}
.lp-price {
  font-variant-numeric: tabular-nums;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.lp-price-old {
  font-variant-numeric: tabular-nums;
  font-size: 17px;
  color: var(--color-text-muted);
  text-decoration: line-through;
}
.lp-off-badge {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: var(--lp-money);
  background: var(--lp-money-soft);
  border-radius: 999px;
  padding: 4px 9px;
  white-space: nowrap;
}
.lp-per {
  color: var(--color-text-muted);
  font-size: 13px;
}
.lp-plan-desc {
  color: var(--color-text-muted);
  font-size: 14.5px;
  margin: 14px 0 20px;
}
.lp-plan-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  flex: 1;
}
.lp-plan-list li {
  font-size: 14px;
  color: var(--color-text-muted);
  padding: 7px 0 7px 22px;
  position: relative;
  border-top: 1px solid var(--color-border);
}
.lp-plan-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--color-text-muted);
}
.lp-plan-cta {
  display: block;
  text-align: center;
}
.lp-trial-note {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--color-text-muted);
  margin: 22px 0 0;
}
.lp-trial-note b {
  color: var(--lp-money);
  font-weight: 600;
}
.lp-pricing-fine {
  margin-top: 10px;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* ---- FAQ -------------------------------------------------------------------------------------- */
/* FAQ sits centered on the page (owner spec): centered heading, the
   accordion block centered as a column; question/answer text stays
   left-aligned inside for readability. */
.lp-faq {
  max-width: 760px;
  margin: 0 auto;
}
#faq .lp-sec-head {
  max-width: none;
  text-align: center;
}
.lp-faq details {
  border-bottom: 1px solid var(--color-border);
}
.lp-faq summary {
  cursor: pointer;
  list-style: none;
  padding: 16px 34px 16px 0;
  font-weight: 600;
  font-size: 15.5px;
  position: relative;
}
.lp-faq summary::-webkit-details-marker { display: none; }
.lp-faq summary::after {
  content: "+";
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: 18px;
}
.lp-faq details[open] summary::after { content: "−"; }
.lp-faq-body {
  color: var(--color-text-muted);
  font-size: 14.5px;
  padding: 0 0 18px;
  max-width: 640px;
}

/* ---- Final CTA band ------------------------------------------------------------------------------ */
.lp-cta-band {
  background: var(--lp-panel);
  color: var(--lp-panel-ink);
  padding: 88px 0;
  text-align: center;
}
.lp-cta-band h2 {
  font-size: clamp(26px, 3.6vw, 40px);
  font-weight: 650;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
  text-wrap: balance;
  color: #FFFFFF;   /* pure white on the ink band, matching the hero h1 */
}
.lp-cta-band p {
  color: var(--lp-panel-ink-2);
  margin: 0 auto 30px;
  max-width: 520px;
}
.lp-composer {
  max-width: 560px;
  margin: 0 auto 26px;
  background: var(--lp-panel-2);
  border: 1px solid var(--lp-panel-line);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  text-decoration: none;
}
.lp-composer:hover { border-color: var(--lp-panel-ink-2); }
.lp-composer-prompt {
  font-size: 13.5px;
  color: var(--lp-panel-ink-2);
  flex: 1;
}
.lp-composer-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  vertical-align: -2px;
  margin-left: 2px;
  background: var(--lp-panel-money);
  animation: lp-blink 1.1s steps(1) infinite;
}
@keyframes lp-blink {
  50% { opacity: 0; }
}
.lp-composer-send {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  background: #F4F4F1;
  color: #101114;
  border-radius: 5px;
  padding: 8px 14px;
  white-space: nowrap;
}
.lp-cta-actions {
  display: flex;
  justify-content: center;
}

/* ---- Footer ------------------------------------------------------------------------------------------ */
.lp-footer {
  padding: 40px 0 32px;
  color: var(--color-text-muted);
  font-size: 13px;
}
.lp-footer-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.lp-footer-brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--color-text);
  margin-bottom: 4px;
}
.lp-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  max-width: 560px;
}
.lp-footer-links a {
  color: var(--color-text-muted);
  text-decoration: none;
}
.lp-footer-links a:hover { color: var(--color-text); }
.lp-footer-fineprint {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  line-height: 1.7;
}

/* ---- Mobile sticky CTA --------------------------------------------------------------------------------- */
.lp-sticky-cta {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  transform: translateY(110%);
  transition: transform 0.25s ease;
}
.lp-sticky-cta.is-visible { transform: translateY(0); }
.lp-sticky-cta-text {
  font-size: 14px;
  font-weight: 600;
}
.lp-sticky-cta-text small {
  display: block;
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 12px;
}
@media (max-width: 720px) {
  .lp-sticky-cta { display: flex; }
}

/* ---- Scroll reveal ---------------------------------------------------------------------------------------- */
.lp-reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.lp-reveal.in {
  opacity: 1;
  transform: none;
}

/* ===================================================================== */
/* Order Analysis — geographic choropleth (apps/reports/geo_maps.py)     */
/* Self-contained monochrome ramp (light → accent) with a dark-mode      */
/* inversion, same pattern as the task-label palette. Region fill is set */
/* by quantile class; the table beside the map carries exact numbers.    */
/* ===================================================================== */
.geo-map-wrap { overflow: hidden; }
.geo-map {
  display: block;
  width: 100%;
  height: auto;
  max-height: 480px;
}
.geo-region {
  stroke: var(--color-bg, #fff);
  stroke-width: 0.4;
  transition: opacity 0.1s ease;
}
.geo-region:hover { opacity: 0.78; cursor: default; }
.geo-q-none { fill: #efeeec; }
.geo-q0     { fill: #dcdbd8; }
.geo-q1     { fill: #b8b7b3; }
.geo-q2     { fill: #88877f; }
.geo-q3     { fill: #4d4c47; }
.geo-q4     { fill: #191919; }

[data-theme="dark"] .geo-region { stroke: var(--color-bg, #191919); }
[data-theme="dark"] .geo-q-none { fill: #2a2a2a; }
[data-theme="dark"] .geo-q0     { fill: #3a3a3a; }
[data-theme="dark"] .geo-q1     { fill: #5c5c59; }
[data-theme="dark"] .geo-q2     { fill: #8a8a86; }
[data-theme="dark"] .geo-q3     { fill: #c4c4c0; }
[data-theme="dark"] .geo-q4     { fill: #ffffff; }

/* Legend — a row of swatches under the map. */
.geo-legend { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.geo-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.geo-legend-swatch {
  width: 14px; height: 14px; border-radius: 3px;
  border: 1px solid var(--color-border);
  display: inline-block;
}

/* ============================================================================
   SKILLs > Profit & Loss — chat workspace + statement result
   ========================================================================== */
.pnl-page {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar-h) - (2 * var(--content-pad-y)));
  height: calc(100dvh - var(--topbar-h) - (2 * var(--content-pad-y)));
  min-height: 460px;
}
.pnl-topline {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-2);
}
.pnl-title {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--fs-lg); margin: 0;
}
.pnl-title-sub { font-size: var(--fs-xs); color: var(--color-text-muted); margin-left: var(--space-2); }
.pnl-app { flex: 1 1 auto; display: flex; gap: var(--space-4); min-height: 0; }

/* Recent rail */
.pnl-rail {
  flex: 0 0 216px; display: flex; flex-direction: column; gap: 1px;
  overflow-y: auto; border-right: 1px solid var(--color-border);
  padding-right: var(--space-3);
}
.pnl-rail-title {
  font-size: 11px; font-weight: var(--fw-medium); text-transform: uppercase;
  letter-spacing: .08em; color: var(--color-text-subtle); padding: var(--space-2);
}
.pnl-rail-item {
  display: flex; flex-direction: column; gap: 1px; padding: var(--space-2);
  border-radius: var(--radius-md); color: var(--color-text); text-decoration: none;
}
.pnl-rail-item:hover { background: var(--color-bg-subtle); text-decoration: none; }
.pnl-rail-item.active { background: var(--color-bg-muted); box-shadow: inset 2px 0 0 var(--color-brand); }
.pnl-rail-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); }

/* Chat column */
.pnl-chat { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.pnl-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.pnl-thread {
  width: 100%; max-width: var(--chat-max); margin: 0 auto;
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-5) var(--space-3);
}
/* Centre the welcome + composer when the thread is empty (Claude-style). */
.pnl-empty .pnl-scroll { flex: 0 0 auto; margin-top: auto; }
.pnl-empty .pnl-dock { margin-bottom: auto; }

/* Message bubbles — user gets a soft right bubble, AI is plain text. */
.pnl-thread .chat-msg { max-width: 100%; border: none; background: transparent; padding: 0; }
.pnl-thread .chat-msg-user {
  align-self: flex-end; max-width: 80%; padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg); background: var(--color-bg-muted);
}
.pnl-thread .chat-msg-ai { align-self: stretch; }
.pnl-thread .chat-msg-text { font-size: var(--fs-md); line-height: 1.6; overflow-wrap: anywhere; }

/* Welcome (empty state) */
.pnl-welcome {
  margin: auto; max-width: 540px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: var(--space-6) var(--space-4);
}
.pnl-welcome-icon {
  width: 56px; height: 56px; border-radius: var(--radius-xl);
  background: var(--color-bg-muted); color: var(--color-brand);
  display: inline-flex; align-items: center; justify-content: center;
}
.pnl-welcome-title {
  margin: 0; font-size: 30px;
  font-weight: var(--fw-normal); line-height: 1.2; letter-spacing: -0.01em;
}
.pnl-welcome-sub { margin: 0; font-size: var(--fs-md); line-height: 1.6; color: var(--color-text-muted); }

/* Composer (drop zone) */
.pnl-dock { flex: 0 0 auto; padding-top: var(--space-3); }
.pnl-composer {
  max-width: var(--chat-max); margin: 0 auto;
  background: var(--color-surface); border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-xl); padding: var(--space-3) var(--space-3) var(--space-2);
  display: flex; flex-direction: column; gap: var(--space-2);
  transition: border-color .1s ease, background .1s ease, box-shadow .1s ease;
}
.pnl-composer.is-dragover {
  border-color: var(--color-brand); border-style: dashed; background: var(--color-bg-subtle);
  box-shadow: 0 0 0 3px var(--color-brand-soft, rgba(67, 97, 125, 0.14));
}
.pnl-composer-top { display: flex; align-items: center; gap: var(--space-3); min-height: 40px; }
.pnl-attach {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--color-border); background: transparent; color: var(--color-text-muted);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .08s ease, color .08s ease;
}
.pnl-attach:hover { background: var(--color-bg-muted); color: var(--color-text); }
.pnl-drophint { color: var(--color-text-subtle); font-size: var(--fs-sm); }
.pnl-drophint b { color: var(--color-text-muted); font-weight: var(--fw-medium); }
.pnl-filechip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 6px 6px 6px 10px; border-radius: var(--radius-md);
  background: var(--color-bg-muted); font-size: var(--fs-sm); max-width: 100%;
}
.pnl-filechip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.pnl-filechip-remove {
  background: none; border: none; cursor: pointer; color: var(--color-text-muted);
  display: inline-flex; padding: 2px; border-radius: var(--radius-sm);
}
.pnl-filechip-remove:hover { background: var(--color-bg); color: var(--color-text); }
.pnl-msg-input {
  width: 100%; border: none; background: transparent; resize: none;
  font: inherit; font-size: var(--fs-md); color: var(--color-text);
  padding: var(--space-2) var(--space-1);
}
.pnl-msg-input::placeholder { color: var(--color-text-subtle); }
.pnl-msg-input:focus { outline: none; }
.pnl-composer-bar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.pnl-select {
  width: auto; font-size: var(--fs-sm); padding: 6px 10px;
  border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-bg);
}
.pnl-send {
  margin-left: auto; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-brand); color: var(--color-brand-text); border: none;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .08s ease;
}
.pnl-send:hover { background: var(--color-brand-hover); }
.pnl-send:disabled { opacity: .45; cursor: not-allowed; }
.pnl-foot { max-width: var(--chat-max); margin: var(--space-2) auto 0; text-align: center; font-size: var(--fs-xs); color: var(--color-text-muted); }
.pnl-readonly { max-width: var(--chat-max); margin: 0 auto; text-align: center; font-size: var(--fs-sm); color: var(--color-text-muted); }

/* ---- The result: a statement that flows from sales to net profit -------- */
.pnl-result { display: flex; flex-direction: column; gap: var(--space-4); }
/* Draft (calculated-but-unsaved) banner — the Save / Discard gate. */
.pnl-save {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--color-brand);
  border-radius: var(--radius-lg);
  background: var(--color-warning-bg);
}
.pnl-save-info { display: flex; flex-direction: column; gap: 2px; }
.pnl-save-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: var(--fw-semibold); color: var(--color-text);
}
.pnl-save-sub { font-size: var(--fs-sm); color: var(--color-text-muted); }
.pnl-save-dup {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); color: var(--color-warning);
}
.pnl-save-actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.pnl-save-actions form { display: inline-flex; gap: var(--space-2); margin: 0; }
.pnl-hero { display: flex; flex-direction: column; gap: var(--space-1); }
.pnl-hero-eyebrow {
  font-size: 11px; font-weight: var(--fw-medium); letter-spacing: .08em;
  text-transform: uppercase; color: var(--color-text-subtle);
}
.pnl-hero-row { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.pnl-hero-figure {
  font-size: 42px; line-height: 1.05;
  font-weight: var(--fw-normal); letter-spacing: -0.02em; color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.pnl-hero-figure.is-loss { color: var(--color-error); }
.pnl-margin {
  display: inline-flex; align-items: baseline; gap: 4px; padding: 3px 10px;
  border-radius: 999px; background: var(--color-success-bg); color: var(--color-success);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.pnl-margin.is-neg { background: var(--color-error-bg); color: var(--color-error); }
.pnl-hero-sub { font-size: var(--fs-md); color: var(--color-text-muted); }

.pnl-statement {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-xl); padding: var(--space-1) var(--space-5);
}
.pnl-line {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border);
}
.pnl-line:last-child { border-bottom: none; }
.pnl-line-label { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-md); color: var(--color-text); min-width: 0; }
.pnl-line-amt { font-variant-numeric: tabular-nums; font-size: var(--fs-md); white-space: nowrap; }
.pnl-line.is-credit > .pnl-line-amt { color: var(--color-success); }
.pnl-line.is-subtotal .pnl-line-label,
.pnl-line.is-subtotal .pnl-line-amt { font-weight: var(--fw-semibold); }
.pnl-line.is-net { padding: var(--space-4) 0; border-top: 2px solid var(--color-border-strong); }
.pnl-line.is-net .pnl-line-label { font-weight: var(--fw-semibold); font-size: var(--fs-lg); }
.pnl-line.is-net .pnl-line-amt { font-size: 22px; font-weight: var(--fw-semibold); }
.pnl-line.is-net.is-loss .pnl-line-amt { color: var(--color-error); }

/* Expandable fee breakdown */
.pnl-fees { border-bottom: 1px solid var(--color-border); }
.pnl-fees > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center;
  justify-content: space-between; gap: var(--space-4); padding: var(--space-3) 0;
}
.pnl-fees > summary::-webkit-details-marker { display: none; }
.pnl-fees-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pnl-chev { color: var(--color-text-subtle); transition: transform .12s ease; }
.pnl-fees[open] .pnl-chev { transform: rotate(90deg); }
.pnl-sublines { padding: 0 0 var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.pnl-subline { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-size: var(--fs-sm); color: var(--color-text-muted); }
.pnl-subline-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Settlement meter */
.pnl-settle {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-3);
}
.pnl-settle-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.pnl-settle-title { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.pnl-meter { height: 8px; border-radius: 999px; background: var(--color-bg-muted); overflow: hidden; }
.pnl-meter-fill { height: 100%; background: var(--color-success); border-radius: 999px; transition: width .3s ease; }
.pnl-settle-legend { display: flex; gap: var(--space-5); font-size: var(--fs-sm); color: var(--color-text-muted); flex-wrap: wrap; }
.pnl-settle-legend b { color: var(--color-text); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }

/* India tax memo — pass-through, not profit */
.pnl-tax {
  border: 1px dashed var(--color-border-strong); border-radius: var(--radius-lg);
  padding: var(--space-4); background: var(--color-bg-subtle);
}
.pnl-tax-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-subtle); font-weight: var(--fw-medium); margin-bottom: var(--space-3); }
.pnl-tax-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); }
.pnl-tax-item { display: flex; flex-direction: column; gap: 1px; }
.pnl-tax-item dt { font-size: var(--fs-xs); color: var(--color-text-muted); }
.pnl-tax-item dd { margin: 0; font-size: var(--fs-md); font-variant-numeric: tabular-nums; }

/* AI key findings */
.pnl-findings {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-brand); border-radius: var(--radius-lg); padding: var(--space-4);
}
.pnl-findings-title { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--fw-semibold); margin-bottom: var(--space-2); }
.pnl-findings-text { white-space: pre-wrap; font-size: var(--fs-md); line-height: 1.6; color: var(--color-text); overflow-wrap: anywhere; }

/* Temp-COGS call to action */
.pnl-cogs {
  border: 1px solid var(--color-warning); border-radius: var(--radius-lg);
  padding: var(--space-4); background: var(--color-warning-bg);
  display: flex; flex-direction: column; gap: var(--space-3);
}
.pnl-cogs-head { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--fw-semibold); color: var(--color-warning); }
.pnl-cogs-body { font-size: var(--fs-sm); color: var(--color-text); }
.pnl-cogs-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.pnl-cogs-upload { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.pnl-cogs-split { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--fs-sm); color: var(--color-text-muted); }
.pnl-cogs-split b { color: var(--color-text); font-variant-numeric: tabular-nums; }

/* KPI ribbon — the percentages a seller scans first */
.pnl-ribbon { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--space-3); }
.pnl-stat {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4);
}
.pnl-stat-k { font-size: var(--fs-xs); color: var(--color-text-muted); }
.pnl-stat-v {
  font-size: 24px; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--color-text);
}
.pnl-stat-v.is-neg { color: var(--color-error); }
.pnl-stat-note { font-size: var(--fs-xs); color: var(--color-text-subtle); }

/* Leak map — where the money went (fee % of sales) */
.pnl-leak {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-3);
}
.pnl-leak-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.pnl-leak-title { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.pnl-leak-take { font-size: var(--fs-sm); color: var(--color-text-muted); }
.pnl-leak-take b { color: var(--color-text); font-variant-numeric: tabular-nums; }
.pnl-leak-rows { display: flex; flex-direction: column; gap: var(--space-2); }
.pnl-leak-row {
  display: grid; grid-template-columns: minmax(90px, 1.4fr) 1fr auto auto;
  align-items: center; gap: var(--space-3); font-size: var(--fs-sm);
}
.pnl-leak-label { color: var(--color-text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pnl-leak-bar { height: 6px; border-radius: 999px; background: var(--color-bg-muted); overflow: hidden; }
.pnl-leak-fill { display: block; height: 100%; background: var(--color-brand); border-radius: 999px; }
.pnl-leak-amt { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--color-text-muted); }
.pnl-leak-pct { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: var(--fw-medium); min-width: 3.2em; text-align: right; }
.pnl-leak-note { font-size: var(--fs-xs); color: var(--color-text-subtle); }

/* Per-unit economics strip */
.pnl-perunit {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-3);
}
.pnl-perunit-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-subtle); font-weight: var(--fw-medium); }
.pnl-perunit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--space-4); }
.pnl-pu { display: flex; flex-direction: column; gap: 1px; }
.pnl-pu-k { font-size: var(--fs-xs); color: var(--color-text-muted); }
.pnl-pu-v { font-size: var(--fs-md); font-variant-numeric: tabular-nums; font-weight: var(--fw-medium); }
.pnl-pu-v.is-neg { color: var(--color-error); }

/* India tax memo — per-line reconciliation note */
.pnl-tax-note { font-size: var(--fs-xs); color: var(--color-text-subtle); margin-top: 1px; }

/* SB campaign → ASIN mapper page */
.dh-header-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.sb-map-form { margin-top: var(--space-2); }
.sb-map-table {
  width: 100%; border-collapse: collapse;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.sb-map-table th, .sb-map-table td {
  text-align: left; padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border); vertical-align: middle;
}
.sb-map-table th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-subtle); font-weight: var(--fw-semibold); }
.sb-map-table tr:last-child td { border-bottom: none; }
.sb-map-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); width: 40%; }
.sb-map-input {
  width: 100%; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-bg); font-size: var(--fs-sm); }
.sb-map-input:focus { outline: none; border-color: var(--color-brand); }
.sb-map-actions { margin-top: var(--space-3); }
.sb-map-upload {
  margin-top: var(--space-5); padding: var(--space-4);
  border: 1px dashed var(--color-border-strong); border-radius: var(--radius-lg);
  background: var(--color-bg-subtle);
}
.sb-map-upload-title { font-size: var(--fs-sm); font-weight: var(--fw-medium); margin-bottom: var(--space-2); }
.sb-map-upload-form { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }

/* Per-SKU P&L table */
.sku-pnl-note {
  display: flex; align-items: flex-start; gap: var(--space-2);
  font-size: var(--fs-sm); color: var(--color-text-muted); line-height: 1.5;
  background: var(--color-bg-subtle); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4);
}
.sku-pnl-note > svg { flex-shrink: 0; margin-top: 2px; color: var(--color-text-subtle); }
.sku-pnl-table {
  width: 100%; border-collapse: collapse;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.sku-pnl-table th, .sku-pnl-table td {
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border);
  font-size: var(--fs-sm); text-align: left;
}
.sku-pnl-table th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-subtle); font-weight: var(--fw-semibold); }
.sku-pnl-table th.is-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.sku-pnl-table th.is-sortable:hover { color: var(--color-text); }
.sku-pnl-table th.is-sortable:focus-visible { outline: 2px solid var(--color-brand); outline-offset: -2px; }
.sku-pnl-table th.is-sortable::after { content: "↕"; opacity: .35; margin-left: 4px; font-size: .9em; }
.sku-pnl-table th[data-dir="asc"]::after { content: "▲"; opacity: 1; }
.sku-pnl-table th[data-dir="desc"]::after { content: "▼"; opacity: 1; }
.sku-pnl-table th.num, .sku-pnl-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sku-pnl-table tbody tr:last-child td { border-bottom: none; }
.sku-pnl-table tbody tr.is-loss { background: var(--color-error-bg); }
.sku-pnl-sku { font-weight: var(--fw-medium); }
.sku-pnl-contrib { font-weight: var(--fw-semibold); }
.sku-pnl-table tr.is-loss .sku-pnl-contrib { color: var(--color-error); }
.sku-pnl-missing { color: var(--color-warning); }

/* Daily Briefing — "By product" sortable table headers (same sort-arrow
   language as the SKILLs P&L table above, scoped to this one table by id
   since it reuses the plain `.table` look rather than a dedicated class). */
#briefingProductTable th.is-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
#briefingProductTable th.is-sortable:hover { color: var(--color-text); }
#briefingProductTable th.is-sortable:focus-visible { outline: 2px solid var(--color-brand); outline-offset: -2px; }
#briefingProductTable th.is-sortable::after { content: "↕"; opacity: .35; margin-left: 4px; font-size: .9em; }
#briefingProductTable th[data-dir="asc"]::after { content: "▲"; opacity: 1; }
#briefingProductTable th[data-dir="desc"]::after { content: "▼"; opacity: 1; }

/* Ad-report upload (chat shortcut on the SKU P&L page) */
.ad-upload {
  margin-top: var(--space-5); padding: var(--space-4);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); display: flex; flex-direction: column; gap: var(--space-3);
}
.ad-upload-title { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.ad-upload-title > svg { color: var(--color-brand); }
.ad-upload-form { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.ad-upload-select {
  padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); background: var(--color-bg); font-size: var(--fs-sm);
}
.ad-upload-hint { font-size: var(--fs-xs); color: var(--color-text-subtle); line-height: 1.5; }

/* After-advertising bridge (settlement profit → profit after ads) */
.pnl-afterads {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-brand); border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2);
}
.pnl-afterads-row { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--fs-sm); }
.pnl-afterads-row > span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pnl-afterads-row.is-muted { color: var(--color-text-muted); }
.pnl-afterads-row.is-total { border-top: 1px solid var(--color-border); padding-top: var(--space-2); font-weight: var(--fw-semibold); }
.pnl-afterads-row.is-total .is-neg { color: var(--color-error); }
.pnl-afterads-note { font-size: var(--fs-xs); color: var(--color-text-subtle); }

/* Month-over-month chips (under the hero) */
.pnl-mom { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-2); }
.pnl-mom-label { font-size: 11px; color: var(--color-text-subtle); text-transform: uppercase; letter-spacing: .08em; }
.pnl-mom-chip {
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 9px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums;
  background: var(--color-bg-muted); color: var(--color-text-muted);
}
.pnl-mom-chip.is-good { background: var(--color-success-bg); color: var(--color-success); }
.pnl-mom-chip.is-bad { background: var(--color-error-bg); color: var(--color-error); }

/* Structured alerts (deterministic flags) */
.pnl-alerts { display: flex; flex-direction: column; gap: var(--space-2); }
.pnl-alert {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg);
  font-size: var(--fs-sm); line-height: 1.5;
  border: 1px solid var(--color-border); background: var(--color-surface);
}
.pnl-alert.is-warn { border-color: var(--color-warning); background: var(--color-warning-bg); }
.pnl-alert.is-warn > svg { color: var(--color-warning); flex-shrink: 0; }
.pnl-alert.is-info > svg { color: var(--color-text-subtle); flex-shrink: 0; }

/* Confirm/preview panels */
.pnl-panel {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-xl); padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-3);
}
.pnl-panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.pnl-panel-title { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--fs-lg); margin: 0; }
.pnl-kv { display: flex; flex-wrap: wrap; gap: var(--space-4); margin: 0; }
.pnl-kv div { display: flex; flex-direction: column; }
.pnl-kv dt { font-size: var(--fs-xs); color: var(--color-text-muted); }
.pnl-kv dd { margin: 0; font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.pnl-removed summary { cursor: pointer; font-size: var(--fs-sm); color: var(--color-text-muted); }
.pnl-removed-list { margin: var(--space-2) 0 0; padding-left: var(--space-5); font-size: var(--fs-xs); color: var(--color-text-muted); max-height: 160px; overflow: auto; }
.pnl-table-wrap { overflow: auto; max-height: 260px; }
.pnl-table-wrap .table { font-size: var(--fs-xs); }
.pnl-confirm-actions { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }

/* Settlement meter width buckets (no inline styles allowed). */
.pnl-fill-0{width:0}.pnl-fill-5{width:5%}.pnl-fill-10{width:10%}.pnl-fill-15{width:15%}
.pnl-fill-20{width:20%}.pnl-fill-25{width:25%}.pnl-fill-30{width:30%}.pnl-fill-35{width:35%}
.pnl-fill-40{width:40%}.pnl-fill-45{width:45%}.pnl-fill-50{width:50%}.pnl-fill-55{width:55%}
.pnl-fill-60{width:60%}.pnl-fill-65{width:65%}.pnl-fill-70{width:70%}.pnl-fill-75{width:75%}
.pnl-fill-80{width:80%}.pnl-fill-85{width:85%}.pnl-fill-90{width:90%}.pnl-fill-95{width:95%}
.pnl-fill-100{width:100%}

@media (max-width: 768px) {
  .pnl-app { flex-direction: column; }
  .pnl-rail { flex: 0 0 auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--color-border); padding-right: 0; padding-bottom: var(--space-2); gap: var(--space-2); }
  .pnl-rail-title { display: none; }
  .pnl-rail-item { flex: 0 0 auto; }
  .pnl-hero-figure { font-size: 34px; }
}

/* =========================================================================
   Tasks — Projects workspace: header actions, project cards, progress bars,
   template gallery, PM detail header, overview, activity, simple board.
   All widths are bucketed classes (no inline styles — CI-guarded).
   ========================================================================= */

/* Header action row (right side of .page-header) + inline form helper. */
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.inline-form { display: inline; }

/* Project colour dot + health chip. */
.proj-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; background: var(--color-text-subtle); }
.proj-dot-gray{background:#a1a1aa}.proj-dot-red{background:#ef4444}.proj-dot-orange{background:#f97316}
.proj-dot-yellow{background:#eab308}.proj-dot-green{background:#22c55e}.proj-dot-teal{background:#14b8a6}
.proj-dot-blue{background:#3b82f6}.proj-dot-indigo{background:#6366f1}.proj-dot-purple{background:#a855f7}
.proj-dot-pink{background:#ec4899}

.health-chip { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: var(--fw-medium); border: 1px solid transparent; white-space: nowrap; }
.health-on_track  { background: var(--color-success-bg); color: var(--color-success); }
.health-at_risk   { background: var(--color-warning-bg); color: var(--color-warning); }
.health-off_track { background: var(--color-error-bg);   color: var(--color-error); }

/* Progress bar (bucketed widths, snapped to nearest 5%). */
.tbar { height: 6px; border-radius: 999px; background: var(--color-bg-muted); overflow: hidden; }
.tbar-fill { height: 100%; background: var(--color-brand); border-radius: 999px; transition: width .3s ease; }
.tbar-fill-0{width:0}.tbar-fill-5{width:5%}.tbar-fill-10{width:10%}.tbar-fill-15{width:15%}
.tbar-fill-20{width:20%}.tbar-fill-25{width:25%}.tbar-fill-30{width:30%}.tbar-fill-35{width:35%}
.tbar-fill-40{width:40%}.tbar-fill-45{width:45%}.tbar-fill-50{width:50%}.tbar-fill-55{width:55%}
.tbar-fill-60{width:60%}.tbar-fill-65{width:65%}.tbar-fill-70{width:70%}.tbar-fill-75{width:75%}
.tbar-fill-80{width:80%}.tbar-fill-85{width:85%}.tbar-fill-90{width:90%}.tbar-fill-95{width:95%}
.tbar-fill-100{width:100%}

/* Project cards grid (Projects list). */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.proj-card { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); text-decoration: none; color: var(--color-text); transition: border-color .15s ease, box-shadow .15s ease; }
.proj-card:hover { border-color: var(--color-text-subtle); box-shadow: var(--shadow-sm); text-decoration: none; }
.proj-card-head { display: flex; align-items: center; gap: var(--space-2); }
.proj-card-name { font-weight: var(--fw-semibold); flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--color-text-muted); }
.proj-card-sep { color: var(--color-text-subtle); }

/* Template gallery. */
.proj-section-head { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.template-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-3); }
.template-card-form { margin: 0; display: flex; }
.template-card { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; width: 100%; padding: var(--space-4); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); cursor: pointer; font: inherit; color: var(--color-text); transition: border-color .15s ease, box-shadow .15s ease; }
.template-card:hover { border-color: var(--color-text-subtle); box-shadow: var(--shadow-sm); }
.template-card-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-md); }
.template-card-name { font-weight: var(--fw-semibold); }
.template-card-tagline { font-size: var(--fs-sm); color: var(--color-text-muted); }
.template-card-meta { font-size: var(--fs-xs); color: var(--color-text-subtle); }
.template-group-title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--color-text-muted); margin: var(--space-3) 0 var(--space-2); }

/* Project detail — PM header. */
.proj-header { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-3); }
.proj-header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.proj-header-title { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.proj-header-title .page-title { margin: 0; }
.proj-header-progress { display: flex; flex-direction: column; gap: 6px; }
.proj-header-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--color-text-muted); }
.proj-header-pct { font-weight: var(--fw-semibold); color: var(--color-text); }
.proj-header-desc { margin: 0; font-size: var(--fs-sm); color: var(--color-text-muted); }
.proj-tabs { margin-bottom: var(--space-4); }

/* Overview stat cards. */
.proj-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-3); }
.proj-stat { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-4); }
.proj-stat-num { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); line-height: 1.1; }
.proj-stat-of { font-size: var(--fs-md); color: var(--color-text-subtle); font-weight: 400; }
.proj-stat-label { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: 4px; }
.proj-stat-danger .proj-stat-num { color: var(--color-error); }

/* Activity feed. */
.proj-activity { list-style: none; margin: 0; padding: 0; }
.proj-activity-item { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); padding: 6px 0; border-bottom: 1px solid var(--color-border); font-size: var(--fs-sm); }
.proj-activity-item:last-child { border-bottom: 0; }
.proj-activity-text { color: var(--color-text-muted); }
.proj-activity-text a { color: var(--color-text); }
.proj-activity-time { color: var(--color-text-subtle); font-size: var(--fs-xs); white-space: nowrap; }

/* AI quick-add row. */
.quick-add-row { display: flex; gap: var(--space-2); align-items: center; }
.quick-add-row .form-control { flex: 1 1 auto; }

/* Project simple board (read-only kanban inside project detail). */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); align-items: start; }
.board-col { background: var(--color-bg-muted); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-2); display: flex; flex-direction: column; gap: var(--space-2); }
.board-col-head { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--color-text-muted); padding: 2px 4px; display: flex; gap: 6px; }
.board-card { display: block; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); text-decoration: none; color: var(--color-text); }
.board-card:hover { border-color: var(--color-text-subtle); text-decoration: none; }
.board-card-title { font-size: var(--fs-sm); font-weight: var(--fw-medium); margin-bottom: 4px; }
.board-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.board-col-empty { padding: 4px; }

/* Form helpers used by the project + task forms. */
.form-check { display: flex; align-items: flex-start; gap: 8px; }
.form-check-label { font-size: var(--fs-sm); color: var(--color-text-muted); }
.form-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); }
.proj-form-card { max-width: 720px; }

/* HTMX partial-swap loading hint on the shared content region. */
#app-content.htmx-request { opacity: .55; transition: opacity .1s ease; }

@media (max-width: 768px) {
  .board { grid-template-columns: 1fr; }
  .quick-add-row { flex-direction: column; align-items: stretch; }
}

/* ===================================================================== */
/* SKILLs > Weekly Snapshot                                              */
/* ===================================================================== */
.snap-layout { display: grid; grid-template-columns: 1fr 260px; gap: var(--space-5); align-items: start; }
@media (max-width: 900px) { .snap-layout { grid-template-columns: 1fr; } }

.snap-source { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-bottom: var(--space-4); }
@media (max-width: 640px) { .snap-source { grid-template-columns: 1fr; } }
.snap-source-opt { display: flex; flex-direction: column; gap: 2px; padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); cursor: pointer; }
.snap-source-opt:has(input:checked) { border-color: var(--color-text); background: var(--color-bg-subtle); }
.snap-source-title { font-weight: var(--fw-semibold); }

.snap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-4); }
@media (max-width: 640px) { .snap-grid { grid-template-columns: 1fr; } }
.snap-upload-fields { border-top: 1px solid var(--color-border); margin-top: var(--space-2); padding-top: var(--space-3); }
.snap-upload-intro { margin-bottom: var(--space-3); }

.snap-recent { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3); }
.snap-recent-title { font-size: 11px; font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-muted); margin-bottom: var(--space-2); }
.snap-recent-item { display: flex; flex-direction: column; padding: var(--space-2); border-radius: var(--radius-sm); text-decoration: none; color: var(--color-text); }
.snap-recent-item:hover { background: var(--color-bg-subtle); }
.snap-recent-name { font-weight: var(--fw-medium); font-size: var(--fs-sm); }

.snap-kpis { margin-bottom: var(--space-4); }
.snap-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-bottom: var(--space-4); }
@media (max-width: 780px) { .snap-cols { grid-template-columns: 1fr; } }
.snap-h2 { font-size: var(--fs-md); font-weight: var(--fw-semibold); margin: 0 0 var(--space-3); }
.snap-mix-table td { padding: var(--space-2) 0; }
.snap-mix-table .snap-total td { font-weight: var(--fw-semibold); border-top: 1px solid var(--color-border); }

.snap-mixbar { position: relative; height: 16px; margin-top: var(--space-3); border: 1px solid var(--color-text); background-image: repeating-linear-gradient(45deg, var(--color-text) 0, var(--color-text) 1px, transparent 1px, transparent 5px); }
.snap-mixbar-fill { position: absolute; top: 0; left: 0; height: 100%; background: var(--color-text); }
.snap-legend { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.snap-swatch { display: inline-block; width: 14px; height: 10px; border: 1px solid var(--color-text); }
.snap-swatch-solid { background: var(--color-text); }
.snap-swatch-hatch { background-image: repeating-linear-gradient(45deg, var(--color-text) 0, var(--color-text) 1px, transparent 1px, transparent 4px); }

.snap-tacos-big { font-size: var(--fs-3xl); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; line-height: 1.1; }
.snap-tacos-prose { margin: var(--space-3) 0; font-size: var(--fs-sm); }

.snap-scroll { overflow-x: auto; }
.snap-pill { display: inline-block; background: var(--color-text); color: var(--color-bg); font-size: 9px; font-weight: var(--fw-bold); letter-spacing: .04em; padding: 1px 5px; border-radius: var(--radius-sm); vertical-align: middle; }
.table .snap-total td { font-weight: var(--fw-semibold); border-top: 2px solid var(--color-border); }

.snap-notes-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.snap-notes { list-style: none; counter-reset: snapnote; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.snap-note { counter-increment: snapnote; position: relative; padding-left: 34px; }
.snap-note::before { content: counter(snapnote, decimal-leading-zero); position: absolute; left: 0; top: 0; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; color: var(--color-text-muted); }
.snap-note-title { font-weight: var(--fw-semibold); }
.snap-note-body { font-size: var(--fs-sm); color: var(--color-text-muted); }
.snap-foot { margin-top: var(--space-4); }

/* ===================================================================== */
/* KPI dashboards (apps/kpi) — role pages of stat tiles over the calc    */
/* layer. Monochrome; the loss-red flag / money-green good accents are   */
/* the same semantic pair the money pages use.                           */
/* ===================================================================== */
.kpi-controls { margin: 4px 0 20px; }
.kpi-roletabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 12px;
}
.kpi-roletab {
  padding: 8px 12px; font-size: 13.5px; color: var(--color-text-muted);
  text-decoration: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.kpi-roletab:hover { color: var(--color-text); }
.kpi-roletab.active {
  color: var(--color-text); font-weight: 600;
  border-bottom-color: var(--color-text);
}
.kpi-ranges { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.kpi-pill {
  font-size: 12px; font-weight: 600; text-decoration: none;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border); border-radius: 999px;
  padding: 5px 12px;
}
.kpi-pill:hover { color: var(--color-text); }
.kpi-pill.active {
  background: var(--color-text); color: var(--color-bg);
  border-color: var(--color-text);
}
.kpi-range-note {
  font-size: 11px;
  color: var(--color-text-muted); margin-top: 8px;
}
.kpi-section-title {
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--color-text-muted); font-weight: var(--fw-medium);
  margin: 26px 0 10px;
}
.kpi-section-note {
  font-size: 12px; color: var(--color-text-muted); margin: 8px 0 0;
}
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .kpi-grid { grid-template-columns: 1fr; } }
.kpi-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 13px 14px; min-width: 0;
}
.kpi-tile-label {
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--color-text-muted); margin-bottom: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-tile-value {
  font-variant-numeric: tabular-nums;
  font-size: 19px; font-weight: 600; letter-spacing: -0.01em;
}
.kpi-tile-sub { font-size: 11.5px; color: var(--color-text-muted); margin-top: 2px; }
.kpi-tile.flag { background: rgba(194, 69, 90, 0.07); border-color: #C2455A; }
.kpi-tile.flag .kpi-tile-label, .kpi-tile.flag .kpi-tile-value { color: #C2455A; }
.kpi-tile.good .kpi-tile-value { color: #0E8A4E; }
[data-theme="dark"] .kpi-tile.flag { background: rgba(240, 128, 143, 0.10); border-color: #F0808F; }
[data-theme="dark"] .kpi-tile.flag .kpi-tile-label, [data-theme="dark"] .kpi-tile.flag .kpi-tile-value { color: #F0808F; }
[data-theme="dark"] .kpi-tile.good .kpi-tile-value { color: #3ECF8E; }

/* KPI tiles + Situation Room shared pieces (apps/kpi) -------------------- */
.cc-verdict {
  font-size: 15px; color: var(--color-text-muted);
  max-width: 720px; margin: 0 0 18px;
}
.cc-verdict strong { color: var(--color-text); }
.kpi-grid-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1100px) { .kpi-grid-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px)  { .kpi-grid-6 { grid-template-columns: repeat(2, 1fr); } }
.cc-findings {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}
.cc-finding {
  display: flex; gap: 12px; padding: 15px 18px;
  border-bottom: 1px solid var(--color-border);
}
.cc-finding:last-child { border-bottom: 0; }
.cc-sev {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: 7px; flex: none; background: var(--color-text-muted);
}
.cc-sev.red { background: #C2455A; }
[data-theme="dark"] .cc-sev.red { background: #F0808F; }
.cc-finding-body { min-width: 0; flex: 1; }
.cc-finding-title {
  font-weight: 600; margin-bottom: 2px;
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
}
.cc-finding-impact {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px; font-weight: 600; color: #C2455A;
}
[data-theme="dark"] .cc-finding-impact { color: #F0808F; }
.cc-finding-detail { color: var(--color-text-muted); font-size: 13px; margin-bottom: 10px; }
.cc-links { display: flex; gap: 10px; flex-wrap: wrap; }
.cc-link {
  font-size: 13px; font-weight: 600; text-decoration: none;
  color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: 8px;
  padding: 10px 14px; background: var(--color-surface);
}
.cc-link:hover { border-color: var(--color-text-muted); }

/* =========================================================================
   Windsor data-sync reliability UI — history strip, tracked-job pills,
   incident lists (tenant Data-sync page + super-admin Windsor page).
   ========================================================================= */

/* --- Per-day history strip: one small square per period ------------------ */
.wsync-strip-row td { padding-top: 0; border-top: none; }
.wsync-strip {
  display: flex; flex-wrap: wrap; gap: 3px;
  padding: 2px 0 10px;
}
.wsync-cell-form { display: inline-flex; margin: 0; }
.wsync-cell {
  display: inline-block; width: 14px; height: 14px;
  border-radius: 3px; border: 1px solid var(--color-border);
  background: var(--color-surface); padding: 0;
}
button.wsync-cell { cursor: pointer; }
button.wsync-cell:hover { transform: scale(1.25); border-color: var(--color-text-muted); }
button.wsync-cell:focus-visible { outline: 2px solid var(--color-text); outline-offset: 1px; }
.wsync-ok      { background: var(--color-success); border-color: var(--color-success); }
.wsync-zero    { background: var(--color-success-bg); border-color: var(--color-success); }
.wsync-pending { background: var(--color-warning-bg); border-color: var(--color-warning); }
.wsync-failed  { background: var(--color-error-bg); border-color: var(--color-error); }
.wsync-stuck   { background: var(--color-error); border-color: var(--color-error); }
.wsync-missing { background: transparent; border-style: dashed; }

/* --- Tracked-job status pill --------------------------------------------- */
.wjob-slot { min-height: 20px; margin-top: 6px; text-align: right; }
.wjob {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--color-border);
}
.wjob-live   { color: var(--color-warning); border-color: var(--color-warning); background: var(--color-warning-bg); }
.wjob-ok     { color: var(--color-success); border-color: var(--color-success); background: var(--color-success-bg); }
.wjob-failed { color: var(--color-error); border-color: var(--color-error); background: var(--color-error-bg); }
.wjob-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  animation: wjob-pulse 1.2s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .wjob-dot { animation: none; }
}
@keyframes wjob-pulse {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}

/* --- Incident lists ------------------------------------------------------- */
.wsync-incident-list { margin: 6px 0 0 0; padding-left: 18px; }
.wsync-incident-list li { margin: 2px 0; font-size: 12.5px; }
.wsync-incident-actions { display: inline-flex; gap: 6px; justify-content: flex-end; }

/* --- Data-freshness chips (Command Center / KPI pages) -------------------- */
.data-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 10px;
}
.data-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--color-text-muted);
  border: 1px solid var(--color-border); border-radius: 999px;
  padding: 2px 10px; background: var(--color-surface);
}
.data-chip strong { color: var(--color-text); font-weight: 500; }

/* =========================================================================
   Raw Data explorer (DataHub > Raw data)
   ========================================================================= */
.raw-toolbar { flex-wrap: wrap; align-items: center; margin-top: 12px; }
.raw-search { min-width: 220px; }
.raw-count { margin-left: auto; }
.raw-report-link { color: var(--color-text); font-weight: 500; text-decoration: none; }
.raw-report-link:hover { text-decoration: underline; }
.table-scroll { overflow-x: auto; }

/* Denser table — same columns, tighter rows for data-heavy grids. */
.table-compact { font-size: var(--fs-xs); }
.table-compact thead th { padding: var(--space-2) var(--space-3); }
.table-compact tbody td { padding: var(--space-2) var(--space-3); }

/* Column-header checkbox (e.g. include/exclude a stock location). */
.stock-col-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
  font-weight: inherit;
}

.raw-table th { white-space: nowrap; }
.raw-table th a { color: var(--color-text-muted); text-decoration: none; }
.raw-table th a:hover { color: var(--color-text); }
.raw-table td { white-space: nowrap; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.raw-pagination { display: flex; align-items: center; gap: 12px; justify-content: center; }

/* === Boardroom / exhibit system — consulting-report presentation ============
   docs/BOARDROOM-BLUEPRINT.md §5. Serif action titles, numbered exhibits,
   labeled pace rows, source footnotes. Data marks are STRICTLY monochrome
   (owner rule 2026-07-17): solid charcoal = actuals/totals, 45° grey hatch
   = projections/deductions, white + black border = targets. Every bar sits
   in a labeled row (name left, value right) — no legend-free guessing.
   --chart-emphasis (Claude orange) is kept as a token but NOT used on data
   marks; status reads through labels, never color alone. */

:root {
  --chart-emphasis:      #D97757;   /* Claude orange */
  --chart-emphasis-soft: rgba(217, 119, 87, 0.16);
}
[data-theme="dark"] {
  --chart-emphasis:      #E08B6D;
  --chart-emphasis-soft: rgba(224, 139, 109, 0.20);
}

.brief-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.brief-headline {
  font-size: var(--fs-xl);
  font-weight: var(--fw-medium);
  line-height: 1.4;
  margin: 6px 0 10px;
  text-wrap: balance;
}

.provenance-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin: 0;
}
.provenance-note svg { flex-shrink: 0; margin-top: 2px; }
.provenance-note a { color: var(--color-text); }

.exhibit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.exhibit {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.exhibit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.exhibit-kicker {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
}
.exhibit-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  line-height: 1.35;
  margin: 0;
  text-wrap: balance;
}
.exhibit-values {
  display: flex;
  align-items: baseline;
  gap: 18px;
}
.exhibit-value-main {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}
.exhibit-value-side {
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}
.exhibit-value-label {
  font-size: var(--fs-xs);
  color: var(--color-text-subtle);
}

/* Pace chart — one labeled row per mark so every bar says what it is:
   Actual = solid charcoal · Projected = 45° grey hatch · Target = white
   with a solid border. Monochrome only (owner rule: no blue, no colored
   marks — black / greys / white / hatching). */
.pace-rows { display: flex; flex-direction: column; gap: 5px; }
.pace-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: var(--fs-xs);
}
.pace-row-label { color: var(--color-text-muted); }
.pace-row-value {
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 64px;
}
.pace-track {
  position: relative;
  height: 12px;
  background: var(--color-bg-subtle);
  border-radius: 3px;
}
.pace-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-radius: 3px;
}
.pace-actual { background: var(--color-text); }
.pace-projected {
  background: repeating-linear-gradient(
    45deg, var(--color-text-muted) 0 2px, transparent 2px 6px);
  border: 1px solid var(--color-text-muted);
}
.pace-goal {
  background: var(--color-surface);
  border: 1.5px solid var(--color-text);
}

.exhibit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.exhibit-meta strong { color: var(--color-text); font-variant-numeric: tabular-nums; }
.exhibit-meta em { color: var(--color-text-subtle); font-style: normal; }
.exhibit-flag { color: var(--color-warning); }
.exhibit-source {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
  font-size: 11px;
  color: var(--color-text-subtle);
}

.boardroom-targets .card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  margin: 0;
}
.target-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.target-grid .form-field { display: flex; flex-direction: column; gap: 4px; }

/* --- Control Tower (L2) — decomposition tables, owner chips, bridge ------- */

.owner-chip {
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.comp-table { display: flex; flex-direction: column; }
.comp-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 0.8fr;
  gap: 8px;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--fs-sm);
}
.comp-row:last-child { border-bottom: none; }
.comp-row-head { font-weight: var(--fw-semibold); }
.comp-row-labels {
  font-size: var(--fs-xs);
  color: var(--color-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border-strong);
}
.comp-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.comp-prev { color: var(--color-text-subtle); }
.delta { font-size: var(--fs-xs); color: var(--color-text-subtle); }
.delta-adverse { color: var(--color-error); }
.delta-favorable { color: var(--color-success); }

.tower-cascade { margin-bottom: 14px; }
.cascade-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.cascade-table th {
  text-align: left;
  font-size: var(--fs-xs);
  color: var(--color-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: var(--fw-medium);
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--color-border-strong);
}
.cascade-table td {
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
.cascade-table tr:last-child td { border-bottom: none; }
.cascade-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cascade-basis { font-size: 11px; color: var(--color-text-subtle); margin-top: 2px; }

/* Derivation row — the full working under a recommendation (how a suggested
   bid was arrived at), spanning the table so the reader can audit the number
   rather than trust it. Reads as an annotation on the row above, not a peer. */
.cascade-table tr.cascade-subrow td {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-sunken, transparent);
  padding-top: 0;
}
.cascade-table tr.cascade-subrow .cascade-basis { line-height: 1.55; }
.cascade-table tr.cascade-subrow .exhibit-flag { margin-right: 4px; }

.bridge { display: flex; flex-direction: column; gap: 6px; }
.bridge-row {
  display: grid;
  grid-template-columns: 76px 1fr 90px;
  gap: 10px;
  align-items: center;
  font-size: var(--fs-xs);
}
.bridge-label { color: var(--color-text-muted); }
.bridge-value { text-align: right; font-variant-numeric: tabular-nums; }
.bridge-track {
  position: relative;
  height: 14px;
  background: var(--color-bg-subtle);
  border-radius: 3px;
}
.bridge-seg { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.bridge-total { background: var(--color-text); }
.bridge-neg {
  background: repeating-linear-gradient(
    45deg, var(--color-text-subtle) 0 2px, transparent 2px 6px);
  border: 1px solid var(--color-border-strong);
}
.bridge-final { background: var(--color-text); }

/* --- Diagnosis Engine (Phase 4) — SCQA doc + walked tree ------------------ */

.diag-scq {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin: 2px 0 10px;
}
.diag-link {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--color-text);
  text-decoration: none;
  border-bottom: 1px solid var(--color-border-strong);
  align-self: flex-start;
}
.diag-link:hover { border-bottom-color: var(--color-text); }
.diag-actions { margin-bottom: 14px; }
.diag-action-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--fs-sm);
}
.diag-tree, .diag-children { list-style: none; margin: 0; padding: 0; }
.diag-children {
  margin: 6px 0 2px 10px;
  padding-left: 14px;
  border-left: 2px solid var(--color-border-strong);
}
.diag-node { padding: 4px 0; }
.diag-node-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.diag-node-label { font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.diag-node-finding { font-size: var(--fs-xs); color: var(--color-text-muted); }

/* --- Chief of Staff memo (Phase 4b) --------------------------------------- */
.memo-section { margin-bottom: 14px; }
.memo-body {
  font-size: var(--fs-sm);
  line-height: 1.6;
  margin: 0;
  white-space: pre-line;
}
.memo-takeaways {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--fs-sm);
}

/* --- Impact ledger (Phase 5) ---------------------------------------------- */
.impact-track-form { display: inline-block; margin: 0 4px 0 0; }
.diag-action-list li .status-badge { margin-left: 6px; }
.diag-action-list li .impact-track-form { margin-left: 8px; }

/* --- Engagement brain (super admin) --------------------------------------- */
.brain-tenant-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.brain-tenant-picker .form-control { width: auto; min-width: 260px; }
.brain-group { margin-bottom: 14px; }
.brain-set-form {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}
.brain-input { width: 90px; text-align: right; font-variant-numeric: tabular-nums; }

/* --- Cascade scenario bar (what-if) --------------------------------------- */
.scenario-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 10px 12px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
}
.scenario-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.scenario-form .form-field { display: flex; flex-direction: column; gap: 3px; }
.scenario-form .brain-input { width: 120px; }

/* --- Density layer: number links, sparklines, sub-metrics, tile deltas ----- */
.num-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--color-text-subtle);
}
.num-link:hover { border-bottom-color: var(--color-text); }
.spark-strip {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 34px;
  margin-top: 2px;
}
.spark-col {
  flex: 1;
  min-height: 1px;
  background: var(--color-text-subtle);
  border-radius: 1px 1px 0 0;
}
.exhibit-subs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.exhibit-sub strong { color: var(--color-text); font-variant-numeric: tabular-nums; }
.kpi-tile-value .delta { margin-left: 6px; }

/* ---- Situation Room (the logged-in home at /kpi/) ---- */
.sidebar-home-link { margin-bottom: 6px; font-weight: var(--fw-medium); }
.tape {
  display: flex;
  border-block: 1px solid var(--color-border-strong);
  margin-top: 4px;
  overflow-x: auto;
}
.tape-item {
  flex: 1 1 0;
  min-width: 92px;
  padding: 10px 12px 8px;
  border-right: 1px solid var(--color-border);
}
.tape-item:last-child { border-right: none; }
.tape-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  white-space: nowrap;
}
.tape-settling {
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  padding: 0 5px;
  font-size: 9px;
  color: var(--color-text-muted);
}
.tape-value {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.tape-delta {
  font-size: var(--fs-xs);
  color: var(--color-text-subtle);
  font-variant-numeric: tabular-nums;
  min-height: 16px;
}
.tape-note {
  font-size: var(--fs-xs);
  color: var(--color-text-subtle);
  margin: 6px 0 18px;
}
.sr-block { margin-bottom: 18px; }
.sr-scroll { overflow-x: auto; }
.sr-sparks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 10px;
}
@media (max-width: 700px) { .sr-sparks { grid-template-columns: 1fr; } }
.sr-engines {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.sr-bridge-row span:first-child { color: var(--color-text-muted); }
.desk-grid,
.sr-practice {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.desk-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.desk-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.desk-flags {
  font-size: var(--fs-xs);
  color: var(--color-error);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}
.desk-chief { font-size: var(--fs-xs); color: var(--color-text-subtle); }
.desk-stats { display: flex; flex-direction: column; }
.desk-stat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--fs-sm);
}
.desk-stat:last-child { border-bottom: none; }
.desk-stat span { color: var(--color-text-muted); }
.desk-stat strong { font-variant-numeric: tabular-nums; }
.desk-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: var(--fs-sm);
  margin-top: auto;
}
.sr-practice-headline {
  font-size: var(--fs-md);
  line-height: 1.45;
  margin: 0;
}

/* ===========================================================================
   Global search — topbar popover + /search/ page + Spark's answer panel.
   Appended, not interleaved — new rules only, nothing above this point in
   the file is touched.
   ========================================================================= */

/* Topbar search popover — same <details class="ws-switcher"> mechanics as
   the store switcher, just wider and holding an input instead of a list.
   The base .ws-switcher-menu rule anchors `left: 0`, which is correct for
   the store switcher (lives in .topbar-left, room to grow rightward) but
   overflows the viewport here, since the search trigger sits in
   .topbar-right near the edge of the screen — anchor from the right edge
   instead so the panel opens leftward and stays on-screen. */
.topbar-search { position: relative; }
.topbar-search-menu {
  left: auto;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 24px);
  padding: var(--space-3);
}
/* Below this width the search icon isn't flush with the true screen edge
   (dark-mode toggle / notifications / avatar sit to its right), so a
   right:0-anchored panel can still run off the LEFT edge. Anchor to the
   viewport itself instead of the trigger. */
@media (max-width: 640px) {
  .topbar-search-menu {
    position: fixed;
    top: calc(var(--impersonation-banner-h) + var(--topbar-h) + 6px);
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
  }
}
.topbar-search-input-row { display: flex; gap: var(--space-2); }
.topbar-search-input-row input[type="search"] { flex: 1; }
.topbar-search-results {
  margin-top: var(--space-2);
  max-height: 320px;
  overflow-y: auto;
}
.topbar-search-footer {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}
.topbar-search-footer a,
.topbar-search-footer-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  width: 100%;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.topbar-search-footer a:hover,
.topbar-search-footer-btn:hover { color: var(--color-text); }

/* Result rows — shared by the topbar dropdown and the /search/ page list.
   Re-declares .search-dropdown-row (defined earlier for the product-group
   member search) so links render without the default underline; source
   order makes this win without editing the original rule. */
.search-dropdown-row {
  text-decoration: none;
  border-bottom: 1px solid var(--color-border);
}
.search-dropdown-row:last-child { border-bottom: 0; }
.search-result-title { font-weight: var(--fw-medium); color: var(--color-text); }
.search-result-summary { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: 2px; }
.search-dropdown-empty {
  padding: var(--space-3);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  text-align: center;
}

/* /search/ page layout. */
.search-results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}
@media (max-width: 860px) {
  .search-results-grid { grid-template-columns: minmax(0, 1fr); }
}
.search-results-list { display: flex; flex-direction: column; }

/* Spark's answer panel. */
.search-ai-loading {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
}
.search-ai-answer { padding: var(--space-5); }
.search-ai-answer-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--space-2);
}
.search-ai-answer-text { font-size: var(--fs-sm); line-height: 1.6; color: var(--color-text); }
.search-ai-answer-empty .search-ai-answer-text { color: var(--color-text-muted); }

/* Ads Practice — duplicate demand. Each ad group's negative list is a native
   <details> block so the page opens as a short to-do list and expands only
   where the seller is actually working. The paste area is deliberately a bare
   monospace <pre>: its text goes straight into Amazon's negative-keyword box,
   one term per line, so nothing may decorate or re-wrap it. */
.neg-block {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  background: var(--color-bg-surface);
}
.neg-block > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  list-style: none;
}
.neg-block > summary::-webkit-details-marker { display: none; }
/* The affordance the seller was promised: a + that becomes a − when open. */
.neg-block > summary::before {
  content: "+";
  color: var(--color-text-muted);
  margin-right: var(--space-2);
}
.neg-block[open] > summary::before { content: "\2212"; }
.neg-block > summary:hover { background: var(--color-bg-muted); }
.neg-block-name { font-weight: var(--fw-semibold); }
.neg-block-group { color: var(--color-text-muted); font-weight: var(--fw-regular); }
.neg-block-meta {
  margin-left: auto;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--ls-kicker);
  color: var(--color-text-muted);
}
.neg-paste-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4) 0;
}
.neg-paste-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--ls-kicker);
  color: var(--color-text-muted);
}
.neg-copy-btn { margin-left: auto; }
.neg-paste {
  margin: var(--space-2) var(--space-4) var(--space-4);
  padding: var(--space-3);
  max-height: 260px;
  overflow: auto;
  background: var(--color-bg-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  line-height: 1.7;
  white-space: pre;
  color: var(--color-text);
}
.neg-block .table-scroll { padding: 0 var(--space-4) var(--space-4); }
.neg-block > .kpi-section-note { padding: 0 var(--space-4) var(--space-3); }

/* ---------- Error pages (404 / 500) ------------------------------------- */
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
}
.error-card {
  width: 100%;
  max-width: 460px;
  text-align: center;
}
.error-code {
  font-size: 4rem;
  line-height: 1;
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-4);
}
.error-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--space-2);
}
.error-hint {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}
.error-path {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  word-break: break-all;
  background: var(--color-bg-muted);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-6);
  display: inline-block;
}
.error-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}
