/* =============================================================
   StockControl — estilos
   1. Tokens · 2. Base · 3. Utilidades · 4. Estructura · 5. Componentes
   6. Secciones · 7. Publicidad · 8. Responsive · 9. Movimiento reducido
   ============================================================= */

/* 1. Tokens ---------------------------------------------------- */
:root {
  --navy: #0f2a4a;
  --navy-2: #173a63;
  --navy-3: #22507f;
  --accent: #16a34a;
  --accent-2: #15803d;
  --accent-soft: #dcfce7;
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-2: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 42, 74, .06), 0 4px 16px rgba(15, 42, 74, .05);
  --shadow-lg: 0 20px 50px rgba(15, 42, 74, .22);
  --sidebar: 252px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* 2. Base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  min-height: 100vh;
}
body.no-scroll { overflow: hidden; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; text-wrap: balance; }
p { text-wrap: pretty; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent); color: #fff; }

/* 3. Utilidades ------------------------------------------------ */
.skip-link { position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem; background: #fff; color: var(--navy); z-index: 9999; border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.pad { padding: 1rem; }
.pos { color: var(--accent-2); }
.neg { color: var(--danger); }
.warn { color: var(--warn); }
.ico { width: 18px; height: 18px; flex: none; }

/* 4. Estructura ------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  height: 58px; padding: 0 .75rem;
  background: var(--navy); color: #fff;
  box-shadow: 0 2px 10px rgba(15, 42, 74, .2);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em; color: #fff; }
.brand b { color: #4ade80; font-weight: 800; }
.logo { width: 32px; height: 32px; display: block; }
.logo svg { width: 32px; height: 32px; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 60;
  width: min(84vw, var(--sidebar));
  display: flex; flex-direction: column; gap: .25rem;
  padding: 1.25rem .9rem 1rem;
  background: linear-gradient(180deg, var(--navy) 0%, #0b2140 100%);
  color: #cbd5e1;
  transform: translateX(-105%);
  transition: transform .32s var(--ease-out);
  overflow-y: auto;
}
.sidebar .brand { padding: 0 .5rem; }
.business { margin: .35rem .5rem 1.1rem; font-size: .8rem; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem .8rem; border-radius: 10px;
  font-weight: 500; color: #cbd5e1;
  transition: background .2s, color .2s;
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.is-active { background: rgba(74, 222, 128, .14); color: #fff; box-shadow: inset 3px 0 0 #4ade80; }
.nav a.is-active .ico { color: #4ade80; }
.nav-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: #f59e0b; color: #1f2937; font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center; }
.nav-badge[hidden] { display: none; }
.sidebar-foot { margin-top: auto; padding: 1rem .5rem 0; border-top: 1px solid rgba(255, 255, 255, .08); font-size: .78rem; color: #94a3b8; }
.sidebar-foot p { display: flex; gap: .5rem; align-items: flex-start; }
.sidebar-foot .ico { width: 15px; height: 15px; margin-top: 2px; }
.legal { margin-top: .5rem; }
.legal a { text-decoration: underline; text-underline-offset: 2px; }
.nav-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(15, 23, 42, .45); opacity: 0; pointer-events: none; transition: opacity .25s; }
body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

.main { padding: 1rem 1rem 3rem; max-width: 1360px; margin: 0 auto; outline: none; }
body.has-corner-ad .main { padding-bottom: 9rem; }
.view { animation: viewIn .35s var(--ease-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; margin: .25rem 0 1rem; }
.page-head h1 { font-size: 1.45rem; font-weight: 800; color: var(--navy); }
.page-head p { margin-top: .15rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* 5. Componentes ---------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 42px; padding: .55rem 1rem; border-radius: 10px;
  font-weight: 600; font-size: .92rem; white-space: nowrap;
  border: 1px solid transparent;
  transition: background .2s, border-color .2s, color .2s, transform .15s, box-shadow .2s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(22, 163, 74, .3); }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }
.btn-ghost { background: var(--surface); border-color: var(--border-2); color: var(--navy); }
.btn-ghost:hover:not(:disabled) { border-color: var(--navy-3); background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-danger-soft { background: var(--danger-soft); color: #991b1b; }
.btn-danger-soft:hover { background: #fecaca; }
.btn-excel { background: #107c41; color: #fff; }
.btn-excel:hover:not(:disabled) { background: #0b5e31; }
.btn-pdf { background: var(--navy); color: #fff; }
.btn-pdf:hover:not(:disabled) { background: var(--navy-2); }
.btn-sm { min-height: 34px; padding: .35rem .7rem; font-size: .84rem; }
.btn-lg { min-height: 52px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.file-btn { cursor: pointer; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px; color: inherit;
  transition: background .2s, color .2s;
}
.icon-btn:hover { background: rgba(15, 42, 74, .07); }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn:disabled { opacity: .4; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-bottom: .85rem; }
.card-head h2 { display: flex; align-items: center; gap: .5rem; font-size: 1.02rem; font-weight: 700; color: var(--navy); }
.card-head h2 .ico { color: var(--accent); }
.link { color: var(--accent-2); font-weight: 600; font-size: .86rem; }
.link:hover { text-decoration: underline; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi {
  position: relative; display: flex; flex-direction: column; gap: .15rem; min-width: 0;
  padding: .95rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: transform .25s var(--ease-out), box-shadow .25s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 42, 74, .1); }
.kpi-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; margin-bottom: .35rem; }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 1.35rem; font-weight: 800; color: var(--navy); letter-spacing: -.02em; overflow-wrap: anywhere; }
.kpi-sub { font-size: .76rem; color: var(--muted); }
.kpi-navy .kpi-ico { background: #e0e9f5; color: var(--navy-2); }
.kpi-green .kpi-ico { background: var(--accent-soft); color: var(--accent-2); }
.kpi-amber .kpi-ico { background: var(--warn-soft); color: var(--warn); }
.kpi-red .kpi-ico { background: var(--danger-soft); color: var(--danger); }

.grid-2 { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 1rem; }

/* Gráficas */
.chart { width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.chart .bar rect:not(.hit) { fill: var(--navy-3); transition: fill .2s; }
.chart .bar:hover rect:not(.hit) { fill: var(--accent); }
.chart .hit { fill: transparent; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt circle { fill: #fff; stroke: var(--accent); stroke-width: 2; transition: r .2s; }
.chart .pt:hover circle { r: 6; }
.hbars { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .8rem; }
.hbar-top { display: flex; align-items: baseline; gap: .5rem; font-size: .88rem; margin-bottom: .3rem; }
.hbar-rank { width: 22px; height: 22px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-2); font-weight: 700; font-size: .75rem; display: grid; place-items: center; flex: none; }
.hbar-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.hbar-val { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.hbar-track { height: 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.hbar-track span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--navy-3), var(--accent)); transform-origin: left; animation: grow .7s var(--ease-out); }
@keyframes grow { from { transform: scaleX(0); } }

/* Tablas */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: .65rem .7rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: #f8fbff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions .icon-btn { width: 34px; height: 34px; color: var(--muted); }
.table .actions .icon-btn:hover { color: var(--navy); }
.table .actions .icon-btn.danger:hover { color: var(--danger); }
.row-agotado td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.row-bajo td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.prod-cell { display: flex; flex-direction: column; min-width: 0; max-width: 340px; }
.prod-cell strong { font-weight: 600; }
.prod-cell .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-summary { font-size: .85rem; color: var(--muted); margin: .25rem 0 .75rem; }
.table-summary strong { color: var(--text); }

.badge { display: inline-flex; align-items: center; padding: .2rem .6rem; border-radius: 99px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--accent-soft); color: #166534; }
.badge-warn { background: var(--warn-soft); color: #92400e; }
.badge-danger { background: var(--danger-soft); color: #991b1b; }
.mbadge { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 500; white-space: nowrap; }
.mbadge .ico { width: 15px; height: 15px; }
.mbadge-in .ico { color: var(--accent); }
.mbadge-out .ico { color: var(--danger); }

/* Barra de filtros */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .75rem; align-items: center; }
.toolbar.inline { margin: 0; }
.toolbar select, .date-f input, .field input, .field select, .field textarea, .search input {
  min-height: 42px; border: 1px solid var(--border-2); border-radius: 10px; background: var(--surface);
  padding: .5rem .75rem; transition: border-color .2s, box-shadow .2s; width: 100%;
}
.toolbar select { width: auto; flex: 1 1 160px; max-width: 100%; }
.toolbar select:focus, .date-f input:focus, .field input:focus, .field select:focus, .field textarea:focus, .search input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22, 163, 74, .18);
}
.search { position: relative; flex: 2 1 240px; display: block; }
.search .ico { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 2.4rem; }
.date-f { display: flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--muted); flex: 1 1 150px; }
.date-f input { flex: 1; min-width: 0; }
.chip { padding: .35rem .75rem; border-radius: 99px; border: 1px solid var(--border-2); background: var(--surface); font-size: .8rem; font-weight: 500; transition: all .2s; }
.chip:hover { border-color: var(--accent); color: var(--accent-2); }
.quick-ranges { display: flex; gap: .35rem; flex-wrap: wrap; }

/* Formularios */
.form { display: flex; flex-direction: column; gap: .9rem; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: .85rem 1rem; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label, .label-like { font-size: .84rem; font-weight: 600; color: var(--text-2); }
.req { color: var(--danger); }
.field textarea { resize: vertical; min-height: 70px; }
.hint { color: var(--muted); font-size: .76rem; }
.field-error { color: var(--danger); font-size: .78rem; font-weight: 500; min-height: 0; }
.field-error:empty { display: none; }
.field.has-error input, .field.has-error select { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }
.form-error { background: var(--danger-soft); color: #991b1b; padding: .65rem .85rem; border-radius: 10px; font-size: .88rem; font-weight: 500; }
.input-affix { display: flex; align-items: stretch; }
.input-affix span { display: grid; place-items: center; padding: 0 .7rem; border: 1px solid var(--border-2); border-right: 0; border-radius: 10px 0 0 10px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.input-affix input { border-radius: 0 10px 10px 0; }
.margin-out, .stock-preview { min-height: 42px; display: flex; align-items: center; padding: 0 .75rem; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.margin-out.pos, .stock-preview.pos { color: var(--accent-2); background: #f0fdf4; border-color: #bbf7d0; }
.margin-out.neg, .stock-preview.neg { color: var(--danger); background: #fef2f2; border-color: #fecaca; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.seg-opt { display: flex; align-items: center; justify-content: center; gap: .45rem; min-height: 46px; border-radius: 10px; border: 1.5px solid var(--border-2); font-weight: 600; cursor: pointer; transition: all .2s; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-in:has(input:checked) { border-color: var(--accent); background: #f0fdf4; color: var(--accent-2); }
.seg-out:has(input:checked) { border-color: var(--danger); background: #fef2f2; color: var(--danger); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Modal */
.modal-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .5); opacity: 0; transition: opacity .2s; }
.modal {
  position: relative; width: 100%; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(24px); opacity: 0; transition: transform .28s var(--ease-out), opacity .2s;
}
.modal-root.is-open .modal-backdrop { opacity: 1; }
.modal-root.is-open .modal { transform: none; opacity: 1; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.1rem .5rem; }
.modal-head h2 { font-size: 1.12rem; font-weight: 700; color: var(--navy); }
.modal-body { padding: .5rem 1.1rem 1rem; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.1rem calc(.85rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 18px 18px; flex-wrap: wrap; }
.confirm-body { display: flex; gap: .85rem; align-items: flex-start; }
.confirm-body p + p { margin-top: .5rem; }
.confirm-ico { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--info-soft); color: var(--info); }
.confirm-ico.danger { background: var(--danger-soft); color: var(--danger); }
.confirm-list { margin: .6rem 0; padding-left: 1.1rem; font-size: .9rem; max-height: 180px; overflow: auto; }
.dl-ok { display: flex; gap: .6rem; align-items: flex-start; margin-bottom: 1rem; }
.dl-ok .ico { color: var(--accent); margin-top: 2px; }

/* Avisos */
.toasts { position: fixed; z-index: 200; top: 66px; right: .75rem; left: .75rem; display: flex; flex-direction: column; gap: .5rem; pointer-events: none; align-items: flex-end; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: .6rem; max-width: 420px; width: 100%;
  padding: .75rem .6rem .75rem .9rem; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--accent); font-size: .9rem;
  transform: translateX(16px); opacity: 0; transition: transform .3s var(--ease-out), opacity .25s;
}
.toast.is-in { transform: none; opacity: 1; }
.toast > .ico { color: var(--accent); margin-top: 1px; }
.toast-error { border-left-color: var(--danger); }
.toast-error > .ico { color: var(--danger); }
.toast-info { border-left-color: var(--info); }
.toast-info > .ico { color: var(--info); }
.toast-msg { flex: 1; }
.toast-x { color: var(--muted); padding: 2px; border-radius: 6px; }
.toast-x .ico { width: 16px; height: 16px; }

/* Estados vacíos */
.empty { text-align: center; padding: 2rem 1rem; display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.empty-ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); margin-bottom: .4rem; }
.empty-ico .ico { width: 26px; height: 26px; }
.empty h3 { font-size: 1rem; color: var(--navy); }
.empty p { color: var(--muted); font-size: .9rem; max-width: 380px; }
.empty .btn { margin-top: .6rem; }

/* 6. Secciones ------------------------------------------------- */
.alert-list { list-style: none; padding: 0; }
.alert-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.alert-list li:last-child { border-bottom: 0; }
.alert-list li > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.alert-right { display: flex; align-items: center; gap: .5rem; }

/* Punto de venta */
.pos { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); margin-bottom: 1rem; }
.pos > .card { margin-bottom: 0; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; margin-top: .75rem; max-height: 440px; overflow-y: auto; padding: 2px; }
.pick {
  display: flex; flex-direction: column; justify-content: space-between; gap: .4rem; text-align: left;
  padding: .7rem; min-height: 78px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: .86rem; transition: border-color .2s, background .2s, transform .15s;
}
.pick:hover:not(:disabled) { border-color: var(--accent); background: #f0fdf4; transform: translateY(-1px); }
.pick:disabled { opacity: .5; cursor: not-allowed; }
.pick strong { font-weight: 600; line-height: 1.25; }
.pick-meta { display: flex; justify-content: space-between; gap: .4rem; font-size: .78rem; font-weight: 600; }
.cart-table td { padding: .55rem .5rem; }
.stepper { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--border-2); border-radius: 10px; padding: 2px; }
.stepper .icon-btn { width: 30px; height: 30px; border-radius: 8px; }
.stepper .ico { width: 15px; height: 15px; }
.stepper input { width: 44px; text-align: center; border: 0; background: transparent; font-weight: 600; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.price-in { width: 92px; text-align: right; border: 1px solid var(--border-2); border-radius: 8px; padding: .35rem .5rem; }
.totals { margin: 1rem 0; display: flex; flex-direction: column; gap: .35rem; font-size: .92rem; }
.totals div { display: flex; justify-content: space-between; gap: 1rem; }
.totals dt { color: var(--muted); }
.totals dd { font-weight: 600; font-variant-numeric: tabular-nums; }
.totals .profit dt { color: var(--text-2); }
.totals .grand { margin-top: .4rem; padding-top: .7rem; border-top: 2px dashed var(--border); font-size: 1.25rem; }
.totals .grand dt { color: var(--navy); font-weight: 700; }
.totals .grand dd { color: var(--navy); font-weight: 800; }
.totals.compact { margin-bottom: 0; }
.pos-cart .field { margin-bottom: .85rem; }

/* Reportes */
.rtabs { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .25rem; margin-bottom: .85rem; scrollbar-width: thin; }
.rtab { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .85rem; border-radius: 10px; font-weight: 600; font-size: .88rem; color: var(--muted); white-space: nowrap; border: 1px solid transparent; transition: all .2s; }
.rtab:hover { background: var(--surface-2); color: var(--navy); }
.rtab.is-active { background: var(--navy); color: #fff; }
.rep-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; padding-top: .85rem; border-top: 1px solid var(--border); }
.rep-head h2 { font-size: 1.1rem; color: var(--navy); }
.export-btns { display: flex; flex-wrap: wrap; gap: .5rem; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin-top: .85rem; }
.mini-stat { padding: .7rem .85rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; }
.mini-stat span { font-size: .76rem; color: var(--muted); }
.mini-stat strong { font-size: 1.08rem; color: var(--navy); font-variant-numeric: tabular-nums; }

/* Categorías */
.cat-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.cat-card { display: flex; align-items: center; gap: .75rem; padding: .85rem; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); transition: border-color .2s, transform .2s var(--ease-out); }
.cat-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.cat-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-2); flex: none; }
.cat-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cat-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-actions { display: flex; }
.cat-actions .icon-btn { width: 34px; height: 34px; color: var(--muted); }

.danger-zone { border-color: #fecaca; }
.danger-zone h2 .ico { color: var(--danger); }
.danger-zone .btn { margin-top: .75rem; }

/* 7. Publicidad (espacios reservados) ------------------------- */
.ad-slot { margin: 0 0 1rem; }
.ad-placeholder {
  position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; text-align: center;
  border: 1.5px dashed #b6c2d2; border-radius: 12px; padding: 1.35rem .75rem .6rem;
  background: repeating-linear-gradient(135deg, #f8fafc 0 12px, #f1f5f9 12px 24px);
  color: #64748b;
}
.ad-placeholder strong { font-size: .82rem; letter-spacing: .12em; color: #475569; }
.ad-placeholder small { font-size: .72rem; }
.ad-tag { position: absolute; top: 6px; left: 8px; font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; padding: 1px 6px; border-radius: 4px; background: #e2e8f0; color: #475569; font-weight: 600; }
.ad-banner { height: 90px; }
.ad-slot.is-live { height: auto; min-height: 90px; display: block; }
.ad-slot.is-live.ad-incontent { min-height: 250px; }
.ad-label { display: block; font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .2rem; }
.ad-incontent { min-height: 250px; max-width: 100%; display: flex; }
.ad-incontent .ad-placeholder { width: 100%; }
.ad-popup-slot { height: 250px; margin: 0; }
.ad-corner {
  position: fixed; z-index: 50; right: .75rem; bottom: .75rem; width: min(300px, calc(100vw - 1.5rem)); height: 110px;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px;
  transform: translateY(20px); opacity: 0; transition: transform .35s var(--ease-out), opacity .3s;
}
.ad-corner.is-in { transform: none; opacity: 1; }
.ad-corner .ad-placeholder { padding: .4rem 2rem .4rem .5rem; }
.ad-corner-x { position: absolute; top: 4px; right: 4px; z-index: 2; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); color: var(--muted); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.ad-corner-x:hover { color: var(--danger); }
.ad-corner-x .ico { width: 15px; height: 15px; }

/* 8. Responsive ------------------------------------------------ */
/* Tablas como tarjetas en teléfonos */
@media (max-width: 719.98px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { position: relative; border: 1px solid var(--border); border-radius: 12px; margin-bottom: .6rem; padding: .5rem .75rem; background: var(--surface); }
  .table-cards tbody tr:hover { background: var(--surface); }
  .table-cards td { border: 0; padding: .3rem 0; display: flex; justify-content: space-between; align-items: center; gap: 1rem; text-align: right; }
  .table-cards td.num { text-align: right; }
  .table-cards td[data-label]::before { content: attr(data-label); font-size: .75rem; font-weight: 600; color: var(--muted); text-align: left; flex: none; }
  .table-cards td:first-child { display: block; text-align: left; padding-right: 0; }
  .table-cards td:first-child::before { display: none; }
  .table-cards td.actions { justify-content: flex-end; border-top: 1px solid var(--border); margin-top: .35rem; padding-top: .45rem; }
  .table-cards td[colspan] { display: block; }
  .table-cards .row-agotado td:first-child, .table-cards .row-bajo td:first-child { box-shadow: none; }
  .table-cards .row-agotado { border-left: 4px solid var(--danger); }
  .table-cards .row-bajo { border-left: 4px solid #f59e0b; }
  .table-cards .prod-cell { max-width: 100%; }
  .table-cards .prod-cell .small { white-space: normal; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .ad-banner { height: 76px; }
  .ad-banner small, .ad-corner small { display: none; }
  .export-btns { width: 100%; }
  .export-btns .btn { flex: 1; }
  .ad-corner { height: 64px; width: min(220px, calc(100vw - 1.5rem)); right: .5rem; bottom: .5rem; }
  .ad-corner .ad-placeholder { padding: 1.1rem 2rem .3rem .5rem; }
  body.has-corner-ad .main { padding-bottom: 6rem; }
  .cart-table .prod-cell .small { display: none; }
  .pick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 270px; }
  .pick { min-height: 70px; padding: .55rem; font-size: .82rem; }
  .cart-table .price-in { width: 74px; }
  .cart-table th:nth-child(3), .cart-table td:nth-child(3) { display: none; }
  .cart-table td { padding: .5rem .25rem; }
  .cart-table .stepper .icon-btn { width: 26px; height: 28px; }
  .cart-table .stepper input { width: 32px; }
  .cart-table th { padding: .5rem .25rem; }
  .cart-table .icon-btn.danger { width: 30px; }
  .pos-cart { padding: .85rem .75rem; }
}
@media (min-width: 540px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: span 2; }
  .modal-root { align-items: center; padding: 1rem; }
  .modal { width: min(460px, 100%); border-radius: 18px; }
  .modal-lg { width: min(680px, 100%); }
  .modal-sm { width: min(420px, 100%); }
  .toasts { left: auto; }
}
@media (min-width: 720px) {
  .main { padding: 1.25rem 1.5rem 3rem; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card { padding: 1.25rem; }
  .page-head h1 { font-size: 1.65rem; }
}
@media (min-width: 960px) {
  .topbar { display: none; }
  .sidebar { transform: none; width: var(--sidebar); }
  .nav-backdrop { display: none; }
  .main { margin-left: var(--sidebar); max-width: none; padding: 1.75rem 2rem 3rem; }
  .view { max-width: 1360px; margin: 0 auto; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-wide { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  .pos { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: start; }
  .pos-cart { position: sticky; top: 1rem; }
  .toasts { top: auto; bottom: 1rem; right: auto; left: calc(var(--sidebar) + 1.5rem); align-items: flex-start; flex-direction: column-reverse; }
  .toast { transform: translateY(12px); }
}
@media (min-width: 1280px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* 9. Movimiento reducido (solo efectos intrusivos) ------------- */
@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
  .hbar-track span { animation: none; }
}
@media print {
  .sidebar, .topbar, .ad-slot, .ad-corner, .toasts, .page-actions { display: none !important; }
  .main { margin: 0; padding: 0; }
}

/* 10. Páginas de contenido (inicio, guía, contacto, legales) ------ */
.site { background: var(--surface); }
.site-wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.site-head { position: sticky; top: 0; z-index: 40; background: var(--navy); color: #fff; box-shadow: 0 2px 10px rgba(15, 42, 74, .2); }
.site-head-in { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 62px; flex-wrap: wrap; padding-top: .4rem; padding-bottom: .4rem; }
.site-nav { display: flex; align-items: center; gap: .25rem 1rem; flex-wrap: wrap; font-weight: 500; font-size: .92rem; }
.site-nav a:not(.btn) { color: #cbd5e1; padding: .3rem .1rem; }
.site-nav a:not(.btn):hover, .site-nav a[aria-current] { color: #fff; }
.hero { background: linear-gradient(160deg, var(--navy) 0%, #0b2140 60%, #123e33 130%); color: #e2e8f0; padding: 3rem 0 3.5rem; }
.hero-in { display: grid; gap: 2rem; align-items: center; }
.eyebrow { font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: .6rem; }
.hero .eyebrow { color: #4ade80; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 3rem); font-weight: 800; color: #fff; letter-spacing: -.03em; }
.lead { font-size: 1.1rem; margin-top: .9rem; max-width: 60ch; }
.hero .lead { color: #cbd5e1; }
.hero-cta { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.5rem; }
.hero .btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .35); }
.hero .btn-ghost:hover { background: rgba(255, 255, 255, .08); border-color: #fff; }
.hero-note { margin-top: 1rem; font-size: .88rem; color: #94a3b8; }
.hero-card { background: #fff; color: var(--text); border-radius: 18px; padding: 1.25rem; box-shadow: var(--shadow-lg); max-width: 380px; width: 100%; justify-self: center; }
.hc-row { display: flex; justify-content: space-between; padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.hc-row span { color: var(--muted); }
.hc-bars { display: flex; align-items: flex-end; gap: 6px; height: 90px; margin-top: 1rem; }
.hc-bars i { flex: 1; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, var(--accent), var(--navy-3)); }
.site .ad-slot { margin: 2rem 0; }
.section { padding: 2.5rem 16px; }
.section h2, .article h2 { font-size: clamp(1.35rem, 3vw, 1.8rem); color: var(--navy); font-weight: 800; margin-bottom: 1.2rem; }
.features { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.feature { padding: 1.2rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.feature h3 { font-size: 1.02rem; color: var(--navy); margin-bottom: .4rem; }
.feature p { color: var(--text-2); font-size: .95rem; }
.steps { padding-left: 1.3rem; display: flex; flex-direction: column; gap: .9rem; max-width: 75ch; }
.steps li::marker { color: var(--accent); font-weight: 800; }
.prose p, .prose li { max-width: 72ch; color: var(--text-2); font-size: 1rem; line-height: 1.7; }
.prose p + p { margin-top: .9rem; }
.prose h3 { color: var(--navy); font-size: 1.12rem; margin: 1.6rem 0 .5rem; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: .7rem 0; }
.prose li + li { margin-top: .35rem; }
.prose a:not(.btn) { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }
.prose code { background: var(--surface-2); border: 1px solid var(--border); padding: .05rem .35rem; border-radius: 5px; font-size: .9em; }
.article { padding-top: 2.5rem; padding-bottom: 3rem; max-width: 820px; }
.article h1 { font-size: clamp(1.8rem, 4.5vw, 2.5rem); color: var(--navy); font-weight: 800; letter-spacing: -.025em; }
.article h2 { margin-top: 2.2rem; margin-bottom: .7rem; }
.toc { margin: 1.8rem 0; padding: 1rem 1.2rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.toc ol { margin-bottom: 0; }
.faq { display: flex; flex-direction: column; gap: .6rem; max-width: 820px; }
.faq details { border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1.1rem; background: var(--surface-2); }
.faq summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.faq details p { margin-top: .6rem; color: var(--text-2); }
.cta-band { text-align: center; background: var(--accent-soft); border-radius: 18px; padding: 2.2rem 1.2rem; margin: 2rem auto; }
.cta-band h2 { margin: 0 0 .4rem; }
.cta-band p { margin: 0 auto 1.2rem; color: var(--text-2); max-width: none; }
.contact-card { margin: 1.5rem 0; padding: 1.2rem 1.3rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }
.contact-card p + p { margin-top: .4rem; }
.todo { background: #fef3c7; color: #92400e; padding: 0 .3rem; border-radius: 4px; }
.site-foot { background: var(--navy); color: #94a3b8; font-size: .86rem; padding: 1.5rem 0; }
.site-foot-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem 1.5rem; }
.site-foot a { color: #cbd5e1; }
.site-foot a:hover { color: #fff; text-decoration: underline; }
@media (min-width: 960px) {
  .hero-in { grid-template-columns: 1.3fr 1fr; }
  .hero { padding: 4.5rem 0 5rem; }
}
@media (max-width: 539.98px) {
  .site-nav { width: 100%; justify-content: space-between; padding-bottom: .3rem; }
  .hero-cta .btn { flex: 1 1 100%; }
}
/* 12. Anuncios sin llenar: se ocultan (regla recomendada por Google AdSense) */
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }
.ad-slot.is-live:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none !important; }
/* 13. Blog ------------------------------------------------------- */
.article-wide { padding-top: 2.5rem; padding-bottom: 3rem; }
.article-wide h1 { font-size: clamp(1.8rem, 4.5vw, 2.5rem); color: var(--navy); font-weight: 800; letter-spacing: -.025em; }
.article-wide .lead { color: var(--text-2); }
.blog-cat { margin-top: 2.2rem; }
.blog-cat h2 { font-size: 1.3rem; color: var(--navy); font-weight: 800; margin-bottom: 1rem; }
.post-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.post-card { display: flex; flex-direction: column; gap: .45rem; padding: 1.2rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); transition: border-color .2s, transform .2s var(--ease-out); }
.post-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.post-card h3 { font-size: 1.05rem; line-height: 1.3; color: var(--navy); }
.post-card h3 a:hover { text-decoration: underline; }
.post-card p { color: var(--text-2); font-size: .92rem; max-width: none; }
.post-cat { font-size: .72rem !important; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-2) !important; }
.post-more { margin-top: auto; font-weight: 600; font-size: .9rem; color: var(--accent-2); }
.post-meta { color: var(--muted) !important; font-size: .88rem !important; margin-top: .6rem; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 1rem; }
.crumbs a { color: var(--muted) !important; text-decoration: none !important; }
.crumbs a:hover { color: var(--accent-2) !important; }
.related { margin-top: 2.5rem; }
.related .post-card p, .related .post-card h3 { max-width: none; }
.prose table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.2rem; font-size: .95rem; }
.prose th, .prose td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
.prose th { background: var(--surface-2); color: var(--navy); font-weight: 700; }
.prose h2 { margin-top: 2rem; }
@media (max-width: 539.98px) { .prose table { font-size: .85rem; } .prose th, .prose td { padding: .5rem .4rem; } }.prose blockquote { margin: 1rem 0; padding: .9rem 1.1rem; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 12px 12px 0; }
.prose blockquote p { margin: 0; font-style: italic; }

/* 14. Lector de códigos de barras ------------------------------- */
.scan-row { display: flex; gap: .5rem; align-items: stretch; flex: 2 1 280px; min-width: 0; }
.scan-row .search { flex: 1; min-width: 0; }
.scan-row > input { flex: 1; min-width: 0; min-height: 42px; border: 1px solid var(--border-2); border-radius: 10px; padding: .5rem .75rem; background: var(--surface); }
.scan-row > input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.scan-btn { flex: none; padding: .5rem .8rem; }
.scan-tip { display: flex; align-items: center; gap: .4rem; margin: .5rem 0 0; }
.scan-tip .ico { width: 15px; height: 15px; flex: none; }
.scan { display: flex; flex-direction: column; gap: .8rem; }
.scan-view { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 55vh; background: #0b1220; border-radius: 14px; overflow: hidden; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; left: 10%; right: 10%; top: 30%; bottom: 30%; border: 3px solid rgba(74, 222, 128, .95); border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); }
.scan-frame::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ef4444; box-shadow: 0 0 8px #ef4444; animation: scanline 1.6s ease-in-out infinite alternate; }
@keyframes scanline { from { transform: translateY(-28px); } to { transform: translateY(28px); } }
.scan-status { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: .5rem .8rem; background: rgba(15, 23, 42, .75); color: #fff; font-size: .85rem; text-align: center; }
.scan-manual label { font-size: .84rem; font-weight: 600; color: var(--text-2); display: block; margin-bottom: .3rem; }
.scan-manual-row { display: flex; gap: .5rem; }
.scan-manual-row input { flex: 1; min-width: 0; min-height: 42px; border: 1px solid var(--border-2); border-radius: 10px; padding: .5rem .75rem; }
@media (max-width: 539.98px) { .scan-btn span { display: none; } }
@media (prefers-reduced-motion: reduce) { .scan-frame::after { animation: none; } }