:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --hover: rgba(11, 11, 11, 0.035);
  --selected: rgba(42, 120, 214, 0.08);
  --quality: #2a78d6;
  --delivery: #eb6834;
  --leverage: #1baf7a;
  --track: #cde2fb;
  --critical: #d03b3b;
  --serious: #ec835a;
  --good: #0ca30c;
  --good-text: #006300;
  --link: #1c5cab;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --hover: rgba(255, 255, 255, 0.04);
    --selected: rgba(57, 135, 229, 0.14);
    --quality: #3987e5;
    --delivery: #d95926;
    --leverage: #199e70;
    --track: #184f95;
    --good-text: #0ca30c;
    --link: #86b6ef;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --hover: rgba(255, 255, 255, 0.04);
  --selected: rgba(57, 135, 229, 0.14);
  --quality: #3987e5;
  --delivery: #d95926;
  --leverage: #199e70;
  --track: #184f95;
  --good-text: #0ca30c;
  --link: #86b6ef;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0 16px;
  background: var(--page);
  color: var(--ink);
  font: 13px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- header */
.top { padding-block: 10px 7px; border-bottom: 1px solid var(--grid); }
.title-row { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
h1 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.window { font-size: 13px; font-weight: 400; color: var(--ink-2); margin-left: 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
  background: var(--surface); color: var(--ink-2); font-size: 12px; white-space: nowrap; cursor: default;
}
.chip b { color: var(--ink); font-weight: 600; }
.def-row { display: flex; align-items: center; gap: 6px 14px; margin-top: 5px; flex-wrap: wrap; }
.actions { margin-left: auto; display: flex; gap: 6px; flex: none; }
.btn {
  font-size: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.definition { margin: 0; flex: 1 1 600px; min-width: 0; color: var(--ink-2); font-size: 12.5px; }
.definition .key { margin: 0 3px 0 0; }
.definition b { color: var(--ink); font-weight: 600; }
.mock-banner { color: var(--critical); font-weight: 600; }

/* ---------------------------------------------------------------- layout */
.grid {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(380px, 36%) minmax(0, 1fr); gap: 12px;
  padding-block: 10px 12px;
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; min-height: 0; }
.left { display: flex; flex-direction: column; padding: 10px 12px; }
.right { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); gap: 10px; padding: 12px 14px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.panel-head h2, .section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.hint { font-size: 11.5px; color: var(--muted); }

.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; flex: none; }

/* ---------------------------------------------------------------- weights (also the legend) */
.weights {
  display: grid; grid-template-columns: max-content minmax(0, 1fr) 34px; align-items: center;
  gap: 0 10px; margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: var(--page); border: 1px solid var(--border);
}
.wlabel { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: help; }
.weights input[type="range"] { width: 100%; margin: 3px 0; accent-color: var(--ink-2); height: 16px; }
.wval { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; }
.weights-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font-size: 11px; }

/* ---------------------------------------------------------------- ranking */
.top5, .rest { list-style: none; margin: 0; padding: 0; }
.top5 { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.card {
  width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 8px;
  padding: 6px 8px; cursor: pointer;
  display: grid; grid-template-columns: 14px 34px minmax(0, 1fr) auto; column-gap: 9px; row-gap: 3px; align-items: center;
}
.card:hover { background: var(--hover); }
.card[aria-current="true"] { background: var(--selected); border-color: var(--border); }
.card .rank { grid-column: 1; grid-row: 1 / span 3; color: var(--muted); font-weight: 600; text-align: center; }
.card .avatar { grid-column: 2; grid-row: 1 / span 3; width: 34px; height: 34px; border-radius: 50%; background: var(--grid); }
.card .who { grid-column: 3; grid-row: 1; }
.who { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.who .name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .login { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.card .score { grid-column: 4; grid-row: 1 / span 3; font-size: 24px; font-weight: 650; text-align: right; line-height: 1; }
.card .score small { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.stack { display: flex; gap: 2px; height: 10px; }
.card .stack { grid-column: 3; grid-row: 2; }
.stack .seg { height: 100%; min-width: 2px; }
.stack .seg:last-child { border-radius: 0 4px 4px 0; }
.card .facts { grid-column: 3; grid-row: 3; font-size: 11.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cutoff { position: relative; margin: 6px 0 4px; height: 12px; }
.cutoff::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; border-top: 1px solid var(--baseline); }
.cutoff span { position: relative; background: var(--surface); padding-right: 6px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.rest { overflow: auto; min-height: 0; flex: 1; }
.row {
  width: 100%; background: none; border: 1px solid transparent; border-radius: 6px; padding: 2px 8px; cursor: pointer; text-align: left;
  display: grid; grid-template-columns: 14px minmax(0, 150px) minmax(0, 1fr) 30px; gap: 9px; align-items: center; font-size: 12px;
}
.row:hover { background: var(--hover); }
.row[aria-current="true"] { background: var(--selected); border-color: var(--border); }
.row .rank { color: var(--muted); text-align: center; }
.row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .stack { grid-column: auto; height: 6px; }
.row .score { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- detail */
.ident { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.ident .avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--grid); }
.ident h2 { font-size: 18px; font-weight: 650; }
.ident h2 .login { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.ident .headline { margin: 2px 0 6px; color: var(--ink-2); }
.hero { text-align: right; }
.hero .num { font-size: 48px; font-weight: 650; line-height: 0.95; letter-spacing: -0.02em; }
.hero .cap { font-size: 11px; color: var(--muted); }
.comp-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.comp {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 8px; font-size: 12px; background: var(--page); cursor: help; white-space: nowrap;
}
.comp b { font-weight: 650; font-size: 13px; }
.comp .sub { color: var(--ink-2); }
.verify { font-size: 11.5px; color: var(--muted); margin-left: 4px; white-space: nowrap; }
.flags { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.mid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; }
.rubric { display: grid; grid-template-columns: 104px minmax(0, 1fr) 50px 72px; gap: 0 8px; align-items: center; margin-top: 4px; }
.rubric .dim { font-size: 12px; font-weight: 600; white-space: nowrap; }
.rubric .dim span { color: var(--muted); font-weight: 600; margin-right: 4px; }
.meter { position: relative; height: 10px; background: var(--track); border-radius: 0 4px 4px 0; cursor: help; }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--quality); border-radius: 0 4px 4px 0; }
.meter .tick { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--ink); border-radius: 1px; opacity: 0.75; }
.rubric .val { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rubric .val b { font-weight: 650; }
.src { font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; text-align: center; white-space: nowrap; }
.because { grid-column: 1 / -1; padding-left: 13px; font-size: 11.5px; color: var(--ink-2); margin: 1px 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.rubric-legend { font-size: 11px; color: var(--muted); display: flex; gap: 10px; align-items: center; margin-top: 2px; }
.rubric-legend i { display: inline-block; width: 2px; height: 11px; background: var(--ink); opacity: 0.75; vertical-align: -1px; margin-right: 4px; }

.feedback { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fb { border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; background: var(--page); }
.fb h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 2px; }
.fb h3 .icon { margin-right: 4px; }
.fb p { margin: 0; }
.fb .pr { font-size: 11.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta-line { font-size: 11.5px; color: var(--ink-2); }
.tag { display: inline-block; border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; margin: 0 3px 2px 0; font-size: 11px; color: var(--ink-2); background: var(--surface); }

/* ---------------------------------------------------------------- evidence */
.evidence { display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--grid); align-items: flex-end; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 4px 8px 5px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.tabs .tab-note { margin-left: auto; font-size: 11px; color: var(--muted); padding-bottom: 5px; }
.table-wrap { overflow: auto; min-height: 0; flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 600; color: var(--muted);
  font-size: 11px; padding: 5px 6px; border-bottom: 1px solid var(--grid); white-space: nowrap;
}
td { padding: 5px 6px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .t { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
table.fixed { table-layout: fixed; }
table.fixed td .t { max-width: 100%; }
table.ai th:nth-child(1) { width: 34%; }
table.ai th:nth-child(2) { width: 37%; }
table.ai th:nth-child(3) { width: 7%; }
table.ai th:nth-child(4), table.ai th:nth-child(5) { width: 5%; }
table.ai th:nth-child(6) { width: 12%; }
table.top th:nth-child(1) { width: 40%; }
table.inc th:nth-child(1) { width: 50%; }
td .s { display: block; color: var(--muted); font-size: 11px; }
tr.expandable { cursor: pointer; }
tr.expandable:hover td { background: var(--hover); }
tr.expandable td:first-child::before { content: "▸"; color: var(--muted); display: inline-block; width: 12px; }
tr.expandable.open td:first-child::before { content: "▾"; }
tr.details td { background: var(--page); padding: 8px 10px 10px 24px; }
.details-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; }
.details-grid h4 { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.04em; }
.details-grid ul { margin: 0; padding-left: 16px; }
.details-grid li { margin-bottom: 2px; }
.ba { color: var(--ink-2); }
.ba b { color: var(--ink); font-weight: 600; }
.status { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; }
.status.critical { color: var(--critical); }
.status.serious { color: var(--ink-2); }
.status.serious .icon { color: var(--serious); }
.status.good { color: var(--good-text); }
.empty { color: var(--muted); padding: 12px 6px; }

/* ---------------------------------------------------------------- drawer + tooltip */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.25); z-index: 30; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); z-index: 31; overflow: auto;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -12px 0 32px rgba(0, 0, 0, 0.12);
  padding: 18px 22px 28px; font-size: 13px;
}
.drawer h2 { font-size: 17px; margin-bottom: 4px; }
.drawer h3 { font-size: 13px; margin: 16px 0 4px; }
.drawer p, .drawer li { color: var(--ink-2); }
.drawer ul, .drawer ol { padding-left: 18px; margin: 4px 0; }
.drawer table { margin: 4px 0; }
.drawer td, .drawer th { position: static; }
.drawer code { font-size: 12px; background: var(--page); border: 1px solid var(--border); border-radius: 4px; padding: 0 3px; }
.drawer .close { position: sticky; top: 0; float: right; }
.funnel { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; }
.funnel div { display: grid; grid-template-columns: 90px 1fr; gap: 8px; align-items: baseline; }
.funnel b { text-align: right; font-variant-numeric: tabular-nums; }

.tip {
  position: fixed; z-index: 50; max-width: 340px; pointer-events: none; white-space: pre-line;
  background: var(--ink); color: var(--surface); padding: 6px 9px; border-radius: 6px; font-size: 12px; line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

/* ---------------------------------------------------------------- one screen on laptops, stacked elsewhere */
@media (min-width: 1100px) and (min-height: 640px) {
  html, body { height: 100%; }
  body { height: 100vh; overflow: hidden; }
}
@media (max-width: 1099px), (max-height: 639px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .rest { overflow: visible; }
  .table-wrap { max-height: 70vh; }
}
@media (max-width: 720px) {
  .mid { grid-template-columns: minmax(0, 1fr); }
  .ident { grid-template-columns: 44px minmax(0, 1fr); }
  .hero { grid-column: 1 / -1; text-align: left; }
  .details-grid { grid-template-columns: minmax(0, 1fr); }
  .actions { margin-left: 0; }
}
