:root {
  --bg: #f6f6f4; --panel: #fff; --text: #1d1d1f; --muted: #6b6b70; --line: #e3e3e0;
  --up: #1a7f37; --down: #c62828; --hi: #fff7d6;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16171a; --panel: #1f2024; --text: #ececee; --muted: #9a9aa2; --line: #33343a;
          --up: #5bd37a; --down: #ff7b7b; --hi: #3a3422; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { padding: 20px 24px 8px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 12px 0 0; }
.sub, .hint, footer { color: var(--muted); }
.hint { font-size: 12px; margin: 8px 0 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
         margin: 12px 24px; padding: 14px 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 10px; }
.toolbar label { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
select, input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
                border-radius: 6px; padding: 4px 8px; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.ccaa td { background: var(--bg); font-weight: 600; font-size: 12px; color: var(--muted); padding-top: 10px; }
td.prov { white-space: nowrap; font-weight: 500; }
td.pred { background: var(--hi); }
td.vacio { color: var(--muted); text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 3px; min-width: 120px; }
.chip { display: inline-flex; align-items: center; gap: 3px; border-radius: 4px; padding: 1px 5px 1px 3px;
        font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; border: 1px solid var(--line); }
.chip i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.chip.up { border-color: var(--up); }
.chip.down { border-color: var(--down); }
.chip sup { font-size: 10px; margin-left: 1px; }
.chip.up sup { color: var(--up); } .chip.down sup { color: var(--down); }
#nacional td.party { white-space: nowrap; font-weight: 500; }
#nacional td.party i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 6px; }
#nacional tr.total td { font-weight: 700; }
#nacional td.sel, #nacional th.sel { background: var(--hi); }
footer { padding: 4px 24px 24px; font-size: 12px; }
@media (max-width: 640px) { .panel { margin: 10px 8px; padding: 10px; } header { padding: 14px 10px 4px; } }

/* Mapa */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; color: var(--text); background: var(--panel); border: 0; border-right: 1px solid var(--line);
              padding: 4px 10px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--text); color: var(--panel); }
.seg button:disabled { color: var(--muted); cursor: default; opacity: .55; }
select:disabled { opacity: .5; }
.mapa-wrap { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .mapa-wrap { grid-template-columns: 1fr; } }
#mapa svg { width: 100%; height: auto; display: block; }
#mapa path.prov { stroke: var(--panel); stroke-width: .8; cursor: pointer; fill: var(--line); transition: fill .2s; }
#mapa path.prov:hover { stroke: var(--text); stroke-width: 1.2; }
#mapa path.prov.sel { stroke: var(--text); stroke-width: 2.2; }
#mapa path.prov.sin { fill: var(--line); }
#mapa path.borde-canarias { fill: none; stroke: var(--muted); stroke-width: .8; }
.leyenda { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; margin-top: 6px; align-items: center; }
.leyenda i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px; vertical-align: -1px; }
.leyenda small { color: var(--muted); flex-basis: 100%; }
#panel h3 { margin: 0; font-size: 18px; }
#panel .meta { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }
#panel table { margin-bottom: 10px; }
#panel td, #panel th { padding: 4px 6px; }
#panel table.part td:first-child { color: var(--muted); }
#panel td.party { white-space: nowrap; }
#panel td.party i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 6px; }
#panel .ultimo { background: var(--hi); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
#panel a { color: inherit; }
