:root {
  --fondo: #f4f1ec; --superficie: #ffffff; --superficie2: #ece7df; --borde: #d9d1c4;
  --texto: #2a2622; --suave: #6f665c; --acento: #c8642a; --acento-texto: #ffffff;
  --verde: #4f8a3c; --ambar: #b7841f; --rojo: #b84a3a; --gris: #8a8178;
  --terminal: #1c1a18; --terminal-texto: #e6e0d6;
  --radio: 10px; --sombra: 0 1px 3px rgba(0,0,0,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #151311; --superficie: #1f1c19; --superficie2: #2a2622; --borde: #3a342e;
    --texto: #ece6dc; --suave: #a59b8f; --acento: #e07a3c; --verde: #79b363; --ambar: #d9a441; --rojo: #d76a58;
    --gris: #8a8178; --terminal: #0f0e0d; --sombra: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fondo: #151311; --superficie: #1f1c19; --superficie2: #2a2622; --borde: #3a342e;
  --texto: #ece6dc; --suave: #a59b8f; --acento: #e07a3c; --verde: #79b363; --ambar: #d9a441; --rojo: #d76a58;
  --gris: #8a8178; --terminal: #0f0e0d; --sombra: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--fondo); color: var(--texto); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1rem; }
code { background: var(--superficie2); padding: .1em .35em; border-radius: 4px; }
.nota { color: var(--suave); font-size: .85rem; margin: .5rem 0 0; }
[hidden] { display: none !important; }

/* barra superior */
.barra { display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; background: var(--superficie);
  border-bottom: 1px solid var(--borde); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.marca { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; }
.marca img { border-radius: 6px; }
.resumen { flex: 1; color: var(--suave); font-size: .9rem; min-width: 12rem; }
.resumen b { color: var(--texto); }
.usuario { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.rol { font-size: .75rem; padding: .1rem .45rem; border-radius: 99px; background: var(--superficie2); color: var(--suave); }

.pestanas { display: flex; gap: .25rem; padding: .5rem 1rem 0; overflow-x: auto; border-bottom: 1px solid var(--borde);
  background: var(--superficie); position: sticky; top: 53px; z-index: 4; scrollbar-width: none; }
.pestanas button { border: 0; background: none; color: var(--suave); padding: .55rem .8rem; font: inherit; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; }
.pestanas button.activa { color: var(--texto); border-color: var(--acento); font-weight: 600; }

main { padding: 1rem; max-width: 1400px; margin: 0 auto; }
.panel { display: none; }
.panel.activa { display: block; }

/* botones y campos */
.btn { background: var(--acento); color: var(--acento-texto); border: 1px solid transparent; border-radius: 8px;
  padding: .45rem .85rem; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 36px; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.fantasma { background: transparent; color: var(--texto); border-color: var(--borde); font-weight: 500; }
.btn.peligro { background: var(--rojo); }
.btn.mini { padding: .25rem .55rem; min-height: 30px; font-size: .85rem; }
input, select, textarea { font: inherit; color: var(--texto); background: var(--superficie); border: 1px solid var(--borde);
  border-radius: 8px; padding: .4rem .6rem; min-height: 36px; max-width: 100%; }
textarea { width: 100%; min-height: 5rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .pestanas button:focus-visible {
  outline: 2px solid var(--acento); outline-offset: 1px; }
.fila-herr { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.en-linea { display: flex; gap: .5rem; flex: 1; min-width: 16rem; }
.en-linea input { flex: 1; min-width: 0; }
.chk { display: flex; align-items: center; gap: .3rem; color: var(--suave); font-size: .9rem; }
.chk input { min-height: 0; }

/* tarjetas de mapa */
.rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.caja, .mapa { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: .9rem; box-shadow: var(--sombra); }
.mapa header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.mapa h3 { margin: 0; font-size: 1.05rem; }
.estado { font-size: .78rem; font-weight: 600; padding: .15rem .55rem; border-radius: 99px; white-space: nowrap; }
.estado.arriba { background: color-mix(in srgb, var(--verde) 18%, transparent); color: var(--verde); }
.estado.parado { background: color-mix(in srgb, var(--rojo) 18%, transparent); color: var(--rojo); }
.estado.transicion { background: color-mix(in srgb, var(--ambar) 20%, transparent); color: var(--ambar); }
.estado.desconocido { background: var(--superficie2); color: var(--gris); }
.datos { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .8rem; margin: 0 0 .7rem; font-size: .88rem; }
.datos dt { color: var(--suave); }
.datos dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.medidor { height: 6px; border-radius: 3px; background: var(--superficie2); overflow: hidden; margin: -.1rem 0 .35rem; grid-column: 1 / -1; }
.medidor i { display: block; height: 100%; background: var(--verde); }
.medidor i.medio { background: var(--ambar); }
.medidor i.alto { background: var(--rojo); }
.acciones-mapa { display: flex; flex-wrap: wrap; gap: .4rem; }

.nucleos { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: .4rem; }
.nucleo { background: var(--superficie2); border-radius: 6px; padding: .3rem .4rem; font-size: .78rem; font-variant-numeric: tabular-nums; }
.nucleo b { display: block; font-size: .95rem; }

/* tablas */
.tabla-envoltura { overflow-x: auto; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); }
.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th, .tabla td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--borde); vertical-align: top; }
.tabla th { color: var(--suave); font-weight: 600; font-size: .8rem; background: var(--superficie2); }
.tabla tr:last-child td { border-bottom: 0; }
.tabla td.eos { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; color: var(--suave); }
.ok { color: var(--verde); } .mal { color: var(--rojo); }

/* consola y registros */
.terminal { background: var(--terminal); color: var(--terminal-texto); border-radius: var(--radio); padding: .75rem;
  height: 60vh; min-height: 260px; overflow: auto; margin: 0 0 .6rem; font: 12.5px/1.45 ui-monospace, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word; }
.terminal .h { color: #8f877c; }
.terminal .e { color: #ff9b8a; }
.terminal .w { color: #f1c66b; }
.terminal .c { color: #9fd38a; }

/* herramientas */
.herr .caja { display: flex; flex-direction: column; gap: .5rem; }
.herr .caja p { margin: 0; color: var(--suave); font-size: .88rem; }
.herr form { display: flex; flex-direction: column; gap: .5rem; margin-top: auto; }
.herr .fila { display: flex; gap: .5rem; flex-wrap: wrap; }
.herr .fila > * { flex: 1; min-width: 7rem; }

/* trabajos en curso */
.trabajos { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 20;
  width: min(420px, calc(100vw - 2rem)); max-height: 70vh; overflow-y: auto; }
.trabajo { background: var(--superficie); border: 1px solid var(--borde); border-left: 4px solid var(--ambar); border-radius: 8px;
  padding: .6rem .75rem; box-shadow: 0 4px 16px rgba(0,0,0,.18); font-size: .88rem; }
.trabajo.hecho { border-left-color: var(--verde); } .trabajo.fallo { border-left-color: var(--rojo); }
.trabajo header { display: flex; justify-content: space-between; gap: .5rem; font-weight: 600; }
.trabajo pre { white-space: pre-wrap; max-height: 14rem; overflow: auto; font-size: .78rem; margin: .4rem 0 0;
  background: var(--superficie2); padding: .4rem; border-radius: 6px; }
.trabajo .cerrar { background: none; border: 0; color: var(--suave); cursor: pointer; font-size: 1.1rem; line-height: 1; }
.trabajo ul { margin: .3rem 0 0; padding-left: 1rem; color: var(--suave); }

/* dialogo */
dialog { border: 1px solid var(--borde); border-radius: 12px; background: var(--superficie); color: var(--texto); padding: 1.1rem;
  width: min(480px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog label { display: block; font-size: .85rem; color: var(--suave); margin: .6rem 0 .2rem; }
dialog input, dialog select { width: 100%; }
dialog .botones { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
dialog .advertencia { background: color-mix(in srgb, var(--rojo) 12%, transparent); border-radius: 8px; padding: .5rem .7rem; font-size: .9rem; }
dialog .resultado { max-height: 55vh; overflow: auto; white-space: pre-wrap; font: 12.5px/1.45 ui-monospace, Consolas, monospace;
  background: var(--superficie2); padding: .6rem; border-radius: 8px; }

/* pagina de entrada */
body.entrar { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.tarjeta-entrar { background: var(--superficie); border: 1px solid var(--borde); border-radius: 14px; padding: 1.75rem; max-width: 420px;
  width: 100%; text-align: center; box-shadow: var(--sombra); }
.tarjeta-entrar img { border-radius: 12px; }
.tarjeta-entrar ol { text-align: left; padding-left: 1.2rem; }
.tarjeta-entrar li { margin: .35rem 0; }
.sub { color: var(--suave); margin-top: 0; }
.aviso { background: color-mix(in srgb, var(--rojo) 14%, transparent); color: var(--rojo); border-radius: 8px; padding: .5rem .7rem; }

body:not(.es-admin) .solo-admin { display: none !important; }

/* tienda, boletos y referencia (19 oct 2026) */
#p-tienda .caja, #ref .caja { margin-bottom: .8rem; }
.formulario { display: flex; flex-direction: column; gap: .35rem; max-width: 520px; }
.formulario label { font-size: .85rem; color: var(--suave); margin-top: .3rem; }
.formulario .btn { align-self: flex-start; margin-top: .5rem; }
.lista-pedidos { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .6rem; margin-top: .6rem; }
.pedido { border: 1px solid var(--borde); border-radius: 8px; padding: .6rem .7rem; display: flex; flex-direction: column; gap: .35rem; }
.pedido header { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.pedido .btn { align-self: flex-start; }
.advertencia { background: color-mix(in srgb, var(--rojo) 12%, transparent); border-radius: 8px; padding: .5rem .7rem; font-size: .9rem; margin: .3rem 0; }
.fila-dino { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .25rem 0; }
.fila-dino span { flex: 1 1 100%; font-size: .9rem; }
dialog .fila-dino select { width: auto; flex: 1; }
dialog textarea { width: 100%; }
.boletos { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: .8rem; align-items: start; }
.tabla tr.clic { cursor: pointer; }
.tabla tr.clic:hover, .tabla tr.sel { background: var(--superficie2); }
.cab-boleto { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.hilo { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; margin: .6rem 0; }
.msg { border-left: 3px solid var(--borde); padding: .2rem .6rem; }
.msg.bot { border-left-color: var(--acento); }
.msg-texto { white-space: pre-wrap; word-break: break-word; }
.embed { background: var(--superficie2); border-radius: 6px; padding: .45rem .6rem; margin-top: .3rem; font-size: .9rem; }
.campos { display: grid; grid-template-columns: auto 1fr; gap: .15rem .6rem; margin: .3rem 0 0; }
.campos dt { color: var(--suave); }
.campos dd { margin: 0; }
.msg a { display: inline-block; margin-top: .2rem; color: var(--acento); }
.lista-def dt { font-weight: 600; margin-top: .5rem; }
.lista-def dd { margin: .1rem 0 0; color: var(--suave); }
#ref ul { margin: 0; padding-left: 1.2rem; }
#ref li { margin: .25rem 0; }
#faq-buscar { width: 100%; max-width: 420px; margin: .2rem 0 .6rem; }
.faq-tema h3 { font-size: .9rem; color: var(--suave); margin: .9rem 0 .3rem; text-transform: uppercase; letter-spacing: .03em; }
.faq details { border: 1px solid var(--borde); border-radius: 8px; margin: .35rem 0; background: var(--superficie); }
.faq summary { cursor: pointer; padding: .5rem .7rem; font-weight: 600; }
.faq summary:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }
.faq details[open] summary { border-bottom: 1px solid var(--borde); }
.faq details p { margin: 0; padding: .55rem .7rem .65rem; color: var(--texto); }
code.copiar { cursor: pointer; white-space: pre-wrap; word-break: break-word; }
code.copiar.copiado { outline: 2px solid var(--verde); }

@media (max-width: 860px) {
  .boletos { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .barra { gap: .4rem .8rem; padding: .5rem 1rem; }
  .resumen { order: 3; flex-basis: 100%; }
  .pestanas { top: 0; position: relative; }
  main { padding: .75rem 1rem; }
  .terminal { height: 55vh; font-size: 11.5px; }
  #p-jugadores .tabla th:nth-child(3), #p-jugadores .tabla td.eos { display: none; }
}
