:root {
  --bg: #f4f6fb; --card: #fff; --ink: #1c2233; --muted: #667089; --line: #e3e7f0;
  --azul: #1e4db7; --fem: #c2417a; --mas: #2563b8;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { margin: 2px 0 0; color: var(--muted); }

.top { background: var(--azul); color: #fff; padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.top .sub { color: #cdd8f5; }
.top-actions { display: flex; gap: 8px; align-items: center; }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat { display: grid; gap: 2px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat strong { font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.stat.fem strong { color: var(--fem); }
.stat.mas strong { color: var(--mas); }

.split { display: flex; height: 22px; border-radius: 11px; overflow: hidden; background: var(--line); }
.seg { height: 100%; transition: width .3s; }
.seg.fem { background: var(--fem); }
.seg.mas { background: var(--mas); }

.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.row h2 { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; border-bottom: 0; }
tbody tr:hover { background: #f8f9fd; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #eef1f8; color: var(--muted); }
.tag.urbana { background: #e4ecfb; color: var(--azul); }

select, input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.btn { font: inherit; font-weight: 600; padding: 9px 16px; border: 0; border-radius: 8px; background: var(--azul); color: #fff; cursor: pointer; }
.btn.ghost { background: transparent; border: 1px solid #ffffff66; }
.btn:disabled { opacity: .6; cursor: default; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.login-card input { color: var(--ink); font-size: 15px; }
.error { color: #b3261e; min-height: 1.2em; margin: 0; }

@media (max-width: 560px) { .stat strong { font-size: 28px; } .top { padding: 14px 16px; } }

tbody tr.click { cursor: pointer; }
tbody tr.click td:first-child { color: var(--azul); font-weight: 600; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(760px, calc(100vw - 24px)); max-height: 88vh; color: var(--ink); background: var(--card); box-shadow: 0 20px 60px #0004; }
dialog::backdrop { background: #101828aa; }
dialog[open] { display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.icon-btn { border: 0; background: transparent; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 6px; }
.modal-body { overflow-y: auto; padding: 16px 20px 20px; display: grid; gap: 12px; }
.rec { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; }
.rec-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.rec-name { font-weight: 700; }
.rec-meta { color: var(--muted); font-size: 13px; }
.maps { display: inline-block; text-decoration: none; font-weight: 600; font-size: 13px; padding: 7px 12px; border-radius: 8px; background: #e8f0fe; color: var(--azul); white-space: nowrap; }
.maps:hover { background: #d7e5fd; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 10px; border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.chip.F { background: #fbe9f2; color: var(--fem); border-color: #f3c8dc; }
.chip.M { background: #e6effb; color: var(--mas); border-color: #c5d9f3; }
.chip.enviado { box-shadow: inset 0 0 0 2px #2e9e5b; }

/* ---- Menú y veedores ---- */
.tabs { display: flex; gap: 4px; background: #ffffff22; padding: 4px; border-radius: 10px; }
.tab { font: inherit; font-weight: 600; border: 0; background: transparent; color: #fff; padding: 7px 16px; border-radius: 7px; cursor: pointer; }
.tab.active { background: #fff; color: var(--azul); }
.stat.ok strong { color: #1f8a4c; }
.stat.warn strong { color: #b26a00; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 8px; }
.pill { display: inline-block; min-width: 26px; text-align: center; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 700; }
.pill.ok { background: #e2f5ea; color: #1f8a4c; }
.pill.bad { background: #fde8e6; color: #b3261e; }
.pill.mid { background: #fff1d6; color: #9a5b00; }
.chip.sin { border-style: dashed; border-color: #b3261e; background: #fff; color: #b3261e; }
.leyenda { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }

.crear { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.crear-bloque { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 10px; align-content: start; }
.crear-bloque h3 { margin: 0; font-size: 14px; }
.crear-bloque label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.crear-bloque input, .crear-bloque select { color: var(--ink); }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.aviso { margin: 2px 0 0; color: #9a5b00; }
td.pin { font: 700 16px/1 ui-monospace, Consolas, monospace; letter-spacing: .12em; }
tr.inactivo td { color: var(--muted); }
td.acc { white-space: nowrap; }
.link { font: inherit; background: none; border: 0; color: var(--azul); cursor: pointer; padding: 2px 6px; }
.link.danger { color: #b3261e; }
.link:disabled { opacity: .5; }
td.vacio { text-align: center; color: var(--muted); padding: 20px; }
input[type="search"] { min-width: 220px; }

@media print {
  body.print-pins .top, body.print-pins #vistaJuntas, body.print-pins #vistaVeedores > *:not(#panelPins),
  body.print-pins #panelPins .acciones, body.print-pins dialog { display: none !important; }
  body.print-pins { background: #fff; }
  body.print-pins #panelPins { border: 0; }
}

/* ---- Formulario y combobox ---- */
.crear-bloque { min-width: 0; }
.crear-bloque input:not([type=hidden]), .crear-bloque select { width: 100%; min-width: 0; }
.crear-bloque > .btn { justify-self: start; }
.campo { display: grid; gap: 4px; min-width: 0; }
.campo > label, .crear-bloque > label { color: var(--muted); font-size: 13px; }
.combo { position: relative; }
.combo input { padding-right: 34px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23667089' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center; }
.combo input:disabled { background-color: #f1f3f8; cursor: not-allowed; }
.combo ul { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; max-height: 260px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px #0002; }
.combo li { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.combo li[aria-selected="true"] { background: #e8f0fe; color: var(--azul); }
.combo li.mas { color: var(--muted); font-size: 12px; cursor: default; }
input:focus-visible, select:focus-visible, .btn:focus-visible { outline: 2px solid var(--azul); outline-offset: 1px; }

/* ---- Dashboard de resultados ---- */
.barra-res { display: grid; gap: 10px; }
.avance-txt { display: flex; gap: 4px; align-items: baseline; margin-bottom: 6px; font-size: 16px; }
.avance-txt span { color: var(--muted); }
.progreso { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.progreso > div { height: 100%; width: 0; background: #1f8a4c; transition: width .4s; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.grid-dig { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.dig { display: grid; gap: 12px; align-content: start; }
.dig header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dig h3 { margin: 0; font-size: 16px; }
.dig.nota { color: var(--muted); }
.lider { background: #f3f7ff; border: 1px solid #d8e4fb; border-radius: 10px; padding: 10px 12px; display: grid; gap: 1px; }
.lider strong { font-size: 18px; }
.lider-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--azul); font-weight: 700; }
.lider-det { color: var(--muted); font-size: 12px; }
.lider.vacio, .lider.empate { background: #f7f8fb; border-color: var(--line); color: var(--muted); }
.lider.empate { background: #fff6e0; border-color: #f1dca4; color: #9a5b00; }
.cands { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.fila-c { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.nom { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.num { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.barra { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.barra > div { height: 100%; border-radius: 4px; transition: width .4s; }
.badge { font-size: 11px; background: #1f8a4c; color: #fff; padding: 1px 7px; border-radius: 9px; margin-left: 4px; font-weight: 700; }
.dig footer { display: flex; flex-wrap: wrap; gap: 4px 16px; border-top: 1px solid var(--line); padding-top: 10px; color: var(--muted); font-size: 13px; }
.dig footer b { color: var(--ink); font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .grid-dig { grid-template-columns: 1fr; } }

/* ---- Detalle interactivo ---- */
.card.dig.clic { cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.card.dig.clic:hover, .card.dig.clic:focus-visible { border-color: var(--azul); box-shadow: 0 4px 16px #1e4db71f; outline: none; }
.dig footer .ver { margin-left: auto; color: var(--azul); font-weight: 600; }
button.chip { font: inherit; font-size: 12px; cursor: pointer; }
button.chip:hover { box-shadow: 0 0 0 2px #1e4db733; }
tr[data-junta] { cursor: pointer; }
tr[data-junta]:focus-visible { outline: 2px solid var(--azul); outline-offset: -2px; }
tr[data-junta] td:first-child { color: var(--azul); font-weight: 600; }
dialog.ancho { width: min(1040px, calc(100vw - 24px)); }
table.det th small { font-weight: 400; text-transform: none; letter-spacing: 0; }
table.det td.max { font-weight: 800; color: var(--azul); }
.mj-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.mj-meta > div { background: #f7f8fb; border-radius: 8px; padding: 8px 10px; }
.mj-meta > div > span:first-child { color: var(--muted); font-size: 12px; }
.mj-meta b { font-size: 14px; }
.mj-cols { display: grid; grid-template-columns: minmax(240px, 380px) 1fr; gap: 18px; align-items: start; }
@media (max-width: 760px) { .mj-cols { grid-template-columns: 1fr; } }
h3.sec { margin: 0 0 8px; font-size: 14px; }
.acta { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fafbfe; }
.acta button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.acta img { display: block; width: 100%; max-height: 460px; object-fit: contain; }
.acta .pie { padding: 6px 10px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.acta.vacia { padding: 32px 14px; text-align: center; color: var(--muted); }
.res-blk { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
.res-blk h3 { margin: 0 0 4px; font-size: 14px; }
.res-blk td { padding: 5px 8px; }
.res-blk tr.gana td { font-weight: 700; }
.res-blk tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; color: var(--muted); }
.btn.ghost-dark { background: #fff; color: var(--azul); border: 1px solid var(--azul); }
dialog.lb { width: 100vw; height: 100vh; max-width: none; max-height: none; background: #000d; border-radius: 0; }
.lb-scroll { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; padding: 16px; }
.lb-scroll img { max-width: 100%; max-height: 100%; cursor: zoom-in; background: #fff; }
dialog.lb.zoom .lb-scroll { place-items: start; }
dialog.lb.zoom .lb-scroll img { max-width: none; max-height: none; width: 200%; cursor: zoom-out; }
.lb-x { position: absolute; top: 8px; right: 14px; color: #fff; font-size: 38px; z-index: 2; }
.mj-meta > div > span:first-child { display: block; }
.mj-meta .pill { display: inline-block; }
dialog.lb { background: #0b0f1af2; }

/* ---- Archivos SAV ---- */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.dropzone { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 28px 16px; border: 2px dashed #b9c6e6; border-radius: 12px; background: #f7f9ff; cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone strong { font-size: 16px; color: var(--azul); }
.dropzone span { color: var(--muted); max-width: 560px; }
.dropzone:hover, .dropzone.sobre, .card:has(#savArchivo:focus-visible) .dropzone { background: #eaf0ff; border-color: var(--azul); }
#vistaSav .cards { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
#vistaSav .savmeta { grid-column: span 2; }
@media (max-width: 720px) { #vistaSav .savmeta { grid-column: auto; } }
.notas { margin-top: 10px; }
.notas pre { white-space: pre-wrap; background: #f7f8fb; padding: 10px; border-radius: 8px; max-height: 200px; overflow: auto; font-size: 12px; }
.subtabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.subtab { font: inherit; font-weight: 600; border: 0; background: none; padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.subtab.active { color: var(--azul); border-bottom-color: var(--azul); }
.sav-barra { margin-bottom: 10px; }
.sav-barra input[type=search] { flex: 1; min-width: 220px; max-width: 420px; }
.sav-info { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; color: var(--muted); }
.pager { display: inline-flex; align-items: center; gap: 6px; }
.pager .btn { padding: 4px 11px; }
.pager .btn:disabled { opacity: .4; }
.sav-scroll { overflow: auto; max-height: 64vh; border: 1px solid var(--line); border-radius: 10px; }
table.dat { border-collapse: separate; border-spacing: 0; }
table.dat th, table.dat td { padding: 6px 10px; border-bottom: 1px solid var(--line); max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
table.dat thead th { position: sticky; top: 0; background: #f1f4fb; z-index: 2; cursor: pointer; user-select: none; text-transform: none; letter-spacing: 0; font-size: 12px; }
table.dat th.ord::after { content: ' ↕'; color: #b0b8cc; }
table.dat th.asc::after { content: ' ▲'; color: var(--azul); }
table.dat th.desc::after { content: ' ▼'; color: var(--azul); }
table.dat .rn { position: sticky; left: 0; background: #f7f8fb; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; z-index: 1; }
table.dat thead .rn { z-index: 3; cursor: default; }
table.dat td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.dat td.etq { color: #1d5fbf; }
table.dat td.perd { color: var(--muted); font-style: italic; }
table.dat tbody tr { cursor: pointer; }
table.dat tbody tr:hover td { background: #f3f7ff; }
table.dat tbody tr:focus-visible { outline: 2px solid var(--azul); outline-offset: -2px; }
#savVarTabla td, #savVarTabla th { white-space: normal; }
#savVarTabla tr.click { cursor: pointer; }
table.reg td:first-child { white-space: nowrap; }
.codigo { color: var(--muted); font-size: 12px; margin-left: 6px; }
main > *, #savContenido, #savContenido > section { min-width: 0; max-width: 100%; }
#vistaSav .cards > .stat { align-content: center; }

/* ---- Marca ---- */
.marca { display: grid; gap: 4px; }
.logo { height: 42px; width: auto; display: block; }
.marca .sub { margin: 0; font-size: 12px; }
.logo-login { width: 100%; max-width: 290px; height: auto; margin: 0 auto 4px; display: block; }
.login-card h1 { text-align: center; font-size: 17px; color: var(--muted); font-weight: 600; }

/* ---- Fotos y colores de candidatos ---- */
.av { position: relative; display: inline-grid; place-items: center; flex: none; border-radius: 50%; overflow: hidden; background: var(--c, #5b6577); color: #fff; box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--c, #5b6577); margin: 2px; vertical-align: middle; }
.av b { font-weight: 800; letter-spacing: .02em; line-height: 1; }
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lider-fila { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.lider-fila > div { display: grid; min-width: 0; }
.nom-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.det th .av { margin-bottom: 2px; }

.cand-grupos { display: grid; gap: 16px; }
.cand-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.cand { font: inherit; text-align: left; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 10px; background: #fff; cursor: pointer; color: var(--ink); }
.cand:hover, .cand:focus-visible { border-color: var(--c); box-shadow: 0 4px 14px #0001; outline: none; }
.cand-txt { display: grid; min-width: 0; }
.cand-txt b { overflow: hidden; text-overflow: ellipsis; }
.cand-txt small { color: var(--muted); }
.cand-color { width: 16px; height: 16px; border-radius: 50%; box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--line); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; min-width: 0; }
.form-grid input:not([type=color]):not([type=file]), .form-grid select { width: 100%; min-width: 0; color: var(--ink); }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0; padding: 10px 14px 14px; min-width: 0; }
legend { padding: 0 6px; color: var(--muted); font-size: 13px; }
.color-fila { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
input[type=color] { width: 46px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.hex { font: 600 13px ui-monospace, Consolas, monospace; color: var(--muted); }
.paleta { display: flex; gap: 8px; flex-wrap: wrap; }
.paleta button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.paleta button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.foto-zona { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.foto-prev { flex: none; }
.foto-acc { display: grid; gap: 8px; justify-items: start; }
.foto-acc label.btn { display: inline-block; text-decoration: none; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); }
.modal-foot .espacio { flex: 1; }
dialog form { display: contents; }

/* ---- Ajustes: tarjetas sin desbordes y logo del encabezado más legible ---- */
.grid-dig { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.grid-dig > .card, .dig, .dig > * { min-width: 0; }
.fila-c .nom { flex: 1; min-width: 0; }
.fila-c .num { flex: none; }
.nom-t { flex: 0 1 auto; min-width: 0; }
.lider strong { overflow-wrap: anywhere; }
.logo { height: 52px; }
.dig { grid-template-columns: minmax(0, 1fr); }
.cands { grid-template-columns: minmax(0, 1fr); }
.cands > li { min-width: 0; }
.nom .badge { flex: none; margin-left: 0; }
.nom-t { display: grid; line-height: 1.2; }
.nom-t b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nom-t small { color: var(--muted); font-weight: 400; font-size: 11px; }
.nom-t small .badge { margin-left: 4px; font-size: 10px; padding: 0 6px; vertical-align: 1px; }
