:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1c1c1a;
  --muted: #6a6862;
  --line: #e2ded4;
  --accent: #0f6e6a;
  --accent-soft: #dcece9;
  --map-lo: #e4ece8;
  --map-hi: #0a4f4c;
  --map-zero: #efebe3;
  --map-stroke: #ffffff;
  --top-stroke: #c2410c;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 16px rgb(0 0 0 / 0.06);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121413;
    --surface: #1a1d1c;
    --ink: #ecebe6;
    --muted: #a19f97;
    --line: #2d3230;
    --accent: #5cc4bc;
    --accent-soft: #1d3331;
    --map-lo: #1f2a28;
    --map-hi: #7fe3d9;
    --map-zero: #1d201f;
    --map-stroke: #121413;
    --top-stroke: #fb923c;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* Cabeçalho e busca */
header { padding-top: 48px; padding-bottom: 8px; }
.kicker { margin: 0 0 6px; color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
h1 { font-size: clamp(40px, 8vw, 64px); letter-spacing: -0.02em; }
.lede { margin: 8px 0 24px; font-size: 19px; color: var(--muted); max-width: 36em; }
.search { position: relative; }
#q {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  font-size: 18px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
#q:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#suggestions {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
#suggestions li { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
#suggestions li[aria-selected="true"], #suggestions li:hover { background: var(--accent-soft); }
#suggestions .who { font-weight: 600; }
#suggestions .meta { display: block; font-size: 13px; color: var(--muted); }
.hint { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.hint button, .linklike {
  font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}

main { padding-bottom: 32px; }
section { margin-top: 40px; }

/* Candidato */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; }
.card-head h2 { font-size: clamp(28px, 5vw, 38px); }
.badge { font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: var(--map-zero); color: var(--muted); }
.badge.elected { background: var(--accent-soft); color: var(--accent); }
.sub { margin: 6px 0 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
.stat { border-top: 2px solid var(--ink); padding-top: 8px; }
.stat b { display: block; font: 600 clamp(22px, 4.5vw, 30px)/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.story { font-size: 18px; margin: 0 0 8px; }
.story strong { color: var(--accent); }
.share { margin-top: 4px; font-size: 14px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.why { margin: 20px 0 8px; padding: 16px 18px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 12px 12px 0; }
.why h3 { font-size: 20px; margin-bottom: 8px; }
.why ul { margin: 0; padding: 0; list-style: none; }
.why li { padding: 3px 0; }
.why li b { display: inline-block; min-width: 3em; font-variant-numeric: tabular-nums; }
.why p { margin: 8px 0 0; }

.map-box { position: relative; margin: 24px 0 8px; }
.map-box svg { display: block; width: 100%; height: auto; max-height: 560px; }
.map-box path { stroke: var(--map-stroke); stroke-width: 0.5; vector-effect: non-scaling-stroke; }
.map-box path.top { stroke: var(--top-stroke); stroke-width: 2.5; }
.map-box path:hover { stroke: var(--ink); stroke-width: 1.5; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; max-width: 260px;
  padding: 8px 10px; font-size: 13px; line-height: 1.4;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.legend { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend .ramp { width: 140px; height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--map-lo), var(--map-hi)); }
.legend .key-top { display: inline-block; width: 14px; height: 10px; border: 2px solid var(--top-stroke); border-radius: 2px; margin-left: 12px; }

table { width: 100%; border-collapse: collapse; margin-top: 20px; font-size: 15px; }
caption { text-align: left; font: 600 18px var(--serif); padding-bottom: 8px; }
th, td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 13px; font-weight: 600; color: var(--muted); }

/* Rankings */
#rankings h2 { font-size: 30px; }
.controls { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: end; justify-content: space-between; margin: 16px 0 8px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs button {
  font: inherit; font-size: 15px; padding: 7px 14px; border-radius: 99px; cursor: pointer;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line);
}
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.filters { display: flex; gap: 12px; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.filters select { font: inherit; font-size: 15px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.help { color: var(--muted); margin: 8px 0 12px; }
.ranking { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.ranking li { counter-increment: rank; }
.ranking button {
  display: grid; grid-template-columns: 2.2em 1fr; gap: 0 10px; width: 100%; text-align: left;
  font: inherit; color: inherit; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 4px; cursor: pointer;
}
.ranking button:hover { background: var(--surface); }
.ranking button::before { content: counter(rank); grid-row: span 4; font: 600 20px var(--serif); color: var(--muted); font-variant-numeric: tabular-nums; }
.ranking .who { font-weight: 600; }
.ranking .who small { font-weight: 400; color: var(--muted); }
.ranking .what { font-size: 15px; }
.ranking .tag { font-size: 13px; color: var(--accent); }
.ranking .tag:empty { display: none; }
.insight { margin: 10px 0 0; padding: 12px 16px; font-size: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.insight strong { color: var(--accent); }
.ranking .bar { height: 6px; margin-top: 6px; border-radius: 99px; background: var(--map-zero); overflow: hidden; }
.ranking .bar i { display: block; height: 100%; background: var(--accent); }

footer { padding-top: 24px; padding-bottom: 48px; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
footer h2 { font-size: 20px; color: var(--ink); margin-bottom: 8px; }

@media (max-width: 560px) {
  header { padding-top: 32px; }
  .card { padding: 18px 16px; border-radius: 12px; }
  .stats { gap: 8px; }
  .filters { width: 100%; }
  .filters label { flex: 1; }
  .filters select { width: 100%; }
  table { font-size: 14px; }
}
