:root {
  --font: 'Red Hat Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Red Hat Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --bg: #ffffff; --fg: #1a1a1a;
  --surface: #f4f5f7; --border: #d2d2d2; --header-bg: #eaeaea;
  --accent: #cc0000; --link: #0066cc; --muted: #6a6a6a;
  --pass: #2e7d32; --fail: #c62828; --skip: #757575; --broken: #6a1b9a; --warn: #ef6c00;
}
html[data-theme="dark"] {
  --bg: #16162a; --fg: #e6e6ef;
  --surface: #1e1e2f; --border: #3a3a5c; --header-bg: #252540;
  --accent: #e0a040; --link: #64b5f6; --muted: #9a9ab0;
  --pass: #66bb6a; --fail: #ef5350; --skip: #9e9e9e; --broken: #ba68c8; --warn: #ffa726;
}
* { box-sizing: border-box; }
body { font: 14px/1.45 var(--font); margin: 0; background: var(--bg); color: var(--fg); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: 0.85rem; }
pre { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); padding: .5rem; }

.page-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
  padding: .5rem .75rem;
  background: var(--header-bg);
  border-bottom: 3px solid var(--accent);
}
.page-header h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: .02em; margin: 0; }
.page-header h1 a { color: inherit; }
.page-header nav { display: flex; gap: .15rem; align-items: center; }
.page-header nav a { padding: .15rem .45rem; border-radius: .2rem; }
.page-header nav a:hover { background: var(--surface); }
.page-header nav a.active { font-weight: 700; }
.page-header nav .sep { color: var(--border); user-select: none; }
.page-header .spacer { flex: 1; }
.theme-toggle {
  font: inherit; color: var(--muted); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: .2rem; padding: .15rem .5rem;
}
main { padding: .75rem; }
h2 { font-size: 1rem; margin: 1.25rem 0 .5rem; }

table { border-collapse: collapse; width: 100%; margin: .5rem 0 1rem; }
th, td { text-align: left; padding: .25rem .5rem; border: 1px solid var(--border); font-family: var(--mono); font-size: .82rem; }
thead th {
  background: var(--header-bg); font-weight: 600; white-space: nowrap;
}
tbody tr:hover > td { background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mid { text-align: center; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.small { font-size: .8rem; }

.filters {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: end;
  padding: .5rem .75rem; margin: .5rem 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: .25rem;
}
.filters label { display: flex; flex-direction: column; font-size: .78rem; color: var(--muted); }
.filters input, .filters button {
  font: inherit; padding: .2rem .4rem;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: .2rem;
}
.filters button { background: var(--accent); color: #fff; border-color: var(--accent); cursor: pointer; }

.v-pass { color: var(--pass); } .v-fail { color: var(--fail); font-weight: 600; }
.v-skip { color: var(--skip); } .v-broken { color: var(--broken); font-weight: 600; }
.v-warn { color: var(--warn); }
.delta-good { color: var(--pass); margin-left: .2em; }
.delta-bad { color: var(--fail); margin-left: .2em; }
.delta-zero { color: var(--muted); margin-left: .2em; }
.muted { color: var(--muted); }
.known { border-left: 3px solid var(--pass); padding-left: .5rem; }
.unknown { border-left: 3px solid var(--fail); padding-left: .5rem; }
.tag { font-size: .75rem; border: 1px solid var(--border); border-radius: .5rem; padding: 0 .4rem; }
.badge {
  font-family: var(--mono); font-size: .78rem; font-weight: 600;
  border: 1px solid var(--border); border-radius: .2rem;
  padding: 0 .35rem; background: var(--surface);
}

tr.rerun > td { background: var(--surface); color: var(--muted); }
.distro { margin: 1rem 0; }
.summary-card { margin: 1rem 0; }
.summary-card table { width: 100%; }
.distro-head {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: baseline;
  padding: .35rem .6rem;
  background: var(--header-bg);
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
}
.distro-head h2 { margin: 0; font-size: 1rem; }
.distro-head .counts { color: var(--muted); font-size: .8rem; }
.toggle {
  font-family: var(--mono); cursor: pointer; color: var(--muted);
  border: 1px solid var(--border); border-radius: .2rem; padding: 0 .3rem;
  background: none;
}

table.grid { table-layout: fixed; }
table.grid th { position: relative; cursor: pointer; user-select: none; padding-right: 1.6rem; }
table.grid th[data-sort]::after {
  content: '⇅'; position: absolute; right: .25rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .65rem;
}
table.grid th.asc::after  { content: '▲'; color: var(--fg); }
table.grid th.desc::after { content: '▼'; color: var(--fg); }
table.grid td { overflow-wrap: break-word; word-break: break-all; }
.col-resize {
  position: absolute; top: 0; right: 0; width: 6px; height: 100%;
  cursor: col-resize; user-select: none;
}
.col-resize:hover { background: var(--accent); }

.log-controls {
  display: flex; gap: 1rem; align-items: center; margin: .5rem 0;
  font-size: .85rem;
}
.log-controls input[type=text] {
  font: inherit; padding: .15rem .4rem;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: .2rem; width: 16em;
}
.log-controls button {
  font: inherit; padding: .15rem .5rem; cursor: pointer;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border); border-radius: .2rem;
}
.log-output {
  font-family: var(--mono); font-size: .78rem; line-height: 1.4;
  background: var(--surface); border: 1px solid var(--border); border-radius: .25rem;
  padding: .5rem; max-height: 70vh; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
}
.log-line { padding: .05rem 0; }
.log-ts { color: var(--muted); }
.log-level { font-weight: 600; min-width: 4em; display: inline-block; }
.log-target { color: var(--muted); }
.log-kv { color: var(--link); }
.log-error .log-level { color: var(--fail); }
.log-warn .log-level { color: var(--warn); }
.log-info .log-level { color: var(--pass); }
.log-debug .log-level { color: var(--muted); }
.log-trace .log-level { color: var(--muted); }

/* Compare page */
/* border-collapse: separate is required for position: sticky th to render
 * correctly in Chrome (collapse breaks sticky table headers there).
 * No overflow wrapper: the wide table overflows the page and the browser
 * provides both scrollbars. */
.compare-grid { table-layout: auto; border-collapse: separate; border-spacing: 0; width: 100%; margin: .5rem 0 1rem; }
.compare-grid thead th { position: sticky; top: var(--page-header-h, 3rem); background: var(--header-bg); z-index: 5; }
/* keep the test column visible when scrolling horizontally */
.compare-grid td:first-child, .compare-grid th:first-child { position: sticky; left: 0; background: var(--bg); }
.compare-grid tbody tr:hover td:first-child { background: var(--surface); }
.compare-grid thead th:first-child { z-index: 6; background: var(--header-bg); }
/* with border-collapse: separate, avoid doubled internal borders */
.compare-grid th, .compare-grid td { border-top-width: 0; border-left-width: 0; }
.compare-grid thead tr:first-child th { border-top-width: 1px; }
.compare-grid th:first-child, .compare-grid td:first-child { border-left-width: 1px; }
.compare-test-col { min-width: 12em; }
.compare-col-head { min-width: 10em; vertical-align: top; text-align: left; }
.compare-cell { text-align: center; font-weight: 600; }
.v-absent { color: var(--muted); font-weight: 400; }

/* Analyze page */
.analyze-grid th.b-left { border-left: 3px solid var(--accent); }
.analyze-grid td.flip-left { border-left: 3px solid var(--accent); }
/* The transition bands sit above the per-column headers: each spans the
 * columns on both sides of its boundary. */
.transition-row th { text-align: center; vertical-align: bottom; padding: .15rem .5rem; }
.transition-cell { background: var(--surface); }
/* A squashed column whose runs disagree: the worst verdict stands, marked so a
 * rerun difference is never quietly averaged into one value. */
.disagree-mark { color: var(--skip); font-weight: 700; margin-left: .1rem; }
.analyze-grid td.cell-disagree { box-shadow: inset 0 0 0 1px var(--skip); }
.boundary-label {
  color: var(--accent); font-weight: 700; font-size: .72rem;
  white-space: nowrap;
}
.chips { display: flex; flex-wrap: wrap; gap: .2rem; margin-top: .2rem; }
.chip {
  font: inherit; font-size: .72rem; line-height: 1.2; cursor: pointer;
  border: 1px solid var(--border); border-radius: .2rem;
  background: var(--surface); color: var(--fg); padding: 0 .3rem;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip-good { color: var(--pass); }
.chip-bad { color: var(--fail); }
.chip-muted { cursor: default; color: var(--muted); }
.badge.attr-kernel { color: var(--broken); border-color: var(--broken); }
.badge.attr-suite { color: var(--link); border-color: var(--link); }
.badge.attr-mixed { color: var(--warn); border-color: var(--warn); }
.badge.attr-flaky { color: var(--skip); border-color: var(--skip); }
.badge.attr-other { color: var(--muted); border-color: var(--muted); }
.badge.dir-regression { color: var(--fail); border-color: var(--fail); }
.badge.dir-fix { color: var(--pass); border-color: var(--pass); }
.badge.dir-new { color: var(--link); border-color: var(--link); }
.badge.dir-removed { color: var(--muted); border-color: var(--muted); }
span.attr-kernel { color: var(--broken); font-weight: 600; }
span.attr-suite { color: var(--link); font-weight: 600; }
span.attr-mixed { color: var(--warn); font-weight: 600; }
span.attr-flaky { color: var(--skip); font-weight: 600; }
span.attr-other { color: var(--muted); font-weight: 600; }

/* Keyboard navigation focus */
tr.kb-focus { outline: 2px solid var(--accent); outline-offset: -2px; }
