/* Pantallas del personal: shell de app (barra superior + contenido a pantalla completa). */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.shell.claro { background: var(--panel); color: var(--ink); }

.topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem 1.25rem;
  flex-wrap: wrap;
  padding: 0.7rem 1.25rem;
  color: var(--crema);
  background: var(--noche);
  border-bottom: 1px solid rgba(255, 248, 234, 0.14);
}
.marca-mini { font-family: var(--display); font-weight: 800; font-size: 1.15rem; letter-spacing: -0.03em; text-decoration: none; }
.marca-mini span { color: var(--oro); }
.topbar-titulo { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #d6d1c4; font-weight: 500; }
.topbar-nav { display: flex; gap: 0.25rem; order: 3; flex-basis: 100%; }
.topbar-nav:empty { display: none; }
.nav-link {
  padding: 0.45rem 0.8rem;
  color: #d6d1c4;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
}
.nav-link:hover { background: rgba(255, 248, 234, 0.1); color: var(--crema); }
.nav-link[aria-current="page"] { color: var(--ink); background: var(--oro); }
.btn-topbar {
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-weight: 600;
  color: var(--crema);
  background: transparent;
  border: 1.5px solid rgba(255, 248, 234, 0.4);
  border-radius: 8px;
  cursor: pointer;
}
.btn-topbar { margin-left: auto; }
.btn-topbar:hover { background: rgba(255, 248, 234, 0.12); }
.nav-link:focus-visible, .btn-topbar:focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; }

.contenido { flex: 1; display: flex; flex-direction: column; gap: 1rem; min-height: 0; padding: 1.25rem; }
.solo-lector { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.vacio { margin: 1rem 0 0; color: var(--ink-soft); }
.nota { margin: 0; font-size: 0.9rem; color: var(--ink-soft); }
.aviso-ok { margin: 0; padding: 0.65rem 0.85rem; background: #d4f6ea; border-radius: 8px; font-weight: 600; }

/* ---------- Reporte (admin) y superadmin ---------- */
.resumen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  margin: 0;
  background: var(--superficie);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.resumen div {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.95rem 1.25rem;
  border-right: 1px solid var(--line);
}
.resumen div:last-child { border-right: 0; }
.resumen dt { font-size: 0.95rem; color: var(--ink-soft); }
.resumen dd { margin: 0; font-family: var(--display); font-weight: 800; font-size: 1.75rem; line-height: 1; font-variant-numeric: tabular-nums; }

.controles { display: grid; gap: 0.75rem; align-items: end; }
.controles label { margin-top: 0; }
.acciones { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.cuenta { margin: 0; font-weight: 600; }
.barra { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; }

.tabla-wrap {
  flex: 1;
  min-height: 12rem;
  overflow: auto;
  background: var(--superficie);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.25rem 0.5rem;
  scrollbar-color: #8a857a transparent;
}
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; min-width: 64rem; }
th, td { padding: 0.7rem 0.9rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
  background: #faf8f3;
}
tbody th { font-weight: 600; }
td.num { font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #faf6e8; }
tbody tr:last-child > * { border-bottom: 0; }

.form-ip { display: flex; gap: 0.6rem; align-items: end; max-width: 30rem; }
.form-ip > div { flex: 1; }

/* ---------- Puerta: todo el alto es el resultado ---------- */
.puerta-shell { background: var(--noche); transition: background 0.25s; }
.puerta-shell[data-estado="ok"], .puerta-shell[data-estado="hecho"] { background: #0b6b4e; }
.puerta-shell[data-estado="aviso"] { background: var(--oro); color: var(--ink); }
.puerta-shell[data-estado="no"] { background: #b3261e; }
.puerta-shell[data-estado="aviso"] .topbar { color: var(--ink); background: transparent; border-color: rgba(27, 23, 64, 0.2); }
.puerta-shell[data-estado="aviso"] .marca-mini span { color: var(--ink); }
.puerta-shell[data-estado="aviso"] .topbar-titulo { color: var(--ink); }
.puerta-shell[data-estado="aviso"] .btn-topbar { color: var(--ink); border-color: rgba(27, 23, 64, 0.5); }
.puerta-shell:not([data-estado]) .error, .puerta-shell[data-estado] .error { color: #ffd9d4; }

.buscador {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0;
}
.buscador input { min-height: 4.25rem; font-size: 2rem; text-align: center; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.buscador .btn { width: auto; margin: 0; padding-inline: 1.75rem; min-height: 4.25rem; box-shadow: none; }
#err-buscar { max-width: 46rem; margin: 0.75rem auto 0; padding: 0 1.25rem; }

.zona { flex: 1; display: grid; place-items: center; padding: 1.5rem 1.25rem 2.5rem; text-align: center; }
.reposo { margin: 0; max-width: 18ch; font-family: var(--display); font-weight: 700; font-size: clamp(1.75rem, 4vw, 3rem); line-height: 1.1; color: rgba(255, 248, 234, 0.55); text-wrap: balance; }
.resultado { width: 100%; max-width: 56rem; display: grid; justify-items: center; gap: 0.75rem; color: #fff; }
.puerta-shell[data-estado="aviso"] .resultado { color: var(--ink); }
.estado { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(2.5rem, 9vw, 6rem); line-height: 1; letter-spacing: -0.03em; text-wrap: balance; }
.quien { margin: 0.25rem 0 0; font-size: clamp(1.5rem, 4vw, 2.75rem); font-weight: 600; line-height: 1.15; text-wrap: balance; }
.quien:empty { display: none; }
.datos { margin: 0.5rem 0 0; padding: 0; list-style: none; font-size: 1.25rem; opacity: 0.92; }
.datos:empty { display: none; }
.resultado .btn { width: min(100%, 30rem); min-height: 4.75rem; margin-top: 1.5rem; font-size: 1.4rem; color: var(--ink); background: #fff; box-shadow: none; }
.resultado .btn:hover { background: #ffe9b0; }

/* ---------- Sorteo: escenario + orden de salida ---------- */
.sorteo-cuerpo { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.escenario {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 70dvh;
  padding: 2rem 1.25rem 2.5rem;
  text-align: center;
  background: var(--noche-2);
}
.escenario-in { width: 100%; max-width: 62rem; }
.escenario h2 { color: var(--crema); font-size: clamp(1.5rem, 3.2vw, 2.5rem); }
.meta { margin: 0.5rem 0 0; color: #d6d1c4; }
.pantalla { display: grid; place-content: center; gap: 0.5rem; min-height: 15rem; padding: 2rem 0; }
.pantalla-rol { margin: 0; min-height: 1.5em; font-weight: 700; font-size: 1.25rem; letter-spacing: 0.04em; color: var(--oro); text-transform: uppercase; }
.pantalla-nombre { margin: 0; font-family: var(--display); font-weight: 800; line-height: 0.98; letter-spacing: -0.035em; font-size: clamp(2.5rem, 9vw, 6rem); text-wrap: balance; }
.escenario .btn { width: min(100%, 26rem); margin: 1rem auto 0; min-height: 4rem; font-size: 1.25rem; }
.escenario .btn:disabled { opacity: 0.55; box-shadow: none; }
.escenario .error { color: #ffd9d4; }

.lateral { padding: 1.5rem 1.25rem 2rem; background: var(--panel); color: var(--ink); overflow: auto; }
.lateral h3 { font-size: 1.15rem; margin-bottom: 0.75rem; }
.resultados { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.5rem; }
.resultados li {
  display: grid;
  grid-template-columns: 2.25rem 1fr auto;
  gap: 0.15rem 0.75rem;
  align-items: center;
  padding: 0.65rem 0.8rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.res-num { grid-row: 1 / span 2; font-family: var(--display); font-weight: 800; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.res-nombre { grid-column: 2; font-weight: 600; }
.res-detalle { grid-column: 2; font-size: 0.875rem; color: var(--ink-soft); }
.resultados li .btn-tabla { grid-column: 3; grid-row: 1 / span 2; }
.resultados li.anulado { background: #ece8dd; }
.resultados li.anulado .res-nombre { text-decoration: line-through; color: var(--ink-soft); }
.lateral .acciones { margin-top: 1rem; }
.lateral .nota { margin-top: 1rem; }

/* ---------- Escritorio: las pantallas ocupan exactamente el alto de la ventana ---------- */
@media (min-width: 48rem) {
  .marca-mini { font-size: 1.4rem; }
  .topbar { padding-inline: 2rem; }
  .topbar-titulo { flex: 0 1 auto; }
  .topbar-nav { order: 0; flex-basis: auto; margin-left: auto; }
  .topbar-nav:not(:empty) + .btn-topbar { margin-left: 0; }
  .contenido { padding: 1.5rem 2rem 2rem; }
  .controles { grid-template-columns: 16rem minmax(0, 1fr) auto; }
  .shell.fijo { height: 100dvh; }
}
@media (min-width: 60rem) {
  .sorteo-shell { height: 100dvh; }
  .sorteo-cuerpo { flex-direction: row; }
  .escenario { min-height: 0; padding: 2rem 3rem; }
  .lateral { flex: 0 0 26rem; border-left: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  .puerta-shell { transition: none; }
}

/* ---------- Importar invitados ---------- */
.importar-grid { gap: 1.25rem; }
.importar-pasos h2 { font-size: 1.5rem; margin-bottom: 1rem; }
.importar-resultado h2 { font-size: 1.5rem; margin-bottom: 1rem; }
.importar-resultado h3 { font-size: 1.05rem; margin: 1.25rem 0 0.5rem; }
.como { margin: 0 0 1.25rem; padding: 0; list-style: none; display: grid; gap: 1rem; counter-reset: paso; }
.como li { display: grid; gap: 0.25rem; padding-left: 2.5rem; position: relative; counter-increment: paso; }
.como li::before {
  content: counter(paso);
  position: absolute; left: 0; top: 0;
  width: 1.75rem; height: 1.75rem; display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; color: var(--crema); background: var(--ink); border-radius: 50%;
}
.como li span { color: var(--ink-soft); }
.como .btn-sec { justify-self: start; margin-top: 0.4rem; }

.soltar {
  display: grid; place-content: center; gap: 0.35rem; margin: 0; padding: 2rem 1rem; min-height: 9rem; text-align: center;
  font-weight: 400; background: #fff; border: 2px dashed #8a857a; border-radius: 14px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.soltar:hover, .soltar.encima { border-color: var(--ink); background: #ffe9b0; }
.soltar-titulo { font-weight: 700; font-size: 1.1rem; }
.soltar-sub { color: var(--ink-soft); overflow-wrap: anywhere; }
#archivo:focus-visible + .soltar { outline: 3px solid var(--foco); outline-offset: 2px; }

.importar-resultado { background: var(--superficie); border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem; min-height: 14rem; overflow: auto; }
.vacio-grande { margin: 0; display: grid; place-content: center; min-height: 12rem; text-align: center; color: var(--ink-soft); font-size: 1.1rem; }
.vacio-grande[hidden] { display: none; }
.tabla-corta { min-height: 0; max-height: 18rem; }
.tabla-chica { min-width: 0; }
.acciones-res { margin-top: 1.25rem; align-items: center; }
.btn-importar { width: auto; margin: 0; padding-inline: 2rem; }
.enlace-btn { display: inline-flex; align-items: center; text-decoration: none; }

@media (min-width: 60rem) {
  .importar-grid { display: grid; grid-template-columns: minmax(22rem, 28rem) minmax(0, 1fr); align-items: start; gap: 2rem; }
  .importar-resultado { align-self: stretch; }
}
.importar-resultado .nota { margin-top: 0.6rem; }
.resumen-menus { margin-top: -0.25rem; background: transparent; border-style: dashed; }
.resumen-menus dd { font-size: 1.4rem; }

/* Pestañas del importador y listado de micros */
.tabs { display: inline-flex; gap: 0.25rem; padding: 0.25rem; margin-bottom: 1.25rem; background: #e6e1d4; border-radius: 12px; }
.tab { min-height: 2.5rem; padding: 0.4rem 1rem; font: inherit; font-weight: 600; color: var(--ink-soft); background: transparent; border: 0; border-radius: 9px; cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab[aria-pressed="true"] { color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(13, 13, 11, 0.18); }
.tab:focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; }
#catalogo { margin-top: 1.5rem; }
#catalogo:first-child, .importar-resultado > #vacio-res[hidden] + #res[hidden] + #catalogo { margin-top: 0; }
.fila-micro th { background: #f2efe8; font-family: var(--display); }
.fila-nota td { color: var(--ink-soft); font-size: 0.9rem; padding-top: 0.2rem; }
tr.oculta td { color: var(--ink-soft); }

/* El Excel es la descarga principal; el CSV queda como alternativa */
.btn-excel { background: var(--oro); border-color: var(--ink); }
.btn-excel:hover { background: var(--oro-hover); }

/* ---------- Sorteo: el ganador sale en el tablero ---------- */
.sr-solo { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.flap { --cw: min(56px, calc((100vw - 2.5rem - 30px) / 16)); display: grid; gap: 0.5rem; justify-content: center; margin: 0.25rem 0; }
.flap .celdas { justify-content: center; }
.flap .celda { font-size: calc(var(--cw) * 1.1); }
.flap.gana .celda { color: var(--ink); background: linear-gradient(to bottom, #ffc23a 0 50%, var(--oro) 50% 100%); }
.flap.gana .celda::after { background: #b27a00; }
@media (min-width: 60rem) { .flap { --cw: min(56px, calc((100vw - 26rem - 6rem - 30px) / 16)); } }

/* Acciones por fila del reporte */
.acciones-fila { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.btn-eliminar { color: #fff; background: var(--error); }
.btn-eliminar:hover { background: #8f1d17; }
