:root {
  --fondo: #f4f2f9;
  --panel: #ffffff;
  --borde: #e5e8ef;
  --texto: #1b2434;
  --suave: #6a7589;
  --acento: #7a1fe0;
  --acento2: #a14bff;
  --acento-rgb: 122, 31, 224;
  --error: #e5484d;
  --aviso: #c27a00;
  --ok: #1f9d63;
  --campo: #ffffff;
  --sombra: 0 2px 10px rgba(40, 20, 80, .08);
  --marino: #120a1f;
  --marino2: #2c1a4d;
  --radio: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0e0916; --panel: #1b1428; --borde: #2f2442; --texto: #f4f1fa; --suave: #a198b4;
    --error: #ff7a6b; --aviso: #ffcc33; --ok: #6fdc9a; --campo: #140e20; --acento: #9d4dff; --acento2: #b57bff; --acento-rgb: 157, 77, 255;
    --sombra: 0 2px 10px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--fondo); color: var(--texto);
  font-family: -apple-system, system-ui, "Helvetica Neue", Arial, sans-serif; font-size: 15px; }
.oculto { display: none !important; }

/* Iconos */
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Pastillas de color con icono */
.chip { width: 36px; height: 36px; border-radius: 12px; display: inline-flex; align-items: center;
  justify-content: center; flex: none; }
.chip.verde  { color: #1f9d63; background: rgba(31, 157, 99, .14); }
.chip.azul   { color: #2f7de1; background: rgba(47, 125, 225, .14); }
.chip.rojo   { color: #e5484d; background: rgba(229, 72, 77, .13); }
.chip.ambar  { color: #d98a00; background: rgba(245, 166, 35, .17); }
.chip.morado { color: #8e55d9; background: rgba(142, 85, 217, .14); }

/* Marca: "vap" naranja + "ERP" */
.marca { margin: 0; font-weight: 800; letter-spacing: -.02em; }
.marca span { color: var(--acento); }

/* Login */
#login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at 85% 8%, rgba(161, 75, 255, .16), transparent 45%),
              linear-gradient(160deg, var(--marino2), var(--marino)); }
#form-login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px;
  background: var(--panel); border-radius: 26px; padding: 0 24px 24px; box-shadow: 0 14px 40px rgba(0, 0, 0, .3); }
input { width: 100%; padding: 13px 15px; font-size: 15px; color: var(--texto);
  background: var(--campo); border: 1.5px solid var(--borde); border-radius: 14px; }
input::placeholder { color: #9aa4b5; }
input:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 4px rgba(var(--acento-rgb), .15); }

button { font: inherit; color: var(--texto); background: none; border: 0; }
button.grande { width: 100%; padding: 13px; font-size: 15px; font-weight: 700; color: #fff; border-radius: 16px;
  background: linear-gradient(135deg, var(--acento2), var(--acento));
  box-shadow: 0 6px 16px rgba(var(--acento-rgb), .30); }
button.grande:active { transform: scale(.985); filter: brightness(.95); }
button.secundario { background: var(--panel); color: var(--texto); border: 1.5px solid var(--borde); box-shadow: none; }
.error { color: var(--error); text-align: center; min-height: 1.2em; margin: 0; font-size: 14px; }

/* App */
#app { display: flex; flex-direction: column; height: 100%; }
header { display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 20px 22px;
  background: radial-gradient(circle at 92% 0%, rgba(161, 75, 255, .16), transparent 50%),
              linear-gradient(160deg, var(--marino2), var(--marino));
  border-radius: 0 0 28px 28px; position: relative; z-index: 2; }
header .marca { font-size: 22px; color: #fff; }
header small { color: #fff; font-size: 13px; font-weight: 600; padding: 7px 13px;
  background: rgba(255, 255, 255, .14); border-radius: 999px; }
header small:empty { display: none; }
main { flex: 1; overflow-y: auto; padding: 18px 16px 24px; }
h2 { margin: 0 0 16px; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.vacio { color: var(--suave); text-align: center; }

/* Menú inferior */
nav .ic { width: 18px; height: 18px; }
nav { display: flex; background: var(--panel); border-radius: 26px 26px 0 0;
  box-shadow: 0 -4px 20px rgba(27, 36, 52, .08);
  padding: 5px 8px calc(env(safe-area-inset-bottom) + 5px); }
nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 2px 0; color: var(--suave); font-size: 11px; font-weight: 600; }
nav .ico { width: 46px; height: 26px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
  transition: background .15s; }
nav button.activa { color: var(--acento); }
nav button.activa .ico { background: rgba(var(--acento-rgb), .13); }

/* Listas (stock, productos, movimientos, ventas) */
.fila { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 15px; font-size: 14px;
  background: var(--panel); border-radius: var(--radio); box-shadow: var(--sombra); margin-bottom: 10px; }
.fila b { font-weight: 700; }
.fila small { display: block; color: var(--suave); margin-top: 2px; }
.fila .num { font-size: 21px; font-weight: 800; }
.fila.bajo { background: linear-gradient(90deg, rgba(245, 166, 35, .16), var(--panel) 60%); }
.fila.bajo .num { color: var(--aviso); }

/* Formularios */
label { display: block; color: var(--suave); font-size: 13px; font-weight: 600; margin-bottom: 14px; }
label input { margin-top: 6px; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; color: var(--texto); font-size: 15px; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--acento); }
.volver { color: var(--acento); font-weight: 700; padding: 0 0 10px; font-size: 15px; }
button.peligro { background: transparent; color: var(--error); border: 1.5px solid var(--error); box-shadow: none; margin-top: 12px; }
#vista-productos > .grande { margin-bottom: 16px; }

/* Selectores y avisos */
select { width: 100%; padding: 13px 15px; font-size: 15px; color: var(--texto); background: var(--campo);
  border: 1.5px solid var(--borde); border-radius: 14px; margin-top: 6px; }
select:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 4px rgba(var(--acento-rgb), .15); }
.aviso-saldo { color: var(--aviso); font-size: 13px; min-height: 1.2em; margin: 8px 0 14px; }
.sub { margin: 22px 0 10px; color: var(--suave); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
#btn-anadir-compra { margin-bottom: 16px; }

/* Caja */
.saldos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.saldo { background: var(--panel); border-radius: var(--radio); box-shadow: var(--sombra); padding: 12px 14px; position: relative; }
.saldo .chip { margin-bottom: 8px; }
.saldo small { display: block; color: var(--suave); font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.saldo strong { font-size: 21px; font-weight: 800; }
.saldo.neg strong { color: var(--aviso); }
.saldo.total { margin-bottom: 12px; padding: 18px 18px; overflow: hidden; color: #fff; box-shadow: 0 10px 24px rgba(var(--acento-rgb), .25);
  background: linear-gradient(135deg, #a14bff 0%, #7a1fe0 50%, #c026d3 100%); }
.saldo.total small { color: rgba(255, 255, 255, .85); font-size: 13px; }
.saldo.total strong { font-size: 33px; letter-spacing: -.02em; }
.saldo.total.neg strong { color: #fff3c4; }
.saldo.total .deco { position: absolute; right: 14px; top: 50%; width: 64px; height: 64px; margin-top: -32px;
  stroke-width: 1.3; opacity: .22; }
.tres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tres button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 11px 4px 10px;
  background: var(--panel); border-radius: var(--radio); box-shadow: var(--sombra); font-weight: 700; font-size: 13px; }
.tres button:active { transform: scale(.97); }
.mov .imp { font-weight: 800; white-space: nowrap; margin-left: 12px; }
.mov .imp.mas { color: var(--ok); }
.mov small { display: block; }
.caption { color: var(--suave); font-size: 13px; margin: 0 0 8px; }

/* Filtros (chips) */
.chips { display: flex; gap: 4px; margin-bottom: 12px; }
.chips button { flex: 1 1 auto; min-width: 0; padding: 8px 6px; background: var(--panel); border: 1.5px solid var(--borde); border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--suave); text-align: center; }
.chips button.activa { background: linear-gradient(135deg, var(--acento2), var(--acento)); border-color: transparent; color: #fff;
  box-shadow: 0 4px 12px rgba(var(--acento-rgb), .28); }
.dos.linea-campos { margin-top: 0; }

/* Vender: cuadrícula */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { position: relative; text-align: left; padding: 12px 13px; min-height: 92px; font-size: 14px; color: var(--texto);
  background: var(--panel); border-radius: var(--radio); box-shadow: var(--sombra);
  display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.tile:active { transform: scale(.97); }
.tile b { display: block; font-size: 15px; }
.tile small { display: block; color: var(--suave); }
.tile .pv { font-weight: 800; font-size: 18px; color: var(--acento); }
.tile .st { font-size: 12px; color: var(--suave); font-weight: 600; }
.tile.sin { background: linear-gradient(160deg, rgba(245, 166, 35, .18), var(--panel) 70%); }
.tile.sin .st { color: var(--aviso); }
.tile .cant { position: absolute; top: -8px; right: -6px; min-width: 28px; height: 28px; padding: 0 7px;
  border-radius: 14px; background: linear-gradient(135deg, var(--acento2), var(--acento)); color: #fff; font-weight: 800;
  box-shadow: 0 4px 10px rgba(var(--acento-rgb), .4); display: flex; align-items: center; justify-content: center; }
.barra-ticket { position: sticky; bottom: 0; margin-top: 16px; display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 16px; background: var(--marino); border-radius: 22px; box-shadow: 0 10px 26px rgba(20, 28, 44, .35); }
.barra-ticket span { flex: 1; font-weight: 700; color: #fff; font-size: 14px; }
.barra-ticket .grande { width: auto; padding: 10px 18px; box-shadow: none; }

/* Vender: ticket */
.linea { background: var(--panel); border-radius: var(--radio); box-shadow: var(--sombra); padding: 12px; font-size: 14px; margin-bottom: 10px; }
.linea .nom { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; margin-bottom: 12px; }
.linea .aviso { color: var(--aviso); font-size: 13px; margin: -4px 0 10px; }
.linea .ctl { display: flex; align-items: center; gap: 10px; }
.linea .ctl button { width: 42px; height: 42px; font-size: 24px; font-weight: 600; color: var(--texto);
  background: var(--fondo); border-radius: 14px; }
.linea .ctl .n { min-width: 28px; text-align: center; font-size: 19px; font-weight: 800; }
.linea .ctl input { margin-left: auto; width: 110px; text-align: right; }
.total-fila { display: flex; justify-content: space-between; align-items: baseline; font-size: 16px; font-weight: 600; margin: 16px 0; }
.total-fila strong { font-size: 30px; font-weight: 800; color: var(--acento); letter-spacing: -.02em; }
.segmento { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 16px;
  background: var(--borde); border-radius: 16px; }
.segmento button { padding: 10px; font-size: 14px; font-weight: 700; color: var(--suave); border-radius: 12px; }
.segmento button.activa { background: var(--panel); color: var(--acento); box-shadow: var(--sombra); }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 76px); transform: translateX(-50%);
  z-index: 20; background: var(--marino); color: #fff; font-weight: 600; font-size: 14px; padding: 10px 18px; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3); white-space: nowrap; max-width: calc(100% - 32px); }
#btn-vaciar { margin-top: 12px; }

/* Menú "Más" */
.lista-menu { background: var(--panel); border-radius: var(--radio); box-shadow: var(--sombra); margin-bottom: 16px; overflow: hidden; }
.item-menu { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; text-align: left; font-weight: 600; font-size: 14.5px; }
.item-menu + .item-menu { border-top: 1px solid var(--borde); }
.item-menu .txt { flex: 1; }
.item-menu .dcha { color: var(--suave); width: 18px; height: 18px; }
.item-menu.salir .txt { color: var(--error); }
.item-menu:active { background: var(--fondo); }

/* Ventana de motivo */
#modal { position: fixed; inset: 0; z-index: 10; background: rgba(15, 22, 34, .55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 24px; }
#modal-form { width: 100%; max-width: 360px; background: var(--panel); border-radius: 24px;
  padding: 22px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
#modal-form h3 { margin: 0; font-size: 17px; }
button.peligro-lleno { background: var(--error); box-shadow: none; }

/* Lista de productos */
.fila.click { cursor: pointer; }
.fila.off { opacity: .55; }
.fila .precio { font-size: 16px; font-weight: 800; text-align: right; }
.fila .precio small { color: var(--aviso); font-weight: 600; }

/* Logo */
.logo-login { width: 170px; height: 170px; align-self: center; margin: -62px 0 6px; border-radius: 50%;
  box-shadow: 0 10px 30px rgba(122, 31, 224, .55); }
#login { padding-top: 70px; }
.marca-cab { display: flex; align-items: center; gap: 10px; }
.marca-cab img { width: 38px; height: 38px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, .25); }
.marca-cab .marca span { color: #c58bff; }
.perfil { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; margin: 4px 0 22px; }
.perfil img { width: 92px; height: 92px; border-radius: 50%; box-shadow: 0 10px 28px rgba(122, 31, 224, .45); margin-bottom: 8px; }
.perfil b { font-size: 19px; font-weight: 800; letter-spacing: .02em; }
.perfil small { color: var(--suave); font-size: 12px; }
.perfil .pastilla { margin-top: 8px; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  color: var(--acento); background: rgba(var(--acento-rgb), .12); }
.perfil .pastilla:empty { display: none; }

/* Stock: botón flotante sobre el menú inferior */
#vista-stock { display: flex; flex-direction: column; min-height: 100%; }
#vista-stock.oculto { display: none; }
#lista-stock { flex: 1; }
.grande.flotante { position: sticky; bottom: 12px; margin-top: 12px; z-index: 3;
  box-shadow: 0 8px 22px rgba(var(--acento-rgb), .45); }
