:root {
  /* NossaTV — Manual de Identidade Visual */
  --terracota: #C9541A;
  --terracota-dark: #a8420f;
  --terracota-light: #e06832;
  --areia: #F2E8D9;
  --noite: #1A1A2E;
  --noite-mid: #2e2e4a;
  --amarelo: #F5A623;

  --bg: #FBF4EA;
  --surface: #FEFAF6;
  --surface-2: #F2E8D9;
  --ink: #1A1A2E;
  --ink-2: #3a3850;
  --muted: #625c6e;
  --line: #E7DAC6;
  --accent: #a8420f;
  --map-stroke: #FEFAF6;
  --map-empty: #E2D0B8;
  --focus: #C9541A;
  --ok: #1d6b3a;
  --ok-bg: #e3f1e5;
  --warn: #8a3a0c;
  --warn-bg: #fbe3d3;
  --shadow: 0 1px 2px rgba(26, 26, 46, .06), 0 6px 18px rgba(26, 26, 46, .07);
  --radius: 14px;
  --font: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Barlow Condensed", "Arial Narrow", sans-serif;
  --semi: "Barlow Semi Condensed", "Arial Narrow", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14142a; --surface: #1A1A2E; --surface-2: #2e2e4a; --ink: #F2E8D9; --ink-2: #ddd0be;
    --muted: #a9a2b8; --line: #34344f; --accent: #f0864e; --map-stroke: #1A1A2E; --map-empty: #2e2e4a;
    --focus: #F5A623; --ok: #7ed79a; --ok-bg: #173a24; --warn: #ffb27f; --warn-bg: #45210c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14142a; --surface: #1A1A2E; --surface-2: #2e2e4a; --ink: #F2E8D9; --ink-2: #ddd0be;
  --muted: #a9a2b8; --line: #34344f; --accent: #f0864e; --map-stroke: #1A1A2E; --map-empty: #2e2e4a;
  --focus: #F5A623; --ok: #7ed79a; --ok-bg: #173a24; --warn: #ffb27f; --warn-bg: #45210c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); margin: 0; letter-spacing: -.01em; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -40px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { top: 8px; }
.muted { color: var(--muted); }
.pad { padding: 20px; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* Header (faixa "noite" da NossaTV) */
.top { background: var(--noite); color: var(--areia); position: relative; overflow: hidden; }
.top::before { content: ""; position: absolute; right: -120px; top: -160px; width: 420px; height: 420px; border-radius: 50%; background: var(--noite-mid); opacity: .55; }
.top > .wrap { position: relative; }
.brandbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 12px; border-bottom: 1px solid rgba(242, 232, 217, .12); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--areia); text-decoration: none; }
.brand img { display: block; width: 34px; height: 34px; }
.wordmark { font-family: var(--serif); font-weight: 700; font-size: 24px; letter-spacing: -.01em; line-height: 1; text-transform: lowercase; }
.wordmark b { color: var(--terracota-light); font-weight: 800; }
.brand-tag { font-family: var(--semi); font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: rgba(242, 232, 217, .6); }
.top-inner { display: flex; gap: 16px 24px; align-items: flex-end; justify-content: space-between; padding-top: 22px; padding-bottom: 22px; flex-wrap: wrap; }
.kicker { margin: 0 0 6px; font-family: var(--semi); font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--amarelo); }
h1 { font-size: clamp(32px, 5.4vw, 54px); line-height: .95; text-transform: uppercase; font-weight: 800; color: var(--areia); }
h1 em { font-style: normal; color: var(--terracota-light); }
.badge { display: inline-flex; align-items: center; gap: 8px; margin: 14px 0 0; padding: 4px 12px 4px 10px; border-radius: 999px; background: rgba(242, 232, 217, .1); color: var(--areia); font-family: var(--semi); font-size: 14px; font-weight: 600; letter-spacing: .02em; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #5fd38a; box-shadow: 0 0 0 3px rgba(95, 211, 138, .25); }
.badge.partial .dot { background: var(--amarelo); box-shadow: 0 0 0 3px rgba(245, 166, 35, .25); }

.search { position: relative; width: min(340px, 100%); }
.search input { width: 100%; padding: 11px 14px 11px 38px; border: 1px solid rgba(242, 232, 217, .18); border-radius: 10px; color: var(--areia); background: rgba(242, 232, 217, .08) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23cfc3b2' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") no-repeat 12px 50%; }
.search input::placeholder { color: rgba(242, 232, 217, .6); }
.search input:focus { border-color: var(--terracota-light); background-color: rgba(242, 232, 217, .12); }
.search ul { color: var(--ink); }
.search ul { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 300px; overflow: auto; }
.search li { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.search li small { color: var(--muted); }
.search li[aria-selected="true"], .search li:hover { background: var(--surface-2); }

/* Tabs */
.tabs { display: flex; gap: 6px; padding-top: 16px; padding-bottom: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 7px 18px; font-family: var(--serif); font-size: 18px; letter-spacing: .02em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; font-weight: 500; color: var(--ink-2); }
.tab[aria-selected="true"] { background: var(--terracota); border-color: var(--terracota); color: #fff; font-weight: 700; }
.tab:hover:not([aria-selected="true"]) { border-color: var(--muted); }

/* Layout */
.grid { display: grid; grid-template-columns: minmax(0, 55fr) minmax(0, 45fr); gap: 16px; padding-top: 12px; padding-bottom: 16px; align-items: start; }
.map-card, .panel, .table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.map-card { padding: 16px; position: sticky; top: 12px; }
.map-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.map-head h2 { font-size: 22px; text-transform: uppercase; font-weight: 700; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .45; cursor: default; }

.map-box { position: relative; }
#mapa { display: block; width: 100%; height: auto; }
#mapa path { stroke: var(--map-stroke); stroke-width: .7; stroke-linejoin: round; cursor: pointer; transition: fill .2s, fill-opacity .2s; vector-effect: non-scaling-stroke; }
#mapa path:hover, #mapa path:focus { stroke: var(--ink); stroke-width: 1.6; outline: none; }
#mapa path.sel { stroke: var(--ink); stroke-width: 2.4; }
#mapa.dim path:not(.sel) { opacity: .8; }
.tip { position: absolute; z-index: 10; pointer-events: none; background: var(--ink); color: var(--surface); padding: 8px 10px; border-radius: 8px; font-size: 13px; line-height: 1.35; max-width: 260px; box-shadow: var(--shadow); transform: translate(-50%, calc(-100% - 12px)); }
.tip b { display: block; font-size: 14px; }
.tip i { font-style: normal; opacity: .75; }

.legend { margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.legend .items { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.legend .ramp { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); flex-wrap: wrap; }
.legend .ramp span.r { display: inline-flex; }
.legend .ramp span.r i { width: 26px; height: 10px; background: var(--ink-2); }
.legend .ramp span.r i:first-child { border-radius: 3px 0 0 3px; }
.legend .ramp span.r i:last-child { border-radius: 0 3px 3px 0; }
.legend .note { margin: 6px 0 0; color: var(--muted); }

/* Panel */
.panel { min-height: 300px; }
.sheet-bar { display: none; }
.p-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.p-head .crumb { font-family: var(--semi); font-size: 13px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin: 0 0 2px; }
.p-head h2 { font-size: 34px; line-height: 1; text-transform: uppercase; font-weight: 800; }
.p-head { border-top: 4px solid var(--terracota); border-radius: var(--radius) var(--radius) 0 0; }
.p-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.stat { background: var(--surface); padding: 10px 14px; }
.stat dt { font-size: 12px; color: var(--muted); }
.stat dd { margin: 0; font-weight: 600; font-size: 16px; }
.stat dd small { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }

.cands { padding: 8px 12px 16px; }
.c-tools { display: flex; gap: 8px; align-items: center; padding: 12px 8px 4px; flex-wrap: wrap; }
.c-tools input { flex: 1 1 180px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--noite); color: var(--areia); }
.colhead { display: grid; grid-template-columns: 1fr auto; padding: 8px 8px 4px; font-size: 12px; color: var(--muted); }
ol.list { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .nm { font-family: var(--semi); font-size: 16px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.row .nm .pos { color: var(--muted); font-weight: 500; margin-right: 6px; }
.row .meta { grid-column: 1; font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.row .num { text-align: right; grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.row .num strong { display: block; font-family: var(--serif); font-size: 24px; font-weight: 700; line-height: 1.05; }
.row .num span { font-size: 12.5px; color: var(--muted); }
.row .bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; position: relative; margin-top: 4px; }
.row .bar i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; }
.row .bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .7; }
.cmp { font-weight: 600; }
.cmp.up { color: var(--ok); }
.cmp.down { color: var(--warn); }
.chip { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 18px; }
.chip.eleito { background: var(--ok-bg); color: var(--ok); }
.chip.turno { background: var(--warn-bg); color: var(--warn); }
.chip.anul { background: var(--surface-2); color: var(--muted); }
.sw-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.more { display: flex; gap: 8px; justify-content: center; padding: 14px 0 0; flex-wrap: wrap; }
.empty { padding: 20px 8px; color: var(--muted); }
.p-foot { padding: 0 20px 16px; font-size: 12.5px; color: var(--muted); }

/* Tabela */
.table-card { padding: 16px 0 8px; margin-top: 4px; margin-bottom: 16px; }
.table-head { padding: 0 16px 10px; display: flex; justify-content: space-between; gap: 8px 16px; align-items: baseline; flex-wrap: wrap; }
.table-head h2 { font-size: 26px; text-transform: uppercase; font-weight: 800; }
.table-head p { margin: 0; font-size: 13px; }
.table-scroll { overflow-x: auto; max-height: 560px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface); font-size: 12.5px; color: var(--muted); font-weight: 600; z-index: 1; }
th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
th button:focus-visible { outline: 3px solid var(--focus); }
td.n, th.n { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.sel { background: var(--surface-2); }
td a { color: inherit; text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }

.foot { background: var(--noite); color: rgba(242, 232, 217, .75); padding: 28px 0 40px; font-size: 13px; margin-top: 8px; }
.foot a { color: var(--terracota-light); }
.foot strong { color: var(--areia); }
.foot-brand { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(242, 232, 217, .12); }
.foot-brand .wordmark { color: var(--areia); font-size: 20px; }
.foot-brand p { margin: 0; }
.foot p { margin: 0 0 8px; max-width: 900px; }

/* Mobile */
@media (max-width: 860px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .map-card { position: static; padding: 12px; }
  body.sheet { overflow: hidden; }
  body.sheet .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 82vh; overflow-y: auto;
    border-radius: 18px 18px 0 0; border-bottom: 0; box-shadow: 0 -8px 40px rgba(0, 0, 0, .25);
    animation: up .22s ease-out; overscroll-behavior: contain;
  }
  body.sheet .sheet-bar { display: flex; position: sticky; top: 0; z-index: 2; background: var(--surface); justify-content: flex-end; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line); }
  body.sheet .sheet-bar .grip { position: absolute; left: 50%; top: 8px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line); }
  body.sheet::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 35; }
  .p-head h2 { font-size: 21px; }
}
@keyframes up { from { transform: translateY(40%); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
