:root {
  --bg: #0A0E17;
  --sidebar-bg: #0B0F1A;
  --panel: #10151F;
  --panel-alt: #151B28;
  --border: #232B3D;
  --border-soft: #1A2130;
  --ink: #E7EAF2;
  --muted: #8891A5;
  --muted-dim: #5C6478;
  --pass: #3ED68C;
  --pass-bg: rgba(62, 214, 140, 0.12);
  --fail: #F1555C;
  --fail-bg: rgba(241, 85, 92, 0.12);
  --warn: #E8B44A;
  --warn-bg: rgba(232, 180, 74, 0.12);
  --accent: #4C8DFF;
  --accent-bg: rgba(76, 141, 255, 0.12);
  --sans: Calibri, Carlito, "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: Calibri, Carlito, "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --sidebar-w: 208px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
code { font-family: var(--mono); background: var(--panel-alt); padding: 1px 5px; border-radius: 2px; }

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

#shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 4px;
}

.sidebar-logo .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.sidebar-logo .wordmark { font-family: var(--mono); font-weight: 600; font-size: 12.5px; letter-spacing: 0.04em; }

.sidebar-tagline {
  padding: 0 16px 16px;
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav { padding: 10px 8px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 1px;
  border: 1px solid transparent;
}

.nav-item:hover { color: var(--ink); background: var(--panel-alt); }

.nav-item.active {
  color: var(--ink);
  background: var(--accent-bg);
  border-color: rgba(76, 141, 255, 0.25);
}

.nav-item svg { width: 13px; height: 13px; flex-shrink: 0; opacity: 0.85; }

.sidebar-foot {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted-dim);
  font-family: var(--mono);
}
.sidebar-foot .row { display: flex; justify-content: space-between; margin-bottom: 3px; }
.sidebar-foot .v { color: var(--muted); }

.main { flex: 1; min-width: 0; }

/* ---------------- Top header ---------------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  gap: 20px;
  flex-wrap: wrap;
}

.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.topbar-right { display: flex; align-items: center; gap: 18px; }

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--pass); }
.status-pill .dot.warn { background: var(--warn); }
.status-pill .dot.fail { background: var(--fail); }
.status-pill .label { color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.status-pill .value { color: var(--ink); font-weight: 600; }

.env-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--accent-bg);
  color: var(--accent);
  letter-spacing: 0.04em;
}

.page-content { padding: 20px 24px 60px; }
.page { display: none; }
.page.active { display: block; }

/* ---------------- Panels & grids ---------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 5px;
}

.panel-pad { padding: 16px 18px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

.section-gap { margin-top: 16px; }

.provenance-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 3px;
  margin-bottom: 10px;
}
.provenance-pill.synthetic { background: var(--accent-bg); color: var(--accent); }
.provenance-pill.real { background: var(--pass-bg); color: var(--pass); }

.panel-title { font-size: 14px; font-weight: 600; margin: 0 0 3px; }
.panel-desc { font-size: 11px; color: var(--muted); margin-bottom: 14px; }

/* stat cells */
.stat-row { display: grid; gap: 1px; background: var(--border-soft); border: 1px solid var(--border-soft); border-radius: 4px; overflow: hidden; }
.stat-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.stat-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stat-row.cols-7 { grid-template-columns: repeat(7, 1fr); }

.stat-cell { background: var(--panel); padding: 10px 12px; }
.stat-label { font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 5px; }
.stat-value { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.stat-value.pass { color: var(--pass); }
.stat-value.fail { color: var(--fail); }
.stat-value.warn { color: var(--warn); }
.stat-value.na { color: var(--muted-dim); font-size: 13px; font-weight: 500; }
.stat-sub { font-size: 9.5px; color: var(--muted-dim); margin-top: 2px; }

/* pass/fail bar */
.bar-track-h { height: 18px; border-radius: 3px; overflow: hidden; display: flex; background: var(--border-soft); }
.bar-seg-pass { background: var(--pass); }
.bar-seg-fail { background: var(--fail); }
.bar-legend { display: flex; gap: 16px; margin-top: 8px; font-size: 10.5px; color: var(--muted); }
.bar-legend .sw { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }

/* compare bars */
.compare-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 11px; }
.compare-row .clabel { width: 130px; flex-shrink: 0; color: var(--muted); }
.compare-row .ctrack { flex: 1; height: 8px; background: var(--border-soft); border-radius: 3px; overflow: hidden; }
.compare-row .cfill { height: 100%; background: var(--accent); }
.compare-row .cfill.baseline { background: var(--muted-dim); }
.compare-row .cval { width: 48px; text-align: right; font-family: var(--mono); flex-shrink: 0; }

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

table.dtable { width: 100%; border-collapse: collapse; font-size: 11.5px; }
table.dtable th {
  text-align: left;
  padding: 7px 10px;
  background: var(--panel-alt);
  border-bottom: 1px solid var(--border);
  font-size: 9.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  white-space: nowrap;
}
table.dtable td { padding: 7px 10px; border-bottom: 1px solid var(--border-soft); font-family: var(--mono); white-space: nowrap; }
table.dtable tbody tr { cursor: default; }
table.dtable tbody tr.clickable { cursor: pointer; }
table.dtable tbody tr.clickable:hover { background: var(--panel-alt); }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 5px; }
.table-scroll table.dtable { border: none; }
.table-scroll th:first-child, .table-scroll td:first-child { padding-left: 14px; }

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.badge.pass { background: var(--pass-bg); color: var(--pass); }
.badge.fail { background: var(--fail-bg); color: var(--fail); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.neutral { background: var(--accent-bg); color: var(--accent); }
.badge.dim { background: var(--border-soft); color: var(--muted); }

.small-link { font-size: 10.5px; color: var(--accent); cursor: pointer; }

/* ---------------- Execution timeline ---------------- */

.exec-timeline { display: flex; gap: 0; overflow-x: auto; }
.exec-step { flex: 1; min-width: 130px; padding: 10px 14px; border-right: 1px solid var(--border-soft); position: relative; }
.exec-step:last-child { border-right: none; }
.exec-step-time { font-family: var(--mono); font-size: 10px; color: var(--muted-dim); margin-bottom: 6px; }
.exec-step-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 4px; display: flex; align-items: center; gap: 5px; }
.exec-step-label .chip { width: 5px; height: 5px; border-radius: 50%; background: var(--pass); }
.exec-step-label .chip.fail { background: var(--fail); }
.exec-step-label .chip.warn { background: var(--warn); }
.exec-step-main { font-size: 12px; font-weight: 600; }
.exec-step-detail { font-size: 10px; color: var(--muted); margin-top: 3px; line-height: 1.4; }

/* ---------------- Failure replay page ---------------- */

.replay-shell { display: grid; grid-template-columns: 280px 1fr; gap: 14px; align-items: start; }
.replay-list { max-height: 78vh; overflow-y: auto; }
.replay-list-item {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  font-size: 11.5px;
}
.replay-list-item:hover { background: var(--panel-alt); }
.replay-list-item.active { background: var(--accent-bg); border-left: 2px solid var(--accent); }
.replay-list-item .rid { font-family: var(--mono); font-weight: 600; }
.replay-list-item .rcat { font-size: 10px; color: var(--muted); margin-top: 2px; }
.replay-search {
  width: 100%;
  padding: 7px 10px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 5px 5px 0 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 11.5px;
}

.chain-step {
  border-left: 2px solid var(--border);
  padding: 0 0 18px 16px;
  margin-left: 4px;
  position: relative;
}
.chain-step::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-dim);
}
.chain-step.pass::before { background: var(--pass); }
.chain-step.fail::before { background: var(--fail); }
.chain-step h4 {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 7px;
}
.chain-step .body { font-size: 12px; line-height: 1.55; }
.narrative-quote {
  font-style: italic;
  font-size: 12px;
  color: var(--ink);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  margin: 6px 0;
}
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 5px 16px; margin-top: 4px; }
.kv { font-size: 11.5px; }
.kv .k { color: var(--muted); font-size: 9.5px; text-transform: uppercase; }
.kv .v { font-family: var(--mono); overflow-wrap: anywhere; word-break: break-word; }
.violation-list { margin: 6px 0 0; padding-left: 16px; }
.violation-list li { color: var(--fail); font-size: 11.5px; margin-bottom: 3px; font-family: var(--mono); }

/* ---------------- Consistency spotlight ---------------- */

.consistency-variants { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; background: var(--border-soft); border: 1px solid var(--border-soft); border-radius: 4px; overflow: hidden; margin: 10px 0; }
.consistency-variant { background: var(--panel); padding: 10px; }
.consistency-variant .vlabel { font-family: var(--mono); font-size: 9.5px; color: var(--muted); margin-bottom: 6px; }
.consistency-variant .vdecision { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.consistency-variant.flagged { box-shadow: inset 0 0 0 1px var(--fail); }
.consistency-variant.flagged .vdecision { color: var(--fail); }
.consistency-note { font-size: 11px; color: var(--muted); font-style: italic; margin-top: 8px; }

/* ---------------- Category / distribution lists ---------------- */

.dist-list { font-size: 11.5px; }
.dist-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--border-soft); }
.dist-row:last-child { border-bottom: none; }
.dist-row .dname { display: flex; align-items: center; gap: 7px; }
.dist-row .dname .sw { width: 7px; height: 7px; border-radius: 2px; }
.dist-row .dval { font-family: var(--mono); color: var(--muted); }

/* ---------------- Category filter chips ---------------- */

.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1px; background: var(--border-soft); border: 1px solid var(--border-soft); border-radius: 4px; overflow: hidden; }
.category-chip { background: var(--panel); padding: 8px 11px; cursor: pointer; font-size: 11.5px; display: flex; justify-content: space-between; }
.category-chip .cat-count { font-family: var(--mono); color: var(--muted); font-size: 10.5px; }
.category-chip.active { background: var(--panel-alt); box-shadow: inset 2px 0 0 var(--accent); }

.filter-btn {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  border-radius: 3px;
}
.filter-btn.active { border-color: var(--accent); color: var(--ink); }

.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 12px; font-size: 11px; color: var(--muted); }
.pagination button { font-family: var(--mono); font-size: 11px; padding: 5px 10px; border: 1px solid var(--border); background: var(--panel); color: var(--ink); cursor: pointer; border-radius: 3px; }
.pagination button:disabled { opacity: 0.35; cursor: default; }

.select-compact {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  border-radius: 3px;
}

.hint-empty {
  font-size: 11.5px;
  color: var(--muted);
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 5px;
  text-align: center;
}

.foot-note { font-size: 10.5px; color: var(--muted-dim); max-width: 100ch; margin-top: 4px; }
.foot-note + .foot-note { margin-top: 8px; }

/* ---------------- Responsive ---------------- */

@media (max-width: 980px) {
  #shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar-logo, .sidebar-tagline, .sidebar-foot { display: none; }
  .sidebar-nav { display: flex; padding: 8px; flex: none; }
  .nav-item { white-space: nowrap; margin-bottom: 0; margin-right: 4px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .stat-row.cols-4, .stat-row.cols-7 { grid-template-columns: repeat(2, 1fr); }
  .replay-shell { grid-template-columns: 1fr; }
  .consistency-variants { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-row.cols-4, .stat-row.cols-7, .stat-row.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 12px 14px; }
  .page-content { padding: 14px 14px 40px; }
}