/* Quality Control AI — dense, type-driven, defense/aerospace */

/* Radzen's structure, imported into a cascade layer of its own (ADR-0026). Every unlayered rule in
   this file beats every layered one whatever the specificity, so the theme's global leaks — body
   margin and background art, input colour and size — can never override the design system. The
   grid's look is set by the --rz-grid-* mapping in the "Data grid" section below. */
@import url("../_content/Radzen.Blazor/css/standard-base.css") layer(radzen);

:root {
  --bg: #FBFBF8;
  --bg-deep: #F4F3EE;
  --surface: #FFFFFF;
  --surface-2: #F8F7F3;
  --surface-3: #EFEEE8;
  --border: rgba(15, 18, 24, 0.08);
  --border-strong: rgba(15, 18, 24, 0.16);
  --border-emph: rgba(15, 18, 24, 0.24);
  --ink: #0F1218;
  --ink-2: #2A2E36;
  --ink-3: #5A5F6A;
  /* CORE-UX-07: every TEXT token below reaches WCAG AA (4.5:1) on --surface, --surface-2 and
     --surface-3, and on its own -soft tint over --surface; DesignTokenContrastTests holds it.
     --ink-5 is decorative only (separators) and is never used for text a person must read. */
  --ink-4: #666A70;
  --ink-5: #B3B7BE;
  /* The brand orange is a FILL colour; as text it fails AA on light surfaces, so text, icons
     and the focus ring use --accent-ink. */
  --accent: #FF6302;
  --accent-ink: #B54601;
  --accent-soft: rgba(255, 99, 2, 0.10);
  --accent-line: rgba(255, 99, 2, 0.28);
  --ok: #0F784F;
  --ok-soft: rgba(15, 120, 79, 0.12);
  --warn: #955B0D;
  --warn-soft: rgba(149, 91, 13, 0.13);
  --err: #C0342C;
  --err-soft: rgba(192, 52, 44, 0.12);
  /* Text on a filled --err surface (the confirm button of a destructive action). */
  --on-err: #FFFFFF;
  /* Boundaries that identify a control (an empty input) reach 3:1 (WCAG 1.4.11). */
  --control-border: rgba(15, 18, 24, 0.47);
  /* CORE-UX-06: the keyboard focus ring, 3:1 or better on every surface. */
  --focus: #B54601;
  --info: #5546D6;
  --info-soft: rgba(85, 70, 214, 0.12);
  --classification: #BF6A1E;

  --row-h: 34px;
  --gutter: 16px;

  /* Type scale — readability pass: engineers read requirement prose all day */
  --fs-2xs: 11px;   /* uppercase micro-labels, mono id chips */
  --fs-xs: 12px;    /* secondary metadata, hints */
  --fs-sm: 13px;    /* tables, buttons, controls */
  --fs-body: 14px;  /* body copy, descriptions */
  --fs-h3: 15px;    /* card headings, sub-headings inside long-form prose */
  --fs-h2: 18px;    /* section headings inside long-form prose */
  --fs-title: 22px; /* page titles */

  --radius: 6px;
  --radius-sm: 4px;
  --shadow-1: 0 1px 0 rgba(15,18,24,0.04), 0 1px 2px rgba(15,18,24,0.04);
  --shadow-2: 0 4px 14px rgba(15,18,24,0.06), 0 2px 4px rgba(15,18,24,0.04);
  --shadow-3: 0 20px 50px rgba(15,18,24,0.14), 0 4px 14px rgba(15,18,24,0.06);
  /* Small floating popovers (dropdown lists, context menus) — lighter than --shadow-3's modal
     elevation. Not redefined per theme: the two call sites (RequirementSetPicker, SetTreePanel's
     tree-menu) used this exact flat rgba in both themes before it was a token. */
  --shadow-dropdown: 0 4px 12px rgba(0,0,0,.15);
  /* CORE-UX-03: the last flat shadows and scrims, moved here from their rules so no colour is
     written outside these two blocks (DesignSystemScan). Not redefined per theme: each was the same
     black in both themes before it was a token. */
  --shadow-drawer: -8px 0 24px rgba(0,0,0,.25);   /* the help drawer, along its left edge */
  --shadow-float: 0 8px 24px rgba(0,0,0,.3);      /* the tour's tip card */
  --scrim: rgba(0,0,0,0.5);                       /* behind a dialog (.modal-overlay) */
  --scrim-soft: rgba(0,0,0,.35);                  /* behind the help drawer */
  --scrim-strong: rgba(0,0,0,.55);                /* the tour's dimming and spotlight */

  /* Text on a swatch a person or the data chose — the classification bar (a company's colour),
     severity cells in the traceability matrix, file-format badges — and the avatar's initials.
     The background is data, so no pair in DesignTokenContrastTests can hold it; the token keeps
     the choice in one place. Same in both themes. */
  --on-swatch: #FFFFFF;
  --avatar-from: #6B8DFF;
  --avatar-to: #9D8DFF;

  /* Categorical palette: the import wizard's regex fields — the highlight on the sample text
     (.hl-N) and the legend dot beside each pattern (.color-dot-N). Decorative, never text; the
     hue identifies the field, the field's label says what it is. -line is the highlight's
     underline, a lighter hue in the dark theme; the tint and line strengths change with it. */
  --cat-0: rgb(46, 91, 255);    /* delimiter - blue */
  --cat-1: rgb(16, 185, 129);   /* externalId - green */
  --cat-2: rgb(245, 158, 11);   /* title - amber */
  --cat-3: rgb(168, 85, 247);   /* description - purple */
  --cat-4: rgb(236, 72, 153);   /* version - pink */
  --cat-5: rgb(20, 184, 166);   /* mapping - teal */
  --cat-6: rgb(251, 146, 60);   /* verification - orange */
  --cat-0-line: var(--cat-0);
  --cat-1-line: var(--cat-1);
  --cat-2-line: var(--cat-2);
  --cat-3-line: var(--cat-3);
  --cat-4-line: var(--cat-4);
  --cat-5-line: var(--cat-5);
  --cat-6-line: var(--cat-6);
  --cat-tint: 18%;
  --cat-line-mix: 60%;

  --font-sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme='dark'] {
  --bg: #08090C;
  --bg-deep: #050609;
  --surface: #0F1115;
  --surface-2: #14171C;
  --surface-3: #1A1E25;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.12);
  --border-emph: rgba(255,255,255,0.22);
  --ink: #ECEEF2;
  --ink-2: #C7CBD3;
  --ink-3: #8C92A0;
  --ink-4: #818799;
  --ink-5: #5E6473;
  --accent: #FF8638;
  --accent-ink: #FF8638;
  --accent-soft: rgba(255, 134, 56, 0.16);
  --accent-line: rgba(255, 134, 56, 0.40);
  --ok: #3FCB91;
  --ok-soft: rgba(63, 203, 145, 0.16);
  --warn: #E8A33D;
  --warn-soft: rgba(232, 163, 61, 0.18);
  --err: #F26A60;
  --err-soft: rgba(242, 106, 96, 0.16);
  --on-err: #1A0706;
  --info: #9D8DFF;
  --info-soft: rgba(157, 141, 255, 0.18);
  --control-border: rgba(255, 255, 255, 0.35);
  --focus: #FF8638;
  --classification: #E89B53;
  --shadow-1: 0 1px 0 rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.4);
  --shadow-2: 0 4px 14px rgba(0,0,0,0.45), 0 2px 4px rgba(0,0,0,0.30);
  --shadow-3: 0 20px 50px rgba(0,0,0,0.55), 0 4px 14px rgba(0,0,0,0.4);
  --cat-0-line: rgb(96, 135, 255);
  --cat-1-line: rgb(52, 211, 153);
  --cat-2-line: rgb(251, 191, 36);
  --cat-3-line: rgb(192, 132, 252);
  --cat-4-line: rgb(244, 114, 182);
  --cat-5-line: rgb(45, 212, 191);
  --cat-6-line: rgb(253, 186, 116);
  --cat-tint: 25%;
  --cat-line-mix: 70%;
}

[data-density='compact'] { --row-h: 28px; --gutter: 12px; }
[data-density='cozy']    { --row-h: 34px; --gutter: 16px; }
[data-density='comfy']   { --row-h: 42px; --gutter: 20px; }

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}
#app { height: 100vh; overflow: hidden; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: transparent; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
code, .mono { font-family: var(--font-mono); }

/* ============ App Layout ============ */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 36px 1fr;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
}
[data-nav='wide'] .app { grid-template-columns: 260px 1fr; }
[data-nav='narrow'] .app { grid-template-columns: 56px 1fr; }

.classification-bar {
  grid-column: 1 / -1;
  background: var(--classification);
  color: var(--on-swatch);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  display: flex; align-items: center; justify-content: center;
  gap: 24px;
}
/* The edition badge rides the bar, whose background is the classification colour, so the base
   .pill's surface/ink tokens would sit on it as a pale box. Tint it from the bar's own text
   colour instead — one rule, no colour named, legible on every classification. */
.classification-bar .pill {
  background: color-mix(in srgb, currentColor 18%, transparent);
  border-color: color-mix(in srgb, currentColor 45%, transparent);
  color: inherit;
  letter-spacing: 0.08em;
}

/* ============ Sidebar ============ */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.sidebar-head {
  padding: 14px 14px 10px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-mark-svg { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px; }
.logo-text { font-weight: 600; font-size: var(--fs-body); letter-spacing: -0.01em; }
.logo-text small {
  display: block; font-size: var(--fs-2xs); color: var(--ink-3);
  letter-spacing: 0.06em; text-transform: uppercase; font-weight: 500; margin-top: 1px;
}
.project-switch {
  margin: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-sm);
  background: var(--surface-2);
  flex-shrink: 0;
}
/* A <button> (CORE-UX-06): reachable and operable by keyboard. */
button.project-switch { width: calc(100% - 20px); text-align: left; font: inherit; color: inherit; cursor: pointer; }
.project-switch .meta, .project-switch .name, .project-switch .sub { display: block; }
.project-switch .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }
.project-option { width: 100%; padding: 6px 10px; font: inherit; font-size: var(--fs-xs); color: inherit; text-align: left;
  cursor: pointer; display: flex; align-items: center; gap: 6px; background: transparent; border: 0; border-bottom: 1px solid var(--border); }
.project-option:hover { background: var(--surface-3); }
.project-switch .meta { flex: 1; min-width: 0; }
.project-switch .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-switch .sub { color: var(--ink-3); font-size: var(--fs-2xs); font-family: var(--font-mono); }

/* Dashboard, above the project selector: company-level, so outside the project's groups. */
.sidebar-lead { padding: 8px 8px 0; flex-shrink: 0; }
/* The selected project's Details and Settings links, directly under the selector (CORE-UX-12). */
.project-links { display: flex; gap: 6px; margin: -4px 10px 8px; }
.project-links .btn { flex: 1; justify-content: center; }
.project-links .btn[aria-current="page"] { background: var(--surface-3); color: var(--ink); }
.nav { flex: 1; overflow-y: auto; padding: 4px 8px 8px; min-height: 0; }
.nav-section { margin-top: 10px; }
.nav-section-label {
  font-size: var(--fs-2xs); letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--ink-4); padding: 8px 8px 4px; font-weight: 500;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 5px;
  color: var(--ink-2); font-size: var(--fs-body); cursor: pointer; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--surface-2); color: var(--ink); }
.nav-item.active::before {
  content: ''; position: absolute; left: -8px; top: 6px; bottom: 6px;
  width: 2px; background: var(--ink); border-radius: 2px;
}
.nav-item .nav-label { flex: 1; }
.nav-item .nav-count {
  font-family: var(--font-mono); font-size: var(--fs-2xs);
  color: var(--ink-4); background: var(--surface-3); padding: 1px 6px; border-radius: 3px;
}
.nav-item .nav-count.bad { color: var(--err); background: var(--err-soft); }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 10px;
  display: flex; align-items: center; gap: 10px;
  font-size: var(--fs-xs);
  flex-shrink: 0;
}
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--avatar-from), var(--avatar-to));
  display: grid; place-items: center;
  color: var(--on-swatch); font-weight: 600; font-size: var(--fs-2xs); font-family: var(--font-mono);
  flex-shrink: 0;
}
.sidebar-foot .who { flex: 1; min-width: 0; }
.sidebar-foot .who .n { font-weight: 500; }
.sidebar-foot .who .s { color: var(--ink-3); font-size: var(--fs-xs); }

/* ============ Main + Topbar ============ */
.main {
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0; /* grid item: without this, wide descendants (matrix tables) grow the
                   1fr column past the viewport instead of scrolling inside their own
                   overflow-x:auto wrapper — the classic CSS grid "blowout" trap. */
  min-height: 0;
  background: var(--bg);
}
.topbar {
  height: 44px; min-height: 44px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center;
  padding: 0 16px; gap: 12px;
  flex-shrink: 0;
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--ink-3); }
.crumbs .sep { color: var(--ink-5); }
.crumbs .cur { color: var(--ink); font-weight: 500; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.search-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--ink-3); font-size: var(--fs-sm); min-width: 200px;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.search-pill:focus-within {
  border-color: var(--accent); background: var(--surface-3);
}
.search-pill:hover {
  border-color: var(--border-strong); background: var(--surface-3);
}
.search-inline {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: var(--fs-sm); font-family: var(--font-sans); color: var(--ink);
  min-width: 0;
}
.search-inline::placeholder { color: var(--ink-4); }
.search-dropdown {
  position: absolute; top: calc(100% + 4px); right: -12px;
  min-width: min(400px, 100vw - 32px); max-width: calc(100vw - 32px); max-height: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-3);
  overflow-y: auto; z-index: 200;
}
.kbd {
  font-family: var(--font-mono); font-size: var(--fs-2xs);
  padding: 2px 5px; border: 1px solid var(--border-strong);
  border-radius: 3px; color: var(--ink-3); background: var(--surface-2);
}

.page-content { flex: 1; overflow-y: auto; }

/* ============ Page ============ */
.page { padding: 18px 22px 60px; max-width: 1480px; width: 100%; margin: 0 auto; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; padding-bottom: 14px; margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: var(--fs-title); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin: 0; }
/* FocusOnNavigate (App.razor) programmatically focuses each page's h1 for screen-reader
   announcements; headings aren't interactively tabbable (tabindex=-1), so suppress the
   browser's focus ring on them without touching focus styles of real controls. */
h1:focus, h2:focus, h3:focus { outline: none; }
/* CORE-UX-06: one visible keyboard-focus indicator for everything focusable. :focus-visible, so
   a mouse click does not draw it; the text inputs keep their own border+halo (above). */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.input:focus-visible, .select:focus-visible { outline: none; }
.page-eyebrow {
  font-family: var(--font-mono); font-size: var(--fs-2xs);
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-4); margin-bottom: 6px;
}
.page-sub { color: var(--ink-3); font-size: var(--fs-body); margin-top: 4px; max-width: 640px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 5px; font-size: var(--fs-sm); font-weight: 500;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink-2); white-space: nowrap;
  transition: background 0.08s ease, border-color 0.08s;
}
.btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border-emph); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: 0.92; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--err); border-color: var(--border); }
.btn.danger:hover { background: var(--err-soft); border-color: var(--err); }
/* The confirm button of a destructive action (ConfirmDialog, CORE-UX-05): filled, never an inline
   style on a .btn.primary. --on-err is checked against --err in DesignTokenContrastTests. */
.btn.danger.solid { background: var(--err); border-color: var(--err); color: var(--on-err); }
.btn.danger.solid:hover { background: var(--err); border-color: var(--err); color: var(--on-err); opacity: 0.92; }
.btn.danger.solid:disabled { opacity: 0.6; }
/* CORE-UX-04: a chosen tab, toggle or wizard step is SELECTED, not a main action. The filled
   .btn.primary is reserved for the one main action in a page's head (PrimaryActionScan); the state
   reaches assistive tech through aria-pressed / aria-current="step", and the look is keyed on the
   same attribute so the two cannot disagree. --accent-ink on --accent-soft is a pair
   DesignTokenContrastTests checks. Declared after .btn.ghost so a pressed ghost toggle shows its
   border, and with its own :hover so hovering does not hide which one is chosen. */
.btn[aria-pressed="true"], .btn[aria-current="step"] { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-ink); }
.btn[aria-pressed="true"]:hover, .btn[aria-current="step"]:hover { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-ink); }
.btn.sm { padding: 3px 7px; font-size: var(--fs-xs); gap: 4px; }
.btn.lg { padding: 8px 14px; font-size: var(--fs-body); }
.btn svg { width: 13px; height: 13px; }
.btn.btn-icon { padding: 5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ Pills / Badges ============ */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: 3px; font-size: var(--fs-2xs); font-weight: 500;
  font-family: var(--font-mono); letter-spacing: 0.02em; text-transform: uppercase;
  background: var(--surface-3); color: var(--ink-2); border: 1px solid var(--border); white-space: nowrap;
}
.pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pill.err { color: var(--err); background: var(--err-soft); border-color: transparent; }
.pill.info { color: var(--info); background: var(--info-soft); border-color: transparent; }
.pill.accent { color: var(--accent-ink); background: var(--accent-soft); border-color: transparent; }
/* Review inbox: category/severity/verdict pills read too small and faint at the base .pill
   size — bump size+weight for all three, and additionally deepen the verdict pill's background
   (via color-mix over transparent, so it scales with each theme's own semantic color rather than
   a hardcoded overlay) since the verdict is the single most load-bearing pill on the card. */
.pill-lg { font-size: var(--fs-body); padding: 4px 11px; font-weight: 600; }
.pill-lg:not(.ok):not(.warn):not(.err):not(.info):not(.accent) { color: var(--ink); }
/* Verdict pills read at body size with max-contrast ink (black in light theme); the
   stronger tint keeps the semantic color legible under the darker text. */
.verdict-pill.ok, .verdict-pill.warn, .verdict-pill.err, .verdict-pill.info { color: var(--ink); }
.verdict-pill.ok { background: color-mix(in srgb, var(--ok) 34%, transparent); }
.verdict-pill.warn { background: color-mix(in srgb, var(--warn) 34%, transparent); }
.verdict-pill.err { background: color-mix(in srgb, var(--err) 34%, transparent); }
.verdict-pill.info { background: color-mix(in srgb, var(--info) 34%, transparent); }
.set-type-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid color-mix(in srgb, var(--type-color) 35%, transparent); background: color-mix(in srgb, var(--type-color) 12%, transparent); color: var(--ink-2); }
.set-type-pill .type-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--type-color); flex: none; }

.id-chip {
  font-family: var(--font-mono); font-size: var(--fs-2xs); padding: 1px 6px;
  border-radius: 3px; background: var(--surface-3); color: var(--ink-2); letter-spacing: -0.01em;
}
.tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-2xs);
  padding: 1px 6px; border-radius: 3px; background: var(--surface-3); color: var(--ink-2);
  font-family: var(--font-mono);
}

/* A chip carrying text the reader has to READ — a requirement's id, the company's status name,
   the scope a link arrived with — rather than a decoration beside words they have already read.
   --fs-2xs is 11px; the legibility rule puts nothing new below --fs-xs, so these opt up a step. */
.id-chip.readable, .tag.readable { font-size: var(--fs-xs); padding: 2px 7px; }

/* ============ Cards ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border); gap: 12px;
}
.card-head h3 { font-size: var(--fs-h3); font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.card-head .sub { font-size: var(--fs-xs); color: var(--ink-3); }
.card-body { padding: 14px; }
.card-body.flush { padding: 0; }

/* ============ Grid ============ */
.grid { display: grid; gap: var(--gutter); }
.grid.c2 { grid-template-columns: 1fr 1fr; }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }

/* ============ Stat cards ============ */
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 4px;
}
.stat .lbl { font-size: var(--fs-2xs); color: var(--ink-3); letter-spacing: 0.04em; text-transform: uppercase; font-weight: 500; }
.stat .val { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; font-family: var(--font-mono); line-height: 1.05; margin-top: 2px; }
.stat .delta { font-size: var(--fs-xs); display: flex; align-items: center; gap: 4px; color: var(--ink-3); margin-top: 2px; }
.stat .delta.up { color: var(--ok); }
.stat .delta.down { color: var(--err); }
/* A count is a link to the list it counts (CORE-UX-02); it reads as a card until pointed at. */
a.stat { transition: border-color 0.08s, background 0.08s; }
a.stat:hover { border-color: var(--border-emph); background: var(--surface-2); }

/* ============ Review inbox zones (summary / filters / items) ============ */
/* Larger gap between zones than the internal gaps within each zone, so the three
   blocks read as distinct regions rather than one continuous run of controls. */
.review-zone + .review-zone { margin-top: calc(var(--gutter) * 1.75); }
.review-zone-label {
  font-size: var(--fs-2xs); letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--ink-4); font-weight: 500; margin-bottom: 8px;
}
.review-filters {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px;
}
.review-items-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding-bottom: 8px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.review-items-head .count { font-size: var(--fs-sm); color: var(--ink); font-weight: 500; }
.review-items-head .hint { font-size: var(--fs-xs); color: var(--ink-3); }

/* ============ Table ============ */
.table-wrap { width: 100%; overflow: auto; }
table.req-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.req-table thead th {
  text-align: left; font-weight: 500; font-size: var(--fs-2xs); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3); padding: 8px 12px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.req-table tbody td {
  padding: 0 12px; border-bottom: 1px solid var(--border);
  height: var(--row-h); vertical-align: middle; color: var(--ink-2);
}
.req-table tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.req-table td.num { font-family: var(--font-mono); font-size: var(--fs-xs); }
/* CORE-UX-09: a numeric column sits under its heading. Both are right-aligned (the heading rule must
   outrank ".req-table thead th"), and the column is no wider than its widest value or heading. */
.req-table thead th.num, .req-table tbody td.num { text-align: right; width: 1%; white-space: nowrap; }

.requirements-content { min-width: 0; }
/* Title and Description take what the fixed columns leave. Each min-width is twice the fixed columns,
   plus a margin, in that layout, so the text keeps over half the row; past it the grid scrolls sideways
   rather than squeezing the text. Wide: ID, Status, Implementation, Ext ver, Compliance, Verification,
   Created and the menu, 864px fixed -> 1520px. Narrow (below the grid's NarrowBelow, 1520): ID, Status,
   one state column (Compliance 132px where the edition has it, else Implementation 148px) and the
   menu, at most 469px fixed -> 960px, which a 1280px window's ~990px grid (after a scrollbar) holds without a sideways
   scroll (CORE-UX-01). Change both with the column widths. */
.requirements-grid .rz-grid-table { min-width: 1520px; }
.requirements-grid td.requirement-title { font-weight: 500; }
.requirements-grid .status-pill { white-space: normal; }
.requirements-grid.is-narrow .rz-grid-table { min-width: 960px; }
.requirement-detail-meta { font-size: var(--fs-xs); margin-bottom: 8px; }
.requirement-status-editor { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.requirement-status-editor .select-menu { width: 100%; }
.requirement-status-editor .select-menu-trigger { width: 100%; font-size: var(--fs-xs); }

/* ============ Data grid (AppDataGrid, ADR-0026) ============ */
/* The variables are set on .rz-data-grid itself, not on .app-grid: Radzen's density class redefines
   several of them on that element, and its derived ones (cell colour from text colour, …) are
   resolved at :root, so only the grid-level names can be overridden from here. */
.app-grid { container: app-grid / inline-size; }
.app-grid .rz-data-grid {
  --rz-grid-background-color: var(--surface);
  --rz-grid-border: none;
  --rz-grid-data-border-shadow: none;
  --rz-grid-cell-border: 1px solid var(--border);
  --rz-grid-bottom-cell-border: 1px solid var(--border);
  --rz-grid-right-cell-border: none;
  --rz-grid-cell-color: var(--ink-2);
  --rz-grid-cell-font-size: var(--fs-sm);
  --rz-grid-cell-line-height: 1.5;
  --rz-grid-cell-padding: 10px 12px;
  --rz-grid-header-background-color: var(--surface-2);
  --rz-grid-header-sorted-background-color: var(--surface-2);
  --rz-grid-header-cell-border: 1px solid var(--border);
  --rz-grid-header-cell-border-bottom: 1px solid var(--border);
  --rz-grid-header-color: var(--ink-3);
  --rz-grid-header-font-size: var(--fs-2xs);
  --rz-grid-header-font-weight: 500;
  --rz-grid-header-line-height: 1.4;
  --rz-grid-header-text-transform: uppercase;
  --rz-grid-header-cell-padding: 8px 0;
  --rz-grid-header-title-padding-inline: 12px 0;
  --rz-grid-hover-background-color: var(--surface-2);
  --rz-grid-hover-color: var(--ink-2);
  --rz-grid-stripe-background-color: var(--surface);
  --rz-grid-stripe-odd-background-color: var(--surface);
  --rz-grid-frozen-cell-background-color: var(--surface);
  --rz-grid-frozen-stripe-background-color: var(--surface);
  --rz-grid-frozen-stripe-odd-background-color: var(--surface);
  --rz-grid-frozen-cell-border: 1px solid var(--border);
  --rz-grid-detail-template-background-color: var(--surface-2);
  --rz-grid-column-resizer-helper-background-color: var(--accent);
  --rz-grid-focus-outline: 2px solid var(--focus);
  --rz-grid-cell-focus-outline: 2px solid var(--focus);
  --rz-grid-cell-focus-background-color: transparent;
  --rz-grid-cell-focus-color: var(--ink-2);
  font-family: var(--font-sans); font-size: var(--fs-sm); color: var(--ink-2);
  /* Bounded, so both scrollbars stay on screen however long the list is. */
  max-height: var(--app-grid-max-h, max(320px, calc(100dvh - 300px)));
  min-height: 0;
}
.app-grid .rz-grid-table thead th { letter-spacing: 0.06em; text-align: left; }
.app-grid .rz-grid-table thead th .rz-column-title { overflow: hidden; text-overflow: ellipsis; }
/* Cells wrap instead of ellipsing: a requirement's wording is the content, not a label. A cell
   still clips at its own edge, so nothing paints over the column beside it. */
.app-grid .rz-grid-table td { vertical-align: top; }
.app-grid .rz-grid-table td .rz-cell-data { white-space: normal; overflow-wrap: break-word; text-overflow: clip; }
.app-grid .rz-grid-table td.grid-cell-nowrap .rz-cell-data { white-space: nowrap; }
.app-grid .rz-grid-table td.grid-cell-prewrap, .app-grid .rz-grid-table td.grid-cell-prewrap .rz-cell-data { white-space: pre-wrap; }
.app-grid .rz-grid-table td.grid-cell-xs .rz-cell-data { font-size: var(--fs-xs); }
.app-grid .rz-grid-table td.dim .rz-cell-data { color: var(--ink-3); }
/* CORE-UX-02: a row or card that opens something is a real link. The item's name is an
   <a class="row-open">, stretched over the whole row by ::after, so a primary click anywhere on
   the row opens it, middle- and Ctrl-click open a tab, and Tab reaches it. Other controls in the
   row sit above the stretched link and keep their own clicks. */
.linked-row, .linked-card { position: relative; cursor: pointer; }
.linked-row:hover > td, .linked-card:hover { background: var(--surface-2); }
:where(a.row-open) { color: inherit; }
a.row-open::after { content: ''; position: absolute; inset: 0; }
.linked-row :is(a, button, input, textarea, label, .select-menu):not(.row-open),
.linked-card :is(a, button, input, textarea, label, .select-menu):not(.row-open) { position: relative; z-index: 1; }
/* The same inside AppDataGrid when it is given ItemHref: the row is marked data-linked (a class set
   through RowRender would replace Radzen's own), and the link lives in a 1px column of its own. A
   frozen cell is sticky and stacked above the row, so it would swallow a click meant for the link
   under it: let the click through, and keep the cell's own controls clickable. */
.app-grid tr.rz-data-row[data-linked] { position: relative; cursor: pointer; }
.app-grid tr.rz-data-row[data-linked]:hover > td { background: var(--surface-2); }
.app-grid tr.rz-data-row[data-linked] > td :is(a, button, input, textarea, label, .select-menu, .item-menu):not(.row-open) { position: relative; z-index: 1; }
.app-grid tr.rz-data-row[data-linked] > td.rz-frozen-cell { pointer-events: none; }
.app-grid tr.rz-data-row[data-linked] > td.rz-frozen-cell :is(a, button, input, textarea, label, .select-menu, .item-menu) { pointer-events: auto; }
.app-grid .rz-grid-table :is(td, th).grid-cell-open { padding: 0; border-left: 0; border-right: 0; }
/* The link has no width of its own, so its focus ring is drawn on the row it covers. */
a.grid-row-link:focus-visible { outline: none; }
a.grid-row-link:focus-visible::after { outline: 2px solid var(--focus); outline-offset: -2px; }
.app-grid-clickable tr.rz-data-row { cursor: pointer; }
.app-grid-clickable tr.rz-data-row:hover > td { background: var(--surface-2); }
.app-grid tr[data-row-state~="deep-link"] > td { background: var(--accent-soft); }
.app-grid tr[data-row-state~="deep-link"] { outline: 2px solid var(--focus); outline-offset: -2px; }
/* The detail spans the whole table, which can be wider than the grid; pin it to the visible width
   so it does not scroll away sideways with the columns. The cell must not clip: an overflow:hidden
   cell becomes the sticky element's scroll container, and it never scrolls, so nothing sticks. */
.app-grid tr.rz-expanded-row-content > td { overflow: visible; padding: 0; background: var(--surface-2); }
.app-grid .rz-expanded-row-template { position: sticky; left: 0; max-width: 100cqi; box-sizing: border-box; padding: 12px 16px; }
/* Being sticky, the detail is a stacking context at z-index auto, so a menu opened inside it —
   whatever its own z-index — paints under the grid's sticky header (z-index 2). A dropdown near
   the foot of the viewport flips upwards, into the header, which then covered its top options and
   swallowed the clicks meant for them. Lift the detail above the header while a menu is open. */
.app-grid .rz-expanded-row-template:has(.select-menu-panel, .item-menu.open) { z-index: 3; }
/* What a narrow grid's dropped columns said, repeated where the row's detail can show it. */
.grid-narrow-only { display: none; }
.app-grid.is-narrow .grid-narrow-only { display: block; }

/* The stage breakdown under a task's progress count ("1 profiling + 17 requirements + 42 pairs").
   It exists to be read — it is the thing that stops the total being mistaken for a requirement
   count — so it sits at --fs-xs (the hint/metadata size) rather than the --fs-2xs micro-label size,
   and at --ink-3 rather than the fainter --ink-4. */
.plan-parts {
  margin-top: 3px;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  line-height: 1.4;
  color: var(--ink-3);
  white-space: nowrap;
}

/* ============ Forms ============ */
.input, .select {
  width: 100%; padding: 6px 9px;
  background: var(--surface); border: 1px solid var(--control-border);
  border-radius: 5px; font-size: var(--fs-sm); color: var(--ink); outline: none;
  transition: border-color 0.08s, box-shadow 0.08s;
}
.input:focus, .select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
label.field { display: block; }
/* A field whose control is not one labelable element — a checkbox group, or a read-only value
   beside a picker — is a div rather than a label, and its caption has to read the same. */
label.field .l, .field > .l, .vstack > .l {
  display: block; font-size: var(--fs-2xs); color: var(--ink-3);
  letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 4px; font-weight: 500;
}
.validation-message { color: var(--err); font-size: var(--fs-xs); margin-top: 3px; }

/* ============ Select Menu (the one panel-style dropdown — native <select> is banned) ======= */
.select-menu { position: relative; }
.select-menu-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  cursor: pointer; background: var(--surface); text-align: left; font-family: inherit;
}
.select-menu-trigger:disabled { cursor: not-allowed; opacity: 0.6; }
.select-menu-value {
  display: flex; align-items: center; gap: 6px; overflow: hidden; flex: 1; min-width: 0;
}
.select-menu-value .select-menu-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-menu-caret { flex: none; color: var(--ink-3); transition: transform 0.1s; }
.select-menu-caret.open { transform: rotate(180deg); }
.select-menu-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.select-menu-backdrop { position: fixed; inset: 0; z-index: 60; background: transparent; border: none; padding: 0; cursor: default; }
/* Stays `absolute` here on purpose. An absolutely-positioned panel is cropped by the nearest
   ancestor with a non-visible overflow — and .card (overflow:hidden, for its rounded corners)
   is one of those — so js/floating-menu.js re-pins the panel to the viewport with `fixed` as
   soon as it renders (see SelectMenu.razor). These rules are the floor if that script is ever
   missing: cropped in the same places it always was, rather than unpositioned. */
.select-menu-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 61;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  max-height: 260px; overflow-y: auto; box-shadow: var(--shadow-dropdown); padding: 4px 0;
}
button.select-menu-option { width: 100%; background: none; border: 0; font: inherit; color: inherit; text-align: left; }
.select-menu-option {
  padding: 6px 10px; font-size: var(--fs-xs); cursor: pointer; display: flex;
  align-items: center; justify-content: space-between; gap: 8px;
}
.select-menu-option:hover, .select-menu-option.highlight { background: var(--surface-3); }
.select-menu-option.disabled { cursor: not-allowed; opacity: 0.5; pointer-events: none; }
.select-menu-option .select-menu-check { flex: none; color: var(--accent-ink); }
.select-menu-empty { padding: 8px 10px; font-size: var(--fs-xs); color: var(--ink-4); }
/* CORE-UX-01: inside an open panel a long label wraps instead of being ellipsised — the panel is
   where somebody reads the names to tell them apart. (The trigger still ellipsises by default;
   .set-picker lets it wrap too.) */
.select-menu-panel .select-menu-value .select-menu-label { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
/* The searchable form: the filter box stays put at the top and only the list scrolls. */
.select-menu-panel.searchable { display: flex; flex-direction: column; overflow: hidden; padding: 0; max-height: min(420px, calc(100vh - 32px)); }
.select-menu-search { flex: none; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.select-menu-search-input { font-size: var(--fs-sm); }
.select-menu-list { overflow-y: auto; min-height: 0; padding: 4px 0; }
/* A group heading is a caption, not an option: it reads like a field caption and takes no hover. */
.select-menu-group + .select-menu-group, .select-menu-option + .select-menu-group { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 2px; }
.select-menu-group-head {
  padding: 8px 10px 4px; font-size: var(--fs-2xs); font-weight: 500; color: var(--ink-3);
  letter-spacing: 0.04em; text-transform: uppercase; overflow-wrap: anywhere; cursor: default;
}
.select-menu-group .select-menu-option { padding-left: 16px; }

/* The requirement-set picker (RequirementSetPicker): the full name, its kind and its count. The
   name wraps — in the panel and in the trigger — rather than hiding its end. */
.set-picker .select-menu-trigger { height: auto; }
.set-picker .select-menu-trigger .set-picker-name { white-space: normal; overflow-wrap: anywhere; }
.set-picker-option { display: flex; align-items: center; gap: 8px 12px; flex: 1; min-width: 0; flex-wrap: wrap; }
.set-picker-name { flex: 1 1 16rem; min-width: 0; font-size: var(--fs-sm); color: var(--ink); white-space: normal; overflow-wrap: anywhere; }
.set-picker-meta { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.set-picker-count { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; }

/* The selector bar (CORE-UX-01): the chooser of the page's item sits above the content it chooses,
   never in a side column, so the content has the page's full width. The chooser takes what the
   bar's buttons leave; the buttons stay on one line beside it and wrap below it on a narrow screen. */
.selector-bar { display: flex; align-items: flex-end; gap: 8px 12px; flex-wrap: wrap; margin-bottom: var(--gutter); }
.selector-bar > .field, .selector-bar > .selector-bar-chooser { flex: 1 1 28rem; min-width: 0; max-width: 64rem; margin: 0; }
.selector-bar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
/* The management dialog's tree reads at full dialog width; its own card frame is redundant there. */
.manage-dialog .modal-body > .card { border: 0; box-shadow: none; }

/* ============ Item menu (the "⋯" on a row or card — CORE-UX-02) ============
   Hangs off the trigger's right edge (js/floating-menu.js, 'right'); its entries are actions, read
   at body size rather than the dropdown's compact size. */
.item-menu { position: relative; display: inline-flex; }
.item-menu-panel { left: auto; right: 0; min-width: 168px; }
.item-menu-panel .select-menu-option { font-size: var(--fs-sm); padding: 7px 12px; }
.item-menu-panel .select-menu-option.danger { color: var(--err); }
.item-menu-panel .select-menu-option:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--surface-3); }
/* A frozen grid cell is a stacking context at z-index 1, as is every frozen cell below it, which
   would paint over the open menu; the cell holding an open menu is raised above its neighbours. */
.app-grid .rz-grid-table td:has(.item-menu.open) { z-index: 3; }
.app-grid .rz-grid-table td.grid-cell-menu .rz-cell-data { overflow: visible; }

/* ============ Misc utilities ============ */
.divider { height: 1px; background: var(--border); width: 100%; }
.spacer { flex: 1; }
.hstack { display: flex; align-items: center; gap: 8px; }
.vstack { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--ink-3); }
.dim { color: var(--ink-4); }
.prewrap { white-space: pre-wrap; word-break: break-word; }

/* ============ Modals ============ */
.modal-overlay {
  position: fixed; inset: 0; background: var(--scrim); z-index: 100;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
/* The box never grows past the viewport, and it is the BODY that scrolls when the content is
   taller — head and footer stay put. Without this a tall dialog (the project editor, with its keys
   card and its edition section) simply runs off the bottom of the screen and takes Save Changes
   with it: the primary action of the dialog, unreachable, with nothing on screen suggesting there
   is more. min-height:0 is what lets the body shrink at all — a flex item defaults to its content's
   height and would otherwise refuse to scroll. */
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; width: 480px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  box-shadow: var(--shadow-3); display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.modal-body { padding: 16px; overflow-y: auto; min-height: 0; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border);
}

/* Raw AI prompt/response blocks in the import AI log */
.ai-log-pre {
  font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; margin: 4px 0 10px;
  white-space: pre-wrap; word-break: break-word;
  max-height: 240px; overflow-y: auto;
}

/* ============ Login ============ */
.login-page {
  min-height: 100vh; background: var(--bg);
  /* EmptyLayout wraps this in [data-theme=dark]; set the text colour here so headings
     resolve against the dark tokens instead of inheriting body's light --ink. */
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 28px; box-shadow: var(--shadow-2);
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-title { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 20px; }
.login-hint {
  margin-top: 16px; padding: 10px 12px;
  background: var(--surface-2); border-radius: 5px;
  font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.7;
}
.login-hint code { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent-ink); }
.login-hint a { color: var(--accent-ink); text-decoration: none; cursor: pointer; font-weight: 500; }
.login-hint a:hover { text-decoration: underline; }

/* ============ Alerts ============ */
.alert-err {
  padding: 8px 12px; background: var(--err-soft); border: 1px solid var(--err);
  border-radius: 5px; color: var(--err); font-size: var(--fs-sm);
}
.alert-ok {
  padding: 8px 12px; background: var(--ok-soft); border: 1px solid var(--ok);
  border-radius: 5px; color: var(--ok); font-size: var(--fs-sm);
}
.alert-warn {
  padding: 8px 12px; background: var(--warn-soft); border: 1px solid var(--warn);
  border-radius: 5px; color: var(--warn); font-size: var(--fs-sm);
}
.alert-info {
  padding: 8px 12px; background: var(--info-soft); border: 1px solid var(--info);
  border-radius: 5px; color: var(--info); font-size: var(--fs-sm);
}
a.id-chip { text-decoration: none; }
a.id-chip:hover { text-decoration: underline; }

/* ============ Inline spinner ============ */
.spinner-inline {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.6s linear infinite;
  vertical-align: middle; margin-left: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Loading state (CORE-UX-08) ============ */
/* LoadingState.razor: a list that is loading says so. Same scale as .empty so the swap from one
   to the other does not jump the page more than it must. */
.loading-state {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 32px 20px; color: var(--ink-3); font-size: var(--fs-sm);
}
.loading-state.inline { display: inline-flex; justify-content: flex-start; padding: 4px 0; }
.loading-spinner {
  flex: none; display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .loading-spinner, .spinner-inline { animation: none; }
}

/* ============ Empty state ============ */
.empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 60px 20px; color: var(--ink-3); gap: 8px;
}
.empty h3 { color: var(--ink); margin: 0; font-size: 15px; font-weight: 600; }
.empty p { margin: 0; font-size: var(--fs-sm); max-width: 380px; }
/* An empty state inside a card, a dialog or a table cell: the same parts at a size that does not
   push the surrounding controls off screen (EmptyGuidance Compact). */
.empty.compact { padding: 20px 16px; }

/* An empty state, but for a page reached for the wrong edition rather than for missing data —
   informational, not an error, so it borrows --info (dashed, not solid) instead of --err. */
.edition-absent {
  background: var(--info-soft); border: 1px dashed var(--info); border-radius: var(--radius);
}
.edition-absent h3 { color: var(--info); }
.edition-absent .btn { margin-top: 4px; }

/* ============ Blazor Error UI ============ */
#blazor-error-ui {
  background: var(--surface);
  border: 1px solid var(--err);
  border-radius: var(--radius);
  box-shadow: var(--shadow-dropdown);
  bottom: 12px; display: none; left: 244px; right: 12px;
  padding: 10px 40px 10px 16px; position: fixed; width: auto; max-width: 400px; z-index: 1000;
  color: var(--err); font-size: var(--fs-xs);
}
#blazor-error-ui .dismiss {
  cursor: pointer; position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 14px; color: var(--ink-3); text-decoration: none;
  transition: background 0.15s;
}
#blazor-error-ui .dismiss:hover { background: var(--surface-2); }

.loading-progress {
  display: block; width: 6rem; height: 6rem; margin: 30vh auto 1rem;
}
.loading-progress circle {
  fill: none; stroke: var(--surface-3); stroke-width: 0.6rem;
  transform-origin: 50% 50%; transform: rotate(-90deg);
}
.loading-progress circle:last-child {
  stroke: var(--accent);
  stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
  transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
  position: absolute; text-align: center; font-weight: 600;
  inset: calc(30vh + 4rem) 0 auto 0.2rem; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-3);
}
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

/* ============ Search Results (inline dropdown) ============ */
.search-dropdown .search-group:first-child { margin-top: 0; }
.search-group {
  font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--ink-4);
  padding: 8px 16px 4px; margin-top: 2px;
}
.search-hit {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; cursor: pointer; transition: background 0.1s;
}
.search-hit:hover, .search-hit.selected {
  background: var(--accent-soft);
}
.search-hit svg { color: var(--ink-3); flex-shrink: 0; }
.search-hit-text {
  display: flex; flex-direction: column; min-width: 0;
}
.search-hit-title {
  font-size: var(--fs-body); font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-hit-sub {
  font-size: var(--fs-xs); color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-empty {
  padding: 24px 16px; text-align: center;
  color: var(--ink-4); font-size: var(--fs-body);
}

/* ============ Descriptor Card ============ */
.descriptor-card {
  display: grid; gap: 10px;
  padding: 14px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.descriptor-card .field-row {
  display: flex; align-items: center; gap: 10px;
}
.descriptor-card .field-row label { min-width: 90px; font-size: var(--fs-xs); font-weight: 500; color: var(--ink-3); }
.descriptor-card .column-editor { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.descriptor-card .column-row { display: flex; align-items: center; gap: 6px; }
.descriptor-card .column-index {
  min-width: 18px; text-align: right; font-size: var(--fs-2xs); color: var(--ink-4);
}
.descriptor-card .column-sample {
  flex: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-2xs); color: var(--ink-4);
}

/* ============ Regex Highlights ============ */
.hl { border-radius: 2px; padding: 0 1px; cursor: default; transition: opacity 0.15s; }
.hl-0 { --hl: var(--cat-0); --hl-line: var(--cat-0-line); } /* delimiter - blue */
.hl-1 { --hl: var(--cat-1); --hl-line: var(--cat-1-line); } /* externalId - green */
.hl-2 { --hl: var(--cat-2); --hl-line: var(--cat-2-line); } /* title - amber */
.hl-3 { --hl: var(--cat-3); --hl-line: var(--cat-3-line); } /* description - purple */
.hl-4 { --hl: var(--cat-4); --hl-line: var(--cat-4-line); } /* version - pink */
.hl-5 { --hl: var(--cat-5); --hl-line: var(--cat-5-line); } /* mapping - teal */
.hl-6 { --hl: var(--cat-6); --hl-line: var(--cat-6-line); } /* verification - orange */
.hl-0, .hl-1, .hl-2, .hl-3, .hl-4, .hl-5, .hl-6 {
  background: color-mix(in srgb, var(--hl) var(--cat-tint), transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--hl-line) var(--cat-line-mix), transparent);
}

.doc-sample-panel {
  max-height: 350px; overflow: auto;
  padding: 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: var(--fs-xs); font-family: var(--font-mono);
  white-space: pre-wrap; word-break: break-word;
  line-height: 1.6;
}

/* Pattern field color indicators */
.pattern-field { display: flex; align-items: flex-start; gap: 6px; }
.pattern-field .color-dot {
  width: 10px; height: 10px; border-radius: 50%;
  margin-top: 24px; flex-shrink: 0;
}
.color-dot-0 { background: color-mix(in srgb, var(--cat-0) 70%, transparent); }
.color-dot-1 { background: color-mix(in srgb, var(--cat-1) 70%, transparent); }
.color-dot-2 { background: color-mix(in srgb, var(--cat-2) 70%, transparent); }
.color-dot-3 { background: color-mix(in srgb, var(--cat-3) 70%, transparent); }
.color-dot-4 { background: color-mix(in srgb, var(--cat-4) 70%, transparent); }
.color-dot-5 { background: color-mix(in srgb, var(--cat-5) 70%, transparent); }
.color-dot-6 { background: color-mix(in srgb, var(--cat-6) 70%, transparent); }

/* Provider inline display */
.provider-inline {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: var(--fs-sm); cursor: pointer;
}
button.provider-inline { font: inherit; color: inherit; cursor: pointer; }
.provider-inline:hover { border-color: var(--accent); }
.provider-inline .edit-icon { font-size: var(--fs-xs); color: var(--ink-3); }

/* Provider popup */
.provider-popup {
  position: absolute; z-index: 100;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-dropdown);
  padding: 12px; min-width: 300px;
}

/* ============ Status pill (requirement health) ============ */
.status-pill { display: inline-flex; align-items: center; gap: 5px; }
.status-pill svg { width: 12px; height: 12px; flex: none; }

/* ============ Finding cards (cross-check) — ported .xc ============ */
.xc { display: flex; gap: 14px; padding: 14px 16px; border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong); border-radius: 8px; background: var(--surface);
  margin-bottom: 12px; }
.xc.flag { border-left-color: var(--err); background: var(--err-soft); }
.xc.review { border-left-color: var(--warn); }
.xc.ok { border-left-color: var(--ok); }
.xc .xc-icon { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; flex: none; }
.xc .xc-icon svg { width: 17px; height: 17px; }
.xc.flag .xc-icon { background: var(--err-soft); color: var(--err); }
.xc.review .xc-icon { background: var(--warn-soft); color: var(--warn); }
.xc.ok .xc-icon { background: var(--ok-soft); color: var(--ok); }
.xc-body { flex: 1; min-width: 0; }
.xc-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 5px; }
.xc-title { font-size: var(--fs-body); font-weight: 600; color: var(--ink); }
.xc-desc { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.6; margin: 0; }
.xc-desc code { font-size: var(--fs-xs); font-family: var(--font-mono); }

/* ============ Search results — ported .res ============ */
.res { display: flex; gap: 14px; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); margin-bottom: 10px; transition: all 150ms; }
.res:hover { border-color: var(--border-strong); background: var(--surface-2); }
.res .score { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600; color: var(--info);
  flex: none; width: 44px; padding-top: 2px; align-self: flex-start;
  /* Above the card's stretched row-open link, so it can be hovered and focused (CORE-UX-22). */
  position: relative; z-index: 1; cursor: help; border-radius: var(--radius-sm); }
.res .score-tip { display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; width: 300px;
  padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--ink-2); font-family: var(--font-sans); font-size: var(--fs-xs); font-weight: 400; line-height: 1.5;
  box-shadow: var(--shadow-dropdown); }
.res .score:hover, .res .score:focus-visible { z-index: 21; }
.res .score:hover .score-tip, .res .score:focus-visible .score-tip { display: block; }
.res .rid { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent-ink); font-weight: 600; }
.res .rtitle { font-size: var(--fs-body); font-weight: 600; margin: 3px 0 5px; color: var(--ink); }
.res .rsnip { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.6; }
.res .rsnip mark { background: var(--accent-soft); color: var(--ink); border-radius: 3px; padding: 0 2px; }
.res .rmeta { display: flex; gap: 8px; margin-top: 9px; flex-wrap: wrap; }

/* Hybrid search bar badge — ported .search-mode */
.search-shell { display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 9px 12px; }
.search-shell svg { width: 17px; height: 17px; color: var(--ink-3); flex: none; }
.search-shell input { flex: 1; border: none; background: none; outline: none;
  font-family: var(--font-sans); font-size: var(--fs-body); color: var(--ink); }
.search-mode { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono);
  font-size: var(--fs-2xs); color: var(--accent-ink); background: var(--accent-soft); padding: 3px 9px;
  border-radius: 999px; font-weight: 600; }

/* ============ Upload dropzone — ported .drop / .fmt / .import-row ============ */
.drop { border: 1.5px dashed var(--border-strong); border-radius: 10px; padding: 28px;
  text-align: center; background: var(--surface-2); transition: all 150ms; }
.drop.dragover { border-color: var(--accent); background: var(--accent-soft); }
.drop .di { width: 38px; height: 38px; color: var(--accent-ink); margin: 0 auto 12px; }
.drop h4 { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: var(--ink); }
.drop p { margin: 0; font-size: var(--fs-sm); color: var(--ink-3); }
.fmt-row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.fmt { display: flex; align-items: center; gap: 8px; padding: 7px 11px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
.fmt .ext { font-family: var(--font-mono); font-size: var(--fs-2xs); padding: 2px 6px; border-radius: 4px; color: var(--on-swatch); }
.import-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.import-row { display: flex; align-items: center; gap: 12px; padding: 10px 13px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; font-size: var(--fs-sm); }
.import-row svg { width: 16px; height: 16px; flex: none; color: var(--accent-ink); }
.import-row .nm { font-weight: 600; flex: 1; color: var(--ink); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-row .ct { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-3); }
.drop-chosen { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.drop-chosen .fmt { color: var(--ink); }

/* ============ Version timeline — ported .ver ============ */
.ver { position: relative; padding-left: 28px; }
.ver::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.ver-item { position: relative; padding: 0 0 22px; }
.ver-item::before { content: ''; position: absolute; left: -25px; top: 4px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.ver-item.cur::before { background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft); }
.ver-tag { font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.ver-when { font-size: var(--fs-xs); color: var(--ink-3); margin-left: 8px; }
.ver-msg { font-size: var(--fs-sm); color: var(--ink-2); margin: 4px 0 0; }
.ver-msg b { color: var(--ink); }

/* AI token usage popover (per-user, lower-right, visible during AI activity) */
.token-popover {
    margin: 0 10px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: var(--fs-xs);
}
.token-popover-title {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-2);
    font-weight: 500;
    margin-bottom: 6px;
}
.token-popover-title .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: token-pulse 1.2s ease-in-out infinite;
}
@keyframes token-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.token-popover-rows { display: flex; flex-direction: column; gap: 3px; }
.token-row { display: flex; align-items: baseline; gap: 6px; }
.token-row .arrow { font-weight: 700; }
.token-row .arrow.up { color: var(--info); }
.token-row .arrow.down { color: var(--accent-ink); }
.token-row .mono { font-family: var(--font-mono); color: var(--ink); }
.token-row .lbl { color: var(--ink-3); font-size: var(--fs-xs); }

/* ============ Progress bar ============ */
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; }

/* ---- Help drawer ---- */
.help-icon { color: var(--ink-3); }
.help-icon:hover { color: var(--ink); }

/* 97/98: below .modal-overlay's 100 and below the guided-flow ring (105) and card (106). The
   card would sit squarely over the drawer's bottom — its Restart tour button and the Ask tab's
   input — so while the drawer is open the card is hidden altogether (see the flow block): the
   drawer has no use for the card's buttons, and the card is back the moment the drawer closes. */
.help-backdrop {
    position: fixed; inset: 0; background: var(--scrim-soft); z-index: 97;
}
.help-drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 92vw;
    background: var(--surface); border-left: 1px solid var(--border);
    box-shadow: var(--shadow-drawer); z-index: 98;
    display: flex; flex-direction: column;
}
.help-drawer-head, .help-drawer-foot {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.help-drawer-foot { border-bottom: none; border-top: 1px solid var(--border); margin-top: auto; }
.help-tabs { display: flex; gap: 4px; margin-left: auto; }
.help-tabs .btn.active { background: var(--surface-3); color: var(--ink); }

.help-chat { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.help-msg { padding: 8px 10px; border-radius: 8px; font-size: var(--fs-body); white-space: pre-wrap; line-height: 1.6; }
.help-msg.from-user { background: var(--accent-soft); align-self: flex-end; max-width: 85%; }
.help-msg.from-ai { background: var(--surface-2); align-self: flex-start; max-width: 95%; }
.help-msg.warn { background: var(--warn-soft); border: 1px solid var(--warn); }

.help-ask-bar { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); }
.help-ask-input, .help-filter {
    flex: 1; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 6px; padding: 7px 9px; color: var(--ink); font-size: var(--fs-body);
}

.help-library { flex: 1; overflow-y: auto; padding: 12px; }
.help-filter { width: 100%; margin-bottom: 10px; }
.help-cat { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .04em; color: var(--ink-4); margin: 12px 0 4px; }
.help-topic { border-bottom: 1px solid var(--border); }
.help-topic-head {
    width: 100%; text-align: left; background: none; border: none; cursor: pointer;
    padding: 8px 2px; color: var(--ink); font-size: var(--fs-body); font-weight: 500;
}
.help-topic.open .help-topic-head { color: var(--accent-ink); }
.help-topic-body { padding: 0 2px 10px; font-size: var(--fs-sm); color: var(--ink-2); white-space: pre-wrap; line-height: 1.6; }

/* ---- Product tour ---- */
.tour-block { position: fixed; inset: 0; z-index: 89; }
.tour-dim { position: fixed; inset: 0; background: var(--scrim-strong); z-index: 90; pointer-events: none; }
.tour-hole {
    position: fixed; z-index: 90; border-radius: 6px;
    box-shadow: 0 0 0 9999px var(--scrim-strong), 0 0 0 2px var(--accent);
    pointer-events: none; transition: all .15s ease;
}
.tour-tip {
    position: fixed; z-index: 91; width: 280px; max-width: 90vw;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: var(--shadow-float); padding: 12px;
}
.tour-tip-title { font-weight: 600; font-size: var(--fs-body); color: var(--ink); margin-bottom: 4px; }
.tour-tip-body { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.5; }
.tour-tip-foot { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.tour-step-count { font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--ink-4); }

/* ---- Contextual help (spec J § 2) ----
   .help-dot is NOT .help-icon: that class belongs to the topbar's drawer button (AppTopbar.razor)
   and is styled above. The popover is position:fixed and placed by js/floating-menu.js for the
   reason SelectMenu's panel is — .card sets overflow:hidden, so a popover opened from a card head
   would otherwise be cropped by the card that owns it. z-index 120 clears .modal-overlay's 100:
   the ? inside a dialog has to open over the dialog. */
.help-dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; flex: 0 0 18px; padding: 0;
    border: 1px solid var(--border); border-radius: 50%; background: transparent;
    /* --fs-sm, not --fs-xs: the Global Constraint forbids --fs-xs on every help surface, and the
       glyph is no exception — a 12px "?" in an 18px circle is the hardest thing on the page to
       aim at. 13px fits with the border-box sizing above. */
    color: var(--ink-3); font-size: var(--fs-sm); font-weight: 600; line-height: 1;
    cursor: pointer; transition: color .12s, border-color .12s;
}
.help-dot:hover, .help-dot[aria-expanded="true"] { color: var(--accent-ink); border-color: var(--accent); }
.help-dot:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.help-pop {
    position: fixed; z-index: 120; width: 320px; max-width: calc(100vw - 32px);
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    /* --shadow-dropdown, not --shadow-3: app.css:47-49 documents it as the token for small
       floating popovers, lighter than --shadow-3's modal elevation. A popover is not a modal. */
    box-shadow: var(--shadow-dropdown); padding: 12px;
}
.help-pop-title { font-weight: 600; font-size: var(--fs-body); color: var(--ink); margin-bottom: 6px; }
/* --fs-sm, never --fs-xs: help text is the one thing on a page a person reads because they are
   already stuck, and this codebase's standing rule is legibility over density. */
.help-pop-body { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.55; }
.help-pop-body p { margin: 0 0 8px; }
.help-pop-body p:last-child { margin-bottom: 0; }
.help-pop-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.help-backdrop-bare { position: fixed; inset: 0; z-index: 119; }

/* A hint under one input or one section of a dialog. Same reasoning on the size. */
.field-hint { font-size: var(--fs-sm); line-height: 1.45; margin: 4px 0 0; }

/* ---- Guided flows (spec J § 3) ----
   These are the flow's OWN rules. They reuse the tour's GEOMETRY HELPER — helpTour.getRect, and
   the revealRect added beside it — and nothing else: .tour-hole's first box-shadow paints a
   9999px black spread over the whole viewport, and .tour-block catches every click. Both are
   right for a tour, where the user watches, and both are wrong for a flow, where the user WORKS
   the page the ring is pointing at. So the ring is re-declared here without the darkness, with a
   softer outer halo in its place.

   z-index: ABOVE .modal-overlay's 100, and below .help-pop's 120. The first version put both
   below 100 on the reasoning that "a step that told you to open a dialog must not cover it". The
   overlay is inset:0 with a backdrop-filter, so what that actually bought was a card and a ring
   painted UNDER a full-viewport blur: unreadable, unclickable, and with no highlight at all on the
   control the step was pointing at — supplier-round-trip's `run` step rings export-run INSIDE the
   New export dialog, so the ring has to reach in there. The card stays one above the ring, so a
   ring around a control near the corner cannot paint over the card explaining it.

   The original worry was real, though; it was only in the wrong layer. See the pointer-events rule
   under .flow-card-foot, which is where "must not cover it" is actually answered. */
.flow-ring {
    position: fixed; z-index: 105; border-radius: 6px;
    box-shadow: 0 0 0 2px var(--accent), 0 0 0 6px var(--accent-soft);
    pointer-events: none; transition: all .15s ease;
}
.flow-card {
    position: fixed; z-index: 106; right: 20px; bottom: 20px; width: 320px; max-width: calc(100vw - 32px);
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: var(--shadow-3); padding: 12px;
}
.flow-card-title { font-weight: 600; font-size: var(--fs-body); color: var(--ink); }
/* --fs-xs, not --fs-2xs: this is the smallest thing on the card and it is still a count somebody
   has to read. The Global Constraint's floor applies to the card's prose below at --fs-sm. */
.flow-card-count { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-4); }
/* The body is markdown, rendered by MarkdownLite exactly as a help popover's is, so it carries its
   own <p> — the paragraph rules below are .help-pop-body's, for the same reason. */
.flow-card-body { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.55; margin: 6px 0 0; }
.flow-card-body p { margin: 0 0 8px; }
.flow-card-body p:last-child { margin-bottom: 0; }
.flow-card-wait { font-size: var(--fs-sm); color: var(--ink-3); margin: 8px 0 0; }
.flow-card-foot { display: flex; align-items: center; gap: 6px; margin-top: 12px; }

/* WHILE A DIALOG IS OPEN the card stops catching clicks, and only its buttons keep catching them.
   Raising the card over .modal-overlay fixed the blur and gave Next and Stop back, and introduced
   the opposite fault: a centred .modal-box is 480px (720 when .wide), so on a 1280px viewport its
   footer ends at x=1000 and the card starts at x=940 — the card sat on the dialog's own Record /
   Export button and ate the click. Seen as EvidenceFlow_RunsEndToEnd failing on "flow-card
   intercepts pointer events", which is the user being unable to do the very thing the step asked
   for. Moving the card does not solve it (the overlap is symmetric: a wide dialog reaches into
   both bottom corners) and shrinking it only moves the breakpoint, so the answer is to stop the
   card's own SURFACE from being a target for as long as a dialog is up. Its three buttons keep
   pointer-events, so Next and Stop are still pressable, and outside a dialog nothing changes —
   the card catches its own clicks as it always did. */
body:has(.modal-overlay) .flow-card { pointer-events: none; }
body:has(.modal-overlay) .flow-card .btn { pointer-events: auto; }
/* The help drawer is not a .modal-overlay, and the card (right 20px, 320px wide, z 106) lands on
   the drawer's bottom — Restart tour, and the Ask tab's input and Send. Buttons that keep
   pointer-events would still cover those, so the card is hidden, not made transparent, while
   the drawer is open. Nothing in the drawer needs the card (Stop and Next belong to the page the
   step is on), and the card returns when the drawer closes. */
body:has(.help-drawer) .flow-card { visibility: hidden; }

/* The Guides tab's list in the help drawer. */
.help-guides { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.help-guide { border: 1px solid var(--border); border-radius: 6px; padding: 10px; }
.help-guide-title { font-weight: 600; font-size: var(--fs-sm); color: var(--ink); }
/* --fs-sm: "you stopped at step 3" is the line that decides whether somebody presses Resume. */
.help-guide-meta { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 2px; }

/* ============ Validation log (/projects/{id}/review-log) ============
   An audit view: everything on it exists to be READ, by an engineer deciding whether to trust a
   run. So nothing here drops below --fs-sm, the notes sit at --fs-body, and the prose blocks keep
   a real line-height and a measure that stops at ~78 characters. Density is not the goal — a
   reader who skips the note that says "this is one page of 2,800 calls" has been misled by the
   layout, which is the one failure this whole feature exists to prevent. */
.log-runs { display: flex; flex-direction: column; gap: 10px; }
.log-run.open { border-color: var(--border-strong); box-shadow: var(--shadow-1); }

.log-run-head {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 12px 14px; background: none; border: none; text-align: left;
  color: inherit; font: inherit; cursor: pointer;
}
.log-run-head:hover { background: var(--surface-2); }
.log-run-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.log-run-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-run-subject { font-size: var(--fs-body); font-weight: 600; color: var(--ink); }
.log-run-when { font-size: var(--fs-xs); color: var(--ink-4); font-family: var(--font-mono); }
.log-run-plan { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; font-size: var(--fs-sm); }
.log-sep { color: var(--ink-5); }

/* The caret is the only affordance saying a row opens, so it is a real 14px glyph rather than a
   micro-arrow, and it rotates rather than swapping shape. */
.log-caret { display: inline-flex; color: var(--ink-4); transition: transform 0.12s ease; flex: none; }
.log-caret svg { width: 14px; height: 14px; }
.log-caret.open { transform: rotate(90deg); }

.log-label {
  font-size: var(--fs-2xs); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-4); font-weight: 500;
}
/* The plan equation and the call/plan ratio. Mono because they are arithmetic a reader checks. */
.log-equation { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--ink-2); }

.log-run-body { padding: 4px 14px 16px; border-top: 1px solid var(--border); }
.log-block { border-top: 1px solid var(--border); padding-top: 12px; }
.log-block:first-child { border-top: none; padding-top: 4px; }
.log-block-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.log-block-head h4 { margin: 0; font-size: var(--fs-h3); font-weight: 600; color: var(--ink); }

/* Prose the page states as fact, and prose that CORRECTS a reading the numbers would otherwise
   invite. The second kind is bordered and tinted because it is load-bearing — it is where "this
   is not a ratio", "this is one page of the log", and "an empty list is not a clean bill of
   health" are said. */
.log-prose {
  font-size: var(--fs-body); line-height: 1.6; color: var(--ink-2);
  margin: 0; max-width: 78ch;
}
.log-note {
  font-size: var(--fs-body); line-height: 1.6; color: var(--ink-2);
  background: var(--info-soft); border-left: 3px solid var(--info);
  border-radius: var(--radius-sm); padding: 9px 12px; margin: 8px 0 0; max-width: 78ch;
}
.log-note.warn { background: var(--warn-soft); border-left-color: var(--warn); }
.log-run > .log-note { margin: 0 14px 12px; }

.log-facts {
  display: grid; gap: 10px; margin-bottom: 10px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.log-fact {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
}
.log-fact-label {
  font-size: var(--fs-2xs); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 500;
}
.log-fact-value {
  font-family: var(--font-mono); font-size: 20px; font-weight: 600;
  letter-spacing: -0.02em; color: var(--ink); margin-top: 3px;
}
.log-fact-value.bad { color: var(--err); }
.log-fact-sub { font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.45; margin-top: 3px; }

/* Requirement chips: gap lists and a call's subjects. A chip carries the id, the title, the set
   version the call read it at, and — where it applies — that the text has moved since. */
.log-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.log-chip-wrap { display: contents; }
.log-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--ink-2); text-decoration: none;
  font-size: var(--fs-sm);
}
a.log-chip:hover { border-color: var(--border-emph); background: var(--surface-2); }
.log-chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42ch; }
.log-chip.changed { border-color: var(--warn); background: var(--warn-soft); }
/* Deleted since the run: not a link, because there is nothing left to link to. */
.log-chip.gone { border-style: dashed; background: var(--surface-2); cursor: default; }
/* Both states are marked by SHAPE as well as colour — in the collapsed call row the chip is an id
   and nothing else, so colour alone would carry the whole signal. The strike-through says gone; the
   dotted underline says the text moved. Each also carries the state in its title. */
.id-chip.gone { text-decoration: line-through; color: var(--ink-4); }
.id-chip.changed { color: var(--warn); text-decoration: underline dotted; text-underline-offset: 2px; }

.log-range { font-size: var(--fs-sm); color: var(--ink-3); font-family: var(--font-mono); }
.log-range.partial { color: var(--warn); }

.log-calls tbody td { height: auto; padding-top: 7px; padding-bottom: 7px; font-size: var(--fs-sm); }
.log-call-row.open { background: var(--surface-2); }
/* The disclosure control for a call row. A real button inside the first cell rather than a role on
   the row itself: the row keeps its "row" role (and its cells their column-header association), and
   Space activates it the way a native button does — without scrolling the page. */
/* CORE-UX-06: an expandable row's keyboard handle — a real button in its first cell, carrying
   aria-expanded. The row's own click stays as a mouse convenience. */
.matrix-cell-btn { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
  min-height: 20px; padding: 0; border: 0; background: transparent; cursor: inherit; }
.tree-set-select { flex: 1; min-width: 0; display: flex; }
.row-toggle { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.log-call-toggle {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  background: none; border: none; color: inherit;
  font-family: var(--font-mono); font-size: var(--fs-sm);
  padding: 2px 5px; margin: -2px -5px; border-radius: var(--radius-sm);
}
.log-call-toggle:hover { background: var(--surface-3); color: var(--ink); }
/* The sequence column is right-aligned like every other numeric cell, but this one leads with a
   disclosure caret, so it reads from the left. */
.log-calls thead th.num:first-child, .log-calls tbody td.num:first-child { text-align: left; }
.log-call-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.log-call-detail > td { background: var(--surface-2); padding: 14px 16px 16px; }
/* Qualified past ".req-table tbody tr:hover", which is (0,2,2) and would otherwise win: the expanded
   detail row is not a click target and must not offer a pointer that says it is. */
.req-table tbody tr.log-call-detail:hover { background: var(--surface-2); cursor: default; }
.log-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 7px;
}
.log-pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; }

/* ============ Change history ============ */
/* The undo plan's two lists, and the field-level diff a history row expands to. Both stay at the
   body font size — these are the numbers someone is about to act on, not annotations. */
.undo-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--ink-2); }
.hist-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hist-seq { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--ink-4); }
.hist-label { font-size: var(--fs-body); font-weight: 600; color: var(--ink); }
.hist-meta { font-size: var(--fs-sm); color: var(--ink-3); }
.hist-counts { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--ink-3); }
.hist-change { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 10px 12px; }
/* Fixed layout, so the field name keeps a steady column and old/new split the rest evenly. With
   auto layout a long value (or a value broken mid-word) collapses the other column to one
   character, which is how this table first rendered. */
.hist-fields { width: 100%; table-layout: fixed; border-collapse: collapse; margin-top: 8px; font-size: var(--fs-sm); }
.hist-fields th, .hist-fields td { text-align: left; vertical-align: top; padding: 4px 10px 4px 0; border-top: 1px solid var(--border); }
.hist-fields th { color: var(--ink-4); font-weight: 500; width: 150px; }
.hist-fields td { overflow-wrap: anywhere; }
.hist-fields td.old { color: var(--ink-3); text-decoration: line-through; padding-right: 22px; position: relative; }
.hist-fields td.old::after { content: '→'; position: absolute; right: 6px; top: 4px; color: var(--ink-4); text-decoration: none; }
.hist-fields td.new { color: var(--ink); }

/* The comparison view. One .diff-row per entity, each folding out to the steps that produced its
   net change. Old/new values are coloured *and* marked the way the history's own field table marks
   them — struck through, with the arrow that says which way the change ran — because colour alone
   does not tell a red/green-blind reader which of two values is the one that is gone. */
.compare-group { margin: 14px 0 6px; font-size: var(--fs-body); font-weight: 600; color: var(--ink-2); }
.compare-group .dim { font-family: var(--font-mono); font-weight: 400; }
.diff-row { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 8px 10px; margin-bottom: 6px; }
.diff-old { color: var(--err); text-decoration: line-through; padding-right: 22px; position: relative; }
.diff-old::after { content: '→'; position: absolute; right: 6px; top: 4px; color: var(--ink-4); text-decoration: none; }
.diff-new { color: var(--ok); }
.compare-steps-toggle { margin-top: 8px; }
.compare-steps { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

/* Project dashboard: run map. The drawing keeps its natural width and scrolls in its own region. */
.run-map-intro { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 20px; padding: 12px 16px; color: var(--ink-3); font-size: var(--fs-xs); line-height: 1.5; border-bottom: 1px solid var(--border); }
.run-map-scroll { overflow: auto; max-height: 720px; background: var(--surface-2); }
.run-map-scroll:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.run-map-canvas { position: relative; min-width: 100%; }
.run-map-lines { position: absolute; inset: 0; overflow: visible; }
.run-map-lines a { cursor: pointer; }
.run-map-lines a:focus-visible { outline: none; }
.run-map-lines a:focus-visible .map-edge,
.run-map-lines a:focus-visible .map-badge-line { filter: drop-shadow(0 0 3px var(--accent)); }
.map-edge { stroke: var(--info); fill: var(--info); stroke-linecap: round; stroke-linejoin: round; }
.run-map-lines path.map-edge { fill: none; }
.map-edge.loop { stroke: var(--accent); fill: var(--accent); }
.map-edge.gap { stroke: var(--ink-4); fill: var(--ink-4); opacity: .48; }
.map-edge.failed { stroke: var(--err); fill: var(--err); }
.map-edge.cancelled { stroke: var(--warn); fill: var(--warn); }
.map-edge.inflight { stroke: var(--info); fill: var(--info); }
.map-edge.stale, .map-badge-line.stale { opacity: .48; }
.map-badge-line { stroke: var(--ok); stroke-linecap: round; stroke-linejoin: round; }
.map-feeder { stroke: var(--ink-4); stroke-width: 1.5; stroke-dasharray: 4 6; opacity: .5; }
.map-hit { stroke: transparent; pointer-events: stroke; }
.map-stat-leader { stroke: var(--ink-4); stroke-width: 1; stroke-dasharray: 2 3; opacity: .7; pointer-events: none; }
.run-map-lines path.map-edge:not(.gap) { stroke-linecap: butt; }
.map-node { position: absolute; box-sizing: border-box; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-1); }
.map-node.inactive { opacity: .55; }
.map-node-icon { font-size: 18px; line-height: 1; color: var(--accent-ink); }
.map-node-name { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-node-meta { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.map-stat { position: absolute; box-sizing: border-box; padding: 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-1); font-size: var(--fs-xs); overflow: hidden; }
.map-stat-head { height: 23px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-stat-head a { color: inherit; }
.map-stat-sub { height: 16px; color: var(--ink-3); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-stat-row { display: flex; justify-content: space-between; align-items: baseline; gap: 7px; height: 19px; color: var(--ink-2); }
.map-stat-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-stat-row b { font-family: var(--font-mono); font-weight: 600; }
.map-stat-row.err.dominant { color: var(--err); font-weight: 600; }
.map-stat-row.warn.normal { color: var(--warn); }
.map-stat-row.ok.recessive, .map-stat-row.recessive { color: var(--ink-4); }
.map-stat-note { height: 19px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-stat-note a { color: var(--info); }
.map-stat-note .pill { box-sizing: border-box; height: 17px; line-height: 15px; padding: 0 4px; }
.map-stat-note .pill a { color: inherit; }
.map-stat-note.map-stale { color: var(--warn); }
.map-mobile-hint { display: none; }

@media (max-width: 700px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 36px 54px minmax(0, 1fr); }
  .classification-bar { grid-column: 1; }
  .sidebar {
    grid-column: 1; grid-row: 2; height: 54px; flex-direction: row; align-items: center;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .sidebar-head { padding: 8px; border: 0; }
  .sidebar-head .logo-text, .sidebar-context, .nav-section-label,
  .sidebar-foot .who, .sidebar-foot [title="Edit profile"],
  .sidebar-foot [title="Sign out"] { display: none; }
  .sidebar-foot [title="Edit profile"] { display: none !important; }
  .sidebar .nav {
    display: flex; align-items: center; flex: 1; min-width: 0;
    overflow-x: auto; overflow-y: hidden; padding: 4px;
  }
  .sidebar .nav-section { display: flex; flex: none; margin: 0; }
  .sidebar-lead { padding: 4px; }
  .sidebar .nav-item { white-space: nowrap; padding: 7px 9px; }
  .sidebar-foot { padding: 0 7px; border: 0; }
  .main { grid-column: 1; grid-row: 3; }
  .page { padding: 14px 12px 40px; }
  .log-run-subject { overflow-wrap: anywhere; }
  .map-mobile-hint { display: inline; }
}

/* Persistent requirement review and immutable scope evidence. */
.requirement-review-card { min-width: 0; }
.requirement-review-card .card-head { flex-wrap: wrap; gap: 10px; }
.requirement-review-card p, .requirement-review-card blockquote { overflow-wrap: anywhere; white-space: pre-wrap; }
.requirement-finding-group { margin-block: 20px; }
.requirement-finding { border: 1px solid var(--border); border-radius: 6px; padding: 14px; margin-block: 10px; }
.requirement-finding.focused { outline: 2px solid var(--focus); outline-offset: 2px; }
.requirement-evidence { background: var(--surface-2); border-left: 2px solid var(--border); padding: 10px 14px; margin-block: 10px; }
.requirement-review-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-block: 12px; }
.requirement-issue-draft { display: grid; gap: 10px; margin-block: 12px; }
.requirement-review-history { border-top: 1px solid var(--border); margin-top: 12px; }
@media (max-width: 600px) { .requirement-review-card .card-body { padding: 12px; } .requirement-finding { padding: 10px; } .requirement-review-actions { align-items: flex-start; } }

.requirement-review-filters .grid > *, .requirement-validation-filters > * { min-width: 0; }
@media (max-width: 700px) {
    .requirement-review-filters .grid, .requirement-validation-filters { grid-template-columns: minmax(0, 1fr); }
}

/* ============ Parameters ============
   The overview: one parameter's detail, chosen from the selector bar above it; the tree of the
   project's named measurables is in the Manage parameters dialog (CORE-UX-01). Sizes come from the existing type scale — a parameter key, its value and its verdict
   are the page's load-bearing text and none of them shrinks below the table size. */
.param-tree { display: flex; flex-direction: column; }
.param-tree-group { border-bottom: 1px solid var(--border); }
.param-tree-group:last-child { border-bottom: 0; }
.param-tree-group.dragover { background: var(--accent-soft); outline: 1px dashed var(--accent-ink); outline-offset: -1px; }
.param-tree-group-head {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.param-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 10px; font-size: var(--fs-sm); cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.param-row:last-child { border-bottom: 0; }
.param-row:hover { background: var(--surface-2); }
.param-row.selected { background: var(--accent-soft); }
.param-row.dragging { opacity: 0.5; }
.param-row-type { font-size: var(--fs-xs); }
.param-row-value { margin-left: auto; font-size: var(--fs-sm); white-space: nowrap; }

.param-content, .param-detail { min-width: 0; }
.param-types .req-table td { vertical-align: top; }
.comparison-editor .comparison-reason { margin-top: 0; }


/* ============ Evidence ============ */

/* A dialog that carries a form (measurements, attachments, the heading fields) is wider than the
   480px default and has to scroll its body rather than the page behind it — otherwise the footer's
   Record button walks off the bottom of a laptop screen. */
.modal-box.wide { width: 720px; }
.modal-box.wide .modal-body { max-height: calc(100vh - 220px); overflow-y: auto; }

/* The type-ahead used by the measurement rows, the Add-parameter key field and the record dialog's
   subject pickers. The panel is absolutely positioned inside a relative field so it overlays what
   follows instead of pushing the form down as the user types. */
.typeahead-field { position: relative; }
.typeahead-panel {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  margin-top: 4px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-3); max-height: 240px; overflow-y: auto;
}
.typeahead-option {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--ink); font-size: var(--fs-sm);
  font-family: inherit; text-align: left; cursor: pointer;
}
.typeahead-option:hover { background: var(--surface-2); }

/* One measurement: key, value, unit, uncertainty, remove. Collapses to a single column on a narrow
   viewport rather than squeezing four boxes no one can read. */
.measurement-row {
  display: grid; align-items: start; gap: 8px;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1.2fr) minmax(0, 1.2fr) auto;
}
.measurement-row .field { margin: 0; }

.req-parameters .req-table td { vertical-align: middle; }

/* A requirement's close-out (CORE-CLO-02/03), in its expanded row: the state and the decision on one
   line, the facts as tags that wrap, and the record of every decision with the facts it was made on. */
.req-close-out { gap: 6px; margin-bottom: 12px; font-size: var(--fs-body); }
.req-close-out .close-out-state, .req-close-out .close-out-facts { flex-wrap: wrap; }
.req-close-out .close-out-action { margin-left: auto; }
.req-close-out .close-out-note { font-size: var(--fs-xs); margin: 0; }
.close-out-record { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.close-out-record li { display: flex; flex-wrap: wrap; gap: 4px 8px; }

/* ============ Compliance ============ */
/* The status pill is the one thing a reader scans a compliance table for, so it sits a step above
   the base pill's micro size — still an existing token, never a new one. */
.compliance-pill { font-size: var(--fs-xs); padding: 3px 8px; }
.compliance-status { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag.info { color: var(--info); background: var(--info-soft); }

/* The summary strip: each status beside its count, then the withdrawn marker and the total. Wraps
   rather than shrinking — a count squeezed to two characters is a count nobody reads. */
.compliance-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; }
.compliance-count { display: flex; align-items: center; gap: 8px; }
.compliance-count .n {
  font-family: var(--font-mono); font-size: var(--fs-title); font-weight: 600;
  letter-spacing: -0.02em; line-height: 1; color: var(--ink);
}
.compliance-count .lbl {
  font-size: var(--fs-2xs); color: var(--ink-3); letter-spacing: 0.04em;
  text-transform: uppercase; font-weight: 500;
}

@media (max-width: 900px) {
  .measurement-row { grid-template-columns: minmax(0, 1fr); }
  .modal-box.wide { width: 480px; }
}

/* ============ Ingestion: keys, CSV, the API guide ============ */
/* The one secret this app ever shows. It is read off the screen and typed into a CI configuration,
   so it is set at body size in mono and given room to breathe — this is the last place to save
   space. It wraps rather than scrolls: a key cut off at the edge of a box is a key half-copied. */
.api-key-box {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); color: var(--ink);
  font-family: var(--font-mono); font-size: var(--fs-body); line-height: 1.6;
  word-break: break-all; user-select: all;
}
.api-key-new { border-color: var(--accent); }
/* A revoked key stays in the list — it is what the chronology's older rows were filed by — but it
   is no longer a credential, and the row says so by fading rather than by disappearing. */
.api-keys-card tr.api-key-revoked td { opacity: 0.55; }

/* The mapping table is read line by line while someone decides what a stranger's column means, so
   its rows are taller than a data table's and its dropdowns are full width. */
.csv-mapping td { padding-top: 10px; padding-bottom: 10px; vertical-align: middle; }
.csv-mapping td:first-child { white-space: nowrap; }
.csv-steps .pill { font-size: var(--fs-xs); }
.csv-totals { font-size: var(--fs-body); color: var(--ink-2); }
.csv-notes { margin: 0; padding-left: 18px; font-size: var(--fs-body); line-height: 1.7; color: var(--ink-2); }
.csv-notes li { margin-bottom: 4px; }

/* The ingestion guide, rendered from the API's own markdown. Long-form prose, so it reads at body
   size with a measure and generous leading rather than at table density. */
.md-doc { font-size: var(--fs-body); line-height: 1.7; color: var(--ink); max-width: 90ch; }
.md-doc h1 { font-size: var(--fs-title); margin: 0 0 12px; letter-spacing: -0.01em; }
.md-doc h2 { font-size: var(--fs-h2); margin: 28px 0 10px; }
.md-doc h3 { font-size: var(--fs-h3); margin: 22px 0 8px; }
.md-doc h4 { font-size: var(--fs-body); margin: 18px 0 6px; color: var(--ink-2); }
.md-doc p { margin: 0 0 12px; }
.md-doc ul { margin: 0 0 12px; padding-left: 20px; }
.md-doc li { margin-bottom: 6px; }
.md-doc hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.md-doc code.mono { font-family: var(--font-mono); font-size: 0.95em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.md-doc pre.md-code {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; overflow-x: auto; margin: 0 0 14px;
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.6;
}
.md-doc pre.md-code code { background: none; padding: 0; font-size: inherit; }
.md-doc .table-wrap { margin: 0 0 16px; }
.md-doc .req-table td, .md-doc .req-table th { font-size: var(--fs-body); vertical-align: top; }

/* The Generated content card's Preview switch (spec M § 8, row 19): HtmlRenderer's fragment,
   styled with the same tokens the rest of the app uses — no hardcoded colour, same rule as
   everywhere else (CLAUDE.md). Mirrors .md-doc's shape rather than reusing it: a report's
   headings are numbered ("2.1 Scope"), its tables carry verdict tones, and its key/value Basis
   block has no equivalent in a markdown doc. */
.report-preview { font-size: var(--fs-body); line-height: 1.7; color: var(--ink); max-width: 90ch; }
.report-preview .report-heading { margin: 24px 0 10px; color: var(--ink); }
.report-preview h2.report-heading { font-size: var(--fs-h2); color: var(--accent-ink); }
.report-preview h3.report-heading { font-size: var(--fs-h3); }
.report-preview h4.report-heading { font-size: var(--fs-body); color: var(--ink-2); }
.report-preview .report-subheading { font-weight: 600; margin: 14px 0 6px; }
.report-preview .report-muted { color: var(--ink-4); font-size: var(--fs-xs); }
.report-preview p { margin: 0 0 12px; }
.report-preview .report-list { margin: 0 0 12px; padding-left: 20px; }
.report-preview .report-list li { margin-bottom: 6px; }
.report-preview .report-page-break { border: 0; border-top: 1px dashed var(--border); margin: 24px 0; }
.report-preview .report-authored { margin: 0 0 12px; }
.report-kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; }
.report-kv dt { color: var(--ink-4); font-size: var(--fs-xs); }
.report-kv dd { margin: 0; }
.report-table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: var(--fs-body); }
.report-table th { text-align: left; background: var(--surface-2); padding: 6px 10px; font-weight: 600; }
.report-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.report-table .report-cell-ok { color: var(--ok); background: var(--ok-soft); }
.report-table .report-cell-warn { color: var(--warn); background: var(--warn-soft); }
.report-table .report-cell-err { color: var(--err); background: var(--err-soft); }
.report-table .report-cell-info { color: var(--info); background: var(--info-soft); }
.report-table .report-cell-muted { color: var(--ink-4); }

/* Report branding (spec E § 3). Two things the design system had no class for: the swatch showing
   the accent colour a report will be printed with, and the logo preview beside the upload. The
   swatch's background is the one colour in this file that cannot be a token — it IS the user's
   chosen value, set inline on the element. */
.branding-swatch {
  width: 22px; height: 22px; flex: 0 0 22px; border-radius: var(--radius);
  border: 1px solid var(--border);
}
.branding-logo {
  max-height: 48px; max-width: 200px; object-fit: contain;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px; background: var(--surface);
}

/* The authored sections of a report (spec E § 1.4). A contenteditable region has no styling of its
   own, so it gets the input's surface and border and the body's reading size — an engineer writes
   an introduction here, not a form field. The placeholder is drawn by the empty state's ::before,
   because a contenteditable element has no placeholder attribute. */
.richtext { display: flex; flex-direction: column; gap: 6px; }
.richtext-toolbar { flex-wrap: wrap; }
.richtext-body {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; overflow-y: auto;
  font-size: var(--fs-body); line-height: 1.7;
}
.richtext-body:focus { outline: none; border-color: var(--accent); }
.richtext-body:empty::before { content: attr(data-placeholder); color: var(--ink-4); }
.richtext-body p { margin: 0 0 10px; }
.richtext-body p:last-child { margin-bottom: 0; }
.richtext-body h3 { font-size: var(--fs-h3); margin: 14px 0 8px; }
.richtext-body ul, .richtext-body ol { margin: 0 0 10px; padding-left: 22px; }
.richtext-body li { margin-bottom: 4px; }

/* The report editor's right-hand column: the actions, the draft files and the issued revisions. */
.report-revision {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; background: var(--surface-2);
}
.report-section-note { border-left: 2px solid var(--border); padding-left: 12px; }

/* The report editor is two columns of unequal weight: the document on the left, what you can do
   with it on the right. .grid.c2 splits evenly, which gives the four action buttons as much room
   as the prose. Below a laptop width it stacks. */
.report-editor { display: grid; gap: var(--gutter); grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .report-editor { grid-template-columns: minmax(0, 1fr); } }
/* Canonical findings share identity, decision controls and the evidence/history reader. */
.finding-workflow { width:100%; margin-block:var(--gutter); }
.finding-identity, .finding-buttons, .finding-status-editor, .finding-owner-editor { gap:8px; flex-wrap:wrap; margin-block:8px; }
.finding-attribution { display:flex; flex-wrap:wrap; gap:8px 20px; color:var(--ink-3); font-size:var(--fs-xs); }
.finding-decision-fields { display:flex; align-items:flex-end; flex-wrap:wrap; gap:12px; margin-top:12px; }
.finding-decision-fields .field { margin:0; flex:1; min-width:180px; }
.finding-status-editor .select-menu, .finding-owner-editor .select-menu { min-width:220px; flex:1; }
.finding-detail { width:min(900px, 94vw); }
.finding-evidence-list, .finding-timeline { margin-top:20px; }
.finding-evidence-entry, .finding-timeline-entry { padding:12px 0; border-bottom:1px solid var(--border); overflow-wrap:anywhere; }
.finding-timeline-entry time { display:block; font-size:var(--fs-xs); }
.finding-evidence-entry p, .finding-timeline-entry p { margin:6px 0; white-space:pre-wrap; }
.finding-anchor { font-size:var(--fs-xs); overflow-wrap:anywhere; }
.finding-list-title { min-width:260px; max-width:600px; white-space:normal; overflow-wrap:anywhere; }
.finding-list-title .dim { white-space:pre-wrap; margin:6px 0; }

/* ============ Undo toast (CORE-UX-05) ============ */
.undo-toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 90; max-width: min(520px, calc(100vw - 40px)); }
.undo-toast {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 14px; border-radius: 6px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-3);
  font-size: var(--fs-sm);
}
.undo-toast > span { flex: 1; }

/* ============ Documents preview (CORE-DOC-05) ============ */
/* The name cell's own control selects the row for the preview pane. It reads as the name, and its
   selected state is aria-pressed, drawn on the whole row. */
.doc-select { display: inline; padding: 0; border: 0; background: none; font: inherit; color: var(--ink);
  font-weight: 600; text-align: left; cursor: pointer; border-radius: var(--radius-sm); }
.doc-select:hover { color: var(--accent-ink); text-decoration: underline; }
.req-table tr[data-selected='true'] > td { background: var(--accent-soft); }
.doc-preview { margin-top: var(--gutter); }
.doc-preview-frame { display: block; width: 100%; height: 72vh; min-height: 420px; border: 0; background: var(--surface-2); }
.doc-preview-text { margin: 0; max-height: 60vh; overflow: auto; padding: 14px; white-space: pre-wrap;
  overflow-wrap: anywhere; font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.6;
  color: var(--ink); background: var(--surface-2); }
.doc-preview-note { margin: 0; padding: 8px 14px; font-size: var(--fs-xs); color: var(--ink-3);
  border-top: 1px solid var(--border); }

/* ============ Search: progressive results (CORE-RAG-05) ============ */
/* Always rendered, so the live region exists before its words change; it keeps one line of height
   so the results below never jump when the status comes and goes. */
.search-status { min-height: 1.5em; margin: 0 0 8px; font-size: var(--fs-sm); color: var(--ink-3); }

/* ── Proposed resolution (CORE-RID-08): the requirement's current text beside a validation run's
   proposed text. Two columns where there is room, stacked on a phone. ── */
.proposal { background: var(--surface-2); border-left: 2px solid var(--accent); padding: 10px 14px; margin-block: 10px; display: flex; flex-direction: column; gap: 8px; }
.proposal-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.proposal-side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.proposal-text { white-space: pre-wrap; }
.proposal-side.proposed { border-color: var(--accent); }
@media (max-width: 640px) { .proposal-sides { grid-template-columns: 1fr; } }

/* ── The work board (CORE-WRK-01) ──────────────────────────────────────────────────────────────
   Five columns that scroll sideways on a narrow screen rather than squeezing a card's text: the
   card's title is the thing a person reads, so it keeps --fs-body (legibility over density). */
.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;
}
.board { display: grid; grid-template-columns: repeat(5, minmax(240px, 1fr)); gap: var(--gutter); overflow-x: auto; padding-bottom: 8px; align-items: start; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; min-height: 160px; }
.board-col.focused { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.board-col.drop-ok { border-color: var(--accent); background: var(--accent-soft); }
.board-col.drop-no { opacity: 0.6; }
.board-col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.board-col-head h2 { font-size: var(--fs-h3); font-weight: 600; margin: 0; }
.board-col-count { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--ink-3); }
.board-col-body { display: flex; flex-direction: column; gap: 8px; padding: 10px; flex: 1; min-height: 80px; }
.board-col-empty { color: var(--ink-4); font-size: var(--fs-sm); margin: 6px 2px; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.board-card[draggable="true"] { cursor: grab; }
.board-card:hover { border-color: var(--ink-4); }
.board-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
/* The key is the card's link (its keyboard path to open it), but not stretched over the card: the
   card itself is the drag source and its own click target, and an overlay would take both away. */
.board-card a.row-open::after { content: none; }
.board-card.dragging { opacity: 0.5; }
.board-card-rid { border-left: 3px solid var(--warn); }
.board-card-chore { border-left: 3px solid var(--info); }
.board-card-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.board-card-title { font-size: var(--fs-body); color: var(--ink); line-height: 1.35; overflow-wrap: anywhere; }
.board-card-facts { display: flex; gap: 4px; flex-wrap: wrap; }
.board-card-facts .tag { font-size: var(--fs-xs); }
.board-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.board-keys { color: var(--ink-3); font-size: var(--fs-sm); margin: 0; }
