/* ============================================================================
   KOP Grant Intelligence — Console UI
   Design system shared with the Phazur RFP Tracker (Notion analysis + brand
   layer): warm paper canvas, white surfaces, hairline rules, one structural
   blue accent, editorial sections instead of card frames, drawers never modals.

   The rules that matter, applied literally:
   · warm paper canvas, white cards, hairline borders — never clinical white pages
   · exactly ONE structural accent (blue) for CTAs, links, active state
   · the multi-colour sticker palette decorates only (dots, chips, illustration)
   · pill radii for badges/CTAs, 8px for utility buttons, 4px for inputs
   · elevation is many near-transparent layers, never a hard cast
   · gates render before scores; a NO_GO is never visually outranked by a number
   ========================================================================= */

/* ── tokens ──────────────────────────────────────────────────────────────── */
:root {
  /* colors */
  --primary: #0075de;
  --primary-active: #005bab;
  --primary-soft: rgba(0, 117, 222, 0.08);
  --secondary: #213183;
  --on-primary: #ffffff;
  --canvas: #ffffff;
  --canvas-soft: #f6f5f4;
  --surface: #ffffff;
  --ink: rgba(0, 0, 0, 0.95);
  --ink-secondary: #31302e;
  --ink-muted: #615d59;
  --ink-faint: #a39e98;
  --hairline: #e6e6e6;

  /* sticker palette — decorative only */
  --accent-sky: #62aef0;
  --accent-purple: #d6b6f6;
  --accent-purple-deep: #391c57;
  --accent-pink: #ff64c8;
  --accent-orange: #dd5b00;
  --accent-orange-deep: #793400;
  --accent-teal: #2a9d99;
  --accent-green: #1aae39;
  --accent-brown: #523410;

  /* radius */
  --r-xs: 4px;
  --r-sm: 5px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 9999px;

  /* spacing — 8px base, extended upward for editorial rhythm */
  --s-xxs: 4px;
  --s-xs: 8px;
  --s-sm: 12px;
  --s-md: 16px;
  --s-lg: 24px;
  --s-xl: 28px;
  --s-xxl: 32px;
  --s-3xl: 48px;
  --s-4xl: 64px;
  --s-5xl: 88px;

  /* type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI",
    Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* elevation — layered, barely-there */
  --shadow-1: rgba(0, 0, 0, 0.01) 0 0.175px 1.041px,
    rgba(0, 0, 0, 0.02) 0 0.8px 2.925px, rgba(0, 0, 0, 0.027) 0 2.025px 7.847px,
    rgba(0, 0, 0, 0.04) 0 4px 18px;
  --shadow-2: rgba(0, 0, 0, 0.01) 0 0.6px 1.4px, rgba(0, 0, 0, 0.02) 0 1.9px 4.4px,
    rgba(0, 0, 0, 0.03) 0 4.5px 10.4px, rgba(0, 0, 0, 0.04) 0 10px 23px,
    rgba(0, 0, 0, 0.05) 0 23px 52px;

  /* semantic aliases — components use these, never the raw tokens */
  --accent: var(--primary);
  --accent-2: var(--primary-active);
  --accent-tint: #eaf4fd;
  --paper: var(--surface);
  --paper-2: var(--canvas-soft);
  --ink-2: var(--ink-secondary);
  --ink-3: var(--ink-muted);
  --rule: var(--hairline);
  --rule-2: #dddddd;

  /* text-safe variants (AA-corrected; fills/dots keep the brand hues) */
  --accent-text: #0064bd;          /* 5.42:1 on canvas */
  --warn-text: #b84c00;            /* 4.74:1 */
  --info-text: #1d7773;            /* 4.90:1 */
  --ok-text: #157c31;              /* AA green for verdict text */

  /* motion */
  --ease: cubic-bezier(0.22, 0.85, 0.26, 1);
  --fast: 170ms;
  --med: 230ms;
  --slow: 360ms;
  --spring: cubic-bezier(0.22, 1, 0.28, 1);   /* overshoot for arrivals only */
  --drawer-in: 420ms;

  /* layout */
  --sidebar-w: 272px;
  --measure: 680px;
  --pad: clamp(20px, 3.4vw, 40px);

  /* dark palette — values live here once, semantics re-point below */
  --d-primary: #4a9eff;
  --d-primary-active: #7ab8ff;
  --d-primary-soft: rgba(74, 158, 255, 0.15);
  --d-accent-tint: rgba(74, 158, 255, 0.16);
  --d-secondary: #2c3f9e;
  --d-canvas: #1e1e1e;
  --d-canvas-soft: #171717;
  --d-surface: #1e1e1e;
  --d-ink: rgba(255, 255, 255, 0.92);
  --d-ink-secondary: rgba(255, 255, 255, 0.78);
  --d-ink-muted: rgba(255, 255, 255, 0.56);
  --d-ink-faint: rgba(255, 255, 255, 0.38);
  --d-hairline: rgba(255, 255, 255, 0.11);
  --d-rule-2: rgba(255, 255, 255, 0.2);
  --d-accent-sky: #7cc0f5;
  --d-accent-purple: #c9a5f0;
  --d-accent-purple-deep: #d6b6f6;
  --d-accent-pink: #ff7fd2;
  --d-accent-orange: #ff8a3d;
  --d-accent-orange-deep: #ffab73;
  --d-accent-teal: #3fc0bb;
  --d-accent-green: #4cd268;
  --d-shadow-1: rgba(0, 0, 0, 0.28) 0 1px 2px, rgba(0, 0, 0, 0.22) 0 4px 12px;
  --d-shadow-2: rgba(0, 0, 0, 0.4) 0 4px 12px, rgba(0, 0, 0, 0.34) 0 16px 40px;

  --topbar-bg: rgba(255, 255, 255, 0.88);
  --scrim: rgba(0, 0, 0, 0.32);
  --skeleton-hi: #efeeed;
  --d-topbar-bg: rgba(30, 30, 30, 0.88);
  --d-scrim: rgba(0, 0, 0, 0.62);
  --d-skeleton-hi: rgba(255, 255, 255, 0.07);
}

/* Re-point semantic tokens at the dark palette. Declared twice on purpose:
   once for viewers on system-dark who have not chosen a theme, once for an
   explicit choice, so the toggle wins in both directions. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --primary: var(--d-primary);
    --primary-active: var(--d-primary-active);
    --primary-soft: var(--d-primary-soft);
    --accent-tint: var(--d-accent-tint);
    --secondary: var(--d-secondary);
    --canvas: var(--d-canvas);
    --canvas-soft: var(--d-canvas-soft);
    --surface: var(--d-surface);
    --ink: var(--d-ink);
    --ink-secondary: var(--d-ink-secondary);
    --ink-muted: var(--d-ink-muted);
    --ink-faint: var(--d-ink-faint);
    --hairline: var(--d-hairline);
    --rule-2: var(--d-rule-2);
    --accent-sky: var(--d-accent-sky);
    --accent-purple: var(--d-accent-purple);
    --accent-purple-deep: var(--d-accent-purple-deep);
    --accent-pink: var(--d-accent-pink);
    --accent-orange: var(--d-accent-orange);
    --accent-orange-deep: var(--d-accent-orange-deep);
    --accent-teal: var(--d-accent-teal);
    --accent-green: var(--d-accent-green);
    --shadow-1: var(--d-shadow-1);
    --shadow-2: var(--d-shadow-2);
    --topbar-bg: var(--d-topbar-bg);
    --skeleton-hi: var(--d-skeleton-hi);
    --scrim: var(--d-scrim);
    --accent-text: var(--d-primary);
    --warn-text: var(--d-accent-orange);
    --info-text: var(--d-accent-teal);
    --ok-text: var(--d-accent-green);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: var(--d-primary);
  --primary-active: var(--d-primary-active);
  --primary-soft: var(--d-primary-soft);
  --accent-tint: var(--d-accent-tint);
  --secondary: var(--d-secondary);
  --canvas: var(--d-canvas);
  --canvas-soft: var(--d-canvas-soft);
  --surface: var(--d-surface);
  --ink: var(--d-ink);
  --ink-secondary: var(--d-ink-secondary);
  --ink-muted: var(--d-ink-muted);
  --ink-faint: var(--d-ink-faint);
  --hairline: var(--d-hairline);
  --rule-2: var(--d-rule-2);
  --accent-sky: var(--d-accent-sky);
  --accent-purple: var(--d-accent-purple);
  --accent-purple-deep: var(--d-accent-purple-deep);
  --accent-pink: var(--d-accent-pink);
  --accent-orange: var(--d-accent-orange);
  --accent-orange-deep: var(--d-accent-orange-deep);
  --accent-teal: var(--d-accent-teal);
  --accent-green: var(--d-accent-green);
  --shadow-1: var(--d-shadow-1);
  --shadow-2: var(--d-shadow-2);
  --topbar-bg: var(--d-topbar-bg);
  --skeleton-hi: var(--d-skeleton-hi);
  --scrim: var(--d-scrim);
  --accent-text: var(--d-primary);
  --warn-text: var(--d-accent-orange);
  --info-text: var(--d-accent-teal);
  --ok-text: var(--d-accent-green);
}

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

/* ── reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  background: var(--canvas-soft);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.33;
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
  font-feature-settings: "lnum" 1, "locl" 1;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* type scale, tracking applied explicitly */
h1, h2, h3 { margin: 0; font-weight: 700; }
.t-display { font-size: 40px; line-height: 1.1; letter-spacing: -1px; font-weight: 700; }
.t-h2 { font-size: 26px; line-height: 1.23; letter-spacing: -0.625px; font-weight: 700; }
.t-h3 { font-size: 22px; line-height: 1.27; letter-spacing: -0.25px; font-weight: 700; }
.t-title { font-size: 20px; line-height: 1.4; letter-spacing: -0.125px; font-weight: 600; }
.t-body { font-size: 16px; line-height: 1.5; }
.t-sm { font-size: 15px; line-height: 1.33; }
.t-caption { font-size: 14px; line-height: 1.43; }

/* ── editorial layer ─────────────────────────────────────────────────────
     .sec-mark    § n  ─────────────────────────   section opener
     .section-label   LABEL ───────────────────    minor section opener
     .spec        left-aligned dt/dd rows on hairlines
     .band        full-width horizontal separator band
     .stat-band   rule-separated statistic columns, no card frames
   ──────────────────────────────────────────────────────────────────── */

.rulebar { flex: 1; height: 1px; background: var(--rule); min-width: 24px; }

.sec-mark { display: flex; align-items: center; gap: var(--s-sm); margin-bottom: var(--s-lg); }
.sec-mark .n {
  flex: 0 0 auto;
  font-size: 12px; font-weight: 600; letter-spacing: 0.125px;
  color: var(--accent-text); background: var(--paper);
  border: 1px solid var(--rule); border-radius: var(--r-full);
  padding: 4px 10px;
}

.section-label {
  display: flex; align-items: center; gap: var(--s-sm);
  font-size: 12px; font-weight: 600; letter-spacing: 0.125px;
  text-transform: uppercase; color: var(--ink-3);
  margin: 0 0 var(--s-lg);
}
.section-label > span:first-child { flex: 0 0 auto; }
.section-label .count {
  flex: 0 0 auto; color: var(--ink-faint); font-weight: 400;
  font-size: 13px; text-transform: none; letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.sheet { margin: 0 0 var(--s-4xl); }
.sheet:last-child { margin-bottom: 0; }
.sheet-head { margin-bottom: var(--s-lg); }
.sheet-head .t-h2 { margin-bottom: 10px; }
.sheet-lede {
  font-size: 16px; line-height: 1.5; color: var(--ink-2);
  max-width: 62ch; margin: 0;
}

.band {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: var(--s-xxl) 0;
  margin: 0 0 var(--s-4xl);
}
.band--open { border-bottom: none; padding-bottom: 0; }

.spec { border-top: 1px solid var(--rule); max-width: 880px; }
.spec .row {
  display: grid; grid-template-columns: 200px minmax(0, 1fr);
  gap: var(--s-lg);
  padding: var(--s-md) 0;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
}
.spec dt {
  font-size: 12px; font-weight: 600; letter-spacing: 0.125px;
  text-transform: uppercase; color: var(--ink-3);
}
.spec dd { margin: 0; font-size: 15px; color: var(--ink); min-width: 0; word-break: break-word; }
.spec dd.n { font-variant-numeric: tabular-nums; }
.spec--tight .row { grid-template-columns: 148px minmax(0, 1fr); }
.spec dd .chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.note {
  max-width: 68ch; margin: var(--s-lg) 0 0;
  font-size: 15px; line-height: 1.65; color: var(--ink-2);
  border-left: 2px solid var(--rule); padding-left: var(--s-lg);
}
.note strong { color: var(--ink); font-weight: 600; }

.stat-band { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-band .stat-cell { padding: 0 var(--s-xxl); border-left: 1px solid var(--rule); }
.stat-band .stat-cell:first-child { padding-left: 0; border-left: none; }
.stat-cell .value {
  font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -1px;
  font-variant-numeric: tabular-nums; display: block; margin-bottom: 8px;
}
.stat-cell .label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.125px;
  text-transform: uppercase; color: var(--ink-3); display: block;
}
.stat-cell .sub { font-size: 13px; color: var(--ink-faint); display: block; margin-top: 4px; }
.stat-cell .value .unit { color: var(--accent); }
.t-eyebrow {
  font-size: 12px; font-weight: 600; line-height: 1.33;
  letter-spacing: 0.125px; text-transform: uppercase;
}
.kicker {
  font-size: 12px; font-weight: 600; line-height: 1.33;
  letter-spacing: 0.125px; text-transform: uppercase; color: var(--accent-text);
}
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.mono { font-family: var(--font-mono); font-size: 13px; }

.byline {
  display: flex; align-items: center; gap: var(--s-xs);
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px var(--s-sm);
  font-size: 14px; line-height: 1.43; color: var(--ink-3);
}
.byline strong { color: var(--ink); font-weight: 600; }

/* ── app shell ───────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--canvas);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

/* wordmark band, closed by a hairline */
.nav-brand {
  padding: var(--s-xxl) var(--s-lg) var(--s-lg);
  border-bottom: 1px solid var(--rule);
  background: var(--canvas);
}
.nav-brand .mark {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); line-height: 1;
}
.nav-brand .mark-rule {
  width: 3px; height: 34px; border-radius: var(--r-full);
  background: var(--accent); flex: 0 0 3px;
}
.nav-brand .mark-word {
  font-size: 21px; font-weight: 700; letter-spacing: -0.25px;
}
.nav-brand .mark-word span { color: var(--ink-3); font-weight: 500; }
.nav-brand .brand-sub {
  font-size: 12px; color: var(--ink-faint); line-height: 1.3;
  margin-top: 10px; letter-spacing: 0.125px;
}

.nav-scroll {
  flex: 1; overflow-y: auto;
  padding: var(--s-lg) var(--s-sm);
  display: flex; flex-direction: column; gap: var(--s-xxl);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  display: flex; align-items: center; gap: var(--s-xs);
  padding: 0 var(--s-sm) var(--s-xs);
  color: var(--ink-3);
  font-size: 10.5px; font-weight: 700; letter-spacing: 1.47px; text-transform: uppercase;
}
/* Active nav keeps ink near-black and signals with the icon plus a 3px rule —
   the structural accent marks actions, and a row you're already on is not one. */
.nav-row {
  display: flex; align-items: center; gap: var(--s-sm);
  padding: var(--s-sm);
  border-radius: var(--r-sm);
  border: none; background: transparent;
  color: var(--ink);
  font-size: 15px; font-weight: 600; text-align: left; width: 100%;
  cursor: pointer;
  position: relative;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.nav-row:hover { background: var(--paper-2); }
.nav-row[aria-current="page"] { background: var(--paper-2); color: var(--ink); }
.nav-row[aria-current="page"]::before {
  content: ""; position: absolute; left: -6px; top: 6px; bottom: 6px;
  width: 3px; border-radius: var(--r-full); background: var(--accent);
}
.nav-row .icon { width: 16px; height: 16px; flex: 0 0 16px; color: var(--ink-3); }
.nav-row[aria-current="page"] .icon { color: var(--accent); }
.nav-count {
  margin-left: auto; font-size: 12px; font-weight: 500; color: var(--ink-3);
  background: var(--paper-2); border-radius: var(--r-full); padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.nav-row[aria-current="page"] .nav-count { background: var(--accent-tint); color: var(--accent-text); }

.sidebar-foot {
  margin-top: auto; display: flex; flex-direction: column; gap: var(--s-xs);
  padding: var(--s-lg) var(--s-sm) var(--s-lg);
}
.status-chip {
  display: flex; align-items: center; gap: var(--s-xs);
  padding: var(--s-xs) var(--s-sm);
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--canvas-soft);
  font-size: 13px; color: var(--ink-muted);
}
.dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: var(--r-full); flex: 0 0 8px;
}
.dot--ok { background: var(--accent-green); }
.dot--warn { background: var(--accent-orange); }
.dot--off { background: var(--ink-faint); }

.theme-row {
  display: flex; align-items: center; gap: var(--s-xs);
  padding: var(--s-xs) 2px 0;
}
.theme-row-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.125px;
  text-transform: uppercase; color: var(--ink-faint);
}
.theme-control { margin-left: auto; }
.theme-control button { padding: 5px 9px; display: grid; place-items: center; }

/* ── main ────────────────────────────────────────────────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--hairline);
  padding: var(--s-md) var(--pad);
  display: flex; align-items: center; gap: var(--s-md);
}
.topbar-context {
  display: flex; align-items: baseline; gap: var(--s-xs);
  font-size: 14px; font-weight: 400; margin: 0;
}
.topbar-context .n {
  font-size: 12px; font-weight: 600; letter-spacing: 0.125px; color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}
.topbar-context .name {
  font-size: 14px; font-weight: 600; letter-spacing: 0.125px;
  text-transform: uppercase; color: var(--ink-3);
}
.topbar .spacer { flex: 1; }

.page { padding: var(--s-3xl) var(--pad) var(--s-5xl); max-width: 1180px; width: 100%; }
.page > * + * { margin-top: var(--s-xxl); }
.page > .sheet + .sheet { margin-top: 0; }
.section-head { display: flex; align-items: baseline; gap: var(--s-sm); margin-bottom: var(--s-sm); }
.section-head .t-h3 { flex: 0 0 auto; }

/* ── buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 5px 14px; min-height: 34px;
  border-radius: var(--r-md);
  border: 1px solid var(--rule);
  background: var(--paper); color: var(--ink);
  font-size: 16px; font-weight: 500; cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
              transform 80ms var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--primary {
  background: var(--accent); color: var(--on-primary); border-color: var(--accent);
  border-radius: var(--r-full); padding: 8px 18px;
}
.btn--primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-3); }
.btn--ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn--sm { min-height: 28px; padding: 3px 10px; font-size: 14px; }
.btn--primary.btn--sm { padding: 4px 14px; }
.btn--danger { color: var(--warn-text); }
.btn--danger:hover {
  background: color-mix(in srgb, var(--accent-orange) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent-orange) 35%, transparent);
}
.btn--pill { border-radius: var(--r-full); padding: 8px 18px; }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-xs); align-items: center; }

/* disabled-with-reason: the reason sits beside the disabled action (H5 —
   a control never disables silently) */
.btn-reason { font-size: 13px; color: var(--ink-faint); line-height: 1.4; }

/* ── inputs (tight 4px — never pill) ─────────────────────────────────────── */
.input, .select, .textarea {
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--rule-2); border-radius: var(--r-xs);
  padding: 6px 12px; font-size: 16px; width: 100%;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--shadow-1);
}
.input::placeholder { color: var(--ink-faint); }
.select { appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%239a9691' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.textarea { font-family: var(--font-mono); font-size: 13px; line-height: 1.55; min-height: 220px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-secondary); }
.field .hint { font-size: 13px; color: var(--ink-faint); }

.switch { display: inline-flex; align-items: center; gap: var(--s-xs); cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 34px; height: 20px; border-radius: var(--r-full);
  background: var(--hairline); position: relative; transition: background 140ms ease;
  flex: 0 0 34px;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: var(--r-full);
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.18);
  transition: transform 140ms ease;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--primary-soft); }

/* ── cards (rare — the editorial layer is the default container) ────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--s-xxl);
}
.card--soft { background: var(--canvas-soft); border-color: transparent; }
.card--elevated { box-shadow: var(--shadow-1); }

.grid { display: grid; gap: var(--s-md); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }

/* ── badges & dots ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-full);
  background: var(--paper); border: 1px solid var(--rule); color: var(--ink-3);
  font-size: 12px; font-weight: 600; letter-spacing: 0.125px;
  white-space: nowrap;
}
.badge--sample { color: var(--accent-orange-deep); background: rgba(221,91,0,0.1); text-transform: none; }
.badge--ok { color: var(--accent-green); background: rgba(26,174,57,0.1); }
.badge--fail { color: var(--accent-orange); background: rgba(221,91,0,0.1); }

/* Verdicts are workflow states with a fixed visual hierarchy: NO_GO is the
   loudest mark on any surface it appears on — a score never outranks it. */
.verdict {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 700; letter-spacing: 0.25px;
  white-space: nowrap; border: 1px solid transparent;
}
.verdict--go { color: var(--ok-text); background: rgba(26,174,57,0.1); border-color: rgba(26,174,57,0.25); }
.verdict--conditional { color: var(--warn-text); background: rgba(221,91,0,0.09); border-color: rgba(221,91,0,0.25); }
.verdict--nogo { color: #ffffff; background: var(--accent-orange-deep); border-color: var(--accent-orange-deep); }
.verdict--insufficient { color: var(--ink-3); background: var(--paper-2); border-color: var(--rule); }
.verdict--lg { font-size: 14px; padding: 6px 14px; }

/* six evidence classifications — same chips in the draft, the explainer and
   the ledger, so the vocabulary is learned once */
.evi-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 600; letter-spacing: 0.125px;
  white-space: nowrap; vertical-align: baseline;
  background: var(--paper); border: 1px solid var(--rule); color: var(--ink-3);
}
.evi-chip .cat-dot { width: 7px; height: 7px; flex: 0 0 7px; }
.evi--verified_org_fact .cat-dot { background: var(--accent-green); }
.evi--funder_requirement .cat-dot { background: var(--accent-teal); }
.evi--external_evidence .cat-dot { background: var(--accent-sky); }
.evi--user_assumption .cat-dot { background: var(--accent-orange); }
.evi--missing_information .cat-dot { background: var(--accent-pink); }
.evi--generated_recommendation .cat-dot { background: var(--accent-purple); }

.cat-dot { width: 10px; height: 10px; border-radius: var(--r-full); flex: 0 0 10px; }
.nav-dot { width: 6px; height: 6px; border-radius: var(--r-full); flex: 0 0 6px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── human decision gate ────────────────────────────────────────────────
   Unmissable by design: full width, warn-toned, first thing on a package.
   It converts to a quiet recorded chip only after a named human records
   the decision — a clean automated review never dismisses it. */
.gate-banner {
  display: flex; align-items: center; gap: var(--s-md); flex-wrap: wrap;
  padding: var(--s-md) var(--s-lg); border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent-orange) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-orange) 28%, transparent);
  color: var(--ink); font-size: 15px; line-height: 1.5;
}
.gate-banner .gate-text { flex: 1 1 320px; min-width: 0; }
.gate-banner .gate-text strong { display: block; font-size: 15px; }
.gate-banner .gate-text span { font-size: 13px; color: var(--ink-3); }
.gate-banner .btn { flex: 0 0 auto; }

.decision-chip {
  display: flex; align-items: center; gap: var(--s-sm); flex-wrap: wrap;
  padding: var(--s-sm) var(--s-md); border-radius: var(--r-md);
  background: var(--paper); border: 1px solid var(--rule);
  font-size: 14px; color: var(--ink-2);
}
.decision-chip strong { color: var(--ink); }

.banner {
  display: flex; align-items: center; gap: var(--s-sm); flex-wrap: wrap;
  padding: var(--s-sm) var(--s-md); border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent-orange) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-orange) 28%, transparent);
  color: var(--accent-orange-deep); font-size: 14px; line-height: 1.43;
}
.banner > span { flex: 1 1 220px; min-width: 0; }
.banner--info { background: var(--primary-soft); border-color: rgba(0,117,222,0.2); color: var(--secondary); }

/* dismissible read-order callout above package tabs */
.callout {
  display: flex; align-items: flex-start; gap: var(--s-sm);
  padding: var(--s-sm) var(--s-md); border-radius: var(--r-md);
  background: var(--primary-soft); border: 1px solid rgba(0,117,222,0.18);
  font-size: 14px; line-height: 1.5; color: var(--ink-2);
}
.callout .grow { flex: 1; min-width: 0; }

/* ── tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  background: transparent;
  color: var(--ink-3);
  font-size: 12px; font-weight: 600; letter-spacing: 0.125px; text-transform: uppercase;
  text-align: left; padding: 0 var(--s-md) var(--s-sm);
  border-bottom: 1px solid var(--ink-3);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.data th:first-child { padding-left: 0; }
table.data th:last-child { padding-right: 0; }
table.data td {
  padding: var(--s-md) var(--s-md);
  border-bottom: 1px solid var(--rule);
  font-size: 15px; vertical-align: middle;
}
table.data td:first-child { padding-left: 0; }
table.data td:last-child { padding-right: 0; }
table.data tbody tr { transition: background var(--fast) var(--ease); }
table.data tbody tr:hover { background: var(--paper-2); }
table.data tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--accent); }

.cell-title {
  font-weight: 600; color: var(--ink); cursor: pointer;
  display: block; max-width: 52ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color var(--fast) var(--ease);
}
.cell-title:hover { color: var(--accent-text); }
.cell-meta {
  color: var(--ink-3); font-size: 13px; margin-top: 2px;
  max-width: 52ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cell-meta .sol { font-variant-numeric: tabular-nums; }

.row-actions { display: flex; gap: 2px; justify-content: flex-end; align-items: center; }
.icon-btn {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--ink-3);
  display: grid; place-items: center; cursor: pointer;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease),
              border-color var(--fast) var(--ease);
}
.icon-btn:hover { background: var(--paper); border-color: var(--rule); color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 15px; height: 15px; }
.row-actions .is-secondary { opacity: 0; transition: opacity var(--fast) var(--ease); }
tr:hover .row-actions .is-secondary,
.row-actions .is-secondary:focus-visible { opacity: 1; }
@media (hover: none) { .row-actions .is-secondary { opacity: 1; } }

/* score cell keeps figures quiet and tabular; the verdict carries the state */
td.n, .n-cell { font-variant-numeric: tabular-nums; }

/* ── filter bar ──────────────────────────────────────────────────────────── */
.filters {
  display: flex; flex-wrap: wrap; gap: var(--s-sm) var(--s-md); align-items: center;
  padding: 0 0 var(--s-lg);
  border-bottom: 1px solid var(--rule);
  background: transparent;
  margin-bottom: var(--s-lg);
}
.filters .search { flex: 1 1 240px; min-width: 190px; max-width: 340px; }
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-group > .glabel {
  font-size: 12px; font-weight: 600; letter-spacing: 0.125px;
  text-transform: uppercase; color: var(--ink-faint); margin-right: 2px;
}

.segmented {
  display: inline-flex; border: 1px solid var(--rule);
  border-radius: var(--r-md); overflow: hidden; background: var(--paper);
}
.segmented button {
  border: none; background: transparent; cursor: pointer;
  padding: 5px 12px; font-size: 14px; font-weight: 500; color: var(--ink-3);
  border-right: 1px solid var(--rule);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { background: var(--paper-2); color: var(--ink); }
.segmented button[aria-pressed="true"] {
  background: var(--accent-tint); color: var(--accent-2); font-weight: 600;
}
.filters-meta {
  display: flex; align-items: center; gap: var(--s-md); flex-wrap: wrap;
  margin-left: auto; font-size: 13px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ── package tabs — editorial: uppercase labels on a hairline, the active tab
   earns a 2px accent underline. Not a segmented control: these are places in
   a document, not options in a setting. */
.tabs {
  display: flex; gap: var(--s-lg); flex-wrap: wrap;
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s-lg);
}
.tabs button {
  border: none; background: transparent; cursor: pointer;
  padding: 0 0 var(--s-sm); margin-bottom: -1px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.125px; text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .tab-flag {
  display: inline-block; margin-left: 5px; min-width: 6px; height: 6px;
  border-radius: var(--r-full); background: var(--accent-orange); vertical-align: 2px;
}

/* ── get-started checklist (state-derived onboarding) ───────────────────── */
.checklist { border-top: 1px solid var(--rule); max-width: 880px; }
.check-step {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: var(--s-md); align-items: center;
  padding: var(--s-md) 0; border-bottom: 1px solid var(--rule);
}
.check-step .marker {
  width: 26px; height: 26px; border-radius: var(--r-full);
  border: 1px solid var(--rule-2); background: var(--paper);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.check-step.is-done .marker {
  background: var(--accent-green); border-color: var(--accent-green); color: #fff;
}
.check-step .body .head { font-size: 15px; font-weight: 600; color: var(--ink); }
.check-step.is-done .body .head { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.check-step .body .sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; line-height: 1.45; }
.check-step .action { justify-self: end; }

/* ── how-it-works stage strip ────────────────────────────────────────────── */
.stage-strip {
  display: flex; align-items: stretch; gap: var(--s-xs);
  overflow-x: auto; padding-bottom: var(--s-xs);
}
.stage {
  flex: 1 1 0; min-width: 132px;
  border: 1px solid var(--rule); border-radius: var(--r-md);
  background: var(--paper); padding: var(--s-sm) var(--s-md);
  display: flex; flex-direction: column; gap: 4px;
}
.stage .num {
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--accent-text); font-variant-numeric: tabular-nums;
}
.stage .name { font-size: 14px; font-weight: 600; color: var(--ink); }
.stage .what { font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.stage--terminal { background: var(--paper-2); border-color: var(--rule-2); }
.stage--terminal .num { color: var(--warn-text); }
.stage-arrow { align-self: center; color: var(--ink-faint); flex: 0 0 auto; }

/* score component bars — sticker sky, never structural blue */
.bar-item { padding: 7px 0; }
.bar-head {
  display: flex; align-items: center; gap: var(--s-xs);
  font-size: 14px; margin-bottom: 7px;
}
.bar-head .count { margin-left: auto; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.bar-track {
  display: block; height: 8px; background: var(--canvas-soft);
  border-radius: var(--r-full); overflow: hidden;
  border: 1px solid var(--rule);
}
.bar-fill {
  display: block; height: 100%; border-radius: var(--r-full);
  background: var(--accent-sky);
  transition: width 400ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.bar-sub { font-size: 13px; color: var(--ink-3); margin-top: 6px; line-height: 1.5; max-width: 68ch; }

/* ── rendered markdown (package files) ──────────────────────────────────── */
.md { max-width: 76ch; font-size: 15px; line-height: 1.65; color: var(--ink-2); }
.md h1 { font-size: 22px; line-height: 1.27; letter-spacing: -0.25px; color: var(--ink); margin: 0 0 var(--s-md); }
.md h2 {
  font-size: 12px; font-weight: 600; letter-spacing: 0.125px; text-transform: uppercase;
  color: var(--ink-3); margin: var(--s-xxl) 0 var(--s-sm);
  display: flex; align-items: center; gap: var(--s-sm);
}
.md h2::after { content: ""; flex: 1; height: 1px; background: var(--rule); min-width: 24px; }
.md p { margin: 0 0 var(--s-md); }
.md ul { margin: 0 0 var(--s-md); padding-left: 20px; }
.md li { margin-bottom: 6px; }
.md blockquote {
  margin: 0 0 var(--s-md); padding: var(--s-sm) var(--s-md);
  border-left: 2px solid var(--accent); background: var(--primary-soft);
  border-radius: 0 var(--r-md) var(--r-md) 0; color: var(--ink-2);
}
.md blockquote p { margin: 0; }
.md code {
  font-family: var(--font-mono); font-size: 12.5px;
  background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: var(--r-xs); padding: 1px 5px;
}
.md strong { color: var(--ink); }
.md .md-table-wrap { overflow-x: auto; margin: 0 0 var(--s-md); }
.md table { width: 100%; border-collapse: collapse; }
.md th {
  font-size: 12px; font-weight: 600; letter-spacing: 0.125px; text-transform: uppercase;
  color: var(--ink-3); text-align: left; padding: 0 var(--s-md) var(--s-xs);
  border-bottom: 1px solid var(--ink-3); white-space: nowrap;
}
.md td { padding: var(--s-sm) var(--s-md); border-bottom: 1px solid var(--rule); font-size: 14px; vertical-align: top; }
.md th:first-child, .md td:first-child { padding-left: 0; }
.md th:last-child, .md td:last-child { padding-right: 0; }

/* ── empty / loading states ──────────────────────────────────────────────── */
.empty {
  background: var(--canvas-soft); border-radius: var(--r-xl);
  padding: var(--s-xxl); text-align: center; color: var(--ink-muted);
  font-size: 16px; line-height: 1.5;
}
.empty .empty-title { font-size: 20px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.125px; margin-bottom: 6px; }
.empty .btn-row { justify-content: center; margin-top: var(--s-md); }

.skeleton {
  background: linear-gradient(90deg, var(--canvas-soft) 25%, var(--skeleton-hi) 50%, var(--canvas-soft) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
  border-radius: var(--r-xs); height: 14px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.spinner {
  width: 15px; height: 15px; border-radius: var(--r-full);
  border: 2px solid rgba(255,255,255,0.35); border-top-color: currentColor;
  animation: spin 700ms linear infinite; display: inline-block;
}
.btn:not(.btn--primary) .spinner { border-color: var(--hairline); border-top-color: var(--ink-muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── drawer ──────────────────────────────────────────────────────────────
   No modals in this app. A drawer slides in from the right — a bottom sheet
   below 720px — so the record behind it stays visible and legible. */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 100;
  display: flex; justify-content: flex-end;
  background: transparent;
  transition: background var(--med) var(--ease),
              backdrop-filter var(--med) var(--ease);
}
.drawer-scrim.is-open {
  background: var(--scrim);
  backdrop-filter: saturate(140%) blur(3px);
  -webkit-backdrop-filter: saturate(140%) blur(3px);
}

.drawer {
  position: relative;
  display: flex; flex-direction: column;
  width: 100%; max-width: 560px; height: 100%;
  background: var(--paper);
  border-left: 1px solid var(--rule);
  box-shadow: var(--shadow-2);
  transform: translateX(100%);
  transition: transform var(--drawer-in) cubic-bezier(0.22, 1, 0.28, 1);
  will-change: transform;
}
.drawer--sm { max-width: 460px; }
.drawer--lg { max-width: 720px; }
.drawer-scrim.is-open .drawer { transform: translateX(0); }

.drawer-head {
  flex: 0 0 auto;
  display: flex; align-items: flex-start; gap: var(--s-md);
  padding: var(--s-xxl) var(--s-xxl) var(--s-lg);
  border-bottom: 1px solid transparent;
  transition: border-color var(--fast) var(--ease),
              box-shadow var(--fast) var(--ease);
}
.drawer.is-scrolled .drawer-head {
  border-bottom-color: var(--rule);
  box-shadow: 0 1px 0 0 var(--rule);
}
.drawer-head-text { flex: 1; min-width: 0; }
.drawer-eyebrow { margin-bottom: 8px; }
.drawer-title {
  font-size: 26px; font-weight: 700; line-height: 1.23; letter-spacing: -0.625px;
  margin: 0; color: var(--ink);
}
.drawer-subtitle {
  margin-top: 8px; font-size: 14px; line-height: 1.5; color: var(--ink-3);
}

.drawer-close {
  flex: 0 0 auto;
  width: 36px; height: 36px; border-radius: var(--r-full);
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink-3);
  display: grid; place-items: center; cursor: pointer;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease),
              transform var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.drawer-close:hover {
  background: var(--paper-2); color: var(--ink);
  border-color: var(--rule-2); transform: rotate(90deg);
}
.drawer-close:active { transform: rotate(90deg) scale(0.92); }

.drawer-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--s-lg) var(--s-xxl) var(--s-xxl);
  scrollbar-width: thin;
}
.drawer-body:focus { outline: none; }

.drawer-foot {
  flex: 0 0 auto;
  display: flex; gap: var(--s-xs); align-items: center; flex-wrap: wrap;
  padding: var(--s-lg) var(--s-xxl);
  border-top: 1px solid var(--rule);
  background: var(--paper);
}
.drawer-foot .spacer { flex: 1; }

.drawer-scrim.is-open .drawer-body > * {
  animation: drawer-settle var(--med) var(--ease) backwards;
}
.drawer-scrim.is-open .drawer-body > *:nth-child(1) { animation-delay: 90ms; }
.drawer-scrim.is-open .drawer-body > *:nth-child(2) { animation-delay: 130ms; }
.drawer-scrim.is-open .drawer-body > *:nth-child(3) { animation-delay: 170ms; }
.drawer-scrim.is-open .drawer-body > *:nth-child(4) { animation-delay: 210ms; }
.drawer-scrim.is-open .drawer-body > *:nth-child(n+5) { animation-delay: 240ms; }
@keyframes drawer-settle {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 720px) {
  .drawer-scrim { align-items: flex-end; justify-content: center; }
  .drawer {
    max-width: none; height: auto; max-height: 92vh;
    border-left: none; border-top: 1px solid var(--rule);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(100%);
  }
  .drawer--sm, .drawer--lg { max-width: none; }
  .drawer-scrim.is-open .drawer { transform: translateY(0); }
  .drawer-head { padding: var(--s-lg) var(--s-lg) var(--s-md); }
  .drawer-body { padding: var(--s-md) var(--s-lg) var(--s-lg); }
  .drawer-foot { padding: var(--s-md) var(--s-lg); }
  .drawer-head::before {
    content: ""; position: absolute; top: 8px; left: 50%;
    width: 36px; height: 4px; margin-left: -18px;
    border-radius: var(--r-full); background: var(--rule-2);
  }
}

.detail-grid { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 10px var(--s-md); }
.detail-grid dt { color: var(--ink-muted); font-size: 13px; }
.detail-grid dd { margin: 0; font-size: 15px; word-break: break-word; }

/* ── toasts ──────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; bottom: var(--s-lg); right: var(--s-lg);
  display: flex; flex-direction: column; gap: var(--s-xs); z-index: 200;
  max-width: 380px;
}
.toast {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-xl); box-shadow: var(--shadow-2);
  padding: var(--s-sm) var(--s-md);
  font-size: 15px; display: flex; gap: 10px; align-items: flex-start;
}
.toast .dot { margin-top: 6px; }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-msg .toast-title { font-weight: 600; }
.toast-msg .toast-detail { color: var(--ink-muted); font-size: 13px; margin-top: 2px;
  word-break: break-word; }

/* ── misc ────────────────────────────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: 1fr auto; gap: 10px var(--s-md); align-items: center; }
.kv .k { color: var(--ink-muted); font-size: 14px; }
.kv .v { font-size: 14px; text-align: right; }
.list { display: flex; flex-direction: column; max-width: 880px; }
.list--wide { max-width: none; }
.list-row {
  display: flex; align-items: center; gap: var(--s-md);
  padding: var(--s-md) 0; border-bottom: 1px solid var(--rule);
}
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.issue-list { list-style: none; margin: 0; padding: 0; max-width: 880px; }
.issue-list li {
  display: flex; gap: var(--s-sm); align-items: flex-start;
  padding: var(--s-sm) 0; border-bottom: 1px solid var(--rule);
  font-size: 14px; line-height: 1.5; color: var(--ink-2);
}
.issue-list .path { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-xs); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .grid--sidebar { grid-template-columns: minmax(0, 1fr); }
  .stat-band { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-lg) 0; }
  .stat-band .stat-cell:nth-child(odd) { padding-left: 0; border-left: none; }
}

@media (max-width: 840px) {
  .grid--2 { grid-template-columns: minmax(0, 1fr); }
  .spec .row { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 10px 0; }
  .spec--tight .row { grid-template-columns: minmax(0, 1fr); }
  .page { padding: var(--s-lg) var(--s-md); }
  .topbar { padding: var(--s-sm) var(--s-md); }
  .sidebar {
    position: fixed; z-index: 60; transform: translateX(-100%);
    transition: transform 180ms ease; box-shadow: var(--shadow-2);
  }
  .sidebar.open { transform: translateX(0); }
  .nav-toggle { display: inline-flex !important; }
}
@media (max-width: 600px) {
  .filters .search { max-width: none; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); gap: 2px var(--s-md); }
  .detail-grid dd { margin-bottom: 8px; }
  .check-step { grid-template-columns: 36px minmax(0, 1fr); }
  .check-step .action { grid-column: 2; justify-self: start; }
}
.nav-toggle { display: none; }

/* ── motion — decoration on a layout that is already correct without it ── */
.page { animation: view-in var(--slow) var(--ease) both; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

tbody.rows tr { animation: row-in var(--med) var(--ease) backwards; }
tbody.rows tr:nth-child(1)  { animation-delay: 20ms; }
tbody.rows tr:nth-child(2)  { animation-delay: 40ms; }
tbody.rows tr:nth-child(3)  { animation-delay: 60ms; }
tbody.rows tr:nth-child(4)  { animation-delay: 80ms; }
tbody.rows tr:nth-child(5)  { animation-delay: 100ms; }
tbody.rows tr:nth-child(6)  { animation-delay: 120ms; }
tbody.rows tr:nth-child(7)  { animation-delay: 140ms; }
tbody.rows tr:nth-child(8)  { animation-delay: 160ms; }
tbody.rows tr:nth-child(n+9) { animation-delay: 180ms; }
@keyframes row-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.stat-band .stat-cell { animation: stat-in var(--slow) var(--ease) backwards; }
.stat-band .stat-cell:nth-child(1) { animation-delay: 60ms; }
.stat-band .stat-cell:nth-child(2) { animation-delay: 120ms; }
.stat-band .stat-cell:nth-child(3) { animation-delay: 180ms; }
.stat-band .stat-cell:nth-child(4) { animation-delay: 240ms; }
@keyframes stat-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.rulebar { transform-origin: left center; animation: rule-draw var(--slow) var(--ease) both; }
@keyframes rule-draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.bar-fill { transform-origin: left center; animation: bar-fill var(--slow) var(--spring) both; animation-delay: 120ms; }
@keyframes bar-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.btn { transform: translateY(0); }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.97); }
.btn--primary:hover:not(:disabled) { box-shadow: var(--shadow-1); }

.nav-row .icon { transition: transform var(--fast) var(--ease), color var(--fast) var(--ease); }
.nav-row:hover .icon { transform: translateX(1px); }
.nav-row[aria-current="page"]::before { animation: nav-mark var(--med) var(--spring) both; }
@keyframes nav-mark { from { transform: scaleY(0.2); opacity: 0; } to { transform: scaleY(1); opacity: 1; } }

.segmented button, .tabs button { transition: background var(--fast) var(--ease),
  border-color var(--fast) var(--ease), color var(--fast) var(--ease),
  transform var(--fast) var(--ease); }
.segmented button:active { transform: scale(0.96); }

.list-row { transition: background var(--fast) var(--ease); }
.list-row:hover { background: var(--paper-2); }

.toast { animation: toast-in var(--med) var(--spring) both; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.check-step.is-done .marker { animation: badge-pop var(--med) var(--spring) both; }
@keyframes badge-pop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Focus is never animated away — it must be instant and obvious. */
:focus-visible { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .rulebar, .bar-fill { transform: none !important; }
  .btn:hover:not(:disabled) { transform: none; }
}

@media (max-width: 720px) {
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

  table.data tbody tr {
    position: relative;
    padding: var(--s-md) 0;
    border-bottom: 1px solid var(--rule);
  }
  table.data tbody tr:hover { background: transparent; }
  table.data tbody tr:hover td:first-child { box-shadow: none; }

  table.data td {
    padding: 0 !important;
    border-bottom: none;
    text-align: left !important;
  }
  table.data td + td { margin-top: var(--s-xs); }

  .cell-title {
    white-space: normal; max-width: none;
    font-size: 16px; line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
    padding-right: 96px;
  }
  .cell-meta { white-space: normal; max-width: none; font-size: 13px; }

  table.data td:nth-of-type(2),
  table.data td:nth-of-type(3),
  table.data td:nth-of-type(4) {
    display: inline-flex; width: auto; margin-top: var(--s-sm);
    margin-right: var(--s-md); vertical-align: middle;
  }
  table.data td:last-of-type {
    position: absolute; top: var(--s-md); right: 0; width: auto; margin: 0;
  }
  .row-actions .is-secondary { opacity: 1; }
  .icon-btn { width: 40px; height: 40px; }

  .filters { gap: var(--s-md) var(--s-sm); padding-bottom: var(--s-md); }
  .filters .search { flex: 1 1 100%; max-width: none; min-width: 0; }
  .filters .input { min-height: 44px; font-size: 16px; }
  .filter-group, .segmented { flex: 0 0 auto; }
  .filters-meta {
    width: 100%; margin-left: 0; gap: var(--s-md);
    padding-top: var(--s-sm); border-top: 1px solid var(--rule);
  }

  .btn { min-height: 44px; padding: 10px 16px; }
  .btn--sm { min-height: 36px; }
  .nav-row { padding: var(--s-sm) var(--s-md); min-height: 46px; }
  .switch .track { width: 40px; height: 24px; flex: 0 0 40px; }
  .switch .track::after { width: 20px; height: 20px; }
  .switch input:checked + .track::after { transform: translateX(16px); }

  .t-display { font-size: 32px; letter-spacing: -0.75px; }
  .t-h2 { font-size: 24px; letter-spacing: -0.5px; }
  .drawer-title { font-size: 22px; letter-spacing: -0.25px; }
  .sheet-lede { font-size: 15px; }

  .page { padding: var(--s-lg) var(--pad) var(--s-4xl); }
  .sheet { margin-bottom: var(--s-3xl); }
  .band { padding: var(--s-lg) 0; margin-bottom: var(--s-3xl); }

  .topbar { padding: var(--s-sm) var(--s-md); gap: var(--s-xs); }
  .topbar-context .name { font-size: 13px; }
}

@media (max-width: 480px) {
  .badge--sample { display: none; }
}

@media (max-width: 400px) {
  .topbar-context .name { display: none; }
  .stat-band { grid-template-columns: minmax(0, 1fr); }
  .stat-band .stat-cell { padding-left: 0; border-left: none; }
  .stat-band .stat-cell + .stat-cell {
    padding-top: var(--s-lg); border-top: 1px solid var(--rule);
  }
}

@media (hover: none) {
  .row-actions .is-secondary { opacity: 1; }
  .btn:hover:not(:disabled) { transform: none; }
}
