@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800;900&display=swap');

:root {
  --bg: #0b1020;
  --bg2: #141b33;
  --card: #1a2242;
  --line: #2a3460;
  --text: #f3f5ff;
  --muted: #9aa4c7;
  --accent: #ffc93c;
  --ok: #2ecc71;
  --bad: #ff5a5f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 15% -10%, #26306a 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 110%, #3a1d5c 0%, transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.badge {
  display: inline-flex; align-items: center; gap: .5em;
  padding: .35em .9em; border-radius: 999px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
}
.badge::before { content: ''; width: .6em; height: .6em; border-radius: 50%; background: currentColor; }
.badge.open { color: var(--ok); border-color: #2ecc7155; }
.badge.open::before { animation: pulse 1.4s infinite; }
.badge.closed { color: var(--accent); border-color: #ffc93c55; }
.badge.revealed { color: #a66cff; border-color: #a66cff55; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .3; transform: scale(.7); } }

/* ===================== PANTALLA ===================== */
body.pantalla { overflow: hidden; font-size: clamp(14px, 1.15vw, 26px); }
.pantalla .wrap { height: 100vh; padding: 3.2vh 3.5vw; display: flex; flex-direction: column; gap: 3vh; }
.pantalla header { display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.pantalla h1 { margin: 0; font-size: 3.4em; font-weight: 900; letter-spacing: -.02em; line-height: 1.05; }
.pantalla header .badge { font-size: 1.2em; flex-shrink: 0; }
.pantalla .grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr minmax(320px, 30vw); gap: 3vw; }

.cands { display: grid; gap: 1.2vw; align-content: center; grid-template-columns: repeat(auto-fit, minmax(16em, 1fr)); }
.cand {
  background: linear-gradient(160deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: 1.2em; padding: 1.3em 1.4em;
  display: flex; align-items: center; gap: 1em; position: relative; overflow: hidden;
  animation: entra .6s both;
}
.cand::before { content: ''; position: absolute; inset: 0 auto 0 0; width: .45em; background: var(--c); }
.cand .ini {
  width: 2.8em; height: 2.8em; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 900; font-size: 1.4em;
  background: color-mix(in srgb, var(--c) 25%, transparent); color: var(--c);
}
.cand .nm { font-size: 1.7em; font-weight: 800; line-height: 1.1; }
.cand .ds { color: var(--muted); margin-top: .2em; font-size: 1.05em; }
@keyframes entra { from { opacity: 0; transform: translateY(1em); } }

.qr-card {
  background: #fff; color: var(--bg); border-radius: 1.6em; padding: 1.6em;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8em;
  box-shadow: 0 2em 5em #0008; text-align: center;
}
.qr-card img { width: 100%; max-width: 26vw; max-height: 46vh; aspect-ratio: 1; }
.qr-card .lbl { font-size: 1.8em; font-weight: 900; margin: 0; }
.qr-card code { font-size: 1em; color: #4a5372; word-break: break-all; }
.qr-card .contador { margin-top: .6em; padding-top: .8em; border-top: 2px dashed #d5d9e8; width: 100%; }
.qr-card .num { display: block; font-size: 5em; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.qr-card .num.bump { animation: bump .5s; }
.qr-card small { font-size: 1.2em; color: #4a5372; font-weight: 600; }
@keyframes bump { 30% { transform: scale(1.25); color: #2ecc71; } }

.qr-card.off img { opacity: .12; filter: grayscale(1); }
.qr-card .aviso { font-size: 1.4em; font-weight: 800; color: #b07800; }

.vacio { color: var(--muted); font-size: 1.6em; text-align: center; grid-column: 1 / -1; }

/* resultados */
.res { height: 100vh; padding: 4vh 6vw; display: flex; flex-direction: column; gap: 3vh; }
.res h1 { text-align: center; }
.res .sub { text-align: center; color: var(--muted); font-size: 1.5em; margin: -1.5vh 0 0; }
.barras { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 2.2vh; }
.fila { display: grid; grid-template-columns: minmax(10em, 22%) 1fr 7em; align-items: center; gap: 1.2em; opacity: 0; transform: translateX(-2em); transition: opacity .6s, transform .6s; }
.fila.vis { opacity: 1; transform: none; }
.fila .nm { font-size: 1.8em; font-weight: 800; text-align: right; line-height: 1.1; }
.fila .pista { height: 3.4em; background: #ffffff10; border-radius: .8em; overflow: hidden; }
.fila .barra { height: 100%; width: 0; background: var(--c); border-radius: .8em; box-shadow: 0 0 2em color-mix(in srgb, var(--c) 50%, transparent); }
.fila .val { font-size: 2.2em; font-weight: 900; font-variant-numeric: tabular-nums; }
.fila .val small { display: block; font-size: .45em; color: var(--muted); font-weight: 600; }
.fila.gana .nm::before { content: '🏆 '; }
.fila.gana .pista { outline: 3px solid var(--accent); outline-offset: 4px; }
.fila.gana .nm { color: var(--accent); }
.fila.pierde { opacity: .55; }
.ganador { text-align: center; font-size: 2.6em; font-weight: 900; min-height: 1.3em; color: var(--accent); opacity: 0; transform: scale(.6); transition: all .8s cubic-bezier(.2, 1.6, .4, 1); }
.ganador.vis { opacity: 1; transform: none; }
#confeti { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

/* ===================== VOTAR (móvil) ===================== */
.votar { max-width: 560px; margin: 0 auto; padding: 24px 16px 120px; min-height: 100%; }
.votar h1 { font-size: 1.8rem; margin: 8px 0 4px; line-height: 1.15; }
.votar .hint { color: var(--muted); margin: 0 0 20px; }
.opciones { display: flex; flex-direction: column; gap: 12px; }
.opcion {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--card); color: var(--text); border: 2px solid var(--line); border-radius: 16px;
  padding: 16px; transition: border-color .15s, transform .1s, background .15s;
}
.opcion:active { transform: scale(.98); }
.opcion .ini { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-weight: 900; font-size: 1.3rem; background: color-mix(in srgb, var(--c) 25%, transparent); color: var(--c); }
.opcion .nm { font-size: 1.2rem; font-weight: 700; }
.opcion .ds { color: var(--muted); font-size: .9rem; }
.opcion .chk { margin-left: auto; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); flex-shrink: 0; display: grid; place-items: center; }
.opcion.sel { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--card)); }
.opcion.sel .chk { background: var(--c); border-color: var(--c); }
.opcion.sel .chk::after { content: '✓'; color: #0b1020; font-weight: 900; }
.barra-fija { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 35%); }
.btn {
  display: block; width: 100%; max-width: 560px; margin: 0 auto; border: 0; border-radius: 14px; padding: 16px;
  font-size: 1.15rem; font-weight: 800; background: var(--accent); color: #0b1020;
}
.btn:disabled { opacity: .35; cursor: not-allowed; }
.mensaje { text-align: center; padding: 18vh 8px 0; }
.mensaje .ico { font-size: 4rem; }
.mensaje h2 { font-size: 1.6rem; margin: 12px 0 6px; }
.mensaje p { color: var(--muted); margin: 0; }
.error { color: var(--bad); text-align: center; margin: 12px 0 0; min-height: 1.2em; }
.mini-res { margin-top: 28px; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.mini-res .r { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.mini-res .r .p { grid-column: 1 / -1; height: 10px; background: #ffffff12; border-radius: 6px; overflow: hidden; }
.mini-res .r .p i { display: block; height: 100%; background: var(--c); border-radius: 6px; }

/* ===================== ADMIN ===================== */
.admin { max-width: 980px; margin: 0 auto; padding: 24px 16px 60px; }
.admin h1 { margin: 0 0 4px; font-size: 1.8rem; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-top: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 1.1rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.campo label { font-size: .9rem; color: var(--muted); }
.campo small { color: var(--muted); font-size: .8rem; }
.inp { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; }
.inp:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.lista-c { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.fila-c { display: grid; grid-template-columns: 14px 1fr 1.3fr auto auto auto; gap: 8px; align-items: center; }
.fila-c .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c, var(--line)); }
.ib { background: var(--bg2); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; width: 36px; height: 40px; }
.ib:hover { color: var(--text); }
.ib.del:hover { color: var(--bad); border-color: var(--bad); }
.acciones { display: flex; flex-wrap: wrap; gap: 10px; }
.b { border: 1px solid var(--line); background: var(--bg2); color: var(--text); border-radius: 10px; padding: 11px 16px; font-weight: 600; }
.b:hover:not(:disabled) { border-color: var(--muted); }
.b:disabled { opacity: .35; cursor: not-allowed; }
.b.pri { background: var(--accent); border-color: var(--accent); color: #0b1020; }
.b.ok { background: var(--ok); border-color: var(--ok); color: #0b1020; }
.b.mor { background: #a66cff; border-color: #a66cff; color: #0b1020; }
.b.peligro { color: var(--bad); border-color: #ff5a5f66; }
.estado-adm { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.estado-adm .total { font-size: 2.6rem; font-weight: 900; line-height: 1; }
.estado-adm .total small { font-size: .9rem; color: var(--muted); font-weight: 600; display: block; }
.links a { color: var(--accent); }
.links { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); }
.toast.vis { opacity: 1; }
.toast.err { background: var(--bad); color: #fff; }
.login { max-width: 340px; margin: 18vh auto 0; text-align: center; padding: 0 16px; }
.login .inp { text-align: center; font-size: 1.6rem; letter-spacing: .3em; margin: 16px 0 10px; }
@media (max-width: 640px) {
  .fila-c { grid-template-columns: 14px 1fr auto auto auto; }
  .fila-c .desc { grid-column: 2 / -1; grid-row: 2; }
}
.opcion.tope { opacity: .45; }
.qr-card .regla { font-size: 1.3em; font-weight: 800; color: #0b1020; background: #ffc93c; border-radius: .6em; padding: .2em .8em; }
.qr-card .regla:empty { display: none; }

/* resultados: las filas se reparten la altura disponible (caben 10+ candidatos en 16:9) */
.res { gap: 2vh; }
.res h1 { font-size: 3em; }
.barras { min-height: 0; gap: 1.2vh; }
.fila { flex: 0 1 4.6em; min-height: 0; }
.fila .pista { height: 75%; max-height: 3.4em; }
.ganador { flex-shrink: 0; }
