/* ── Loterías · estilos ────────────────────────────────────────── */
:root {
  --primario: #8a1c1c;
  --primario-2: #b3261e;
  --oro: #c9971c;
  --fondo: #f6f1ea;
  --superficie: #ffffff;
  --texto: #201a17;
  --muted: #6d625b;
  --borde: #e6ddd2;
  --peligro: #c62828;
  --ok: #15803d;
  --aviso: #b45309;
  --radio: 14px;
  --sombra: 0 1px 3px rgba(40, 20, 10, .08), 0 4px 14px rgba(40, 20, 10, .05);
  --nav-alto: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --primario: #f08a80; --primario-2: #e5675c; --oro: #e2b84a;
    --fondo: #15110f; --superficie: #221c19; --texto: #f1e9e3; --muted: #ab9d94; --borde: #3a302b;
    --ok: #4ade80; --sombra: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo); color: var(--texto);
  padding-bottom: calc(var(--nav-alto) + env(safe-area-inset-bottom) + 12px);
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; margin-bottom: 10px; }
h3 { font-size: .95rem; margin: 12px 0 6px; }
.muted { color: var(--muted); }
.pequeno { font-size: .85rem; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.positivo { color: var(--ok); }
.negativo { color: var(--peligro); }

/* ── Cabecera y navegación ── */
#cabecera {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: #8a1c1c; color: #fff;
}
#cabecera select {
  flex: 1; margin: 0; min-height: 40px; background: rgba(255,255,255,.12); color: #fff;
  border: 1px solid rgba(255,255,255,.25); font-weight: 700;
}
#cabecera select option { color: #201a17; background: #fff; }
.btn-icono { color: #fff; background: none; border: 0; font-size: 1.4rem; padding: 4px 10px; border-radius: 8px; cursor: pointer; }
.btn-icono:hover { background: rgba(255,255,255,.12); }
#navegacion {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; justify-content: space-around;
  height: calc(var(--nav-alto) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--superficie); border-top: 1px solid var(--borde);
}
#navegacion button {
  flex: 1; border: 0; background: none; color: var(--muted); font: inherit; font-size: .7rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
#navegacion button span { font-size: 1.3rem; line-height: 1; filter: grayscale(.7); }
#navegacion button.activo { color: var(--primario); font-weight: 700; }
#navegacion button.activo span { filter: none; }
#principal { max-width: 760px; margin: 0 auto; padding: 14px 14px; }
.seccion { display: none; position: relative; }
.seccion.activa { display: block; animation: aparecer .18s ease-out; }
@keyframes aparecer { from { opacity: 0; transform: translateY(4px); } }

/* ── Tarjetas, formularios ── */
.tarjeta { background: var(--superficie); border-radius: var(--radio); box-shadow: var(--sombra); border: 1px solid var(--borde); padding: 16px; margin-bottom: 14px; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--texto);
  background: var(--fondo); border: 1px solid var(--borde); border-radius: 10px; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primario-2); outline-offset: 0; border-color: transparent; }
input.numero-grande { font-size: 2rem; font-weight: 800; letter-spacing: .18em; text-align: center; font-variant-numeric: tabular-nums; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--texto); font-size: .95rem; }
label.check input { width: 22px; height: 22px; min-height: 0; margin: 0; flex: none; accent-color: var(--primario); }
.fila-2, .fila-3 { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.fila-3 { grid-template-columns: 1fr 1fr 1fr; }
.segmentado { display: flex; background: var(--fondo); border: 1px solid var(--borde); border-radius: 10px; padding: 3px; margin: 4px 0 12px; }
.segmentado label { flex: 1; margin: 0; }
.segmentado input { display: none; }
.segmentado span { display: block; text-align: center; padding: 8px 4px; border-radius: 8px; color: var(--muted); font-weight: 600; cursor: pointer; font-size: .9rem; }
.segmentado input:checked + span { background: var(--primario); color: #fff; }
.nota-calculo { font-size: .88rem; margin: -4px 0 12px; padding: 8px 10px; border-radius: 8px; background: rgba(201,151,28,.12); }

/* ── Botones ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px;
  border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-primario { background: #8a1c1c; color: #fff; }
.btn-primario:hover { background: #721616; }
.btn-secundario { background: var(--superficie); color: var(--texto); border-color: var(--borde); }
.btn-secundario:hover { border-color: var(--primario-2); }
.btn-peligro { background: var(--peligro); color: #fff; }
.btn-enlace { background: none; border: 0; color: var(--primario-2); padding: 0; min-height: 0; font: inherit; font-weight: 600; cursor: pointer; }
.btn-pequeno { min-height: 34px; padding: 6px 10px; font-size: .85rem; }
.btn-bloque { display: flex; width: 100%; }
.btn:disabled { opacity: .55; cursor: wait; }
label.btn { color: inherit; margin: 0; font-size: 1rem; }
.acciones-fila { display: flex; gap: 10px; margin-bottom: 14px; }
.acciones-fila .btn { flex: 1; }
.fab {
  position: fixed; right: max(16px, calc(50vw - 370px)); bottom: calc(var(--nav-alto) + 16px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; border: 0; background: #8a1c1c; color: #fff; font-size: 1.8rem;
  box-shadow: 0 6px 18px rgba(138,28,28,.4); cursor: pointer; z-index: 9;
}

/* ── Avisos ── */
.aviso { border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; font-size: .92rem; }
.aviso-info { background: rgba(201,151,28,.12); border: 1px solid rgba(201,151,28,.4); }
.aviso-error { background: rgba(198,40,40,.1); border: 1px solid rgba(198,40,40,.35); color: var(--peligro); }
.aviso-ok { background: rgba(21,128,61,.1); border: 1px solid rgba(21,128,61,.35); }

/* ── Pestañas ── */
.pestanas { display: flex; gap: 6px; margin-bottom: 12px; }
.pestanas button { flex: 1; border: 1px solid var(--borde); background: var(--superficie); color: var(--texto); border-radius: 999px; padding: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.pestanas button.activa { background: #8a1c1c; color: #fff; border-color: #8a1c1c; }

/* ── Cifras del resumen ── */
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.cifra { background: var(--superficie); border: 1px solid var(--borde); border-radius: 12px; padding: 12px; box-shadow: var(--sombra); }
.cifra small { display: block; color: var(--muted); font-size: .78rem; }
.cifra b { display: block; font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.cifra .detalle { font-size: .78rem; color: var(--muted); }
.cuenta-atras { text-align: center; padding: 18px; background: linear-gradient(135deg, #8a1c1c, #b3261e); color: #fff; border-radius: var(--radio); margin-bottom: 14px; }
.cuenta-atras b { font-size: 2rem; display: block; }

/* ── Listas ── */
.lista { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; gap: 12px; align-items: center; background: var(--superficie); border: 1px solid var(--borde);
  border-radius: 12px; padding: 10px 12px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%;
}
.item .cuerpo { flex: 1; min-width: 0; }
.item .derecha { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.item .secundario { font-size: .82rem; color: var(--muted); }
.item.agotado { opacity: .6; }
.boleto {
  flex: none; font-weight: 800; font-size: 1.25rem; letter-spacing: .06em; font-variant-numeric: tabular-nums;
  background: #f6e7c8; color: #6b1515; border: 1px dashed #c9971c; border-radius: 8px; padding: 6px 8px; min-width: 88px; text-align: center;
}
.boleto.premiado { background: #c9971c; color: #fff; border-style: solid; }
.miniatura { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; }
.etiqueta { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; background: var(--fondo); border: 1px solid var(--borde); color: var(--muted); white-space: nowrap; }
.etiqueta.roja { background: rgba(198,40,40,.1); color: var(--peligro); border-color: rgba(198,40,40,.3); }
.etiqueta.verde { background: rgba(21,128,61,.1); color: var(--ok); border-color: rgba(21,128,61,.3); }
.etiqueta.oro { background: rgba(201,151,28,.15); color: #8a6410; border-color: rgba(201,151,28,.4); }
.vacio { text-align: center; color: var(--muted); padding: 24px 8px; }
.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th, .tabla td { padding: 7px 4px; border-bottom: 1px solid var(--borde); text-align: right; font-variant-numeric: tabular-nums; }
.tabla th:first-child, .tabla td:first-child { text-align: left; }
.tabla th { color: var(--muted); font-weight: 600; font-size: .78rem; }
.apuntes { margin: 6px 0 0; padding: 0; list-style: none; font-size: .85rem; }
.apuntes li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px dashed var(--borde); }

/* ── Operación: líneas de entrego/recibo ── */
.linea { display: grid; grid-template-columns: 1fr 90px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--borde); }
.linea input { margin: 0; text-align: center; }
.linea-recibo { display: grid; grid-template-columns: 1.3fr 1fr .8fr auto; gap: 6px; align-items: end; padding: 8px 0; border-bottom: 1px solid var(--borde); }
.linea-recibo label { margin: 0; font-size: .72rem; }
.linea-recibo .extra { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.saldo-op { font-weight: 700; font-size: 1.05rem; text-align: center; padding: 10px; border-radius: 10px; background: var(--fondo); margin: 10px 0; }

/* ── Foto y lectura del número ── */
.foto-caja { margin-bottom: 12px; }
.foto-caja img { width: 100%; max-height: 45vh; object-fit: contain; border-radius: 10px; background: #000; display: block; margin-bottom: 8px; }
.candidatos { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.candidatos button { font: inherit; font-weight: 800; letter-spacing: .1em; padding: 6px 12px; border-radius: 8px; border: 1px dashed var(--oro); background: #f6e7c8; color: #6b1515; cursor: pointer; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 3px solid rgba(0,0,0,.15); border-top-color: var(--primario); border-radius: 50%; animation: girar .8s linear infinite; vertical-align: -3px; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ── Premios ── */
.premio-grande { text-align: center; padding: 18px; border-radius: var(--radio); background: linear-gradient(135deg, #c9971c, #e2b84a); color: #3a2604; margin-bottom: 14px; }
.premio-grande b { display: block; font-size: 2.2rem; }
.grupo-premios { margin-bottom: 10px; }
.grupo-premios .nums { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.grupo-premios .nums span { font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .06em; background: #f6e7c8; color: #6b1515; padding: 2px 8px; border-radius: 6px; }

/* ── Modal, menú y toast ── */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 20px));
  max-height: calc(100vh - 30px); background: var(--superficie); color: var(--texto); box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
dialog::backdrop { background: rgba(20, 10, 5, .55); }
#modal-contenido { padding: 18px; }
#modal-contenido h2 { margin-bottom: 12px; }
.modal-acciones { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.modal-acciones .izquierda { margin-right: auto; }
.menu { display: flex; flex-direction: column; gap: 6px; }
.menu button, .menu a { text-align: left; justify-content: flex-start; }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-alto) + 20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: #201a17; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: .92rem; transition: .2s; z-index: 50; max-width: calc(100vw - 32px);
}
#toast.visible { opacity: 1; transform: translateX(-50%); }
#toast.error { background: var(--peligro); }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--superficie); border-radius: 18px; box-shadow: var(--sombra); border: 1px solid var(--borde); padding: 28px 22px; width: 100%; max-width: 380px; text-align: center; }
.login-card form { text-align: left; margin-top: 18px; }
.login-card h1 { margin-top: 8px; }
.login-card p { margin: 4px 0 0; }
@media (max-width: 380px) { .fila-3 { grid-template-columns: 1fr 1fr; } .boleto { min-width: 74px; font-size: 1.1rem; } }
