:root {
  --bg: #0f1419;
  --panel: #161d26;
  --ink: #e8eef5;
  --muted: #8b9bb0;
  --line: #2a3644;
  --lula: #c0392b;
  --bolso: #1e6bb8;
  --empate: #9a8b4f;
  --accent: #3d9a6a;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template-columns: 320px 1fr;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 1rem 1.1rem 1.5rem;
  overflow-y: auto;
  z-index: 500;
}
.brand {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}
.star13 {
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 6px rgba(192, 57, 43, 0.45));
}
.panel h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: #f0e6c8;
}
.sub { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.78rem; }

.contato-wa {
  display: block;
  margin: -0.35rem 0 0.85rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid #1f6b45;
  border-radius: 8px;
  background: #0f2a1c;
  color: #9de0b8;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
}
.contato-wa:hover {
  background: #143524;
  color: #c8f5d8;
  border-color: #2e8b57;
}

.helpbox {
  background: #0f1419;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.78rem;
  color: #b7c4d4;
}
.helpbox summary {
  cursor: pointer;
  padding: 0.55rem 0.75rem;
  font-weight: 600;
  color: #f0e6c8;
  list-style: none;
}
.helpbox summary::-webkit-details-marker { display: none; }
.helpbox summary::before {
  content: "▸ ";
  color: #c0392b;
}
.helpbox[open] summary::before { content: "▾ "; }
.helpbody {
  padding: 0 0.75rem 0.75rem;
  line-height: 1.4;
  border-top: 1px solid var(--line);
}
.helpbody p { margin: 0.55rem 0 0.25rem; }
.helpbody ul {
  margin: 0.2rem 0 0;
  padding-left: 1.1rem;
}
.helpbody li { margin: 0.2rem 0; }
.helpbody em { color: #e8eef5; font-style: normal; font-weight: 600; }
.hint {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: #6a7888;
  line-height: 1.35;
}

section { margin-bottom: 1rem; }
label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
select, input[type="range"] { width: 100%; }
select {
  background: #0f1419;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.5rem;
}

.geo-box {
  background: #0f1419;
  border: 1px solid #5c1a16;
  border-radius: 8px;
  padding: 0.7rem 0.75rem 0.85rem;
  margin-bottom: 1rem;
}
.geo-btns { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.4rem 0 0.5rem; }
.geo-btns button, .chips button {
  background: #0f1419;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  font-size: 0.76rem;
  cursor: pointer;
}
.geo-btns button { border-color: #c0392b; color: #f0e6c8; }
.geo-btns button.ghost { border-color: var(--line); color: var(--muted); }
.geo-btns button:hover { background: #5c1a16; }
.geo-btns button.active-pick { background: #7a2420; color: #fff; }
#geoResumo { margin-top: 0.6rem; margin-bottom: 0; }
#raioWrap { margin: 0.45rem 0 0.7rem; }
#drawTools { margin-top: 0.15rem; }
.draw-banner {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 850;
  background: rgba(30,122,70,0.94);
  color: #e8f8ee;
  border: 1px solid #2e8b57;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}
.popup-secao { font-size: 0.82rem; line-height: 1.35; }
.voto-bar {
  height: 8px;
  border-radius: 4px;
  background: #1e6bb8;
  overflow: hidden;
  margin: 0.4rem 0 0.3rem;
}
.voto-bar .voto-l { display: block; height: 100%; background: #c0392b; }
.leaflet-popup-content-wrapper { background: #161d26; color: #e8eef5; }
.leaflet-popup-tip { background: #161d26; }
.leaflet-popup-content .l { color: #e0746a; }
.secao-canvas { position: absolute; left: 0; top: 0; pointer-events: none; }

.leaflet-pane .secao-dot { }

.chips.view-switch { margin-bottom: 0.85rem; }
.chips.view-switch button { font-weight: 600; }
.chips.view-switch button.on {
  background: #5c1a16;
  border-color: #c0392b;
  color: #f0e6c8;
}
.frente-lista { display: flex; flex-direction: column; gap: 0.35rem; max-height: 42vh; overflow: auto; }
.frente-lista button {
  text-align: left;
  background: #0f1419;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-size: 0.76rem;
  cursor: pointer;
}
.frente-lista button.on { border-color: #c0392b; background: #1c1414; }
.frente-lista .tag { display: inline-block; font-size: 0.68rem; color: var(--muted); }
.chat-box { margin: 0.7rem 0 1rem; }
.chat-box input, .chat-box textarea {
  width: 100%;
  background: #0f1419;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.5rem;
  margin: 0.3rem 0;
  font: inherit;
}
.chat-box button {
  background: #5c1a16;
  color: #f0e6c8;
  border: 1px solid #c0392b;
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  font-weight: 600;
}
.chat-msgs {
  max-height: 220px;
  overflow: auto;
  background: #0f1419;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.5rem;
  font-size: 0.78rem;
  line-height: 1.35;
}
.chat-msgs .m { margin: 0.4rem 0; }
.chat-msgs .who { color: #f0e6c8; font-weight: 600; }
.mural-leaflet .leaflet-popup-content-wrapper {
  background: #161d26;
  color: #e8eef5;
  border: 1px solid #c0392b;
  border-radius: 10px;
}
.mural-leaflet .leaflet-popup-tip { background: #161d26; }
.mural-pop { min-width: 240px; font-size: 0.8rem; line-height: 1.35; }
.mural-pop .mural-diag {
  background: #0f1419;
  border: 1px solid #2a3644;
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  margin: 0.4rem 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #c5d0dc;
}
.mural-pop .mural-sit { color: #f0e6c8; font-weight: 700; margin-bottom: 0.25rem; }
.mural-pop .mural-acoes { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.mural-pop .mural-acoes li { margin: 0.25rem 0; }
.mural-pop .mural-lbl {
  display: block;
  margin: 0.35rem 0 0.1rem;
  font-size: 0.72rem;
  color: #8b9bb0;
  font-weight: 600;
}
.mural-pop input, .mural-pop textarea {
  width: 100%;
  background: #0f1419;
  color: #e8eef5;
  border: 1px solid #2a3644;
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  margin: 0.25rem 0;
  font: inherit;
}
.mural-pop .mural-send {
  background: #5c1a16;
  color: #f0e6c8;
  border: 1px solid #c0392b;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-weight: 600;
}
.mural-leaflet .leaflet-popup-content { overflow-y: auto; max-height: 82vh; }
.mural-head {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #161d26;
  padding-bottom: 0.35rem;
  margin: 0 -2px 0.35rem;
  border-bottom: 1px solid #5c1a16;
}
.mural-pot {
  background: #0f1419;
  border: 1px solid #c0392b;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  margin: 0.3rem 0;
  font-size: 0.75rem;
  line-height: 1.35;
}
.pot-kicker { color: #e0746a; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.pot-num { color: #f0e6c8; font-size: 1.15rem; font-weight: 800; margin: 0.1rem 0; }
.pot-split { color: #8b9bb0; font-size: 0.7rem; margin-top: 0.2rem; }
.mural-fazer { font-size: 0.75rem; margin-top: 0.2rem; }
.mural-pop .mural-live {
  font-size: 0.68rem;
  color: #8b9bb0;
  margin: 0.35rem 0 0.15rem;
}
.mural-pop .chat-msgs {
  max-height: min(42vh, 360px);
  min-height: 200px;
  margin: 0.25rem 0 0.45rem;
  border-left: 2px solid #5c1a16;
  padding: 0.2rem 0.55rem 0.4rem 0.85rem;
}
.tl-dia {
  text-align: center;
  font-size: 0.68rem;
  color: #8b9bb0;
  margin: 0.45rem 0 0.3rem;
  letter-spacing: 0.04em;
}
.tl-item { position: relative; margin: 0.55rem 0; }
.tl-dot {
  position: absolute;
  left: -1.05rem;
  top: 0.35rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c0392b;
  box-shadow: 0 0 0 2px #161d26;
}
.tl-meta { margin-bottom: 0.12rem; }
.mural-urnas { max-height: min(28vh, 240px); overflow: auto; margin: 0.3rem 0 0.5rem; }
.urna-tbl { width: 100%; border-collapse: collapse; font-size: 0.68rem; }
.urna-tbl th { text-align: left; color: #8b9bb0; font-weight: 600; padding: 0.15rem 0.2rem; }
.urna-tbl td { padding: 0.18rem 0.2rem; border-top: 1px solid #2a3644; }
.urna-row { cursor: pointer; }
.mural-cores { margin: 0.25rem 0 0.15rem; }
.mural-cor[data-c="pt"].on { background: #5c1a16; border-color: #ff2a2a; color: #ffd0d0; }
.mural-cor[data-c="disputa"].on { background: #3d3410; border-color: #ffc400; color: #ffe9a0; }
.mural-cor[data-c="oposicao"].on { background: #0f2a4a; border-color: #1a7dff; color: #b8d4ff; }
.crc-row { display: flex; gap: 0.65rem; align-items: flex-end; margin: 0.45rem 0; font-size: 0.75rem; }
.crc-item { display: inline-flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.crc-ball { display: inline-block; border-radius: 50%; border: 1px solid rgba(255,255,255,0.25); }
.mural-crc[data-k="cury"].on { background: #3b1a4a; border-color: #8e44ad; color: #e0c6f0; }
.mural-crc[data-k="renan"].on { background: #0d3a32; border-color: #16a085; color: #b8eee0; }
.mural-crc[data-k="caiado"].on { background: #4a2208; border-color: #d35400; color: #ffd0b0; }
.secao-info .leaflet-popup-content-wrapper { background: #161d26; color: #e8eef5; }
.chips button.on {
  color: var(--ink);
  border-color: #5a7a9a;
  background: #1c2836;
}

.stats {
  background: #0f1419;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  font-size: 0.84rem;
  line-height: 1.45;
  margin-bottom: 1rem;
}
.stats strong { color: #fff; }
.stats .l { color: #e0746a; }
.stats .b { color: #6aa8e0; }

.legend {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.legend .row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.25rem 0;
}
.swatch {
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.15);
  flex: 0 0 auto;
}
.bar {
  height: 12px;
  border-radius: 3px;
  margin: 0.4rem 0 0.2rem;
  background: linear-gradient(90deg, var(--bolso), #444 50%, var(--lula));
}

.pdf-link { margin: 0.8rem 0 0.4rem; }
.pdf-link-top { margin: 0.55rem 0 0; }
.pdf-link a {
  display: inline-block;
  color: #f0e6c8;
  background: #5c1a16;
  border: 1px solid #c0392b;
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  font-size: 0.78rem;
  text-decoration: none;
  font-weight: 600;
}
.pdf-link a:hover { background: #7a2420; }

.leaflet-pane.leaflet-chatpins-pane { z-index: 850; pointer-events: auto; }
.chat-pin {
  background: none !important;
  border: none !important;
  pointer-events: auto !important;
}
.chat-pin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  border: 1px solid #f0e6c8;
  border-radius: 50%;
  background: #c0392b;
  color: #fff8e8;
  font-size: 0.72rem;
  line-height: 1;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
  cursor: pointer;
  pointer-events: auto;
}
.chat-pin-btn::before { content: "💬"; font-size: 0.7rem; }
.chat-janela {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(420px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  z-index: 900;
  background: #161d26;
  color: #e8eef5;
  border: 1px solid #c0392b;
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-janela[hidden] { display: none !important; }
.chat-janela-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  background: #5c1a16;
  color: #f0e6c8;
  font-weight: 700;
  font-size: 0.88rem;
}
.chat-janela-head button {
  border: 0;
  background: transparent;
  color: #f0e6c8;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
}
.chat-janela-body {
  overflow: auto;
  padding: 0.45rem 0.7rem 0.85rem;
}
.chat-janela-body .mural-pop { min-width: 0; }

.map-wrap {
  position: relative;
  min-height: 100vh;
  height: 100%;
}
.map-pdf-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 800;
  background: #5c1a16;
  color: #f0e6c8;
  border: 1px solid #c0392b;
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.map-pdf-btn:hover { background: #7a2420; color: #fff; }
.note { font-size: 0.7rem; color: #6a7888; line-height: 1.4; }

#map { height: 100%; min-height: 100vh; background: #1a222c; }

.hover {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  background: rgba(15,20,25,0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.8rem;
  max-width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.hover b { display: block; margin-bottom: 0.25rem; }

.leaflet-container { background: #1a222c; font: inherit; }
.leaflet-control-attribution {
  background: rgba(15,20,25,0.75) !important;
  color: #8b9bb0 !important;
}
.leaflet-control-attribution a { color: #a8c0d8 !important; }

@media (max-width: 800px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 70vh; }
  .panel { max-height: 40vh; }
}
