/*
  The console's whole stylesheet.

  The rules it is written to:
  - One neutral ramp, one accent, four status colours. Colour is only ever
    used to mean something: a verdict, a state, a link, the focused control.
  - Hairlines and space do the separating. No shadows on content, no
    gradients, no decoration.
  - One type family, four sizes. Numbers that line up in a column are
    tabular; identifiers are monospace.
  - Dense where people scan (tables), generous where they decide (a case).
*/

:root {
  color-scheme: light;

  --surface: #ffffff;
  --plane: #f9f9f9;
  --raised: #ffffff;
  --hover: #f4f4f4;
  --selected: #eef4fd;

  --line: #e7e7e7;
  --line-strong: #d0d0d0;

  --ink: #191919;
  --ink-2: #5f5f5f;
  --ink-3: #8a8a8a;

  --accent: #1d6fd0;
  --accent-wash: #eef4fd;
  --series: #257de0;
  --series-quiet: #cfe2f9;

  --good: #0aac23;
  --warning: #fbb315;
  --serious: #f18a59;
  --critical: #dc3c3d;

  --good-ink: #00630f;      --good-wash: #e8f6ea;
  --warning-ink: #7a5200;   --warning-wash: #fff4d9;
  --serious-ink: #99441a;   --serious-wash: #fdeee6;
  --critical-ink: #b3261e;  --critical-wash: #fdeceb;
  --neutral-wash: #f0f0f0;

  --button: #191919;
  --button-ink: #ffffff;

  --radius: 6px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --surface: #191919;
    --plane: #121212;
    --raised: #212121;
    --hover: #232323;
    --selected: #1c2a3d;

    --line: #303030;
    --line-strong: #474747;

    --ink: #efefef;
    --ink-2: #a8a8a8;
    --ink-3: #7c7c7c;

    --accent: #6aabf1;
    --accent-wash: #1c2a3d;
    --series: #338ced;
    --series-quiet: #1f3a5c;

    --good-ink: #6fd57c;      --good-wash: #15301a;
    --warning-ink: #f5c558;   --warning-wash: #3a2e10;
    --serious-ink: #f3a57f;   --serious-wash: #3b2318;
    --critical-ink: #f08a8a;  --critical-wash: #3d1c1c;
    --neutral-wash: #2a2a2a;

    --button: #efefef;
    --button-ink: #191919;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, dl, dd, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Shell ------------------------------------------------------------------ */

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--plane);
  border-right: 1px solid var(--line);
  padding: 20px 12px 14px;
}

.brand { display: flex; align-items: baseline; gap: 8px; padding: 0 8px 18px; }
.brand b { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.brand span { font-size: 12px; color: var(--ink-3); }

.switcher { padding: 0 4px 16px; }
.switcher label { display: block; font-size: 12px; color: var(--ink-3); padding: 0 4px 4px; }
.switcher select { width: 100%; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius);
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.nav .count {
  min-width: 20px; padding: 0 6px; border-radius: 10px; text-align: center;
  background: var(--neutral-wash); color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums;
}
.nav .count.hot { background: var(--critical-wash); color: var(--critical-ink); }
.nav-label { font-size: 12px; color: var(--ink-3); padding: 16px 8px 4px; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.side-foot .who { color: var(--ink-2); }
.health { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.good { background: var(--good); }
.dot.warning { background: var(--warning); }
.dot.serious { background: var(--serious); }
.dot.critical { background: var(--critical); }

.main { min-width: 0; }
.page { max-width: 1160px; padding: 28px 40px 64px; }

.notice {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 40px; font-size: 13px;
  border-bottom: 1px solid var(--line);
  background: var(--plane); color: var(--ink-2);
}
.notice b { color: var(--ink); font-weight: 600; }
.notice.warning { background: var(--warning-wash); color: var(--warning-ink); border-bottom-color: transparent; }
.notice.warning b { color: inherit; }

/* Page head -------------------------------------------------------------- */

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.head h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.25; }
.head .sub { color: var(--ink-2); margin-top: 2px; }
.crumb { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.crumb a { color: var(--ink-2); }

.section { margin-top: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 15px; font-weight: 600; }
.section-head .aside { font-size: 13px; color: var(--ink-2); }

.cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 48px; }
.cols.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

/* Controls --------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--button); border-color: var(--button); color: var(--button-ink); }
.btn.primary:hover { opacity: 0.88; }
.btn.danger { color: var(--critical-ink); }
.btn.danger.solid { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn.quiet { border-color: transparent; background: none; color: var(--ink-2); padding: 0 8px; }
.btn.quiet:hover { background: var(--hover); color: var(--ink); }
.btn.small { height: 26px; padding: 0 8px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="search"], select, textarea {
  height: 32px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface);
}
textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 72px; width: 100%; line-height: 1.45; }
select { padding-right: 26px; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13px; font-weight: 500; }
.field > small { font-size: 12.5px; color: var(--ink-2); }
.field input, .field select { width: 100%; }
.form { display: flex; flex-direction: column; gap: 16px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters input[type="search"] { width: 200px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { height: 30px; padding: 0 12px; border: 0; border-left: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; font-weight: 500; }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--hover); }
.seg button[aria-pressed="true"] { background: var(--neutral-wash); color: var(--ink); }

.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 0; }
.tabs button {
  padding: 8px 0 9px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--ink-2); font-weight: 500; cursor: pointer;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs .count { color: var(--ink-3); font-weight: 400; margin-left: 6px; font-variant-numeric: tabular-nums; }

/* Badges ----------------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 7px; border-radius: 4px;
  font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap;
  background: var(--neutral-wash); color: var(--ink-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.block, .badge.critical { background: var(--critical-wash); color: var(--critical-ink); }
.badge.challenge, .badge.serious { background: var(--serious-wash); color: var(--serious-ink); }
.badge.review, .badge.warning { background: var(--warning-wash); color: var(--warning-ink); }
.badge.allow, .badge.good { background: var(--good-wash); color: var(--good-ink); }

.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: 4px; background: var(--neutral-wash); color: var(--ink-2); white-space: nowrap; }
.chip.more { font-family: var(--sans); background: none; padding-left: 2px; }

/* Tables ----------------------------------------------------------------- */

.table-wrap { border-top: 1px solid var(--line); }
.table th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-2);
  padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
.table th.r, .table td.r { text-align: right; }
.table th.r + th:not(.r), .table td.r + td:not(.r) { padding-left: 28px; }
.table th:last-child, .table td:last-child { padding-right: 4px; }
.table tbody tr.link { cursor: pointer; }
.table tbody tr.link:hover td { background: var(--hover); }
.table tbody tr[aria-selected="true"] td { background: var(--selected); }
.table td:first-child, .table th:first-child { padding-left: 4px; }
.table .primary { color: var(--ink); font-weight: 500; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; font-size: 13px; color: var(--ink-2); }
.pager div { display: flex; gap: 8px; }

/* Inline bar inside a table cell: one hue, thin, value beside it. */
.bar { display: flex; align-items: center; gap: 10px; }
.bar i { display: block; height: 6px; border-radius: 3px; background: var(--series); min-width: 2px; }
.bar .track { flex: 1; min-width: 60px; }

/* Stats ------------------------------------------------------------------ */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stat {
  display: block; text-align: left; padding: 14px 16px 12px;
  border: 0; border-left: 1px solid var(--line); background: var(--surface); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.stat:first-child { border-left: 0; }
.stat:hover { background: var(--hover); }
.stat[aria-pressed="true"] { border-bottom-color: var(--ink); }
.stat .label { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.stat .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin-top: 4px; }
.stat .note { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }

/* Charts ----------------------------------------------------------------- */

.chart { position: relative; margin-top: 20px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .tick { fill: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .col { fill: var(--series); }
.chart .hit { fill: transparent; }
.chart .hit:hover + .col, .chart .col.on { fill: var(--accent); }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.chart-head h2 { font-size: 15px; font-weight: 600; }

.tip {
  position: absolute; z-index: 5; pointer-events: none;
  padding: 6px 9px; border-radius: var(--radius);
  background: var(--ink); color: var(--surface);
  font-size: 12.5px; line-height: 1.35; white-space: nowrap;
  transform: translate(-50%, -100%);
}
.tip b { display: block; font-size: 14px; font-weight: 600; }

.mix { display: flex; gap: 2px; height: 8px; margin: 4px 0 14px; }
.mix i { display: block; height: 100%; border-radius: 4px; min-width: 3px; }
.mix .block, .key.block { background: var(--critical); }
.mix .challenge, .key.challenge { background: var(--serious); }
.mix .review, .key.review { background: var(--warning); }
.mix .allow, .key.allow { background: var(--good); }
.legend { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 7px 16px; font-size: 13px; align-items: center; }
.legend .name { display: flex; align-items: center; gap: 8px; }
.key { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .v { text-align: right; font-variant-numeric: tabular-nums; }
.legend .p { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* The score against the thresholds it was judged by. */
.scale { position: relative; height: 56px; margin: 6px 0 2px; }
.scale .rail { position: absolute; left: 0; right: 0; top: 22px; height: 6px; border-radius: 3px; background: var(--neutral-wash); overflow: hidden; }
.scale .rail i { position: absolute; top: 0; bottom: 0; }
.scale .rail .zone-review { background: var(--warning-wash); }
.scale .rail .zone-block { background: var(--critical-wash); }
.scale .mark { position: absolute; top: 14px; width: 1px; height: 22px; background: var(--line-strong); }
.scale .mark span { position: absolute; top: 24px; left: 0; transform: translateX(-50%); font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.scale .pin { position: absolute; top: 17px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; border: 3px solid var(--surface); background: var(--ink); }
.scale .pin.block { background: var(--critical); }
.scale .pin.challenge { background: var(--serious); }
.scale .pin.review { background: var(--warning); }
.scale .pin.allow { background: var(--good); }
.scale .pin b { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Detail ----------------------------------------------------------------- */

.facts { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 7px 16px; font-size: 13px; }
.facts dt { color: var(--ink-2); }
.facts dd { min-width: 0; overflow-wrap: anywhere; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; align-items: start; }
.rail-box { border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.rail-box + .rail-box { margin-top: 16px; }
.rail-box h2 { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.rail-box .stack { display: flex; flex-direction: column; gap: 8px; }

.verdict-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.verdict-line h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.015em; }

.section-note { margin-top: 10px; font-size: 13px; }
details > summary { cursor: pointer; font-size: 13px; width: fit-content; }
details[open] > summary { margin-bottom: 10px; }

.callout { padding: 10px 12px; border-radius: var(--radius); background: var(--plane); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.callout b { color: var(--ink); font-weight: 600; }
.callout.warning { background: var(--warning-wash); border-color: transparent; color: var(--warning-ink); }
.callout.warning b { color: inherit; }
.callout.critical { background: var(--critical-wash); border-color: transparent; color: var(--critical-ink); }
.callout.critical b { color: inherit; }

.secret { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--plane); }
.secret code { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }

/* Review queue: list and the case beside it. */
.queue { display: grid; grid-template-columns: 380px minmax(0, 1fr); border-top: 1px solid var(--line); align-items: start; }
/* The list keeps its place and scrolls by itself while the case beside it is read. */
.queue-list { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; border-right: 1px solid var(--line); min-width: 0; }
.queue-item { display: block; width: 100%; text-align: left; padding: 12px 16px 12px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; }
.queue-item:hover { background: var(--hover); }
.queue-item[aria-current="true"] { background: var(--selected); }
.queue-item .top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.queue-item .who { font-weight: 600; font-family: var(--mono); font-size: 12.5px; }
.queue-item .meta { display: flex; gap: 12px; align-items: center; margin-top: 6px; font-size: 12.5px; color: var(--ink-2); flex-wrap: wrap; }
.queue-detail { padding: 20px 0 0 32px; min-width: 0; }
.queue-detail .cols { grid-template-columns: minmax(0, 1fr); gap: 28px; }
.queue-detail .head { margin-bottom: 16px; }
.queue-detail h2 { font-size: 16px; font-weight: 600; }

.empty { padding: 56px 24px; text-align: center; color: var(--ink-2); }
.empty h2 { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.empty p { max-width: 420px; margin: 0 auto; }
.empty .btn { margin-top: 14px; }
.empty.inline { padding: 4px 0 0; text-align: left; }
.empty.inline h2 { font-size: 14px; }
.empty.inline p { margin: 0; max-width: 560px; }

.loading { padding: 40px 0; color: var(--ink-3); }
.stale { opacity: 0.55; transition: opacity 0.15s; }

/* Dialog and toast ------------------------------------------------------- */

dialog {
  width: min(460px, calc(100vw - 32px)); padding: 0;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--raised); color: var(--ink);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.32); }
dialog .dialog-body { padding: 20px 20px 4px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { font-size: 16px; font-weight: 600; }
dialog .dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 20px; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast { padding: 9px 12px; border-radius: var(--radius); background: var(--ink); color: var(--surface); font-size: 13px; max-width: 360px; }
.toast.error { background: var(--critical); color: #fff; }

/* Sign in ---------------------------------------------------------------- */

.gate { min-height: 100vh; display: grid; place-items: center; background: var(--plane); padding: 24px; }
.gate-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.gate-card .brand { padding: 0 0 20px; }
.gate-card h1 { font-size: 18px; font-weight: 650; margin-bottom: 4px; }
.gate-card .sub { color: var(--ink-2); margin-bottom: 20px; }
.gate-card .btn { width: 100%; height: 36px; }
.gate-foot { margin-top: 16px; font-size: 13px; color: var(--ink-2); text-align: center; }
.error-text { color: var(--critical-ink); font-size: 13px; }

/* Narrow screens --------------------------------------------------------- */

@media (max-width: 980px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; }
  .side .nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin-top: 12px; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .nav-label { display: none; }
  .page { padding: 20px 16px 48px; }
  .notice { padding: 8px 16px; }
  .cols, .cols.even, .split { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .queue { grid-template-columns: minmax(0, 1fr); }
  .queue-list { position: static; max-height: 320px; border-right: 0; border-bottom: 1px solid var(--line); }
  .queue-detail { padding: 20px 0 0; }
  .table-wrap { overflow-x: auto; }
  .facts { grid-template-columns: 112px minmax(0, 1fr); }
}

/* Form pieces used in dialogs. */
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field legend { font-size: 13px; font-weight: 500; padding: 0; margin-bottom: 2px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 2px 0; cursor: pointer; }
.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.events { max-height: 250px; overflow: auto; }
