/*
  app/static/css/theme.css

  BT-007.6 Part A -- design tokens.

  What this is:
    Light + dark color palettes as CSS custom properties plus a thin
    typography / radius / spacing scale. The dashboard's component
    partials (templates/components/*.html) reference these vars so the
    light <-> dark swap is purely a color rebind -- layout, density,
    component sizes stay constant.

  Density rule:
    Light mode and dark mode use IDENTICAL spacing + sizing tokens.
    Workshop designers sometimes use dark = denser; we don't. The
    only difference between the two modes is which palette is bound.

  How to extend:
    Add a token here, then reference it via `var(--name)` in a
    component or template. Don't sprinkle hex codes in templates.
*/

:root {
  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;

  /* Type scale (rem) */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-kpi: 2rem;
  --leading-tight: 1.2;
  --leading-normal: 1.5;

  /* Spacing (rem). Density-controlled. Identical in light + dark. */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Layout */
  --container-max: 1100px;
  --container-px: 1.5rem;
}

/* --------------------------------------------------------------------- */
/* Light palette (default).                                              */
/* Inspired by Plausible / Notion / Coda whites with a single Linear-ish */
/* accent color. Surface colors are slightly off-white to keep cards     */
/* visually distinct from the page background.                           */
/* --------------------------------------------------------------------- */
:root,
[data-theme="light"] {
  color-scheme: light;

  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-muted: #f5f5f4;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #0f172a;
  --text-muted: #57534e;
  --text-faint: #8a857f;       /* BT-007.6.4-patch2 item 8: was #a8a29e (2.4:1 on white) */

  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-pool: #b45309;       /* Pool == Kevin's #1 strategic priority */
  --accent-pool-soft: #fef3c7;
  --accent-food: #6b7280;       /* Food == loss-leader; intentionally muted */
  --accent-food-soft: #f1f5f9;

  --tone-positive: #047857;
  --tone-positive-soft: #a7f3d0;   /* BT-007.6.5 A17: deepened from #d1fae5 — washed out in light */
  --tone-neutral: #57534e;
  --tone-neutral-soft: #f5f5f4;
  --tone-cautious: #b45309;
  --tone-cautious-soft: #fde68a;   /* BT-007.6.5 A17: deepened from #fef3c7 so CAUTIOUS reads "look at this" */
  --tone-alert: #b91c1c;
  --tone-alert-soft: #fecaca;      /* BT-007.6.5 A17: deepened from #fee2e2 */

  --chart-line: #0f172a;
  --chart-area: rgba(15, 23, 42, 0.06);
  --chart-pnl: #047857;
  --chart-pool: #b45309;
  --chart-grid: #e7e5e4;        /* BT-007.6.4-patch2 item 8 */

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* --------------------------------------------------------------------- */
/* Dark palette.                                                          */
/* Linear-ish deep neutrals with the same accent role assignments. SAME  */
/* spacing tokens -- no density change.                                   */
/* --------------------------------------------------------------------- */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b0d12;
  --surface: #14171e;
  --surface-elevated: #1b1f28;
  --surface-muted: #11141a;
  --border: #262b35;
  --border-strong: #353a45;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;

  --accent: #818cf8;
  --accent-soft: #1e1b4b;
  --accent-pool: #fbbf24;
  --accent-pool-soft: #422006;
  --accent-food: #a1a1aa;
  --accent-food-soft: #1f2937;

  --tone-positive: #34d399;
  --tone-positive-soft: #064e3b;
  --tone-neutral: #a1a1aa;
  --tone-neutral-soft: #1c2027;
  --tone-cautious: #fbbf24;
  --tone-cautious-soft: #422006;
  --tone-alert: #f87171;
  --tone-alert-soft: #450a0a;

  --chart-line: #e4e4e7;
  --chart-area: rgba(228, 228, 231, 0.08);
  --chart-pnl: #34d399;
  --chart-pool: #fbbf24;
  --chart-grid: #323845;        /* BT-007.6.4-patch2 item 8: border #262b35 faded into bg */

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
}

/* --------------------------------------------------------------------- */
/* Base element styling                                                   */
/* --------------------------------------------------------------------- */
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); }

.font-num,
.tabular-nums {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.01em;
}

/* --------------------------------------------------------------------- */
/* Layout primitives used by analytics partials                           */
/* --------------------------------------------------------------------- */
.page-shell {
  background: var(--bg);
  min-height: 100vh;
}

.page-header {
  /* BT-008 Theme G: sticky top nav. Stays pinned to the viewport top on
     scroll across every page (Home, Uploads, Analytics, Briefings). Uses
     an OPAQUE token background (not a translucent one) so content never
     bleeds through and there are no white rectangles in dark mode; the
     blur is a progressive-enhancement nicety where supported. */
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

/* patch18 (Item 4): hide the page-level browser scrollbar app-wide (the page
   still scrolls on wheel/trackpad/keys). Matches the patch17 inner-card behavior
   so the whole UI is scrollbar-free. */
html, body {
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE/Edge */
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;                /* Safari/Chrome */
}

.page-container {
  max-width: var(--container-max);
  margin: 0 auto;
  /* BT-007.6.4-patch3 #1/R1: guaranteed horizontal padding at ALL
     breakpoints so content never bleeds to the viewport edge ("lello
     Kevin" left-clip). clamp keeps it comfortable on desktop, safe on
     phones. Replaces the old `0 var(--container-px)` which lost its
     inline padding under some mobile reflows. */
  padding-block: 0;
  padding-inline: clamp(16px, 4vw, 32px);
  width: 100%;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);   /* BT-007.6.5 A1: roomier; Home/Ingest now adopt this instead of raw bg-white */
  color: var(--text);
}

.card-elevated {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.section-title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.section-meta {
  font-size: var(--text-xs);
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* KPI tile */
.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.kpi-tile__label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.kpi-tile__value {
  font-family: var(--font-mono);
  font-size: var(--text-kpi);
  font-weight: 600;
  color: var(--text);
  line-height: var(--leading-tight);
}

.kpi-tile__deltas {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.kpi-tile__sparkline {
  margin-top: var(--space-2);
  height: 36px;
}

.delta--up { color: var(--tone-positive); }
.delta--down { color: var(--tone-alert); }
.delta--flat { color: var(--text-muted); }

/* Attention card */
.attention-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--text-sm);
}

.attention-card--info    { background: var(--surface); border-color: var(--border); }
.attention-card--warning { background: var(--tone-cautious-soft); border-color: var(--tone-cautious); color: var(--text); }
.attention-card--alert   { background: var(--tone-alert-soft); border-color: var(--tone-alert); color: var(--text); }

.attention-pill {
  flex-shrink: 0;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
  padding: 2px var(--space-2);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
}

.attention-card--warning .attention-pill { background: var(--tone-cautious); color: white; }
.attention-card--alert   .attention-pill { background: var(--tone-alert);    color: white; }

.attention-card__action {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* Data tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table thead th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}

.data-table tbody td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .num {
  text-align: right;
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
}

.data-table .row-pool td { color: var(--accent-pool); font-weight: 600; }
.data-table .row-other td { color: var(--text-faint); font-style: italic; }

/* Pool / Food focus sections */
.focus-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.focus-section--pool {
  border-left: 3px solid var(--accent-pool);
}

.focus-section--food {
  border-left: 3px solid var(--accent-food);
}

.focus-section__title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-1);
}

.focus-section__note {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.placeholder-block {
  background: var(--surface-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
}

/* Collapsibles */
details.collapsible > summary {
  cursor: pointer;
  list-style: none;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::before {
  content: "▸";
  display: inline-block;
  width: 1.2em;
  color: var(--text-muted);
  transition: transform 120ms ease;
}
details.collapsible[open] > summary::before { transform: rotate(90deg); }

details.collapsible > .collapsible__body { padding-top: var(--space-4); }

/* Theme toggle button */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 4px var(--space-3);
  font-size: var(--text-xs);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
}

.theme-toggle:hover { background: var(--surface-muted); }

.theme-toggle__icon-sun { display: none; }
.theme-toggle__icon-moon { display: inline; }
[data-theme="dark"] .theme-toggle__icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle__icon-moon { display: none; }

/* Logo placeholder */
.brand-logo-slot {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--surface-muted);
  border: 1px dashed var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-faint);
}

/* --------------------------------------------------------------------- */
/* Canvas containment (BT-007.6.2 defect 8)                               */
/* --------------------------------------------------------------------- */
/*
  Chart.js charts are configured with `responsive: true, maintainAspectRatio: false`,
  which means the canvas takes its dimensions from its positioned parent.
  Without an explicit container height the canvas balloons to fill the
  viewport on render, causing lag + the "empty plane" visual when the data
  arrives a frame late. Wrapping each canvas in .card__canvas-wrap fixes
  this by giving Chart.js a bounded box to render into.

  Sparkline canvases inside .kpi-tile__sparkline are NOT wrapped — that
  container already constrains height (see .kpi-tile__sparkline above).

  Three modifiers because charts have different ideal heights:
    --tall    Doughnut (chart-product-groups) — needs vertical room
    --med     Primary line/bar charts (daily revenue, weather, pool history, equity)
    --short   Compact bars (weekday averages, labor by weekday)
*/
.card__canvas-wrap {
  position: relative;
  width: 100%;
}

.card__canvas-wrap--tall  { height: 280px; }
.card__canvas-wrap--med   { height: 240px; }
.card__canvas-wrap--short { height: 180px; }

/* Mobile reflow */
@media (max-width: 720px) {
  :root { --container-px: 1rem; }
  .kpi-tile__value { font-size: 1.5rem; }
  .section-title { font-size: var(--text-base); }

  /* Scale chart containers down so phone screens aren't dominated by them. */
  .card__canvas-wrap--tall  { height: 220px; }
  .card__canvas-wrap--med   { height: 200px; }
  .card__canvas-wrap--short { height: 160px; }
}

/* --------------------------------------------------------------------- */
/* BT-007.6.4 -- UX polish layer                                          */
/* --------------------------------------------------------------------- */

/* Theme A: plain-English section captions (italic one-liner under each
   section header explaining WHAT the section shows and WHY it matters). */
.section-caption {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-style: italic;
  margin: calc(-1 * var(--space-2)) 0 var(--space-3);
  max-width: 72ch;
  line-height: var(--leading-normal);
}

/* Theme A: tooltip affordances. data-tooltip elements get a help cursor;
   chart titles also get a dotted underline so the hover surface is
   discoverable. Bubble (desktop hover/focus) + bottom sheet (touch). */
[data-tooltip] { cursor: help; }
.chart-title[data-tooltip] {
  text-decoration: underline dotted var(--text-faint);
  text-underline-offset: 3px;
}

.hp-tooltip-bubble {
  position: fixed;
  z-index: 1000;
  max-width: 340px;
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-style: normal;
  font-family: var(--font-sans);
  line-height: var(--leading-normal);
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

.hp-tooltip-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

.hp-tooltip-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1001;
  background: var(--surface-elevated);
  color: var(--text);
  border-top: 1px solid var(--border-strong);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-5) var(--space-5) var(--space-8);
  font-size: var(--text-sm);
  font-style: normal;
  line-height: var(--leading-normal);
  box-shadow: var(--shadow-md);
}

.hp-tooltip-sheet__close {
  display: block;
  margin-top: var(--space-4);
  padding: var(--space-2) var(--space-4);
  min-height: 32px;
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  cursor: pointer;
}

/* Theme B: direction-aware delta tones. green = improvement, red =
   regression (DOWN-IS-GOOD metrics invert server-side -- see
   analytics.py::_DOWN_IS_GOOD), gray = flat / needs-context. The legacy
   --up/--down classes stay for any remaining literal usage. */
.delta--good    { color: var(--tone-positive); }
.delta--bad     { color: var(--tone-alert); }
.delta--neutral { color: var(--text-muted); }

/* Theme D: time-range selector (Wealthsimple-style button group).
   Buttons are >=32px tall/wide for mobile tap targets. */
.time-range {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

.time-range__btn {
  min-width: 32px;
  min-height: 32px;
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.time-range__btn:hover:not(:disabled):not(.time-range__btn--active) {
  background: var(--surface-muted);
}

.time-range__btn--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

[data-theme="dark"] .time-range__btn--active { color: #0b0d12; }

.time-range__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------- */
/* BT-007.6.4-patch2 item 7 -- mobile horizontal-overflow guards          */
/* --------------------------------------------------------------------- */
/* BT-008 patch2: `overflow-x: hidden` on <body> forces overflow-y to compute
   to `auto`, making body a scroll container — which breaks `position: sticky`
   on the .page-header (sticky needs no scroll-clipping ancestor). `clip`
   contains the same horizontal overflow WITHOUT creating a scroll container,
   so the sticky nav pins. (html was already switched to clip below.) */
html, body { max-width: 100%; overflow-x: clip; }

.card, .card-elevated, .kpi-tile, .focus-section {
  min-width: 0;
  max-width: 100%;
}

.card__canvas-wrap { overflow: hidden; }

/* Bubble can't exceed the viewport on narrow phones. */
.hp-tooltip-bubble { max-width: min(340px, calc(100vw - 16px)); }

/* Two-column card layout (Product Groups) collapses on mobile. */
.grid-2col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: var(--space-3);
}

@media (max-width: 720px) {
  .grid-2col { grid-template-columns: minmax(0, 1fr); }
}

/* Scrollable table with edge-shadow indicators (pure CSS: shadows only
   appear when there's actually content to scroll toward). */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(to right, var(--surface) 30%, rgba(255, 255, 255, 0)),
    linear-gradient(to right, rgba(255, 255, 255, 0), var(--surface) 70%) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0)) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

/* --------------------------------------------------------------------- */
/* BT-007.6.4-patch2 item 8 -- defensive contrast fixes (dark mode)       */
/* White pill text on the bright dark-mode warning/alert tones failed     */
/* WCAG badly (#fbbf24 + white ~1.6:1). Dark text on those backgrounds.   */
/* --------------------------------------------------------------------- */
[data-theme="dark"] .attention-card--warning .attention-pill,
[data-theme="dark"] .attention-card--alert .attention-pill {
  color: #0b0d12;
}

/* --------------------------------------------------------------------- */
/* BT-007.6.4-patch3 #1/R1 + A1                                            */
/* --------------------------------------------------------------------- */
/* overflow-x: clip on <html> stops horizontal scroll WITHOUT creating a
   scroll container (unlike `hidden`, which can trap position:sticky).
   Pairs with the body guard added in patch2. */
html { overflow-x: clip; }

/* A1: the engineers-only (?) affordance next to the page metadata. */
.meta-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1;
  cursor: help;
}

/* ===================================================================== */
/* BT-007.6.5 — design system + responsive shell + a11y baseline         */
/* ===================================================================== */

/* --- Theme C #19/S1: focus-visible (WCAG 2.4.7). PRIORITY-FIRST. ------ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --- Theme C #25/S9: skip link ---------------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 2000;
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  font: 600 13px/20px var(--font-sans);
  box-shadow: var(--shadow-md);
}
.skip-link:focus {
  left: var(--space-4);
  top: var(--space-4);
}

/* --- Theme A #4: token-driven semantic type scale --------------------- */
.t-display { font: 600 32px/36px var(--font-sans); letter-spacing: -0.02em; color: var(--text); }
.t-h2      { font: 600 22px/28px var(--font-sans); color: var(--text); }
.t-body    { font: 400 15px/24px var(--font-sans); color: var(--text-muted); }
.t-small   { font: 400 13px/20px var(--font-sans); color: var(--text-muted); }
.t-eyebrow { font: 600 11px/16px var(--font-sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }

/* --- Theme B #8: active-route indicator (horizontal nav + drawer) ----- */
nav a[aria-current="page"],
.nav-drawer a[aria-current="page"] {
  color: var(--text);
  border-bottom: 2px solid var(--accent);
}

/* --- Theme B #6: hamburger + off-canvas drawer ------------------------ */
.nav-hamburger {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
/* patch11 (D15d): main links take the middle and center themselves between the
   left logo and the right theme+auth cluster. */
.nav-links { display: flex; align-items: center; gap: var(--space-4); flex: 1 1 auto; justify-content: center; }

.nav-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
.nav-drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

.nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 280px;
  max-width: 85vw;
  background: var(--surface-elevated);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  z-index: 1600;
  transform: translateX(100%);
  transition: transform 200ms ease;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
}
.nav-drawer.is-open { transform: translateX(0); }
.nav-drawer a {
  display: block;
  padding: var(--space-2) 0;
  color: var(--text);
  text-decoration: none;
  font: 500 16px/24px var(--font-sans);
}

@media (max-width: 767px) {
  .nav-links { display: none; }
  .nav-right { display: none; }   /* patch11: theme+auth live in the drawer on mobile */
  .nav-hamburger { display: inline-flex; }
}
@media (min-width: 768px) {
  .nav-drawer, .nav-drawer-backdrop { display: none; }
}

/* --- Theme B #9: responsive KPI grid ---------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}
.kpi-tile .value, .kpi-tile__value { font-size: clamp(1.5rem, 6vw, 2rem); }
.kpi-tile .label, .kpi-tile__label { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }

/* --- Theme B #11: chart aspect floor (no sparkline/month collision) --- */
.card__canvas-wrap { min-height: 220px; }

/* --- Theme D #20: brand mark ----------------------------------------- */
.brand-mark { display: inline-flex; align-items: center; gap: var(--space-2); text-decoration: none; }
.brand-text { font: 700 18px/24px var(--font-sans); color: var(--accent); letter-spacing: -0.01em; }
.brand-mark img, .brand-mark svg { width: 28px; height: 28px; }

/* --- Theme E #23: homepage hero + CTA cards -------------------------- */
.cta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}
.cta-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  color: var(--text);
  text-decoration: none;
  transition: border-color 120ms ease, transform 120ms ease;
}
.cta-card:hover { border-color: var(--accent); transform: translateY(-1px); }
/* BT-007.6.5-patch2: disabled CTA (e.g. briefings before BT-008/009). */
.cta-card--disabled { opacity: 0.6; pointer-events: none; cursor: not-allowed; }
.cta-card--disabled:hover { border-color: var(--border); transform: none; }
.cta-card__title { font: 600 16px/22px var(--font-sans); color: var(--text); }
.cta-card__desc { font: 400 13px/20px var(--font-sans); color: var(--text-muted); }
.cta-card__arrow { color: var(--accent); font-weight: 600; }

.status-strip summary {
  cursor: pointer;
  font: 400 12px/18px var(--font-mono);
  color: var(--text-faint);
  padding: var(--space-2) 0;
}
.status-strip__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-2);
}

/* --- Theme F #28: dropzone ------------------------------------------- */
.dropzone {
  min-height: 240px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 120ms ease, background 120ms ease;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone__hint { color: var(--text-muted); }
.dropzone__file { color: var(--text); font-family: var(--font-mono); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font: 600 13px/20px var(--font-sans);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] .btn--primary { color: #0b0d12; }
.btn--ghost { background: transparent; }
.btn[disabled], .btn.is-disabled { opacity: 0.5; pointer-events: none; }
.btn--danger { color: var(--tone-alert); border-color: var(--border); background: transparent; }
.btn--danger:hover { background: var(--tone-alert-soft); }

/* --- Theme F #33 + Theme G #34: empty-state component ----------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  text-align: center;
  padding: var(--space-8) var(--space-5);
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  min-height: 220px;
}
.empty-state svg { width: 36px; height: 36px; color: var(--text-faint); }
.empty-state__msg { font: 400 14px/22px var(--font-sans); color: var(--text-muted); max-width: 42ch; }

/* --- Theme F #30: upload-history mobile cards ------------------------- */
@media (max-width: 767px) {
  .uploads-table thead { display: none; }
  .uploads-table, .uploads-table tbody, .uploads-table tr, .uploads-table td { display: block; width: 100%; }
  .uploads-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
  }
  .uploads-table td { border: none; padding: var(--space-1) 0; }
  .uploads-table td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--text-faint);
    font-size: var(--text-xs);
  }
}

/* --- Theme F #17/S8: inline confirm-before-delete -------------------- */
.confirm-delete { display: inline-flex; gap: var(--space-2); align-items: center; }

/* --- Theme F I1/I3: Uploads tabs (token contrast + active underline) -- */
.uploads-tabs { display: flex; flex-wrap: wrap; gap: var(--space-1); border-bottom: 1px solid var(--border); }
.uploads-tab {
  padding: var(--space-2) var(--space-4);
  font: 500 14px/20px var(--font-sans);
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.uploads-tab:hover { color: var(--text); }
.uploads-tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.dropzone__change { color: var(--accent); cursor: pointer; text-decoration: underline; background: none; border: none; font: inherit; }

/* BT-007.6.5-patch1 DEFECT 2: the Uploads tab panels carry an inline
   `display:flex`, which overrides the `[hidden]` attribute the tab JS
   toggles — so clicking a tab moved the underline but never swapped the
   panel. `!important` lets the hidden attribute win over the inline
   display so only the active panel shows. (Not an htmx issue — the tabs
   are vanilla JS toggling `hidden`.) */
[data-panel][hidden] { display: none !important; }

/* ====================================================================== */
/* BT-008 Phase 1 -- /briefings surface (.brief-* component rules)         */
/* ====================================================================== */

/* Generate-fresh-brief button */
.brief-generate-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.6rem 1.1rem;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.brief-generate-btn:hover { filter: brightness(1.05); }
.brief-generate-btn:disabled { opacity: 0.6; cursor: progress; }
.brief-generate-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Status banner after a generate */
.brief-banner {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: var(--text-sm);
}
.brief-banner--ok { background: var(--tone-positive-soft); color: var(--tone-positive); border-color: var(--tone-positive); }
.brief-banner--warn { background: var(--accent-pool-soft); color: var(--accent-pool); border-color: var(--accent-pool); }
.brief-banner--error { background: var(--tone-alert-soft); color: var(--tone-alert); border-color: var(--tone-alert); }

/* Brief card -- native <details>; token-driven so dark mode just works */
.brief-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.brief-card__summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.brief-card__summary::-webkit-details-marker { display: none; }
.brief-card__summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.brief-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.brief-card__when { color: var(--text-faint); font-size: var(--text-sm); }
.brief-card__headline {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.brief-card__breaches { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.brief-card__body {
  padding: 0 var(--space-4) var(--space-4);
  border-top: 1px solid var(--border);
}
.brief-card__section-title {
  font-size: var(--text-xs, 0.75rem);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: var(--space-4) 0 var(--space-2);
}
.brief-card__actions { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: var(--space-2); }
.brief-card__actions li { color: var(--text); }

/* Pills (fire-type + threshold breaches) */
.brief-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: var(--text-xs, 0.72rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
}
.brief-pill--scheduled { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.brief-pill--on_demand { background: var(--surface-muted); color: var(--text-muted, var(--text-faint)); }
.brief-pill--breach { background: var(--tone-alert-soft); color: var(--tone-alert); border-color: var(--tone-alert); }
/* BT-008.9 Slice A: revenue-stream (business_unit) pill -- accent-tinted so it
   reads as the draft's stream at a glance in the queue + detail. */
.brief-pill--unit { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
/* BT-008.10 Slice A: photo-with-overlay marker pill. */
.brief-pill--overlay { background: var(--accent-pool-soft); color: var(--accent-pool); border-color: var(--accent-pool); }
/* BT-008.10 Slice B: FB carousel marker pill + carousel mockup strip. */
.brief-pill--carousel { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.carousel-strip { display: flex; gap: var(--space-2); overflow-x: auto; padding-bottom: var(--space-1); scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.carousel-strip__item { position: relative; flex: 0 0 auto; width: 78%; max-width: 320px; scroll-snap-align: start; }
.carousel-strip__item img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: var(--radius-2, 8px); display: block; }
.carousel-strip__idx { position: absolute; top: var(--space-1); right: var(--space-1); background: rgba(0,0,0,0.6); color: #fff; font-size: 0.72rem; padding: 1px 7px; border-radius: 999px; }
@media (max-width: 640px) { .carousel-strip__item { width: 88%; } }
/* BT-008.10 Slice C: IG Story marker pill + 9:16 vertical Story mockup. */
.brief-pill--story { background: var(--accent-pool-soft); color: var(--accent-pool); border-color: var(--accent-pool); }
.mockup--story { max-width: 300px; border-radius: var(--radius-2, 8px); overflow: hidden; background: #000; position: relative; }
.mockup-story__progress { height: 3px; background: rgba(255,255,255,0.3); margin: var(--space-2) var(--space-2) 0; border-radius: 999px; }
.mockup-story__progress span { display: block; height: 100%; width: 40%; background: #fff; border-radius: 999px; }
.mockup-story__bar { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); color: #fff; }
.mockup-story__bar .mockup__handle { color: #fff; font-weight: 600; }
.mockup-story__expiry { margin-left: auto; font-size: 0.7rem; color: rgba(255,255,255,0.7); }
.mockup-story__media { position: relative; aspect-ratio: 9 / 16; width: 100%; }
.mockup-story__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mockup-story__caption { position: absolute; left: 0; right: 0; bottom: 0; padding: var(--space-3) var(--space-2); color: #fff; font-size: 0.9rem; background: linear-gradient(to top, rgba(0,0,0,0.7), rgba(0,0,0,0)); }
/* patch20 Item 3: FB Story chrome -- FB blue accents distinguish it from IG. */
.mockup--fb-story { max-width: 300px; border-radius: var(--radius-2, 8px); overflow: hidden; background: #000; position: relative; }
.mockup-story__progress--fb span { background: #1877F2; }
.mockup-story__bar--fb .mockup__page { color: #fff; font-weight: 600; }
.mockup-story__bar--fb .mockup__meta { color: rgba(255,255,255,0.7); }
.mockup-story__bar--fb .mockup__avatar { border: 2px solid #1877F2; }
/* BT-008.10 Slice D: IG Reel marker pill + vertical video preview. */
.brief-pill--reel { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.mockup--reel { max-width: 300px; border-radius: var(--radius-2, 8px); overflow: hidden; background: #000; }
.mockup-reel__video { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; display: block; background: #000; }
/* BT-008.10 Slice E: FB video marker pill + feed video element (aspect set inline). */
.brief-pill--fb-video { background: var(--accent-pool-soft); color: var(--accent-pool); border-color: var(--accent-pool); }
.mockup-fbvideo__video { width: 100%; object-fit: cover; display: block; background: #000; border-radius: var(--radius-2, 8px); }
/* patch20 Item 5: draft-card video thumbnail matches the img footprint. */
.draft-card__video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }

/* ====================================================================== */
/* BT-008 Phase 2 -- login form input                                     */
/* ====================================================================== */
.login-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font: inherit;
}
.login-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

/* ====================================================================== */
/* BT-008 Phase 2 -- marketing approval surface (.draft-* )               */
/* ====================================================================== */
.draft-tabs { display: flex; flex-wrap: wrap; gap: var(--space-2); border-bottom: 1px solid var(--border); }
.draft-tab {
  padding: 0.5rem 0.75rem;
  color: var(--text-faint);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  font-size: var(--text-sm);
}
.draft-tab:hover { color: var(--text); }
.draft-tab--active { color: var(--text); border-bottom-color: var(--accent); }

.draft-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}
@media (max-width: 720px) { .draft-grid { grid-template-columns: 1fr; } }

.draft-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.draft-card__media { aspect-ratio: 4 / 3; background: var(--surface-muted); overflow: hidden; }
.draft-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.draft-card__media-empty {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  color: var(--text-faint); font-size: var(--text-sm); padding: var(--space-3);
}
.draft-card__body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.draft-card__pills { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.draft-card__copy { color: var(--text); line-height: 1.5; }
.draft-card__more summary { cursor: pointer; color: var(--text-faint); font-size: var(--text-sm); }
.draft-card__actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }

.draft-status {
  display: inline-block; padding: 0.12rem 0.5rem; border-radius: 999px;
  font-size: var(--text-xs, 0.72rem); font-weight: 600; border: 1px solid var(--border);
  text-transform: capitalize;
}
.draft-status--pending { background: var(--accent-soft); color: var(--accent); }
.draft-status--approved, .draft-status--scheduled { background: var(--tone-positive-soft); color: var(--tone-positive); }
.draft-status--published { background: var(--tone-positive-soft); color: var(--tone-positive); }
.draft-status--rejected, .draft-status--publish_failed { background: var(--tone-alert-soft); color: var(--tone-alert); }
.draft-status--modify_requested { background: var(--accent-pool-soft); color: var(--accent-pool); }

.draft-link { color: var(--accent); text-decoration: none; font-size: var(--text-sm); }
.draft-link:hover { text-decoration: underline; }
.draft-btn-sm { padding: 0.35rem 0.7rem; font-size: var(--text-sm); }
.draft-btn-ghost {
  padding: 0.35rem 0.7rem; font: inherit; font-size: var(--text-sm);
  background: transparent; color: var(--text-muted, var(--text-faint));
  border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer;
}
.draft-btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
/* BT-008 P2 patch8: the advisor's current thumbs vote, highlighted. */
.draft-btn-ghost--active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* =========================================================================
   BT-008 Phase 2 patch10
   ========================================================================= */

/* D1.5: nav auth control (Sign in / username · Sign out). margin-left:auto
   pushes it (and the theme toggle after it) to the right of the nav. */
.nav-auth { margin-left: auto; font-size: var(--text-sm); color: var(--text-faint); white-space: nowrap; }
.nav-auth a { color: var(--accent); }
.nav-auth__user { color: var(--text); font-weight: 600; }
.nav-drawer .nav-auth { margin-left: 0; }

/* D6: platform-native post mockups on the draft detail view. Sized like a real
   feed post (max ~420px) so reviewers approve the audience view, not metadata. */
.mockup {
  max-width: 420px; width: 100%; align-self: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm);
}
.mockup__bar { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3); }
.mockup__avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), var(--surface-muted));
}
.mockup__handle { font-weight: 600; font-size: var(--text-sm); color: var(--text); }
.mockup__pagecol { display: flex; flex-direction: column; line-height: 1.2; }
.mockup__page { font-weight: 600; font-size: var(--text-sm); color: var(--text); }
.mockup__meta { font-size: var(--text-xs); color: var(--text-faint); }
.mockup__media { width: 100%; background: var(--surface-muted); overflow: hidden; }
.mockup--ig .mockup__media { aspect-ratio: 1 / 1; }
.mockup--fb .mockup__media { aspect-ratio: 1.91 / 1; }
.mockup__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mockup__media-empty {
  width: 100%; height: 100%; min-height: 160px; display: flex; align-items: center;
  justify-content: center; text-align: center; color: var(--text-faint);
  font-size: var(--text-sm); padding: var(--space-3);
}
/* faded interaction row -- visual only, no functionality. */
.mockup__icons { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-3) 0; color: var(--text); opacity: 0.45; }
.mockup__icons svg { width: 22px; height: 22px; }
.mockup__caption { padding: var(--space-2) var(--space-3); font-size: var(--text-sm); color: var(--text); line-height: 1.5; white-space: pre-wrap; }
.mockup__tags { padding: 0 var(--space-3) var(--space-3); font-size: var(--text-sm); color: var(--accent); }
.mockup__tags-inline { color: var(--accent); }
.mockup__fbactions { display: flex; justify-content: space-around; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-top: 1px solid var(--border); color: var(--text-faint); font-size: var(--text-sm); opacity: 0.7; }

/* D7: uniform queue cards. Square cover-cropped media, copy clamped to ~4
   lines, pills pinned top / actions pinned bottom -> every card same height.
   These rules come AFTER the base .draft-card rules so they win. Detail view
   does NOT use .draft-card, so its full content stays uncapped. */
.draft-card__media { aspect-ratio: 1 / 1; }
.draft-card__body { flex: 1 1 auto; }
.draft-card__copy {
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden; min-height: calc(1.5em * 4);
}
.draft-card__actions { margin-top: auto; }

/* =========================================================================
   BT-008 Phase 2 patch11
   ========================================================================= */

/* D15a/c: right cluster (theme icon + auth button); auth is rightmost. */
.nav-right { display: flex; align-items: center; gap: var(--space-3); flex: 0 0 auto; }

/* D15b: icon-only theme toggle (no "Theme" word) -> square button. */
.theme-toggle--icon { padding: 6px; gap: 0; }

/* D15c: Sign in / Sign out styled as a button (was plain link text). */
.nav-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none;
  font: 500 13px/1 var(--font-sans); white-space: nowrap;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--surface-muted); }
.nav-auth { font-size: var(--text-sm); color: var(--text-faint); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.nav-auth__user { color: var(--text); font-weight: 600; }

/* D16: drawer footer pinned to the bottom -- theme toggle then Sign in/out. */
.nav-drawer-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-3); }
.nav-drawer-foot .nav-btn { justify-content: center; }

/* D17: detail view split -- post mockup beside Approval Context on desktop,
   stacked on mobile. History + forms stay full-width below (own blocks). */
.detail-split { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: var(--space-5); align-items: start; }
@media (max-width: 767px) { .detail-split { grid-template-columns: 1fr; } }

/* D20: reserve a fixed 2-line zone for the pill row so a wrapped angle pill
   doesn't push the rest of the card down (grid baseline shift). Preserves the
   pill text (no clip of the 2nd line, unlike a 1-line overflow:hidden). */
.draft-card__pills { min-height: 3.1rem; align-items: flex-start; align-content: flex-start; }

/* =========================================================================
   BT-008.5 -- Modify -> auto-regenerate (revision lineage)
   ========================================================================= */

/* Refinement 1: the detail right column stacks Approval Context + Decision
   History and scrolls (desktop) if it outgrows the mockup. Mobile flows. */
.detail-split__col { display: flex; flex-direction: column; gap: var(--space-4); }
/* patch12 (D22): on desktop the right column is a fixed-height box split 50/50
   between Approval Context (top) and Decision History (bottom). Each CARD scrolls
   internally on overflow (flex:1 + min-height:0 + overflow-y on the card), with
   its uppercase header pinned (sticky) so it stays visible while the body
   scrolls. Mobile (below) is untouched: cards flow at natural heights. */
/* patch19 (Item 1): header + scrolling-body structure REPLACES patch18's sticky
   header (which let content peek above the header before the sticky caught up).
   The h3 is anchored by normal flow at the card top with a bottom border; the
   .card__scroll-body scrolls beneath it -- no sticky positioning, no peek. These
   base rules apply at ALL widths; the desktop media query below adds the fixed
   height + flex sizing that drives the internal scroll (mobile has no height, so
   nothing scrolls and the cards flow at natural heights). */
.detail-split__col--scroll > .card {
  display: flex; flex-direction: column; overflow: hidden; padding: 0;
}
.detail-split__col--scroll > .card > .brief-card__section-title {
  margin: 0;
  padding: var(--space-3) var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-split__col--scroll > .card > .card__scroll-body {
  overflow-y: auto;
  padding: var(--space-2) var(--space-3) var(--space-3);
  scrollbar-width: none;                 /* Firefox */
}
.detail-split__col--scroll > .card > .card__scroll-body::-webkit-scrollbar {
  display: none;                         /* Safari/Chrome */
}

@media (min-width: 768px) {
  /* Desktop: fixed-height column split between the two cards; each card's BODY
     scrolls internally under its anchored header. */
  .detail-split__col--scroll { height: calc(100vh - 200px); }
  .detail-split__col--scroll > .card { flex: 1 1 0; min-height: 0; }
  .detail-split__col--scroll > .card > .card__scroll-body { flex: 1 1 0; min-height: 0; }
}

/* patch17 (Item 4): center the marketing detail view within the page container
   (its 56rem column otherwise sits left-aligned inside the wider container). */
.marketing-detail { width: 100%; max-width: 56rem; margin-inline: auto; }

/* patch19 (Item 3): the considered-image alternatives as a scannable vertical
   list -- PICKED in accent, rejected faint. */
.candidates-list {
  list-style: none; padding: 0; margin: var(--space-1) 0 0;
  display: flex; flex-direction: column; gap: var(--space-1);
}
.candidates-list li { padding-left: var(--space-2); line-height: 1.4; }
.candidate-picked { color: var(--accent); }
.candidate-rejected { color: var(--text-faint); }

/* "AI" tag on the synthesized regeneration entry in decision history. */
.draft-pill-ai {
  display: inline-block; padding: 0 6px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.03em;
}

/* Queue card revision-lineage pills (extend .brief-pill). */
.draft-pill-resolved { background: var(--surface-muted); color: var(--text-faint); border-color: var(--border); }
.draft-pill-attention { background: var(--tone-cautious-soft); color: var(--tone-cautious); border-color: var(--tone-cautious); font-weight: 600; }

/* A resolved original (already regenerated) is faded -- the eye goes to the
   unresolved drafts above it in the Needs Revision tab. */
.draft-card--resolved { opacity: 0.62; }

/* =========================================================================
   BT-008.8 Slice B -- user management table
   ========================================================================= */
.users-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.users-table th, .users-table td {
  text-align: left; padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
.users-table th {
  color: var(--text-faint); font-weight: 600; text-transform: uppercase;
  font-size: var(--text-xs); letter-spacing: 0.04em;
}
.users-row--disabled { opacity: 0.55; }
.users-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.login-input--sm { padding: 4px var(--space-2); font-size: var(--text-sm); max-width: 12rem; }

/* =========================================================================
   BT-008.8 Slice C -- kill-switch pill + audit table
   ========================================================================= */
.publish-status { display: inline-flex; align-items: center; gap: var(--space-2); }
.publish-pill {
  display: inline-block; padding: 2px var(--space-2); border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.03em; border: 1px solid transparent;
}
.publish-pill--on { background: rgba(47, 138, 91, 0.12); color: #2f8a5b; border-color: #2f8a5b; }
.publish-pill--off { background: var(--tone-alert-soft); color: var(--tone-alert); border-color: var(--tone-alert); }
.audit-table td code { font-size: var(--text-xs); }
