:root {
  --marino: #19244e;
  --azul: #253c96;
  --celeste: #bfedff;
  --claro: #eef5fb;
  --naranja: #f36b2e;
  --naranja-osc: #c94e17;
  --neon: #d8e022;
  --verde: #1f8a57;
  --rojo: #c0392b;
  --amarillo: #b7791f;
  --texto: #19244e;
  --suave: #56607f;
  --borde: #dfe6f0;
  --fondo: #f6f8fc;
  --blanco: #ffffff;
  --radio: 16px;
  --sombra: 0 6px 20px rgba(25, 36, 78, .08);
  --fuente: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --titulos: 'DM Serif Display', Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--fuente); color: var(--texto); background: var(--fondo); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
a { color: var(--azul); }
.oculto { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; }

/* ===== Aviso de demo ===== */
.demo { background: var(--neon); color: var(--marino); font-size: .82rem; font-weight: 700; text-align: center; padding: 6px 12px; }
.demo button { background: none; border: 0; text-decoration: underline; font-weight: 700; padding: 0 4px; }

/* ===== Ingreso ===== */
.ingreso { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--marino); }
.ingreso__caja { width: 100%; max-width: 420px; background: var(--blanco); border-radius: 24px; padding: 32px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.ingreso__logo { width: 64px; height: 64px; border-radius: 18px; background: var(--marino); color: var(--naranja); display: grid; place-items: center; font-family: var(--titulos); font-size: 34px; margin-bottom: 18px; }
.ingreso h1 { font-family: var(--titulos); font-weight: 400; font-size: 2rem; }
.ingreso p { color: var(--suave); margin: 6px 0 22px; }
.ingreso__roles { display: grid; gap: 12px; }
.rol { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; background: var(--claro); border: 2px solid transparent; border-radius: var(--radio); padding: 16px; }
.rol:hover, .rol:focus-visible { border-color: var(--azul); outline: none; }
.rol strong { display: block; font-size: 1.05rem; }
.rol span { color: var(--suave); font-size: .9rem; }
.rol__ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--azul); color: #fff; flex: none; }
.rol--emp .rol__ic { background: var(--naranja); color: var(--marino); }
.ingreso__firma { margin-top: 22px; text-align: center; font-size: .82rem; color: var(--suave); }

/* ===== Estructura ===== */
.marco { display: flex; min-height: calc(100vh - 31px); }
.lateral { display: none; }
.cuerpo { flex: 1; min-width: 0; padding: 0 0 150px; }
.barra { position: sticky; top: 0; z-index: 20; background: var(--marino); color: #fff; display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.barra__tienda { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.barra__logo { width: 38px; height: 38px; border-radius: 11px; background: var(--naranja); color: var(--marino); font-family: var(--titulos); font-size: 22px; display: grid; place-items: center; flex: none; }
.barra__nombre { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra__nombre small { display: block; font-weight: 400; font-size: .78rem; color: var(--celeste); }
.chip-rol { background: rgba(255,255,255,.14); border-radius: 999px; padding: 4px 10px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.contenido { padding: 18px 16px; max-width: 1100px; margin: 0 auto; }
.titulo { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.titulo h1 { font-family: var(--titulos); font-weight: 400; font-size: 1.8rem; }
.titulo p { margin: 2px 0 0; color: var(--suave); font-size: .92rem; }

/* Navegación inferior (celular) */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--blanco); border-top: 1px solid var(--borde); display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; text-decoration: none; color: var(--suave); font-size: .72rem; font-weight: 700; border-radius: 12px; }
.nav a.activo { color: var(--azul); background: var(--claro); }
.nav svg.i { width: 22px; height: 22px; }

/* ===== Elementos ===== */
.boton { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 700; background: var(--azul); color: #fff; text-decoration: none; min-height: 46px; }
.boton:hover { filter: brightness(1.08); }
.boton--naranja { background: var(--naranja); color: var(--marino); }
.boton--claro { background: var(--claro); color: var(--marino); }
.boton--borde { background: var(--blanco); color: var(--azul); border: 2px solid var(--azul); }
.boton--peligro { background: #fdecea; color: var(--rojo); }
.boton--bloque { width: 100%; }
.boton--chico { min-height: 38px; padding: 8px 14px; font-size: .9rem; }
.boton[disabled] { opacity: .45; cursor: not-allowed; filter: none; }

.tarjetas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.dato { background: var(--blanco); border-radius: var(--radio); padding: 14px 16px; box-shadow: var(--sombra); }
.dato span { display: block; font-size: .8rem; color: var(--suave); font-weight: 700; }
.dato strong { display: block; font-size: 1.35rem; margin-top: 2px; }
.dato small { color: var(--suave); }
.dato--azul { background: var(--marino); color: #fff; }
.dato--azul span, .dato--azul small { color: var(--celeste); }

.caja { background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; margin-bottom: 16px; }
.caja__cab { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.caja__cab h2 { font-size: 1.05rem; }
.caja__cab a, .enlace { font-weight: 700; font-size: .9rem; color: var(--azul); background: none; border: 0; padding: 0; text-decoration: none; }

.lista { list-style: none; margin: 0; padding: 0; }
.fila { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--borde); }
.fila:last-child { border-bottom: 0; }
.fila__info { flex: 1; min-width: 0; }
.fila__info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila__info small { color: var(--suave); }
.fila__valor { text-align: right; font-weight: 700; white-space: nowrap; }
.fila__valor small { display: block; font-weight: 400; color: var(--suave); }
button.fila { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--borde); text-align: left; }
button.fila:hover { background: var(--claro); }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--claro); color: var(--azul); font-weight: 700; flex: none; }

.etq { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: .74rem; font-weight: 700; }
.etq--ok { background: #e3f5ec; color: var(--verde); }
.etq--bajo { background: #fdf3e1; color: var(--amarillo); }
.etq--agotado { background: #fdecea; color: var(--rojo); }
.etq--azul { background: var(--claro); color: var(--azul); }

.buscador { display: flex; align-items: center; gap: 8px; background: var(--blanco); border: 2px solid var(--borde); border-radius: 999px; padding: 0 14px; margin-bottom: 12px; }
.buscador:focus-within { border-color: var(--azul); }
.buscador input { border: 0; outline: none; background: none; padding: 11px 0; width: 100%; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 2px solid var(--borde); background: var(--blanco); border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: .88rem; color: var(--suave); }
.chip.activo { background: var(--marino); border-color: var(--marino); color: #fff; }

.vacio { text-align: center; color: var(--suave); padding: 28px 12px; }

/* ===== Vender ===== */
.productos-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.prod { position: relative; background: var(--blanco); border: 2px solid transparent; border-radius: var(--radio); box-shadow: var(--sombra); padding: 12px; text-align: left; display: flex; flex-direction: column; gap: 4px; min-height: 108px; }
.prod:hover { border-color: var(--celeste); }
.prod__emoji { font-size: 1.6rem; line-height: 1; }
.prod__nombre { font-weight: 700; font-size: .95rem; line-height: 1.2; }
.prod__precio { font-weight: 700; color: var(--azul); margin-top: auto; }
.prod__stock { font-size: .76rem; color: var(--suave); }
.prod--agotado { opacity: .5; }
.prod__cant { position: absolute; top: 8px; right: 8px; background: var(--naranja); color: var(--marino); font-weight: 700; font-size: .8rem; min-width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center; padding: 0 6px; }
.carrito-barra { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 25; background: var(--marino); color: #fff; border-radius: 18px; padding: 10px 10px 10px 18px; display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(25,36,78,.35); }
.carrito-barra div { flex: 1; }
.carrito-barra small { display: block; color: var(--celeste); font-size: .8rem; }
.carrito-barra strong { font-size: 1.2rem; }
.panel-venta { display: none; }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(15, 22, 50, .55); display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.modal__caja { background: var(--blanco); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 24px 24px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
.modal__cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal__cab h2 { font-family: var(--titulos); font-weight: 400; font-size: 1.5rem; }
.cerrar { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--claro); display: grid; place-items: center; }
.acciones { display: grid; gap: 10px; margin-top: 16px; }
.acciones--2 { grid-template-columns: 1fr 1fr; }

.campo { display: grid; gap: 5px; margin-bottom: 12px; }
.campo label { font-weight: 700; font-size: .88rem; }
.campo input, .campo select, .campo textarea { width: 100%; border: 2px solid var(--borde); border-radius: 12px; padding: 11px 12px; background: var(--blanco); }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--azul); }
.campo small { color: var(--suave); }
.campos-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.item-venta { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--borde); }
.item-venta__info { flex: 1; min-width: 0; }
.item-venta__info strong { display: block; font-size: .95rem; }
.item-venta__info small { color: var(--suave); }
.contador { display: flex; align-items: center; gap: 6px; }
.contador button { width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--claro); font-weight: 700; font-size: 1.1rem; display: grid; place-items: center; }
.contador span { min-width: 22px; text-align: center; font-weight: 700; }
.total-linea { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 6px; }
.total-linea strong { font-size: 1.6rem; }
.metodos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 8px 0 12px; }
.metodo { border: 2px solid var(--borde); background: var(--blanco); border-radius: 12px; padding: 10px 6px; font-weight: 700; font-size: .86rem; }
.metodo.activo { border-color: var(--azul); background: var(--claro); color: var(--azul); }
.cambio { background: #e3f5ec; color: var(--verde); border-radius: 12px; padding: 10px 14px; font-weight: 700; display: flex; justify-content: space-between; }

/* ===== Reportes ===== */
.periodos { margin-bottom: 14px; }
.barras { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 10px; }
.barras div { flex: 1; background: var(--azul); border-radius: 6px 6px 2px 2px; min-height: 3px; position: relative; }
.barras div:hover { background: var(--naranja); }
.barras-eje { display: flex; justify-content: space-between; font-size: .74rem; color: var(--suave); margin-top: 6px; }
.descargas { display: grid; gap: 10px; }

/* ===== Más ===== */
.menu-mas { display: grid; gap: 10px; }
.menu-mas a, .menu-mas button { display: flex; align-items: center; gap: 14px; background: var(--blanco); border: 0; border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; text-decoration: none; color: var(--texto); font-weight: 700; text-align: left; width: 100%; }
.menu-mas small { display: block; font-weight: 400; color: var(--suave); }
.menu-mas .avatar { background: var(--claro); }

.toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--verde); color: #fff; font-weight: 700; padding: 12px 20px; border-radius: 999px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: calc(100% - 32px); text-align: center; }
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.firma { text-align: center; font-size: .8rem; color: var(--suave); padding: 10px 16px 0; }

/* ===== Pantallas grandes ===== */
@media (min-width: 560px) {
  .productos-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tarjetas { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .modal { align-items: center; }
  .modal__caja { border-radius: 24px; }
}
@media (min-width: 960px) {
  .nav { display: none; }
  .lateral { display: flex; flex-direction: column; gap: 4px; width: 240px; flex: none; background: var(--marino); color: #fff; padding: 20px 14px; position: sticky; top: 0; height: calc(100vh - 31px); }
  .lateral__tienda { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
  .lateral a { display: flex; align-items: center; gap: 12px; color: #dfe8ff; text-decoration: none; font-weight: 700; padding: 11px 12px; border-radius: 12px; }
  .lateral a:hover { background: rgba(255,255,255,.08); }
  .lateral a.activo { background: var(--naranja); color: var(--marino); }
  .lateral__pie { margin-top: auto; font-size: .8rem; color: var(--celeste); padding: 0 8px; }
  .barra .barra__tienda { visibility: hidden; }
  .barra { background: var(--fondo); color: var(--texto); justify-content: flex-end; padding: 14px 24px 0; position: static; }
  .chip-rol { background: var(--blanco); box-shadow: var(--sombra); }
  .cuerpo { padding-bottom: 40px; }
  .contenido { padding: 10px 28px 28px; }
  .vender-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
  .productos-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .carrito-barra { display: none; }
  .panel-venta { display: block; position: sticky; top: 20px; }
  .toast { bottom: 30px; }
  .dos-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
}
@media (min-width: 1200px) { .productos-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ===== Cambios v2 ===== */
.avatar { overflow: hidden; font-family: var(--titulos); font-size: 1.25rem; font-weight: 400; }
.avatar svg.i { width: 20px; height: 20px; }
.avatar--grande { width: 72px; height: 72px; border-radius: 18px; font-size: 2.2rem; }
.avatar--foto { background: var(--claro); }
.avatar--foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar--insumo { background: #fff4ec; color: var(--naranja-osc); }
.prod .avatar { width: 44px; height: 44px; margin-bottom: 4px; }
.lista .avatar, .item-venta .avatar { font-family: var(--fuente); font-weight: 700; font-size: 1rem; }
.lista .avatar[style], .item-venta .avatar[style], .prod .avatar[style] { font-family: var(--titulos); font-weight: 400; font-size: 1.3rem; }

.pestanas { display: inline-flex; background: var(--blanco); border-radius: 999px; padding: 4px; box-shadow: var(--sombra); margin-bottom: 14px; gap: 2px; }
.pestana { border: 0; background: none; border-radius: 999px; padding: 8px 16px; font-weight: 700; color: var(--suave); }
.pestana.activa { background: var(--marino); color: #fff; }

.buscador-fila { display: flex; gap: 8px; align-items: flex-start; }
.buscador-fila .buscador { flex: 1; }
.boton-escanear { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--azul); background: var(--blanco); color: var(--azul); border-radius: 999px; padding: 0 14px; height: 48px; font-weight: 700; flex: none; }
.boton-escanear:hover { background: var(--claro); }
.boton-escanear--chico { height: 46px; width: 46px; padding: 0; justify-content: center; border-radius: 12px; }
@media (max-width: 420px) { .boton-escanear span { display: none; } .boton-escanear { width: 48px; justify-content: center; padding: 0; } }
.con-boton { display: flex; gap: 8px; }
.con-boton input { flex: 1; min-width: 0; }

.foto-campo { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.receta { border: 2px dashed var(--borde); border-radius: 14px; padding: 12px 14px; margin: 4px 0 6px; }
.receta legend { font-weight: 700; font-size: .9rem; padding: 0 6px; }
.receta legend span { font-weight: 400; color: var(--suave); }
.receta p { margin: 0 0 8px; color: var(--suave); font-size: .86rem; }
.receta-fila { display: grid; grid-template-columns: minmax(0, 1fr) 80px 40px; gap: 8px; margin-bottom: 8px; }
.receta-fila select, .receta-fila input { border: 2px solid var(--borde); border-radius: 12px; padding: 9px 10px; background: var(--blanco); min-width: 0; }
.receta-info { background: var(--claro); border-radius: 12px; padding: 10px 14px; font-size: .9rem; margin-top: 4px; }
.producto-cab { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.producto-cab__codigo { margin: 6px 0 0; color: var(--suave); font-size: .9rem; }
.nota-suave { color: var(--suave); font-size: .9rem; max-width: 640px; }

.aviso-caja { display: flex; align-items: center; gap: 12px; background: #fff4ec; border: 2px solid #ffd9c2; color: var(--marino); border-radius: var(--radio); padding: 12px 14px; margin-bottom: 16px; flex-wrap: wrap; }
.aviso-caja span { flex: 1; min-width: 200px; }
.aviso-caja svg.i { color: var(--naranja-osc); }
.abrir-caja { text-align: center; }
.abrir-caja h2 { font-family: var(--titulos); font-weight: 400; font-size: 1.5rem; margin-top: 10px; }
.abrir-caja p { color: var(--suave); margin: 6px 0 16px; }
.abrir-caja .campo { text-align: left; }
.abrir-caja__ic { width: 60px; height: 60px; border-radius: 18px; background: var(--claro); color: var(--azul); display: grid; place-items: center; margin: 0 auto; }
.abrir-caja__ic svg.i { width: 30px; height: 30px; }
.estado-caja { background: #e3f5ec; color: var(--verde); font-weight: 700; border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: .92rem; }
.estado-caja--cerrada { background: var(--claro); color: var(--azul); }
.selector select { border: 2px solid var(--borde); border-radius: 12px; padding: 10px 12px; background: var(--blanco); font-weight: 700; }
.tabla-scroll { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabla th { text-align: left; font-size: .78rem; color: var(--suave); font-weight: 700; padding: 8px 6px; border-bottom: 2px solid var(--borde); white-space: nowrap; }
.tabla td { padding: 10px 6px; border-bottom: 1px solid var(--borde); white-space: nowrap; }
.tabla td:nth-child(n+2):not(:last-child), .tabla th:nth-child(n+2):not(:last-child) { text-align: right; }
.tabla__total td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--borde); }
.barras--meses { gap: 8px; }
.barras-meses-eje { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; font-size: .72rem; color: var(--suave); margin-top: 6px; text-align: center; }

.escaner { z-index: 70; }
.escaner__caja { background: var(--blanco); width: 100%; max-width: 480px; border-radius: 24px 24px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
.escaner__video { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.escaner__video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.escaner__marco { position: absolute; left: 12%; right: 12%; top: 30%; bottom: 30%; border: 3px solid var(--neon); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
#escaner-msg { color: var(--suave); text-align: center; margin: 12px 0; }
@media (min-width: 560px) { .escaner__caja { border-radius: 24px; } }

/* ===== Conteo de insumos ===== */
.caja--ancha { grid-column: 1 / -1; order: 3; }
.conteo { margin-top: 16px; }
.conteo-fila { display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: 4px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--borde); }
.conteo-fila:last-child { border-bottom: 0; }
.conteo-fila label strong { display: block; font-size: .92rem; }
.conteo-fila label small { color: var(--suave); }
.conteo-fila input { border: 2px solid var(--borde); border-radius: 12px; padding: 9px 10px; width: 100%; }
.conteo-fila input:focus { outline: none; border-color: var(--azul); }
.ct-dif { grid-column: 1 / -1; font-size: .82rem; font-weight: 700; }
.ct-dif:empty { display: none; }
.ct-dif--ok { color: var(--verde); }
.ct-dif--mal { color: var(--rojo); }
.ct-dif--sobra { color: var(--amarillo); }
