:root {
  --azul: #1565c0; --azul2: #0d47a1; --verde: #2e7d32; --rojo: #c62828; --ambar: #ef6c00;
  --fondo: #f3f5f9; --carta: #fff; --texto: #1d2430; --suave: #667085; --linea: #e4e7ec;
  --radio: 14px; --sombra: 0 1px 3px rgba(16,24,40,.08);
  --abajo: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(64px + var(--abajo)); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#barra { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  background: var(--azul); color: #fff; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px; }
#barra .titulos { flex: 1; min-width: 0; }
#titulo { font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#subtitulo { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icono { background: none; border: 0; color: #fff; font-size: 22px; padding: 4px 8px; }
.chip-suc { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 20px; padding: 6px 12px; font-size: 13px; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#offline { background: var(--rojo); color: #fff; text-align: center; padding: 6px; font-size: 13px; }

main { padding: 12px; max-width: 900px; margin: 0 auto; }
#nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: #fff;
  border-top: 1px solid var(--linea); padding-bottom: var(--abajo); }
#nav button { flex: 1; background: none; border: 0; padding: 8px 0 7px; font-size: 11px; color: var(--suave); display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
#nav button span { font-size: 20px; line-height: 1; }
#nav button.activo { color: var(--azul); font-weight: 600; }
#badgeCarrito { position: absolute; top: 3px; left: 55%; background: var(--rojo); color: #fff; border-radius: 10px; font-size: 10px; padding: 1px 6px; }

.carta { background: var(--carta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 14px; margin-bottom: 12px; }
.carta h3 { margin: 0 0 10px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
@media (min-width: 700px) { .grid2.g4 { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--carta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 12px; border-left: 4px solid var(--azul); }
.kpi .et { font-size: 11px; color: var(--suave); text-transform: uppercase; letter-spacing: .03em; }
.kpi .va { font-size: 21px; font-weight: 700; margin: 2px 0; white-space: nowrap; }
.kpi .de { font-size: 12px; color: var(--suave); }
.kpi.verde { border-color: var(--verde); } .kpi.verde .va { color: var(--verde); }
.kpi.rojo { border-color: var(--rojo); } .kpi.rojo .va { color: var(--rojo); }
.kpi.morado { border-color: #6a1b9a; }
.veredicto { border-radius: var(--radio); color: #fff; padding: 14px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.veredicto.bien { background: var(--verde); } .veredicto.mal { background: var(--rojo); } .veredicto.neutro { background: #455a64; }
.veredicto .t1 { font-weight: 800; font-size: 17px; } .veredicto .t2 { font-size: 12px; opacity: .9; }
.veredicto .monto { text-align: right; flex: none; } .veredicto .monto b { font-size: 20px; display: block; white-space: nowrap; }

.periodos { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; }
.periodos button, .chip { flex: none; border: 1px solid var(--linea); background: #fff; border-radius: 20px; padding: 7px 13px; font-size: 13px; }
.periodos button.activo, .chip.activo { background: var(--azul); color: #fff; border-color: var(--azul); }
.fechas { display: flex; gap: 8px; margin-bottom: 10px; }
.fechas input { flex: 1; }

.fila { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--linea); }
.fila:last-child { border-bottom: 0; }
.fila .izq { min-width: 0; flex: 1; }
.fila .nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.fila .sub { font-size: 12px; color: var(--suave); }
.fila .der { text-align: right; white-space: nowrap; }
.fila.total { font-weight: 700; }
.lista-tap .fila { cursor: pointer; }
.lista-tap .fila:active { background: #f5f8ff; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--verde); } .neg { color: var(--rojo); } .gris { color: var(--suave); }
.etq { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 10px; background: #eef2ff; color: var(--azul2); font-weight: 600; }
.etq.rojo { background: #fdecea; color: var(--rojo); } .etq.ambar { background: #fff3e0; color: var(--ambar); } .etq.verde { background: #e8f5e9; color: var(--verde); }

.barras { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.barras .b { flex: 1; background: var(--azul); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.barras .b.hoy { background: var(--verde); }
.ejes { display: flex; gap: 3px; font-size: 10px; color: var(--suave); }
.ejes span { flex: 1; text-align: center; overflow: hidden; white-space: nowrap; }

.campo { display: block; margin-bottom: 12px; }
.campo > span { display: block; font-size: 13px; color: var(--suave); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], input[type=url], select, textarea {
  width: 100%; padding: 12px; border: 1px solid #cfd5df; border-radius: 10px; background: #fff; font-size: 16px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #90caf9; border-color: var(--azul); }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.check input { width: 20px; height: 20px; }

.btn { text-decoration: none; display: inline-flex; justify-content: center; align-items: center; gap: 6px; border: 0; border-radius: 10px; padding: 12px 16px; font-weight: 600; background: var(--azul); color: #fff; cursor: pointer; }
.btn:disabled { opacity: .55; }
.btn.bloque { width: 100%; }
.btn.sec { background: #e8eef9; color: var(--azul2); }
.btn.verde { background: var(--verde); } .btn.rojo { background: var(--rojo); }
.btn.peq { padding: 8px 12px; font-size: 13px; }
.botones { display: flex; gap: 8px; } .botones > * { flex: 1; }

.buscador { display: flex; gap: 8px; margin-bottom: 10px; position: sticky; top: 58px; z-index: 5; background: var(--fondo); padding: 4px 0; }
.buscador input { flex: 1; }
.buscador .btn { flex: none; padding: 0 14px; font-size: 20px; }

.prod-precio { font-size: 16px; font-weight: 700; }
.vacio { text-align: center; color: var(--suave); padding: 30px 10px; }
.cargando { text-align: center; color: var(--suave); padding: 30px; }
.error { background: #fdecea; color: var(--rojo); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.aviso { background: #fff8e1; color: #8a5300; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-size: 13px; }
.ok { background: #e8f5e9; color: var(--verde); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.grande { font-size: 40px; font-weight: 800; text-align: center; margin: 10px 0; color: var(--azul2); }
.centro { text-align: center; }
.mt { margin-top: 12px; }
.nota { font-size: 12px; color: var(--suave); }

.cant { display: flex; align-items: center; gap: 6px; }
.cant button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--linea); background: #fff; font-size: 18px; }
.cant input { width: 64px; text-align: center; padding: 6px; }

#hoja { position: fixed; inset: 0; z-index: 50; }
.hoja-fondo { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.hoja-caja { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto; background: var(--fondo);
  border-radius: 18px 18px 0 0; padding: 16px 14px calc(16px + var(--abajo)); max-width: 700px; margin: 0 auto; }
.hoja-caja h2 { margin: 0 0 12px; font-size: 18px; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + var(--abajo)); background: #263238; color: #fff;
  padding: 10px 16px; border-radius: 22px; z-index: 60; font-size: 14px; max-width: 90vw; text-align: center; }

.empresa { display: flex; align-items: center; gap: 12px; }
.empresa .logo { width: 42px; height: 42px; border-radius: 10px; background: var(--azul); color: #fff; display: grid; place-items: center; font-weight: 800; }
.portada { text-align: center; padding: 20px 0 8px; }
.portada img { width: 72px; height: 72px; border-radius: 18px; }
.portada h1 { margin: 10px 0 2px; font-size: 22px; }
video.escaner { width: 100%; border-radius: 12px; background: #000; max-height: 50vh; object-fit: cover; }
.segmento { display: flex; background: #e8eef9; border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.segmento button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 8px; font-weight: 600; color: var(--azul2); }
.segmento button.activo { background: #fff; box-shadow: var(--sombra); }
.selsuc { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 6px 6px 6px 12px; margin-bottom: 10px; box-shadow: var(--sombra); }
.selsuc span { font-size: 13px; color: var(--suave); flex: none; }
.selsuc select { border: 0; padding: 8px; font-weight: 600; color: var(--azul2); background: transparent; }
.vend { cursor: pointer; }
.barra { height: 8px; background: #eef2f7; border-radius: 4px; overflow: hidden; margin: 2px 0 8px; }
.barra div { height: 100%; background: var(--azul); border-radius: 4px; }
.vend-datos { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--suave); }
.vend-datos b { color: var(--texto); font-weight: 600; } .vend-datos .pos b, .vend-datos span.pos { color: var(--verde); } .vend-datos .neg b, .vend-datos span.neg { color: var(--rojo); }
.interruptor { position: relative; width: 48px; height: 28px; flex: none; }
.interruptor input { opacity: 0; width: 0; height: 0; }
.interruptor span { position: absolute; inset: 0; background: #cfd5df; border-radius: 14px; transition: .2s; }
.interruptor span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.interruptor input:checked + span { background: var(--verde); }
.interruptor input:checked + span::before { transform: translateX(20px); }
.interruptor input:disabled + span { opacity: .5; }
