*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #1a1a18;
  --ink-muted: #5a5a54;
  --ink-faint: #9a9a92;
  --surface: #ffffff;
  --surface-alt: #f7f6f2;
  --surface-tertiary: #f0efe9;
  --border: rgba(0,0,0,0.10);
  --border-mid: rgba(0,0,0,0.18);
  --accent: #2a5298;
  --accent-light: #e8eef8;
  --verified: #2d6a4f;
  --verified-bg: #e8f5ee;
  --preliminary: #7d5a00;
  --preliminary-bg: #fef9e7;
  --progress: #6d28d9;
  --progress-bg: #ede9fe;
  --ff-display: 'Playfair Display', Georgia, serif;
  --ff-body: 'Source Serif 4', Georgia, serif;
  --ff-mono: 'JetBrains Mono', monospace;
}

[data-theme="dark"] {
  --ink: #e5e5df;
  --ink-muted: #9a9a92;
  --ink-faint: #6a6a62;
  --surface: #1c1c1a;
  --surface-alt: #242422;
  --surface-tertiary: #181816;
  --border: rgba(255,255,255,0.10);
  --border-mid: rgba(255,255,255,0.18);
  --accent: #6b93d6;
  --accent-light: #1e2d47;
  --verified: #52b788;
  --verified-bg: #1a3028;
  --preliminary: #d4a843;
  --preliminary-bg: #2e2200;
  --progress: #a78bfa;
  --progress-bg: #2e1065;
}

html { font-size: 16px; }

body {
  font-family: var(--ff-body);
  color: var(--ink);
  background: var(--surface-tertiary);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* HERO */
.hero {
  border-bottom: 0.5px solid var(--border);
  padding: 3rem 2.5rem 2.5rem;
  background: var(--surface);
}
.hero-eyebrow {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 1rem;
}
.hero-title {
  font-family: var(--ff-display);
  font-size: 38px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.5px;
  color: var(--ink);
  max-width: 640px;
  margin-bottom: 1rem;
}
.hero-title em { font-style: italic; color: var(--accent); }
.hero-desc {
  font-size: 15px;
  color: var(--ink-muted);
  max-width: 560px;
  line-height: 1.75;
  font-weight: 300;
}

/* STATS BAR */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 0.5px solid var(--border);
  background: var(--surface);
}
.stat-cell {
  padding: 1.5rem 2.5rem;
  border-right: 0.5px solid var(--border);
}
.stat-cell:last-child { border-right: none; }
.stat-num {
  font-family: var(--ff-mono);
  font-size: 28px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 5px;
}
.stat-label {
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-family: var(--ff-mono);
}

/* SECTIONS */
.section { padding: 2rem 2.5rem; }
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 0.5px solid var(--border);
}
.section-title {
  font-family: var(--ff-display);
  font-size: 21px;
  font-weight: 500;
}
.section-link {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-decoration: none;
}
.section-link:hover { text-decoration: underline; }

/* ELECTIONS GRID */
.elections-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 0.5px solid var(--border);
}
.election-card {
  background: var(--surface);
  padding: 1.4rem;
  cursor: pointer;
  transition: background 0.12s;
}
.election-card:hover { background: var(--surface-alt); }
.election-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}
.election-year {
  font-family: var(--ff-mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
}
.status-badge {
  font-family: var(--ff-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 3px;
  font-weight: 500;
}
.status-verified { background: var(--verified-bg); color: var(--verified); }
.status-preliminary { background: var(--preliminary-bg); color: var(--preliminary); }
.status-progress { background: var(--progress-bg); color: var(--progress); }
.election-type { font-size: 13px; color: var(--ink-muted); margin-bottom: 4px; font-weight: 300; }
.election-precincts { font-family: var(--ff-mono); font-size: 11px; color: var(--ink-faint); }

/* FILTER ROW */
.filter-row { display: flex; gap: 8px; margin-bottom: 1.5rem; flex-wrap: wrap; }
.filter-btn {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 7px 16px;
  border: 0.5px solid var(--border-mid);
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.12s;
}
.filter-btn:hover { background: var(--surface-alt); color: var(--ink); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* DATA TABLE */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  font-family: var(--ff-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 9px 14px;
  text-align: left;
  border-bottom: 0.5px solid var(--border-mid);
  font-weight: 400;
  background: var(--surface);
  white-space: nowrap;
}
.data-table td {
  padding: 9px 14px;
  border-bottom: 0.5px solid var(--border);
  color: var(--ink);
  vertical-align: middle;
  background: var(--surface);
}
.data-table tr:hover td { background: var(--surface-alt); }
.data-table td.mono { font-family: var(--ff-mono); font-size: 12px; }
.proto-link {
  font-family: var(--ff-mono);
  font-size: 10px;
  color: var(--accent);
  text-decoration: none;
  border: 0.5px solid #c5d5ef;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}
.proto-link:hover { background: var(--accent-light); }

/* BUTTONS */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: opacity 0.12s;
  text-decoration: none;
}
.btn-primary:hover { opacity: 0.88; }
.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 20px;
  background: transparent;
  color: var(--accent);
  border: 0.5px solid var(--accent);
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
}
.btn-outline:hover { background: var(--accent-light); }

/* EXPLORER */
.explorer-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 1.5rem;
  padding: 1.5rem 2.5rem;
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
}
.filter-group label {
  font-family: var(--ff-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 7px;
}
.filter-group select {
  width: 100%;
  font-size: 13px;
  font-family: var(--ff-body);
  padding: 8px 12px;
  border: 0.5px solid var(--border-mid);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239a9a92'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
.filter-group select:focus { border-color: var(--accent); }

/* METHODOLOGY */
.method-page { width: 100%; padding: 2.5rem; }
.method-page h2 {
  font-family: var(--ff-display);
  font-size: 23px;
  font-weight: 500;
  margin-bottom: 0.6rem;
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 0.5px solid var(--border);
}
.method-page h2:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.method-page p {
  font-size: 14px;
  line-height: 1.85;
  color: var(--ink-muted);
  margin-bottom: 1rem;
  font-weight: 300;
}
.formula-block {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 1.25rem 1.5rem;
  font-family: var(--ff-mono);
  font-size: 14px;
  margin: 1.25rem 0 1.5rem;
  color: var(--ink);
  line-height: 2;
}
.formula-var { color: var(--accent); }

/* THESIS */
.thesis-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
  padding: 2.5rem;
  align-items: start;
}
.thesis-pdf-frame {
  border: 0.5px solid var(--border);
  background: var(--surface-alt);
  height: 580px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
}
.thesis-pdf-icon {
  width: 56px; height: 70px;
  border: 0.5px solid var(--border-mid);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}
.thesis-sidebar { position: sticky; top: 76px; }
.thesis-sidebar h3 {
  font-family: var(--ff-display);
  font-size: 17px;
  font-weight: 500;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 0.5px solid var(--border);
}
.thesis-meta-row { margin-bottom: 1.1rem; }
.thesis-meta-label {
  font-family: var(--ff-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 3px;
}
.thesis-meta-value { font-size: 14px; color: var(--ink); font-weight: 300; line-height: 1.5; }
.thesis-divider { border: none; border-top: 0.5px solid var(--border); margin: 1.25rem 0; }

/* ABOUT */
.about-page { max-width: 720px; padding: 2.5rem; }
.about-page h2 {
  font-family: var(--ff-display);
  font-size: 21px;
  font-weight: 500;
  margin-bottom: 0.75rem;
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 0.5px solid var(--border);
}
.about-page h2:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.about-page p {
  font-size: 14px;
  line-height: 1.85;
  color: var(--ink-muted);
  margin-bottom: 0.75rem;
  font-weight: 300;
}

/* FOOTER */
.footer {
  border-top: 0.5px solid var(--border);
  padding: 1.5rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--ink-faint);
  background: var(--surface);
  margin-top: auto;
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .elections-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .thesis-layout { grid-template-columns: 1fr; }
  .thesis-sidebar { position: static; }
  .explorer-filters { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .nav-links { display: none; }
  .elections-grid { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .hero-title { font-size: 28px; }
}