:root {
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --bg: #0a0f1c;
  --panel: #10172a;
  --panel-2: #141d33;
  --line: #222d47;
  --hover: #17213b;
  --selected: #1b2a4d;
  --text: #e5eaf5;
  --muted: #8b96ad;
  --faint: #5d6882;
  --accent: #5aa9ff;
  --ok: #3ddc97;
  --ok-bg: rgba(61, 220, 151, 0.12);
  --bad: #ff6070;
  --bad-bg: rgba(255, 96, 112, 0.12);
  --warn: #ffb547;
  --warn-bg: rgba(255, 181, 71, 0.13);
  --info-bg: rgba(90, 169, 255, 0.12);
  --code-bg: #0c1222;
  --add-bg: rgba(61, 220, 151, 0.13);
  --del-bg: rgba(255, 96, 112, 0.13);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #f7f8fb;
  --line: #e1e6ef;
  --hover: #f1f4fa;
  --selected: #e6efff;
  --text: #172033;
  --muted: #5d6882;
  --faint: #8b96ad;
  --accent: #1667d9;
  --ok: #0f9d63;
  --ok-bg: rgba(15, 157, 99, 0.1);
  --bad: #d33447;
  --bad-bg: rgba(211, 52, 71, 0.09);
  --warn: #b26b00;
  --warn-bg: rgba(178, 107, 0, 0.1);
  --info-bg: rgba(22, 103, 217, 0.08);
  --code-bg: #f7f8fb;
  --add-bg: rgba(15, 157, 99, 0.1);
  --del-bg: rgba(211, 52, 71, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  padding: 0 20px 20px;
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }

/* header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 0 14px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: -0.2px; }
.brand p { margin: 1px 0 0; font-size: 12.5px; }
.pulse { width: 64px; height: 28px; }
.pulse path { fill: none; stroke: var(--ok); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 160; animation: trace 2.6s ease-in-out infinite; }
@keyframes trace { 0% { stroke-dashoffset: 160; } 55%, 100% { stroke-dashoffset: 0; } }
body.running .pulse path { animation-duration: 0.9s; stroke: var(--warn); }

.controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--panel); }
.seg-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--faint); padding: 0 8px 0 6px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--selected); color: var(--text); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.actions { display: inline-flex; gap: 6px; }
.actions button, .icon, .small-btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.actions button:hover, .icon:hover, .small-btn:hover { border-color: var(--accent); }
.actions button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.actions button:disabled { opacity: 0.5; cursor: progress; }
.icon { padding: 6px 10px; }

/* vitals */
.vitals { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.vital { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; min-width: 0; }
.vital .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--faint); }
.vital .v { font: 600 24px/1.2 var(--font); margin-top: 2px; font-variant-numeric: tabular-nums; }
.vital .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vital.ok .v { color: var(--ok); }
.vital.bad .v { color: var(--bad); }
.vital.warn .v { color: var(--warn); }

/* layout */
.split { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(360px, 1fr); gap: 12px; height: 560px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.grid-panel { display: flex; flex-direction: column; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 14px; }
input[type="search"] { background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; min-width: 200px; outline: none; }
input[type="search"]:focus { border-color: var(--accent); }
.grid { flex: 1; min-height: 0; height: 100%; }

/* cell bits */
.pill, .badge, .chip { line-height: 18px; vertical-align: middle; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proof-cell { display: inline-flex; align-items: center; gap: 8px; }
.proof-cell .arrow { color: var(--faint); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 18px; white-space: nowrap; }
.sev-critical { background: var(--bad-bg); color: var(--bad); }
.sev-high { background: var(--warn-bg); color: var(--warn); }
.sev-medium { background: var(--info-bg); color: var(--accent); }
.two { display: flex; flex-direction: column; justify-content: center; line-height: 1.3; height: 100%; }
.two .sub { color: var(--faint); font-size: 12px; font-family: var(--mono); }
.dot { display: inline-flex; align-items: center; gap: 6px; }
.dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.ok::before { background: var(--ok); }
.dot.bad::before { background: var(--bad); }
.dot.warn::before { background: var(--warn); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.4px; }
.chip.verified, .chip.fixed, .chip.static-only { background: var(--ok-bg); color: var(--ok); }
.chip.failed, .chip.rejected { background: var(--bad-bg); color: var(--bad); }
.chip.skipped, .chip.error, .chip.not-run, .chip.no-patch { background: var(--warn-bg); color: var(--warn); }
.badge { display: inline-block; padding: 1px 7px; border: 1px solid var(--line); border-radius: 6px; font-size: 11.5px; color: var(--muted); }
.badge.llm { border-color: var(--accent); color: var(--accent); }
.status-2 { color: var(--ok); }
.status-4, .status-5, .status-0 { color: var(--bad); }

/* detail */
.detail { overflow: auto; padding: 16px 18px; }
.detail .empty { color: var(--muted); padding: 40px 10px; text-align: center; }
.detail h3 { margin: 6px 0 4px; font-size: 17px; line-height: 1.3; }
.detail h4 { margin: 18px 0 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--faint); }
.detail p { margin: 6px 0; }
.detail .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.where { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.code { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; overflow: auto; padding: 6px 0; margin: 0; }
.code .ln { display: block; padding: 0 12px; white-space: pre; }
.code .ln.hit { background: var(--bad-bg); }
.code .n { display: inline-block; width: 34px; color: var(--faint); user-select: none; }
.diff .ln.add { background: var(--add-bg); }
.diff .ln.del { background: var(--del-bg); }
.diff .ln.hunk { color: var(--accent); }
.diff .ln.file { color: var(--muted); font-weight: 600; }
.callout { background: var(--warn-bg); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.proof { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.proof .col { border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-width: 0; }
.proof .col h5 { margin: 0 0 6px; font-size: 13px; display: flex; justify-content: space-between; gap: 6px; }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 16px 1fr; gap: 6px; padding: 4px 0; border-top: 1px dashed var(--line); font-size: 12.5px; }
.checks li:first-child { border-top: 0; }
.checks .mark.ok { color: var(--ok); }
.checks .mark.bad { color: var(--bad); }
.checks .mark.soft { color: var(--warn); }
.checks .d { color: var(--muted); font-size: 12px; word-break: break-word; }
.notes { margin: 6px 0 0; padding-left: 16px; color: var(--muted); font-size: 12px; }
.docs { margin: 0; padding-left: 18px; }
.provenance { color: var(--faint); font-size: 12px; margin-top: 14px; }
.small-btn { padding: 3px 9px; font-size: 12px; }

/* bottom */
.bottom { margin-top: 12px; height: 340px; display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button[role="tab"] { border: 0; background: none; padding: 6px 10px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--selected); color: var(--text); }
.count { color: var(--faint); font-variant-numeric: tabular-nums; margin-left: 2px; }
.tab-tools { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.check { font-size: 12.5px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.tab-body { flex: 1; min-height: 0; overflow: auto; }
.tab-body[hidden] { display: none; }
#log { margin: 0; padding: 10px 14px; white-space: pre-wrap; color: var(--muted); }
#log .step { color: var(--text); font-weight: 600; }
#log .ok { color: var(--ok); }
#log .warn { color: var(--warn); }
#log .error { color: var(--bad); }
#final-list { padding: 10px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.final-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.final-card h5 { margin: 0 0 6px; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--bad); padding: 10px 14px; border-radius: 8px; max-width: 420px; box-shadow: 0 8px 30px rgba(0,0,0,0.35); }

@media (max-width: 1100px) {
  .vitals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; height: auto; }
  .grid-panel { height: 460px; }
  .detail { max-height: 640px; }
}
@media (max-width: 640px) {
  body { padding: 0 12px 12px; }
  .vitals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .proof { grid-template-columns: 1fr; }
  input[type="search"] { min-width: 0; width: 100%; }
  .tab-tools { margin-left: 0; width: 100%; }
}

.diffs { margin-top: 16px; }
.diffs summary { cursor: pointer; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--faint); margin-bottom: 8px; }
.diffs .code + .code { margin-top: 8px; }
.head-tools { display: flex; gap: 8px; align-items: center; }
.notice.recording { background: var(--info-bg); color: var(--text); line-height: 1.5; }
.notice code { font-size: 12px; }
a.small-btn { display: inline-block; color: var(--text); }
.notice { margin: 14px 0 0; padding: 8px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.badge.fixture { border-color: var(--warn); color: var(--warn); }
