:root {
  --fondo: #f5f6f8; --panel: #ffffff; --panel2: #eef0f4; --texto: #1b1f27; --suave: #5d6675; --borde: #dde1e8;
  --acento: #2f6fed; --acento-t: #ffffff; --verde: #1f9d55; --amarillo: #c98a00; --rojo: #d64545; --gris: #8a93a3;
  --verde-f: #e3f5ea; --amarillo-f: #fdf3d8; --rojo-f: #fbe5e5; --azul-f: #e6eefc;
  --radio: 12px; --sombra: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #12151b; --panel: #1b2029; --panel2: #232a35; --texto: #e7eaf0; --suave: #9aa4b5; --borde: #2e3644;
    --acento: #5b8dff; --acento-t: #0d1220; --verde: #3ccf7f; --amarillo: #f0b429; --rojo: #ff6b6b; --gris: #7d8799;
    --verde-f: #16301f; --amarillo-f: #352a0d; --rojo-f: #3a1a1a; --azul-f: #1a2540;
    --sombra: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fondo: #12151b; --panel: #1b2029; --panel2: #232a35; --texto: #e7eaf0; --suave: #9aa4b5; --borde: #2e3644;
  --acento: #5b8dff; --acento-t: #0d1220; --verde: #3ccf7f; --amarillo: #f0b429; --rojo: #ff6b6b; --gris: #7d8799;
  --verde-f: #16301f; --amarillo-f: #352a0d; --rojo-f: #3a1a1a; --azul-f: #1a2540;
  --sombra: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fondo); color: var(--texto); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--acento); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: .3rem 0; }
.suave { color: var(--suave); }
.peque { font-size: .85rem; }
.error { color: var(--rojo); font-weight: 600; }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select { width: 100%; padding: .55rem .65rem; border: 1px solid var(--borde); border-radius: 8px; background: var(--panel); }
textarea { min-height: 5rem; resize: vertical; }
label { display: block; font-weight: 600; margin: .6rem 0 .25rem; font-size: .9rem; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
label.check input { width: auto; }
.boton { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .55rem .9rem; border-radius: 9px; border: 1px solid var(--borde); background: var(--panel); cursor: pointer; font-weight: 600; min-height: 40px; text-decoration: none; color: var(--texto); }
.boton:hover { border-color: var(--acento); }
.boton.principal { background: var(--acento); color: var(--acento-t); border-color: var(--acento); }
.boton.peligro { color: var(--rojo); }
.boton.bien { color: var(--verde); }
.boton.peque { min-height: 32px; padding: .3rem .6rem; font-size: .85rem; }
.boton:disabled { opacity: .5; cursor: default; }
.fila { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.entre { justify-content: space-between; }

/* acceso */
body.acceso { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.acceso-caja { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1.5rem; width: 100%; max-width: 360px; box-shadow: var(--sombra); }
.acceso-caja button { width: 100%; margin-top: 1rem; }

/* cabecera y pestañas */
header.cab { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--borde); }
.cab-arriba { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem 16px; }
.cab-arriba h1 { margin: 0; font-size: 1.1rem; }
.estado-pc { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--suave); }
.punto { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--gris); flex: none; }
.punto.verde { background: var(--verde); } .punto.amarillo { background: var(--amarillo); } .punto.rojo { background: var(--rojo); }
nav.pestanas { display: flex; gap: .25rem; overflow-x: auto; padding: 0 12px .5rem; scrollbar-width: thin; }
nav.pestanas a { flex: none; padding: .45rem .75rem; border-radius: 999px; text-decoration: none; color: var(--suave); font-weight: 600; font-size: .9rem; white-space: nowrap; }
nav.pestanas a.activa { background: var(--azul-f); color: var(--acento); }
.globo { display: inline-block; min-width: 1.2rem; padding: 0 .3rem; border-radius: 999px; background: var(--rojo); color: #fff; font-size: .72rem; text-align: center; margin-left: .25rem; }
main.contenido { padding: 16px; max-width: 1200px; margin: 0 auto; }

/* tarjetas */
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem; box-shadow: var(--sombra); margin-bottom: 1rem; min-width: 0; }
.tarjeta.click { cursor: pointer; }
.tarjeta.click:hover { border-color: var(--acento); }
.rejilla { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.rejilla > .tarjeta { margin-bottom: 0; }
.seccion { margin: 1.25rem 0 .6rem; }
.aviso-banda { border-radius: var(--radio); padding: .75rem 1rem; margin-bottom: 1rem; font-weight: 600; }
.aviso-banda.amarillo { background: var(--amarillo-f); } .aviso-banda.rojo { background: var(--rojo-f); } .aviso-banda.verde { background: var(--verde-f); } .aviso-banda.azul { background: var(--azul-f); }
.etiqueta { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--panel2); color: var(--suave); }
.etiqueta.verde { background: var(--verde-f); color: var(--verde); } .etiqueta.amarillo { background: var(--amarillo-f); color: var(--amarillo); }
.etiqueta.rojo { background: var(--rojo-f); color: var(--rojo); } .etiqueta.azul { background: var(--azul-f); color: var(--acento); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0; }

/* trabajadores */
.trab-cab { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--panel2); color: var(--acento); flex: none; }
.mesa { border-top: 1px dashed var(--borde); padding-top: .5rem; margin-top: .5rem; }
.mesa.fallo { color: var(--rojo); }
.barra { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin: .35rem 0; position: relative; }
.barra > span { display: block; height: 100%; background: var(--acento); border-radius: 99px; }
.semaforo { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem 0; border-top: 1px solid var(--borde); }
.semaforo:first-of-type { border-top: 0; }
.semaforo .punto { margin-top: .35rem; }

/* pizarra */
.pizarra { display: grid; gap: .75rem; grid-template-columns: repeat(7, minmax(180px, 1fr)); overflow-x: auto; padding-bottom: .5rem; }
.columna { background: var(--panel2); border-radius: var(--radio); padding: .6rem; min-width: 0; }
.columna h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--suave); display: flex; justify-content: space-between; }
.ficha { background: var(--panel); border: 1px solid var(--borde); border-radius: 10px; padding: .55rem .65rem; margin-bottom: .5rem; cursor: pointer; }
.ficha:hover { border-color: var(--acento); }
.ficha b { display: block; font-size: .8rem; color: var(--acento); }
@media (max-width: 760px) { .pizarra { grid-template-columns: 1fr; overflow: visible; } }

/* tablas */
.tabla-caja { overflow-x: auto; border: 1px solid var(--borde); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: .45rem .6rem; text-align: left; border-bottom: 1px solid var(--borde); vertical-align: top; }
th { background: var(--panel2); font-weight: 700; white-space: nowrap; cursor: default; }
th.ordenable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* calendario */
.calendario { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.dia { background: var(--panel); border: 1px solid var(--borde); border-radius: 10px; padding: .5rem; min-height: 92px; min-width: 0; overflow-wrap: anywhere; }
.dia.hoy { border-color: var(--acento); }
.dia.vacio { background: var(--amarillo-f); }
.dia .num-dia { font-weight: 800; font-size: .85rem; }
.dia .vid { font-size: .78rem; margin-top: .25rem; }
@media (max-width: 760px) { .calendario { grid-template-columns: 1fr; } .dia { min-height: 0; } }
.huecos td { text-align: center; min-width: 38px; padding: .3rem; }
.hueco { display: block; width: 100%; min-height: 28px; border-radius: 6px; border: 1px solid var(--borde); background: var(--panel); cursor: pointer; font-size: .7rem; }
.hueco.cola { background: var(--verde-f); border-color: var(--verde); cursor: default; }
.hueco.espera { background: var(--amarillo-f); border-color: var(--amarillo); }

/* Ana */
.pregunta { font-size: 1.1rem; font-weight: 700; }
.medidor { margin: .5rem 0; }
.medidor .barra { height: 12px; }
.medidor .objetivo { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--texto); }
.medidor .barra > span.bien { background: var(--verde); } .medidor .barra > span.mal { background: var(--rojo); }
.medidor .barra > span.provisional { background: repeating-linear-gradient(45deg, var(--gris), var(--gris) 6px, var(--panel2) 6px, var(--panel2) 12px); }
.regla { display: grid; grid-template-columns: 1fr; gap: .4rem; margin: .5rem 0; }
.regla div { background: var(--panel2); border-radius: 8px; padding: .5rem .65rem; overflow-wrap: anywhere; }
.regla .despues { background: var(--verde-f); }
.tono-bien { border-left: 4px solid var(--verde); } .tono-ojo { border-left: 4px solid var(--amarillo); } .tono-mal { border-left: 4px solid var(--rojo); }
ol.pasos { margin: .4rem 0; padding-left: 1.3rem; }

/* miniaturas */
.minis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.minis img, .fotos img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; border: 1px solid var(--borde); display: block; }
.minis button { padding: 0; border: 0; background: none; cursor: pointer; position: relative; text-align: left; }
.minis button span { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: .75rem; padding: 0 .35rem; border-radius: 4px; }
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .4rem; }
.fuente { display: flex; gap: .5rem; align-items: flex-start; margin: .35rem 0; }
.fuente img { width: 96px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; flex: none; }

/* diálogos */
dialog { border: 1px solid var(--borde); border-radius: var(--radio); background: var(--panel); color: var(--texto); padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dialogo-cab { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .8rem 1rem; border-bottom: 1px solid var(--borde); position: sticky; top: 0; background: var(--panel); }
.dialogo-cuerpo { padding: 1rem; }
pre.json { background: var(--panel2); padding: .75rem; border-radius: 8px; overflow: auto; max-height: 60vh; font-size: .8rem; white-space: pre-wrap; overflow-wrap: anywhere; }
dl.kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: .25rem .75rem; margin: .4rem 0; }
dl.kv dt { color: var(--suave); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { dl.kv { grid-template-columns: 1fr; } dl.kv dd { margin-bottom: .35rem; } }
.lista-diario { list-style: none; padding: 0; margin: 0; }
.lista-diario li { padding: .35rem 0; border-bottom: 1px solid var(--borde); display: flex; gap: .6rem; }
.lista-diario time { color: var(--suave); font-size: .8rem; flex: none; min-width: 3.2rem; font-variant-numeric: tabular-nums; }
.subpestanas { display: flex; gap: .3rem; overflow-x: auto; margin-bottom: 1rem; }
.subpestanas button { flex: none; border: 1px solid var(--borde); background: var(--panel); border-radius: 999px; padding: .35rem .8rem; cursor: pointer; font-weight: 600; color: var(--suave); }
.subpestanas button.activa { background: var(--acento); color: var(--acento-t); border-color: var(--acento); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--borde); border-radius: 10px; padding: .6rem .75rem; }
.kpi b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--suave); font-size: .8rem; }
.vacio-txt { color: var(--suave); font-style: italic; padding: .5rem 0; }
.no-leido { border-left: 4px solid var(--acento); }
.oculto { display: none !important; }
