/* ABASTO · Estilos base. Mobile-first, WCAG 2.1 AA, sin dependencias. */
:root {
  --azul: #1E4FA3; --azul-osc: #163C7D; --azul-claro: #E8EFFB;
  --naranja: #F28C1B; --naranja-osc: #A85500; --naranja-claro: #FFF1E0;
  --texto: #1A1F2B; --texto-2: #4A5468; --borde: #CBD3E1; --fondo: #F5F7FB; --blanco: #fff;
  --ok: #17703A; --ok-bg: #E3F5EA; --warn: #8A5300; --warn-bg: #FFF3D6; --danger: #B3261E; --danger-bg: #FDE7E5; --info: #1E4FA3; --info-bg: #E8EFFB;
  --radio: 12px; --sombra: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
  --fs: 1rem; --tap: 48px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
html.texto-grande { font-size: 118%; }
html.texto-xl { font-size: 135%; }
html.alto-contraste {
  --azul: #0B2E6B; --azul-osc: #00122E; --texto: #000; --texto-2: #1a1a1a; --borde: #000; --fondo: #fff;
  --naranja: #FFB000; --naranja-osc: #6B3500;
}
html.alto-contraste .card, html.alto-contraste .btn { border-width: 2px; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--fs); line-height: 1.5; color: var(--texto); background: var(--fondo); }
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
svg[aria-hidden="true"] { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.2em; }
.card.row > svg { width: 32px; height: 32px; color: var(--azul); }
a { color: var(--azul); }
a:hover { color: var(--azul-osc); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.08rem; }
p { margin: 0 0 .8rem; }
:focus-visible { outline: 3px solid var(--naranja); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: .5rem; top: -100px; background: var(--azul); color: #fff; padding: .75rem 1rem; z-index: 1000; border-radius: 8px; font-weight: 700; }
.skip-link:focus { top: .5rem; color: #fff; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Estructura ---------- */
.topbar { background: var(--blanco); border-bottom: 1px solid var(--borde); position: sticky; top: 0; z-index: 50; }
.topbar-in { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; min-height: 60px; }
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--azul); font-weight: 800; font-size: 1.25rem; letter-spacing: .02em; }
.brand img { width: 36px; height: 36px; }
.brand small { display: block; font-size: .65rem; color: var(--naranja-osc); font-weight: 700; letter-spacing: .04em; }
.topbar .spacer { flex: 1; }
.container { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.container-sm { max-width: 520px; margin: 0 auto; padding: 1.25rem 1rem; }
main { min-height: 60vh; }
.with-bottomnav main { padding-bottom: 96px; }
.footer { text-align: center; color: var(--texto-2); font-size: .875rem; padding: 2rem 1rem; }

/* Navegación de paneles (mayorista/admin) */
.panel-nav { background: var(--azul); }
.panel-nav ul { list-style: none; margin: 0 auto; padding: 0 .5rem; display: flex; gap: .25rem; overflow-x: auto; max-width: 1200px; scrollbar-width: thin; }
.panel-nav a { display: flex; align-items: center; gap: .35rem; color: #fff; text-decoration: none; padding: .8rem .9rem; white-space: nowrap; font-weight: 600; font-size: .95rem; border-bottom: 3px solid transparent; min-height: var(--tap); }
.panel-nav a[aria-current="page"] { border-bottom-color: var(--naranja); background: rgba(255,255,255,.08); }
.panel-nav a:hover { background: rgba(255,255,255,.12); color: #fff; }

/* Barra inferior (comercio, uso con una mano) */
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--blanco); border-top: 1px solid var(--borde); z-index: 60; padding-bottom: env(safe-area-inset-bottom); }
.bottomnav ul { list-style: none; margin: 0 auto; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); max-width: 640px; }
.bottomnav a, .bottomnav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px; color: var(--texto-2); text-decoration: none; font-size: .72rem; font-weight: 600; background: none; border: 0; width: 100%; cursor: pointer; font-family: inherit; position: relative; }
.bottomnav a[aria-current="page"] { color: var(--azul); }
.bottomnav svg { width: 24px; height: 24px; }
.bottomnav .fab { background: var(--naranja); color: #1A1F2B; border-radius: 50%; width: 64px; height: 64px; min-height: 64px; margin: -22px auto 0; box-shadow: 0 4px 12px rgba(242,140,27,.45); border: 4px solid var(--blanco); }
.bottomnav .fab span { position: absolute; bottom: -18px; color: var(--texto); }
.cart-badge { position: absolute; top: 6px; right: calc(50% - 22px); background: var(--danger); color: #fff; border-radius: 999px; font-size: .7rem; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 5px; }

/* ---------- Componentes ---------- */
.card { background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem; box-shadow: var(--sombra); margin-bottom: 1rem; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-title h2, .card-title h3 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: .5rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.muted { color: var(--texto-2); }
.small { font-size: .875rem; }
.right { text-align: right; }
.mt-0 { margin-top: 0 } .mb-0 { margin-bottom: 0 } .mt-1 { margin-top: 1rem } .mb-1 { margin-bottom: 1rem }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: var(--tap); padding: .6rem 1.1rem; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; line-height: 1.2; text-align: center; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--azul); color: #fff; } .btn-primary:hover { background: var(--azul-osc); color: #fff; }
.btn-accent { background: var(--naranja); color: #1A1F2B; } .btn-accent:hover { background: #E07A0A; color: #000; }
.btn-ghost { background: var(--blanco); color: var(--azul); border-color: var(--borde); } .btn-ghost:hover { background: var(--azul-claro); }
.btn-danger { background: var(--blanco); color: var(--danger); border-color: var(--danger); } .btn-danger:hover { background: var(--danger-bg); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-wa { background: #157A3C; color: #fff; } .btn-wa:hover { background: #0F5E2D; color: #fff; }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 1.08rem; padding: .8rem 1.25rem; }
.btn-sm { min-height: 38px; padding: .35rem .75rem; font-size: .875rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--azul); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: #9BD3B0; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: #F0C870; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: #F2A8A2; }
.badge-info { background: var(--info-bg); color: var(--info); border-color: #A9C1EA; }
.badge-neutral { background: #EEF1F6; color: var(--texto-2); border-color: var(--borde); }

.alert { padding: .85rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; display: flex; gap: .6rem; align-items: flex-start; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #9BD3B0; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #F2A8A2; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #F0C870; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #A9C1EA; }
.alert strong { font-weight: 800; }

/* Formularios */
label, .label { display: block; font-weight: 700; margin-bottom: .3rem; font-size: .95rem; }
.hint { display: block; font-weight: 400; color: var(--texto-2); font-size: .85rem; margin-top: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=search], input[type=url], input[type=date], input[type=color], select, textarea {
  width: 100%; min-height: var(--tap); padding: .6rem .75rem; border: 1px solid #8C97AB; border-radius: 10px; font: inherit; background: var(--blanco); color: var(--texto);
}
input[type=color] { padding: .25rem; width: 80px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--azul); box-shadow: 0 0 0 3px rgba(30,79,163,.2); outline: none; }
.field { margin-bottom: 1rem; }
.field-error input, .field-error select { border-color: var(--danger); }
.error-text { color: var(--danger); font-size: .875rem; margin-top: .25rem; }
.check { display: flex; align-items: flex-start; gap: .6rem; font-weight: 600; min-height: 32px; cursor: pointer; margin-bottom: .6rem; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--azul); }
fieldset { border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem; margin: 0 0 1rem; }
legend { font-weight: 800; padding: 0 .4rem; }
.input-group { display: flex; gap: .5rem; } .input-group > input { flex: 1; }

/* Tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--borde); border-radius: var(--radio); background: var(--blanco); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
caption { text-align: left; padding: .75rem; font-weight: 700; }
th, td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid #E3E8F0; vertical-align: middle; }
th { background: #F0F3F9; font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
@media (max-width: 699px) {
  table.responsive thead { position: absolute; left: -9999px; }
  table.responsive tr { display: block; border-bottom: 1px solid var(--borde); padding: .5rem 0; }
  table.responsive td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .35rem .75rem; text-align: right; }
  table.responsive td::before { content: attr(data-label); font-weight: 700; text-align: left; color: var(--texto-2); }
}

/* KPIs */
.kpi { background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem; }
.kpi .kpi-label { color: var(--texto-2); font-size: .85rem; font-weight: 600; }
.kpi .kpi-value { font-size: 1.6rem; font-weight: 800; color: var(--texto); margin-top: .2rem; }
.kpi .kpi-sub { font-size: .8rem; color: var(--texto-2); }

/* Selector de proveedor */
.prov-select { display: flex; gap: .5rem; align-items: center; background: var(--azul); color: #fff; padding: .75rem 1rem; border-radius: var(--radio); margin-bottom: 1rem; }
.prov-select label { color: #fff; margin: 0; font-size: .85rem; }
.prov-select select { background: #fff; flex: 1; }

/* Acciones rápidas comercio */
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1rem; }
.quick .btn { min-height: 84px; flex-direction: column; font-size: 1rem; border-radius: var(--radio); }
.quick .btn svg { width: 30px; height: 30px; }

/* Producto */
.products { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .products { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .products { grid-template-columns: repeat(3, 1fr); } }
.product { background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: .85rem; display: grid; grid-template-columns: 76px 1fr; gap: .75rem; }
.product .thumb { width: 76px; height: 76px; border-radius: 10px; background: var(--azul-claro); object-fit: cover; display: grid; place-items: center; color: var(--azul); font-weight: 800; font-size: 1.4rem; }
.product h3 { font-size: 1rem; margin: 0 0 .15rem; }
.product .meta { font-size: .8rem; color: var(--texto-2); }
.product .price { font-size: 1.15rem; font-weight: 800; }
.product .price small { font-weight: 600; color: var(--texto-2); font-size: .78rem; }
.product .vol { font-size: .8rem; color: var(--ok); font-weight: 700; }
.product .buy { grid-column: 1 / -1; }
.semaforo { font-size: .78rem; font-weight: 700; display: inline-flex; gap: .25rem; align-items: center; }
.semaforo-ok { color: var(--ok); } .semaforo-ultimas { color: var(--warn); } .semaforo-sin { color: var(--danger); }
.semaforo i { font-style: normal; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: #fff; font-size: .7rem; }
.semaforo-ok i { background: var(--ok); } .semaforo-ultimas i { background: #C77700; } .semaforo-sin i { background: var(--danger); }
.qty { display: flex; gap: .4rem; align-items: stretch; flex-wrap: wrap; }
.qty .stepper { display: flex; border: 1px solid #8C97AB; border-radius: 10px; overflow: hidden; }
.qty .stepper button { width: var(--tap); min-height: var(--tap); border: 0; background: var(--azul-claro); color: var(--azul); font-size: 1.4rem; font-weight: 800; cursor: pointer; }
.qty .stepper input { width: 70px; border: 0; border-radius: 0; text-align: center; font-weight: 700; min-height: var(--tap); }
.qty select { width: auto; flex: 1; min-width: 120px; }
.qty .btn { flex: 1; }
.matrix { overflow-x: auto; } .matrix table { font-size: .85rem; } .matrix input { width: 64px; min-height: 40px; text-align: center; }

/* Ofertas carrusel */
.carousel { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 70%); gap: .75rem; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .5rem; }
@media (min-width: 700px) { .carousel { grid-auto-columns: 260px; } }
.carousel > * { scroll-snap-align: start; }
.offer { background: var(--naranja-claro); border: 1px solid #F5C58A; border-radius: var(--radio); padding: .85rem; display: flex; flex-direction: column; gap: .4rem; }
.offer .left { font-weight: 800; color: var(--naranja-osc); font-size: .85rem; }

/* Progreso mínimo */
.progress { background: #E3E8F0; border-radius: 999px; height: 14px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--naranja); border-radius: 999px; }
.progress.done > span { background: var(--ok); }

/* Banner retail media */
.banner { display: block; border-radius: var(--radio); overflow: hidden; margin-bottom: 1rem; border: 1px solid var(--borde); background: var(--azul-claro); text-decoration: none; color: var(--azul); }
.banner img { display: block; width: 100%; max-height: 180px; object-fit: cover; }
.banner .banner-txt { padding: .75rem 1rem; font-weight: 700; }
.banner .ad { font-size: .7rem; font-weight: 700; color: var(--texto-2); padding: 0 1rem .5rem; display: block; }

/* Escáner */
.scanner-dialog { border: 0; padding: 0; width: 100%; max-width: 560px; border-radius: 16px; background: #000; color: #fff; }
.scanner-dialog::backdrop { background: rgba(0,0,0,.75); }
.scanner-video-wrap { position: relative; aspect-ratio: 3/4; max-height: 60vh; background: #000; overflow: hidden; }
.scanner-video-wrap video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame { position: absolute; inset: 22% 10%; border: 3px solid var(--naranja); border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.scanner-bar { padding: .75rem; display: flex; gap: .5rem; flex-wrap: wrap; background: #111; }
.scanner-bar .btn-ghost { background: #222; color: #fff; border-color: #444; }
.scanner-result { background: #fff; color: var(--texto); padding: 1rem; }
.scanner-status { padding: .5rem .75rem; font-size: .9rem; min-height: 2.2em; }

/* Accesibilidad toolbar */
.a11y-bar { display: flex; gap: .25rem; }
.a11y-bar button { min-width: 40px; min-height: 40px; border: 1px solid var(--borde); background: var(--blanco); border-radius: 8px; font-weight: 800; cursor: pointer; color: var(--texto); font-family: inherit; }
.a11y-bar button[aria-pressed="true"] { background: var(--azul); color: #fff; border-color: var(--azul); }

/* Landing */
.hero { background: linear-gradient(160deg, var(--azul) 0%, var(--azul-osc) 100%); color: #fff; padding: 3rem 1rem; text-align: center; }
.hero h1 { font-size: 2.2rem; color: #fff; margin-bottom: .25rem; letter-spacing: .02em; }
.hero .tag { color: var(--naranja); font-weight: 800; font-size: 1.15rem; margin-bottom: 1rem; letter-spacing: .03em; }
.hero p { max-width: 640px; margin: 0 auto 1.5rem; font-size: 1.1rem; color: #E6ECF8; }
.hero .logo-hero { width: 110px; margin-bottom: .5rem; background: #fff; border-radius: 24px; padding: 10px; }
.hero .row { justify-content: center; }
.section { padding: 2.5rem 1rem; } .section h2 { text-align: center; font-size: 1.6rem; margin-bottom: 1.5rem; }
.feature { text-align: left; } .feature .ico { width: 48px; height: 48px; border-radius: 12px; background: var(--naranja-claro); color: var(--naranja-osc); display: grid; place-items: center; margin-bottom: .5rem; }
.feature .ico svg { width: 26px; height: 26px; }
.price-card { text-align: center; border-width: 2px; }
.price-card.destacado { border-color: var(--naranja); }
.price-card .amount { font-size: 2.4rem; font-weight: 900; color: var(--azul); }
.price-card ul { text-align: left; padding-left: 1.2rem; }
.price-card li { margin-bottom: .35rem; }

/* Comprobantes / impresión */
.doc { background: #fff; max-width: 800px; margin: 1rem auto; padding: 1.5rem; border: 1px solid var(--borde); }
.doc.t80 { max-width: 80mm; padding: 4mm; font-size: 12px; }
.doc.t80 table { font-size: 11px; } .doc.t80 th, .doc.t80 td { padding: 2px 3px; }
.no-print { }
@media print {
  body { background: #fff; }
  .no-print, .topbar, .panel-nav, .bottomnav, .footer, .skip-link { display: none !important; }
  .doc { border: 0; margin: 0; max-width: none; }
  .doc.t80 { width: 80mm; }
  a { color: #000; text-decoration: none; }
  .page-break { page-break-after: always; }
}
.etiquetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(62mm, 1fr)); gap: 3mm; }
.etiqueta { border: 1px dashed #999; padding: 3mm; text-align: center; break-inside: avoid; }
.etiqueta .pv { font-size: 22px; font-weight: 900; }
.etiqueta svg { max-width: 100%; height: 50px; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--texto-2); }
.empty svg { width: 56px; height: 56px; color: var(--borde); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; background: var(--texto); color: #fff; padding: .75rem 1.1rem; border-radius: 10px; z-index: 100; font-weight: 600; max-width: 92vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.offline-banner { background: var(--warn-bg); color: var(--warn); text-align: center; padding: .5rem; font-weight: 700; font-size: .9rem; border-bottom: 1px solid #F0C870; }
.code-box { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 2rem; font-weight: 900; letter-spacing: .25em; color: var(--azul); background: var(--azul-claro); padding: .5rem 1rem; border-radius: 10px; display: inline-block; }
.pill-nav { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; margin-bottom: 1rem; }
.pill-nav a { padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--borde); text-decoration: none; background: var(--blanco); white-space: nowrap; font-weight: 600; font-size: .9rem; min-height: 40px; display: inline-flex; align-items: center; }
.pill-nav a[aria-current="true"] { background: var(--azul); color: #fff; border-color: var(--azul); }
details.box { border: 1px solid var(--borde); border-radius: var(--radio); background: var(--blanco); margin-bottom: 1rem; }
details.box > summary { padding: .85rem 1rem; cursor: pointer; font-weight: 700; min-height: var(--tap); }
details.box > div { padding: 0 1rem 1rem; }
.timeline { list-style: none; padding: 0; margin: 0; display: flex; gap: .25rem; flex-wrap: wrap; }
.timeline li { flex: 1; min-width: 90px; text-align: center; font-size: .75rem; padding: .4rem .2rem; border-radius: 8px; background: #EEF1F6; color: var(--texto-2); font-weight: 700; }
.timeline li.done { background: var(--ok-bg); color: var(--ok); } .timeline li.current { background: var(--azul); color: #fff; }
