/* ============================================================================
   estilos.css — diseño de Demoskratia (móvil primero, modo claro y oscuro)
   ============================================================================ */
:root {
  --fondo: #f5f3ee; --tarjeta: #ffffff; --texto: #18213a; --suave: #5d6577; --borde: #ddd8cb;
  --primario: #1b2a4e; --primario-texto: #ffffff; --oro: #b8901f; --oro-suave: #f3e7bf;
  --verde: #1f9d55; --rojo: #c92a3e; --naranja: #d9820b; --sombra: 0 1px 3px rgba(20, 30, 60, .12); --radio: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --fondo: #0d1220; --tarjeta: #171e33; --texto: #eef0f7; --suave: #9aa4bd; --borde: #2a3452;
    --primario: #d5ad3b; --primario-texto: #101626; --oro: #e0b84a; --oro-suave: #3a321a; --verde: #3ecf82; --rojo: #ff6b7d; --naranja: #ffb04d; --sombra: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fondo); color: var(--texto); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: .25rem 0 .75rem; }
small, .suave { color: var(--suave); }
a { color: var(--primario); }
[hidden] { display: none !important; }
button { font-family: inherit; }

/* ---- estructura ---- */
.cabecera { position: sticky; top: 0; z-index: 10; background: var(--tarjeta); border-bottom: 1px solid var(--borde); padding: .5rem 16px 0; box-shadow: var(--sombra); }
.cabecera-fila { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.marca { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.2rem; text-decoration: none; color: var(--texto); }
.marca img { width: 34px; height: 34px; }
.marca b { color: var(--oro); }
.quien { font-size: .85rem; color: var(--suave); text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; }
.ambitos { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; padding: .55rem 0 .15rem; }
.ambitos::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); border-radius: 99px; padding: .3rem .8rem; font-weight: 600; font-size: .88rem; cursor: pointer; white-space: nowrap; }
.chip.activo { background: var(--primario); color: var(--primario-texto); border-color: transparent; }
.chip.ro { border-style: dashed; }
.nav { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.nav::-webkit-scrollbar { display: none; }
.nav a { flex: none; padding: .5rem .8rem; text-decoration: none; color: var(--suave); font-weight: 600; font-size: .95rem; border-bottom: 3px solid transparent; white-space: nowrap; }
.nav a.activo { color: var(--oro); border-bottom-color: var(--oro); }
main { max-width: 980px; margin: 0 auto; padding: 16px; }
.tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; margin-bottom: 14px; box-shadow: var(--sombra); }
.cuadricula { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.fila { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.fila.entre { justify-content: space-between; }
.vacio { text-align: center; color: var(--suave); padding: 1.5rem 0; }
.aviso { background: var(--oro-suave); border: 1px solid var(--oro); border-radius: 10px; padding: .6rem .8rem; margin-bottom: 12px; }
.error { color: var(--rojo); font-weight: 600; }
.ok { color: var(--verde); font-weight: 600; }

/* ---- botones y formularios ---- */
.btn { appearance: none; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); padding: .65rem 1rem; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primario { background: var(--primario); color: var(--primario-texto); border-color: transparent; }
.btn-oro { background: var(--oro); color: #fff; border-color: transparent; }
.btn-peligro { background: var(--rojo); color: #fff; border-color: transparent; }
.btn-pequeno { min-height: 34px; padding: .3rem .65rem; font-size: .9rem; }
.btn-enlace { border: 0; background: none; color: var(--primario); padding: .3rem; min-height: 0; text-decoration: underline; }
.btn-bloque { width: 100%; }
.campo { display: block; margin-bottom: .8rem; }
.campo > span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .2rem; color: var(--suave); }
.campo small { display: block; margin-top: .2rem; }
input, select, textarea { width: 100%; padding: .6rem .7rem; border: 1px solid var(--borde); border-radius: 10px; background: var(--fondo); color: var(--texto); font: inherit; min-height: 44px; }
input[type=color] { padding: .15rem; min-height: 44px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
textarea { min-height: 90px; resize: vertical; }
.insignia { font-size: .75rem; font-weight: 700; padding: .1rem .5rem; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.insignia.verde { color: var(--verde); } .insignia.rojo { color: var(--rojo); } .insignia.naranja { color: var(--naranja); } .insignia.oro { color: var(--oro); } .insignia.gris { color: var(--suave); }
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .55rem 0; border-bottom: 1px solid var(--borde); }
.lista li:last-child { border-bottom: 0; }
.etiqueta { flex: 1 1 160px; min-width: 0; }

/* ---- tarjetas de candidatura ---- */
.candidatura { border-left: 6px solid var(--c, var(--oro)); }
.candidatura h3 { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.siglas { font-size: .75rem; font-weight: 800; padding: .1rem .45rem; border-radius: 6px; background: var(--c, var(--oro)); color: #fff; }
.barra { height: 14px; background: var(--fondo); border: 1px solid var(--borde); border-radius: 99px; overflow: hidden; margin: .4rem 0 .2rem; }
.barra > i { display: block; height: 100%; background: var(--c, var(--oro)); transition: width .6s ease; }
.pct { font-size: 1.5rem; font-weight: 800; }
.voto-mio { outline: 3px solid var(--verde); }
.estado-votacion { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.cuenta { font-variant-numeric: tabular-nums; font-size: 1.4rem; font-weight: 800; color: var(--oro); }

/* ---- mapa de calor (cuadrícula de provincias) ---- */
.mapa { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 3px; max-width: 560px; margin: .5rem auto; }
.mapa .zona { aspect-ratio: 1; border-radius: 5px; display: grid; place-items: center; font-size: .6rem; font-weight: 700; color: #fff; background: var(--borde); cursor: default; overflow: hidden; }
.leyenda { display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: center; font-size: .85rem; }
.leyenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }

/* ---- pestañas, modal, avisos ---- */
.pestanas { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 12px; }
.pestanas .btn.activo { background: var(--primario); color: var(--primario-texto); border-color: transparent; }
.modal-fondo { position: fixed; inset: 0; background: rgba(8, 12, 24, .6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--tarjeta); border-radius: var(--radio); padding: 18px; width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.modal-botones { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: grid; gap: .4rem; width: min(480px, 92vw); }
.toast { background: #222b45; color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.toast-ok { background: #1f7a45; } .toast-error { background: #b3203a; } .toast-aviso { background: #a8650a; }

/* ---- acceso ---- */
.acceso { max-width: 460px; margin: 0 auto; padding: 24px 16px; }
.acceso .logo { display: block; width: 92px; margin: 0 auto 8px; }
.acceso h1 { text-align: center; }
.separador { display: flex; align-items: center; gap: .6rem; color: var(--suave); margin: 14px 0; font-size: .85rem; }
.separador::before, .separador::after { content: ''; flex: 1; height: 1px; background: var(--borde); }
.google-caja { display: flex; justify-content: center; min-height: 44px; }
.avatar { display: inline-flex; width: 32px; height: 32px; border-radius: 50%; align-items: center; justify-content: center; background: var(--oro-suave); color: var(--oro); font-weight: 800; }
.punto { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--rojo); }
.insignia-n { background: var(--rojo); color: #fff; border-radius: 99px; font-size: .7rem; padding: 0 .4rem; margin-left: .25rem; }
pre { white-space: pre-wrap; font: inherit; margin: 0; }
.texto-largo { white-space: pre-wrap; }
@media (min-width: 720px) { .nav { justify-content: center; } }

/* ---- MODOS: OFICIAL / PERSONALIZADO / OTROS (cada uno con su propio color para que no se confundan) ---- */
.modos { display: flex; gap: .35rem; padding: .55rem 0 .1rem; }
.modo { flex: 1 1 0; border: 2px solid var(--borde); background: var(--fondo); color: var(--suave); border-radius: 12px; padding: .45rem .3rem; font-weight: 700; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.modo.activo { background: var(--primario); color: var(--primario-texto); border-color: var(--primario); }
.cabecera { border-top: 4px solid var(--oro); }
:root[data-modo="personalizado"] { --primario: #0b6e6a; --oro: #0b8a84; --oro-suave: #d5f0ee; }
:root[data-modo="otros"] { --primario: #4a5568; --oro: #5a6b86; --oro-suave: #e3e8f0; }
@media (prefers-color-scheme: dark) {
  :root[data-modo="personalizado"]:not([data-tema="claro"]) { --primario: #4fd1c5; --oro: #4fd1c5; --oro-suave: #12302e; --primario-texto: #07201e; }
  :root[data-modo="otros"]:not([data-tema="claro"]) { --primario: #a0aec0; --oro: #a0aec0; --oro-suave: #232b3a; --primario-texto: #121722; }
}
:root[data-modo="personalizado"] body { background-image: linear-gradient(180deg, color-mix(in srgb, var(--oro) 7%, transparent), transparent 220px); }
:root[data-modo="otros"] body { background-image: linear-gradient(180deg, color-mix(in srgb, var(--oro) 8%, transparent), transparent 220px); }
.insignia.oro { background: var(--oro-suave); color: var(--oro); border-color: transparent; }
.fila input:not([type=checkbox]) { flex: 1 1 14rem; min-width: 0; }

/* ---- panel de administración ---- */
.admin-cab { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: 14px; }
.admin-cab h2 { margin: 0; } .admin-cab p { margin: .1rem 0 0; }
.admin-grupo { margin: 18px 0 8px; }
.tareas { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tarea { display: flex; flex-direction: column; gap: .15rem; text-align: left; border: 2px solid var(--naranja); background: var(--oro-suave); color: var(--texto); border-radius: 12px; padding: .8rem 1rem; cursor: pointer; font: inherit; }
.tarea-n { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--naranja); }
.menu-admin { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.menu-item { display: flex; align-items: center; gap: .8rem; text-align: left; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); border-radius: 12px; padding: .8rem 1rem; cursor: pointer; font: inherit; box-shadow: var(--sombra); }
.menu-item:hover { border-color: var(--oro); }
.menu-ic { font-size: 1.7rem; }
.menu-tx { flex: 1; display: flex; flex-direction: column; }
.menu-tx small { color: var(--suave); }
