:root {
  --fondo: #f6f4f0;
  --tarjeta: #ffffff;
  --texto: #1f2328;
  --tenue: #6b6f76;
  --linea: #e4e0d9;
  --acento: #8f3b22;
  --acento-suave: #f4e6df;
  --bien: #1d7a46;
  --mal: #b42318;
  --sombra: 0 1px 2px rgba(31, 35, 40, .06), 0 2px 8px rgba(31, 35, 40, .05);
  --radio: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--texto);
  background: var(--fondo);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fondo); }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
[hidden] { display: none !important; }
a { color: var(--acento); }

/* ---------- Encabezado y menú ---------- */
.encabezado {
  background: var(--tarjeta); border-bottom: 1px solid var(--linea);
  display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; padding: 12px 16px 0;
  position: sticky; top: 0; z-index: 5;
}
.marca strong { display: block; font-size: 1.1rem; color: var(--acento); }
.marca span { color: var(--tenue); font-size: .85rem; }
.usuario { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.nombre-usuario { color: var(--tenue); font-size: .9rem; }
.selector-mes { padding: 6px 8px; border: 1px solid var(--linea); border-radius: 8px; font: inherit; background: #fff; }
.menu { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0 4px; }
.menu a {
  white-space: nowrap; padding: 9px 10px; text-decoration: none; color: var(--tenue);
  border-bottom: 3px solid transparent; font-weight: 500;
}
.menu a.activo { color: var(--acento); border-bottom-color: var(--acento); }

.contenido { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.cargando { text-align: center; color: var(--tenue); padding: 40px; }

/* ---------- Tarjetas y formularios ---------- */
.tarjeta {
  background: var(--tarjeta); border: 1px solid var(--linea); border-radius: var(--radio);
  box-shadow: var(--sombra); padding: 18px; margin-bottom: 16px;
}
.tarjeta.error h2 { color: var(--mal); }
.centrada { max-width: 460px; margin: 60px auto; }
.formulario { max-width: 640px; margin-left: auto; margin-right: auto; display: grid; gap: 14px; }
.campo { display: grid; gap: 5px; }
.campo > span, legend { font-weight: 600; font-size: .9rem; }
.campo small, .descripcion { color: var(--tenue); font-size: .82rem; }
.descripcion { margin-top: -8px; }
input, select, textarea {
  font: inherit; padding: 10px 11px; border: 1px solid #cfc9bf; border-radius: 8px;
  background: #fff; color: var(--texto); width: 100%; min-height: 44px;
}
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--acento); transform: scale(1.15); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--acento); outline-offset: 1px; border-color: transparent; }
.fila-campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
fieldset { border: 1px solid var(--linea); border-radius: 8px; padding: 10px 12px; display: flex; gap: 18px; flex-wrap: wrap; }
.opcion { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.casillas { display: flex; flex-wrap: wrap; gap: 8px 16px; }
details.mas summary { cursor: pointer; color: var(--acento); font-weight: 500; margin-bottom: 8px; }
.bloque-fiscal { display: grid; gap: 12px; background: var(--acento-suave); padding: 12px; border-radius: 8px; }

/* ---------- Botones ---------- */
.boton {
  font: inherit; font-weight: 600; background: var(--acento); color: #fff; border: 0;
  border-radius: 8px; padding: 10px 16px; cursor: pointer; min-height: 42px;
}
.boton:hover { filter: brightness(1.08); }
.boton:disabled { opacity: .6; cursor: wait; }
.boton-grande { padding: 14px; font-size: 1.05rem; }
.boton-secundario { background: #fff; color: var(--acento); border: 1px solid var(--acento); }
.boton-chico { padding: 6px 10px; min-height: 0; font-size: .85rem; }
.boton-texto { background: none; border: 0; color: var(--acento); cursor: pointer; font: inherit; padding: 6px; text-decoration: underline; }
.boton-icono { background: none; border: 0; cursor: pointer; font-size: 1rem; padding: 4px 6px; text-decoration: none; }
.botones { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Entrar ---------- */
.pantalla-entrar { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.entrar { width: 100%; max-width: 400px; display: grid; gap: 14px; }
.entrar h1 { color: var(--acento); margin: 0; }
.subtitulo { color: var(--tenue); margin: -8px 0 6px; }

/* ---------- Títulos, pestañas, filtros ---------- */
.titulo-pantalla { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.pestanas { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pestanas a {
  padding: 7px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--linea);
  text-decoration: none; color: var(--texto); font-size: .9rem;
}
.pestanas a.activo { background: var(--acento); color: #fff; border-color: var(--acento); }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filtros > * { width: auto; flex: 1 1 170px; }
.filtros .boton { flex: 0 0 auto; }
.nota { color: var(--tenue); font-size: .88rem; margin: 4px 0 12px; }
.nota.error { color: var(--mal); }
.resumen { font-weight: 600; margin: 0 0 8px; }
.vacio { color: var(--tenue); text-align: center; padding: 24px; }

/* ---------- Tablas ---------- */
.tabla-scroll { overflow-x: auto; background: var(--tarjeta); border: 1px solid var(--linea); border-radius: var(--radio); }
.tarjeta .tabla-scroll { border: 0; }
.tabla { border-collapse: collapse; width: 100%; font-size: .9rem; }
.tabla th, .tabla td { padding: 8px 10px; border-bottom: 1px solid var(--linea); text-align: left; vertical-align: top; }
.tabla thead th { background: #faf8f5; font-weight: 600; color: var(--tenue); position: sticky; top: 0; white-space: nowrap; }
.tabla .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabla .tenue { color: var(--tenue); }
.tabla .fuerte { font-weight: 600; }
.tabla .texto-largo { min-width: 180px; max-width: 320px; }
.tabla .quien { color: var(--tenue); font-size: .82rem; }
.tabla .acciones { white-space: nowrap; }
.tabla tr.inactivo td { color: var(--tenue); text-decoration: line-through; }
.etiqueta { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eee; font-size: .78rem; }
.etiqueta.ok { background: #e3f3e9; color: var(--bien); }

.matriz th.fija, .estado-tabla th.fija {
  position: sticky; left: 0; background: #fff; z-index: 1; white-space: nowrap; font-weight: 500;
}
.matriz thead th.fija { z-index: 2; background: #faf8f5; }
.matriz td { min-width: 64px; }
.matriz .clic { cursor: pointer; }
.matriz td.clic:hover, .matriz th.clic:hover { background: var(--acento-suave); }
.matriz tr.subtotal th, .matriz tr.subtotal td { background: #faf6f2; font-weight: 600; }
.matriz tr.total th, .matriz tr.total td { background: var(--acento-suave); font-weight: 700; }
.matriz tr.traspaso th, .matriz tr.traspaso td { color: var(--tenue); font-style: italic; }

.estado h3 { color: var(--acento); }
.estado-tabla th.fija { min-width: 230px; }
.renglon-total th, .renglon-total td { font-weight: 700; background: #faf6f2; }
.renglon-formula th, .renglon-formula td { font-weight: 700; background: var(--acento-suave); }
.renglon-detalle th { padding-left: 22px; }
.renglon-sub th { padding-left: 44px; color: var(--tenue); font-weight: 400; }
.renglon-sub td { color: var(--tenue); }
.desplegar { background: none; border: 0; font: inherit; cursor: pointer; padding: 0; text-align: left; color: inherit; }
td.bien { color: var(--bien); }
td.mal { color: var(--mal); }
.proyeccion select, .proyeccion input { min-height: 36px; padding: 6px 8px; min-width: 110px; }

.resumen-cierre { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.resumen-cierre dt { color: var(--tenue); }
.resumen-cierre dd { margin: 0; font-weight: 600; }
.pendientes { background: #fff6e5; border-radius: 8px; padding: 10px 14px; margin: 12px 0; }
.lista { padding-left: 18px; }

/* ---------- Avisos y ventanas ---------- */
.aviso {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: var(--texto); color: #fff; padding: 12px 18px; border-radius: 10px; max-width: calc(100% - 32px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .2); transition: opacity .4s;
}
.aviso-error { background: var(--mal); }
.aviso.salir { opacity: 0; }
.ventana-fondo { position: fixed; inset: 0; background: rgba(31, 35, 40, .45); z-index: 40; display: grid; place-items: center; padding: 16px; }
.ventana { background: #fff; border-radius: 12px; width: min(720px, 100%); max-height: 90vh; overflow: auto; padding: 18px; }
.ventana-titulo { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

@media (max-width: 640px) {
  .encabezado { grid-template-columns: auto 1fr; position: static; padding: 10px 12px 0; }
  .marca span { display: none; }
  .usuario { flex-wrap: nowrap; gap: 6px; }
  .selector-mes { min-height: 38px; padding: 4px 6px; max-width: 190px; }
  .nombre-usuario { display: none; }
  .contenido { padding: 14px 12px 60px; }
  .tarjeta { padding: 14px; }
  .estado-tabla th.fija { min-width: 170px; }
}

@media print {
  .encabezado, .filtros, .pestanas, .boton, .boton-secundario { display: none !important; }
  .tabla-scroll { overflow: visible; border: 0; }
}

/* ---------- Cajas ---------- */
.cajas-saldos { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.caja-tarjeta {
  display: grid; gap: 4px; padding: 14px 16px; background: var(--tarjeta); border: 1px solid var(--linea);
  border-radius: var(--radio); box-shadow: var(--sombra); text-decoration: none; color: var(--texto);
}
.caja-tarjeta span { color: var(--tenue); font-weight: 500; }
.caja-tarjeta strong { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.caja-tarjeta small { color: var(--tenue); }
.caja-tarjeta.activa { border-color: var(--acento); box-shadow: 0 0 0 2px var(--acento-suave); }
.arqueo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.arqueo-grid input { min-height: 38px; }
.arqueo-total { display: flex; flex-wrap: wrap; gap: 6px 18px; background: var(--acento-suave); padding: 10px 12px; border-radius: 8px; margin: 0; }
.arqueo-total .mal { color: var(--mal); font-weight: 700; }
.arqueo-total .bien { color: var(--bien); font-weight: 700; }
.tabla small.recibido { display: block; color: var(--tenue); margin-top: 2px; }
.nota.foto { background: #eef6f0; color: var(--bien); padding: 8px 12px; border-radius: 8px; }

/* ---------- Cuentas por pagar ---------- */
.etiqueta.alerta { background: #fdecea; color: var(--mal); }
.dos-columnas { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.ventana .formulario.ancho { max-width: none; }
.ventana h4 { margin: 8px 0 4px; }
.arqueo-total strong.bien, .arqueo-total .bien { color: var(--bien); font-weight: 700; }
.arqueo-total strong.mal, .arqueo-total .mal { color: var(--mal); font-weight: 700; }
td.mal { color: var(--mal); font-weight: 600; }
.ventana { width: min(920px, 100%); }
a.boton { display: inline-flex; align-items: center; text-decoration: none; }
.etiqueta.aviso-naranja { background: #fff1db; color: #9a5b00; }
.parecidos { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.parecidos:empty { display: none; }
p.pendientes a { color: var(--acento); font-weight: 600; }
.etiqueta { white-space: nowrap; }
code.clave { display: block; padding: 10px 12px; background: #f3f1ec; border-radius: 8px; font-size: .85rem; word-break: break-all; user-select: all; }
label.boton { cursor: pointer; }

/* ---------- Punto de venta ---------- */
.vender-columnas { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
.vender .cobro { position: sticky; top: 120px; display: grid; gap: 10px; }
.botones-venta { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.producto { display: grid; gap: 3px; text-align: left; padding: 12px; border: 1px solid var(--linea); border-radius: 10px; background: #fff; cursor: pointer; font: inherit; min-height: 74px; }
.producto:hover { border-color: var(--acento); background: var(--acento-suave); }
.producto span { font-weight: 600; }
.producto strong { color: var(--acento); }
.producto small { color: var(--tenue); }
.producto small.mal, .recibido.mal { color: var(--mal); }
.producto.sin-precio { opacity: .65; }
.producto.sin-precio strong { color: #9a5b00; font-weight: 500; font-size: .85rem; }
.linea-carrito { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--linea); }
.cantidad { display: flex; align-items: center; gap: 6px; }
.cantidad .boton-icono { border: 1px solid var(--linea); border-radius: 6px; width: 30px; height: 30px; }
.total-venta { font-size: 1.3rem; }
pre.ticket { background: #f6f4f0; padding: 12px; border-radius: 8px; white-space: pre-wrap; font: .9rem/1.4 ui-monospace, Menlo, monospace; margin: 0; }
.boton.whatsapp { background: #1f8f4e; justify-content: center; }
.campo.en-linea { display: flex; align-items: center; gap: 8px; }
.campo.en-linea select { width: auto; }
.banda-aviso { display: block; background: #e3f3e9; color: var(--bien); font-weight: 600; padding: 10px 16px; text-decoration: none; text-align: center; }
@media (max-width: 860px) { .vender-columnas { grid-template-columns: 1fr; } .vender .cobro { position: static; } }
.barra-cobro { display: none; }
@media (max-width: 860px) {
  .barra-cobro:not([hidden]) {
    display: block; position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 30;
    background: var(--acento); color: #fff; border: 0; border-radius: 12px; padding: 14px; font: inherit; font-weight: 700;
    box-shadow: 0 6px 20px rgba(0,0,0,.25); cursor: pointer;
  }
  .vender { padding-bottom: 70px; }
}
.mensaje-confirmar { font-size: 1.02rem; margin: 0 0 4px; white-space: pre-line; }
td.asignar { display: grid; gap: 4px; min-width: 220px; }
.en-fila { display: flex; gap: 4px; align-items: center; }
input.entrada-chica { min-height: 34px; padding: 4px 8px; font-size: .85rem; }

/* ---------- Checador ---------- */
.cuerpo-checador { background: var(--fondo); }
.checador-caja { max-width: 420px; margin: 0 auto; padding: 24px 18px 40px; display: grid; gap: 14px; text-align: center; }
.checador-caja h1 { margin: 0; font-size: 1.6rem; }
.checador-marca { color: var(--acento); font-weight: 700; margin: 0; }
.checador-nota { color: var(--tenue); margin: 0; }
.checador-mal { color: var(--mal); font-weight: 600; margin: 0; }
.checador-etiqueta { margin: 6px 0 0; font-weight: 600; }
.checador-tipos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checador-tipo { font: inherit; font-size: 1.1rem; font-weight: 700; padding: 16px; border-radius: 12px; border: 2px solid var(--linea); background: #fff; cursor: pointer; }
.checador-tipo.activo { border-color: var(--acento); background: var(--acento-suave); color: var(--acento); }
.pin-puntos { display: flex; justify-content: center; gap: 14px; }
.pin-puntos span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--acento); }
.pin-puntos span.lleno { background: var(--acento); }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tecla { font: inherit; font-size: 1.5rem; padding: 14px 0; border-radius: 12px; border: 1px solid var(--linea); background: #fff; cursor: pointer; }
.tecla:active { background: var(--acento-suave); }
.checador-boton { font: inherit; font-size: 1.15rem; font-weight: 700; padding: 16px; border-radius: 12px; border: 0; background: var(--acento); color: #fff; cursor: pointer; }
.checador-boton:disabled { opacity: .45; }
.checador-boton.secundario { background: #fff; color: var(--acento); border: 2px solid var(--acento); }
.checador-selfie { width: 120px; height: 120px; object-fit: cover; border-radius: 50%; margin: 0 auto; }
.checador-ok { font-size: 4rem; }
.checador-hora { font-size: 2.4rem; font-weight: 800; margin: 0; }
.checador-privacidad { font-size: .8rem; color: var(--tenue); }

/* Nómina */
.tabla.nomina input[type=number] { width: 4.2em; padding: 4px 6px; text-align: right; }
.tabla.nomina select { max-width: 9.5em; padding: 4px 6px; font-size: .85em; margin-top: 4px; }
.tabla.nomina th small, .tabla.nomina td small { display: block; font-weight: normal; }
.tabla.nomina td .boton-texto { display: block; font-size: .8em; margin-top: 2px; }

/* Permisos por módulo */
.tabla.permisos th { width: 30%; vertical-align: top; }
.tabla.permisos th small { display: block; font-weight: normal; margin-top: 2px; }
.niveles { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.nivel { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border: 1px solid var(--linea); border-radius: 999px; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.nivel:has(input:checked) { background: var(--acento-suave); border-color: var(--acento); font-weight: 600; }
.nivel.nivel-no:has(input:checked) { background: transparent; border-color: var(--linea); font-weight: normal; color: var(--tenue); }
.tabla.permisos tr.distinto th { box-shadow: inset 4px 0 0 #d9a400; }
.tabla.permisos tr.distinto th::after { content: ' · distinto a la plantilla'; font-weight: normal; font-size: .75rem; color: #9a7400; }
.editor-permisos .campo { margin-top: 10px; }
tr.inactivo { opacity: .55; }

.solo-ver button, .solo-ver .boton { display: none; }
.solo-ver .pestanas a, .solo-ver a { display: inline-block; }

/* ---------- Pregúntale a ValerIA ---------- */
.valeria-boton { position: fixed; right: 18px; bottom: 18px; z-index: 900; width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--acento); color: #fff; font-size: 1.5rem; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.22); cursor: pointer; }
.valeria-boton:hover { filter: brightness(1.08); }
.valeria-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 950; background: var(--tarjeta);
  box-shadow: -6px 0 24px rgba(0,0,0,.18); display: flex; flex-direction: column; }
.valeria-encabezado { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--linea); }
.valeria-encabezado small { display: block; color: var(--tenue); font-size: .8rem; }
.valeria-tabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--linea); }
.valeria-tab { flex: 1; border: 0; background: none; padding: 10px 6px; font: inherit; color: var(--tenue); border-bottom: 3px solid transparent; cursor: pointer; }
.valeria-tab.activo { color: var(--acento); border-bottom-color: var(--acento); font-weight: 600; }
.valeria-cuerpo { flex: 1; overflow-y: auto; padding: 12px 16px 16px; }
.valeria-seccion { border: 1px solid var(--linea); border-radius: var(--radio); padding: 8px 12px; margin-bottom: 8px; background: var(--tarjeta); }
.valeria-seccion summary { cursor: pointer; font-weight: 600; }
.valeria-seccion[open] summary { margin-bottom: 6px; }
.valeria-buscar { width: 100%; margin: 14px 0 8px; }
.valeria-ir-chat { width: 100%; margin-top: 6px; }
.valeria-chat { display: flex; flex-direction: column; height: 100%; gap: 8px; }
.valeria-mensajes { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 200px; }
.valeria-msg { max-width: 88%; padding: 10px 12px; border-radius: 14px; line-height: 1.45; font-size: .95rem; }
.valeria-msg.usuario { align-self: flex-end; background: var(--acento); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.valeria-msg.valeria { align-self: flex-start; background: var(--fondo); border: 1px solid var(--linea); border-bottom-left-radius: 4px; }
.valeria-msg.error { border-color: var(--mal); color: var(--mal); }
.valeria-msg.sin-respuesta { border-style: dashed; }
.valeria-votos { display: flex; gap: 4px; margin-top: 6px; }
.valeria-votos .boton-icono.activo { background: var(--acento-suave); border-radius: 8px; }
.valeria-form textarea { width: 100%; resize: vertical; }
.valeria-form-pie { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; gap: 8px; }
.valeria-aviso { display: block; font-size: .75rem; }
.texto-formato p { margin: .35em 0; }
.texto-formato h4 { margin: .7em 0 .3em; font-size: .95rem; }
.texto-formato ul, .texto-formato ol { margin: .3em 0 .5em; padding-left: 1.3em; }
.texto-formato li { margin: .15em 0; }
.texto-formato li.sub { margin-left: 1em; list-style-type: circle; }
.lista-dudas .duda { border-bottom: 1px solid var(--linea); padding: 8px 0; }
.lista-dudas .duda summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.lista-dudas .duda summary .tenue { width: 100%; font-size: .8rem; }
.editor-manual { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.vista-previa { border: 1px dashed var(--linea); border-radius: var(--radio); padding: 8px 12px; max-height: 300px; overflow: auto; }
@media (max-width: 700px) {
  .valeria-boton { bottom: 84px; right: 14px; width: 48px; height: 48px; }
}
