:root {
  color-scheme: dark;
  --bg: #070d18;
  --surface: #0f1729;
  --surface2: #141f35;
  --border: rgba(148, 163, 184, 0.14);
  --text: #e8edf5;
  --muted: #8b9bb8;
  --accent: #f59e0b;
  --success: #22c55e;
  --danger: #f87171;
  --primary: #38bdf8;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html {
  height: 100%;
  overflow: hidden;
}
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(56, 189, 248, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(245, 158, 11, 0.05), transparent);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
}
a { color: var(--accent); }
.shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1440px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 12px 16px;
  overflow: hidden;
  transition: max-width 0.2s;
}

/* Fullscreen */
.shell:fullscreen,
.shell.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  max-width: none;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 12px 16px;
  overflow: hidden;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(56, 189, 248, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(245, 158, 11, 0.05), transparent);
}
.shell:fullscreen .chart-box--xl,
.shell.is-fullscreen .chart-box--xl { height: min(56vh, 580px); }
.shell:fullscreen .chart-box--fs,
.shell.is-fullscreen .chart-box--fs { height: min(42vh, 420px); }
.shell:fullscreen .cand-list--tall,
.shell.is-fullscreen .cand-list--tall { max-height: min(56vh, 580px); }
.shell:fullscreen .scroll--fill,
.shell.is-fullscreen .scroll--fill { max-height: min(64vh, 660px); }

/* Tabs */
.tabs {
  display: flex; gap: 4px; flex-wrap: nowrap;
  margin-bottom: 10px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px;
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.tab {
  flex: 0 0 auto; min-width: 84px;
  padding: 12px 16px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted);
  font: 600 13px var(--font); letter-spacing: 0.04em;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.tab-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: #7a8ef9;
  border: 1px solid rgba(122, 142, 249, 0.35);
}
.tab-link:hover { background: rgba(122, 142, 249, 0.12); color: #a5b4fc; }
.tab.active {
  color: var(--text); background: var(--surface2);
  box-shadow: inset 0 0 0 1px var(--border);
}
.tab-panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  animation: fadeIn 0.2s ease;
  padding-bottom: 2px;
}
.tab-panel.active { display: block; }
.tab-panel.active > *:last-child { margin-bottom: 0; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card--tall { min-height: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; gap: 16px; flex-wrap: wrap;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 19px; letter-spacing: 0.02em; }
.brand .sub { font-size: 12px; color: var(--muted); }
.pulse {
  width: 11px; height: 11px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border);
}
.badge.live { color: var(--success); border-color: rgba(34,197,94,0.35); background: rgba(34,197,94,0.08); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.muted { color: var(--muted); font-size: 13px; }
.icon-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; width: 36px; height: 36px; cursor: pointer; font-size: 17px;
}
.icon-btn:hover { border-color: rgba(56,189,248,0.4); }

.disclaimer {
  background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.22);
  color: #fcd34d; font-size: 13px; border-radius: 10px; padding: 10px 14px; margin-bottom: 10px;
  flex-shrink: 0;
}
.banner {
  background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3);
  color: #fca5a5; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: 12px;
  flex-shrink: 0;
}
.hidden { display: none !important; }

.hero {
  display: grid; grid-template-columns: 1.4fr 0.9fr 1fr; gap: 14px; margin-bottom: 14px;
}
@media (max-width: 960px) { .hero { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px; box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px; gap: 8px;
}
.card-head h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.eyebrow { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.hero-projection .leader-name { font-size: 30px; font-weight: 700; line-height: 1.15; margin: 4px 0; }
.hero-projection .leader-party { color: var(--muted); font-size: 14px; }
.hero-projection .margin-pill {
  display: inline-block; margin-top: 10px; padding: 4px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: rgba(56,189,248,0.12); color: var(--primary);
}
.hero-projection .called { background: rgba(34,197,94,0.15); color: var(--success); }

.ring-wrap { position: relative; width: 156px; height: 156px; margin: 0 auto; }
.ring-center {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; pointer-events: none;
}
.hero-stats { display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.stat-line { display: flex; justify-content: space-between; font-size: 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.stat-line:last-child { border: none; padding: 0; }
.stat-line strong { font-variant-numeric: tabular-nums; }

.kpi-strip {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 14px;
}
@media (max-width: 1100px) { .kpi-strip { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .kpi-strip { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
}
.kpi label { display: block; font-size: 10px; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 4px; }
.kpi strong { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.accent strong { color: var(--accent); }
.kpi.registered strong { color: var(--primary); font-size: 20px; }

.insights-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.insight {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.insight strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}
.insight p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.insight--watch { border-color: rgba(245, 158, 11, 0.45); }
.insight--alert { border-color: rgba(248, 113, 113, 0.55); }
.insight--info { border-color: rgba(56, 189, 248, 0.35); }

.validation-compare { margin-bottom: 14px; }
.validation-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 900px) {
  .validation-grid { grid-template-columns: 1fr; }
}
.validation-lane {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.validation-lane h3 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.validation-lane--delta {
  border-color: rgba(56, 189, 248, 0.35);
  min-width: 180px;
}
.validation-stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.validation-stat:last-child { border-bottom: none; }
.validation-stat span { color: var(--muted); }
.validation-stat strong { font-variant-numeric: tabular-nums; }

.data-list { display: flex; flex-direction: column; gap: 8px; }
.data-list-item {
  padding: 10px 12px; border-radius: 10px; background: var(--surface2);
  border: 1px solid var(--border); font-size: 13px;
}
.data-list-item strong { display: block; margin-bottom: 2px; }
.data-list-item .meta { font-size: 11px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.chart-box { position: relative; height: 250px; }
.chart-box.tall { height: 310px; }
.chart-box--fs { height: 290px; }
.chart-box--xl { height: 380px; }

.cand-list { display: flex; flex-direction: column; gap: 8px; max-height: 310px; overflow-y: auto; }
.cand-list--tall { max-height: 380px; }
.scroll--fill { max-height: 460px; overflow-y: auto; }
.cand-row {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.cand-rank { font-size: 11px; color: var(--muted); font-weight: 600; }
.cand-name { font-size: 14px; font-weight: 600; }
.cand-party { font-size: 12px; color: var(--muted); }
.cand-votes { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.bar-mini { height: 4px; background: rgba(148,163,184,0.12); border-radius: 4px; margin-top: 4px; overflow: hidden; }
.bar-mini > span { display: block; height: 100%; border-radius: 4px; }

.stat-blocks { display: grid; gap: 10px; }
.stat-block {
  background: var(--surface2); border-radius: 10px; padding: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.stat-block label { font-size: 12px; color: var(--muted); }
.stat-block strong { font-size: 18px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-item label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.form-track { height: 8px; background: rgba(148,163,184,0.12); border-radius: 6px; overflow: hidden; }
.form-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, #38bdf8, #22c55e); }

.scroll { overflow-x: auto; }
.scroll.tall { max-height: 320px; overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 600; text-align: left; }
.tab-panel.active > *:last-child { margin-bottom: 0; }

.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.subtab {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.subtab:hover { color: var(--text); background: rgba(148,163,184,0.08); }
.subtab.active {
  color: var(--text);
  border-color: rgba(56,189,248,0.45);
  background: rgba(56,189,248,0.12);
}
.return-views {
  margin-top: -4px;
  padding-top: 8px;
}
.return-view-banner {
  margin: 0 16px 12px;
  font-size: 12px;
}
.return-views .view-count {
  display: inline-block;
  min-width: 1.25rem;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(148,163,184,0.15);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.geo-panel { display: none; }
.geo-panel.active { display: block; }

.party-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.party-badge i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

.geo-search {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
}
.geo-search input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.geo-search button {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(56,189,248,0.4);
  background: rgba(56,189,248,0.15);
  color: var(--text);
  cursor: pointer;
}

.data-table .r { text-align: right; }
.data-table.mono { font-family: var(--mono); font-size: 11px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.pill.ok { background: rgba(34,197,94,0.15); color: #4ade80; }
.pill.unchanged { background: rgba(100,116,139,0.2); color: #94a3b8; }
.pill.fail { background: rgba(248,113,113,0.15); color: #f87171; }
.pill.miss { background: rgba(148,163,184,0.1); color: var(--muted); }
.badge.fail { background: rgba(248,113,113,0.15); color: #f87171; }
.ok-text { color: #4ade80; }
.err-text { color: #f87171; }

.ingestor-hero {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.ingestor-status-head { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.ingestor-status-head h2 { margin: 0; font-size: 1.1rem; }
.ingestor-cycle-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.ingestor-progress { height: 8px; border-radius: 999px; background: rgba(148,163,184,0.15); overflow: hidden; }
.ingestor-progress-bar { height: 100%; background: linear-gradient(90deg, #38bdf8, #22c55e); transition: width 0.4s ease; }
.ingestor-last { margin: 8px 0 0; font-size: 12px; }
.ingestor-ring-wrap { position: relative; width: 140px; height: 140px; margin: 0 auto; }
.ingestor-ring-center {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700;
}
.ingestor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  padding: 12px;
  max-height: min(56vh, 580px);
  overflow: auto;
}
.ingestor-cell {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.ingestor-cell.ok { border-color: rgba(34,197,94,0.35); }
.ingestor-cell.stale { border-color: rgba(245,158,11,0.45); }
.ingestor-cell.fail { border-color: rgba(248,113,113,0.45); }
.ingestor-cell.wait { opacity: 0.55; }
.ingestor-cell-name { display: block; font-size: 11px; font-family: var(--mono); line-height: 1.3; }
.ingestor-cell-meta { display: block; font-size: 10px; color: var(--muted); margin-top: 4px; }
.ingestor-log-controls { display: flex; gap: 8px; align-items: center; }
.ingestor-log-controls select {
  max-width: 220px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}
.ingestor-raw-output {
  width: calc(100% - 24px);
  margin: 0 12px 12px;
  min-height: min(56vh, 580px);
  max-height: min(56vh, 580px);
  resize: vertical;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #060a12;
  color: #c8d4e8;
}
.ingestor-raw-meta { padding: 0 16px 8px; font-size: 12px; margin: 0; }
.ingestor-log-view { font-size: 11px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border); background: transparent; color: var(--primary); cursor: pointer; }
.ingestor-log-view:hover { background: rgba(56,189,248,0.1); }
.db-table-tag { display: inline-block; padding: 1px 6px; margin: 1px 2px; border-radius: 4px; background: rgba(56,189,248,0.12); color: #7dd3fc; font-size: 10px; }
@media (max-width: 960px) {
  .ingestor-hero { grid-template-columns: 1fr; }
}

.icon-btn.is-active { border-color: var(--primary); color: var(--primary); }

.insights-feed {
  display: grid;
  gap: 10px;
  padding: 4px 0 8px;
}
.insight-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface2);
}
.insight-card header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.insight-card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.insight-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.insight-card footer {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.insight-sev {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.insight-card--watch .insight-sev { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.insight-card--info .insight-sev { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; }
.insight-card--alert .insight-sev { background: rgba(248, 113, 113, 0.18); color: #fca5a5; }
.insight-card--watch { border-left: 3px solid #f59e0b; }
.insight-card--info { border-left: 3px solid #38bdf8; }
.insight-card--alert { border-left: 3px solid #f87171; }
.tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
}
