:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --line: #e2e6ee;
  --ink: #0f1b33;
  --muted: #5f6b80;
  --primary: #1b2b4b;
  --primary-dark: #14213d;
  --accent-soft: #f4ecd6;
  --success: #2f7a4f;
  --success-soft: #ddefe3;
  --danger: #b4442f;
  --danger-soft: #f8e1dc;
  --warn: #b7862a;
  --warn-soft: #f8ecd0;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 27, 51, .05), 0 6px 18px rgba(15, 27, 51, .05);
  --nav-h: 64px;
  --chart: #a8822f;        /* serie única de gráficos (validada: luminosidad, croma y contraste) */
  --chart-hover: #8a6a24;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  /* Dorado del logo (validado para gráficos sobre blanco) y barra lateral azul marino */
  --gold: #a8822f;
  --gold-light: #e3c37b;
  --side: #14213d;
  --side-ink: #aeb8cc;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- barra superior y navegación ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-logo { height: 30px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 600; font-size: 15px;
}
.sync-pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--warn-soft); color: #7a5a14; }
.sync-pill.off { background: var(--danger-soft); color: var(--danger); }

.view { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 28px); }
.view.full { padding-bottom: 32px; }

.bottomnav {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line);
}
.bottomnav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 500;
}
.bottomnav button.active { color: var(--primary-dark); }
.bottomnav button.active svg { stroke-width: 2.1; }

/* ---------- tipografía y bloques ---------- */
h1 { font: 700 28px/1.1 var(--serif); color: var(--primary-dark); }
h2 { font: 700 21px/1.2 var(--serif); color: var(--primary-dark); margin: 26px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strike { text-decoration: line-through; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card + .card { margin-top: 10px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

.hello { margin-bottom: 18px; }
.hello p { color: var(--muted); font-size: 13px; }
.login-hello { text-align: center; }
.cols > div > h2:first-child { margin-top: 26px; }

/* Piezas que solo existen en computadora */
.side-only, .side-logo, .login-brand, .pin-desktop { display: none !important; }
body:not(.is-owner) .owner-only { display: none !important; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px;
  font-weight: 600; background: var(--surface-2); color: var(--ink);
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.success { background: var(--success); color: #fff; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn.big { min-height: 58px; font-size: 17px; border-radius: 14px; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--primary-dark); }
.icon-btn:active { background: var(--surface-2); }

.fab {
  position: fixed; right: max(16px, calc(50vw - 304px)); bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 25;
  height: 52px; padding: 0 20px; border-radius: 26px; background: var(--primary); color: #fff;
  font-weight: 600; box-shadow: 0 6px 18px rgba(20, 33, 61, .3); display: flex; align-items: center; gap: 6px;
}

/* ---------- chips / segmentado ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 4px; margin: 0 -16px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.seg button { padding: 8px 0; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

/* ---------- formularios ---------- */
.field { display: block; }
.field + .field { margin-top: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; font-size: 16px; /* 16px evita el zoom en iPhone */
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid2 .field + .field, .grid3 .field + .field { margin-top: 0; }

.search { position: relative; margin-bottom: 12px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 20px; height: 20px; }
.search .input { padding-left: 44px; background: var(--surface); }

/* ---------- inicio (panel) ---------- */
.page-head { margin-bottom: 18px; }
.page-head p { margin-top: 2px; }
.page-actions { display: grid; gap: 10px; margin-top: 14px; }
.page-actions .seg { margin: 0; }
.new-sale-btn { min-height: 52px; font-size: 16px; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.stat-foot { font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px; align-items: baseline; }
.delta { font-weight: 600; color: var(--muted); }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }

.home-grid { display: grid; gap: 14px; }
.home-main, .home-side { display: grid; gap: 14px; align-content: start; min-width: 0; }
.home-main > .panel + .panel, .home-side > .panel + .panel { margin-top: 0; }
@media (max-width: 899px) {
  .home-main, .home-side { display: contents; }
  .chart-panel { order: 1; }
  .att-panel { order: 2; }
  .methods-panel { order: 3; }
  .recovery-panel { order: 4; }
  .top-panel { order: 5; }
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.panel-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.panel-link { font-size: 13px; font-weight: 600; color: var(--primary-dark); white-space: nowrap; }
.panel-link:hover { text-decoration: underline; }

.chart-total { font-size: 30px; font-weight: 700; line-height: 1.1; margin-top: 4px; }
.chart { position: relative; height: 210px; margin: 26px 0 4px; }
.chart-grid { position: absolute; inset: 0 0 24px 0; display: flex; flex-direction: column; justify-content: space-between; }
.chart-tick { position: relative; height: 0; border-top: 1px solid var(--line); }
.chart-tick span { position: absolute; left: 0; top: -16px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-bars { position: absolute; inset: 0 0 0 52px; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 2px; padding-bottom: 24px; }
.chart-col { position: relative; display: flex; align-items: flex-end; justify-content: center; border-radius: 6px; outline: none; }
.chart-col i { display: block; width: min(24px, 72%); background: var(--chart); border-radius: 4px 4px 0 0; }
.chart-col i.zero { height: 0 !important; }
.chart-col.hover, .chart-col:focus-visible { background: rgba(20, 33, 61, .05); }
.chart-col.hover i, .chart-col:focus-visible i { background: var(--chart-hover); }
.chart-x { position: absolute; bottom: -20px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.chart-empty { position: absolute; inset: 0 0 24px 52px; display: grid; place-items: center; font-size: 13px; color: var(--muted); pointer-events: none; }
.chart-tip { position: absolute; top: 0; transform: translate(-50%, -105%); z-index: 4; pointer-events: none; white-space: nowrap;
  background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 10px; font-size: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.chart-tip .tip-value { font-size: 15px; font-weight: 700; }
.chart-tip .tip-count, .chart-tip .tip-label { opacity: .8; }
.chart-table summary { font-size: 12px; color: var(--muted); cursor: pointer; margin-top: 12px; }
.chart-table table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.chart-table td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.chart-table td + td { text-align: right; }

.att-list > * + *, .lot-row + .lot-row, .top-row + .top-row { border-top: 1px solid var(--line); }
.att-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 0; text-align: left; font-size: 14px; }
.att-item:hover .grow { color: var(--primary-dark); }
.att-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.att-dot.warn { background: var(--warn); }
.att-dot.bad { background: var(--danger); }
.lot-row { display: block; width: 100%; text-align: left; padding: 12px 0; }
.lot-row:first-of-type { padding-top: 2px; }
.lot-row .progress { height: 8px; margin: 8px 0 6px; }
.top-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; font-size: 14px; }
.top-row:first-child { padding-top: 0; }
.top-rank { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--muted); }

/* ---------- indicadores (otras pantallas) ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi span { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi strong { display: block; font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi.hero { grid-column: 1 / -1; background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.kpi.hero span { color: #c9d2e3; }
.kpi.hero strong { font-size: 32px; }

.bars .bar-row { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.bars .bar-row + .bar-row { margin-top: 8px; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--primary); }

.progress { height: 12px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 10px 0 8px; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold), #cfa955); transition: width .5s; }
.progress.done > i { background: linear-gradient(90deg, var(--success), #5a9a69); }
.lot-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 12px; color: var(--muted); }
.lot-stats b { display: block; color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------- listas de productos ---------- */
.cat-title {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-top: 10px; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  font-size: 15px; font-weight: 600; color: var(--primary-dark); text-align: left;
}
.cat-title span:last-child { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.cat-title.open { position: sticky; top: 58px; z-index: 5; background: var(--accent-soft); border-color: var(--accent-soft); }
.cat-title + .stack { margin-top: 10px; }

.inv-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.inv-head { display: flex; align-items: center; gap: 8px; padding: 12px 8px 10px 14px; }
.inv-head .name { font-weight: 600; line-height: 1.3; }
.vrow { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.vrow.out { opacity: .55; }
.vrow .vlabel { font-weight: 600; font-size: 14px; }
.vrow .btn.sm { min-width: 74px; }
.qty-ctl { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.qty-ctl button { width: 34px; height: 34px; font-size: 18px; font-weight: 600; color: var(--primary-dark); background: var(--surface-2); }
.qty-ctl button:disabled { opacity: .35; }
.qty-ctl b { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }
.badge.disc { background: var(--accent-soft); color: #7a5d22; }
.kpi small { display: block; margin-top: 2px; }

.strategy-item { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 12px; padding: 12px 14px; }
.price-row { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 10px; background: var(--bg); border-radius: 10px; padding: 8px 4px; text-align: center; }
.price-row > div + div { border-left: 1px solid var(--line); }
.price-row span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.price-row strong { font-size: 13px; font-variant-numeric: tabular-nums; }
.plist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pitem { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 14px; text-align: left; }
.pitem + .pitem { border-top: 1px solid var(--line); }
.pitem:active { background: var(--surface-2); }
.pitem.out { opacity: .5; }
.pitem .name { font-weight: 600; line-height: 1.3; }
.pitem .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pitem .price { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pitem .price small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); vertical-align: middle; }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.low { background: var(--warn-soft); color: #7a5a14; }
.badge.out, .badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.m-efectivo { background: #e3eedb; color: #3f6a2c; }
.badge.m-yape { background: #eadcf0; color: #742284; }
.badge.m-plin { background: #d9eef0; color: #136d78; }
.badge.m-transferencia { background: #dfe6f3; color: #2d4f8a; }
.badge.m-tarjeta { background: #f0e4d6; color: #7a4f1f; }

.vchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.vchip { font-size: 12px; padding: 4px 9px; border-radius: 8px; background: var(--surface-2); }
.vchip.out { opacity: .5; text-decoration: line-through; }

/* ---------- ventas ---------- */
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 2px 8px; }
.sale { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 12px 14px; }
.sale + .sale { border-top: 1px solid var(--line); }
.sale.voided { opacity: .5; }
.sale.voided .amt { text-decoration: line-through; }
.sale .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sale .time { font-size: 12px; color: var(--muted); width: 42px; flex: none; font-variant-numeric: tabular-nums; }

/* ---------- hoja inferior (modal) ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 18, 35, .5); animation: fade .2s; }
.sheet-panel {
  position: relative; width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 8px 18px calc(20px + var(--safe-b));
  animation: up .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet-grip { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.sheet-head h3 { font: 700 22px/1.2 var(--serif); color: var(--primary-dark); flex: 1; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.variant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.variant-btn { text-align: left; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.variant-btn b { display: block; }
.variant-btn span { font-size: 12px; color: var(--muted); }
.variant-btn:disabled { opacity: .4; }

.stepper { display: grid; grid-template-columns: 52px 1fr 52px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.stepper button { font-size: 22px; font-weight: 600; color: var(--primary-dark); background: var(--surface-2); }
.stepper input { border: none; text-align: center; font-size: 18px; font-weight: 600; min-height: 48px; width: 100%; background: #fff; }
.stepper input:focus { outline: none; }

.methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.method { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; }
.method.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.total-box { display: flex; justify-content: space-between; align-items: baseline; margin-top: 16px; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.total-box strong { font-size: 28px; font-variant-numeric: tabular-nums; }

.vedit { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--surface); }
.vedit + .vedit { margin-top: 10px; }
.vedit .stockbar { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.vedit .stockbar input { width: 80px; min-height: 36px; padding: 4px 8px; font-size: 15px; }

.menu-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.menu-list button, .menu-list a { display: flex; align-items: center; gap: 12px; width: 100%; padding: 15px 14px; text-align: left; color: inherit; text-decoration: none; font-weight: 500; }
.menu-list > * + * { border-top: 1px solid var(--line); }
.menu-list svg { color: var(--gold); }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px; gap: 22px; max-width: 420px; margin: 0 auto; }
.login-logo { width: 220px; }
.login .card { width: 100%; }
.who { display: grid; gap: 10px; width: 100%; }
.who button { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 16px; text-align: left; }
.who .avatar { flex: none; display: grid; place-items: center; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 6px 0 4px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--primary); }
.pin-dots i.on { background: var(--primary); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; justify-content: center; }
.keypad button { height: 76px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); font-size: 26px; font-weight: 500; }
.keypad button:active { background: var(--accent-soft); }
.keypad .k-ok { background: var(--primary); color: #fff; border-color: var(--primary); font-size: 16px; font-weight: 600; }
.keypad .k-del { font-size: 15px; color: var(--muted); }
.error-text { color: var(--danger); font-size: 14px; text-align: center; min-height: 20px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 18px); transform: translateX(-50%); z-index: 60;
  width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; background: var(--ink); color: #fff;
  font-weight: 500; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); animation: up .25s;
}
.toast.ok { background: var(--success); }
.toast.bad { background: var(--danger); }

@media (min-width: 700px) {
  .sheet { align-items: center; }
  .sheet-panel { border-radius: 22px; }
}

/* =====================================================================
   COMPUTADORA: barra lateral, contenido ancho y cuadrículas.
   (El celular sigue usando la barra inferior y una sola columna.)
   ===================================================================== */
@media (min-width: 900px) {
  :root { --side-w: 248px; }
  body { font-size: 15px; }

  .topbar { display: none; }

  /* La barra inferior se convierte en barra lateral */
  .bottomnav {
    inset: 0 auto 0 0; width: var(--side-w); height: 100dvh; padding: 26px 16px 18px;
    display: flex; flex-direction: column; gap: 4px;
    border-top: none; border-right: 1px solid var(--line);
  }
  .bottomnav button {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 11px 14px; border-radius: 12px; font-size: 15px; font-weight: 500;
  }
  .bottomnav { background: var(--side); border-right-color: var(--side); }
  .bottomnav button { color: var(--side-ink); }
  .bottomnav button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
  .bottomnav button.active { background: rgba(201, 162, 78, .18); color: var(--gold-light); font-weight: 600; }
  .side-user { border-top-color: rgba(255, 255, 255, .12) !important; }
  .side-user b { color: #fff; }
  .side-user .muted { color: var(--side-ink); }
  .side-user .avatar { background: var(--gold); color: var(--side); }
  .side-user .sync-pill { background: rgba(255, 255, 255, .1); color: var(--gold-light); }
  .side-logo { display: block !important; width: 150px; margin: 0 10px 28px; }
  .side-only { display: flex !important; }
  body:not(.is-owner) .owner-only { display: none !important; }
  .side-user {
    margin-top: auto; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 14px 6px 0; border-top: 1px solid var(--line);
  }
  .side-user .avatar { display: grid; place-items: center; flex: none; }

  /* El contenido se centra en el espacio a la derecha de la barra lateral, con un ancho máximo. */
  .view { --content-w: 1640px; margin-left: var(--side-w); max-width: none; padding: 34px max(40px, calc((100% - var(--content-w)) / 2)) 60px; }
  .view.full { margin-left: 0; padding: 0; }
  .view.tab-ventas { --content-w: 1100px; }
  .view.tab-mas { --content-w: 900px; }

  h1 { font-size: 34px; }
  h2 { font-size: 23px; }


  .kpis { grid-template-columns: repeat(4, 1fr); gap: 14px; }

  .page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
  .page-actions { display: flex; align-items: center; gap: 12px; margin: 0; }
  .page-actions .seg { width: 300px; }
  .new-sale-btn { min-height: 46px; padding: 0 24px; font-size: 15px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
  .stat { padding: 18px 20px; }
  .stat-value { font-size: 28px; }
  .home-grid { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
  .home-main, .home-side { gap: 20px; }
  .panel { padding: 20px 22px; }
  .chart { height: 260px; }
  .kpi.hero { grid-column: span 2; }
  .kpi { padding: 18px; }

  .cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
  .cols .kpis { grid-template-columns: repeat(2, 1fr); }
  .tab-analisis .field { max-width: 460px; }

  .chips { flex-wrap: wrap; overflow: visible; margin: 0 0 14px; padding: 0; }
  .search { max-width: 560px; }
  .seg { max-width: 420px; }

  /* Vender: productos en cuadrícula de tarjetas */
  .sell-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; background: none; border: none; overflow: visible; }
  .sell-grid .pitem { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 16px; }
  .sell-grid .pitem + .pitem { border-top: 1px solid var(--line); }
  button.pitem:hover, button.sale:hover { background: var(--surface-2); }

  /* Inventario y estrategia: tarjetas en columnas */
  .inv-grid, .strategy-grid { display: grid; gap: 14px; align-items: start; }
  .inv-grid { grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); }
  .strategy-grid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
  .inv-grid > * + *, .strategy-grid > * + * { margin-top: 0; }
  .cat-title.open { top: 0; }
  .cat-title:hover { border-color: var(--accent-soft); }

  .fab { right: 44px; bottom: 36px; }
  .toast { left: auto; right: 36px; bottom: 36px; transform: none; }
  .sheet-panel { max-width: 620px; padding: 12px 28px 28px; }
  .sheet-grip { display: none; }

  .btn:hover { filter: brightness(.97); }
  .btn.primary:hover, .fab:hover { background: var(--primary-dark); }

  /* Login en dos paneles */
  .login-wrap { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100dvh; }
  .login-brand {
    display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    background: radial-gradient(circle at 30% 20%, #22365e 0%, #14213d 55%, #0d172b 100%);
    padding: 40px;
  }
  .login-brand img { width: min(360px, 70%); }
  .login-brand-title { font: 700 30px/1.1 var(--serif); color: var(--gold-light); margin-top: 10px; }
  .login-brand-sub { color: var(--side-ink); letter-spacing: .14em; text-transform: uppercase; font-size: 12px; }
  .login { min-height: 0; max-width: 420px; width: 100%; align-self: center; justify-self: center; padding: 40px 24px; align-items: stretch; }
  .login .login-logo, .login .pin-dots, .login .keypad { display: none; }
  .login > .muted { text-align: center; font-size: 16px; }
  .login-hello { text-align: center; }
  .pin-desktop { display: grid !important; gap: 12px; }
  .pin-desktop .input { text-align: center; font-size: 22px; letter-spacing: .4em; }
  .pin-desktop .input::placeholder { font-size: 15px; letter-spacing: normal; }
  .who button:hover { border-color: var(--primary); }
}


/* =====================================================================
   PANTALLAS (Vender, Inventario, Ventas, Análisis, Más) con el mismo
   lenguaje del Inicio. Letra y botones más grandes para que sea fácil
   de leer y tocar.
   ===================================================================== */
body { font-size: 16px; }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.page-sub { color: var(--muted); font-size: 15px; margin-top: 4px; max-width: 60ch; }
.list-count { font-size: 14px; color: var(--muted); margin: 4px 2px 10px; }
.stat-value.pos, .pos { color: var(--success); }

.filters { margin-bottom: 16px; }
.filters .search { margin-bottom: 12px; }
.filters .chips { margin: 0; padding: 0; flex-wrap: wrap; overflow: visible; }
.chip { padding: 9px 16px; font-size: 14px; min-height: 40px; }
.seg button { font-size: 15px; padding: 10px 0; }
.seg-wide { margin-bottom: 16px; }
.filter-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

/* Vender: tarjetas de producto con la acción escrita */
.pgrid { display: grid; gap: 10px; }
.pcard {
  display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.pcard:not(:disabled):active { transform: scale(.99); }
.pcard.out { opacity: .55; }
.pcard-name { font-size: 16px; font-weight: 600; line-height: 1.3; }
.pcard-meta { font-size: 14px; color: var(--muted); }
.pcard-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 8px; }
.pcard-price { font-size: 19px; font-weight: 700; }
.pcard-stock { font-size: 14px; color: var(--muted); white-space: nowrap; }
.pcard-stock.low { color: #7a5a14; font-weight: 600; }
.pcard-stock.out { color: var(--danger); font-weight: 600; }
.pcard-cta { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-weight: 600; color: var(--primary-dark); font-size: 15px; }
.pcard.out .pcard-cta { color: var(--muted); }

/* Inventario: categorías con texto "Ver / Ocultar" */
.cat-title { gap: 12px; padding: 16px 18px; font-size: 16px; }
.cat-title .cat-meta { font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.cat-title .cat-toggle { font-size: 14px; font-weight: 600; color: var(--primary-dark); white-space: nowrap; min-width: 72px; text-align: right; }

/* Ventas */
.panel + .panel, .day-panel { margin-top: 14px; }
.panel-alert { border-color: var(--danger-soft); background: #fff6f3; }
.day-panel { padding-bottom: 6px; }
.day-panel .sale { padding: 12px 0; }
.day-panel .sale + .sale { border-top: 1px solid var(--line); }
.sale .time { font-size: 14px; width: 48px; }
.sale .chev, .menu-list .chev { color: var(--muted); font-size: 20px; }

/* Más */
.menu-group { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 4px 8px; }
.menu-list button { padding: 16px; }
.menu-list b { display: block; font-weight: 600; }
.menu-sub { display: block; font-size: 14px; color: var(--muted); font-weight: 400; }

/* Análisis */
.plain { font-size: 16px; line-height: 1.5; }
.progress.big { height: 14px; margin: 14px 0 6px; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.kv:first-of-type { border-top: none; padding-top: 0; }
.kv span { display: block; font-weight: 500; }
.kv small { display: block; font-size: 13px; color: var(--muted); }
.kv b { font-size: 18px; white-space: nowrap; }
.kv.total { border-top: 2px solid var(--line); margin-top: 4px; }
.kv.total b { font-size: 24px; }
.two-col { display: grid; gap: 14px; }
.two-col > .panel + .panel { margin-top: 0; }
.an-filters { display: grid; gap: 14px; }
.an-filters .field + .field { margin-top: 0; }
.strategy-foot { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.strategy-foot b { color: var(--ink); }
.strategy-foot b.pos { color: var(--success); }

/* Celular: categorías en una sola fila deslizable y tarjetas más compactas */
@media (max-width: 899px) {
  .filters .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -18px; padding: 0 18px 2px; scrollbar-width: none; }
  .filters .chips::-webkit-scrollbar { display: none; }
  .pcard { padding: 14px 16px; }
  .pcard-foot { margin-top: 4px; }
  .pcard-cta { margin-top: 8px; padding-top: 8px; }
  .page-head h1 { font-size: 30px; }
  .day-panel .ellipsis { white-space: normal; } /* nombre completo, sin cortar */
  .cat-title { flex-wrap: wrap; row-gap: 2px; }
  .cat-title .cat-meta { order: 3; flex-basis: 100%; }
  .list-count .btn { white-space: nowrap; flex: none; }
}

@media (min-width: 900px) {
  .pgrid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
  .filters .search { max-width: 640px; }
  .seg-wide { max-width: 560px; }
  .fab { display: none; }
  .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
  .an-filters { grid-template-columns: minmax(0, 1fr) 360px; align-items: end; }
  .an-filters .field { max-width: none; }
  .view.tab-ventas { --content-w: 1100px; }
  .view.tab-mas { --content-w: 820px; }
}

/* Análisis: lista "Precio de cada producto" con su propio título */
.section-block { margin-top: 32px; }
.section-title { font: 700 24px/1.2 var(--serif); color: var(--primary-dark); margin: 0; }
.group-title { margin: 22px 2px 10px; font-size: 14px; font-weight: 700; color: var(--ink); text-transform: uppercase; letter-spacing: .05em; }
.group-title span { font-weight: 500; color: var(--muted); text-transform: none; letter-spacing: 0; }
.warn-text { color: #8a5a00; font-weight: 600; }

/* =====================================================================
   SISTEMA DE DISEÑO (tipografía, espacios y tamaños de control)
   Base: escala tipográfica de Material Design 3 + patrones de Shopify
   Polaris (tamaño mínimo 13 px, alturas de línea en múltiplos de 4).
   Va al final para que gane sobre las reglas anteriores.
   Los colores NO se tocan aquí.
   ===================================================================== */
:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Escala de texto: solo estos tamaños en toda la app */
  --t-page: 600 22px/28px var(--font);      /* Título de pantalla        (M3 Headline small) */
  --t-hero: 600 24px/32px var(--font);      /* Número destacado          (M3 Headline small) */
  --t-stat: 600 20px/28px var(--font);      /* Números de indicadores    (M3 Title large)    */
  --t-title: 600 16px/24px var(--font);     /* Título de tarjeta/sección (M3 Title medium)   */
  --t-body: 400 15px/22px var(--font);      /* Texto normal              (M3 Body large)     */
  --t-label: 500 14px/20px var(--font);     /* Botones, filtros          (M3 Label large)    */
  --t-caption: 400 13px/18px var(--font);   /* Texto de apoyo            (mínimo Polaris)    */
  --t-tiny: 500 12px/16px var(--font);      /* Solo ejes del gráfico, etiquetas y barra inferior */

  /* Espacios: múltiplos de 4 */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;

  /* Controles */
  --h-control: 48px;     /* botones, campos, segmentos (mínimo cómodo para tocar) */
  --h-control-sm: 40px;  /* botones secundarios y filtros */
  --r-card: 14px;
  --r-control: 10px;
  --pad-card: var(--sp-4);
}
@media (min-width: 900px) {
  :root { --t-page: 600 24px/32px var(--font); --t-hero: 600 28px/36px var(--font); --t-stat: 600 22px/28px var(--font); --pad-card: 20px; }
}

/* ---------- texto base: una sola familia ---------- */
body { font: var(--t-body); }
h1, h2, h3, h4, .section-title, .login-brand-title { font-family: var(--font); letter-spacing: -0.01em; }
h1, .page-head h1 { font: var(--t-page); color: var(--primary-dark); }
h2, .section-title { font: var(--t-title); font-size: 18px; color: var(--primary-dark); }
.small { font: var(--t-label); font-weight: 400; }
.tiny { font: var(--t-caption); }
.t-title { font: var(--t-title); }
.page-sub, .list-count, .stat-foot, .delta, .pcard-meta, .menu-sub, .kv small, .strategy-foot { font: var(--t-caption); }
.delta { font-weight: 600; }
.empty { font: var(--t-body); }

/* ---------- encabezado de pantalla ---------- */
.page-head { margin-bottom: var(--sp-4); }
.page-sub { margin-top: var(--sp-1); }
.page-actions { gap: var(--sp-2); margin-top: var(--sp-3); }

/* ---------- controles ---------- */
.btn { min-height: var(--h-control); padding: 0 var(--sp-4); border-radius: var(--r-control); font: var(--t-label); font-weight: 600; }
.btn.big, .new-sale-btn { min-height: var(--h-control); font: var(--t-label); font-weight: 600; border-radius: var(--r-control); }
.btn.sm { min-height: var(--h-control-sm); padding: 0 var(--sp-3); font: var(--t-label); font-weight: 600; }
.input, select.input, textarea.input { min-height: var(--h-control); border-radius: var(--r-control); font: 400 16px/22px var(--font); /* 16 px evita el zoom en iPhone */ }
.chip { min-height: var(--h-control-sm); padding: 0 var(--sp-3); font: var(--t-label); display: inline-flex; align-items: center; }
.seg { padding: var(--sp-1); border-radius: 12px; }
.seg button { min-height: var(--h-control-sm); padding: 0; font: var(--t-label); }
.seg button.active { font-weight: 600; }
.method { min-height: var(--h-control); font: var(--t-label); font-weight: 600; }
.stepper { grid-template-columns: var(--h-control) 1fr var(--h-control); }
.stepper input { min-height: var(--h-control); font: var(--t-title); }
.qty-ctl button { width: var(--h-control-sm); height: var(--h-control-sm); font-size: 18px; }
.icon-btn { width: var(--h-control-sm); height: var(--h-control-sm); }
.fab { height: var(--h-control); padding: 0 var(--sp-5); font: var(--t-label); font-weight: 600; }
.badge { font: var(--t-tiny); padding: 2px var(--sp-2); }
.search svg { width: 18px; height: 18px; }

/* ---------- tarjetas ---------- */
.panel, .stat, .card, .inv-card, .strategy-item, .menu-list, .plist { border-radius: var(--r-card); }
.panel { padding: var(--pad-card); }
.panel + .panel, .day-panel { margin-top: var(--sp-3); }
.panel-head { margin-bottom: var(--sp-3); }
.panel-title { font: var(--t-title); }
.panel-link { font: var(--t-label); font-weight: 600; }
.filters { margin-bottom: var(--sp-4); }
.filters .search { margin-bottom: var(--sp-3); }

/* ---------- indicadores ---------- */
.stats { gap: var(--sp-3); margin-bottom: var(--sp-4); }
.stat { padding: var(--sp-3) var(--sp-4); gap: 2px; }
.stat-label { font: var(--t-caption); font-weight: 500; }
.stat-value { font: var(--t-stat); }
.chart-total { font: var(--t-hero); }
.chart-x, .chart-tick span { font: var(--t-tiny); font-weight: 400; }

/* ---------- Inicio ---------- */
.home-grid, .home-main, .home-side { gap: var(--sp-3); }
.att-item, .top-row { font: var(--t-body); padding: var(--sp-3) 0; }
.lot-row { padding: var(--sp-3) 0; }
.lot-row b { font: var(--t-title); font-size: 15px; }
.bars .bar-row { font: var(--t-label); font-weight: 400; }

/* ---------- Vender: filas compactas ---------- */
.pgrid { gap: var(--sp-2); }
.pcard { flex-direction: row; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-card); min-height: 64px; }
.pcard-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pcard-name { font: var(--t-body); font-weight: 600; }
.pcard-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; text-align: right; }
.pcard-price { font: var(--t-title); }
.pcard-stock { font: var(--t-caption); }
.pcard .chev { color: var(--muted); font-size: 22px; line-height: 1; margin-left: calc(-1 * var(--sp-1)); }
.pcard.out .chev { visibility: hidden; }

/* ---------- Inventario ---------- */
.cat-title { min-height: var(--h-control); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-card); font: var(--t-title); margin-top: var(--sp-2); }
.cat-title .cat-meta { font: var(--t-caption); }
.cat-title .cat-toggle { font: var(--t-label); font-weight: 600; min-width: 0; }
.cat-title + .stack { margin-top: var(--sp-2); }
.inv-head { padding: var(--sp-3) var(--sp-2) var(--sp-2) var(--sp-4); }
.inv-head .name { font: var(--t-title); font-size: 15px; }
.vrow { padding: var(--sp-3) var(--sp-4); gap: var(--sp-3); }
.vrow .vlabel { font: var(--t-label); font-weight: 600; }
.vrow .small { font: var(--t-label); font-weight: 400; }
.vrow .btn.sm { min-width: 0; }

/* ---------- Ventas ---------- */
.sale { font: var(--t-body); }
.day-panel .sale { padding: var(--sp-3) 0; }
.sale .time { font: var(--t-caption); width: 44px; }
.sale .amt { font: var(--t-title); font-size: 15px; }

/* ---------- Análisis ---------- */
.plain { font: var(--t-body); }
.kv { padding: var(--sp-3) 0; }
.kv span { font: var(--t-body); font-weight: 500; }
.kv b { font: var(--t-title); }
.kv.total b { font: var(--t-stat); }
.section-block { margin-top: var(--sp-6); }
.group-title { font: var(--t-caption); font-weight: 600; letter-spacing: .05em; margin: var(--sp-5) 2px var(--sp-2); }
.strategy-item { padding: var(--sp-3) var(--sp-4); }
.strategy-item > .row b { font: var(--t-title); font-size: 15px; }
.price-row span { font: var(--t-tiny); }
.price-row strong { font: var(--t-label); font-weight: 600; }

/* ---------- Más ---------- */
.menu-list button { padding: var(--sp-3) var(--sp-4); gap: var(--sp-3); }
.menu-list b { font: var(--t-body); font-weight: 600; }
.menu-group { font: var(--t-caption); font-weight: 600; margin: 0 var(--sp-1) var(--sp-2); }
.avatar-lg { display: grid; place-items: center; width: 44px; height: 44px; font-size: 18px; }

/* ---------- hojas emergentes ---------- */
.sheet-head h3 { font: var(--t-title); font-size: 18px; color: var(--primary-dark); }
.sheet-sub { display: block; font: var(--t-label); font-weight: 400; color: var(--muted); margin-top: 2px; }
.sheet-section { font: var(--t-title); color: var(--primary-dark); margin: var(--sp-5) 0 var(--sp-3); }
.field > span { font: var(--t-caption); font-weight: 500; }
.total-box strong { font: var(--t-hero); }
.variant-btn b { font: var(--t-label); font-weight: 600; }

/* ---------- login ---------- */
.setup-title { margin-bottom: var(--sp-2); }
.login-brand-title { font: var(--t-hero); }
.who button { font: var(--t-title); }
.keypad { grid-template-columns: repeat(3, 72px); gap: var(--sp-3); }
.keypad button { height: 72px; font: 500 24px/32px var(--font); }
.keypad .k-ok, .keypad .k-del { font: var(--t-label); font-weight: 600; }
.pin-desktop .input { font: 600 20px/28px var(--font); }

/* ---------- navegación y avisos ---------- */
.bottomnav button { font: var(--t-tiny); }
.toast { font: var(--t-label); }
.sync-pill { font: var(--t-tiny); }

@media (min-width: 900px) {
  .page-head { margin-bottom: var(--sp-5); }
  .page-actions { margin-top: 0; gap: var(--sp-3); }
  .stats, .home-grid, .home-main, .home-side, .two-col { gap: var(--sp-4); }
  .stats { margin-bottom: var(--sp-5); }
  .stat { padding: var(--sp-4) 20px; }
  .bottomnav button { font: var(--t-label); }
  .bottomnav button.active { font-weight: 600; }
  .pgrid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--sp-3); }
  .inv-grid, .strategy-grid { gap: var(--sp-3); }
}

/* ---------- Filtros (Material 3 "filter chips") ----------
   Sin tarjeta alrededor; fichas de 32 px, esquinas de 8 px y la elegida en tono suave. */
.filters { background: none; border: none; padding: 0; box-shadow: none; }
.filters .search { margin-bottom: var(--sp-2); }
.filters .search .input { min-height: 44px; background: var(--surface); }
.filters .chips { gap: 6px; }
.chip {
  min-height: 32px; padding: 0 var(--sp-3); border-radius: 8px;
  font: 500 13px/18px var(--font); background: var(--surface); border: 1px solid var(--line); color: var(--ink);
}
.chip.active { background: #e3e9f4; border-color: #c9d3e6; color: var(--primary-dark); font-weight: 600; }
.chip:not(.active):hover { border-color: #c9d3e6; }
.an-filters { gap: var(--sp-3); }
.an-filters .input { min-height: 44px; background: var(--surface); }
@media (max-width: 899px) {
  .filters .chips { margin: 0 calc(-1 * var(--sp-4)); padding: 0 var(--sp-4) 2px; }
}

/* ---------- Formularios en diálogo (Material 3: full-screen dialog en celular) ---------- */
.sheet.dialog .sheet-panel { height: 100dvh; max-height: 100dvh; border-radius: 0; padding: 0 var(--sp-4) var(--sp-5); animation: up .22s cubic-bezier(.2, .8, .2, 1); }
.sheet.dialog .sheet-grip { display: none; }
.sheet.dialog .sheet-head {
  position: sticky; top: 0; z-index: 3; align-items: center;
  margin: 0 calc(-1 * var(--sp-4)) var(--sp-4); padding: var(--sp-3) var(--sp-2) var(--sp-3) var(--sp-4);
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.dialog-footer { position: sticky; bottom: calc(-1 * var(--sp-5)); z-index: 3; margin: var(--sp-4) calc(-1 * var(--sp-4)) calc(-1 * var(--sp-5)); padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + var(--safe-b)); background: var(--bg); border-top: 1px solid var(--line); }
.sheet:not(.dialog) .dialog-footer { position: static; margin: var(--sp-4) 0 0; padding: 0; border: none; background: none; }
@media (min-width: 700px) {
  .sheet.dialog .sheet-panel { height: auto; max-height: 88dvh; max-width: 600px; border-radius: 16px; padding: 0 var(--sp-5) var(--sp-5); }
  .sheet.dialog .sheet-head { margin: 0 calc(-1 * var(--sp-5)) var(--sp-4); padding: var(--sp-4) var(--sp-3) var(--sp-4) var(--sp-5); border-radius: 16px 16px 0 0; }
  .dialog-footer { margin: var(--sp-4) calc(-1 * var(--sp-5)) calc(-1 * var(--sp-5)); padding: var(--sp-3) var(--sp-5) var(--sp-4); border-radius: 0 0 16px 16px; }
}

/* ---------- Opciones visibles (reemplazan listas desplegables cortas) ---------- */
.choices { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--h-control-sm); padding: 0 var(--sp-3);
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: var(--t-label); cursor: pointer;
}
.choice input:checked + span { background: #e3e9f4; border-color: #c9d3e6; color: var(--primary-dark); font-weight: 600; }
.choice input:checked + span::before { content: '✓'; }
.choice input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Listas desplegables que quedan (ej. producto en Análisis): flecha propia y mismo estilo que los campos */
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6b80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
.field + .field, .field + div.field { margin-top: var(--sp-3); }
.sheet-head .icon-btn { color: var(--muted); font: 400 18px/1 var(--font); font-variant-emoji: text; }
.sheet-head .icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.cat-picker .cat-new { margin-top: var(--sp-2); }

/* ---------- Desplegable propio ---------- */
.dd { position: relative; }
.dd-btn {
  display: flex; align-items: center; width: 100%; text-align: left; cursor: pointer; padding-right: 40px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6b80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 18px;
}
.dd-btn[aria-expanded="true"] { border-color: var(--primary); outline: 2px solid var(--primary); outline-offset: -1px; }
.dd-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-value.placeholder { color: var(--muted); }
.dd-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 10;
  max-height: 248px; overflow-y: auto; padding: var(--sp-1);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control);
  box-shadow: 0 10px 28px rgba(15, 27, 51, .14);
}
.dd-opt { display: block; width: 100%; text-align: left; padding: 10px var(--sp-3); border-radius: 8px; font: var(--t-body); }
.dd-opt:hover, .dd-opt:focus-visible { background: var(--surface-2); outline: none; }
.dd-opt[aria-selected="true"] { background: #e3e9f4; color: var(--primary-dark); font-weight: 600; }
.dd-opt.dd-new { color: var(--primary-dark); font-weight: 600; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; margin-top: var(--sp-1); }

/* ---------- Nuevo producto: un solo producto vs. con tallas ---------- */
[data-mode="single"] .only-sizes, [data-mode="sizes"] .only-single { display: none !important; }
[data-mode="single"] .v-label { display: none; }
.sheet-section span { display: inline; }
/* Pregunta de dos opciones: dos mitades iguales */
.choices-split .choices { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.choices-split .choice span { width: 100%; justify-content: center; }

/* Botón secundario (Material 3 "outlined"): blanco con borde, en toda la app */
.btn.ghost, .btn:not(.primary):not(.success):not(.danger) {
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
}
.btn.ghost:hover, .btn:not(.primary):not(.success):not(.danger):hover { background: var(--surface-2); filter: none; }


/* =====================================================================
   MOVIMIENTO (Material 3): animaciones cortas y suaves, solo opacidad
   y desplazamiento (fluidas incluso en celulares económicos).
   Se desactivan solas si el sistema tiene "reducir movimiento".
   ===================================================================== */
:root {
  --ease-enter: cubic-bezier(.05, .7, .1, 1);  /* entra rápido y frena suave */
  --ease-exit: cubic-bezier(.3, 0, .8, .15);   /* sale acelerando */
  --ease-std: cubic-bezier(.2, 0, 0, 1);
  --d-fast: 150ms;
  --d-med: 220ms;
  --d-slow: 280ms;
}

@keyframes view-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* ---------- cambio de pantalla y fin de carga ---------- */
.view.entering { animation: view-in var(--d-med) var(--ease-enter) backwards; }
.view.loaded { animation: fade-in var(--d-med) var(--ease-std) backwards; }

/* ---------- desplegable propio ---------- */
.dd-btn { position: relative; background-image: none; }
.dd-btn::after {
  content: ''; position: absolute; right: 12px; top: 50%; width: 18px; height: 18px; margin-top: -9px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6b80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat center / 18px;
  transition: transform var(--d-fast) var(--ease-std);
}
.dd-btn[aria-expanded="true"]::after { transform: rotate(180deg); }
.dd-list:not([hidden]) { transform-origin: top center; animation: dd-in var(--d-fast) var(--ease-enter); }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------- categorías del inventario ---------- */
.cat-chev { display: inline-block; transition: transform var(--d-med) var(--ease-std); }
.cat-title.open .cat-chev { transform: rotate(180deg); }
.cat-title.just-toggled.open .cat-chev { animation: chev-open var(--d-med) var(--ease-std); }
.cat-title.just-toggled:not(.open) .cat-chev { animation: chev-close var(--d-med) var(--ease-std); }
@keyframes chev-open { from { transform: rotate(0); } to { transform: rotate(180deg); } }
@keyframes chev-close { from { transform: rotate(180deg); } to { transform: rotate(0); } }
.stack.just-opened > * { animation: view-in var(--d-med) var(--ease-enter) backwards; }
.stack.just-opened > :nth-child(2) { animation-delay: 30ms; }
.stack.just-opened > :nth-child(3) { animation-delay: 60ms; }
.stack.just-opened > :nth-child(n + 4) { animation-delay: 90ms; }

/* ---------- hojas y ventanas: entrada y salida ---------- */
.sheet-backdrop { animation: fade-in var(--d-med) var(--ease-std); }
.sheet .sheet-panel, .sheet.dialog .sheet-panel { animation: sheet-in var(--d-slow) var(--ease-enter); }
.sheet.closing { pointer-events: none; }
.sheet.closing .sheet-backdrop { animation: fade-out var(--d-fast) var(--ease-exit) forwards; }
.sheet.closing .sheet-panel, .sheet.dialog.closing .sheet-panel { animation: sheet-out 180ms var(--ease-exit) forwards; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes dialog-in { from { opacity: 0; transform: scale(.96); } }
@keyframes dialog-out { to { opacity: 0; transform: scale(.97); } }
@media (min-width: 700px) {
  /* En pantallas grandes las ventanas están centradas: aparecen creciendo un poco, no desde abajo. */
  .sheet .sheet-panel, .sheet.dialog .sheet-panel { animation: dialog-in var(--d-med) var(--ease-enter); }
  .sheet.closing .sheet-panel, .sheet.dialog.closing .sheet-panel { animation: dialog-out var(--d-fast) var(--ease-exit) forwards; }
}

/* ---------- aviso (toast): entra y sale deslizándose ---------- */
.toast { --tx: -50%; animation: toast-in var(--d-med) var(--ease-enter); }
.toast.leaving { animation: toast-out 180ms var(--ease-exit) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translate(var(--tx), 12px); } to { opacity: 1; transform: translate(var(--tx), 0); } }
@keyframes toast-out { from { opacity: 1; transform: translate(var(--tx), 0); } to { opacity: 0; transform: translate(var(--tx), 8px); } }
@media (min-width: 900px) { .toast { --tx: 0; } }

/* ---------- botones, filtros y filas: color suave y leve "hundido" ---------- */
.btn, .chip, .choice span, .method, .seg button, .bottomnav button, .pcard, .cat-title, .menu-list button,
.att-item, .sale, .dd-opt, .icon-btn, .qty-ctl button, .variant-btn, .who button, .keypad button, .input, .lot-row {
  transition: background-color var(--d-fast) var(--ease-std), border-color var(--d-fast) var(--ease-std),
    color var(--d-fast) var(--ease-std), box-shadow var(--d-fast) var(--ease-std), transform 100ms var(--ease-std);
}
.btn:active, .chip:active, .choice span:active, .method:active, .pcard:not(:disabled):active, .cat-title:active,
.menu-list button:active, .variant-btn:not(:disabled):active, .who button:active, .keypad button:active, .qty-ctl button:active {
  transform: scale(.97);
}

/* ---------- bloques de carga ---------- */
.skel {
  display: block; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, #f8f9fc 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.skel + .skel { margin-top: var(--sp-2); }
.skel-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); margin-top: var(--sp-3); }
.skel-row { padding: 14px var(--sp-4); }
.skel-row + .skel-row { border-top: 1px solid var(--line); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- "reducir movimiento" ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
  .skel { animation: none !important; }
}

/* ---------- Menú de la cuenta ---------- */
.user-menu {
  position: fixed; z-index: 45; top: calc(60px + env(safe-area-inset-top, 0px)); right: 12px; width: 240px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: var(--sp-2);
  box-shadow: 0 12px 32px rgba(15, 27, 51, .18);
  transform-origin: top right; animation: menu-in var(--d-fast) var(--ease-enter);
}
.user-menu-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-1); }
.user-menu-head .avatar { display: grid; place-items: center; flex: none; }
.user-menu-head b, .user-menu-head .tiny { display: block; }
.user-menu [role="menuitem"] {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 44px; padding: 0 var(--sp-3);
  border-radius: 10px; text-align: left; font: var(--t-body); font-weight: 500; color: var(--ink);
}
.user-menu [role="menuitem"] svg { width: 20px; height: 20px; color: var(--muted); }
.user-menu [role="menuitem"]:hover, .user-menu [role="menuitem"]:focus-visible { background: var(--surface-2); outline: none; }
.user-menu .user-menu-logout { color: var(--danger); }
.user-menu .user-menu-logout svg { color: var(--danger); }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.97); } }

@media (min-width: 900px) {
  /* En computadora se abre hacia arriba, sobre el usuario de la barra lateral. */
  .user-menu { top: auto; right: auto; left: 16px; bottom: 84px; width: calc(var(--side-w) - 32px); transform-origin: bottom left; }
  @keyframes menu-in { from { opacity: 0; transform: translateY(4px) scale(.97); } }
  .user-menu-head { display: none; }
  .side-account { margin-top: auto; padding-top: var(--sp-3); border-top: 1px solid rgba(255, 255, 255, .12); display: flex !important; flex-direction: column; gap: var(--sp-2); }
  .side-account .sync-pill { align-self: flex-start; background: rgba(255, 255, 255, .1); color: var(--gold-light); }
  .bottomnav .side-user {
    display: flex; align-items: center; gap: 10px; width: 100%; margin: 0; padding: 10px; border: none; border-radius: 12px;
    text-align: left; font: var(--t-label); color: var(--side-ink);
  }
  .bottomnav .side-user:hover, .bottomnav .side-user[aria-expanded="true"] { background: rgba(255, 255, 255, .08); }
  .side-user b { display: block; color: #fff; font-weight: 600; }
  .side-user .tiny { display: block; color: var(--side-ink); }
  .side-user .avatar { display: grid; place-items: center; flex: none; background: var(--gold); color: var(--side); }
  .side-user-chev { width: 18px; height: 18px; color: var(--side-ink); transition: transform var(--d-fast) var(--ease-std); transform: rotate(180deg); }
  .side-user[aria-expanded="true"] .side-user-chev { transform: rotate(0deg); }
  /* En computadora "Mi cuenta" está en este menú, no en la pantalla Más. */
  .account-group { display: none !important; }
}

/* =====================================================================
   PEDIDOS, FIADOS, ABONOS Y BOLETA
   ===================================================================== */
.neg { color: var(--danger); }
.pos { color: var(--success); }

/* Barra del pedido en curso: encima de la barra inferior en celular. */
.cart-bar {
  position: fixed; z-index: 29; left: var(--sp-3); right: var(--sp-3);
  bottom: calc(var(--nav-h) + var(--safe-b) + var(--sp-2));
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  background: var(--primary-dark); color: #fff; border-radius: 14px; box-shadow: 0 6px 20px rgba(20, 33, 61, .28);
  animation: cart-in var(--d-med, 250ms) var(--ease-enter, ease-out);
}
.cart-bar[hidden] { display: none; }
.cart-bar svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--gold); stroke-width: 1.8; }
.cart-bar .grow { display: flex; flex-direction: column; min-width: 0; font: var(--t-label); }
.cart-bar .grow b { font-weight: 600; }
.cart-bar #cart-total { color: #e9d7a8; font-weight: 600; }
.cart-bar .btn { min-height: var(--h-control-sm, 40px); }
body.has-cart .view { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 96px); }
@keyframes cart-in { from { opacity: 0; transform: translateY(12px); } }
@media (min-width: 900px) {
  .cart-bar { left: auto; right: 32px; bottom: 28px; width: 380px; }
  body.has-cart .view { padding-bottom: 120px; }
}

/* Cobrar el pedido */
.co-lines { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.co-line { padding: var(--sp-3); }
.co-line + .co-line { border-top: 1px solid var(--line); }
.co-name { font: var(--t-body); margin-bottom: var(--sp-2); }
.co-controls { display: flex; align-items: center; gap: var(--sp-2); }
.co-controls .qty-ctl button { width: 36px; height: 36px; font-size: 18px; }
.co-controls .qty-ctl b { min-width: 28px; text-align: center; }
.co-price { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.co-price span { color: var(--muted); font: var(--t-label); }
.co-price .input { min-height: 36px; padding: 6px 10px; }
.co-totals { margin-top: var(--sp-4); padding: var(--sp-3) var(--sp-4); border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.co-totals .kv { display: flex; justify-content: space-between; padding: 3px 0; }
.co-totals .kv.total { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 17px; }
.co-balance { margin-top: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: 12px; background: #fff6f3; color: var(--danger); border: 1px solid var(--danger-soft); }
.co-balance[hidden] { display: none; }
.warn-box { padding: var(--sp-3) var(--sp-4); border-radius: 12px; background: var(--warn-soft); color: #7a5a14; font: var(--t-label); margin-bottom: var(--sp-3); }
.choices-split.three .choices { grid-template-columns: repeat(3, 1fr); }
.choices-split.three .choice span { padding-left: 6px; padding-right: 6px; text-align: center; }

/* Ventas: estado de cada pedido */
.badge.owes { background: var(--danger-soft); color: var(--danger); }
.amt-col { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.stats-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-link { cursor: pointer; transition: border-color var(--d-fast, 150ms); }
.stat-link:hover { border-color: var(--gold); }
.debts-panel .sale { padding: var(--sp-2) 0; }
.od-line { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 6px 0; }
.od-line + .od-line { border-top: 1px solid var(--line); }
.od-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.od-actions .btn.danger { grid-column: 1 / -1; }
.toast-action { margin-left: var(--sp-3); padding: 4px 10px; border-radius: 8px; background: rgba(255, 255, 255, .18); color: #fff; font-weight: 600; }

/* Pérdidas y movimiento de productos */
.loss-box { margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px dashed var(--line); }
.loss-box summary { cursor: pointer; color: var(--danger); font: var(--t-label); font-weight: 600; }
.table-scroll { overflow-x: auto; }
.mv-table { width: 100%; border-collapse: collapse; font: var(--t-label); margin-top: var(--sp-3); }
.mv-table th { text-align: right; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.mv-table td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.mv-table th:first-child, .mv-table td:first-child { text-align: left; padding-left: 0; }
.mv-table tfoot td { font-weight: 700; border-bottom: 0; }

/* Boleta: tarjeta blanca como el ticket que se comparte */
.receipt-wrap { display: flex; justify-content: center; padding: var(--sp-2) 0; }
.rc { width: 100%; max-width: 360px; background: #fff; color: #1d1d1f; border: 1px solid var(--line); border-radius: 10px; padding: 22px 20px; box-shadow: var(--shadow); font: 400 14px/1.45 var(--font); }
.rc hr { border: 0; border-top: 1px dashed #c9ced8; margin: 12px 0; }
.rc-logo { display: block; width: 120px; margin: 0 auto 4px; }
.rc-sub { text-align: center; letter-spacing: .14em; font-size: 11px; font-weight: 600; color: var(--gold); }
.rc-place { text-align: center; font-size: 12px; color: var(--muted); margin-top: 2px; }
.rc-row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.rc-item { padding: 4px 0; }
.rc-item + .rc-item { border-top: 1px dotted #e1e4ea; }
.rc-small { font-size: 12px; color: var(--muted); }
.rc-small b { color: #1d1d1f; }
.rc-red { color: var(--danger); }
.rc-green { color: var(--success); }
.rc-big { font-size: 16px; font-weight: 700; }
.rc-phrase { text-align: center; font: italic 600 16px/1.35 var(--serif); color: var(--primary-dark); padding: 2px 8px; }
.receipt-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
/* Con un pedido abierto, los avisos salen encima de la barra del pedido. */
body.has-cart .toast { bottom: calc(var(--nav-h) + var(--safe-b) + 84px); }
@media (min-width: 900px) { body.has-cart .toast { bottom: 108px; } }
.pcard-stock.in-cart { color: var(--primary); }
