:root { color-scheme: light; }
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, system-ui, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f8fafc;
  color: #111827;
}
.container { max-width: 72rem; margin: 0 auto; padding: 1.5rem; }
.mb { margin-bottom: 1rem; }
.h1 { font-size: 1.75rem; font-weight: 700; margin: 0; }
.muted { color: #6b7280; }
.tiny { font-size: 12px; }

/* Legislature Toggle */
.legislature-toggle {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.toggle-buttons {
  display: inline-flex;
  background: #eef2f7;
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.toggle-btn {
  padding: 0.6rem 1.5rem;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: #6b7280;
  transition: all 0.2s ease;
}

.toggle-btn:hover:not(.active) {
  background: #dde3eb;
  color: #374151;
}

.toggle-btn.active {
  background: #111;
  color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Controls */
.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
  margin-bottom: .75rem;
}
@media (max-width: 900px) { .controls { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .controls { grid-template-columns: 1fr; } }

.control label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .25rem; }
.control input, .control select {
  width: 100%; padding: .5rem .75rem; border: 1px solid #d1d5db; border-radius: 8px; background: #fff;
}
.buttons { display: flex; align-items: end; gap: .5rem; }
.btn {
  padding: .55rem 1rem; border-radius: 10px; border: 1px solid #111; background: #111; color: #fff; cursor: pointer;
  font-weight: 500;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.9; }
.btn.secondary { background: #fff; color: #111; border-color: #d1d5db; }
.btn.secondary:hover { background: #f9fafb; }
.btn:disabled { opacity: .6; cursor: default; }

/* Card and Table */
.card { background: #fff; border-radius: 16px; box-shadow: 0 6px 18px rgba(0,0,0,.06); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  position: sticky; top: 0; background: #eef2f7; text-align: left; padding: .75rem 1rem; white-space: nowrap; cursor: pointer;
}
thead th:hover { background: #e2e8f0; }
tbody td { padding: .75rem 1rem; border-top: 1px solid #eef2f7; }
tbody tr:hover { background: #f8fafc; }
.right { text-align: right; }
.th-sort { user-select: none; }

/* Summary */
.summary {
  background: #eef2f7;
  padding: .75rem 1rem;
  border-radius: 8px;
  font-size: 14px;
  margin-top: 1rem;
}

/* Party Stats Cards */
.party-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 700px) { .party-stats { grid-template-columns: 1fr; } }

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border-left: 4px solid #9ca3af;
}
.stat-card.dem { border-left-color: #3b82f6; }
.stat-card.rep { border-left-color: #ef4444; }
.stat-card.overall { border-left-color: #8b5cf6; }

.stat-party {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: #374151;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 0.25rem 0;
}
.stat-label { color: #6b7280; }
.stat-value { font-weight: 600; color: #111827; }

/* Leaderboards */
.leaderboards {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.leaderboard-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.lb-tab {
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: #6b7280;
  transition: all 0.15s ease;
}
.lb-tab:hover { background: #f9fafb; color: #374151; }
.lb-tab.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.leaderboard-list {
  margin: 0;
  padding: 0 0 0 1.5rem;
  font-size: 0.95rem;
}
.leaderboard-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #eef2f7;
}
.leaderboard-list li:last-child { border-bottom: none; }
.lb-name { font-weight: 600; }
.lb-party { color: #6b7280; font-size: 0.85rem; }
.lb-value { float: right; font-weight: 600; color: #111; }
.lb-party.dem { color: #3b82f6; }
.lb-party.rep { color: #ef4444; }

/* Section titles */
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  color: #374151;
}

/* Timeline Section */
.timeline-section {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.timeline-chart-container {
  height: 300px;
  position: relative;
}

/* Network Section */
.network-section {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.network-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.network-controls label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #6b7280;
}

.network-controls select {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  background: #fff;
  color: #111827;
}

.network-zoom-controls {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  min-width: 32px;
}

.network-hint {
  margin-top: 0.5rem;
  text-align: center;
}

.network-container {
  height: 500px;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  overflow: hidden;
  background: #fafbfc;
}

/* Network graph styles */
.network-container svg {
  width: 100%;
  height: 100%;
}

.network-node {
  cursor: pointer;
}

.network-node circle {
  stroke: #fff;
  stroke-width: 2px;
}

.network-node.dem circle { fill: #3b82f6; }
.network-node.rep circle { fill: #ef4444; }
.network-node.other circle { fill: #9ca3af; }

.network-node text {
  font-size: 10px;
  fill: #374151;
  pointer-events: none;
}

.network-link {
  stroke: #d1d5db;
  stroke-opacity: 0.6;
}

.network-node:hover circle {
  stroke: #111;
  stroke-width: 3px;
}

/* Tooltip for network */
.network-tooltip {
  position: absolute;
  background: #111;
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}
