:root {
  --ink: #14212b;
  --muted: #5c6b76;
  --paper: #f3f1eb;
  --card: #ffffffee;
  --line: #d5d0c6;
  --accent: #1f6f8b;
  --accent-2: #c23b22;
  --gold: #d4a017;
  --shadow: 0 18px 50px rgba(20, 33, 43, 0.08);
  --radius: 18px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 480px at 8% -10%, #c9e4ef 0%, transparent 55%),
    radial-gradient(700px 420px at 95% 0%, #f0d7c8 0%, transparent 50%),
    linear-gradient(180deg, #f7f4ee 0%, #ebe6dc 100%);
}

.header, main, .tabs, .footer {
  width: min(1100px, calc(100% - 2rem));
  margin-left: auto;
  margin-right: auto;
}

.header {
  padding: 2.4rem 0 1rem;
}

.eyebrow {
  margin: 0 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.lede {
  max-width: 46rem;
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1.2rem auto 1rem;
}

.tab {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tab:hover { background: #fff; }
.tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.panel { display: none; padding-bottom: 2.5rem; }
.panel.active { display: block; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.controls, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: fit-content;
}

.controls label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
  font-weight: 500;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.mono { font-family: var(--mono); font-size: 0.85rem; }

.primary {
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 0.8rem 1rem;
  cursor: pointer;
}

.primary:hover { filter: brightness(1.05); }

.metrics {
  background: #f7fafb;
  border: 1px solid #d9e5ea;
  border-radius: 12px;
  padding: 0.85rem;
  line-height: 1.55;
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.hint code {
  font-family: var(--mono);
  font-size: 0.75rem;
  background: #efece4;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}

.charts { display: grid; gap: 1rem; }
.chart-card { padding: 0.85rem 0.85rem 0.4rem; }
.chart-card.small { min-height: 220px; }
.chart-card canvas { width: 100% !important; }

.dataset-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 1rem 1.1rem 0.4rem;
}

.dataset-meta p { margin: 0; color: var(--muted); }

.link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.link:hover { text-decoration: underline; }

.table-wrap {
  overflow: auto;
  max-height: 560px;
  padding: 0.5rem 1.1rem 1.1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.88rem;
}

th, td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
}

th { color: var(--muted); font-weight: 500; }

.subject-card { overflow: hidden; }
.pdf-frame {
  width: 100%;
  height: min(78vh, 900px);
  border: none;
  border-top: 1px solid var(--line);
  background: #fff;
}

.prose {
  padding: 1.25rem 1.4rem 1.8rem;
  line-height: 1.65;
}

.prose h1, .prose h2, .prose h3 {
  letter-spacing: -0.02em;
  margin-top: 1.4rem;
}

.prose pre, .prose code {
  font-family: var(--mono);
  font-size: 0.84rem;
}

.prose pre {
  background: #efece4;
  padding: 0.9rem;
  border-radius: 10px;
  overflow: auto;
}

.prose table {
  font-size: 0.85rem;
  margin: 1rem 0;
}

.muted { color: var(--muted); }

.footer {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 0 2rem;
}

.footer a { color: var(--accent); }
