:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --ink: #18201d;
  --muted: #657069;
  --line: #d8ded7;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --brand: #155e75;
  --brand-2: #0f766e;
  --accent: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 60px rgba(24, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

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

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 22px;
}

.topbar,
.panel-heading,
.topbar-actions,
.status-grid,
.main-grid,
.vote-split {
  display: flex;
  gap: 16px;
}

.topbar {
  align-items: end;
  justify-content: space-between;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.05rem;
}

.topbar-actions {
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.select-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

select,
button,
.button-link {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

select {
  min-width: 120px;
  padding: 0 34px 0 12px;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

button:not(.secondary) {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.secondary {
  background: var(--surface-2);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 16px;
}

.status-grid.compact article strong {
  font-size: 1.2rem;
}

.status-grid article,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.status-grid article {
  padding: 16px;
}

.status-grid span,
.vote-split span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-grid strong {
  display: block;
  margin: 7px 0 3px;
  font-size: 1.55rem;
}

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

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  margin-bottom: 16px;
}

.panel {
  padding: 18px;
}

.governor-panel {
  margin-bottom: 16px;
}

.panel-heading {
  align-items: start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  align-self: start;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--brand);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.leaderboard {
  display: grid;
  gap: 10px;
}

.candidate-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.number {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 800;
}

.candidate-meta {
  min-width: 0;
}

.candidate-name {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.candidate-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-name span {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width 400ms ease;
}

.votes {
  min-width: 104px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.gap-box {
  border-left: 4px solid var(--brand);
  padding: 12px 0 12px 14px;
  margin: 8px 0 18px;
}

.gap-box strong {
  display: block;
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.gap-box span {
  color: var(--muted);
}

.vote-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.vote-split div {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 14px;
}

.vote-split strong {
  display: block;
  margin-top: 6px;
}

.state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 10px;
}

.sections-grid {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  align-items: stretch;
}

.state-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  text-align: left;
}

.state-card strong {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.state-card span,
.state-card small {
  display: block;
  margin-top: 6px;
}

.state-card[data-active="true"] {
  background: #f7fbfa;
  border-color: #8fc7bb;
}

.office-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.forecast-panel {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 4px 0 16px;
  padding: 16px 0;
}

.forecast-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.forecast-header h3 {
  margin: 0;
  font-size: 1rem;
}

.forecast-header p,
.forecast-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.viz-badge {
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.forecast-grid article {
  min-width: 0;
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.forecast-grid span,
.forecast-grid small,
.projection-table small {
  display: block;
  color: var(--muted);
}

.forecast-grid strong {
  display: block;
  margin: 6px 0;
  overflow-wrap: anywhere;
}

.projection-table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

.projection-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.projection-table th,
.projection-table td {
  border-top: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
}

.projection-table th:not(:first-child),
.projection-table td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.office-stats article {
  min-width: 0;
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.office-stats span,
.office-stats small {
  display: block;
  color: var(--muted);
}

.office-stats strong {
  display: block;
  margin: 6px 0;
  overflow-wrap: anywhere;
}

.detailed {
  gap: 14px;
}

.detailed-row {
  grid-template-columns: 52px minmax(0, 1fr) minmax(160px, 220px);
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.wide-votes {
  min-width: 160px;
}

.section-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 84px;
  border-left: 5px solid var(--line);
  cursor: pointer;
  overflow: hidden;
}

button.section-card {
  border-color: var(--line);
  color: var(--ink);
}

button.section-card[data-active="true"] {
  border-left-color: var(--brand-2);
  color: var(--ink);
}

.section-card .section-number {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.section-card .section-info {
  min-width: 0;
}

.section-card .section-info strong {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: #d9efea;
  color: #0d4d49;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 800;
}

.section-card[disabled] .section-info strong {
  background: #ecefed;
  color: var(--muted);
}

.section-card .section-info span {
  display: block;
  margin-top: 7px;
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.section-card .section-info small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.25;
}

button.section-card:disabled {
  cursor: not-allowed;
  background: #f5f6f4;
  color: var(--muted);
  border-left-color: var(--line);
}

.section-dialog {
  width: min(920px, calc(100% - 28px));
  max-height: min(760px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 18px;
}

.section-dialog::backdrop {
  background: rgba(24, 32, 29, 0.32);
}

.dialog-heading,
.section-office-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-heading {
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  padding-bottom: 14px;
}

.dialog-heading p,
.section-office-heading span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

.section-office {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.section-office:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

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

footer {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 10px 2px 0;
}

a {
  color: var(--brand);
}

@media (max-width: 820px) {
  .topbar,
  .main-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: start;
  }

  .topbar-actions {
    justify-content: start;
  }

  .status-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .office-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .forecast-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .status-grid,
  .vote-split {
    grid-template-columns: 1fr;
  }

  .candidate-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .votes {
    grid-column: 2;
    text-align: left;
  }

  .office-stats {
    grid-template-columns: 1fr;
  }

  .forecast-header {
    display: grid;
  }

  .forecast-grid {
    grid-template-columns: 1fr;
  }
}
