/* CyberPaw components (UI restyle 2026-10-14, spec §1). Styles for the views/ui/ macros.
   Colours come only from ui/tokens.css; no shadows anywhere.

   Contrast: every text token reaches 4.5:1 on every surface (test/ui-contrast.test.js).
   --c-text-3 is still the quiet one: meta, counts beside a label, empty-cell marks. Text a
   reader needs (help, crumbs, card meta, labels, row counts) uses --c-text-2.

   Specificity note: this file loads BEFORE the legacy app.css/components.css, which win ties.
   Components therefore use their own class names (.ui-*, .ph-*, .bn, .st, .seg, .pill, .chip),
   and where an element must keep a legacy hook class that the legacy sheets also style
   (.card, .tab-bar/.tab-btn, .modal-overlay/.modal, .table-container, .rf-chip, .toast) the rule
   is written with one more class so it wins. app.css and components.css still carry those
   hook-class rules (on tokens since Task 9), so keep the compound selectors. */

/* ── Layout helpers (instead of u-* spacing utilities) ─────────────────────────────────── */
/* Vertical rhythm: top-level components are spaced by their own bottom margin... */
:where(.ph, .bn, .ui-card, .ui-tiles, .ui-grid-2, .ui-grid-3, .ui-note, .ui-stack):not(:last-child) { margin-bottom: var(--s-4); }
/* ...except inside a layout container, which spaces its children with gap. */
.ui-stack { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.ui-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); min-width: 0; }
.ui-grid-2, .ui-grid-3 { display: grid; gap: var(--s-4); min-width: 0; }
.ui-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ui-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ui-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s-3); }
.ui-stack > *, .ui-grid-2 > *, .ui-grid-3 > *, .ui-tiles > *, .ui-row > * { margin-bottom: 0; }

/* Key/value facts for record pages. */
.ui-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-4) var(--s-6); margin: 0; }
.ui-facts > div { min-width: 0; }
.ui-facts dt { font-size: var(--t-xs); font-weight: 600; color: var(--c-text-2); margin: 0 0 2px; }
.ui-facts dd { font-size: var(--t-sm); color: var(--c-text); margin: 0; overflow-wrap: anywhere; }
.ui-facts .ui-facts-wide { grid-column: 1 / -1; }

/* ── Page header ───────────────────────────────────────────────────────────────────────── */
.ph { min-width: 0; }
.ph .ph-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1); margin: 0 0 var(--s-2); font-size: var(--t-xs); color: var(--c-text-2); }
.ph .ph-crumbs :is(a, .breadcrumb-sep, .breadcrumb-parent, .breadcrumb-current) { color: var(--c-text-2); }
.ph .ph-crumbs a:hover { color: var(--c-text); }
.ph-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.ph-text { min-width: 0; flex: 1 1 320px; }
.ph-title.page-title {
  display: flex; align-items: center; gap: var(--s-2);
  margin: 0; font-family: var(--f-sans); font-size: var(--t-xl); font-weight: 600;
  line-height: 1.3; letter-spacing: -.01em; color: var(--c-text);
  overflow-wrap: anywhere;
}
.ph-icon { flex: none; color: var(--c-text-2); }
.ph-sub { margin: var(--s-1) 0 0; font-size: var(--t-sm); color: var(--c-text-2); max-width: 80ch; }
.ph-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
/* Slot order is fixed by the macro: filters, export, refresh, then the page's own actions. */
.ph-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.ph-filters :is(.ui-select, .ui-input) { width: auto; }

/* ── Banner: the full-width status strip ───────────────────────────────────────────────── */
.bn {
  --bn-fill: var(--c-info-fill); --bn-edge: var(--c-info-edge); --bn-c: var(--c-info);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-5);
  min-height: 44px; padding: var(--s-2) var(--s-4);
  background: var(--bn-fill); border: 1px solid var(--bn-edge); border-radius: var(--r);
  font-size: var(--t-sm); color: var(--c-text);
}
.bn-risk { --bn-fill: var(--c-risk-fill); --bn-edge: var(--c-risk-edge); --bn-c: var(--c-risk-text); }
.bn-warn { --bn-fill: var(--c-warn-fill); --bn-edge: var(--c-warn-edge); --bn-c: var(--c-warn); }
.bn-info { --bn-fill: var(--c-info-fill); --bn-edge: var(--c-info-edge); --bn-c: var(--c-info); }
.bn-ok   { --bn-fill: var(--c-ok-fill);   --bn-edge: var(--c-ok-edge);   --bn-c: var(--c-accent); }
.bn-lead { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--bn-c); }
.bn-icon { flex: none; }
.bn-title { font-size: var(--t-md); font-weight: 600; }
/* Every fact carries its divider on the left; the list is pulled left by one padding and clips,
   so the first fact on EACH line (also after a wrap) loses its divider and starts flush. The block
   padding keeps focus rings inside the clip. */
.bn-facts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) 0; margin: calc(-1 * var(--s-1)) 0 calc(-1 * var(--s-1)) calc(-1 * var(--s-4)); padding: var(--s-1) 0; list-style: none; overflow: hidden; }
.bn-facts > li { padding: 0 var(--s-4); margin-left: -1px; border-left: 1px solid var(--bn-edge); line-height: 20px; }
.bn-fact { color: var(--c-text); }
.bn-fact b { font-weight: 600; font-variant-numeric: tabular-nums; }
a.bn-fact:hover { color: var(--c-text); text-decoration: underline; text-decoration-color: var(--bn-c); }

/* ── Card ──────────────────────────────────────────────────────────────────────────────── */
.card.ui-card {
  min-width: 0;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r);
  overflow: hidden; box-shadow: none;
}
.ui-card-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3);
  padding: var(--s-4) var(--s-5) 0;
}
.ui-card-title { margin: 0; font-family: var(--f-sans); font-size: var(--t-lg); font-weight: 600; line-height: 1.35; color: var(--c-text); min-width: 0; }
.ui-card-meta { margin-left: auto; min-width: 0; max-width: 100%; font-size: var(--t-xs); color: var(--c-text-2); } /* wraps: a sentence-long meta ran past the card edge (admin/notifications) */
.ui-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.ui-card-title + .ui-card-actions { margin-left: auto; }
.ui-card-body { padding: var(--s-4) var(--s-5) var(--s-5); min-width: 0; }
.ui-card-body.ui-card-flush { padding: var(--s-3) 0 0; }
.ui-card-head + .ui-card-body.ui-card-flush { padding-top: var(--s-3); }
.ui-card-body > :first-child { margin-top: 0; }
.ui-card-body > :last-child { margin-bottom: 0; }

/* ── Stat tile ─────────────────────────────────────────────────────────────────────────── */
.st {
  --st-c: var(--c-text);
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: var(--s-3) var(--s-4);
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r);
  color: var(--c-text); text-decoration: none;
  transition: background var(--ease), border-color var(--ease);
}
.st-risk { --st-c: var(--c-risk-text); }
.st-warn { --st-c: var(--c-warn); }
.st-info { --st-c: var(--c-info); }
.st-ok   { --st-c: var(--c-accent); }
a.st:hover { background: var(--c-raised); border-color: var(--c-border-strong); text-decoration: none; color: var(--c-text); }
.st-label { font-size: var(--t-xs); font-weight: 600; color: var(--c-text-2); line-height: 1.4; }
.st-value { font-size: var(--t-stat); font-weight: 600; line-height: 1.15; color: var(--st-c); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.st-delta { font-size: var(--t-xs); color: var(--c-text-2); }
.st-delta-good { color: var(--c-ok); }
.st-delta-bad { color: var(--c-risk-text); }
.st-sub { font-size: var(--t-xs); color: var(--c-text-2); }
.st-spark { display: block; margin-top: var(--s-1); height: 28px; color: var(--st-c); }
.st-neutral .st-spark { color: var(--c-accent); }
.st-spark svg { display: block; width: 100%; height: 100%; }

/* Filter tile (risk/_kit.njk filterTile): a stat tile that filters the list it sits above */
.st-high { --st-c: var(--c-sev-high); }
.st-filter { position: relative; }
.st-filter::before { content: ""; position: absolute; left: var(--s-4); right: var(--s-4); top: 0; height: 3px; border-radius: 0 0 3px 3px; background: var(--st-c); opacity: .85; }
.st-filter.st-neutral::before { background: var(--c-border-strong); }
.st-filter.is-active { border-color: var(--st-c); background: var(--c-raised); }
.st-filter.st-neutral.is-active { border-color: var(--c-accent); }
.st-range { font-weight: 400; color: var(--c-text-2); }

/* ── Filter form (selects submit on change; risk, XDR risk, changes) ───────────────────── */
.ui-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3) var(--s-4); margin-bottom: var(--s-3); }
.ui-filters .ui-field { min-width: 11rem; }

/* ── Chip (outlined tag) and pill (status / severity) ──────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; max-width: 100%;
  height: 20px; padding: 0 var(--s-2);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-pill);
  background: transparent; color: var(--c-text-2);
  font-size: var(--t-xs); font-weight: 600; line-height: 1; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.pill {
  --pill-c: var(--c-text-3); --pill-t: var(--c-text-2);
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  height: 20px; padding: 0 var(--s-2);
  border: 1px solid color-mix(in srgb, var(--pill-c) 45%, transparent);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--pill-c) 10%, transparent);
  color: var(--pill-t);
  font-size: var(--t-xs); font-weight: 600; line-height: 1;
  white-space: nowrap; vertical-align: middle;
}
.pill::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--pill-c); }
.pill-critical { --pill-c: var(--c-risk);     --pill-t: var(--c-risk-text); }
.pill-high     { --pill-c: var(--c-sev-high); --pill-t: var(--c-sev-high); }
.pill-medium   { --pill-c: var(--c-warn);     --pill-t: var(--c-warn); }
.pill-low      { --pill-c: var(--c-info);     --pill-t: var(--c-info); }
.pill-info     { --pill-c: var(--c-info);     --pill-t: var(--c-info); }
.pill-warn     { --pill-c: var(--c-warn);     --pill-t: var(--c-warn); }
.pill-ok       { --pill-c: var(--c-accent);   --pill-t: var(--c-accent); }
.pill-unknown  { --pill-c: var(--c-text-3);   --pill-t: var(--c-text-2); }
.pill-neutral  { --pill-c: var(--c-text-3);   --pill-t: var(--c-text-2); }

/* ── Notes (inline notices, e.g. a capped table) ───────────────────────────────────────── */
.ui-note {
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  border: 1px solid var(--c-info-edge); background: var(--c-info-fill);
  font-size: var(--t-sm); color: var(--c-text);
}
.ui-note-warn { border-color: var(--c-warn-edge); background: var(--c-warn-fill); }
/* A note followed by more content (stacked notes, the base layout's mail-failure banner, a JS
   notice above a form) keeps a gap wherever it sits, not only at the top level; layout containers
   space their children with gap instead. */
.ui-note:not(:last-child) { margin-bottom: var(--s-4); }
:is(.ui-stack, .ui-row, .ui-grid-2, .ui-grid-3, .ui-tiles) > .ui-note { margin-bottom: 0; }
.ui-note-risk { border-color: var(--c-risk-edge); background: var(--c-risk-fill); }
.ui-note-ok   { border-color: var(--c-ok-edge);   background: var(--c-ok-fill); }

/* ── Table ─────────────────────────────────────────────────────────────────────────────── */
.ui-tbl { min-width: 0; }
.ui-tbl > .rf-chips,
.ui-tbl > .tbl-actions-static,
.ui-tbl > .tbl-toolbar,
.ui-tbl > .tbl-capped { margin: 0 0 var(--s-3); }
/* A table filling a flush card: the furniture above it keeps the card's side padding. */
/* Also when the table sits in a tab panel of the flush card (Report library > Changes). */
:is(.ui-card-flush, .ui-card-flush > .tab-section) > .ui-tbl > :is(.rf-chips, .tbl-actions-static, .tbl-toolbar, .tbl-capped) { margin-left: var(--s-5); margin-right: var(--s-5); }

/* A wide table scrolls sideways inside its own box, so the page never does. A long table (more
   than 30 body rows: table-enhance.js sets data-tall, and a page may set it with tall: true) is
   also capped at the window height and scrolls down inside the box, with the header row sticky.
   Shorter tables keep their natural height and no inner scroll. */
.ui-tbl .tbl-scroll { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.ui-tbl .tbl-scroll[data-tall] { overflow: auto; max-height: var(--tbl-max-h); }
.ui-tbl .ui-table {
  width: 100%; border-collapse: collapse; border-spacing: 0;
  font-family: var(--f-sans); font-size: var(--t-sm); color: var(--c-text);
}
.ui-tbl .ui-table thead th {
  position: sticky; top: 0; z-index: 1;
  height: var(--row-h); padding: 0 var(--s-3);
  background: var(--c-surface); border-bottom: 1px solid var(--c-border);
  font-size: var(--t-xs); font-weight: 600; color: var(--c-text-2);
  text-align: left; text-transform: none; letter-spacing: 0; white-space: nowrap; vertical-align: middle;
}
.ui-tbl .ui-table tbody tr { border: 0; transition: background var(--ease); }
.ui-tbl .ui-table tbody td {
  height: var(--row-h); padding: 6px var(--s-3);
  border-bottom: 1px solid var(--c-border);
  font-size: var(--t-sm); color: var(--c-text); vertical-align: middle;
}
.ui-tbl .ui-table tbody tr:last-child td { border-bottom: 0; }
.ui-tbl .ui-table th:first-child, .ui-tbl .ui-table td:first-child { padding-left: var(--s-5); }
.ui-tbl .ui-table th:last-child, .ui-tbl .ui-table td:last-child { padding-right: var(--s-5); }
.ui-tbl .ui-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ui-tbl .ui-table .mono { font-family: var(--f-mono); font-size: var(--t-xs); }
/* A right-aligned header keeps its sort button on the right edge too. */
.ui-tbl .ui-table th.num .th-sort { flex-direction: row-reverse; }
/* Long unbroken values (ARNs, hashes, hostnames) wrap instead of stretching a column forever. */
.ui-tbl .ui-table td { overflow-wrap: break-word; } /* not "anywhere": that shrinks min-content, so narrow screens wrapped words per letter instead of scrolling the table */
.ui-tbl .ui-table td.num, .ui-tbl .ui-table td.nowrap { overflow-wrap: normal; }
/* The sort control table-enhance.js puts inside each sortable header. */
.ui-tbl .ui-table .th-sort {
  display: inline-flex; align-items: center; gap: 4px; padding: 0; margin: 0;
  background: none; border: 0; font: inherit; color: inherit; cursor: pointer; white-space: nowrap;
}
.ui-tbl .ui-table .th-sort:hover, .ui-tbl .ui-table th[aria-sort] .th-sort { color: var(--c-text); }
.ui-tbl .ui-table .th-sort:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; border-radius: 2px; }
/* Empty and no-match rows. */
.ui-tbl .ui-table .tbl-empty td, .ui-tbl .ui-table .tbl-no-match td {
  height: auto; padding: var(--s-7) var(--s-5); text-align: center; color: var(--c-text-2); font-size: var(--t-sm);
}
.ui-tbl .ui-table .tbl-empty:hover, .ui-tbl .ui-table .tbl-no-match:hover { background: transparent; }

/* ── Every data table: zebra rows, hover, number / mono / truncate classes ────────────────── */
/* :where() keeps these at (0,1,2): one class-level part (:nth-child, :hover or .is-alt) plus the
   tbody and tr types. A page rule that names its table's class and the rows (".inv-table tbody tr",
   0,2,2) wins; a bare "tr.x" rule (0,1,1) does not, so a page colouring rows names the table too.
   table-enhance.js stripes by visible row (tr.is-alt, data-zebra) so a filtered table stays even;
   before it runs, :nth-child does the same job. */
:where(table) > tbody > tr:nth-child(even) { background: var(--c-zebra); }
:where(table[data-zebra]) > tbody > tr:nth-child(even) { background: transparent; }
:where(table[data-zebra]) > tbody > tr.is-alt { background: var(--c-zebra); }
:where(table) > tbody > tr:hover { background: var(--c-row-hover); }
:where(table) > tbody > tr:is(.tbl-empty, .tbl-no-match) { background: transparent; }

/* Generic classes for hand-written tables (ui.table sets them from the column spec). */
:where(table) :is(th, td).num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* .mono itself is in ui/base.css: the monospace face for IDs, hashes, IPs and keys. */
.trunc {
  display: inline-block; max-width: 32ch; vertical-align: bottom;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.trunc[data-trunc="8"]  { max-width: 8ch; }
.trunc[data-trunc="12"] { max-width: 12ch; }
.trunc[data-trunc="16"] { max-width: 16ch; }
.trunc[data-trunc="20"] { max-width: 20ch; }
.trunc[data-trunc="24"] { max-width: 24ch; }
.trunc[data-trunc="40"] { max-width: 40ch; }
.trunc[data-trunc="48"] { max-width: 48ch; }
.trunc[data-trunc="64"] { max-width: 64ch; }
/* Keyboard focus on the value, on a link around it or on a link inside it shows the whole value. */
.trunc:focus-visible, :focus-visible > .trunc, .trunc:focus-within { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
.trunc:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; border-radius: 2px; }

/* Filter chips above the table (data-chip-value, aria-pressed). */
.ui-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.ui-chips .rf-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 var(--s-3);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-pill);
  background: transparent; color: var(--c-text-2);
  font-family: var(--f-sans); font-size: var(--t-xs); font-weight: 600; cursor: pointer;
}
.ui-chips .rf-chip b { font-weight: 600; color: var(--c-text-3); font-variant-numeric: tabular-nums; }
.ui-chips .rf-chip:hover { border-color: var(--c-text-3); color: var(--c-text); }
.ui-chips .rf-chip.active { background: var(--c-accent-muted); border-color: var(--c-accent); color: var(--c-text); }
.ui-chips .rf-chip.active b { color: var(--c-text-2); }

/* Search toolbar table-enhance.js inserts before .table-container. */
.ui-tbl .tbl-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.ui-tbl .tbl-toolbar .tbl-search {
  width: 100%; max-width: 300px; height: var(--ctl-h); padding: 0 var(--s-3);
  background: var(--c-raised); border: 1px solid var(--c-border-strong); border-radius: var(--r-sm);
  color: var(--c-text); font-family: var(--f-sans); font-size: var(--t-sm);
}
.ui-tbl .tbl-toolbar .tbl-search::placeholder { color: var(--c-text-3); }
.ui-tbl .tbl-toolbar .tbl-search:focus { border-color: var(--c-accent); }
.ui-tbl .tbl-toolbar .tbl-count { font-size: var(--t-xs); color: var(--c-text-2); font-variant-numeric: tabular-nums; }
.ui-tbl .tbl-actions { display: flex; gap: var(--s-2); margin-left: auto; }
.ui-tbl > .tbl-actions-static { justify-content: flex-end; }

/* ── Segmented tabs (public/js/tabs.js hooks) ──────────────────────────────────────────── */
.tab-bar.seg {
  display: inline-flex; flex-wrap: nowrap; gap: 2px; max-width: 100%; overflow-x: auto;
  padding: 2px; background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--r-sm);
}
.tab-bar.seg.seg-full { display: flex; width: 100%; }
.seg .seg-btn {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; padding: 0 var(--s-4); margin: 0;
  background: transparent; border: 0; border-radius: calc(var(--r-sm) - 2px);
  color: var(--c-text-2); font-family: var(--f-sans); font-size: var(--t-sm); font-weight: 600;
  white-space: nowrap; cursor: pointer; transition: background var(--ease), color var(--ease);
}
.seg-full .seg-btn { flex: 1 1 0; }
.seg .seg-btn:hover { color: var(--c-text); background: transparent; }
.seg .seg-btn.active { background: var(--c-raised); color: var(--c-text); border: 0; }
.seg .seg-btn:focus-visible { outline: 2px solid var(--c-focus); outline-offset: -2px; }
.seg-n { font-size: var(--t-xs); font-weight: 600; color: var(--c-text-3); font-variant-numeric: tabular-nums; }
.seg .seg-btn.active .seg-n { color: var(--c-text-2); }
/* The panel contract (same as components.css; kept here so it survives the legacy sheets). */
.tab-section { display: none; }
.tab-section.active { display: block; }
/* A panel's own heading shows only without JavaScript (ui/nojs.css), when the panels stack. */
.tab-panel-h { display: none; }

/* ── Page tabs (ui.tabs, Phase 3a) ─────────────────────────────────────────────────────────
   One underlined bar under the page header. Three-class selectors: the legacy .tab-btn rules in
   css/components.css load later and would win a tie. */
.tab-bar.ui-tabs {
  display: flex; flex-wrap: nowrap; gap: var(--s-1); max-width: 100%; overflow-x: auto;
  margin: 0 0 var(--s-5); border-bottom: 1px solid var(--c-border);
}
.ui-tabs .tab-btn.ui-tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: var(--s-2);
  height: 38px; padding: 0 var(--s-4); margin: 0 0 -1px;
  background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--c-text-2); font-family: var(--f-sans); font-size: var(--t-md); font-weight: 600;
  white-space: nowrap; cursor: pointer; transition: color var(--ease), border-color var(--ease);
}
.ui-tabs-full .tab-btn.ui-tab { flex: 1 1 0; justify-content: center; }
.ui-tabs .tab-btn.ui-tab:hover { color: var(--c-text); background: transparent; }
.ui-tabs .tab-btn.ui-tab.active { color: var(--c-text); background: transparent; border-bottom-color: var(--c-accent); }
.ui-tabs .tab-btn.ui-tab:focus-visible { outline: 2px solid var(--c-focus); outline-offset: -2px; }
.ui-tab-n {
  min-width: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--c-raised);
  font-size: var(--t-xs); font-weight: 600; line-height: 18px; text-align: center;
  color: var(--c-text-2); font-variant-numeric: tabular-nums;
}
.ui-tabs .tab-btn.ui-tab.active .ui-tab-n { background: var(--c-accent-muted); color: var(--c-text); }

/* ── More menu (ui.moreMenu, public/js/more-menu.js) ──────────────────────────────────────
   The list is hidden with the hidden attribute; nothing here may set display on it while it
   carries [hidden]. */
.ui-more { position: relative; display: inline-flex; }
.ui-more-btn[aria-expanded="true"] { background: var(--c-raised); color: var(--c-text); }
.ui-more-caret { transition: transform var(--ease); }
.ui-more-btn[aria-expanded="true"] .ui-more-caret { transform: rotate(180deg); }
.ui-more-menu {
  position: absolute; top: calc(100% + var(--s-1)); right: 0; z-index: 300;
  min-width: 220px; max-width: 320px; padding: var(--s-1) 0;
  background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--r-sm);
}
.ui-more-menu:not([hidden]) { display: block; }
.ui-more-menu form { margin: 0; }
.ui-more-item {
  display: block; width: 100%; padding: var(--s-2) var(--s-4); margin: 0;
  background: transparent; border: 0; border-radius: 0; text-align: left; text-decoration: none;
  color: var(--c-text); font-family: var(--f-sans); font-size: var(--t-sm); line-height: 1.4;
  cursor: pointer; white-space: normal;
}
.ui-more-item:hover, .ui-more-item:focus-visible { background: var(--c-raised); color: var(--c-text); text-decoration: none; }
.ui-more-item:focus-visible { outline: 2px solid var(--c-focus); outline-offset: -2px; }
.ui-more-item.is-danger { color: var(--c-risk-text); }
.ui-more-sep { height: 1px; margin: var(--s-1) 0; background: var(--c-border); }
/* A form moved in through the {% call %} body keeps its own button classes; in the list it reads
   as a menu row like the others. */
.ui-more-menu .ui-btn {
  display: flex; width: 100%; height: auto; justify-content: flex-start; padding: var(--s-2) var(--s-4);
  background: transparent; border: 0; border-radius: 0; color: var(--c-text); font-weight: 400;
}
.ui-more-menu .ui-btn:hover, .ui-more-menu .ui-btn:focus-visible { background: var(--c-raised); }
.ui-more-menu .ui-btn-danger { color: var(--c-risk-text); }

/* ── Buttons ───────────────────────────────────────────────────────────────────────────── */
/* .ui-btn is the one button class: the macro, exportLink, table-enhance.js and the JS-built
   dialogs all emit it (the legacy .btn family is gone, Task 9). */
.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--ctl-h); padding: 0 var(--s-4); margin: 0;
  border: 1px solid var(--c-border-strong); border-radius: var(--r-sm);
  background: transparent; color: var(--c-text);
  font-family: var(--f-sans); font-size: var(--t-sm); font-weight: 600; line-height: 1;
  text-decoration: none; white-space: nowrap; cursor: pointer; box-shadow: none;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.ui-btn:hover {
  background: var(--c-raised); border-color: var(--c-text-3); color: var(--c-text); text-decoration: none;
}
.ui-btn-primary {
  background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent);
}
.ui-btn-primary:hover {
  background: var(--c-accent-hover); border-color: var(--c-accent-hover); color: var(--c-on-accent);
}
.ui-btn-ghost {
  border-color: transparent; color: var(--c-text-2);
}
.ui-btn-ghost:hover {
  background: var(--c-raised); border-color: transparent; color: var(--c-text);
}
.ui-btn-danger {
  background: transparent; border-color: var(--c-risk-edge); color: var(--c-risk-text);
}
.ui-btn-danger:hover {
  background: var(--c-risk-fill); border-color: var(--c-risk); color: var(--c-risk-text);
}
.ui-btn-sm {
  height: var(--ctl-h-sm); padding: 0 var(--s-3); font-size: var(--t-xs);
}
.ui-btn:disabled, .ui-btn[aria-disabled="true"] {
  opacity: .5; cursor: not-allowed; pointer-events: none;
}
.ui-btn:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.ui-btn-icon { flex: none; }

/* ── Forms ─────────────────────────────────────────────────────────────────────────────── */
.ui-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ui-field + .ui-field { margin-top: var(--s-4); }
.ui-label { font-size: var(--t-sm); font-weight: 600; color: var(--c-text); }
.ui-help { margin: 0; font-size: var(--t-xs); color: var(--c-text-2); }
.ui-error { margin: 0; font-size: var(--t-xs); font-weight: 600; color: var(--c-risk-text); }
.ui-input, .ui-select, .ui-textarea {
  width: 100%; min-width: 0; height: var(--ctl-h); padding: 0 var(--s-3); margin: 0;
  background: var(--c-raised); border: 1px solid var(--c-border-strong); border-radius: var(--r-sm);
  color: var(--c-text); font-family: var(--f-sans); font-size: var(--t-sm); line-height: 1.4;
  transition: border-color var(--ease);
}
.ui-textarea { height: auto; min-height: 72px; padding: var(--s-2) var(--s-3); resize: vertical; }
.ui-select { padding-right: var(--s-2); cursor: pointer; }
/* A control placed straight into a .ui-row (a one-line filter bar) sizes to its content, as the
   old u-w-* widths did; full width would give every filter its own line. Search boxes keep their
   own widths; controls inside a .ui-field are unaffected. */
.ui-row > :is(.ui-select, .form-select), .ui-row > :is(.ui-input, .form-input)[type="date"] { width: auto; max-width: 100%; }
.ui-row > :is(.ui-input, .form-input):not([type="date"]):not([class*="search"]) { width: auto; flex: 0 1 12.5rem; min-width: 10rem; max-width: 100%; }
/* Placeholders use --c-text-3 (about 4.9:1 on --c-raised). A placeholder is a hint, never the
   label or the only instruction: every control has a visible .ui-label. */
.ui-input::placeholder, .ui-textarea::placeholder { color: var(--c-text-3); }
.ui-input:hover, .ui-select:hover, .ui-textarea:hover { border-color: var(--c-text-3); }
.ui-input:focus, .ui-select:focus, .ui-textarea:focus { border-color: var(--c-accent); }
.ui-input:disabled, .ui-select:disabled, .ui-textarea:disabled { opacity: .55; cursor: not-allowed; }
.ui-field-error :is(.ui-input, .ui-select, .ui-textarea) { border-color: var(--c-risk); }
.ui-check { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--t-sm); color: var(--c-text); cursor: pointer; }
.ui-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--c-accent); cursor: pointer; }
.ui-field-check { gap: 2px; }
.ui-field-check .ui-help, .ui-field-check .ui-error { padding-left: 24px; }

/* ── Empty state ───────────────────────────────────────────────────────────────────────── */
.ui-empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  padding: var(--s-7) var(--s-4); text-align: center;
}
.ui-empty-text { margin: 0; max-width: 56ch; font-size: var(--t-sm); color: var(--c-text-2); }

/* ── Empty value, loading skeleton, error state (ui/states.njk) ───────────────────────── */
/* One empty-value mark: a muted middle dot. The dot is decoration (empty alt text after the
   slash, so screen readers skip it); ui.noValue() carries a visually hidden "none" instead. A
   table cell left completely empty (an empty `| dt`) gets the same dot, read as "none". The
   first `content` line is the fallback for browsers without alt text on generated content. */
.ui-none::before { content: "\00b7"; content: "\00b7" / ""; color: var(--c-text-3); font-weight: 600; }
/* Only data cells (tbody) and definition values; a cell with a control in it is never :empty.
   .no-empty-mark opts a cell out where blank is the honest state (a select column, an action
   cell with nothing to do). */
:is(.ui-table, .table-container table) > tbody > tr > td:empty:not(.no-empty-mark)::before,
dd:empty:not(.no-empty-mark)::before { content: "\00b7"; content: "\00b7" / "none"; color: var(--c-text-3); font-weight: 600; }

/* Loading skeleton: grey bars with a slow shimmer. */
.ui-skel { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4) 0; }
.ui-skel-line {
  display: block; height: 12px; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--c-raised) 0%, var(--c-row-hover) 50%, var(--c-raised) 100%);
  background-size: 200% 100%;
  animation: ui-skel-shimmer 1.6s ease-in-out infinite;
}
.ui-skel-line:nth-child(3n + 2) { width: 92%; }
.ui-skel-line:nth-child(3n + 3) { width: 64%; }
.ui-skel-line:nth-child(3n + 4) { width: 80%; }
@keyframes ui-skel-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .ui-skel-line { animation: none; } }

/* Error state: what went wrong and what to try. */
.ui-state-error {
  display: flex; flex-direction: column; gap: var(--s-2); align-items: flex-start;
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--c-risk-edge); border-left: 3px solid var(--c-risk); border-radius: var(--r-sm);
  background: var(--c-risk-fill);
}
.ui-state-title { margin: 0; font-size: var(--t-md); font-weight: 600; color: var(--c-text); }
.ui-state-text { margin: 0; max-width: 72ch; font-size: var(--t-sm); color: var(--c-text-2); }
.ui-state-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-1); }

/* ── Modal (visibility is the .open class; CLAUDE.md "Modal visibility") ────────────────── */
.modal-overlay.ui-modal-overlay {
  position: fixed; inset: 0; z-index: 400;
  display: flex; align-items: center; justify-content: center; padding: var(--s-4);
  background: var(--c-scrim);
  opacity: 0; pointer-events: none; visibility: hidden;
  transition: opacity var(--ease), visibility 0s linear 150ms;
}
.modal-overlay.ui-modal-overlay.open { opacity: 1; pointer-events: auto; visibility: visible; transition-delay: 0s; }
.modal.ui-modal {
  display: flex; flex-direction: column;
  width: min(560px, 100%); max-width: 100%; max-height: calc(100vh - 32px);
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r);
  box-shadow: none; overflow: hidden;
  transform: translateY(6px); transition: transform var(--ease);
}
.modal.ui-modal.ui-modal-wide { width: min(760px, 100%); }
.ui-modal-overlay.open .modal.ui-modal { transform: none; }
.ui-modal-head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border);
}
.ui-modal-title { margin: 0; flex: 1; min-width: 0; font-family: var(--f-sans); font-size: var(--t-lg); font-weight: 600; color: var(--c-text); }
.ui-modal-danger .ui-modal-head { border-bottom-color: var(--c-risk-edge); background: var(--c-risk-fill); }
.ui-modal-danger .ui-modal-title { color: var(--c-risk-text); }
.ui-modal-x {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; margin: 0;
  background: transparent; border: 0; border-radius: var(--r-sm);
  color: var(--c-text-2); cursor: pointer;
}
.ui-modal-x:hover { background: var(--c-raised); color: var(--c-text); }
.ui-modal-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--s-5); font-size: var(--t-md); color: var(--c-text-2); }
.ui-modal-foot {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2);
  padding: var(--s-3) var(--s-5); border-top: 1px solid var(--c-border);
}

/* ── Toast (markup built by public/js/toast.js; restyled in place) ─────────────────────── */
/* Screen readers hear a toast through toast.js's two hidden live regions (role="status",
   aria-live="polite"; role="alert" for errors), so the visible box carries no live role of its
   own and nothing is announced twice. */
.toast-container .toast {
  background: var(--c-raised); border: 1px solid var(--c-border-strong); border-left-width: 3px;
  border-left-color: var(--c-info); border-radius: var(--r-sm);
  padding: var(--s-3) var(--s-4); min-width: 280px; box-shadow: none;
  font-family: var(--f-sans); color: var(--c-text);
}
.toast-container .toast.success { border-left-color: var(--c-ok); }
.toast-container .toast.error   { border-left-color: var(--c-risk); }
.toast-container .toast.warning { border-left-color: var(--c-warn); }
.toast-container .toast.info    { border-left-color: var(--c-info); }
.toast-container .toast .toast-message { font-size: var(--t-sm); color: var(--c-text); }
.toast-container .toast .toast-close { color: var(--c-text-3); }
.toast-container .toast .toast-close:hover { color: var(--c-text); }
.toast-container .toast .toast-progress { color: var(--c-info); }
.toast-container .toast.success .toast-progress { color: var(--c-ok); }
.toast-container .toast.error .toast-progress { color: var(--c-risk); }
.toast-container .toast.warning .toast-progress { color: var(--c-warn); }
/* The bar runs as long as the toast stays: errors stay 10 s (toast.js), the rest 4 s. */
.toast-container .toast.error .toast-progress { animation-duration: 10s; }
.toast-container .toast-close:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }

/* ── Pager ─────────────────────────────────────────────────────────────────────────────── */
.ui-pager.fa-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s-2); margin: var(--s-3) 0 0; padding: 0; }
.ui-card-flush > .ui-pager.fa-pager { margin: 0; padding: var(--s-3) var(--s-5); border-top: 1px solid var(--c-border); }
.ui-pager-state { font-size: var(--t-xs); color: var(--c-text-2); font-variant-numeric: tabular-nums; }

/* ── Focus ring and reading width ──────────────────────────────────────────────────────── */
/* ui/base.css draws one ring on every :focus-visible element. The legacy sheets load after it and
   restyle some of these controls, so the ring is restated here for each interactive family the
   macros emit: buttons, links, chips, tabs, sort headers, form controls, tiles and banner facts. */
:is(.ui-btn, .ui-chips .rf-chip, .seg .seg-btn, .ui-tabs .ui-tab, .ui-more-item, .ui-tbl .th-sort, .ui-input, .ui-select, .ui-textarea,
    .ui-check input, a.st, a.bn-fact, .ui-pager a, .ui-card a, .ph a, .ui-modal-x, .tbl-no-match .link-btn):focus-visible {
  outline: 2px solid var(--c-focus); outline-offset: 2px;
}
.seg .seg-btn:focus-visible, .ui-tabs .ui-tab:focus-visible, .ui-more-item:focus-visible { outline-offset: -2px; }
/* Prose stays readable on a very wide monitor; tables and grids still use the full width. */
:where(.content-area) :where(p, li) { max-width: 100ch; }
.content-area { min-width: 0; }

/* ── Small screens ─────────────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .ui-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .ui-grid-2, .ui-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .ph-actions { width: 100%; }
  .ui-card-head { padding: var(--s-3) var(--s-4) 0; }
  .ui-card-body { padding: var(--s-3) var(--s-4) var(--s-4); }
  .ui-tbl .ui-table th:first-child, .ui-tbl .ui-table td:first-child { padding-left: var(--s-4); }
  .ui-tbl .ui-table th:last-child, .ui-tbl .ui-table td:last-child { padding-right: var(--s-4); }
  :is(.ui-card-flush, .ui-card-flush > .tab-section) > .ui-tbl > :is(.rf-chips, .tbl-actions-static, .tbl-toolbar, .tbl-capped) { margin-left: var(--s-4); margin-right: var(--s-4); }
  .bn-facts { margin-left: calc(-1 * var(--s-3)); }
  .bn-facts > li { padding: 0 var(--s-3); }
}
@media (max-width: 560px) {
  .ui-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bn-facts { flex-direction: column; align-items: flex-start; margin-left: 0; }
  .bn-facts > li { padding: 0; margin-left: 0; border-left: 0; }
  .ui-tbl .tbl-toolbar .tbl-search { max-width: none; }
}

@media print {
  .card.ui-card, .st { border-color: currentColor; }
  .ui-tbl .tbl-scroll { overflow: visible; max-height: none; }
  .trunc { white-space: normal; overflow: visible; max-width: none; }
  .ui-tbl .ui-table thead th { position: static; }
  .ph-actions, .ui-chips, .ui-pager { display: none; }
}

/* Full AD username under a name (views/ui/adname.njk): UPN primary, FETCH\login below. Every username line is one
   line, truncated with an ellipsis and the full value in its title, so a long name never widens a table or card. */
.adn { min-width: 0; max-width: 100%; }
.adn-name { font-weight: 600; color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adn-name a { color: var(--c-accent); }
.adn-u { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; margin-top: 1px; }
.adn-u-v { font-size: var(--t-xs); color: var(--c-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.adn-u-down .adn-u-v { color: var(--c-text-3); }
.adn-copy { flex: none; width: 18px; height: 18px; padding: 0; }
.adn-compact .adn-u-down { display: none; }
.adn-inline { display: inline-flex; align-items: baseline; gap: 4px; min-width: 0; max-width: 100%; overflow: hidden; }
.adn-inline .adn-u-v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adn-u-down2 { color: var(--c-text-3); }
/* In a report table the Person / Identity cell is auto-sized, so a one-line username would set the
   column's intrinsic width (max-width:100% resolves to the content, and nowrap+ellipsis alone does not
   cap it). Inside a ui-table the username block truncates past this width; the full value stays in the
   title and the CSV, so a long UPN never widens a dense table. The down-level form shares the line and
   ellipsises first, so a typical "upn · FETCH\login" shows in full and only an outlier is cut. */
.ui-table .adn-inline { max-width: 40ch; }
.ui-table .adn-u-down2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Universal risk disposition (Task 11): the chip (effective severity + decision badge) and the drawer. */
.disp-chip { display: inline-flex; align-items: center; gap: var(--s-1); vertical-align: middle; }
.disp-badge { display: inline-block; padding: 1px var(--s-2); font-size: var(--t-xs); font-weight: 600; white-space: nowrap;
  color: var(--disp-c, var(--c-text-2)); border: 1px solid currentColor; border-radius: var(--r-pill); }
.disp-accepted { --disp-c: var(--c-ok); }
.disp-revised { --disp-c: var(--c-info); }
.disp-mitigating { --disp-c: var(--c-info); }
.disp-transferred { --disp-c: var(--c-text-2); }
.disp-expired { --disp-c: var(--c-warn); }
/* Shared with risk.css pages: the decision drawer's entity line and action row (moved here from risk.css). */
.rt-actions { display: flex; justify-content: flex-end; gap: var(--s-3); padding-top: var(--s-2); border-top: 1px solid var(--c-border); }
.rt-entity { margin: var(--s-1) 0 0; color: var(--c-text-2); font-size: var(--t-md); overflow-wrap: anywhere; }
.disp-trigger { white-space: nowrap; }
.disp-form { display: flex; flex-direction: column; gap: var(--s-3); }
.disp-form [hidden] { display: none !important; }
.disp-errors { margin: 0; padding: var(--s-2) var(--s-3); font-size: var(--t-sm); color: var(--c-risk-text); border: 1px solid var(--c-risk); border-radius: var(--r-md, 6px); }
