:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --text: #14181f;
  --text-dim: #5b6572;
  --text-faint: #8a93a0;
  --accent: #c2410c;
  --accent-soft: #fff1e7;
  --ok: #0f7b46;
  --ok-soft: #e7f5ee;
  --warn: #a16207;
  --warn-soft: #fdf4e3;
  --err: #b42318;
  --err-soft: #fdecea;
  --info: #1e5eb8;
  --info-soft: #e8f0fc;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 16px rgb(16 24 40 / 6%);
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161b22;
    --surface-2: #1c222b;
    --border: #2a323d;
    --text: #e6edf3;
    --text-dim: #9aa5b1;
    --text-faint: #6e7781;
    --accent: #fb923c;
    --accent-soft: #3a1f0c;
    --ok: #4ade80;
    --ok-soft: #10291c;
    --warn: #fbbf24;
    --warn-soft: #2e2510;
    --err: #f87171;
    --err-soft: #33191a;
    --info: #7cb3ff;
    --info-soft: #16243b;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--info); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------- shell --- */

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; flex-direction: column; gap: 7px; padding: 4px 8px 16px; }
.brand-row { display: flex; align-items: center; gap: 10px; }
/* The wordmark is 3.09:1, so its height is what decides whether it and the
   title share a line. The brand row is 191px inside the 232px sidebar and the
   title needs 103px, leaving 78px once the 10px gap is taken — so 24px high
   (74px wide) fits and 26px (80px) does not. */
.brand-logo { height: 24px; width: auto; display: block; flex: none; }
.brand-text { line-height: 1.2; }
.brand-text strong { display: block; font-size: 14px; }
.brand-by { font-size: 11px; color: var(--text-faint); }

.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 10px; border-radius: 8px;
  color: var(--text-dim); text-decoration: none; cursor: pointer;
  border: 0; background: none; width: 100%; text-align: left;
}
/* Longer labels ("Bravo Licenses") must not wrap or squeeze the count badge. */
.nav-item > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-count {
  font-size: 11px; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--text-faint);
  padding: 1px 6px; border-radius: 20px; flex: none;
}
.nav-item.active .nav-count { background: var(--accent); color: #fff; }
.nav-count.alert { background: var(--err); color: #fff; }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-faint); }
.sidebar-foot strong { display: block; color: var(--text-dim); font-weight: 500; word-break: break-all; }

.main { padding: 22px 26px 60px; min-width: 0; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 2px; font-size: 21px; letter-spacing: -.2px; }
.page-head p { margin: 0; color: var(--text-dim); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* Always there, rarely what you came to do — so it stays quieter than the
   page's own actions sitting beside it. */
.btn.signout { color: var(--text-dim); }
.btn.signout:hover { color: var(--text); }

/* ------------------------------------------------------------ controls --- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); border-color: var(--err); background: transparent; }
.btn.danger:hover { background: var(--err-soft); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input[type=text], input[type=password], input[type=search], select, textarea {
  padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { resize: vertical; min-height: 62px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }

.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px;
}
.filters input[type=search] { flex: 1 1 240px; }
.filters select { width: auto; flex: 0 0 auto; }
.filters .spacer { flex: 1 1 auto; }
.result-count { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- cards --- */

/* ------------------------------------------------------------- jobs --- */

/* Task-shaped entry points. Deliberately the first thing on the page — most
   visits are someone trying to do one of these, not read a number. */
.jobs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.job {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  padding: 15px 16px; border-radius: 12px; cursor: pointer; text-align: left;
  border: 1px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform .14s ease, border-color .14s ease;
}
.job:hover, .job:focus-visible {
  transform: translateY(-2px); border-color: var(--accent); outline: none;
}
.job-title { font-size: 15px; font-weight: 620; color: var(--text); }
.job-sub { font-size: 12.5px; color: var(--text-dim); line-height: 1.35; }
.job.ghost { background: var(--surface-2); box-shadow: none; }
@media (prefers-reduced-motion: reduce) { .job:hover, .job:focus-visible { transform: none; } }

/* ---------------------------------------------------------- worklist --- */

.worklist { display: flex; flex-direction: column; gap: 10px; }
.work {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px 14px 19px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
}
.work::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tone, var(--border)); }
.work.t-crit { --tone: var(--viz-crit); }
.work.t-warn { --tone: var(--viz-warn); }
.work.t-good { --tone: var(--viz-good); }
.work-body { flex: 1; min-width: 0; }
.work-title { font-size: 14.5px; font-weight: 600; margin-bottom: 3px; }
.work-why { font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }
.work .btn { flex: none; }

@media (max-width: 620px) {
  .work { flex-direction: column; align-items: stretch; }
  .work .btn { width: 100%; justify-content: center; }
}

/* ------------------------------------------------------------ picker --- */

.picker-results { max-height: 46vh; overflow-y: auto; margin-top: 4px; }
.picker-row {
  display: grid; grid-template-columns: 1fr auto 16px; align-items: center; gap: 12px;
  width: 100%; padding: 9px 10px; border: 0; border-radius: 8px;
  background: none; cursor: pointer; text-align: left; color: inherit;
}
.picker-row:hover, .picker-row:focus-visible { background: var(--surface-2); outline: none; }
.picker-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-meta { font-size: 12px; color: var(--text-faint); font-family: var(--mono); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 42ch; }
.picker-go { color: var(--text-faint); font-size: 16px; }

/* The key, big enough to read off a screen and compare against a machine. */
.confirm-lead { font-size: 13.5px; color: var(--text-dim); text-align: center; margin: 0 0 14px; }
.confirm-key {
  font-family: var(--mono); font-size: 26px; font-weight: 600; letter-spacing: 1px;
  text-align: center; padding: 18px 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  word-break: break-all; margin-bottom: 12px;
}

/* ------------------------------------------------------ empty states --- */

.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-body { font-size: 13px; color: var(--text-dim); max-width: 52ch; margin: 0 auto 14px; line-height: 1.5; }

/* --------------------------------------------------------- nav groups --- */

.nav-group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-faint); padding: 14px 10px 5px; margin-top: 4px;
  border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------- hero band --- */

.hero {
  display: grid; grid-template-columns: minmax(240px, 340px) 1fr;
  gap: 30px; align-items: center;
  background: var(--surface); /* fallback for engines without color-mix */
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 10%, transparent) 0%, transparent 58%),
    var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 22px 24px; box-shadow: var(--shadow);
}
.hero-main { display: flex; align-items: baseline; gap: 16px; min-width: 0; }
.hero-figure {
  font-size: 60px; font-weight: 680; line-height: .9; letter-spacing: -3px;
  color: var(--text); flex: none;
}
.hero-copy { min-width: 0; }
.hero-copy strong { display: block; font-size: 15px; line-height: 1.25; }
.hero-copy span { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: 4px; }
.hero-chart { min-width: 0; }

@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr; gap: 20px; }
}

/* ----------------------------------------------------------- callout --- */

.callout {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; padding: 12px 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--err);
  border-color: color-mix(in srgb, var(--err) 40%, var(--border));
  background: var(--err-soft);
  background: color-mix(in srgb, var(--err) 9%, var(--surface));
}
.callout:hover { border-color: var(--err); }
.callout-icon {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  background: var(--err); color: #fff;
}
.callout strong { display: block; font-size: 14px; }
.callout span { font-size: 12.5px; color: var(--text-dim); }

/* ------------------------------------------------------------- tiles --- */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 12px; margin-bottom: 22px; }

.tile {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px 15px 14px;
  box-shadow: var(--shadow);
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}
/* A 3px status rail — the tone is repeated by the dot and the number colour,
   so the state never rests on one cue. */
.tile::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--tone, var(--border));
}
.tile.clickable { cursor: pointer; }
.tile.clickable:hover, .tile.clickable:focus-visible {
  transform: translateY(-2px);
  border-color: var(--tone, var(--accent));
  border-color: color-mix(in srgb, var(--tone, var(--accent)) 55%, var(--border));
  box-shadow: 0 2px 4px rgb(16 24 40 / 8%), 0 10px 26px rgb(16 24 40 / 12%);
  outline: none;
}
@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
  .tile.clickable:hover, .tile.clickable:focus-visible { transform: none; }
}
.tile.t-crit { --tone: var(--viz-crit); }
.tile.t-warn { --tone: var(--viz-warn); }
.tile.t-good { --tone: var(--viz-good); }
.tile.t-idle { --tone: var(--text-faint); }

.tile-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--tone, var(--text-faint)); }

.tile-value {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 30px; font-weight: 660; letter-spacing: -1px; line-height: 1.15;
  margin-top: 5px; font-variant-numeric: tabular-nums;
}
.tile.t-crit .tile-value { color: var(--viz-crit); }
.tile.t-good .tile-value { color: var(--viz-good); }
.tile-pct {
  font-size: 12px; font-weight: 600; letter-spacing: 0;
  color: var(--text-faint); font-variant-numeric: tabular-nums;
}

.tile-meter {
  height: 4px; border-radius: 999px; background: var(--viz-track);
  margin: 9px 0 8px; overflow: hidden;
}
.tile-meter span { display: block; height: 100%; border-radius: 999px; background: var(--tone, var(--accent)); }

.tile-sub { font-size: 12px; color: var(--text-dim); line-height: 1.35; }


.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.panel-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); }
.panel-body { padding: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

/* ------------------------------------------------------------- tables --- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--text-dim);
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }
tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 220px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.key { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.2px; }
.muted { color: var(--text-faint); }
.empty { padding: 40px 20px; text-align: center; color: var(--text-faint); }

/* -------------------------------------------------------------- pills --- */

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .2px;
  background: var(--surface-2); color: var(--text-dim);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--err-soft); color: var(--err); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* -------------------------------------------------------------- modal --- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgb(9 12 17 / 55%);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  width: min(660px, 100%); max-height: 88vh; display: flex; flex-direction: column;
}
.modal.wide { width: min(920px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-head .sub { font-size: 12px; color: var(--text-faint); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--text-faint); font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-faint); margin: 14px 0 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.form-grid + .section-label { margin-top: 4px; }

dl.detail { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
dl.detail dt { color: var(--text-faint); }
dl.detail dd { margin: 0; word-break: break-word; }

/* -------------------------------------------------------------- toast --- */

#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--info);
  border-radius: 8px; box-shadow: var(--shadow); padding: 10px 14px; max-width: 380px; font-size: 13px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }

/* --------------------------------------------------------------- viz --- */

/* Reserved status tokens — fixed, never themed. Validated against this app's
   own surfaces (#ffffff light, #161b22 dark): worst adjacent CVD ΔE 11.3,
   normal-vision ΔE 27.6. Amber is sub-3:1 on white by design, so every chart
   using it ships visible labels, a legend, and a table view. */
/* Declared at :root so tiles and table accents draw on the same tokens as the
   charts — a colour must mean one thing across the whole app. */
:root {
  --viz-good: #0ca30c;   /* key verified on the machine */
  --viz-warn: #fab219;   /* has a key, nobody has checked it */
  --viz-crit: #d03b3b;   /* no key at all */
  --viz-series-1: #2a78d6;
  --viz-track: #f0efec;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --viz-series-1: #3987e5;
    --viz-track: #24262b;
  }
}
:root[data-theme="dark"] {
  --viz-series-1: #3987e5;
  --viz-track: #24262b;
}

.viz-figure { margin: 0; }

/* Bars. The 2px gap is a surface gap between fills, not a border on the mark. */
.viz-bar { display: flex; gap: 2px; border-radius: 4px; overflow: hidden; min-width: 3px; }
.viz-bar.tall { height: 34px; }
.viz-seg {
  min-width: 3px; height: 100%;
  display: flex; align-items: center;
  transition: opacity .12s;
}
.viz-bar.tall .viz-seg { cursor: pointer; }
.viz-bar.tall .viz-seg:hover { opacity: .82; }
.viz-seg-label {
  padding: 0 10px; font-size: 12px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden;
}
/* Amber is a light fill in both modes, so its in-bar label takes dark ink —
   white on #fab219 would be unreadable. */
.viz-seg.seg-unverified .viz-seg-label { color: #3d2a00; }

.viz-chart-row {
  display: grid; grid-template-columns: 150px 1fr 62px;
  align-items: center; gap: 10px;
  height: 26px; cursor: pointer; border-radius: 6px; padding: 0 4px;
}
.viz-chart-row:hover { background: var(--surface-2); }
.viz-chart-row .viz-bar { height: 14px; }

.viz-row-label {
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
}
.viz-chart-row:hover .viz-row-label { color: var(--text); }
.viz-row-label .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--text-faint); }
.viz-row-label .dot.err { background: var(--viz-crit); }
.viz-row-label .dot.warn { background: var(--viz-warn); }
.viz-row-label .dot.info { background: var(--viz-series-1); }

.viz-track { display: block; min-width: 0; }
.viz-value {
  font-size: 12px; color: var(--text-dim); text-align: right;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* Below this the panel is too narrow to guarantee an in-bar label fits, so the
   legend carries the numbers instead of risking a clipped label. */
@media (max-width: 900px) {
  .viz-seg-label { display: none; }
}
@media (max-width: 620px) {
  .viz-chart-row { grid-template-columns: 104px 1fr 52px; }
}
.viz-caption {
  font-size: 12px; color: var(--text-dim); margin: 0 0 12px;
}

/* Legend — always present for 2+ series, so identity is never colour-alone. */
.viz-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  margin: 0 0 12px; padding: 0; list-style: none;
  font-size: 12px; color: var(--text-dim);
}
.viz-legend li { display: flex; align-items: center; gap: 6px; }
.viz-legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.viz-legend b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }

.viz-row-label {
  font-size: 12px; fill: var(--text-dim);
}
.viz-value { font-size: 11px; fill: var(--text-dim); font-variant-numeric: tabular-nums; }
.viz-seg { cursor: pointer; }
.viz-seg:hover { opacity: .82; }

.viz-tooltip {
  position: fixed; z-index: 200; pointer-events: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 7px 10px; font-size: 12px;
  max-width: 260px;
}
.viz-tooltip .t-title { font-weight: 600; margin-bottom: 2px; }
.viz-tooltip .t-row { display: flex; align-items: center; gap: 6px; color: var(--text-dim); }
.viz-tooltip .t-row .swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }

.viz-rows { max-height: 460px; overflow-y: auto; }
.viz-site-row { cursor: pointer; }
.viz-site-row:hover .viz-row-label { fill: var(--text); }

/* Row status accents — the same three states as the charts, so a colour learned
   in a chart means the same thing in a table. */
tr.row-crit td:first-child { box-shadow: inset 3px 0 0 var(--err); }
tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tr.row-good td:first-child { box-shadow: inset 3px 0 0 var(--ok); }

/* ---------------------------------------------------------- assistant --- */

.chat-log { max-height: 56vh; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.chat-empty { color: var(--text-dim); font-size: 13px; }
.chat-empty p { margin: 0 0 12px; }
.chat-suggestions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.chat-suggestions .btn { text-align: left; white-space: normal; }

.chat-msg { max-width: 100%; }
.chat-msg.user {
  align-self: flex-end; max-width: 76%;
  background: var(--accent-soft); color: var(--text);
  border-radius: 12px 12px 3px 12px; padding: 9px 13px;
}
.chat-msg.user p { margin: 0; }
.chat-msg.assistant { align-self: flex-start; max-width: 88%; }

.chat-steps { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.chat-step { font-size: 12px; color: var(--text-faint); display: flex; align-items: center; gap: 7px; }
.chat-step.done { opacity: .55; }
.chat-step.done .spinner-dot { animation: none; background: var(--ok); }
.spinner-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none;
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .spinner-dot { animation: none; } }

.chat-error { color: var(--err); font-size: 13px; }

.prose p { margin: 0 0 9px; line-height: 1.55; }
.prose p:last-child, .prose ul:last-child, .prose ol:last-child { margin-bottom: 0; }
.prose ul, .prose ol { margin: 0 0 9px; padding-left: 20px; }
.prose li { margin-bottom: 4px; line-height: 1.5; }
.prose code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

.chat-composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.chat-input { resize: none; max-height: 140px; }

/* ------------------------------------------------------- review findings --- */

.review-headline { font-size: 15px; line-height: 1.5; margin: 0 0 16px; }

.finding {
  position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 15px 14px; margin-bottom: 12px; background: var(--surface);
}
.finding::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tone, var(--border)); }
.finding.t-crit { --tone: var(--viz-crit); }
.finding.t-warn { --tone: var(--viz-warn); }
.finding.t-idle { --tone: var(--text-faint); }
.finding-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.finding-head strong { font-size: 14px; }
.finding-refs { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.finding-fix {
  margin-top: 12px; padding: 10px 12px; border-radius: 8px;
  background: var(--surface-2); font-size: 13px;
}
.finding-fix-label {
  display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-faint); margin-bottom: 5px;
}

/* ---------------------------------------------------- command palette --- */

.palette-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; margin-bottom: 10px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text-faint);
  cursor: pointer; text-align: left;
}
.palette-trigger:hover { border-color: var(--accent); color: var(--text); }
.palette-trigger kbd {
  font: 11px var(--mono); padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-faint);
}

.palette-input input { font-size: 15px; padding: 10px 12px; }
.palette-results { margin-top: 12px; max-height: 52vh; overflow-y: auto; }
.palette-hint { color: var(--text-faint); font-size: 13px; padding: 14px 4px; margin: 0; }
.palette-group {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-faint); padding: 10px 4px 4px;
}
.palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer;
}
.palette-item.active { background: var(--accent-soft); }
.palette-label { font-weight: 600; white-space: nowrap; }
.palette-meta {
  color: var(--text-faint); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}

/* ----------------------------------------------------------- bulk bar --- */

.bulk-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; margin-bottom: 12px;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent-soft); color: var(--text);
}
.bulk-bar[hidden] { display: none; }

td input[type=checkbox], th input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

/* --------------------------------------------------------------- gate --- */

.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.gate-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 32px; width: min(400px, 100%); text-align: center;
}
.gate-logo { height: 34px; width: auto; display: block; margin: 0 auto 16px; }
.gate-card h1 { margin: 0 0 6px; font-size: 19px; }
.gate-card p { margin: 0 0 18px; color: var(--text-dim); font-size: 13px; }
.gate-card form { display: flex; flex-direction: column; gap: 10px; }
.gate-card button {
  padding: 9px 14px; border-radius: 8px; border: 0;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
.gate-error { color: var(--err); font-size: 13px; margin: 0; }
/* The landing page's way in. An anchor rather than a button, because following
   it is a navigation into Cloudflare's sign-in flow, not a form submission. */
/* ------------------------------------------------------------ landing --- */
/* The public front door. Deliberately quiet: one click later you are inside a
   dense working tool, and a loud entrance would read as a different product.
   Character comes from scale, spacing and a single brand accent rather than
   decoration — there is no display face to reach for, because font-src is
   'self' and this page loads no webfonts. */

.landing {
  --gem: #e3222b;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  /* Two offset glows instead of a flat fill, so the card sits in a space
     rather than on a colour. Low enough alpha to read on either theme. */
  background:
    radial-gradient(48rem 30rem at 50% -12%, rgb(227 34 43 / 13%), transparent 70%),
    radial-gradient(36rem 24rem at 88% 108%, rgb(227 34 43 / 7%), transparent 72%),
    var(--bg);
}

/* A fine diagonal weave — enough to give the background a surface, not enough
   to become a pattern anyone notices. */
.landing::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(135deg,
    rgb(127 127 127 / 3.5%) 0 1px, transparent 1px 7px);
}

.landing-card {
  position: relative;
  width: min(400px, 100%);
  text-align: center;
  padding: 44px 40px 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* The brand edge — the only saturated thing above the button. */
.landing-card::before {
  content: '';
  position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, var(--gem), #ff5a45);
}

.landing-logo { height: 46px; width: auto; display: block; margin: 0 auto 24px; }
.landing-card h1 { margin: 0 0 10px; font-size: 23px; font-weight: 600; letter-spacing: -.3px; }
.landing-lede {
  margin: 0 auto 28px; max-width: 30ch;
  font-size: 14px; line-height: 1.55; color: var(--text-dim);
}

.landing-cta {
  display: block; padding: 12px 20px;
  border-radius: 10px; background: var(--gem); color: #fff;
  font-size: 14.5px; font-weight: 600; text-decoration: none;
  box-shadow: 0 1px 2px rgb(0 0 0 / 18%);
  transition: background 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}
.landing-cta:hover {
  background: #c8181f; transform: translateY(-1px);
  box-shadow: 0 4px 14px rgb(227 34 43 / 30%);
}
.landing-cta:active { transform: translateY(0); }
.landing-cta:focus-visible { outline: 2px solid var(--gem); outline-offset: 3px; }

.landing-foot {
  margin: 26px 0 0; padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint);
}

/* One orchestrated entrance beats scattered micro-interactions. `backwards`
   rather than `both`, so the button's own hover transform still applies once
   the animation has finished. */
@media (prefers-reduced-motion: no-preference) {
  .landing-card > * { animation: landing-rise 620ms cubic-bezier(.22, .7, .3, 1) backwards; }
  .landing-logo { animation-delay: 60ms; }
  .landing-card h1 { animation-delay: 130ms; }
  .landing-lede { animation-delay: 200ms; }
  .landing-cta { animation-delay: 270ms; }
  .landing-foot { animation-delay: 340ms; }
}
@keyframes landing-rise {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}

.loading { padding: 60px; text-align: center; color: var(--text-faint); }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-foot { width: 100%; margin-top: 8px; }
  .nav-item { width: auto; }
  .main { padding: 16px; }
}

/* --- destructive confirmation ------------------------------------------- */
/* Deletes get their own visual weight: the consequences are stated, the safe
   alternative is offered inline, and the button stays dead until the name is
   typed. Nothing here is decorative — the server checks the same string. */
.danger-block {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 8px;
  background: var(--err-soft); color: var(--err);
  border-left: 3px solid var(--err); font-size: 13px; line-height: 1.5;
}
.danger-lose {
  margin: 0 0 14px; padding: 12px 14px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.danger-lose-title {
  margin: 0 0 6px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint);
}
.danger-lose ul { margin: 0; padding-left: 18px; }
.danger-lose li { font-size: 13px; line-height: 1.6; color: var(--text-dim); }
.danger-instead { margin: 0 0 14px; font-size: 13px; color: var(--text-dim); }
.danger-prompt { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-dim); }
.danger-prompt code {
  padding: 1px 5px; border-radius: 4px; background: var(--surface-2);
  font-family: var(--mono); font-size: 12px; color: var(--text);
}
.danger-name { font-family: var(--mono); letter-spacing: .02em; }
.danger-name:focus { border-color: var(--err); outline-color: var(--err); }
.btn.danger:disabled { opacity: .4; cursor: not-allowed; }
.btn.danger:disabled:hover { background: transparent; }
.linkish {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--accent); font: inherit; text-decoration: underline;
}

/* --- bulk edit review ---------------------------------------------------- */
.bulk-hazards { margin: 0 0 14px; display: grid; gap: 8px; }
.bulk-hazard {
  margin: 0; padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.5;
  background: var(--warn-soft); color: var(--warn); border-left: 3px solid var(--warn);
}
.bulk-hazard[data-kind="strand"] {
  background: var(--err-soft); color: var(--err); border-left-color: var(--err);
}
.bulk-change {
  margin: 0 0 12px; padding: 12px 14px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.bulk-change-title {
  margin: 0 0 6px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint);
}
.bulk-change ul { margin: 0; padding-left: 18px; }
.bulk-change li { font-size: 13px; line-height: 1.8; color: var(--text-dim); }
.bulk-field { font-weight: 600; color: var(--text); }
.bulk-change code, .bulk-names code {
  padding: 1px 5px; border-radius: 4px; background: var(--surface);
  border: 1px solid var(--border); font-family: var(--mono); font-size: 12px; color: var(--text);
}
.bulk-names summary { cursor: pointer; font-size: 13px; color: var(--text-dim); }
.bulk-names p {
  margin: 8px 0 0; font-size: 12px; line-height: 1.7; color: var(--text-faint);
  max-height: 180px; overflow-y: auto;
}

/* --- release ------------------------------------------------------------- */
/* Releasing from a live machine and recovering a key from a retired one are
   opposite acts behind the same button; the copy and the colour say which. */
.release-warn, .release-ok {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 8px;
  font-size: 13px; line-height: 1.55; border-left: 3px solid;
}
.release-warn { background: var(--warn-soft); color: var(--warn); border-left-color: var(--warn); }
.release-ok   { background: var(--ok-soft);   color: var(--ok);   border-left-color: var(--ok); }

/* Assign hazards reuse the bulk styling; these three are the loud ones. */
.bulk-hazard[data-kind="duplicate"],
.bulk-hazard[data-kind="near_miss"],
.bulk-hazard[data-kind="deactivated"] {
  background: var(--err-soft); color: var(--err); border-left-color: var(--err);
}

/* --- people -------------------------------------------------------------- */
.people-domains { padding: 14px 16px; margin-bottom: 14px; }
.people-domains ul { margin: 0; padding-left: 18px; }
.people-domains li { font-size: 13px; line-height: 1.9; color: var(--text-dim); }
.people-domains code {
  padding: 1px 6px; border-radius: 4px; background: var(--surface-2);
  border: 1px solid var(--border); font-family: var(--mono); font-size: 12px; color: var(--text);
}
.role-select { padding: 3px 6px; font-size: 12px; border-radius: 6px; }
.role-select:disabled { opacity: .55; cursor: not-allowed; }
/* The "you are signed in but not on the roster" panel. This used to be called
   .gate as well, which collided with the full-page wrapper of the same name
   above: the wrapper inherited this max-width and background and rendered as a
   520px band down the middle of the sign-in and landing pages. */
.notice {
  max-width: 520px; margin: 18vh auto; padding: 28px 32px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.notice h1 { margin: 0 0 12px; font-size: 20px; color: var(--text); }
.notice p { margin: 0 0 10px; font-size: 14px; line-height: 1.6; color: var(--text-dim); }
