/* ===========================================================================
   Classification dashboard theme.
   Tokens and primitives. Page layout lives in app.css, which loads after this.

   Read THEME.md before you add a component. Two rules matter most:
     1. Use a token. Do not write a hex value in app.css or in page CSS.
     2. Colour never carries meaning alone. Pair it with a glyph or a label.
   =========================================================================== */

:root {
  /* --- Surfaces ------------------------------------------------------- */
  --bg: #1a1d21;          /* page */
  --panel: #212429;       /* card, section */
  --panel-2: #1e2126;     /* header, table head, nested card */
  --panel-3: #24272c;     /* inset control, unselected chip */
  --field: #1a1d21;       /* input, select */
  --sel: #252b36;         /* selected row or card */

  /* --- Lines ---------------------------------------------------------- */
  --line: #2b2f35;        /* section hairline */
  --line-2: #33383f;      /* control border */
  --line-sel: #3d4657;    /* selected border */
  --divider: #24272c;     /* row divider inside a list */

  /* --- Text ----------------------------------------------------------- */
  --text: #dfe3e8;
  --text-2: #c3c9d1;
  --muted: #949ca6;
  --accent: #a3b3dd;      /* link, emphasis */
  --accent-text: #c9d4ee; /* text on an accent surface */

  /* --- Review states --------------------------------------------------
     Every state owns a glyph, a foreground, a tint, a border and a solid
     fill. The solid fill marks a human reviewer. See THEME.md.           */
  --pass-fg: #9fbfa8;  --pass-bg: #232a26;  --pass-line: #3c4d43;  --pass-solid: #44705a;
  --none-fg: #949ca6;  --none-bg: #24272c;  --none-line: #383d44;  --none-solid: #5a626c;
  --needs-fg: #cbae72; --needs-bg: #2e2a20; --needs-line: #443d2c; --needs-solid: #8f7b4a;
  --rej-fg: #d49aa0;   --rej-bg: #2e2326;   --rej-line: #4a3a3e;   --rej-solid: #8d5f65;

  /* --- Coverage bar segments ------------------------------------------ */
  --seg-human: #9fbfa8;
  --seg-judge: #5c7f68;
  --seg-unreviewed: #3a3f46;
  --seg-needs: #8f7b4a;
  --seg-rejected: #8d5f65;
  --seg-never: #24272c;

  /* --- Semantic aliases -----------------------------------------------
     Older rules in app.css read these names. They now resolve to the
     theme palette, so a run status and a review state agree on colour.   */
  --green: var(--pass-fg);
  --yellow: var(--needs-fg);
  --red: var(--rej-fg);

  /* --- Type ------------------------------------------------------------ */
  --font-ui: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* --- Radius ---------------------------------------------------------- */
  --r-pill: 99px;
  --r-panel: 10px;
  --r-btn: 8px;
  --r-input: 7px;
  --r-tab: 6px;
  --r-glyph: 4px;
  --radius: var(--r-panel);

  color-scheme: dark;
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-text); }
::selection { background: var(--sel); }

h1 { font: 600 20px/1.2 var(--font-ui); letter-spacing: -.02em; margin: 3px 0 4px; }
h2 { font: 600 15px/1.3 var(--font-ui); letter-spacing: -.01em; margin: 0; }
h3 { font: 600 13px/1.35 var(--font-ui); margin: 0 0 4px; }

.eyebrow {
  font: 600 9px/1 var(--font-ui);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 5px;
}
.muted { color: var(--muted); margin: 0; }
.small { font-size: 11px; }
/* Carries the state word for a screen reader when the glyph is the only
   visible marker. */
.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;
}
.mono { font-family: var(--font-mono); font-size: .92em; }
.back { display: block; color: var(--muted); font-size: 11.5px; margin-bottom: 14px; }

code { font-family: var(--font-mono); color: var(--text-2); }

/* ---------------------------------------------------------------------------
   Topbar
   --------------------------------------------------------------------------- */
.topbar {
  height: 46px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 18px;
  border-bottom: 1px solid var(--line); background: var(--panel-2);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; gap: 9px; align-items: center; font: 600 13px/1 var(--font-ui); color: var(--text); white-space: nowrap; }
.brand small { font: 400 11px/1 var(--font-ui); color: var(--muted); }
.brand-mark {
  display: grid; place-items: center; width: 22px; height: 22px;
  border-radius: var(--r-tab); background: var(--sel); border: 1px solid var(--line-sel);
  font: 700 10px/1 var(--font-mono); color: var(--accent-text);
}
nav { display: flex; gap: 2px; align-items: center; }
nav a {
  color: var(--muted); padding: 7px 9px; border-radius: var(--r-tab);
  font: 500 12px/1 var(--font-ui);
}
nav a:hover { color: var(--text-2); background: var(--panel-3); }
nav a.active { color: var(--text); background: var(--sel); }
nav .nav-count { font: 700 11px/1 var(--font-mono); color: var(--needs-fg); margin-left: 4px; }
.live-dot {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--pass-fg); margin-left: 5px;
}
.nav-user {
  color: var(--muted); font: 500 11px/1 var(--font-mono); padding: 7px 8px;
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-logout { color: var(--muted); font: 500 11px/1 var(--font-ui); padding: 7px 8px; }

/* ---------------------------------------------------------------------------
   Shell and page head
   --------------------------------------------------------------------------- */
.shell { max-width: 1400px; margin: 0 auto; padding: 16px 18px 48px; }
.shell.wide { max-width: 1640px; }

.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 0 0 14px; }
.hero.compact { align-items: center; }
.hero p.muted { font: 400 12px/1.55 var(--font-ui); max-width: 88ch; margin-top: 4px; }
.hero-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------------------
   Panel
   --------------------------------------------------------------------------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-panel); padding: 15px;
}
.panel-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.grid { display: grid; gap: 14px; }

/* ---------------------------------------------------------------------------
   Buttons
   Approve is the only saturated fill on the page. Keep it that way.
   --------------------------------------------------------------------------- */
.button {
  border: 1px solid var(--line-2); border-radius: var(--r-btn);
  padding: 8px 13px; background: #252930; color: var(--text-2);
  font: 600 11.5px/1 var(--font-ui); cursor: pointer;
  display: inline-block; text-align: center;
}
.button:hover { color: var(--text); border-color: var(--line-sel); }
.button.primary { border-color: var(--pass-solid); background: var(--pass-solid); color: #fff; font-weight: 700; }
.button.primary:hover { border-color: var(--pass-solid); filter: brightness(1.1); }
.button.danger { border-color: var(--rej-line); background: var(--rej-bg); color: var(--rej-fg); font-weight: 700; }
.button.danger:hover { color: var(--rej-fg); border-color: var(--rej-fg); }
.button.info { border-color: var(--line-sel); background: var(--sel); color: var(--accent-text); }
.button.ghost { background: transparent; }
.button.small { padding: 6px 10px; font-size: 10.5px; }
.button:disabled { opacity: .4; cursor: not-allowed; }
.button kbd, .button .key { font-family: var(--font-mono); opacity: .75; margin-left: 4px; }

/* ---------------------------------------------------------------------------
   Form controls
   --------------------------------------------------------------------------- */
label { color: var(--muted); font: 600 10px/1 var(--font-ui); }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 8px 9px;
  border: 1px solid var(--line-2); border-radius: var(--r-input);
  background: var(--field); color: var(--text);
  font: 500 11.5px/1.2 var(--font-ui); outline: none;
}
input[type="search"], input.mono, .filters input { font-family: var(--font-mono); }
input:focus, select:focus, textarea:focus {
  border-color: var(--line-sel); box-shadow: 0 0 0 2px rgba(163, 179, 221, .14);
}
input[type="checkbox"], input[type="radio"] { width: auto; margin: 0; accent-color: var(--pass-solid); }
kbd {
  display: inline-block; border: 1px solid var(--line-2); border-bottom-width: 2px;
  border-radius: var(--r-glyph); padding: 1px 5px;
  font: 10px/1.4 var(--font-mono); background: var(--panel-3); color: var(--text);
}

/* ---------------------------------------------------------------------------
   Badges, counts, run status
   --------------------------------------------------------------------------- */
.badge, .count {
  border: 1px solid var(--line-2); border-radius: var(--r-pill);
  background: var(--panel-3); color: var(--text-2);
  padding: 3px 8px; font: 500 10px/1.4 var(--font-ui);
}
.badge-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.badge.warn { border-color: var(--needs-line); color: var(--needs-fg); background: var(--needs-bg); }
.badge.bad { border-color: var(--rej-line); color: var(--rej-fg); background: var(--rej-bg); }
.badge.muted { opacity: .7; }

.status {
  display: inline-block; border-radius: var(--r-pill); padding: 3px 8px;
  font: 700 9.5px/1.4 var(--font-mono); text-transform: uppercase; letter-spacing: .06em;
  background: var(--panel-3); color: var(--text-2); border: 1px solid var(--line-2);
}
.status.completed, .status.succeeded { color: var(--pass-fg); background: var(--pass-bg); border-color: var(--pass-line); }
.status.failed { color: var(--rej-fg); background: var(--rej-bg); border-color: var(--rej-line); }
.status.stale, .status.pending { color: var(--needs-fg); background: var(--needs-bg); border-color: var(--needs-line); }
.status.started, .status.running { color: var(--accent-text); background: var(--sel); border-color: var(--line-sel); }
.status.large { padding: 5px 11px; font-size: 10.5px; }

.health {
  display: flex; gap: 7px; align-items: center; color: var(--muted);
  font: 500 11px/1 var(--font-ui);
  border: 1px solid var(--line-2); background: var(--panel-3);
  padding: 6px 10px; border-radius: var(--r-pill);
}
.health span { width: 6px; height: 6px; border-radius: 50%; }
.health.online span { background: var(--pass-fg); }
.health.offline span { background: var(--rej-fg); }
.health b { font-size: 9px; text-transform: uppercase; color: var(--needs-fg); margin-left: 2px; }

/* ---------------------------------------------------------------------------
   Segmented control (density switch, tab switch)
   --------------------------------------------------------------------------- */
.view-toggle {
  display: inline-flex; gap: 2px; padding: 2px;
  border: 1px solid var(--line-2); border-radius: var(--r-btn); background: var(--panel);
}
.view-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font: 600 11.5px/1 var(--font-ui); padding: 6px 12px; border-radius: var(--r-tab);
}
.view-btn:hover { color: var(--text-2); }
.view-btn.active { background: var(--sel); color: var(--text); }

/* ---------------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
th {
  text-align: left; padding: 8px 9px;
  font: 600 9px/1.4 var(--font-ui); letter-spacing: .11em; text-transform: uppercase;
  color: var(--muted); background: var(--panel-2);
  position: sticky; top: 0; z-index: 2;
}
td { padding: 9px; border-top: 1px solid var(--line); vertical-align: top; }
td small { display: block; color: var(--muted); margin-top: 3px; font-size: 9.5px; }
tbody tr:hover { background: var(--panel-3); }
.table-wrap { overflow: auto; max-height: 58vh; border: 1px solid var(--line); border-radius: 9px; }

/* ---------------------------------------------------------------------------
   Review state indicator
   Glyph carries the state. Fill carries the reviewer. Dashed plus the stale
   mark carries staleness. Colour only confirms. Never ship one without a
   glyph: the indicator must survive a grayscale screenshot.
   --------------------------------------------------------------------------- */
.rv {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  vertical-align: middle;
  border: 1px solid var(--rv-line); border-radius: var(--r-pill);
  background: var(--rv-bg); padding: 2px 8px 2px 2px;
}
.rv-passed       { --rv-fg: var(--pass-fg);  --rv-bg: var(--pass-bg);  --rv-line: var(--pass-line);  --rv-solid: var(--pass-solid); }
.rv-unreviewed   { --rv-fg: var(--none-fg);  --rv-bg: var(--none-bg);  --rv-line: var(--none-line);  --rv-solid: var(--none-solid); }
.rv-needs_review { --rv-fg: var(--needs-fg); --rv-bg: var(--needs-bg); --rv-line: var(--needs-line); --rv-solid: var(--needs-solid); }
.rv-rejected     { --rv-fg: var(--rej-fg);   --rv-bg: var(--rej-bg);   --rv-line: var(--rej-line);   --rv-solid: var(--rej-solid); }

.rv-glyph {
  flex: none; width: 14px; height: 14px; border-radius: var(--r-glyph);
  display: grid; place-items: center;
  border: 1px solid var(--rv-line); background: transparent;
  font: 700 8px/1 var(--font-mono); color: var(--rv-fg);
}
/* A human decision outranks a judge decision, so it gets the solid fill. */
.rv[data-reviewer="human"] .rv-glyph { background: var(--rv-solid); color: #fff; }
/* Evidence changed after the review. The verdict shows, but it is not load-bearing. */
.rv[data-stale="true"] { border-style: dashed; }
.rv-stale { flex: none; font: 700 8px/1 var(--font-mono); color: var(--needs-fg); }

.rv-value {
  font: 500 10.5px/1.3 var(--font-mono); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rv-unreviewed .rv-value { color: var(--muted); }
.rv-empty { color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; }

/* Expanded form: detail views, where the state gets a word and a date. */
.rv.rv-lg { gap: 7px; border-radius: var(--r-btn); padding: 4px 10px 4px 5px; }
.rv.rv-lg .rv-glyph { width: 17px; height: 17px; border-radius: 5px; font-size: 10px; }
.rv.rv-lg .rv-label { font: 600 11px/1 var(--font-ui); color: var(--rv-fg); }
.rv.rv-lg .rv-meta { font: 500 10px/1 var(--font-mono); color: var(--muted); }

/* Row rollup: count only the states that need a person. */
.rv-roll { display: inline-flex; gap: 5px; align-items: center; font: 700 10px/1 var(--font-mono); }
.rv-roll .n-needs { color: var(--needs-fg); }
.rv-roll .n-rej { color: var(--rej-fg); }
.rv-roll .n-none { color: var(--muted); }
.rv-roll .is-zero { color: var(--muted); opacity: .55; }

/* ---------------------------------------------------------------------------
   Coverage bar
   --------------------------------------------------------------------------- */
.cov-bar { display: flex; height: 11px; border-radius: var(--r-glyph); overflow: hidden; background: var(--line); }
.cov-bar.sm { height: 9px; border-radius: 3px; }
.cov-bar.xs { height: 3px; border-radius: 3px; }
.cov-seg { display: block; height: 100%; }
.cov-seg[data-seg="human"] { background: var(--seg-human); }
.cov-seg[data-seg="judge"] { background: var(--seg-judge); }
.cov-seg[data-seg="unreviewed"] { background: var(--seg-unreviewed); }
.cov-seg[data-seg="needs"] { background: var(--seg-needs); }
.cov-seg[data-seg="rejected"] { background: var(--seg-rejected); }
.cov-seg[data-seg="never"] { background: var(--seg-never); }

.cov-legend { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.cov-legend > span { display: inline-flex; align-items: center; gap: 6px; font: 500 10px/1 var(--font-ui); color: var(--text-2); }
.cov-key { width: 10px; height: 10px; border-radius: 3px; display: block; }

/* ---------------------------------------------------------------------------
   KPI card
   --------------------------------------------------------------------------- */
.kpi-row { display: flex; gap: 8px; flex-wrap: wrap; }
.kpi { flex: 1 1 150px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-panel); padding: 12px 14px; }
.kpi-label { display: flex; align-items: center; gap: 6px; font: 600 9px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.kpi b { display: block; font: 700 22px/1.2 var(--font-ui); letter-spacing: -.02em; margin-top: 6px; }
.kpi small { display: block; font: 400 11px/1 var(--font-ui); color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------------------------------
   Feedback
   --------------------------------------------------------------------------- */
.empty { color: var(--muted); text-align: center; padding: 28px !important; font-size: 11.5px; }
.is-empty { color: var(--muted); }
.error-box {
  color: var(--rej-fg); background: var(--rej-bg); border: 1px solid var(--rej-line);
  padding: 10px; border-radius: var(--r-input); font-size: 11.5px; margin-bottom: 12px;
}
.form-result { margin: 0; min-height: 16px; font-size: 11.5px; color: var(--muted); }
.form-result.success { color: var(--pass-fg); }
.form-result.error { color: var(--rej-fg); }
.hidden { display: none !important; }

#toast-root { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 40; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r-panel);
  padding: 10px 13px; font-size: 11.5px; box-shadow: 0 12px 34px rgba(0, 0, 0, .45);
}
.skeleton {
  height: 66px; border-radius: var(--r-panel);
  background: linear-gradient(90deg, var(--panel), var(--panel-3), var(--panel));
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 900px) {
  .topbar { padding: 0 12px; }
  .shell { padding: 14px 12px 40px; }
}
