/* Locus — dark mission-control surface.
 *
 * The console commits deliberately to one look, so only the dark column of the
 * reference palette appears here. Every value is a documented palette hex; the
 * two data encodings were validated with the palette script rather than by eye:
 *   diverging blue/red + neutral (AlphaMissense class) — CVD dE 19.2
 *   ordinal one-hue blue ramp   (structural evidence)  — monotone L, 3.23:1
 */

:root {
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #202020;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);

  --series-1: #3987e5;

  /* diverging: AlphaMissense class */
  --am-benign: #3987e5;
  --am-amb: #383835;
  --am-path: #e66767;
  --no-data: #2c2c2a;

  /* ordinal: structural evidence, brightest = strongest */
  --tier-exp: #cde2fb;
  --tier-conf: #6da7ec;
  --tier-weak: #256abf;

  /* status (fixed scale, never themed) */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── chrome ─────────────────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.25rem; height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 600; letter-spacing: 0.16em; font-size: 0.78rem; }
.brand span { color: var(--muted); font-weight: 400; letter-spacing: 0.06em;
              margin-left: 0.6rem; }

.seg { display: flex; border: 1px solid var(--border); border-radius: 5px;
       overflow: hidden; }
.seg button {
  background: transparent; color: var(--ink-2); border: 0;
  border-right: 1px solid var(--border);
  padding: 0.35rem 0.8rem; font: inherit; font-size: 0.8rem;
  cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--series-1); color: #fff; }

.spacer { flex: 1; }
.stamp { color: var(--muted); font-size: 0.7rem; }
.manual-link {
  color: var(--ink-2); font-size: 0.8rem; text-decoration: none;
  border: 1px solid var(--border); border-radius: 5px;
  padding: 0.32rem 0.75rem; margin-right: 1.1rem;
}
.manual-link:hover { background: var(--surface-2); color: var(--ink);
                     text-decoration: none; }

main { padding: 1rem 1.25rem 3rem; }
.view[hidden] { display: none; }

.eyebrow {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); margin: 1.1rem 0 0.4rem;
}
h1 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.sub { color: var(--ink-2); font-size: 0.85rem; }

/* ── KPI strip ──────────────────────────────────────────────────────── */

.kpi { display: flex; border: 1px solid var(--border); border-radius: 6px;
       background: var(--surface); overflow: hidden; margin-top: 0.6rem; }
.kpi > div { flex: 1; padding: 0.7rem 1rem; border-right: 1px solid var(--border); }
.kpi > div:last-child { border-right: 0; }
.kpi .v { font-size: 1.5rem; font-weight: 600; line-height: 1.15; }
.kpi .k { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em;
          color: var(--muted); }

/* ── filters ────────────────────────────────────────────────────────── */

.filters {
  display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap;
  padding: 0.6rem 0.85rem; margin-top: 0.75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.filters label { font-size: 0.72rem; color: var(--muted); margin-right: 0.3rem; }
select, input[type="text"] {
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 0.3rem 0.5rem; font: inherit; font-size: 0.8rem;
}
input[type="text"] { min-width: 150px; }
input[type="range"] { accent-color: var(--series-1); vertical-align: middle; }
.chk { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem;
       color: var(--ink-2); cursor: pointer; }

/* ── split view ─────────────────────────────────────────────────────── */

.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
         gap: 0.9rem; margin-top: 0.75rem; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--border);
         border-radius: 6px; overflow: hidden; }
.panel-h { padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--border);
           font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em;
           color: var(--muted); display: flex; justify-content: space-between; }

/* ── dense linked-record table ──────────────────────────────────────── */

.tablewrap { max-height: 430px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.79rem; }
thead th {
  position: sticky; top: 0; background: var(--surface-2); z-index: 2;
  text-align: left; font-weight: 500; color: var(--muted);
  padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
/* Row height is fixed and must stay in sync with ROW_H in app.js: the
   virtualiser computes scroll offsets from it, so a row that is taller than
   declared makes the scrollbar lie. */
tbody td { height: 26px; padding: 0 0.6rem; line-height: 25px;
           border-bottom: 1px solid var(--grid); white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr[aria-selected="true"] { background: #16304f; }
tbody tr.spacer, tbody tr.spacer td { padding: 0; border: 0; height: auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.dim { color: var(--muted); }

/* Identity travels on a mark, not on the text. Two series colours measure
   below 4.5:1 against this surface as small text (critical 3.62,
   tier-weak 3.23), so the label stays in ink and the swatch carries the
   colour — which is also what the palette method requires. */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px;
       margin-right: 0.4rem; vertical-align: middle; }

/* ── focus + assistive text ─────────────────────────────────────────── */

:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
tbody tr:focus-visible { outline-offset: -2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 50;
  background: var(--series-1); color: #fff; padding: 0.5rem 0.9rem;
  border-radius: 0 0 4px 0;
}
.skip:focus { left: 0; }

/* A bar is a second, redundant channel for the score already printed beside
   it — never the only way to read the value. */
.bar { display: inline-block; height: 5px; border-radius: 2px;
       background: var(--series-1); vertical-align: middle; margin-right: 0.4rem; }

/* ── detail pane ────────────────────────────────────────────────────── */

.detail { padding: 0.85rem; }
.detail .title { font-size: 1.1rem; font-weight: 600; }
.detail .ident { color: var(--muted); font-size: 0.76rem; margin-bottom: 0.6rem;
                 font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 8.5rem 1fr; gap: 0.28rem 0.7rem;
      font-size: 0.81rem; margin-top: 0.7rem; }
.kv .k { color: var(--muted); }
.kv .v { font-variant-numeric: tabular-nums; }

.chip { display: inline-block; padding: 0.1rem 0.45rem; border-radius: 3px;
        font-size: 0.71rem; font-weight: 600; border: 1px solid;
        margin-right: 0.3rem; }

.legend { display: flex; gap: 0.85rem; flex-wrap: wrap; font-size: 0.71rem;
          color: var(--ink-2); padding: 0.4rem 0.8rem; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px;
            margin-right: 0.35rem; }

.empty { color: var(--muted); font-size: 0.82rem; padding: 1rem 0.9rem; }
/* Table cells are nowrap so columns stay scannable; an empty-state sentence is
   prose and must wrap instead of forcing a horizontal scrollbar. */
tbody td.empty { white-space: normal; line-height: 1.55; max-width: 0; }

/* ── structure ──────────────────────────────────────────────────────── */

/* The claim the 3D exists to make, stated in words above the picture. */
.finding { margin: 0.35rem 0 0; font-size: 0.83rem; color: var(--ink-2);
           line-height: 1.55; max-width: 62rem; }
.finding b { color: var(--ink); }

.mols { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem;
        margin-top: 0.75rem; }
@media (max-width: 1100px) { .mols { grid-template-columns: 1fr; } }
.mol { position: relative; height: 400px; background: var(--surface); }

/* ── dossier ────────────────────────────────────────────────────────── */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
         gap: 0.75rem; margin-top: 0.75rem; }
.card { background: var(--surface); border: 1px solid var(--border);
        border-radius: 6px; padding: 0.8rem 0.9rem; }
.card .k { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em;
           color: var(--muted); }
.card .band { font-size: 1.05rem; font-weight: 600; margin: 0.25rem 0 0.45rem; }
.card .d { font-size: 0.78rem; color: var(--ink-2); line-height: 1.5;
           font-variant-numeric: tabular-nums; }

.archetype { display: flex; align-items: baseline; gap: 0.9rem; flex-wrap: wrap;
             margin-top: 0.5rem; }
.archetype .a { font-size: 1.05rem; font-weight: 600; }

.meter { height: 5px; border-radius: 3px; background: var(--grid);
         overflow: hidden; margin-top: 0.35rem; }
.meter > i { display: block; height: 100%; background: var(--series-1); }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }

a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── governed actions ───────────────────────────────────────────────── */

.actions { padding: 0.8rem 0.9rem; }
.actions .row { display: flex; gap: 0.5rem; align-items: flex-start;
                flex-wrap: wrap; margin-top: 0.55rem; }
.actions .row:has(textarea) { display: block; }
.actions textarea {
  width: 100%; min-height: 56px; resize: vertical;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 0.4rem 0.5rem; font: inherit; font-size: 0.8rem;
}
.btn {
  background: var(--surface-2); color: var(--ink); cursor: pointer;
  border: 1px solid var(--border); border-radius: 4px;
  padding: 0.35rem 0.7rem; font: inherit; font-size: 0.8rem;
}
.btn:hover:not(:disabled) { background: #2a2a29; }
.btn.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn.danger { color: var(--critical); border-color: #d03b3b55; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* A blocked action states its precondition. A disabled control that does not
   say what it wants is not a governed action, just a broken one. */
.blocked { color: var(--warning); font-size: 0.78rem; line-height: 1.5;
           margin-top: 0.4rem; }
.warn { color: var(--warning); font-size: 0.8rem; margin-top: 0.5rem; }

.decision {
  border-left: 2px solid var(--series-1); padding: 0.4rem 0 0.4rem 0.6rem;
  margin-top: 0.55rem; font-size: 0.8rem;
}
.decision.superseded { border-left-color: var(--baseline); opacity: 0.62; }
.decision .meta { color: var(--muted); font-size: 0.73rem;
                  font-variant-numeric: tabular-nums; }
.decision .why { color: var(--ink-2); margin-top: 0.15rem; }

tr.superseded td { opacity: 0.55; }
tr.superseded td:first-child { text-decoration: line-through; }
td.wrap { white-space: normal; max-width: 380px; line-height: 1.5; }
.tag { font-size: 0.68rem; padding: 0.05rem 0.35rem; border-radius: 3px;
       border: 1px solid var(--border); color: var(--muted); }
.tag.stale { color: var(--warning); border-color: #fab21955; }

footer { color: var(--muted); font-size: 0.72rem; padding: 1.5rem 1.25rem 2rem;
         line-height: 1.6; }
