:root {
  --bg: #f8f9fa;
  --fg: #1a1a2e;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea580c;
  --card-bg: #fff;
  --diff-add: #dcfce7;
  --diff-rm: #fee2e2;
  --radius: 10px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

.site-header {
  padding: 2rem 0 1rem;
}

.site-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.site-brand {
  color: var(--fg);
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.15rem;
}

.stats {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  color: var(--muted);
  font-size: 0.75rem;
}

.stat-source {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.stat--median {
  padding: 0.55rem 0.8rem;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  background: #eef2ff;
}

.stat--median .stat-value {
  color: #1d4ed8;
}

.stat--median-secondary {
  background: #f8fbff;
  border-color: #dbeafe;
}

.landing-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  margin: 1.5rem 0 1rem;
  overflow-x: auto;
}

.landing-tabs button,
.landing-tabs a {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  font-weight: 500;
}

.landing-tabs button.active,
.landing-tabs a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.landing-tabs button:hover:not(.active),
.landing-tabs a:hover {
  color: var(--fg);
  text-decoration: none;
}

.landing-section {
  display: none;
}

.landing-section.active {
  display: block;
}

.section-note,
.section-cta,
.result-count,
.breadcrumb,
.function,
.source-link,
.pol-meta,
.item-detail,
.section-empty,
.change-detail,
.detail-summary {
  color: var(--muted);
  font-size: 0.85rem;
}

.section-note {
  margin-bottom: 0.75rem;
}

.highlight-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
}

.highlight-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

.highlight-card:hover {
  border-color: var(--accent);
}

.highlight-card a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  color: inherit;
}

.hl-left {
  flex: 1;
  min-width: 0;
}

.hl-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.hl-meta {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hl-right {
  text-align: right;
  flex-shrink: 0;
  margin-left: 1rem;
}

.hl-big {
  font-size: 1.1rem;
  font-weight: 700;
}

.hl-big.positive {
  color: var(--green);
}

.hl-big.negative {
  color: var(--red);
}

.hl-big.neutral {
  color: var(--fg);
}

.hl-small {
  font-size: 0.75rem;
  color: var(--muted);
}

.hl-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  margin-left: 0.5rem;
}

.badge-up {
  background: #dcfce7;
  color: #15803d;
}

.badge-down {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-year {
  background: #e0e7ff;
  color: #3730a3;
}

.explainer {
  margin-top: 0.85rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.82rem;
  line-height: 1.5;
}

.explainer summary {
  cursor: pointer;
  font-weight: 600;
  color: #4338ca;
}

.explainer p {
  margin-top: 0.4rem;
}

.controls {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
}

.search-box input {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
}

.search-box input:focus,
.sort-select select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.sort-select select,
.year-tabs button {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  font-size: 0.85rem;
  cursor: pointer;
}

.politician-list {
  list-style: none;
}

.person-row__link {
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.4rem;
  transition: border-color 0.15s;
  color: inherit;
}

.person-row__link:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.pol-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.pol-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.pol-right {
  text-align: right;
}

.pol-income {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
}

.pol-pct-bar {
  width: 72px;
  height: 6px;
  margin-top: 4px;
  margin-left: auto;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.pol-pct-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.pol-pct-fill.high {
  background: var(--green);
}

.pol-pct-fill.top {
  background: var(--orange);
}

.pol-indicators {
  display: flex;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: var(--muted);
  justify-content: flex-end;
  margin-top: 2px;
}

.list-more {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  text-align: center;
  cursor: default;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.detail-header {
  margin-bottom: 1.25rem;
}

.detail-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.detail-switch {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}

.detail-switch__button {
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.detail-switch__button.is-active {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent);
}

.detail-mode[hidden] {
  display: none;
}

.function {
  font-size: 0.9rem;
}

.source-link {
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.year-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.year-tabs button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.context-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.ctx-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  padding: 0.8rem 0.9rem;
}

.ctx-item--median {
  border-color: #c7d2fe;
  background: #f8fbff;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.08);
}

.ctx-val {
  font-size: 1.15rem;
  font-weight: 700;
}

.ctx-label {
  margin-top: 0.15rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.ctx-rank {
  margin-top: 0.45rem;
  font-size: 0.76rem;
  color: var(--muted);
}

.ctx-item--median .ctx-val {
  color: #1d4ed8;
}

.ctx-meter {
  width: 100%;
  height: 6px;
  margin-top: 0.45rem;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.ctx-meter__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.ctx-meter__fill.high {
  background: var(--green);
}

.section {
  margin-bottom: 1.25rem;
}

.section h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.section-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
}

.section-empty {
  font-style: italic;
}

.data-row {
  display: flex;
  padding: 0.3rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.data-row:last-child {
  border-bottom: none;
}

.data-label {
  width: 180px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.data-value {
  flex: 1;
}

.data-old {
  color: var(--red);
  text-decoration: line-through;
  font-size: 0.8rem;
  margin-right: 0.5rem;
}

.items-list {
  list-style: none;
}

.items-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.items-list li:last-child {
  border-bottom: none;
}

.item-role {
  font-weight: 500;
  font-size: 0.875rem;
}

.income-chart-wrap {
  position: relative;
}

.income-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 140px;
  padding-top: 10px;
}

.income-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
}

.bar-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 56px;
  margin: 0 auto;
}

.income-bar {
  width: 100%;
  max-width: 56px;
  border-radius: 4px 4px 0 0;
  min-height: 3px;
  transition: height 0.3s;
}

.income-bar.pub {
  background: var(--accent);
}

.income-bar.other {
  background: #93c5fd;
  border-radius: 4px 4px 0 0;
}

.income-bar-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

.income-bar-value {
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 3px;
}

.median-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dashed #94a3b8;
  pointer-events: none;
}

.median-label {
  position: absolute;
  right: 0;
  padding: 0.1rem 0.45rem;
  border: 1px solid #dbeafe;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #475569;
  font-size: 0.68rem;
  font-weight: 700;
  transform: translateY(-50%);
}

.timeline-entry {
  padding: 0.6rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.timeline-entry:last-child {
  border-bottom: none;
}

.timeline-year {
  font-weight: 700;
  font-size: 0.9rem;
}

.timeline-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 1px 8px;
  border-radius: 4px;
  margin-left: 0.4rem;
  font-weight: 600;
}

.badge-new {
  background: #dcfce7;
  color: #15803d;
}

.badge-changed {
  background: #fef3c7;
  color: #92400e;
}

.badge-unchanged {
  background: #f1f5f9;
  color: var(--muted);
}

.change-detail {
  margin-top: 0.3rem;
  color: var(--fg);
}

.change-detail .field-name {
  font-weight: 500;
}

.change-detail .old-val {
  color: var(--red);
}

.change-detail .new-val {
  color: var(--green);
}

.timeline-compare-link {
  margin-top: 0.45rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.timeline-compare-link:hover {
  text-decoration: underline;
}

.compare-intro {
  margin-bottom: 0.9rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid #dbeafe;
  border-radius: var(--radius);
  background: #f8fbff;
  color: var(--muted);
  font-size: 0.84rem;
}

.compare-selectors {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.compare-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 140px;
}

.compare-field span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.compare-field select {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  font-size: 0.9rem;
  font-weight: 600;
}

.compare-arrow {
  padding-bottom: 0.5rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.compare-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.compare-summary-card,
.compare-col {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
}

.compare-card-eyebrow,
.compare-section-title {
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.compare-summary-card h3 {
  margin-bottom: 0.6rem;
  font-size: 1.05rem;
}

.compare-card-metrics {
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.compare-card-metrics li,
.compare-data-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.84rem;
}

.compare-section {
  margin-bottom: 1rem;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.compare-col.diff-old {
  border-left: 3px solid #d97777;
}

.compare-col.diff-new {
  border-left: 3px solid var(--green);
}

.compare-item-title {
  font-weight: 600;
  font-size: 0.85rem;
}

.compare-item-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.compare-data-block {
  display: grid;
  gap: 0.4rem;
}

.compare-data-row--total {
  padding-top: 0.35rem;
  border-top: 1px solid #e5e7eb;
  font-weight: 700;
}

.compare-data-row--delta strong {
  font-weight: 700;
}

.compare-col .item-added,
.compare-col .item-removed,
.compare-col .item-same {
  padding: 0.4rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.compare-col .item-added:last-child,
.compare-col .item-removed:last-child,
.compare-col .item-same:last-child {
  border-bottom: 0;
}

.compare-col .item-added {
  background: var(--diff-add);
  margin: 0 -0.45rem;
  padding: 0.4rem 0.45rem;
  border-radius: 6px;
}

.compare-col .item-removed {
  background: var(--diff-rm);
  margin: 0 -0.45rem;
  padding: 0.4rem 0.45rem;
  border-radius: 6px;
  opacity: 0.8;
}

.compare-delta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.compare-delta.up {
  background: rgba(22, 163, 74, 0.14);
  color: #15803d;
}

.compare-delta.down {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

.compare-delta.flat {
  background: rgba(100, 116, 139, 0.12);
  color: var(--muted);
}

.empty-state {
  color: var(--muted);
  font-style: italic;
}

.site-footer {
  padding-top: 1rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .data-row {
    flex-direction: column;
  }

  .data-label {
    width: auto;
  }

  .controls {
    flex-direction: column;
  }

  .stats {
    flex-wrap: wrap;
  }

  .person-row__link {
    display: block;
  }

  .pol-right {
    text-align: left;
    margin-top: 0.35rem;
  }

  .pol-pct-bar {
    margin-left: 0;
  }

  .pol-indicators {
    justify-content: flex-start;
  }

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