/* =========================================================================
   Sistema de diseño — claro, moderno, azul como acento sutil.
   ========================================================================= */
:root {
  /* Acento (azul de marca, usado con moderación) */
  --accent: #0b5fd0;
  --accent-strong: #0a4fad;
  --accent-soft: #eaf1fc;
  --accent-ring: rgba(11, 95, 208, 0.22);

  /* Estados */
  --ok: #0f8a55;      --ok-soft: #e8f6ef;
  --error: #d23f4f;   --error-soft: #fdecee;
  --warn: #9a6a00;    --warn-soft: #fff4e1;

  /* Tinta / neutros */
  --ink: #1b2433;
  --ink-2: #586273;
  --ink-3: #8b94a4;
  --line: #e7eaf1;
  --line-strong: #d7dce6;

  /* Superficies / fondo */
  --bg: #f3f6fb;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 10px 28px rgba(16, 24, 40, 0.06);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);

  /* Compat con nombres viejos (por si algo los referencia) */
  --azul: var(--accent);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 12% -8%, #e6eefb 0%, rgba(230, 238, 251, 0) 60%),
    radial-gradient(900px 480px at 100% 0%, #eaf3fb 0%, rgba(234, 243, 251, 0) 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Layout -------------------------------------------------------------- */
.contenedor { max-width: 460px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.panel .contenedor { max-width: 1120px; }

/* Tipografía ---------------------------------------------------------- */
h1 { font-size: 1.45rem; line-height: 1.2; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0 0 0.8rem; letter-spacing: -0.01em; }
h3 { font-size: 1rem; margin: 0 0 0.6rem; }
.subtitulo { color: var(--ink-2); margin: -0.2rem 0 0.6rem; }
.hora { font-size: 1.1rem; }
.hora strong { color: var(--accent); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Tarjetas (glass sutil) --------------------------------------------- */
.tarjeta {
  background: var(--surface);
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-bottom: 1rem;
}

/* Botones ------------------------------------------------------------- */
.boton, button, .item-resultado {
  font-family: inherit;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  margin-top: 1rem; padding: 0.7rem 1.1rem; min-height: 46px;
  font-size: 1rem; font-weight: 600; line-height: 1;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); cursor: pointer; text-decoration: none;
}
.boton:hover { background: #f7f9fc; text-decoration: none; }
.boton:active { transform: translateY(1px); }
.boton.primario {
  width: 100%; background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 700; box-shadow: 0 6px 16px rgba(11, 95, 208, 0.22);
}
.boton.primario:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.boton.primario.cargado { background: var(--ok); border-color: var(--ok); box-shadow: 0 6px 16px rgba(15, 138, 85, 0.22); }
.boton.votar { background: var(--ok); border-color: var(--ok); color: #fff; }
.boton.votar:hover { filter: brightness(0.96); }
.boton.cancelar { background: #fff; border-color: var(--line-strong); color: var(--error); }
.boton.cancelar:hover { background: var(--error-soft); }
.boton.wpp { background: #25d366; border-color: #25d366; color: #fff; width: 100%; }
.boton.wpp:hover { filter: brightness(0.96); }
.boton.inconveniente { width: 100%; background: var(--error-soft); border-color: #f3c6cc; color: var(--error); font-weight: 700; }
.boton.inconveniente:hover { background: #fbd4d9; border-color: #eeb3bb; }
.boton.instalar { width: 100%; background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); font-weight: 700; }
.boton.chico { margin-top: 0; padding: 0.5rem 0.8rem; min-height: 40px; font-size: 0.9rem; }

/* Formularios --------------------------------------------------------- */
label { display: block; margin: 1rem 0 0.35rem; font-weight: 600; font-size: 0.95rem; color: var(--ink); }
input, select, textarea {
  width: 100%; padding: 0.7rem 0.85rem; min-height: 46px;
  font-size: 1rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring);
}
button:focus-visible, a:focus-visible, .item-resultado:focus-visible {
  outline: none; box-shadow: 0 0 0 4px var(--accent-ring);
}

.campo-clave { position: relative; }
.campo-clave input { padding-right: 3rem; }
.ojito {
  position: absolute; right: 0.3rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 1.3rem; cursor: pointer;
  min-height: 40px; width: 44px; line-height: 1;
}

/* Avisos -------------------------------------------------------------- */
.aviso { padding: 0.75rem 0.95rem; border-radius: var(--radius-sm); margin: 0.7rem 0; font-size: 0.95rem; border: 1px solid transparent; }
.aviso.ok { background: var(--ok-soft); color: var(--ok); border-color: #c7e8d6; }
.aviso.error { background: var(--error-soft); color: var(--error); border-color: #f3c6cc; }
.aviso.advertencia { background: var(--warn-soft); color: var(--warn); border-color: #f0dcae; }
ul.aviso { padding-left: 1.8rem; }

.link-secundario { margin-top: 1.2rem; text-align: center; font-size: 0.95rem; }
.hint { color: var(--ink-3); font-style: italic; margin: 0.6rem 0; }
.hint.vacio { color: var(--error); font-style: normal; }

/* ---- Fiscal: barra superior y logout ---- */
.barra-fiscal { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; margin-bottom: 0.9rem; }
.mesa-actual {
  font-size: 1.3rem; font-weight: 800; color: var(--accent-strong);
  letter-spacing: -0.01em; white-space: nowrap;
}
.logout { margin: 0; }
.boton-logout {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(255, 255, 255, 0.85); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.45rem 0.85rem; min-height: 40px;
  font-size: 0.9rem; font-weight: 600; line-height: 1; cursor: pointer;
  color: var(--ink-2); box-shadow: var(--shadow-sm); white-space: nowrap;
}
.boton-logout svg { flex: none; }
.boton-logout:hover { background: var(--error-soft); border-color: #f0c2c8; color: var(--error); }
.fiscal { color: var(--ink-2); }

/* ---- Fiscal: buscador / resultados / panel ---- */
.buscador label { font-size: 1.15rem; margin-top: 0; }
#dni {
  font-size: 1.6rem; font-weight: 700; min-height: 58px; letter-spacing: 0.05em;
}
#dni::placeholder { font-size: 1rem; font-weight: 400; letter-spacing: normal; }
ul.resultados { list-style: none; padding: 0; margin: 0.7rem 0 0; display: grid; gap: 0.5rem; }
.item-resultado {
  width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.95rem 1rem; cursor: pointer; font-size: 1.2rem;
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
}
.item-resultado:hover { border-color: var(--accent); background: var(--accent-soft); }
.item-resultado strong { font-weight: 700; }
.item-resultado .dni { color: var(--ink-3); font-size: 1rem; white-space: nowrap; }

.panel:empty { display: none; }
.panel-votante {
  margin-top: 1rem; padding: 1.1rem; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid #d4e3f8;
}
.panel-votante h2 { margin: 0 0 0.3rem; color: var(--accent-strong); }
.panel-votante p { margin: 0.2rem 0; color: var(--ink-2); }
.acciones { display: flex; gap: 0.6rem; margin-top: 1rem; }
.acciones .boton { margin-top: 0; flex: 1; }

/* ---- Acordeón de marcados ---- */
.acordeon { margin-bottom: 1rem; }
.acordeon summary {
  list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  font-size: 1.05rem; font-weight: 700; color: var(--accent-strong);
  background: var(--accent-soft); border: 1px solid #d4e3f8;
  border-radius: var(--radius-sm); padding: 0.9rem 1.1rem; min-height: 52px;
  cursor: pointer; user-select: none;
}
.acordeon summary::-webkit-details-marker { display: none; }
.acordeon summary::after {
  content: "▾"; font-size: 0.95rem; color: var(--accent); transition: transform .15s ease;
}
.acordeon summary:hover { background: #dceafe; }
.acordeon[open] summary { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.acordeon[open] summary::after { transform: rotate(180deg); }
.acordeon[open] #marcados {
  border: 1px solid #d4e3f8; border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 0.6rem 1.1rem 0.9rem; background: var(--surface-solid);
}
ul.lista-marcados { list-style: none; padding: 0; margin: 0; }
ul.lista-marcados li {
  display: flex; justify-content: space-between; align-items: center; gap: 0.6rem;
  padding: 0.65rem 0; border-bottom: 1px solid var(--line);
}
ul.lista-marcados .dato { color: var(--ink); font-size: 0.95rem; }
.boton-no-voto {
  background: #fff; color: var(--error); border: 1px solid #f0c2c8;
  border-radius: 8px; padding: 0.45rem 0.75rem; min-height: 40px; cursor: pointer; white-space: nowrap; font-weight: 600;
}
.boton-no-voto:hover { background: var(--error-soft); }

/* ---- Escrutinio ---- */
.num-lista { color: var(--ink-3); font-weight: 400; font-size: 0.88rem; }
.total-escrutinio { font-size: 1.15rem; margin: 1.2rem 0 0.4rem; }
.total-escrutinio #total { color: var(--accent); font-weight: 800; }
.ref-marcados { display: block; font-size: 0.85rem; color: var(--ink-3); margin-top: 0.2rem; }

/* =========================================================================
   Dashboard / panel
   ========================================================================= */
.barra-panel {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--surface); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6); box-shadow: var(--shadow-sm);
  border-radius: var(--radius); padding: 0.7rem 1rem; margin-bottom: 1rem; color: var(--ink);
}
.barra-panel strong { color: var(--accent-strong); }
.acciones-panel { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.acciones-panel form { margin: 0; }

.controles { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin: 0.4rem 0 0.8rem; }
.controles label { margin: 0; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 0.4rem; }
.controles input, .controles select { width: auto; min-height: 42px; }
.generado { color: var(--ink-3); font-size: 0.88rem; margin: 0 0 0.8rem; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.9rem; }
.card {
  background: var(--surface); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.6); box-shadow: var(--shadow-sm);
  border-radius: var(--radius); padding: 1.1rem; text-align: center;
}
.card h3 { margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.card .big { margin: 0; font-size: 2rem; font-weight: 800; color: var(--accent); letter-spacing: -0.02em; }

.fila-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin: 1rem 0; }
.chart {
  height: 300px; background: var(--surface-solid);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm); border-radius: var(--radius);
}

.grid-tablas { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.grid-tablas section, .incongruencias, .escrutinio-resultados {
  background: var(--surface-solid); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); border-radius: var(--radius); padding: 1.1rem; margin-top: 1rem;
}
.panel table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.panel th, .panel td { text-align: left; padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--line); }
.panel thead th { color: var(--ink-2); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.02em; }
.panel tbody tr:hover { background: var(--accent-soft); }
.exportar { font-size: 0.82rem; color: var(--accent); margin-left: 0.5rem; font-weight: 600; }
.acciones-sesion { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.form-clave { display: inline-flex; gap: 0.4rem; margin: 0; }
.form-clave input { padding: 0.45rem 0.6rem; min-height: 40px; width: auto; max-width: 150px; }
tr.total td, tr.extra td { font-weight: 600; color: var(--ink-2); }

/* Zona de peligro (administración) */
.zona-peligro { border: 1px solid #f1cfd4; box-shadow: 0 1px 2px rgba(210, 63, 79, 0.08); }
.zona-peligro h2 { color: var(--error); }
.zona-peligro .controles { padding: 0.5rem 0; border-bottom: 1px dashed var(--line); }
.zona-peligro .controles:last-child { border-bottom: none; }
code { background: #f1f3f8; border: 1px solid var(--line); border-radius: 6px; padding: 0.05rem 0.35rem; font-size: 0.88em; }

/* Pestañas del dashboard */
[x-cloak] { display: none !important; }
.tabs {
  display: flex; gap: 0.25rem; flex-wrap: wrap; margin-bottom: 1rem;
  background: var(--surface); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6); box-shadow: var(--shadow-sm);
  border-radius: 999px; padding: 0.3rem;
}
.tab {
  margin-top: 0; min-height: 42px; padding: 0.5rem 1.1rem; border: none; border-radius: 999px;
  background: transparent; color: var(--ink-2); font-weight: 600; font-size: 0.95rem; cursor: pointer;
}
.tab:hover { background: rgba(11, 95, 208, 0.06); color: var(--ink); }
.tab.activa { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(11, 95, 208, 0.22); }

.badge {
  display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.78rem;
  font-weight: 700; background: #eef1f6; color: var(--ink-2); border: 1px solid var(--line);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: #c7e8d6; }
.muted { color: var(--ink-3); font-size: 0.85rem; }

/* Accesibilidad: respetar reduce-motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
