:root {
  --bg: #090b0f;
  --panel: #11151b;
  --panel-2: #151a22;
  --line: #252d38;
  --text: #f5f7fa;
  --muted: #9aa5b1;
  --accent: #9bf00b;
  --accent-2: #d5ff8a;
  --danger: #ff6b6b;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 22% -10%, rgba(155,240,11,.11), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }
button, input, select { font: inherit; }

.hero {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.018), transparent);
}
.hero-inner, .shell, footer {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
}
.hero-inner { padding: 48px 0 32px; }
.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  margin-bottom: 10px;
}
.hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 76px);
  line-height: .94;
  letter-spacing: -.055em;
}
.lede {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 17px;
}
.source-pill {
  border: 1px solid #344050;
  background: #0d1117;
  border-radius: 999px;
  padding: 9px 13px;
  color: #c8d0da;
  white-space: nowrap;
  font-size: 13px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 34px;
}
.stat {
  padding: 18px 20px;
  border: 1px solid var(--line);
  background: rgba(17,21,27,.8);
  border-radius: 14px;
}
.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 850;
  letter-spacing: -.03em;
}
.stat-label {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  display: block;
}

.shell { padding: 24px 0 60px; }
.panel, .table-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.controls-panel { padding: 18px; }
.control-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 750;
  margin-bottom: 7px;
}
.search, select {
  width: 100%;
  background: #0b0e13;
  color: var(--text);
  border: 1px solid #303947;
  border-radius: 10px;
  outline: none;
}
.search {
  padding: 14px 15px;
  font-size: 16px;
}
.search:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155,240,11,.10);
}
.filter-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.2fr .65fr;
  gap: 12px;
  margin-top: 14px;
}
select { min-height: 42px; padding: 9px 10px; }

.control-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #0a0c0f;
  border-radius: 9px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.button:hover { filter: brightness(1.06); }
.button.ghost {
  background: transparent;
  color: #d7dde5;
  border-color: #35404e;
}
.button:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  user-select: none;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui {
  width: 36px;
  height: 20px;
  background: #2b3440;
  border-radius: 999px;
  position: relative;
  transition: .15s ease;
}
.toggle-ui::after {
  content: "";
  width: 14px;
  height: 14px;
  position: absolute;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: white;
  transition: .15s ease;
}
.toggle input:checked + .toggle-ui { background: var(--accent); }
.toggle input:checked + .toggle-ui::after { transform: translateX(16px); }

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 2px 10px;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }

.table-card { overflow: hidden; }
.table-scroll { overflow: auto; max-height: 67vh; }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1180px;
}
thead {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #11161d;
}
th, td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid #202832;
  vertical-align: top;
}
th {
  color: #bdc6d0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .055em;
  white-space: nowrap;
}
td { font-size: 13px; }
tbody tr:hover { background: rgba(255,255,255,.025); }
.candidate-name {
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
}
.affiliation-empty, .cell-empty { color: #606b78; }
.source-link {
  color: var(--accent-2);
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}
.source-link:hover { text-decoration: underline; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid #384352;
  background: #171d25;
  color: #c5ced8;
  white-space: nowrap;
  font-size: 11px;
}
.badge.elected {
  border-color: rgba(155,240,11,.45);
  background: rgba(155,240,11,.08);
  color: var(--accent-2);
}
.sort {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  font-weight: 800;
  cursor: pointer;
}
.sort span { color: #596575; margin-left: 4px; }
.sort.active span { color: var(--accent); }

.pager {
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #0e1217;
}
#pageIndicator {
  color: var(--muted);
  min-width: 150px;
  text-align: center;
  font-size: 13px;
}

.empty {
  min-height: 260px;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 7px;
  color: var(--muted);
}
.empty strong { color: var(--text); font-size: 17px; }
.empty-icon { font-size: 38px; color: var(--accent); }

.about {
  margin-top: 22px;
  padding: 22px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 28px;
}
.about h2 { margin: 0 0 8px; font-size: 18px; }
.about p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
  font-size: 13px;
}
.notice {
  padding-left: 24px;
  border-left: 1px solid var(--line);
}
.notice strong {
  color: var(--accent-2);
  display: block;
  margin-bottom: 6px;
}

footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 32px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: #788390;
  font-size: 12px;
}

@media (max-width: 900px) {
  .hero-row { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .control-footer { align-items: flex-start; flex-direction: column; }
  .actions { justify-content: flex-start; }
  .results-head { align-items: flex-start; flex-direction: column; gap: 5px; }
  .about { grid-template-columns: 1fr; }
  .notice { border-left: 0; border-top: 1px solid var(--line); padding: 18px 0 0; }
  footer { flex-direction: column; gap: 4px; }
}

@media (max-width: 620px) {
  .hero-inner, .shell, footer { width: min(100% - 20px, 1500px); }
  .hero-inner { padding-top: 34px; }
  .filter-grid { grid-template-columns: 1fr; }
  .actions { width: 100%; }
  .actions .button { flex: 1 1 auto; }
  .table-scroll { max-height: none; overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; }
  table { min-width: 0; }
  thead { display: none; }
  tbody { padding: 8px; }
  tbody tr {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    margin: 8px 0;
    background: #0e1217;
  }
  tbody tr:hover { background: #0e1217; }
  td {
    border: 0;
    padding: 5px 0;
    display: grid;
    grid-template-columns: 112px 1fr;
    gap: 10px;
    line-height: 1.35;
  }
  td::before {
    content: attr(data-label);
    color: #74808e;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 800;
  }
  .candidate-name { white-space: normal; }
  .pager { position: sticky; bottom: 0; z-index: 5; }
}


/* Site section tabs */
.site-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.site-tab {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #344050;
  border-radius: 10px;
  color: #aeb8c5;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  background: #0d1117;
}
.site-tab:hover { border-color: #4a586a; color: #fff; }
.site-tab.active {
  border-color: rgba(155,240,11,.55);
  background: rgba(155,240,11,.08);
  color: var(--accent-2);
}

/* Candidate change log */
.changelog-controls {
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
}
.change-filter-row {
  display: flex;
  gap: 10px;
  align-items: end;
}
.change-filter-row > div { min-width: 190px; }

.change-log {
  display: grid;
  gap: 16px;
}
.change-day {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.change-day-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.018), transparent);
}
.change-date {
  font-size: 22px;
  font-weight: 850;
  letter-spacing: -.025em;
}
.change-revision-meta {
  display: flex;
  gap: 9px 14px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.reconstructed-tag,
.observed-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.reconstructed-tag {
  color: #ffd88d;
  border: 1px solid rgba(255,209,102,.35);
  background: rgba(255,209,102,.07);
}
.observed-tag {
  color: var(--accent-2);
  border: 1px solid rgba(155,240,11,.35);
  background: rgba(155,240,11,.07);
}
.change-count-pills {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-content: flex-start;
}
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid #35404e;
  color: #cbd3dd;
  background: #0e1319;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.pill.add { border-color: rgba(155,240,11,.35); color: var(--accent-2); }
.pill.remove { border-color: rgba(255,107,107,.35); color: #ff9a9a; }
.pill.status { border-color: rgba(111,210,255,.35); color: #9ee4ff; }
.pill.field { border-color: rgba(193,144,255,.35); color: #d8b8ff; }

.change-items {
  display: grid;
}
.change-item {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 15px;
  padding: 15px 20px;
  border-bottom: 1px solid #202832;
}
.change-item:last-child { border-bottom: 0; }
.change-item:hover { background: rgba(255,255,255,.018); }
.change-badge {
  width: max-content;
  height: max-content;
  min-width: 68px;
  text-align: center;
  border-radius: 7px;
  padding: 5px 7px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .055em;
  border: 1px solid #3a4553;
  color: #dbe2eb;
  background: #111820;
}
.change-added .change-badge {
  color: #cfff7e;
  border-color: rgba(155,240,11,.38);
  background: rgba(155,240,11,.07);
}
.change-removed .change-badge {
  color: #ff9c9c;
  border-color: rgba(255,107,107,.38);
  background: rgba(255,107,107,.07);
}
.change-status .change-badge {
  color: #9ee4ff;
  border-color: rgba(111,210,255,.38);
  background: rgba(111,210,255,.07);
}
.change-modified .change-badge {
  color: #d8b8ff;
  border-color: rgba(193,144,255,.38);
  background: rgba(193,144,255,.07);
}
.change-name {
  color: #fff;
  font-size: 15px;
  font-weight: 850;
}
.change-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.change-detail {
  margin-top: 8px;
  color: #e7edf4;
  font-size: 13px;
  font-weight: 700;
}
.change-meta {
  display: block;
  margin-top: 6px;
  color: #6f7b89;
  font-size: 11px;
}
.no-events {
  padding: 22px 20px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 900px) {
  .changelog-controls { grid-template-columns: 1fr; }
  .change-filter-row { align-items: stretch; }
  .change-filter-row > div { flex: 1; min-width: 0; }
  .change-day-head { flex-direction: column; }
  .change-count-pills { justify-content: flex-start; }
}

@media (max-width: 620px) {
  .site-tabs { margin-bottom: 22px; }
  .site-tab { flex: 1 1 auto; justify-content: center; }
  .change-filter-row { flex-direction: column; }
  .change-filter-row .button { width: 100%; }
  .change-item {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px 15px;
  }
  .change-day-head { padding: 16px 15px; }
  .change-date { font-size: 19px; }
}
