:root {
  --fondo: #f7f3ea;
  --papel: #ffffff;
  --tinta: #1d2420;
  --tinta-2: #5b645f;
  --tinta-3: #8a918c;
  --linea: #e4ddcf;
  --verde: #1f6b4a;
  --verde-2: #17553a;
  --verde-claro: #e3f1e8;
  --rojo: #b4342a;
  --rojo-claro: #fbe7e4;
  --mostaza: #9a6a00;
  --mostaza-claro: #fdf1d2;
  --azul: #22558f;
  --azul-claro: #e4eef9;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(29, 36, 32, .06), 0 4px 14px rgba(29, 36, 32, .06);
  --nav: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--tinta);
  background: var(--fondo);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body { font-size: 16px; line-height: 1.4; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
a { color: var(--verde); }
.oculto { display: none !important; }

#app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 8px); }
.pantalla { padding: 12px 14px 20px; }

/* barra superior */
.barra { display: flex; align-items: center; gap: 10px; padding: 12px 14px 6px; position: sticky; top: 0; background: var(--fondo); z-index: 5; }
.barra .titulo { flex: 1; min-width: 0; }
.barra .titulo b { display: block; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra .titulo small { color: var(--tinta-2); font-size: 13px; }
.estado { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--verde-claro); color: var(--verde-2); white-space: nowrap; }
.estado.sin { background: var(--mostaza-claro); color: var(--mostaza); }
.volver { border: 0; background: var(--papel); width: 40px; height: 40px; border-radius: 12px; font-size: 22px; box-shadow: var(--sombra); cursor: pointer; }

/* navegación inferior */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--papel); border-top: 1px solid var(--linea); padding-bottom: env(safe-area-inset-bottom); }
.nav-in { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); height: var(--nav); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--tinta-3); font-size: 12px; font-weight: 600; }
.nav a svg { width: 26px; height: 26px; }
.nav a.activo { color: var(--verde); }

/* tarjetas y listas */
.tarjeta { background: var(--papel); border-radius: var(--radio); box-shadow: var(--sombra); padding: 14px; margin-bottom: 12px; }
.lista { background: var(--papel); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; margin-bottom: 12px; }
.fila { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--linea); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; cursor: pointer; }
.fila:last-child { border-bottom: 0; }
.fila .info { flex: 1; min-width: 0; }
.fila .nombre { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .sub { font-size: 13px; color: var(--tinta-2); }
.fila .der { text-align: right; font-weight: 700; white-space: nowrap; }
.vacio { text-align: center; color: var(--tinta-2); padding: 28px 16px; }
.seccion { font-size: 13px; font-weight: 700; color: var(--tinta-2); text-transform: uppercase; letter-spacing: .04em; margin: 18px 4px 8px; }

/* botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1.5px solid var(--linea); background: var(--papel); font-weight: 650; cursor: pointer; text-decoration: none; color: var(--tinta); }
.btn:active { transform: scale(.98); }
.btn.prim { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn.prim:active { background: var(--verde-2); }
.btn.peligro { color: var(--rojo); border-color: #ecc6c1; }
.btn.grande { min-height: 58px; font-size: 19px; width: 100%; }
.btn.ancho { width: 100%; }
.btn.chico { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .5; }
.botones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.botones.tres { grid-template-columns: 1fr 1fr 1fr; }

/* formularios */
label.campo { display: block; margin-bottom: 12px; }
label.campo > span { display: block; font-size: 14px; font-weight: 600; color: var(--tinta-2); margin-bottom: 5px; }
.input, select.input, textarea.input { width: 100%; min-height: 50px; border: 1.5px solid var(--linea); background: var(--papel); border-radius: 12px; padding: 10px 13px; font-size: 17px; outline: none; }
.input:focus { border-color: var(--verde); box-shadow: 0 0 0 3px rgba(31, 107, 74, .15); }
.input.numero { font-size: 22px; font-weight: 700; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--verde); }
.error { background: var(--rojo-claro); color: var(--rojo); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }
.nota { font-size: 13px; color: var(--tinta-2); }

/* chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--linea); background: var(--papel); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.chip.activo { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.etiqueta { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--verde-claro); color: var(--verde-2); }
.etiqueta.rojo { background: var(--rojo-claro); color: var(--rojo); }
.etiqueta.amarillo { background: var(--mostaza-claro); color: var(--mostaza); }
.etiqueta.azul { background: var(--azul-claro); color: var(--azul); }
.rojo-t { color: var(--rojo); } .verde-t { color: var(--verde); } .amarillo-t { color: var(--mostaza); }

/* vender */
.buscador { display: flex; gap: 8px; margin-bottom: 10px; }
.buscador .input { flex: 1; }
.btn-escanear { flex: none; width: 58px; min-height: 50px; border-radius: 12px; border: 0; background: var(--tinta); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.btn-escanear svg { width: 28px; height: 28px; }
.camara { position: relative; background: #000; border-radius: var(--radio); overflow: hidden; margin-bottom: 10px; aspect-ratio: 16 / 9; }
.camara video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camara .mira { position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .25); }
.camara .linea-roja { position: absolute; left: 14%; right: 14%; top: 50%; height: 2px; background: #ff4d3d; }
.camara .cerrar { position: absolute; top: 8px; right: 8px; border: 0; background: rgba(0, 0, 0, .6); color: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 700; cursor: pointer; }
.camara .aviso { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; color: #fff; font-size: 13px; text-shadow: 0 1px 3px #000; }
.rapidos { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 8px; margin-bottom: 12px; }
.rapido { min-height: 54px; border-radius: 12px; border: 1.5px solid var(--linea); background: var(--papel); font-weight: 650; font-size: 14px; padding: 6px; cursor: pointer; line-height: 1.15; }
.rapido small { display: block; color: var(--tinta-2); font-weight: 500; font-size: 12px; }
.rapido.varios { border-style: dashed; }
.resultados { margin-top: -4px; }
.ticket-linea { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--linea); }
.ticket-linea:last-child { border-bottom: 0; }
.ticket-linea .info { flex: 1; min-width: 0; cursor: pointer; }
.cant { display: flex; align-items: center; gap: 4px; }
.cant button { width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid var(--linea); background: var(--papel); font-size: 20px; font-weight: 700; cursor: pointer; line-height: 1; }
.cant span { min-width: 34px; text-align: center; font-weight: 700; }
.total-barra { position: fixed; left: 0; right: 0; bottom: calc(var(--nav) + env(safe-area-inset-bottom)); z-index: 15; padding: 10px 14px; background: var(--fondo); border-top: 1px solid var(--linea); }
.total-barra .in { max-width: 692px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.total-barra .monto { flex: 1; }
.total-barra .monto small { display: block; font-size: 13px; color: var(--tinta-2); }
.total-barra .monto b { font-size: 28px; letter-spacing: -.02em; }
.total-barra .btn { min-width: 150px; min-height: 56px; font-size: 19px; }
.con-total { padding-bottom: 96px; }

/* hojas (ventanas desde abajo) */
.velo { position: fixed; inset: 0; background: rgba(20, 24, 22, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: aparecer .15s ease-out; }
.hoja { background: var(--fondo); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); animation: subir .2s ease-out; }
.hoja .agarradera { width: 44px; height: 5px; border-radius: 9px; background: var(--linea); margin: 4px auto 12px; }
.hoja h2 { margin-bottom: 14px; }
.hoja-cab { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.hoja-cab h2 { margin: 0; }
.x { border: 0; background: var(--papel); width: 38px; height: 38px; border-radius: 999px; font-size: 20px; cursor: pointer; box-shadow: var(--sombra); }
@keyframes subir { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }

.metodos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.metodo { min-height: 56px; border-radius: 12px; border: 2px solid var(--linea); background: var(--papel); font-weight: 700; cursor: pointer; font-size: 16px; }
.metodo.activo { border-color: var(--verde); background: var(--verde-claro); color: var(--verde-2); }
.billetes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0 12px; }
.billetes button { min-height: 44px; border-radius: 10px; border: 1.5px solid var(--linea); background: var(--papel); font-weight: 700; cursor: pointer; font-size: 14px; }
.cambio { text-align: center; padding: 14px; border-radius: var(--radio); background: var(--verde-claro); color: var(--verde-2); margin-bottom: 14px; }
.cambio small { display: block; font-weight: 600; }
.cambio b { font-size: 38px; letter-spacing: -.02em; }
.cambio.falta { background: var(--rojo-claro); color: var(--rojo); }
.gran-total { text-align: center; margin-bottom: 14px; }
.gran-total small { color: var(--tinta-2); font-weight: 600; }
.gran-total b { display: block; font-size: 42px; letter-spacing: -.02em; }
.listo { text-align: center; padding: 8px 0 14px; }
.listo .palomita { width: 64px; height: 64px; border-radius: 999px; background: var(--verde); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 34px; margin-bottom: 8px; }

/* métricas */
.metricas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.metrica { background: var(--papel); border-radius: var(--radio); box-shadow: var(--sombra); padding: 12px 14px; }
.metrica small { display: block; color: var(--tinta-2); font-size: 13px; font-weight: 600; }
.metrica b { font-size: 24px; letter-spacing: -.02em; }
.barras { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; }
.barras div { flex: 1; background: var(--verde); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.barras-et { display: flex; gap: 4px; font-size: 11px; color: var(--tinta-3); margin-top: 4px; }
.barras-et span { flex: 1; text-align: center; overflow: hidden; }

.menu-mas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-mas a { background: var(--papel); border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px 14px; text-decoration: none; color: var(--tinta); font-weight: 650; display: flex; flex-direction: column; gap: 6px; min-height: 92px; }
.menu-mas a svg { width: 28px; height: 28px; color: var(--verde); }
.menu-mas a small { color: var(--tinta-2); font-weight: 500; font-size: 13px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav) + 90px); z-index: 80; background: var(--tinta); color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; max-width: 90vw; box-shadow: var(--sombra); animation: aparecer .15s; }
.toast.mal { background: var(--rojo); }

/* acceso */
.acceso { max-width: 420px; margin: 0 auto; padding: 40px 18px; }
.marca { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.marca .logo { width: 52px; height: 52px; border-radius: 14px; background: var(--verde); color: #fff; display: flex; align-items: center; justify-content: center; }
.marca .logo svg { width: 32px; height: 32px; }
.marca b { font-size: 26px; display: block; }
.marca small { color: var(--tinta-2); }

/* ticket impreso (58 mm) */
#impresion { display: none; }
@media print {
  @page { size: 58mm auto; margin: 2mm; }
  body * { visibility: hidden; }
  #impresion, #impresion * { visibility: visible; }
  #impresion { display: block; position: absolute; left: 0; top: 0; width: 54mm; font: 11px/1.3 "Courier New", monospace; color: #000; }
  #impresion .c { text-align: center; }
  #impresion .f { display: flex; justify-content: space-between; gap: 4px; }
  #impresion hr { border: 0; border-top: 1px dashed #000; }
}
