:root {
  color-scheme: light;
  --ink: #1c2321;
  --muted: #5e6964;
  --paper: #f7f5ef;
  --surface: #fffdf7;
  --line: #d8d2c2;
  --blue: #255f85;
  --green: #38745f;
  --red: #9b3f3f;
  --gold: #a27123;
  --violet: #675184;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1520px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 26px 0 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.9rem, 3.2vw, 3.35rem);
  line-height: 1.05;
  max-width: 980px;
}

h2 {
  font-size: 1.05rem;
}

.run-status {
  max-width: 420px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #eee8d7;
  color: var(--muted);
  font-size: 0.9rem;
}

.controls {
  display: grid;
  grid-template-columns: 1.35fr 2fr 0.9fr 0.9fr 2fr 1.3fr;
  gap: 12px;
  padding: 18px 0;
}

.source-note {
  min-height: 34px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0 0 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
  text-transform: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 18px 0;
  background: var(--line);
  border: 1px solid var(--line);
}

.metrics > div {
  display: grid;
  gap: 8px;
  min-height: 92px;
  background: var(--surface);
  padding: 16px;
}

.metric-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metrics strong {
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  line-height: 1;
}

.tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0 14px;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  min-height: 38px;
  padding: 8px 12px;
}

.tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

.view {
  display: none;
  padding: 18px 0 0;
}

.view.active {
  display: block;
}

.section-header {
  display: grid;
  grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
  gap: 28px;
  align-items: baseline;
  margin-bottom: 12px;
}

.section-header p {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
}

.chart {
  width: 100%;
  height: 520px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.chart.tall {
  height: 680px;
}

.axis path,
.axis line {
  stroke: #c7c0ad;
}

.axis text {
  fill: var(--muted);
  font-size: 12px;
}

.axis-title {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.grid line {
  stroke: #e8e2d3;
}

.legend {
  fill: var(--muted);
  font-size: 13px;
}

.hit-area {
  fill: #fff;
  fill-opacity: 0;
  stroke: none;
  cursor: crosshair;
  pointer-events: all;
}

.chart-tooltip {
  position: fixed;
  z-index: 20;
  max-width: 320px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  border: 1px solid #c7c0ad;
  background: rgba(255, 253, 247, 0.98);
  box-shadow: 0 10px 24px rgba(28, 35, 33, 0.14);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.chart-tooltip.visible {
  opacity: 1;
  visibility: visible;
}

.tooltip-title {
  margin-bottom: 7px;
  font-weight: 800;
}

.chart-tooltip div:not(.tooltip-title) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
}

.chart-tooltip span {
  color: var(--muted);
}

.chart-tooltip strong {
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  background: #f0eadb;
  position: sticky;
  top: 0;
}

.validation-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
}

.stacked-tables {
  display: grid;
  gap: 14px;
}

pre {
  margin: 0;
  min-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  background: #211f1c;
  color: #f4ebd7;
  padding: 16px;
  font-size: 0.82rem;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .masthead,
  .controls,
  .metrics,
  .section-header,
  .validation-grid {
    grid-template-columns: 1fr;
  }

  .shell {
    width: min(100vw - 20px, 1520px);
    padding-top: 14px;
  }

  .chart,
  .chart.tall {
    height: 520px;
  }
}
