:root {
  color-scheme: dark;
  --bg: #060a12;
  --panel: #0b1220;
  --panel-raised: #0e1728;
  --line: #1b2940;
  --line-strong: #2b4270;
  --text: #f5f7fb;
  --muted: #8492a6;
  --blue: #2e5cff;
  --blue-soft: #5b8cff;
  --cyan: #52d6ff;
  --amber: #f2b94b;
  --red: #f16d7a;
  --green: #55d69e;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
}

button, select { font: inherit; }
button { color: inherit; }
button:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: 23px; line-height: 1.12; letter-spacing: -.02em; }
h2 { margin-bottom: 7px; font-size: 21px; line-height: 1.15; letter-spacing: -.02em; }
h3 { margin-bottom: 0; font-size: 14px; line-height: 1.3; letter-spacing: -.01em; }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  transform: translateY(-150%);
  padding: 8px 12px;
  background: var(--blue);
  color: white;
}
.skip-link:focus { transform: translateY(0); }

.topbar, .health-strip, .tabs, main, footer {
  width: min(1460px, calc(100% - 32px));
  margin-inline: auto;
}

.topbar {
  min-height: 102px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-block { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: white;
  font: 700 19px/1 var(--mono);
}
.eyebrow, .card-index {
  margin-bottom: 6px;
  color: var(--blue-soft);
  font: 700 10px/1.2 var(--mono);
  letter-spacing: .14em;
}
.header-note, .section-copy {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.audit-button {
  min-width: 230px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font: 700 10px/1.2 var(--mono);
  letter-spacing: .04em;
}
.audit-button:hover { border-color: var(--line-strong); color: var(--text); }
.status-dot { width: 7px; height: 7px; background: var(--muted); }
.audit-button.partial .status-dot { background: var(--amber); }
.audit-button.complete .status-dot { background: var(--green); }
.audit-button.invalid .status-dot { background: var(--red); }

.health-strip {
  min-height: 38px;
  display: grid;
  grid-template-columns: auto 1.3fr 1fr 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #08101d;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font: 600 10px/1.2 var(--mono);
  letter-spacing: .035em;
}
.health-strip:hover { border-color: var(--line-strong); }
.health-main, .health-action { color: var(--blue-soft); }
.health-action { text-align: right; }

.tabs {
  display: flex;
  gap: 2px;
  margin-top: 12px;
  border-bottom: 1px solid var(--line);
}
.tab {
  min-width: 104px;
  padding: 12px 14px 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}
.tab:hover { color: var(--text); background: #0a1120; }
.tab.active { color: var(--text); border-bottom-color: var(--blue); background: #0a1120; }
.tab span {
  margin-left: 5px;
  color: #5d6980;
  font: 700 8px/1 var(--mono);
  letter-spacing: .08em;
}

main { padding: 24px 0 34px; }
.panel[hidden] { display: none; }
.panel.active { animation: appear 120ms ease-out; }
@keyframes appear { from { opacity: .72; } to { opacity: 1; } }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 18px;
}
.section-head > div:first-child { min-width: 0; }
.field-row { display: flex; gap: 10px; }
.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font: 700 9px/1.2 var(--mono);
  letter-spacing: .07em;
  text-transform: uppercase;
}
select {
  min-width: 210px;
  height: 36px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  color: var(--text);
  font: 500 11px/1 var(--mono);
}

.metric-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.metric {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 10px;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}
.metric:last-child { border-right: 0; }
.metric span {
  grid-column: 1 / -1;
  color: var(--muted);
  font: 700 9px/1.2 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.metric strong { overflow: hidden; font: 600 20px/1.2 var(--mono); text-overflow: ellipsis; }
.metric small { color: var(--muted); font: 9px/1.2 var(--mono); }
.metric strong.missing-value { color: var(--red); }

.card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
}
.card-head {
  min-height: 40px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}
.provenance {
  max-width: 57%;
  margin: 0;
  color: var(--muted);
  font: 9px/1.5 var(--mono);
  text-align: right;
}

.lanes { border-top: 1px solid var(--line); }
.lane {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
}
.lane:last-child { border-bottom: 0; }
.lane-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 8px 10px 8px 0;
  border-right: 1px solid var(--line);
}
.lane-label strong { color: var(--blue-soft); font: 700 11px/1 var(--mono); letter-spacing: .1em; }
.lane-label span { color: var(--muted); font: 8px/1.35 var(--mono); }
.lane-chart { min-height: 170px; padding-left: 8px; }

.evidence-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.lower-grid { grid-template-columns: 1.15fr .85fr; }
.chart { position: relative; min-height: 280px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font: 9px/1 var(--mono); }
.chart .legend-text, .chart .facet-title { fill: #b7c3d8; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .hover { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 4; opacity: .7; }
.chart .event-marker { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .identity { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 5 5; }
.chart .facet-divider { stroke: var(--line); }
.chart .scatter-point { fill: var(--blue); stroke: var(--cyan); stroke-width: 1; }
.tooltip {
  position: absolute;
  z-index: 3;
  width: max-content;
  max-width: 205px;
  padding: 8px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: #050811f2;
  color: var(--text);
  font: 10px/1.55 var(--mono);
  white-space: pre;
  pointer-events: none;
}
.chart-empty, .small-empty {
  min-height: 260px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  text-align: center;
}
.chart-empty strong { color: var(--text); font-size: 13px; }
.chart-empty span:last-child { max-width: 480px; font-size: 11px; }
.small-empty { min-height: 160px; font-size: 11px; }

.badge {
  display: inline-block;
  padding: 3px 5px 2px;
  border: 1px solid currentColor;
  border-radius: 2px;
  font: 700 8px/1 var(--mono);
  letter-spacing: .07em;
  text-transform: uppercase;
}
.badge.real, .badge.complete { color: var(--green); }
.badge.proxy { color: var(--cyan); }
.badge.pending, .badge.partial { color: var(--amber); }
.badge.missing, .badge.invalid { color: var(--red); }
.badge.stale { color: var(--amber); }

.detail-card { min-height: 326px; }
.selected-detail { color: var(--muted); }
.selected-detail dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.selected-detail dl > div { padding: 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.selected-detail dt { margin-bottom: 5px; font: 700 9px/1.2 var(--mono); letter-spacing: .07em; text-transform: uppercase; }
.selected-detail dd { margin: 0; color: var(--text); font: 600 12px/1.4 var(--mono); }
.selected-detail p { margin: 16px 0 0; font-size: 11px; }

.matrix {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.matrix-cell {
  min-height: 94px;
  display: grid;
  align-content: space-between;
  gap: 4px;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 2px;
  background: #080f1b;
  color: var(--muted);
  text-align: left;
  opacity: 1;
}
.matrix-cell span, .matrix-cell small { font: 8px/1.2 var(--mono); letter-spacing: .08em; }
.matrix-cell strong { color: #a5b1c5; font: 600 10px/1.3 var(--mono); text-transform: uppercase; }
.matrix-cell b { color: var(--red); font: 600 20px/1 var(--mono); }
.matrix-cell.pending b { color: var(--amber); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font: 10px/1.4 var(--mono); }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }

.empty-state {
  min-height: 520px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 32px;
  border: 1px dashed var(--line-strong);
  text-align: center;
}
.empty-state h2 { margin-bottom: 10px; }
.empty-state p:last-child { max-width: 580px; color: var(--muted); }
.future-state { background: #080e19; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 0 30px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 9px/1.4 var(--mono);
  letter-spacing: .05em;
}
footer span:first-child { color: var(--blue-soft); font-weight: 700; }

.audit-scrim {
  position: fixed;
  z-index: 8;
  inset: 0;
  background: #02050aad;
}
.audit-drawer {
  position: fixed;
  z-index: 9;
  top: 0;
  right: 0;
  width: min(560px, 100%);
  height: 100dvh;
  overflow-y: auto;
  padding: 20px;
  border-left: 1px solid var(--line-strong);
  background: #080e19;
  transform: translateX(102%);
  transition: transform 160ms ease-out;
  visibility: hidden;
}
.audit-drawer.open { transform: translateX(0); visibility: visible; }
.drawer-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font: 300 23px/1 var(--sans);
}
.drawer-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 14px;
  border: 1px solid var(--line);
}
.drawer-summary > div { min-width: 0; padding: 10px; border-right: 1px solid var(--line); }
.drawer-summary > div:last-child { border-right: 0; }
.drawer-summary span { display: block; margin-bottom: 5px; color: var(--muted); font: 700 8px/1 var(--mono); }
.drawer-summary strong { display: block; overflow: hidden; font: 600 10px/1.4 var(--mono); text-overflow: ellipsis; }
.audit-rows { border-top: 1px solid var(--line); }
.audit-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.audit-row > div, .source-list article > div { display: flex; align-items: center; gap: 8px; }
.audit-row strong, .source-list strong { font-size: 11px; }
.audit-row p { margin: 7px 0 4px; color: #a9b4c6; font-size: 11px; }
.audit-row small, .source-list small { color: var(--muted); font: 9px/1.45 var(--mono); }
.drawer-section { margin-top: 24px; }
.drawer-section h3 { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.issue-list { margin: 0; padding-left: 18px; color: #a9b4c6; font-size: 11px; }
.issue-list li { margin: 8px 0; }
.source-list article {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.source-list article > div { grid-column: 1 / -1; }
.source-list a { color: var(--cyan); font: 9px/1.4 var(--mono); text-decoration: none; }
.source-list a:hover { text-decoration: underline; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1179px) {
  .health-strip { grid-template-columns: auto 1fr 1fr auto; }
  #health-sources { display: none; }
  .section-head { align-items: start; }
  .evidence-grid, .lower-grid { grid-template-columns: 1fr; }
  .detail-card { min-height: auto; }
}

@media (max-width: 719px) {
  .topbar, .health-strip, .tabs, main, footer { width: min(100% - 20px, 1460px); }
  body { padding-bottom: 64px; }
  .topbar { min-height: 124px; align-items: start; padding: 18px 0; }
  .brand-mark { width: 32px; height: 32px; font-size: 16px; }
  h1 { font-size: 19px; }
  .header-note { max-width: 250px; }
  .audit-button { min-width: 38px; width: 38px; padding: 11px; }
  .audit-button #source-status, .audit-button span:last-child { display: none; }
  .health-strip { grid-template-columns: 1fr auto; padding-block: 8px; }
  .health-main, #health-sources, #health-gaps { display: none; }
  .health-action { display: block; }
  .tabs {
    position: fixed;
    z-index: 6;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    margin: 0;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    border-bottom: 0;
    background: #070d18f7;
  }
  .tab { min-width: 0; flex: 1; padding: 13px 3px 12px; font-size: 9px; }
  .tab span { display: none; }
  .tab.active { border-top: 2px solid var(--blue); border-bottom: 0; }
  main { padding-top: 18px; }
  .section-head { display: grid; gap: 14px; }
  .section-copy { max-width: 100%; }
  .field-row { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .field, select { width: 100%; min-width: 0; }
  .metric-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .metric strong { font-size: 16px; }
  .card { padding: 11px; }
  .card-head { display: block; }
  .provenance { max-width: 100%; margin-top: 8px; text-align: left; }
  .lane { grid-template-columns: 48px minmax(0, 1fr); }
  .lane-label { padding-right: 4px; }
  .lane-label span { display: none; }
  .lane-chart { min-height: 150px; }
  .chart { min-height: 250px; }
  .chart-empty { min-height: 230px; padding: 18px; }
  .selected-detail dl { grid-template-columns: 1fr; }
  .matrix { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer-summary { grid-template-columns: 1fr; }
  .drawer-summary > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .drawer-summary > div:last-child { border-bottom: 0; }
  footer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .panel.active { animation: none; }
  .audit-drawer { transition: none; }
}
