/* PedIA Gestión — estilos. Sin dependencias ni fuentes externas. */
:root {
  --fondo: #f4f5f9;
  --panel: #ffffff;
  --panel-2: #f8f9fc;
  --borde: #e3e6ee;
  --texto: #1b2033;
  --texto-2: #5b6277;
  --texto-3: #8a90a3;
  --acento: #2346c8;
  --acento-2: #e8edff;
  --acento-texto: #ffffff;
  --ok: #16865a;
  --ok-2: #e3f5ec;
  --aviso: #b26a00;
  --aviso-2: #fff3dc;
  --mal: #c8323b;
  --mal-2: #fde7e8;
  --neutro-2: #eef0f5;
  --sombra: 0 1px 2px rgba(20, 26, 50, .06), 0 2px 8px rgba(20, 26, 50, .05);
  --radio: 12px;
  --barra: #2346c8;
  --barra-2: #b8c5f5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #12141c; --panel: #1b1e29; --panel-2: #20242f; --borde: #2d3240; --texto: #e9ebf2; --texto-2: #a7adbf; --texto-3: #7c8296;
    --acento: #7b95ff; --acento-2: #252c4a; --acento-texto: #0d1020; --ok: #4cc58f; --ok-2: #173326; --aviso: #f0b04a; --aviso-2: #3a2c12;
    --mal: #ff7a80; --mal-2: #3d1d21; --neutro-2: #262a36; --sombra: none; --barra: #7b95ff; --barra-2: #3a4675; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.45; color: var(--texto); background: var(--fondo);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.35rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 600; }
.cargando-pantalla { display: grid; place-items: center; min-height: 100vh; color: var(--texto-2); }
.oculto { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.derecha { text-align: right; }
.suave { color: var(--texto-2); }
.muy-suave { color: var(--texto-3); font-size: .85rem; }
.fila { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.fila-sep { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.pila > * + * { margin-top: 1rem; }

/* ---------- estructura */
.marco { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.lateral {
  background: var(--panel); border-right: 1px solid var(--borde); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: .25rem; overflow-y: auto;
}
.marca { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem 1rem; font-weight: 700; font-size: 1.05rem; }
.marca img { width: 30px; height: 30px; }
.marca small { display: block; font-weight: 500; color: var(--texto-3); font-size: .72rem; }
.nav-titulo { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--texto-3); padding: .9rem .6rem .3rem; }
.nav a, .nav span {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .65rem; border-radius: 9px; color: var(--texto-2); font-weight: 500;
}
.nav a:hover { background: var(--panel-2); text-decoration: none; color: var(--texto); }
.nav a.activo { background: var(--acento-2); color: var(--acento); }
.nav span { opacity: .55; cursor: default; }
.nav .etq { margin-left: auto; font-size: .68rem; background: var(--neutro-2); padding: .05rem .4rem; border-radius: 6px; }
.nav .etq.aviso { background: var(--aviso-2); color: var(--aviso); font-weight: 700; }
.qr { display: block; width: 210px; height: 210px; margin: .5rem auto; background: #fff; border-radius: 10px; padding: 4px; }
.clave-manual { font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em; text-align: center; font-size: .95rem; word-break: break-all; background: var(--panel-2); border-radius: 8px; padding: .5rem; }
.codigos { display: grid; grid-template-columns: repeat(2, 1fr); gap: .35rem; font-family: ui-monospace, Consolas, monospace; text-align: center; }
.codigos span { background: var(--panel-2); border: 1px solid var(--borde); border-radius: 8px; padding: .35rem; }
.doble { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 1rem; align-items: start; }
.doble .visor { position: sticky; top: 5rem; }
.visor img, .visor iframe { width: 100%; border-radius: 10px; border: 1px solid var(--borde); background: #fff; }
.visor iframe { height: 75vh; }
.tabla-editable input, .tabla-editable select { width: 100%; min-width: 70px; padding: .35rem .45rem; min-height: 34px; }
.tabla-editable td { vertical-align: middle; padding: .35rem .3rem; }
.estado-local { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; }
.contar input { width: 110px; text-align: right; }
@media (max-width: 900px) { .doble { grid-template-columns: 1fr; } .doble .visor { position: static; } }
.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lateral .pie { margin-top: auto; padding: .75rem .5rem 0; border-top: 1px solid var(--borde); font-size: .85rem; }

.principal { min-width: 0; display: flex; flex-direction: column; }
.cabecera {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--fondo) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--borde); padding: .75rem 1.5rem; display: flex; gap: .75rem 1rem; align-items: center; flex-wrap: wrap;
}
.cabecera h1 { margin-right: auto; }
.contenido { padding: 1.25rem 1.5rem 2.5rem; max-width: 1400px; width: 100%; }
.banda-demo { background: var(--aviso-2); color: var(--aviso); font-size: .82rem; padding: .35rem 1.5rem; text-align: center; }
.estado-sync { font-size: .8rem; color: var(--texto-3); display: flex; align-items: center; gap: .4rem; }
.estado-sync.error { color: var(--mal); }

.inferior { display: none; }

/* ---------- controles */
button, .boton {
  font: inherit; cursor: pointer; border: 1px solid var(--borde); background: var(--panel); color: var(--texto); border-radius: 9px;
  padding: .5rem .85rem; font-weight: 550; display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; min-height: 38px;
}
button:hover, .boton:hover { background: var(--panel-2); text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
button.primario, .boton.primario { background: var(--acento); border-color: var(--acento); color: var(--acento-texto); }
button.primario:hover { filter: brightness(1.07); }
button.peligro { color: var(--mal); }
button.enlace { border: 0; background: none; color: var(--acento); padding: .25rem .4rem; min-height: auto; }
button.pequeno, .boton.pequeno { padding: .3rem .6rem; font-size: .85rem; min-height: 32px; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
input, select, textarea {
  font: inherit; color: var(--texto); background: var(--panel); border: 1px solid var(--borde); border-radius: 9px; padding: .5rem .65rem; min-height: 38px; max-width: 100%;
}
textarea { min-height: 80px; width: 100%; resize: vertical; }
label.campo { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--texto-2); font-weight: 550; }
label.campo input, label.campo select, label.campo textarea { color: var(--texto); font-weight: 400; }
.rejilla-campos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .9rem; }
.casillas { display: flex; flex-wrap: wrap; gap: .4rem; }
.casilla { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--borde); border-radius: 20px; padding: .25rem .65rem; font-size: .85rem; cursor: pointer; background: var(--panel); }
.casilla input { min-height: auto; margin: 0; }
.casilla:has(input:checked) { background: var(--acento-2); border-color: var(--acento); color: var(--acento); }
.selector-local { min-width: 190px; }
.filtro-fechas { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.filtro-fechas input[type=date] { width: 150px; }

.pestanas { display: flex; gap: .25rem; border-bottom: 1px solid var(--borde); margin-bottom: 1.1rem; overflow-x: auto; scrollbar-width: none; }
.pestanas a { padding: .6rem .9rem; color: var(--texto-2); font-weight: 550; border-bottom: 2px solid transparent; white-space: nowrap; }
.pestanas a:hover { text-decoration: none; color: var(--texto); }
.pestanas a.activo { color: var(--acento); border-bottom-color: var(--acento); }

/* ---------- tarjetas */
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); padding: 1rem 1.1rem; min-width: 0; }
.tarjeta > h2, .tarjeta > .fila-sep > h2 { margin-bottom: .75rem; }
.tarjeta .fila-sep { margin-bottom: .6rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; }
.kpi { display: flex; flex-direction: column; gap: .2rem; }
.kpi .titulo { font-size: .82rem; color: var(--texto-2); font-weight: 600; display: flex; justify-content: space-between; gap: .5rem; }
.kpi .valor { font-size: 1.65rem; font-weight: 700; letter-spacing: -.01em; }
.kpi .detalle { font-size: .8rem; color: var(--texto-3); }
.kpi.pendiente .valor { font-size: 1rem; font-weight: 600; color: var(--texto-3); padding: .45rem 0 .2rem; }
.var { font-size: .78rem; font-weight: 650; padding: .05rem .4rem; border-radius: 6px; white-space: nowrap; }
.var.sube { color: var(--ok); background: var(--ok-2); }
.var.baja { color: var(--mal); background: var(--mal-2); }
.var.igual { color: var(--texto-2); background: var(--neutro-2); }
.medidor { height: 6px; background: var(--neutro-2); border-radius: 4px; overflow: hidden; margin-top: .35rem; }
.medidor > div { height: 100%; background: var(--acento); border-radius: 4px; }
.medidor.alto > div { background: var(--mal); }
.rejilla-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.rejilla-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1rem; }
@media (max-width: 1150px) { .rejilla-2 { grid-template-columns: 1fr; } }
.rejilla-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }

/* ---------- gráficos */
.grafico { width: 100%; height: 220px; display: block; }
.grafico .barra { fill: var(--barra); }
.grafico .barra.hoy { fill: var(--barra-2); }
.grafico .barra:hover { opacity: .8; }
.grafico .eje { stroke: var(--borde); }
.grafico text { fill: var(--texto-3); font-size: 10px; }
.barras-h .fila-barra { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; gap: .6rem; align-items: center; padding: .3rem 0; font-size: .88rem; }
.barras-h .pista { height: 8px; background: var(--neutro-2); border-radius: 5px; overflow: hidden; }
.barras-h .pista > div { height: 100%; background: var(--acento); border-radius: 5px; }
.ancho-0 { width: 0; }

/* ---------- tablas */
.tabla-env { overflow-x: auto; margin: 0 -1.1rem; padding: 0 1.1rem; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-3); font-weight: 600; padding: .5rem .6rem; border-bottom: 1px solid var(--borde); white-space: nowrap; }
td { padding: .55rem .6rem; border-bottom: 1px solid var(--borde); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.clic { cursor: pointer; }
tr.clic:hover td { background: var(--panel-2); }
tr.inactivo td { opacity: .55; }
tfoot td { font-weight: 650; border-top: 1px solid var(--borde); }
th.derecha, td.derecha { text-align: right; }

.etiqueta { display: inline-block; font-size: .74rem; font-weight: 600; padding: .1rem .45rem; border-radius: 6px; background: var(--neutro-2); color: var(--texto-2); white-space: nowrap; margin: .05rem .15rem .05rem 0; }
.etiqueta.ok { background: var(--ok-2); color: var(--ok); }
.etiqueta.aviso { background: var(--aviso-2); color: var(--aviso); }
.etiqueta.mal { background: var(--mal-2); color: var(--mal); }
.etiqueta.acento { background: var(--acento-2); color: var(--acento); }
.punto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: .35rem; }
.punto.pausa { background: var(--aviso); }

.lista { list-style: none; margin: 0; padding: 0; }
.lista li { padding: .55rem 0; border-bottom: 1px solid var(--borde); display: flex; justify-content: space-between; gap: .25rem .75rem; align-items: center; flex-wrap: wrap; }
.lista li:last-child { border-bottom: 0; }
.vacio { color: var(--texto-3); padding: 1.25rem 0; text-align: center; font-size: .9rem; }
.nota { background: var(--panel-2); border: 1px dashed var(--borde); border-radius: 10px; padding: .75rem .9rem; font-size: .88rem; color: var(--texto-2); }
.nota.aviso { background: var(--aviso-2); border-color: transparent; color: var(--aviso); }
.nota.mal { background: var(--mal-2); border-color: transparent; color: var(--mal); }

/* marcajes y correcciones */
.marcaje { display: grid; grid-template-columns: 110px 1fr auto; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--borde); align-items: start; }
.marcaje:last-child { border-bottom: 0; }
.marcaje .hora { font-weight: 700; font-size: 1.05rem; }
.marcaje.anulado .hora, .marcaje.anulado .tipo { text-decoration: line-through; color: var(--texto-3); }
.historial { margin-top: .35rem; border-left: 2px solid var(--borde); padding-left: .6rem; font-size: .82rem; color: var(--texto-2); }
.historial div + div { margin-top: .2rem; }

/* editor de recetas */
.lineas-receta { width: 100%; }
.lineas-receta td { vertical-align: middle; }
.lineas-receta select { width: 100%; min-width: 180px; }
.lineas-receta input.cant { width: 90px; text-align: right; }
.lineas-receta select.uni { width: 76px; min-width: 0; }
.resumen-coste { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.resumen-coste .kpi .valor { font-size: 1.35rem; }

/* ---------- modal y avisos */
dialog { border: 0; border-radius: 14px; padding: 0; max-width: min(560px, calc(100vw - 2rem)); width: 100%; background: var(--panel); color: var(--texto); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 18, 30, .45); }
dialog form { padding: 1.25rem; }
dialog h2 { margin-bottom: 1rem; }
dialog .acciones { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }
.error-form { color: var(--mal); font-size: .88rem; margin-top: .75rem; }
#avisos { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; }
.aviso-flotante { background: var(--texto); color: var(--panel); padding: .65rem 1rem; border-radius: 10px; box-shadow: var(--sombra); font-size: .9rem; max-width: 360px; }
.aviso-flotante.mal { background: var(--mal); color: #fff; }

/* ---------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(ellipse at top, var(--acento-2), var(--fondo) 60%); }
.login .tarjeta { width: 100%; max-width: 400px; padding: 1.75rem; }
.login .marca { justify-content: center; padding-bottom: 1.25rem; font-size: 1.25rem; }
.login .marca img { width: 40px; height: 40px; }
.login form > * + * { margin-top: .9rem; }
.login button.primario { width: 100%; justify-content: center; }
.login input { width: 100%; }
.login .codigo { font-size: 1.5rem; letter-spacing: .4em; text-align: center; }

/* ---------- módulos (móvil) */
.modulos { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
.modulo { display: flex; gap: .85rem; align-items: center; padding: .9rem 1rem; color: var(--texto); }
.modulo:hover { text-decoration: none; border-color: var(--acento); }
.modulo .ico { width: 26px; height: 26px; color: var(--acento); }
.modulo.inactivo { opacity: .55; }
.modulo .ico.gris { color: var(--texto-3); }
.modulo small { display: block; color: var(--texto-3); font-size: .8rem; }

/* ---------- móvil */
@media (max-width: 900px) {
  .marco { grid-template-columns: 1fr; }
  .lateral { display: none; }
  .cabecera { padding: .6rem 1rem; gap: .5rem; }
  .cabecera h1 { font-size: 1.15rem; width: 100%; }
  .contenido { padding: 1rem 1rem calc(5.5rem + env(safe-area-inset-bottom)); }
  .rejilla-2, .rejilla-3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .kpi .valor { font-size: 1.3rem; }
  .selector-local { min-width: 0; flex: 1; }
  .filtro-fechas { width: 100%; }
  .filtro-fechas select { flex: 1; }
  .estado-sync { width: 100%; }
  .inferior {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--panel); border-top: 1px solid var(--borde); padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
  }
  .inferior a { display: flex; flex-direction: column; align-items: center; gap: .15rem; font-size: .72rem; color: var(--texto-3); padding: .25rem; }
  .inferior a.activo { color: var(--acento); }
  .inferior a:hover { text-decoration: none; }
  .tarjeta { padding: .9rem; }
  .tabla-env { margin: 0 -.9rem; padding: 0 .9rem; }
  .marcaje { grid-template-columns: 80px 1fr; }
  .marcaje > :last-child { grid-column: 1 / -1; }
  #avisos { left: 1rem; bottom: 5rem; }
  .ocultar-movil { display: none; }
}
@media print {
  .lateral, .cabecera, .inferior, .banda-demo, button { display: none !important; }
  .marco { display: block; }
}
.mal-texto { color: var(--mal); font-weight: 600; }
.kpi.alto .valor { color: var(--mal); }
.tabla-editable .ancho { min-width: 210px; }
.tabla-editable input[type=number] { min-width: 76px; }

/* ---------------------------------------------------------------- fases 4 a 7 */
tr.destacada td { border-top: 2px solid var(--texto); background: var(--panel-2); }
/* Checklists: firma en pantalla y puntos de control */
canvas.firma { display: block; width: 100%; max-width: 600px; height: auto; aspect-ratio: 600 / 180; background: #fff; border: 1px dashed var(--borde); border-radius: 8px; touch-action: none; cursor: crosshair; }
.firma-img { display: block; max-width: 300px; width: 100%; background: #fff; border: 1px solid var(--borde); border-radius: 8px; }
.punto-control { padding: .6rem 0; border-bottom: 1px solid var(--borde); display: grid; gap: .4rem; }
.punto-control:last-of-type { border-bottom: 0; }
/* Turnos */
.tabla-turnos th, .tabla-turnos td { min-width: 108px; vertical-align: top; }
.tabla-turnos th:first-child, .tabla-turnos td:first-child { min-width: 140px; position: sticky; left: 0; background: var(--panel); z-index: 1; }
.tabla-turnos th.hoy { color: var(--acento); }
.tabla-turnos .fila-resumen td { font-size: .82rem; color: var(--texto-2); background: var(--panel-2); padding-top: .3rem; padding-bottom: .3rem; }
.tabla-turnos .fila-resumen td:first-child { background: var(--panel-2); }
.celda-turno { cursor: pointer; }
.celda-turno:hover { background: var(--acento-2); }
.celda-turno.ausente { cursor: default; background: var(--neutro-2); }
.turno { display: block; width: 100%; margin: 0 0 .25rem; padding: .25rem .4rem; font-size: .8rem; border-radius: 6px; background: var(--acento-2); color: var(--acento); border: 0; font-variant-numeric: tabular-nums; text-align: left; }
/* Asistente */
.asistente { display: grid; grid-template-columns: 260px 1fr; gap: 1rem; align-items: start; }
.conversaciones .lista li { display: grid; gap: .1rem; }
.conversacion { display: grid; gap: .75rem; }
.chat { display: flex; flex-direction: column; gap: .6rem; min-height: 280px; max-height: 60vh; overflow-y: auto; padding: .25rem; }
.mensaje { max-width: 85%; padding: .6rem .8rem; border-radius: 12px; display: grid; gap: .35rem; }
.mensaje .texto { white-space: pre-wrap; line-height: 1.45; }
.mensaje.yo { align-self: flex-end; background: var(--acento); color: var(--acento-texto); }
.mensaje.yo .muy-suave { color: inherit; opacity: .75; }
.mensaje.ia { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--borde); }
.mensaje.pensando { color: var(--texto-3); font-style: italic; }
.pregunta { display: flex; gap: .5rem; align-items: flex-end; }
.pregunta textarea { flex: 1; resize: vertical; }
@media (max-width: 900px) {
  .asistente { grid-template-columns: 1fr; }
  .conversaciones { order: 2; }
  .mensaje { max-width: 95%; }
}
/* Entrada: «recordar este dispositivo» como casilla normal (no píldora) */
.login .recordar { display: flex; align-items: flex-start; gap: .5rem; font-size: .85rem; color: var(--texto-2); cursor: pointer; }
.login .recordar input { width: auto; min-height: auto; margin: .15rem 0 0; flex: none; }
