/* Modern Lab dashboard. Colours follow the validated reference palette
   (dataviz skill): blue sequential, 4 categorical slots, blue/red diverging. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --border: rgba(11, 11, 11, 0.10);
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --accent: #2a78d6;
  --accent-soft: #dce9f9;
  --seq: #2a78d6;
  --seq-track: #e6eefa;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --pos: #2a78d6; --neg: #e34948; --mid: #f0efec;
  --good-text: #006300;
  --warn-bg: #fdf0d5; --warn-text: #7a5200;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --border: rgba(255, 255, 255, 0.10);
    --grid: #2c2c2a; --axis: #383835;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #898781;
    --accent: #3987e5; --accent-soft: #1d3554; --seq: #3987e5; --seq-track: #22303f;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --pos: #3987e5; --neg: #e66767; --mid: #383835;
    --good-text: #0ca30c; --warn-bg: #3a2c0c; --warn-text: #f0c46a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --border: rgba(255, 255, 255, 0.10);
  --grid: #2c2c2a; --axis: #383835;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #898781;
  --accent: #3987e5; --accent-soft: #1d3554; --seq: #3987e5; --seq-track: #22303f;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --pos: #3987e5; --neg: #e66767; --mid: #383835;
  --good-text: #0ca30c; --warn-bg: #3a2c0c; --warn-text: #f0c46a;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body { margin: 0; background: var(--page); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.top { background: var(--surface); border-bottom: 1px solid var(--border); }
header.top .inner { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center;
  gap: 24px; min-height: 52px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.brand span { color: var(--text-muted); font-weight: 500; }
nav.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
nav.tabs a { color: var(--text-secondary); padding: 15px 10px 13px; border-bottom: 2px solid transparent; }
nav.tabs a:hover { color: var(--text-primary); text-decoration: none; }
nav.tabs a[aria-current="page"] { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }
nav.tabs .lock { font-size: 11px; color: var(--text-muted); margin-left: 3px; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 4px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.sub { color: var(--text-secondary); margin: 0 0 16px; }
.hint { color: var(--text-muted); font-size: 12px; margin: 0 0 12px; }
.note { color: var(--text-muted); font-size: 12px; margin: 10px 0 0; }

.filters { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin: 0 0 18px; }
.filters .lbl { color: var(--text-secondary); font-size: 13px; margin-right: 6px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; color: var(--text-secondary); padding: 6px 10px; font: inherit; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text-primary); font-weight: 600; }
.seg button:focus-visible, select:focus-visible, th button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 18px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.grid2 > .card { margin-bottom: 0; }
.stack { display: grid; gap: 18px; margin-bottom: 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile .k { color: var(--text-secondary); font-size: 12px; }
.tile .v { font-size: 24px; font-weight: 600; margin-top: 2px; }
.tile .d { color: var(--text-muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; vertical-align: middle; }
td { font-variant-numeric: tabular-nums; }
th { color: var(--text-muted); font-weight: 500; font-size: 12px; }
th button { all: unset; cursor: pointer; }
th button::after { content: ""; margin-left: 4px; }
th[aria-sort="descending"] button::after { content: "↓"; }
th[aria-sort="ascending"] button::after { content: "↑"; }
th.l, td.l { text-align: left; }
td.name { font-weight: 500; }
td.wrap { white-space: normal; }
td.muted, span.muted { color: var(--text-muted); }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover, tbody tr.sel { background: var(--accent-soft); }
.sig { color: var(--text-muted); font-size: 12px; white-space: normal; text-align: left; min-width: 180px; }

.low, .badge { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 6px; font-weight: 500; vertical-align: 1px; }
.low { background: var(--warn-bg); color: var(--warn-text); margin-left: 6px; }
.badge { border: 1px solid var(--border); color: var(--text-secondary); }
.badge.core { background: var(--accent-soft); color: var(--text-primary); border-color: transparent; }
.flag { color: var(--warn-text); font-size: 12px; }

/* Horizontal bar inside a table cell: thin, 4px rounded data end, square at the baseline. */
.bar { position: relative; height: 10px; min-width: 120px; background: var(--seq-track); border-radius: 0 4px 4px 0; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--seq); border-radius: 0 4px 4px 0; }
td.barcell { width: 32%; min-width: 140px; }

/* Interval plot: a 0-100% track, a 50% reference, the 95% interval and the point. */
.ci { position: relative; height: 18px; min-width: 200px; }
.ci .track { position: absolute; left: 0; right: 0; top: 8px; height: 1px; background: var(--grid); }
.ci .ref { position: absolute; left: 50%; top: 2px; bottom: 2px; width: 1px; background: var(--axis); }
.ci .rng { position: absolute; top: 7px; height: 4px; border-radius: 2px; opacity: 0.35; }
.ci .pt { position: absolute; top: 4px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface); }
.ci .fld { position: absolute; top: 2px; width: 2px; height: 14px; margin-left: -1px; background: var(--text-secondary); }
.ci-scale { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 11px; min-width: 200px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-secondary); font-size: 12px; margin: 4px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .key { width: 14px; height: 2px; border-radius: 1px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; }
.legend .tick { width: 2px; height: 12px; background: var(--text-secondary); }

svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
svg.chart .gridline { stroke: var(--grid); stroke-width: 1; }
svg.chart .baseline { stroke: var(--axis); stroke-width: 1; }
svg.chart text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.chart text.end { fill: var(--text-secondary); font-size: 12px; }
svg.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .cross { stroke: var(--axis); stroke-width: 1; }
svg.chart circle.enddot { stroke: var(--surface); stroke-width: 2; }

svg.spark { display: block; }
svg.spark rect { fill: var(--seq-track); }
svg.spark rect.on { fill: var(--seq); }

/* Matchup matrix */
table.matrix { width: auto; }
table.matrix th, table.matrix td { padding: 0; border: 0; }
table.matrix td.cell { width: 52px; height: 34px; text-align: center; font-size: 12px; border: 2px solid var(--surface); border-radius: 4px; }
table.matrix td.diag { background: transparent; color: var(--text-muted); }
table.matrix td.cell.lown { font-style: italic; }
table.matrix th.row { text-align: right; padding-right: 8px; white-space: nowrap; font-size: 12px; color: var(--text-secondary); font-weight: 500; }
table.matrix th.col { height: 120px; vertical-align: bottom; padding-bottom: 6px; }
table.matrix th.col div { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-size: 12px; color: var(--text-secondary); font-weight: 500; margin: 0 auto; }
table.matrix tr.hl th.row { color: var(--text-primary); font-weight: 700; }
.gradient { height: 10px; width: 220px; border-radius: 2px;
  background: linear-gradient(90deg, var(--neg), var(--mid), var(--pos)); }
.gradient-scale { display: flex; justify-content: space-between; width: 220px; color: var(--text-muted); font-size: 11px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; font-size: 13px; background: var(--page); }
.chip b { font-variant-numeric: tabular-nums; margin-right: 4px; }
.plan-row { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: start; margin: 6px 0; }
.plan-row .k { color: var(--text-muted); font-size: 12px; padding-top: 3px; }
.cols75 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.cols75 ul { list-style: none; padding: 0; margin: 0; columns: 1; }
.cols75 li { padding: 2px 0; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
.cols75 li b { display: inline-block; width: 22px; }
.cols75 li.chg { background: var(--accent-soft); }

#tip { position: fixed; z-index: 10; pointer-events: none; background: var(--surface); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.12);
  max-width: 280px; display: none; }
#tip .v { font-weight: 600; font-size: 13px; }
#tip .r { display: flex; align-items: center; gap: 6px; }
#tip .r i { width: 12px; height: 2px; display: inline-block; }
#tip .m { color: var(--text-secondary); }

footer { max-width: 1180px; margin: 0 auto; padding: 0 16px 32px; color: var(--text-muted); font-size: 12px; }
.private { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 8px 12px; margin: 0 0 16px; font-size: 13px; }

@media (max-width: 640px) {
  header.top .inner { gap: 4px 16px; padding-top: 8px; }
  nav.tabs a { padding: 8px 8px 10px; }
  .tile .v { font-size: 20px; }
}
@media (forced-colors: active) {
  .bar i, .ci .pt, .ci .rng { forced-color-adjust: none; }
}
