:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-strong: #f9faf8;
  --text: #17211b;
  --muted: #657268;
  --line: #dfe5dc;
  --green: #16814a;
  --green-dark: #0c5c35;
  --yellow: #f3c53c;
  --blue: #1c6aa9;
  --red: #bd3a3a;
  --shadow: 0 18px 55px rgba(24, 38, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(135deg, rgba(22, 129, 74, 0.14), transparent 32%),
    linear-gradient(315deg, rgba(28, 106, 169, 0.14), transparent 36%),
    var(--bg);
  color: var(--text);
}

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

.topbar,
.summary-grid,
.content-grid {
  display: grid;
  gap: 16px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1;
  letter-spacing: 0;
}

.brand-link {
  display: inline-block;
  margin-top: 10px;
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.brand-link:visited,
.brand-link:hover,
.brand-link:active,
.brand-link:focus {
  color: #fff;
  text-decoration: none;
}

.brand-link:hover,
.brand-link:focus {
  background: #15588f;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--yellow);
}

.status.ok .status-dot {
  background: var(--green);
}

.status.error .status-dot {
  background: var(--red);
}

.filters,
.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(140px, 180px);
  align-items: end;
  justify-content: start;
}

.filters label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.filters select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.metric,
.progress-panel,
.leader-panel,
.table-panel,
.governor-map-panel,
.president-chart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 126px;
  padding: 18px;
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.metric-label,
.panel-heading,
.footer {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1;
}

.refresh-button {
  width: max-content;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.refresh-button:hover {
  background: var(--green-dark);
}

.progress-panel {
  padding: 18px;
  margin-bottom: 16px;
}

.progress-header,
.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.progress-header {
  margin-bottom: 10px;
  font-weight: 700;
}

.progress-track {
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #d9e2d8;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 380ms ease;
}

.content-grid {
  grid-template-columns: minmax(280px, 380px) 1fr;
}

.leader-panel,
.table-panel,
.governor-map-panel,
.president-chart-panel {
  overflow: hidden;
}

.panel-heading {
  min-height: 48px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
  font-weight: 700;
}

.leader-card {
  min-height: 230px;
  padding: 22px;
  display: grid;
  align-content: center;
  gap: 18px;
}

.leader-card.empty,
.empty-row {
  color: var(--muted);
  text-align: center;
}

.leader-number {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
}

.leader-name {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.04;
}

.leader-party {
  color: var(--muted);
  font-weight: 700;
}

.leader-percent {
  font-size: 56px;
  line-height: 1;
  font-weight: 800;
  color: var(--green-dark);
}

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

.state-progress {
  border-top: 1px solid var(--line);
  padding: 16px 18px 18px;
}

.state-progress-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.state-progress-list {
  max-height: 430px;
  overflow: auto;
  display: grid;
  gap: 10px;
  padding-right: 4px;
}

.state-row {
  display: grid;
  grid-template-columns: 34px 1fr 58px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 800;
}

.state-bar {
  display: block;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #d9e2d8;
}

.state-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.state-row.complete .state-bar-fill {
  background: var(--green-dark);
}

.state-percent {
  text-align: right;
  color: var(--muted);
}

.governor-map-panel {
  margin-top: 16px;
}

.president-chart-panel {
  margin-top: 16px;
}

.president-chart-panel[hidden] {
  display: none;
}

.governor-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.state-tile {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-content: start;
  align-items: start;
  background: linear-gradient(180deg, #ffffff, #eef5f0);
}

.state-tile.empty {
  opacity: 0.54;
}

.state-tile-uf {
  grid-row: span 3;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green-dark);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
}

.state-tile-region {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.state-tile-name {
  color: var(--green-dark);
  font-size: 14px;
  line-height: 1.12;
  font-weight: 900;
}

.state-tile-party,
.state-tile-percent {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.state-tile-percent {
  color: var(--blue);
}

.chart-wrap {
  padding: 18px;
}

.line-chart-empty {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.line-chart-svg {
  width: 100%;
  min-height: 320px;
  display: block;
}

.chart-grid-line {
  stroke: #dfe5dc;
  stroke-width: 1;
}

.chart-axis-text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-line {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot {
  stroke: #fff;
  stroke-width: 2;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chart-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 15px;
}

td:nth-child(1),
td:nth-child(4),
td:nth-child(5),
th:nth-child(1),
th:nth-child(4),
th:nth-child(5) {
  text-align: right;
}

.candidate-name {
  font-weight: 800;
}

.candidate-sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.footer {
  margin-top: 18px;
  text-align: center;
}

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

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

  .status {
    width: max-content;
  }
}

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

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

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

  .metric {
    min-height: 104px;
  }

  .progress-header,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
