/* ONPE 2026 — estilos minimalistas */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f6f7f9;
  color: #222;
}
a { color: #1b5fad; text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: #777; }

/* Header */
.top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  background: #0a3d3d;
  color: #eee;
  border-bottom: 3px solid #00b4d8;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.05rem; flex-shrink: 0; }
.mainnav { display: flex; gap: 0.25rem; margin-left: 0.5rem; flex: 1; flex-wrap: wrap; }
.mainnav a {
  padding: 0.4rem 0.7rem;
  color: #ddd;
  border-radius: 3px;
  font-size: 0.92rem;
  white-space: nowrap;
}
.mainnav a.active, .mainnav a:hover {
  background: #13575c;
  color: #fff;
  text-decoration: none;
}
.status { display: flex; gap: .5rem; align-items: center; flex-shrink: 0; }
.status .muted { color: #bbb; font-size: 0.8rem; }

/* Hamburger (oculto en desktop) */
.navtoggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
  flex-direction: column;
  gap: 4px;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
}
.navtoggle span {
  display: block;
  width: 22px; height: 2px;
  background: #ddd;
  transition: transform 0.2s, opacity 0.2s;
}
.navtoggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.navtoggle.open span:nth-child(2) { opacity: 0; }
.navtoggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ==== Mobile (<=720px) ==== */
@media (max-width: 720px) {
  .top { padding: 0.6rem 0.7rem; gap: 0.4rem; }
  .brand { font-size: 0.95rem; }
  /* Brand a la izquierda, status + hamburger a la derecha */
  .status { order: 2; margin-left: auto; }
  .navtoggle { display: flex; order: 3; margin-left: 0.4rem; }
  .status .muted { display: none; }
  .mainnav {
    order: 4;
    flex-basis: 100%;
    flex-direction: column;
    gap: 2px;
    margin: 0.5rem 0 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease-out;
  }
  .mainnav.open { max-height: 600px; overflow: visible; }
  .mainnav a {
    padding: 0.7rem 1rem;
    border-radius: 4px;
    background: #13575c;
  }
  .mainnav a.active { background: #1b5fad; }
  .container { padding: 0 0.7rem; }
  h1 { font-size: 1.2rem; }
  h2 { font-size: 1rem; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .card { padding: 0.7rem; }
  .card .val { font-size: 1.2rem; }
  table.data { font-size: 0.85rem; }
  table.data th, table.data td { padding: 5px 6px; }
  .filters { padding: 0.5rem; }
  .filters label { display: block; margin: 0.3rem 0; }
}

@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
}

/* Franja de descargo visible en todas las páginas (debajo del header) */
.topbar-disclaimer {
  background: #fff7d6;
  border-bottom: 1px solid #e8d57a;
  color: #6b5200;
  font-size: 0.82rem;
  padding: 8px 16px;
  text-align: center;
  line-height: 1.45;
}
.topbar-disclaimer strong { color: #8a3d00; }
.topbar-disclaimer a {
  color: #1b5fad;
  font-weight: 600;
  white-space: nowrap;
  margin-left: 4px;
}
.topbar-disclaimer a::after { content: " →"; }
@media (max-width: 720px) {
  .topbar-disclaimer { font-size: 0.76rem; padding: 7px 10px; }
}

/* Container */
.container { max-width: 1400px; margin: 1.2rem auto; padding: 0 1.2rem; }
h1, h2, h3 { color: #1f2933; }
h1 { font-size: 1.4rem; margin: 0 0 1rem 0; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; border-bottom: 2px solid #eee; padding-bottom: 0.3rem; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-ok    { background: #d5f3d5; color: #1a651a; }
.badge-warn  { background: #fef0c2; color: #7a5b00; }
.badge-err   { background: #fcd7d7; color: #b32222; }
.badge-info  { background: #d7e7fc; color: #1b5fad; }
.badge-muted { background: #e0e0e0; color: #555; }

/* Cards grid */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.8rem; margin: 1rem 0; }
.card {
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 6px;
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.card h3 { font-size: 0.85rem; margin: 0; color: #666; font-weight: 500; text-transform: uppercase; }
.card .val { font-size: 1.6rem; font-weight: 700; margin-top: 4px; color: #1f2933; }
.card .sub { font-size: 0.78rem; color: #888; margin-top: 3px; }

/* Tables */
table.data {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 6px;
  overflow: hidden;
}
table.data th, table.data td { padding: 6px 10px; text-align: left; border-bottom: 1px solid #eee; }
table.data th { background: #f0f2f5; font-weight: 600; font-size: 0.85rem; }
table.data tr:hover td { background: #f9fafc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Wrapper con scroll horizontal + sticky first column (opción A: tablas densas) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 6px; }
.table-wrap table.data { border-radius: 0; }
.table-wrap.sticky-first td:first-child,
.table-wrap.sticky-first th:first-child {
  position: sticky; left: 0; z-index: 1;
  background: #fff;
  box-shadow: 2px 0 4px -2px rgba(0,0,0,0.12);
}
.table-wrap.sticky-first th:first-child { background: #f0f2f5; }

/* Stacked cards en mobile (opción B: tablas de pocos registros) */
@media (max-width: 640px) {
  table.data.stackable { border: none; background: transparent; }
  table.data.stackable thead { display: none; }
  table.data.stackable tbody,
  table.data.stackable tr,
  table.data.stackable td { display: block; width: 100%; }
  table.data.stackable tr {
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  }
  table.data.stackable tr:hover td { background: transparent; }
  table.data.stackable td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.8rem;
    padding: 3px 0;
    border-bottom: 1px dashed #eef0f3;
    text-align: right;
  }
  table.data.stackable td:last-child { border-bottom: none; }
  table.data.stackable td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #666;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    text-align: left;
    flex-shrink: 0;
  }
  table.data.stackable td.num { text-align: right; }
}

/* Deltas con color */
.delta-pos { color: #17883c; font-weight: 600; }
.delta-neg { color: #c21d1d; font-weight: 600; }
.delta-zero { color: #aaa; }

/* Forms */
select, input[type=text], input[type=number] {
  padding: 0.3rem 0.5rem;
  border: 1px solid #c5c9d0;
  border-radius: 3px;
  font: inherit;
}
label { display: inline-flex; gap: 0.4rem; align-items: center; margin-right: 0.8rem; font-size: 0.9rem; }
.filters { margin: 0.5rem 0 1rem 0; padding: 0.6rem; background: #fff; border: 1px solid #e3e6ea; border-radius: 6px; }

/* Chart container */
.chart-container { background: #fff; border: 1px solid #e3e6ea; border-radius: 6px; padding: 1rem; margin: 1rem 0; }
.chart-container canvas { max-height: 320px; }

/* Footer */
.foot { padding: 1.2rem; margin-top: 2rem; border-top: 1px solid #e3e6ea; background: #fafbfc; }
.foot .disclaimer {
  max-width: 900px; margin: 0 auto 0.8rem;
  font-size: 0.82rem; color: #5a5a5a; line-height: 1.45;
  text-align: left;
}
.foot .disclaimer strong { color: #b32222; }
.foot-src { text-align: center; color: #888; font-size: 0.82rem; }
.foot a { color: #1b5fad; }

/* ============== SHARE PAGE (mobile-first) ============== */
.share-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 0.5rem;
}

/* Botón "Compartir" sutil en la parte superior */
.share-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.45rem;
}
.btn-share-top {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.4rem 0.9rem;
  background: #ffffff;
  color: #1b5fad;
  border: 1px solid #c5d8ee;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: background 0.15s, transform 0.1s;
}
.btn-share-top:hover  { background: #eff5fc; }
.btn-share-top:active { transform: scale(0.97); }
.btn-share-top svg    { width: 15px; height: 15px; }
.share-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  padding: 1.2rem 1rem;
  margin-bottom: 1rem;
}
.share-card h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin: 0 0 0.5rem;
  border: none;
  padding: 0;
}
.share-head {
  background: linear-gradient(135deg, #0a3d3d 0%, #13575c 100%);
  color: #fff;
}
.share-head h2 { color: #bbd2f0; }
.share-head h1 { font-size: 1.2rem; margin: 0; color: #fff; }
.share-head .sub { font-size: 0.85rem; opacity: 0.85; margin-top: 4px; }

.pct-big { font-size: 3rem; font-weight: 800; color: #fff; margin: 0.3rem 0; line-height: 1; }
.pct-sub { opacity: 0.8; font-size: 0.85rem; }

.candlist { list-style: none; padding: 0; margin: 0; }
.candlist li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid #eef0f3;
  font-size: 0.95rem;
  align-items: center;
}
.candlist li:last-child { border-bottom: none; }
.candlist .rank { font-weight: 700; color: #777; min-width: 22px; }
.candlist .nombre { font-weight: 600; color: #1f2933; }
.candlist .nombre small { display: block; color: #888; font-weight: 400; font-size: 0.78rem; }
.candlist .val-pct { font-weight: 700; color: #1f2933; font-variant-numeric: tabular-nums; }
.candlist .val-delta { font-size: 0.78rem; font-variant-numeric: tabular-nums; min-width: 55px; text-align: right; }

/* Resaltar Sánchez (Juntos por el Perú) y López Aliaga (Renovación Popular) */
.candlist li.hl-sanchez { background: #eef7ee; margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; }
.candlist li.hl-lopez   { background: #eaf2fb; margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; }
.candlist li.hl-sanchez .nombre { color: #17883c; }
.candlist li.hl-sanchez .rank   { color: #17883c; }
.candlist li.hl-lopez   .nombre { color: #1b5fad; }
.candlist li.hl-lopez   .rank   { color: #1b5fad; }

/* Botón "Ver los N restantes" */
.candlist li.more-toggle-row {
  grid-template-columns: 1fr;
  padding: 0;
  border-bottom: none;
  background: transparent;
  margin: 0 -1rem;
}
.more-toggle {
  width: 100%;
  padding: 0.7rem 1rem;
  background: #f0f2f5;
  border: none;
  border-top: 1px solid #eef0f3;
  color: #1b5fad;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.more-toggle:hover { background: #e3e6ea; }

.more-collapse { display: contents; }
.more-collapse[hidden] { display: none; }

/* Fila-diff entre Sánchez y López (ajustada para parecer un separador, no un candidato) */
.candlist li.diff-row {
  grid-template-columns: auto 1fr auto;
  padding: 0.4rem 1rem;
  background: #fffbea;
  margin: 0 -1rem;
  border-top: 1px dashed #e0c97a;
  border-bottom: 1px dashed #e0c97a;
  font-size: 0.82rem;
  color: #6b5200;
}
.candlist li.diff-row .diff-label { grid-column: 2; font-weight: 600; }
.candlist li.diff-row .diff-val   { font-weight: 700; font-variant-numeric: tabular-nums; }
.candlist li.diff-row .diff-icon  { font-size: 1rem; }

.origen-list { list-style: none; padding: 0; margin: 0; }
.origen-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #eef0f3;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.origen-list li:last-child { border-bottom: none; }
.origen-list .loc { flex: 1; font-size: 0.92rem; }
.origen-list .loc small { color: #888; display: block; font-size: 0.75rem; }
.origen-list .v { font-variant-numeric: tabular-nums; font-weight: 600; color: #17883c; }

.share-actions { margin-top: 1rem; }
.btn {
  display: inline-block;
  padding: 0.7rem 1rem;
  border-radius: 6px;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #1b5fad; color: #fff; width: 100%; padding: 0.9rem; font-size: 1rem; }
.btn-primary:hover { background: #15488a; color:#fff; text-decoration: none; }
.btn-secondary { background: #f0f2f5; color: #1f2933; width: 100%; padding: 0.8rem; margin-top: 0.5rem; }
.btn-secondary:hover { background: #e3e6ea; text-decoration:none; }

.share-net {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 1rem;
}
.share-net a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 0.4rem;
  border-radius: 6px;
  background: #f0f2f5;
  text-decoration: none;
  color: #1f2933;
  font-size: 0.75rem;
  gap: 6px;
  transition: background 0.15s, transform 0.1s;
}
.share-net a:hover  { background: #e3e6ea; text-decoration: none; }
.share-net a:active { transform: scale(0.97); }
.share-net .icon    { width: 24px; height: 24px; display: block; }

/* Colores oficiales de marca (ícono) al hover + icono siempre con color de marca */
.share-net a.sn-x   .icon { color: #000000; }
.share-net a.sn-fb  .icon { color: #1877F2; }
.share-net a.sn-wa  .icon { color: #25D366; }
.share-net a.sn-tg  .icon { color: #26A5E4; }

.share-net a.sn-x:hover   { background: #000000; color: #fff; }
.share-net a.sn-x:hover   .icon { color: #fff; }
.share-net a.sn-fb:hover  { background: #1877F2; color: #fff; }
.share-net a.sn-fb:hover  .icon { color: #fff; }
.share-net a.sn-wa:hover  { background: #25D366; color: #fff; }
.share-net a.sn-wa:hover  .icon { color: #fff; }
.share-net a.sn-tg:hover  { background: #26A5E4; color: #fff; }
.share-net a.sn-tg:hover  .icon { color: #fff; }

/* Responsive wider */
@media (min-width: 768px) {
  .share-wrap { max-width: 640px; padding: 1rem; }
}

/* Metodología page */
.doc-page h2 { margin-top: 1.6rem; }
.doc-page h3 { font-size: 1rem; margin-top: 1.2rem; color: #1f2933; }
.doc-page pre { background: #f4f6f8; padding: 0.8rem; border-radius: 4px; overflow-x: auto; font-size: 0.85rem; }
.doc-page code { background: #eff2f5; padding: 2px 5px; border-radius: 3px; font-size: 0.88em; }
.doc-page .alert-warn { background: #fff7d6; border-left: 4px solid #d9a900; padding: 0.8rem 1rem; margin: 1rem 0; border-radius: 0 4px 4px 0; }
.doc-page ol li, .doc-page ul li { margin-bottom: 0.3rem; }

/* DataTables ajustes */
.dataTables_wrapper { font-size: 0.9rem; }
table.dataTable { border-collapse: collapse !important; }

/* Callout */
.callout {
  background: #fff;
  border-left: 4px solid #1b5fad;
  padding: 0.8rem 1rem;
  margin: 0.8rem 0;
  border-radius: 0 4px 4px 0;
}
.callout.warn   { border-left-color: #d9a900; }
.callout.err    { border-left-color: #c21d1d; }
.callout.ok     { border-left-color: #17883c; }
