/* ============================================================================
   Organicaly AI design system — the single stylesheet for every dashboard page.

   Identity: calm-density operator cockpit. Zinc near-black surfaces (dark is
   default), paper-white client-presentation light theme, ONE emerald signal
   color, ink-colored primary buttons, hairline borders + luminance elevation
   (shadows only on floating layers), Inter with cv01/ss03/zero, tabular
   numerals on every number.

   Load order per page:
     <link rel="stylesheet" href="/static/theme.css">
     ...page's own small <style> (tokens only, no raw hexes)...

   Component vocabulary (all restyle-safe for JS-generated markup):
     shell:  .app-sidebar .app-topbar .app-main .side-nav .nav-badge
     text:   .page-head .page-title .page-sub .mono .term kbd.ui-kbd
     cards:  .card .card-head .card-title .section .section-title .t-ico
     kpis:   .kpi-grid .kpi (.label .value .delta .mini .spark)
     tables: .table .table-wrap
     forms:  global input/select/textarea, .field label, .form-grid
     btns:   .btn (.primary .accent .danger .ghost .mini .lg .block)
     status: .badge (.ok .warn .err .info .neutral + tolerant default)
             .impact .effort-chip .msg (.ok .err) .dot (.ok .warn .bad) .pill
     misc:   .empty .spinner .progress .skeleton .donut .segbar .rank
             .explainer details.howto .divider .tip .banner
             .selection-bar .sticky-actions .step-rail
     home:   .home-hero .review-grid .review-card .channel-grid .channel-card
             .feed .feed-item
   ========================================================================== */

/* ── Tokens: dark (default) ────────────────────────────────────────────── */
:root {
  color-scheme: dark;

  /* Background ladder — zinc near-black; sidebar sits BELOW the page */
  --bg-page:    #09090b;
  --bg-surface: #101012;
  --bg-raised:  #17171a;
  --bg-overlay: #1d1d21;
  --bg-inset:   #0d0d0f;              /* wells, code blocks, table headers */
  --bg-sidebar: #070708;
  --bg-hover:   rgba(255,255,255,.045);
  --bg-active:  rgba(255,255,255,.08);
  --bg-selected: rgba(52,211,153,.10);

  /* Borders — alpha-white hairlines composite on any layer */
  --border-subtle:  rgba(255,255,255,.06);
  --border-default: rgba(255,255,255,.10);
  --border-strong:  rgba(255,255,255,.16);

  /* Ink ladder */
  --text-primary:   #f7f8f8;
  --text-secondary: #b9bdc7;
  --text-muted:     #7d828d;
  --text-disabled:  #4e525b;

  /* Signal accent — emerald. Text on solid accent is near-black, never white. */
  --accent:        #10b981;
  --accent-hover:  #34d399;
  --accent-active: #0ea371;
  --accent-fg:     #34d399;
  --accent-ink:    #05130c;           /* text color ON accent-solid surfaces */
  --accent-subtle: rgba(52,211,153,.11);
  --accent-border: rgba(52,211,153,.40);
  --accent-glow:   rgba(52,211,153,.30);

  /* Ink primary button (white on dark / near-black on light) */
  --btn-ink-bg:    #fafafa;
  --btn-ink-fg:    #101013;
  --btn-ink-hover: #ffffff;

  /* Status */
  --success-fg: #4cc38a; --success-bg: rgba(76,195,138,.12); --success-border: rgba(76,195,138,.35);
  --warning-fg: #f5b14d; --warning-bg: rgba(245,177,77,.12); --warning-border: rgba(245,177,77,.35);
  --danger-fg:  #ff7b72; --danger-bg:  rgba(255,123,114,.12); --danger-border: rgba(255,123,114,.35);
  --danger-solid: #dc3d33; --danger-solid-hover: #b42318;
  --info-fg:    #52aef0; --info-bg:    rgba(82,174,240,.12);  --info-border:   rgba(82,174,240,.35);
  --violet-fg:  #a78bfa; --violet-bg:  rgba(167,139,250,.12); --violet-border: rgba(167,139,250,.35);

  /* Charts */
  --chart-1: #34d399; --chart-2: #f5a54a; --chart-3: #52aef0;
  --chart-4: #a78bfa; --chart-5: #f2699c; --chart-6: #8b9098;
  --chart-grid: rgba(255,255,255,.06);

  /* Geometry */
  --radius-sm: 5px; --radius-md: 8px; --radius-lg: 10px;
  --radius-xl: 12px; --radius-full: 9999px;

  /* Elevation — floating layers only */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 1px 1px rgba(0,0,0,.06), 0 4px 8px -4px rgba(0,0,0,.3), 0 12px 20px -8px rgba(0,0,0,.35);
  --shadow-lg: 0 1px 1px rgba(0,0,0,.08), 0 8px 16px -4px rgba(0,0,0,.35), 0 24px 40px -8px rgba(0,0,0,.45);
  --shadow-overlay: 0 0 0 1px rgba(255,255,255,.07), 0 16px 48px rgba(0,0,0,.55);
  --focus-ring: 0 0 0 2px var(--bg-page), 0 0 0 4px var(--accent);

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Layout */
  --sidebar-w: 244px;
  --topbar-h: 54px;
  --content-max: 1440px;
  --content-pad: 28px;

  /* Motion */
  --t-fast: 120ms ease-out;
  --t-base: 180ms ease-out;
}

/* ── Tokens: light (client-presentation mode) ──────────────────────────── */
[data-theme="light"] {
  color-scheme: light;

  --bg-page:    #fafaf9;
  --bg-surface: #ffffff;
  --bg-raised:  #ffffff;
  --bg-overlay: #ffffff;
  --bg-inset:   #f4f4f2;
  --bg-sidebar: #f6f6f4;
  --bg-hover:   rgba(23,23,26,.04);
  --bg-active:  rgba(23,23,26,.07);
  --bg-selected: rgba(5,150,105,.08);

  --border-subtle:  rgba(23,23,26,.07);
  --border-default: rgba(23,23,26,.12);
  --border-strong:  rgba(23,23,26,.20);

  --text-primary:   #17171a;
  --text-secondary: #4f5560;
  --text-muted:     #71767f;
  --text-disabled:  #a6aab2;

  --accent:        #059669;
  --accent-hover:  #047857;
  --accent-active: #065f46;
  --accent-fg:     #047857;
  --accent-ink:    #ffffff;
  --accent-subtle: rgba(5,150,105,.09);
  --accent-border: rgba(5,150,105,.35);
  --accent-glow:   rgba(5,150,105,.22);

  --btn-ink-bg:    #17171a;
  --btn-ink-fg:    #fafafa;
  --btn-ink-hover: #26262b;

  --success-fg: #15803d; --success-bg: #ebf9f0; --success-border: rgba(21,128,61,.3);
  --warning-fg: #b45309; --warning-bg: #fff8eb; --warning-border: rgba(180,83,9,.3);
  --danger-fg:  #b42318; --danger-bg:  #fef2f1; --danger-border: rgba(180,35,24,.3);
  --danger-solid: #d92d20; --danger-solid-hover: #b42318;
  --info-fg:    #0b6bcb; --info-bg:    #eff6ff; --info-border:   rgba(11,107,203,.3);
  --violet-fg:  #7c3aed; --violet-bg:  rgba(124,58,237,.08); --violet-border: rgba(124,58,237,.3);

  --chart-1: #059669; --chart-2: #d97706; --chart-3: #0369a1;
  --chart-4: #7c3aed; --chart-5: #db2777; --chart-6: #64748b;
  --chart-grid: rgba(23,23,26,.07);

  --shadow-sm: 0 1px 2px rgba(23,23,26,.05);
  --shadow-md: 0 1px 1px rgba(23,23,26,.03), 0 4px 8px -4px rgba(23,23,26,.06), 0 12px 20px -8px rgba(23,23,26,.08);
  --shadow-lg: 0 1px 1px rgba(23,23,26,.04), 0 8px 16px -4px rgba(23,23,26,.08), 0 24px 40px -8px rgba(23,23,26,.12);
  --shadow-overlay: 0 0 0 1px rgba(23,23,26,.05), 0 20px 48px rgba(23,23,26,.16);
  --focus-ring: 0 0 0 2px #ffffff, 0 0 0 4px var(--accent);
}

/* ── Legacy variable aliases ───────────────────────────────────────────────
   Pre-redesign pages and JS-emitted inline styles reference these names;
   keep them pointed at the current ramp forever. */
:root, [data-theme="light"] {
  --bg: var(--bg-page);
  --surface: var(--bg-surface);
  --panel: var(--bg-surface);
  --border: var(--border-default);
  --text: var(--text-primary);
  --muted: var(--text-secondary);
  --blue: var(--accent-fg);
  --green: var(--success-fg);
  --yellow: var(--warning-fg);
  --red: var(--danger-fg);
  --purple: var(--violet-fg);
}

/* ── Base ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  font-feature-settings: "cv01", "ss03", "zero", "liga";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent-fg); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
::selection { background: rgba(52,211,153,.28); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.mono { font-family: var(--font-mono); font-size: 12px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
table, .kpi .value, .nav-badge, .tabs .count { font-variant-numeric: tabular-nums; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(128,140,160,.25) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(128,140,160,.25); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(128,140,160,.45); }
*::-webkit-scrollbar-track { background: transparent; }

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

/* ── App shell ─────────────────────────────────────────────────────────────
   ui.js builds: <aside class="app-sidebar">…  <header class="app-topbar">…
   Pages provide: <body data-shell="seo" data-title="Hub"><main class="app-main"> */
body[data-shell] { padding-left: var(--sidebar-w); }
.app-main {
  max-width: var(--content-max);
  padding: calc(var(--topbar-h) + 26px) var(--content-pad) 64px;
  margin: 0 auto;
}
/* Staggered page entrance — quick, subtle, once per navigation */
@media (prefers-reduced-motion: no-preference) {
  .app-main > * { animation: page-rise .35s cubic-bezier(.16,1,.3,1) backwards; }
  .app-main > *:nth-child(2) { animation-delay: .03s; }
  .app-main > *:nth-child(3) { animation-delay: .06s; }
  .app-main > *:nth-child(4) { animation-delay: .09s; }
  .app-main > *:nth-child(n+5) { animation-delay: .12s; }
}
@keyframes page-rise { from { opacity: 0; transform: translateY(8px); } }

/* Sidebar — one luminance step below the page; content leads */
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 90;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 16px 12px;
}
.side-brand .mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  color: var(--accent-ink);
}
[data-theme="light"] .side-brand .mark { color: #05130c; }
.side-brand .mark svg { width: 15px; height: 15px; display: block; }
.side-brand .word { line-height: 1.15; }
.side-brand .word b { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; display: block; }
.side-brand .word small { font-size: 10.5px; color: var(--text-muted); font-weight: 450; }

/* Client switcher — the agency "acting as" context, top of the sidebar.
   brand_switcher.js mounts <div id="brand-switcher"> into #brand-slot. */
#brand-slot { padding: 2px 10px 10px; }
#brand-switcher { display: flex; flex-direction: column; gap: 4px; }
#brand-switcher .bs-label {
  font-size: 10px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted); padding-left: 2px;
}
#brand-switcher select {
  width: 100%; height: 32px; padding: 0 26px 0 10px;
  background-color: var(--bg-raised); color: var(--text-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  font-family: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d828d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  transition: border-color var(--t-fast);
}
#brand-switcher select:hover { border-color: var(--border-strong); }
[data-theme="light"] #brand-switcher select { background-color: #ffffff; }

.side-nav { flex: 1; overflow-y: auto; padding: 2px 10px 10px; }
.side-nav .group {
  font-size: 10px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-disabled); padding: 16px 8px 5px;
}
.side-nav a {
  display: flex; align-items: center; gap: 9px;
  height: 30px; padding: 0 8px; margin: 1px 0;
  border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  text-decoration: none; position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
.side-nav a:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.side-nav a.active { background: var(--bg-active); color: var(--text-primary); }
.side-nav a.active .ico { color: var(--accent-fg); }
.side-nav a .ico { width: 16px; height: 16px; flex: none; color: var(--text-muted); display: inline-flex; }
.side-nav a .ico svg { width: 16px; height: 16px; }
.side-nav a .nav-badge {
  margin-left: auto; min-width: 18px; text-align: center;
  font-size: 10.5px; font-weight: 600;
  color: var(--text-secondary); background: var(--bg-active);
  border-radius: var(--radius-full); padding: 1px 6px;
}
.side-nav a .nav-badge:empty { display: none; }
.side-nav a.active .nav-badge { color: var(--accent-fg); background: var(--accent-subtle); }
/* Nested sub-pages under the active section */
.side-nav .subtree { margin: 1px 0 4px; padding-left: 16px; position: relative; }
.side-nav .subtree::before {
  content: ""; position: absolute; left: 15px; top: 4px; bottom: 4px;
  width: 1px; background: var(--border-default);
}
.side-nav .subtree a { height: 28px; font-size: 12.5px; padding-left: 12px; color: var(--text-muted); }
.side-nav .subtree a:hover { color: var(--text-primary); }
.side-nav .subtree a.active { background: transparent; color: var(--accent-fg); font-weight: 600; }
.side-nav .subtree a.active::before {
  content: ""; position: absolute; left: 15px; width: 1px; height: 16px;
  margin-top: 2px; background: var(--accent-fg);
}
.side-foot {
  border-top: 1px solid var(--border-subtle);
  padding: 10px; display: flex; flex-direction: column; gap: 1px;
}
.side-foot a {
  display: flex; align-items: center; gap: 9px; height: 28px; padding: 0 8px;
  border-radius: var(--radius-md); font-size: 12.5px; color: var(--text-muted);
  text-decoration: none; transition: background var(--t-fast), color var(--t-fast);
}
.side-foot a:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.side-foot a.logout:hover { color: var(--danger-fg); background: var(--danger-bg); }
.side-foot a .ico { width: 15px; height: 15px; display: inline-flex; color: currentColor; }
.side-foot a .ico svg { width: 15px; height: 15px; }
/* Signed-in user chip — non-interactive context row under the footer links */
.user-chip {
  display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 8px;
  font-size: 12px; color: var(--text-muted);
}
.user-chip .user-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .user-chip-badge {
  flex: none; padding: 1px 6px; border-radius: var(--radius-full);
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  background: var(--warning-bg); color: var(--warning-fg);
  border: 1px solid var(--warning-border);
}

/* Topbar — frosted, spans the content column (glass allowed on chrome only) */
.app-topbar {
  position: fixed; top: 0; right: 0; left: var(--sidebar-w); z-index: 80;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--content-pad);
  background: color-mix(in srgb, var(--bg-page) 82%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  backdrop-filter: blur(10px) saturate(130%);
  border-bottom: 1px solid var(--border-subtle);
}
.app-topbar .crumb { display: flex; align-items: baseline; gap: 8px; min-width: 0; overflow: hidden; }
.app-topbar .crumb .sect { color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }
.app-topbar .crumb .sep { color: var(--text-disabled); font-size: 12px; }
.app-topbar .crumb .here {
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-topbar .spacer { flex: 1; }
/* Active-client chip — wrong-brand safety: always-visible context */
#topbar-client {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  background: var(--accent-subtle); color: var(--accent-fg);
  border: 1px solid transparent; border-radius: var(--radius-full);
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
#topbar-client:empty { display: none; }
#topbar-client::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: none;
}
/* Staging-mode pill — quiet reminder that live pushes are disabled */
.user-staging-pill {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px;
  background: var(--warning-bg); color: var(--warning-fg);
  border: 1px solid var(--warning-border); border-radius: var(--radius-full);
  font-size: 11.5px; font-weight: 550; white-space: nowrap;
}
/* Staging users never see live-push controls */
html[data-user-role="staging"] [data-live-push] { display: none !important; }
#topbar-actions { display: flex; align-items: center; gap: 8px; }
#topbar-actions:empty { display: none; }
.topbar-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 10px;
  background: transparent; border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); cursor: pointer;
  color: var(--text-muted); font-family: inherit; font-size: 12.5px;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.topbar-btn:hover { color: var(--text-primary); border-color: var(--border-strong); background: var(--bg-hover); }
.topbar-btn .ico { width: 14px; height: 14px; display: inline-flex; }
.topbar-btn .ico svg { width: 14px; height: 14px; }
.topbar-btn.icon-only { width: 30px; padding: 0; justify-content: center; }
kbd.ui-kbd {
  background: var(--bg-raised); border: 1px solid var(--border-default);
  border-bottom-width: 2px; border-radius: 4px; padding: 0 5px;
  font-size: 10.5px; font-family: var(--font-mono); color: var(--text-secondary);
}

/* Mobile: sidebar becomes a drawer */
.menu-btn { display: none; }
#shell-scrim {
  display: none; position: fixed; inset: 0; z-index: 85;
  background: rgba(0,0,0,.55);
}
@media (max-width: 980px) {
  body[data-shell] { padding-left: 0; }
  .app-topbar { left: 0; }
  .app-sidebar { transform: translateX(-100%); transition: transform 200ms cubic-bezier(.16,1,.3,1); z-index: 95; }
  .app-sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  #shell-scrim.show { display: block; }
  .menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; flex: none;
    background: none; border: 1px solid var(--border-default); border-radius: var(--radius-md);
    color: var(--text-secondary); cursor: pointer; font-size: 15px;
  }
}
@media (max-width: 700px) {
  .app-topbar { gap: 8px; padding: 0 14px; }
  .app-topbar .crumb .sect, .app-topbar .crumb .sep { display: none; }
  #palette-btn > span:not(.ico), #palette-btn kbd { display: none; }
  #palette-btn { width: 30px; padding: 0; justify-content: center; }
  .app-main { padding-left: 16px; padding-right: 16px; }
}

/* ── Page header ───────────────────────────────────────────────────────── */
.page-head { margin-bottom: 22px; }
.page-title {
  font-size: 24px; font-weight: 650; letter-spacing: -0.02em; color: var(--text-primary);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
/* Soft vertical fade on plain-text titles */
.page-title > span:only-child, .page-title:not(:has(*)) {
  background: linear-gradient(180deg, var(--text-primary), color-mix(in srgb, var(--text-primary) 66%, transparent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.page-sub { color: var(--text-secondary); font-size: 13px; margin-top: 6px; max-width: 860px; line-height: 1.55; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Cards & sections ──────────────────────────────────────────────────── */
.card, .section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  margin-bottom: 16px;
  transition: border-color var(--t-base);
}
[data-theme="light"] .card, [data-theme="light"] .section { box-shadow: var(--shadow-sm); }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--border-strong); text-decoration: none; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-title, .section-title {
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary);
}
.card-title .hint, .section-title .hint {
  color: var(--text-muted); font-weight: 400; font-size: 12px; margin-left: 8px; letter-spacing: 0;
}
.divider { border: none; border-top: 1px solid var(--border-subtle); margin: 14px 0; }
/* Icon tile for card titles — one shared treatment */
.t-ico {
  width: 26px; height: 26px; border-radius: var(--radius-md); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-inset); border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}
.t-ico svg { width: 14px; height: 14px; }

/* ── KPI cards ─────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl); padding: 14px 16px; min-width: 0;
  transition: border-color var(--t-base);
}
.kpi:hover { border-color: var(--border-strong); }
[data-theme="light"] .kpi { box-shadow: var(--shadow-sm); }
.kpi .label {
  color: var(--text-muted); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  display: flex; align-items: center; gap: 5px;
}
.kpi .value {
  font-size: 24px; font-weight: 650; letter-spacing: -0.02em; margin-top: 6px;
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.kpi .delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; margin-top: 7px; font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 2px 8px; border-radius: var(--radius-full);
}
.kpi .delta:empty { display: none; }
.kpi .delta.up { color: var(--success-fg); background: var(--success-bg); }
.kpi .delta.down { color: var(--danger-fg); background: var(--danger-bg); }
.kpi .delta.flat { color: var(--text-muted); background: var(--bg-active); font-weight: 500; }
.kpi .mini { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.kpi .spark { margin-top: 8px; }
.kpi .spark svg { display: block; width: 100%; }
.kpi.na .value { font-size: 12.5px; font-weight: 500; color: var(--text-muted); line-height: 1.45; margin-top: 8px; }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
.table-wrap .table { border: none; border-radius: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; padding: 8px 12px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted); background: var(--bg-inset);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle; font-variant-numeric: tabular-nums;
}
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.table tbody tr:last-child td { border-bottom: none; }
.table td.r, .table th.r { text-align: right; }

/* ── Buttons ───────────────────────────────────────────────────────────────
   Default = quiet secondary. Variants: .primary (ink) .accent .danger .ghost
   .mini .lg .block */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 32px; padding: 0 14px;
  background: var(--bg-raised); color: var(--text-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  font-family: inherit; font-size: 12.5px; font-weight: 550; letter-spacing: 0;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.btn:hover { border-color: var(--border-strong); background: var(--bg-active); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--btn-ink-bg); color: var(--btn-ink-fg);
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.btn.primary:hover { background: var(--btn-ink-hover); border-color: transparent; }
.btn.primary:active { transform: scale(.98); box-shadow: none; }
.btn.accent {
  background: var(--accent); color: var(--accent-ink);
  border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 1px 2px rgba(0,0,0,.2);
}
.btn.accent:hover { background: var(--accent-hover); border-color: transparent; }
.btn.danger { color: var(--danger-fg); border-color: var(--danger-border); background: transparent; }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger-fg); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn.mini { height: 26px; padding: 0 10px; font-size: 11.5px; border-radius: var(--radius-sm); }
.btn.lg { height: 38px; padding: 0 18px; font-size: 13.5px; border-radius: var(--radius-lg); }
.btn.block { width: 100%; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
input[type="text"], input[type="number"], input[type="password"], input[type="email"],
input[type="url"], input[type="search"], input[type="date"], input[type="time"],
input[type="datetime-local"], select, textarea {
  background: var(--bg-inset); color: var(--text-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  padding: 7px 11px; font-family: inherit; font-size: 13px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:not([type="checkbox"]):not([type="radio"]):hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-disabled); }
textarea { resize: vertical; line-height: 1.5; }
select { cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); cursor: pointer; }
label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field .help { font-size: 11px; color: var(--text-muted); font-weight: 400; }
/* Shared form grid (promoted from per-page .grid implementations) */
.form-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid .half { grid-column: span 2; }
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .half { grid-column: 1 / -1; }
}
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* ── Badges, chips, status ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 10.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  background: var(--bg-active); color: var(--text-secondary);
  border: 1px solid transparent; white-space: nowrap;
}
.badge.ok    { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-border); }
.badge.warn  { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-border); }
.badge.err   { background: var(--danger-bg);  color: var(--danger-fg); border-color: var(--danger-border); }
.badge.info  { background: var(--info-bg);    color: var(--info-fg); border-color: var(--info-border); }
.badge.neutral { background: var(--bg-active); color: var(--text-secondary); border-color: var(--border-default); }
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: var(--radius-full); font-size: 11px; font-weight: 550;
  background: var(--bg-active); color: var(--text-secondary);
}
.impact {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  vertical-align: 1px;
}
.impact.critical { background: var(--danger-bg); color: var(--danger-fg); }
.impact.high { background: var(--success-bg); color: var(--success-fg); }
.impact.medium { background: var(--warning-bg); color: var(--warning-fg); }
.impact.supporting { background: var(--bg-active); color: var(--text-secondary); }
.effort-chip {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 10px; background: var(--info-bg); color: var(--info-fg); letter-spacing: .03em;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-disabled); display: inline-block; flex: none; }
.dot.ok { background: var(--success-fg); }
.dot.warn { background: var(--warning-fg); }
.dot.bad { background: var(--danger-fg); }

/* Inline message banners (JS-generated on several pages) */
.msg {
  padding: 9px 12px; border-radius: var(--radius-lg); font-size: 12.5px;
  border: 1px solid var(--border-default); background: var(--bg-raised); color: var(--text-secondary);
  margin: 8px 0;
}
.msg.ok { background: var(--success-bg); border-color: var(--success-border); color: var(--success-fg); }
.msg.err { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-fg); }
.msg:empty { display: none; }
/* Setup / info banner */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-lg); font-size: 12.5px;
  border: 1px solid var(--border-default); background: var(--bg-surface);
  color: var(--text-secondary); line-height: 1.55; margin-bottom: 14px;
}
.banner.info { border-color: var(--info-border); background: var(--info-bg); color: var(--text-primary); }
.banner.warn { border-color: var(--warning-border); background: var(--warning-bg); color: var(--text-primary); }

/* ── Feedback: empty states, spinners, progress, skeletons ─────────────── */
.empty { text-align: center; color: var(--text-muted); padding: 32px 16px; font-size: 12.5px; line-height: 1.6; }
.empty h3 { font-size: 13.5px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.empty p { max-width: 420px; margin: 0 auto 12px; }
.empty .btn { margin-top: 2px; }
.empty:not(:has(.spinner)):not(:has(.big))::before {
  content: ""; display: block; width: 36px; height: 36px; margin: 0 auto 10px;
  border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  background: var(--bg-active);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d828d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 12h-6l-2 3h-4l-2-3H2'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 17px;
}
.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid var(--border-strong); border-top-color: var(--accent-fg);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress {
  height: 6px; border-radius: var(--radius-full); background: var(--bg-active); overflow: hidden;
}
.progress > div {
  height: 100%; border-radius: var(--radius-full);
  background: var(--accent);
  transition: width 300ms ease;
  position: relative; overflow: hidden;
}
.progress > div::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent);
  animation: shimmer 1.6s linear infinite;
}
.skeleton {
  position: relative; overflow: hidden; border-radius: var(--radius-md);
  background: var(--bg-active); color: transparent !important; user-select: none;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* Score donut: <div class="donut ok" style="--p:87"><b>87</b><span>health</span></div> */
.donut {
  --p: 0; --donut-size: 92px; --donut-color: var(--accent-fg);
  width: var(--donut-size); height: var(--donut-size); border-radius: 50%; flex: none;
  background:
    radial-gradient(closest-side, var(--bg-surface) 79%, transparent 80% 100%),
    conic-gradient(var(--donut-color) calc(var(--p) * 1%), var(--bg-active) 0);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.donut b { font-size: calc(var(--donut-size) * .26); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.donut span { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.donut.ok { --donut-color: var(--success-fg); }
.donut.warn { --donut-color: var(--warning-fg); }
.donut.bad { --donut-color: var(--danger-fg); }

/* Segmented distribution bar */
.segbar {
  display: flex; height: 8px; border-radius: var(--radius-full); overflow: hidden;
  background: var(--bg-active);
}
.segbar i { display: block; height: 100%; }
.segbar i.ok { background: var(--success-fg); }
.segbar i.warn { background: var(--warning-fg); }
.segbar i.bad { background: var(--danger-fg); }
.segbar i.info { background: var(--info-fg); }
.segbar i.neutral { background: var(--text-disabled); }

/* Numbered medallion (rank / step number) — flat accent tile */
.rank {
  width: 22px; height: 22px; border-radius: var(--radius-md); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-subtle); border: 1px solid var(--accent-border);
  color: var(--accent-fg); font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px; overflow-x: auto;
}
.tabs .tab, .tabs button, .tabs a {
  appearance: none; background: none; border: none; border-bottom: 2px solid transparent;
  padding: 8px 12px 9px; margin-bottom: -1px;
  font-family: inherit; font-size: 12.5px; font-weight: 550; color: var(--text-muted);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.tabs .tab:hover, .tabs button:hover, .tabs a:hover { color: var(--text-primary); text-decoration: none; }
.tabs .tab.active, .tabs button.active, .tabs a.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.tabs .tab.active .count, .tabs button.active .count, .tabs a.active .count { background: var(--accent-subtle); color: var(--accent-fg); }
.tabs .count {
  font-size: 10.5px; font-variant-numeric: tabular-nums; font-weight: 600;
  background: var(--bg-active); color: var(--text-secondary);
  border-radius: var(--radius-full); padding: 1px 6px; margin-left: 5px;
}

/* Sub-nav fallback (legacy .subnav[data-subnav] pages) */
.subnav { display: flex; gap: 2px; margin: 0 0 18px; font-size: 12.5px; flex-wrap: wrap; }
.subnav a {
  color: var(--text-muted); text-decoration: none; padding: 5px 11px;
  border-radius: var(--radius-md); font-weight: 500;
}
.subnav a:hover { color: var(--text-primary); background: var(--bg-hover); text-decoration: none; }
.subnav a.active { color: var(--accent-fg); background: var(--accent-subtle); font-weight: 600; }

/* ── Plain-language layer ──────────────────────────────────────────────── */
.term { border-bottom: 1px dotted var(--text-muted); cursor: help; text-decoration: none; }
/* Accessible CSS tooltip: <span class="tip" data-tip="…">term</span> */
.tip { position: relative; border-bottom: 1px dotted var(--text-muted); cursor: help; }
.tip:hover::after, .tip:focus-visible::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 7px); transform: translateX(-50%);
  z-index: 150; width: max-content; max-width: 260px;
  background: var(--bg-overlay); color: var(--text-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 7px 10px; font-size: 11.5px; font-weight: 450; line-height: 1.5;
  text-transform: none; letter-spacing: 0; white-space: normal;
}
.explainer {
  background: var(--accent-subtle); border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg); padding: 12px 14px; margin: 10px 0 14px;
  font-size: 12.5px; line-height: 1.55; color: var(--text-primary);
}
.explainer .x-row { margin: 3px 0; }
.explainer .x-label {
  display: inline-block; min-width: 92px; color: var(--accent-fg);
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.explainer .x-muted { color: var(--text-secondary); }
details.howto {
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  margin-bottom: 16px; background: var(--bg-surface);
}
details.howto > summary {
  cursor: pointer; padding: 10px 14px; font-size: 12.5px; color: var(--text-secondary);
  list-style: none; font-weight: 550; display: flex; align-items: center; gap: 8px;
  transition: color var(--t-fast);
}
details.howto > summary:hover { color: var(--text-primary); }
details.howto > summary::-webkit-details-marker { display: none; }
details.howto > summary::before {
  content: ""; width: 14px; height: 14px; flex: none;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E") center/contain no-repeat;
}
details.howto[open] > summary { border-bottom: 1px solid var(--border-subtle); }
details.howto .howto-body { padding: 10px 14px 12px; font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; }
details.howto .howto-body ol { margin: 6px 0 6px 18px; padding: 0; }
details.howto .howto-body li { margin: 4px 0; }
details.howto .howto-body b { color: var(--text-primary); }

/* ── Bulk selection ────────────────────────────────────────────────────── */
/* Gmail-style truthful-selection banner:
   <div class="selection-bar"><b>12 selected</b><span>…of 480 matching</span>
     <button class="btn mini">Select all 480</button> <button class="btn mini ghost">Clear</button></div> */
.selection-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; margin: 8px 0;
  background: var(--accent-subtle); border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg); font-size: 12.5px; color: var(--text-primary);
}
.selection-bar:empty { display: none; }
.selection-bar b { font-weight: 650; }
.selection-bar span { color: var(--text-secondary); }
/* Sticky bottom action bar for long selection flows */
.sticky-actions {
  position: sticky; bottom: 12px; z-index: 40;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-top: 12px;
  background: color-mix(in srgb, var(--bg-overlay) 92%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--border-default); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

/* ── Step rail (shared stepper) ────────────────────────────────────────── */
.step-rail { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 16px; }
.step-rail .step-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 6px; border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle); background: var(--bg-surface);
  font-size: 11.5px; font-weight: 550; color: var(--text-secondary);
}
.step-rail .step-item.done { border-color: var(--success-border); color: var(--success-fg); }
.step-rail .step-item.now { border-color: var(--accent-border); color: var(--text-primary); background: var(--accent-subtle); }

/* ── Toasts ────────────────────────────────────────────────────────────── */
#ui-toasts {
  position: fixed; bottom: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; max-width: 380px;
}
.ui-toast {
  background: var(--bg-overlay); border: 1px solid var(--border-default);
  border-left: 3px solid var(--info-fg); color: var(--text-primary);
  border-radius: var(--radius-lg); padding: 10px 14px; font-size: 12.5px;
  box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start;
  animation: ui-toast-in 180ms cubic-bezier(.16,1,.3,1);
}
.ui-toast.ok { border-left-color: var(--success-fg); }
.ui-toast.err { border-left-color: var(--danger-fg); }
.ui-toast.warn { border-left-color: var(--warning-fg); }
.ui-toast .ui-toast-close {
  cursor: pointer; color: var(--text-muted); background: none; border: none;
  font-size: 13px; line-height: 1; padding: 0; margin-left: auto; font-family: inherit;
}
.ui-toast .ui-toast-close:hover { color: var(--text-primary); }
@keyframes ui-toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.ui-toast { position: relative; overflow: hidden; }
.ui-toast::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  background: currentColor; opacity: .25;
  animation: toast-count 5s linear forwards; transform-origin: left;
}
.ui-toast.warn::after { animation-duration: 8s; }
.ui-toast.err::after { display: none; }
@keyframes toast-count { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ── Confirm modal ─────────────────────────────────────────────────────── */
#ui-confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 210;
  display: flex; align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
#ui-confirm-overlay[hidden] { display: none; }
.ui-confirm {
  background: var(--bg-overlay); border: 1px solid var(--border-default);
  border-radius: 14px; width: min(440px, 92vw); padding: 20px 22px;
  color: var(--text-primary); font-size: 13px; box-shadow: var(--shadow-overlay);
  animation: ui-pop 160ms cubic-bezier(.16,1,.3,1);
}
@keyframes ui-pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.ui-confirm h3 { font-size: 14.5px; margin: 0 0 8px; }
.ui-confirm .ui-confirm-body { color: var(--text-secondary); margin-bottom: 16px; line-height: 1.5; }
.ui-confirm .ui-confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
.ui-confirm button {
  font-family: inherit; font-size: 12.5px; font-weight: 550; padding: 7px 16px;
  border-radius: var(--radius-md); cursor: pointer;
  background: var(--bg-raised); border: 1px solid var(--border-default); color: var(--text-primary);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.ui-confirm button:hover { background: var(--bg-active); border-color: var(--border-strong); }
.ui-confirm button.ui-confirm-yes { border-color: transparent; background: var(--btn-ink-bg); color: var(--btn-ink-fg); }
.ui-confirm button.ui-confirm-yes:hover { background: var(--btn-ink-hover); }
.ui-confirm button.ui-confirm-yes.danger { background: var(--danger-solid); color: #fff; }
.ui-confirm button.ui-confirm-yes.danger:hover { background: var(--danger-solid-hover); }

/* ── Busy buttons ──────────────────────────────────────────────────────── */
.ui-busy { position: relative; pointer-events: none; opacity: .6; }
.ui-busy::after {
  content: ""; display: inline-block; width: 11px; height: 11px; margin-left: 7px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite; vertical-align: -1px;
}

/* ── Command palette ───────────────────────────────────────────────────── */
#ui-palette-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 220;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 14vh;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
#ui-palette-overlay[hidden] { display: none; }
.ui-palette {
  background: var(--bg-overlay); border: 1px solid var(--border-default);
  border-radius: 14px; width: min(620px, 92vw); overflow: hidden;
  box-shadow: var(--shadow-overlay);
  animation: ui-pop 140ms cubic-bezier(.16,1,.3,1);
}
.ui-palette input {
  width: 100%; background: transparent; border: none !important; outline: none;
  border-bottom: 1px solid var(--border-subtle) !important; border-radius: 0 !important;
  color: var(--text-primary); box-shadow: none !important;
  font-size: 15px; padding: 15px 18px; font-family: inherit;
}
.ui-palette .ui-palette-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.ui-palette .ui-palette-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: var(--radius-lg); cursor: pointer; font-size: 13px; color: var(--text-primary);
  transition: background var(--t-fast);
}
.ui-palette .ui-palette-item .hint { margin-left: auto; color: var(--text-muted); font-size: 11px; font-family: var(--font-mono); }
.ui-palette .ui-palette-item.sel { background: var(--accent-subtle); box-shadow: inset 2px 0 0 var(--accent); }
.ui-palette .ui-palette-item .kind {
  font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); border: 1px solid var(--border-default);
  border-radius: var(--radius-full); padding: 1px 7px; flex: none;
}
.ui-palette .ui-palette-empty { color: var(--text-muted); text-align: center; padding: 20px; font-size: 12.5px; }
.ui-palette .ui-palette-foot {
  border-top: 1px solid var(--border-subtle); color: var(--text-muted);
  font-size: 11px; padding: 8px 14px; display: flex; gap: 14px;
}

/* ── Home (Mission Control) ────────────────────────────────────────────── */
.home-hero { margin-bottom: 20px; }
.home-hero h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
.home-hero .date { color: var(--text-muted); font-size: 12.5px; margin-top: 4px; }
.review-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
a.review-card {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl); padding: 15px 16px;
  color: inherit; text-decoration: none;
  transition: border-color var(--t-base), background var(--t-base);
}
a.review-card:hover { border-color: var(--accent-border); text-decoration: none; background: var(--bg-raised); }
[data-theme="light"] a.review-card { box-shadow: var(--shadow-sm); }
.review-card .rc-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted);
}
.review-card .rc-count { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.review-card .rc-sub { font-size: 11.5px; color: var(--text-secondary); }
.review-card .rc-go { font-size: 11.5px; color: var(--accent-fg); font-weight: 600; margin-top: 8px; }
.review-card.zero { opacity: .62; }
.review-card.zero:hover { opacity: 1; }
.review-card.attention { border-color: var(--warning-border); }
.channel-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.channel-card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl); padding: 14px 16px; min-width: 0;
}
[data-theme="light"] .channel-card { box-shadow: var(--shadow-sm); }
.channel-card .ch-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: 12.5px; font-weight: 600;
}
.channel-card .ch-head .ico { width: 15px; height: 15px; display: inline-flex; color: var(--text-muted); }
.channel-card .ch-head .ico svg { width: 15px; height: 15px; }
.channel-card .ch-head a { margin-left: auto; font-size: 11px; font-weight: 550; }
.channel-card .ch-stat { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.channel-card .ch-stat span { color: var(--text-muted); }
.channel-card .ch-stat b { font-weight: 600; font-variant-numeric: tabular-nums; }
.feed { display: flex; flex-direction: column; }
.feed-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 2px; border-bottom: 1px solid var(--border-subtle);
  font-size: 12.5px; line-height: 1.5;
}
.feed-item:last-child { border-bottom: none; }
.feed-item .f-dot { margin-top: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--text-disabled); flex: none; }
.feed-item .f-dot.ok { background: var(--success-fg); }
.feed-item .f-dot.err { background: var(--danger-fg); }
.feed-item .f-body { min-width: 0; flex: 1; }
.feed-item .f-chan { color: var(--text-muted); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; margin-right: 6px; }
.feed-item .f-time { color: var(--text-disabled); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.all-clear {
  display: flex; align-items: center; gap: 12px;
  background: var(--success-bg); border: 1px solid var(--success-border);
  border-radius: var(--radius-xl); padding: 16px 18px; margin-bottom: 16px;
  color: var(--text-primary); font-size: 13px;
}
.all-clear b { display: block; font-size: 13.5px; }
.all-clear .ac-ico {
  width: 32px; height: 32px; border-radius: var(--radius-lg); flex: none;
  background: var(--success-fg); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
}
.all-clear .ac-ico svg { width: 16px; height: 16px; }

/* ── Print: client-ready exports ───────────────────────────────────────── */
@media print {
  body[data-shell] { padding-left: 0; }
  .app-sidebar, .app-topbar, #ui-toasts { display: none !important; }
  .app-main { padding-top: 0; max-width: none; }
  .card, .section, .kpi { break-inside: avoid; }
}
