:root {
  --bg: #FAF6F0;
  --surface: #FFFFFF;
  --surface-2: #F5EEE4;
  --ink: #2E1A14;
  --ink-2: #6B5348;
  --muted: #9A887D;
  --line: #EADFD2;
  --line-2: #DCCDBB;
  --gold: #A87B22;
  --gold-2: #C9A24A;
  --gold-soft: #F5EBD6;
  --choco: #3B1F17;
  --ok: #2F7D4F;
  --ok-soft: #E3F1E8;
  --warn: #A86512;
  --warn-soft: #FBEEDB;
  --bad: #B42318;
  --bad-soft: #FBE4E1;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(59, 31, 23, .06), 0 6px 20px rgba(59, 31, 23, .06);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --nav-h: 68px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }
h1, h2, h3 { margin: 0; line-height: 1.15; }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.hide { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 14px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:hover { border-color: var(--gold-2); }
.btn.primary { background: var(--choco); border-color: var(--choco); color: #fff; }
.btn.primary:hover { background: #4d2a1f; }
.btn.gold { background: var(--gold-2); border-color: var(--gold-2); color: #2a1a0c; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.big { min-height: 56px; font-size: 17px; border-radius: 14px; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; pointer-events: none; }
.icon-btn { width: 44px; height: 44px; padding: 0; border-radius: 12px; border: 1px solid transparent; background: transparent; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Campos ---------- */
.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface); outline: none;
  font-size: 16px; /* evita el zoom en iPhone */
}
.input:focus { border-color: var(--gold-2); box-shadow: 0 0 0 3px var(--gold-soft); }
.input.huge { min-height: 64px; font-size: 28px; font-weight: 700; letter-spacing: .04em; text-align: center; }
.input.huge::placeholder { font-size: 17px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr; } }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; font-size: 14px;
}
.chip.on { background: var(--choco); color: #fff; border-color: var(--choco); }
.chip .dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; min-height: 38px; padding: 0 12px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h2 { font-family: var(--serif); font-size: 24px; font-weight: 700; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 22px; }
.kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--gold); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }

/* ---------- Esmalte (frasco) ---------- */
.bottle { flex: none; display: block; }
.sw { width: 22px; height: 22px; border-radius: 50%; flex: none; display: inline-block; background: var(--c, #ccc);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.14), inset -3px -4px 6px rgba(0,0,0,.12), inset 3px 3px 5px rgba(255,255,255,.35); }

/* ---------- Pantalla de PIN ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.login-logo { width: 150px; height: 150px; border-radius: 50%; object-fit: cover; margin: 0 auto 6px; display: block; mix-blend-mode: multiply; }
.login h1 { font-family: var(--serif); font-size: 30px; margin-bottom: 4px; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 22px 0 10px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gold-2); }
.pin-dots i.on { background: var(--gold-2); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.keypad button { height: 66px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); font-size: 26px; font-weight: 600; box-shadow: var(--shadow); }
.keypad button:active { background: var(--gold-soft); }
.keypad button.fn { font-size: 15px; background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-2); }
.pin-msg { min-height: 22px; color: var(--bad); font-weight: 600; font-size: 14px; }
.demo-hint { margin-top: 22px; font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }

/* ---------- Estructura ---------- */
.shell { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(250, 246, 240, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar .logo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; mix-blend-mode: multiply; }
.topbar .title { font-family: var(--serif); font-weight: 700; font-size: 21px; line-height: 1; }
.topbar .sub { font-size: 12px; color: var(--muted); }
/* Barra de arriba: el logo y el nombre del local al centro; la persona y el candado a la derecha */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.topbar .brand { display: flex; align-items: center; gap: 10px; justify-self: center; min-width: 0; }
.topbar .top-side.end { justify-self: end; display: flex; align-items: center; gap: 8px; }
/* Aviso de conexión: solo aparece si se cae el internet */
.sync { font-size: 12px; font-weight: 600; color: var(--warn); white-space: nowrap; line-height: 1.3; }
@media (max-width: 600px) {
  .topbar .user-chip .small { display: none; } /* en el celular, solo la inicial: deja espacio para centrar el logo */
  .topbar .user-chip { padding: 4px; }
}
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); font-weight: 700; font-size: 14px; }
main.view { padding: 18px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.view-head h1 { font-family: var(--serif); font-size: 32px; font-weight: 700; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border-radius: 12px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; min-width: 0; }
.nav a.on { color: var(--choco); }
.nav a.on svg { stroke: var(--gold); }
.nav a .badge-dot { position: absolute; top: -7px; right: -12px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10px; display: grid; place-items: center; }
.nav .ic { position: relative; display: flex; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 236px 1fr; }
  .topbar { grid-column: 1 / -1; }
  .nav { position: sticky; top: 61px; height: calc(100dvh - 61px); flex-direction: column; justify-content: flex-start; gap: 4px; border-top: 0; border-right: 1px solid var(--line); padding: 16px 12px; background: transparent; }
  .nav a { flex: none; flex-direction: row; gap: 12px; font-size: 15px; padding: 11px 14px; color: var(--ink-2); }
  .nav a.on { background: var(--surface); box-shadow: var(--shadow); }
  .nav a:hover { background: var(--surface); }
  main.view { padding: 26px 32px 48px; width: 100%; min-width: 0; } /* sin min-width:0, una fila larga de botones ensancha toda la página */
}

/* ---------- Escáner ---------- */
.scan-box { position: relative; border-radius: var(--radius); overflow: hidden; background: #1d1310; min-height: 210px; display: grid; place-items: center; color: #f3e9dc; }
/* Cámara: el video llena el cuadro y solo se lee lo que queda dentro del recuadro guía */
.scan-cam { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 62vh; background: #000; overflow: hidden; }
.scan-cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-guide { position: absolute; left: 8%; right: 8%; top: 20%; bottom: 20%; border: 2px solid rgba(255,255,255,.92); border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0,0,0,.38); pointer-events: none; }
.scan-guide i { position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: var(--gold-2); box-shadow: 0 0 10px var(--gold-2); animation: scan-g 2.2s ease-in-out infinite; }
@keyframes scan-g { 0%, 100% { transform: translateY(-28px); } 50% { transform: translateY(28px); } }
.scan-hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 13px; font-weight: 600; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.7); pointer-events: none; }
.scan-tools { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; z-index: 2; }
.scan-tool { border: 1px solid rgba(255,255,255,.55); background: rgba(0,0,0,.45); color: #fff; font: inherit; font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.scan-tool.on { background: var(--gold-2); border-color: var(--gold-2); color: #1d1310; }
@media (prefers-reduced-motion: reduce) { .scan-guide i { animation: none; } }
.scan-idle { text-align: center; padding: 22px; }
.scan-idle p { margin: 8px 0 14px; color: #d6c6b4; font-size: 14px; }
.scan-flash { position: absolute; inset: 0; background: rgba(201,162,74,.35); opacity: 0; pointer-events: none; transition: opacity .3s; }
.scan-flash.on { opacity: 1; transition: none; }
.scan-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: var(--gold-2); box-shadow: 0 0 12px var(--gold-2); animation: scan 2.2s ease-in-out infinite; pointer-events: none; }
@keyframes scan { 0%, 100% { transform: translateY(-50px); } 50% { transform: translateY(50px); } }
.scan-stop { position: absolute; right: 10px; top: 10px; z-index: 2; }
/* Campo de archivo invisible dentro de un botón (<label>). No se usa display:none: así lo abre bien Safari en iPhone. */
.file-hid { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }

/* ---------- Mosaico de productos ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 10px; }
.tile {
  position: relative; text-align: left; display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); min-height: 74px; width: 100%;
}
.tile:hover { border-color: var(--gold-2); }
.tile.match { border-color: var(--gold-2); box-shadow: 0 0 0 3px var(--gold-soft); }
.tile .code { font-size: 20px; font-weight: 800; letter-spacing: .02em; line-height: 1.05; }
.tile .name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.tile .meta { font-size: 11.5px; color: var(--muted); line-height: 1.25; }
.tile .stock { position: absolute; right: 8px; top: 8px; }
.tile .badge { white-space: normal; font-size: 11px; line-height: 1.25; }

.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li .t { font-weight: 600; }
.li .s { font-size: 12.5px; color: var(--muted); }
.li.void { opacity: .5; }
.li.void .t { text-decoration: line-through; }
.li.new { animation: newrow 1.6s ease-out; }
@keyframes newrow { from { background: var(--gold-soft); } to { background: transparent; } }

/* ---------- Lista de salida (carrito) ---------- */
.cart {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 25;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(59,31,23,.10);
  padding: 12px 16px; max-height: 60dvh; display: flex; flex-direction: column;
}
.cart-items { overflow-y: auto; margin: 6px 0 10px; }
.cart.collapsed .cart-items { display: none; }
.cart.collapsed { padding-top: 10px; }
.cart.collapsed #submitBtn { margin-top: 8px; }
.cart-toggle { border: 0; background: none; padding: 0; text-align: left; min-width: 0; }
.cart-toggle .tiny:not(.muted) { color: var(--gold); font-weight: 700; margin-left: 4px; }
.cart .li { padding: 8px 0; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; }
.stepper button { width: 40px; height: 40px; border: 0; background: var(--surface-2); font-size: 20px; font-weight: 700; }
.stepper input { width: 48px; height: 40px; border: 0; text-align: center; font-weight: 700; font-size: 16px; background: var(--surface); }
@media (min-width: 960px) { .cart { left: 236px; bottom: 0; } }
.spacer-cart { height: 170px; }

/* ---------- Panel ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
.kpi .v { font-size: 34px; font-weight: 700; font-family: var(--serif); line-height: 1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.kpi.alert .v { color: var(--bad); }
.cols { display: grid; gap: 16px; margin-top: 16px; }
.cols > *, .stack > * { min-width: 0; }
/* En una grilla, un hijo no se achica menos que su contenido salvo con min-width: 0. Sin esto, una tabla
   ancha (que debería moverse dentro de su caja) ensancha toda la página y la vista se ve corrida en el celular. */
.report-grid > *, .grid2 > *, .grid3 > *, .lot-grid > *, .more-grid > *, .kpis > *, .lot-facts > * { min-width: 0; }
.scan-idle svg.i { width: 34px; height: 34px; }
@media (min-width: 960px) { .cols { grid-template-columns: 1.25fr 1fr; align-items: start; } }

/* ---------- Gráficos ---------- */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(48px, 1fr) 36px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar-row .lab { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-track { height: 14px; background: var(--surface-2); border-radius: 0 4px 4px 0; position: relative; }
.bar-fill { height: 100%; background: var(--gold-2); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-row:hover .bar-fill { background: var(--gold); }
.trend { width: 100%; height: auto; display: block; }
.trend rect.col { fill: var(--gold-2); }
.trend rect.col:hover { fill: var(--gold); }
.trend text { font-size: 10px; fill: var(--muted); font-family: var(--sans); }
.trend line { stroke: var(--line); }
.tip { position: fixed; z-index: 100; pointer-events: none; background: var(--choco); color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap; }
.heat { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: 12px; }
.heat th { font-weight: 600; color: var(--ink-2); text-align: left; padding: 4px 6px; white-space: nowrap; }
.heat thead th { text-align: center; font-size: 11px; text-transform: capitalize; }
.heat td { text-align: center; height: 30px; min-width: 34px; border-radius: 4px; font-variant-numeric: tabular-nums; font-weight: 600; }
.heat-wrap { overflow-x: auto; }
.legend-seq { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend-seq i { width: 22px; height: 12px; border-radius: 3px; display: inline-block; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl-wrap { overflow-x: auto; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(46,26,20,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal { background: var(--bg); width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); animation: up .22s cubic-bezier(.2,.8,.2,1); }
.modal h2 { font-family: var(--serif); font-size: 26px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 22px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }

/* ---------- Avisos ---------- */
#toasts { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--choco); color: #fff; padding: 12px 14px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 600; display: flex; gap: 10px; align-items: center; animation: up .2s; pointer-events: auto; }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
.toast.warn { background: var(--warn); }
.done-overlay { position: fixed; inset: 0; z-index: 70; background: var(--ok); color: #fff; display: grid; place-items: center; text-align: center; padding: 24px; animation: fade .15s; }
.done-overlay .check { width: 84px; height: 84px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; margin: 0 auto 14px; }
.done-overlay h2 { font-family: var(--serif); font-size: 34px; }
.done-overlay .check svg { width: 44px; height: 44px; stroke-width: 2.4; }
.done-overlay .btn { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.4); }

/* ---------- Foto y color ---------- */
.photo-box { position: relative; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 1px dashed var(--line-2); }
.photo-box canvas { width: 100%; display: block; cursor: crosshair; touch-action: manipulation; }
.photo-box .ring { position: absolute; width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.5); transform: translate(-50%, -50%); pointer-events: none; }
.color-result { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.color-result .big-sw { width: 56px; height: 56px; border-radius: 14px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
input[type=color].input { padding: 4px; height: 46px; width: 64px; }

/* ---------- Etiquetas para imprimir ---------- */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.label { background: #fff; border: 1px dashed #bbb; border-radius: 10px; padding: 14px; text-align: center; break-inside: avoid; }
.label img, .label svg.qr { width: 150px; height: 150px; }
.label .brand { font-family: var(--serif); font-size: 24px; font-weight: 700; }
.labels.small { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.labels.small .label { padding: 8px; }
.labels.small svg { width: 150px; height: 70px; }

/* ---------- Impresión ---------- */
#print-area { display: none; }
@media print {
  body { background: #fff; }
  .topbar, .nav, .cart, .no-print, #toasts, .modal-bg { display: none !important; }
  .shell { display: block; }
  main.view { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
  body.print-doc .shell { display: none !important; }
  body.print-doc #print-area { display: block; }
  .bar-fill, .heat td, .sw, .big-sw, .chip .dot { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tile, .label { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.print-doc-inner { font-family: var(--sans); color: #222; padding: 10mm; }
.print-doc-inner h1 { font-family: var(--serif); font-size: 28px; }

/* ---------- Fotos ---------- */
.thumb { flex: none; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-photo { position: relative; display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.detail-photo img { width: 100%; max-height: 46dvh; object-fit: contain; display: block; background: #1d1310; }
.detail-photo span { position: absolute; right: 10px; bottom: 10px; display: inline-flex; gap: 6px; align-items: center; background: rgba(46,26,20,.8); color: #fff; font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 999px; }
.detail-photo.empty-photo { cursor: default; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px; }
.detail-photo.empty-photo span { position: static; background: none; color: var(--muted); padding: 0; font-weight: 500; }
.lightbox { position: fixed; inset: 0; z-index: 95; background: rgba(20,10,8,.94); display: grid; place-items: center; padding: 16px; animation: fade .15s; cursor: zoom-out; }
.lightbox figure { margin: 0; text-align: center; }
.lightbox img { max-width: 100%; max-height: 84dvh; border-radius: 12px; display: block; margin: 0 auto; }
.lightbox figcaption { color: #F3E9DC; font-weight: 600; margin-top: 10px; }
.lightbox .lb-close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; color: #fff; background: rgba(255,255,255,.12); }

@media (max-width: 520px) { .hide-sm { display: none; } }

/* ---------- Configuración inicial del dueño (una sola vez) ---------- */
.setup { min-height: 100vh; background: var(--bg); padding: 24px 16px 48px; }
.setup-box { max-width: 760px; margin: 0 auto; }
.setup-top { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.setup-logo { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; background: #fff; box-shadow: var(--shadow); flex: none; }
.setup-steps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.setup-steps span { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.setup-steps span.on { background: var(--choco); color: #fff; }
.setup-steps span.done { background: var(--gold-soft); color: var(--gold); }
.setup-h { font-family: var(--serif); font-size: 34px; line-height: 1.1; margin: 0; color: var(--choco); }
.setup-nav { justify-content: space-between; margin-top: 4px; }
.setup-prev { color: var(--ink-2); background: var(--gold-soft); border-radius: var(--radius-sm); padding: 8px 12px; }
.setup-prev:empty { display: none; }
.setup-person { display: grid; grid-template-columns: 1.4fr 1.2fr 92px auto; gap: 8px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
@media (max-width: 600px) {
  .setup-h { font-size: 28px; }
  .setup-person { grid-template-columns: 1fr 84px auto; }
  .setup-person select { grid-column: 1 / 3; grid-row: 2; }
}

/* Menú: nombre largo en la barra lateral (computadora), corto en la barra de abajo (celular) */
.nav .nl { display: none; }
@media (min-width: 960px) { .nav .nl { display: inline; } .nav .ns { display: none; } }

/* Etiquetas QR propias (productos sin código de barras), en pantalla y al imprimir */
.qr-labels { display: flex; flex-wrap: wrap; gap: 10px; }
.qr-label { width: 52mm; background: #fff; color: #222; border: 1px dashed #b9b0a6; border-radius: 10px; padding: 3mm; text-align: center; break-inside: avoid; page-break-inside: avoid; }
.qr-label .ql-brand { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #6b5348; }
.qr-label .ql-code { font-size: 20px; font-weight: 800; line-height: 1.15; }
.qr-label .ql-qr img, .qr-label .ql-qr svg { width: 34mm; height: 34mm; display: block; margin: 2mm auto; }
.qr-label .ql-name { font-size: 11px; font-weight: 600; }
.qr-label .ql-raw { font-size: 9px; color: #777; font-family: ui-monospace, monospace; margin-top: 1mm; }

/* =====================================================================
   ESTILO GLASS (vidrio esmerilado) con la paleta de La Guapa: crema, dorado y chocolate.
   1) Un fondo con manchas de color (dorado, caramelo, chocolate) detrás de todo: sin color atrás,
      el vidrio no se nota.
   2) Encima, "vidrios": blanco translúcido en degradado + desenfoque (backdrop-filter) + un borde
      blanco que brilla arriba (como el canto de un vidrio).
   Los mosaicos de productos (pueden ser muchos) no llevan desenfoque, para no poner lento el celular.
   ===================================================================== */
:root {
  --glass-1: rgba(255, 255, 255, .72);        /* parte clara del vidrio */
  --glass-2: rgba(255, 255, 255, .38);        /* parte transparente */
  --glass: linear-gradient(140deg, var(--glass-1) 0%, var(--glass-2) 100%);
  --glass-hi: linear-gradient(140deg, rgba(255, 255, 255, .86) 0%, rgba(255, 255, 255, .52) 100%);
  --glass-border: rgba(255, 255, 255, .70);
  --glass-edge: inset 0 1px 0 rgba(255, 255, 255, .95), inset 1px 0 0 rgba(255, 255, 255, .45), inset 0 -1px 0 rgba(255, 255, 255, .18);
  --blur: blur(26px) saturate(185%);
  --blur-sm: blur(12px) saturate(170%);
  --shadow: var(--glass-edge), 0 14px 40px rgba(59, 31, 23, .09);
  --shadow-sm: inset 0 1px 0 rgba(255, 255, 255, .9), 0 4px 14px rgba(59, 31, 23, .07);
  --shadow-lift: var(--glass-edge), 0 20px 50px rgba(59, 31, 23, .2);
}
body { background: #FAF4EC; }
/* Fondo fijo con manchas de color (un elemento aparte: así también se ve bien en iPhone) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(44vmax 44vmax at 6% 4%, rgba(214, 178, 96, .42), transparent 62%),
    radial-gradient(36vmax 36vmax at 96% 12%, rgba(232, 196, 150, .40), transparent 62%),
    radial-gradient(42vmax 42vmax at 55% 45%, rgba(255, 252, 246, .95), transparent 66%),
    radial-gradient(48vmax 48vmax at 84% 96%, rgba(201, 162, 74, .30), transparent 62%),
    radial-gradient(42vmax 42vmax at 0% 92%, rgba(168, 123, 34, .14), transparent 64%),
    linear-gradient(160deg, #FDF9F3 0%, #F8EFE3 52%, #FBF5EC 100%);
}
/* Vidrios grandes: con desenfoque */
.card, .topbar, .nav, .cart, .modal, .subtabs, .kpi, .user-chip, .lot-row, .more-item {
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.chip, .btn, .seg, .input, select.input, .keypad button {
  -webkit-backdrop-filter: var(--blur-sm); backdrop-filter: var(--blur-sm);
}
.card { background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--shadow); border-radius: 22px; }
.card.flat { background: linear-gradient(140deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, .2)); box-shadow: var(--glass-edge), 0 8px 26px rgba(59, 31, 23, .08); }
.kpi { background: var(--glass-hi); border: 1px solid var(--glass-border); box-shadow: var(--shadow); border-radius: 20px; }
.card .kpi { box-shadow: var(--shadow-sm); }
a.kpi:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.kpi .v { color: var(--choco); }
.tile { background: linear-gradient(140deg, rgba(255, 255, 255, .78), rgba(255, 255, 255, .38)); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); }
.tile:hover { background: linear-gradient(140deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, .6)); border-color: var(--gold-2); }
.btn { background: linear-gradient(140deg, rgba(255, 255, 255, .7), rgba(255, 255, 255, .34)); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); }
.btn:hover { background: linear-gradient(140deg, rgba(255, 255, 255, .92), rgba(255, 255, 255, .55)); border-color: var(--glass-border); }
.btn.primary { background: linear-gradient(160deg, rgba(92, 52, 38, .95) 0%, rgba(59, 31, 23, .92) 100%); border-color: rgba(255, 255, 255, .25); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 8px 22px rgba(59, 31, 23, .3); }
.btn.primary:hover { background: linear-gradient(160deg, rgba(108, 62, 45, .97), rgba(70, 38, 28, .95)); }
.btn.gold { background: linear-gradient(160deg, #E2C277 0%, #C9A24A 100%); border-color: rgba(255, 255, 255, .5); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 8px 22px rgba(168, 123, 34, .3); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.btn.ghost:hover { background: rgba(255, 255, 255, .45); }
.done-overlay .btn { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .4); box-shadow: none; }
.input, select.input, textarea.input { background: rgba(255, 255, 255, .5); border: 1px solid var(--glass-border); box-shadow: inset 0 1px 3px rgba(59, 31, 23, .07); }
.input::placeholder { color: rgba(107, 83, 72, .7); }
.input:focus { background: rgba(255, 255, 255, .86); border-color: var(--gold-2); box-shadow: 0 0 0 4px rgba(201, 162, 74, .22); }
.chip { background: linear-gradient(140deg, rgba(255, 255, 255, .66), rgba(255, 255, 255, .3)); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); }
.chip.on { background: linear-gradient(160deg, rgba(92, 52, 38, .95), rgba(59, 31, 23, .92)); border-color: rgba(255, 255, 255, .25); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 6px 16px rgba(59, 31, 23, .25); }
.seg { background: rgba(255, 255, 255, .32); border: 1px solid var(--glass-border); }
.seg button.on { background: rgba(255, 255, 255, .9); box-shadow: var(--shadow-sm); }
.user-chip { background: var(--glass-hi); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); }
.color-result, .photo-box { background: rgba(255, 255, 255, .45); border-color: var(--glass-border); }
.stepper { border-color: var(--glass-border); background: rgba(255, 255, 255, .4); }
.stepper button { background: rgba(255, 255, 255, .45); }
.stepper input { background: rgba(255, 255, 255, .75); }
.topbar { background: linear-gradient(180deg, rgba(255, 252, 247, .7), rgba(255, 252, 247, .4)); border-bottom: 1px solid rgba(255, 255, 255, .6); box-shadow: 0 6px 24px rgba(59, 31, 23, .08); }
.nav { background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--shadow); }
.nav a { color: var(--ink-2); }
.cart { background: linear-gradient(150deg, rgba(255, 252, 247, .8), rgba(255, 248, 238, .58)); border: 1px solid var(--glass-border); box-shadow: var(--glass-edge), 0 -10px 40px rgba(59, 31, 23, .16); }
.modal-bg { background: rgba(46, 26, 20, .22); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal { background: linear-gradient(150deg, rgba(255, 252, 247, .80), rgba(255, 248, 238, .60)); border: 1px solid var(--glass-border); box-shadow: var(--glass-edge), 0 30px 80px rgba(46, 26, 20, .3); -webkit-backdrop-filter: blur(32px) saturate(185%); backdrop-filter: blur(32px) saturate(185%); }
.modal .card, .modal .kpi { background: var(--glass-hi); }
.toast { box-shadow: 0 14px 34px rgba(0, 0, 0, .22); }
.tbl th { border-bottom-color: rgba(255, 255, 255, .7); color: var(--ink-2); }
.tbl td { border-bottom-color: rgba(255, 255, 255, .55); }
.tbl tbody tr:hover td { background: rgba(255, 255, 255, .28); }
.li { border-bottom-color: rgba(255, 255, 255, .55); }
.bar-track { background: rgba(255, 255, 255, .45); box-shadow: inset 0 1px 2px rgba(59, 31, 23, .08); }
.bar-fill { background: linear-gradient(90deg, #D9B866, #B88E35); }
.trend rect.col { fill: #C9A24A; }
.badge { background: rgba(255, 255, 255, .5); }
.setup { background: transparent; }
.setup .card { background: var(--glass-hi); }
/* Pantalla del PIN: teclas de vidrio */
.login-box { background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--shadow); border-radius: 28px; padding: 26px 20px; -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.login-logo { mix-blend-mode: normal; box-shadow: 0 8px 24px rgba(59, 31, 23, .15); }
.keypad button { background: linear-gradient(140deg, rgba(255, 255, 255, .72), rgba(255, 255, 255, .32)); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); }
.keypad button:active { background: rgba(245, 235, 214, .9); }
.keypad button.fn { background: transparent; box-shadow: none; border-color: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.demo-hint { background: rgba(255, 255, 255, .45); }
.topbar .logo { mix-blend-mode: normal; box-shadow: 0 4px 12px rgba(59, 31, 23, .15); }

/* Celular: menú de abajo y lista flotantes, como piezas de vidrio */
@media (max-width: 959px) {
  .nav { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); padding: 6px 4px; border-radius: 26px; }
  .nav a.on { background: rgba(255, 255, 255, .7); box-shadow: var(--shadow-sm); }
  .cart { left: 10px; right: 10px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); border-radius: 24px; }
  main.view { padding-bottom: calc(var(--nav-h) + 44px + env(safe-area-inset-bottom)); }
}
@media (min-width: 960px) {
  /* Menú lateral: un panel de vidrio flotante */
  .nav { top: 73px; height: calc(100dvh - 85px); margin: 0 0 12px 12px; border-radius: 24px; padding: 14px 10px; }
  .nav a.on { background: rgba(255, 255, 255, .78); box-shadow: var(--shadow-sm); color: var(--choco); }
  .nav a:hover { background: rgba(255, 255, 255, .5); }
  .cart { left: 248px; right: 12px; bottom: 12px; border-radius: 22px; }
}
/* Si el equipo no soporta el desenfoque, o la persona pidió menos transparencia: fondos más sólidos */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card, .nav, .topbar, .cart, .modal, .subtabs, .kpi, .login-box { background: rgba(255, 252, 247, .94); }
}
@media (prefers-reduced-transparency: reduce) {
  .card, .nav, .topbar, .cart, .modal, .subtabs, .kpi, .login-box, .lot-row, .more-item { background: #FFFCF7; -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ---------- Pestañas dentro de cada sección ---------- */
.subtabs {
  display: flex; gap: 4px; padding: 4px; margin: 0 0 18px; width: max-content; max-width: 100%; overflow-x: auto; scrollbar-width: none;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 16px; box-shadow: var(--shadow);
}
.subtabs::-webkit-scrollbar { display: none; }
.subtabs a { flex: none; padding: 9px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.subtabs a:hover { background: rgba(255, 255, 255, .5); }
.subtabs a.on { background: linear-gradient(160deg, rgba(92, 52, 38, .95), rgba(59, 31, 23, .92)); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 6px 16px rgba(59, 31, 23, .25); }

/* ---------- "Más" en el celular ---------- */
.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.more-item { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 18px; background: var(--glass-hi); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); text-decoration: none; color: var(--ink); }
.more-item svg.i { stroke: var(--gold); width: 24px; height: 24px; margin-bottom: 4px; }
.more-item b { font-size: 15px; }
.more-item span { font-size: 12px; color: var(--muted); line-height: 1.3; }

/* ---------- Ingreso por lote ---------- */
.lot-card { margin-bottom: 16px; }
.lot-target { margin-bottom: 12px; }
.lot-target select { font-weight: 600; }
.lot-target-hint { display: flex; gap: 8px; align-items: flex-start; margin: -2px 0 12px; padding: 10px 12px; border-radius: 14px; background: rgba(245, 230, 198, .7); border: 1px solid rgba(201, 162, 74, .45); color: var(--choco); font-size: 13.5px; }
.lot-target-hint svg.i { stroke: var(--gold); flex: none; margin-top: 1px; }
.input:disabled { opacity: .75; background: rgba(245, 238, 228, .6); }
.lot-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .lot-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 460px) { .lot-grid { gap: 10px; } .lot-grid > :first-child, .lot-grid > :last-child { grid-column: 1 / -1; } }
.cost-in { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 700; flex: none; }
.cost-in input { width: 78px; height: 40px; border: 1px solid var(--line-2); border-radius: 10px; text-align: right; padding: 0 8px; font-weight: 700; font-size: 16px; background: rgba(255, 255, 255, .9); }
.cost-in input:focus { outline: none; border-color: var(--gold-2); box-shadow: 0 0 0 3px var(--gold-soft); }
@media (max-width: 560px) {
  .cart .li { flex-wrap: wrap; }
  .cart .li > .grow { flex-basis: calc(100% - 60px); }
  .cart .li .cost-in { margin-left: 58px; flex-direction: row; align-items: center; gap: 6px; }
  .cart .li .stepper { margin-left: auto; }
}
.lot-details { border: 1px dashed rgba(168, 123, 34, .35); border-radius: 16px; padding: 6px 12px 10px; background: rgba(255, 255, 255, .3); }
.lot-details summary { cursor: pointer; font-weight: 600; color: var(--ink-2); padding: 6px 0; }

/* ---------- Lotes y facturas ---------- */
.lot-list { display: flex; flex-direction: column; gap: 8px; }
.lot-row { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 12px 14px; border-radius: 18px; border: 1px solid var(--glass-border); background: var(--glass); box-shadow: var(--shadow-sm); color: inherit; }
.lot-row:hover { border-color: var(--gold-2); background: var(--glass-hi); }
.lot-row.void { opacity: .55; }
.lot-row .t { font-weight: 600; }
.lot-row .s { font-size: 12.5px; color: var(--muted); }
.lot-id { display: flex; flex-direction: column; min-width: 92px; }
.lot-id b { font-size: 15px; }
.lot-money { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; flex: none; }
.lot-money b { font-size: 16px; font-variant-numeric: tabular-nums; }
.use-bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .5); margin-top: 7px; overflow: hidden; max-width: 280px; }
.use-bar i { display: block; height: 100%; background: var(--gold-2); border-radius: 3px; }
.lot-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.lot-facts > div { background: var(--glass-hi); box-shadow: var(--shadow-sm); border: 1px solid var(--glass-border); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lot-facts span { font-size: 12px; color: var(--muted); font-weight: 600; }
.cost-edit { width: 90px; min-height: 38px; text-align: right; padding: 6px 8px; }
@media (max-width: 560px) {
  .lot-facts { grid-template-columns: 1fr 1fr; }
  .lot-row { gap: 10px; padding: 11px 12px; }
  .lot-id { min-width: 66px; }
}

/* ---------- Reporte a medida ---------- */
.report-builder > div + div { margin-top: 14px; }
.rb-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
.wrap-chips { flex-wrap: wrap; overflow: visible; }
.chip svg.i { width: 15px; height: 15px; }
.ghost-chip { background: linear-gradient(140deg, rgba(245, 225, 180, .85), rgba(232, 200, 140, .45)); border-color: rgba(255, 255, 255, .7); color: var(--choco); }
.report-grid { display: grid; gap: 16px; }
/* Resumen en tablas, con jerarquía: bloque (título + totales) > grupo (marca o lote) > producto */
.sum-block { margin-top: 14px; padding: 14px 14px 8px; border-radius: 20px; background: linear-gradient(140deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, .22)); border: 1px solid var(--glass-border); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9); }
.sum-top { display: flex; align-items: center; gap: 12px; padding: 2px 2px 12px; margin-bottom: 6px; border-bottom: 1px solid rgba(168, 123, 34, .28); }
.sum-top h3 { font-family: var(--serif); font-size: 24px; font-weight: 700; color: var(--choco); line-height: 1.1; }
.sum-ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 6px 14px rgba(59, 31, 23, .18); }
.sum-ic svg.i { width: 22px; height: 22px; stroke-width: 2.2; }
.sum-ic.out { background: linear-gradient(160deg, #E2C277, #C9A24A); color: #2a1a0c; }
.sum-ic.in { background: linear-gradient(160deg, #5C3426, #3B1F17); color: #fff; }
.sum-totals { display: flex; gap: 20px; text-align: right; flex: none; }
.sum-totals b { display: block; font-family: var(--serif); font-size: 30px; font-weight: 700; line-height: 1; color: var(--choco); font-variant-numeric: tabular-nums; }
.sum-totals span { display: block; margin-top: 3px; font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.sum-tbl { border-collapse: separate; border-spacing: 0; }
.sum-tbl th { font-size: 10.5px; padding: 6px 10px; border-bottom: 0; color: var(--muted); }
/* nivel 2: la marca o el lote */
.sum-tbl tr.grp td { background: #F8EEDA; color: var(--choco); font-weight: 700; font-size: 15px; padding: 11px 10px; border-bottom: 0; border-top: 10px solid transparent; background-clip: padding-box; font-variant-numeric: tabular-nums; }
.sum-tbl tbody tr.grp:first-child td { border-top-width: 2px; }
.sum-tbl tr.grp td:first-child { border-radius: 12px 0 0 12px; box-shadow: inset 4px 0 0 var(--gold-2); padding-left: 14px; }
.sum-tbl tr.grp td:last-child { border-radius: 0 12px 12px 0; }
/* tapa la rayita de un píxel que queda entre celdas de la franja */
.sum-tbl tr.grp td:not(:first-child) { box-shadow: -1px 0 0 #F8EEDA; }
.grp-name { margin-right: 8px; }
.grp-meta { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.lot-pill { display: inline-block; margin-right: 8px; padding: 2px 8px; border-radius: 8px; background: var(--choco); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .02em; vertical-align: 1px; }
/* nivel 3: cada producto */
.sum-tbl tr.item td { font-size: 13.5px; color: var(--ink-2); padding: 8px 10px; border-bottom: 1px solid rgba(255, 255, 255, .6); }
.sum-tbl tr.item td:first-child { padding-left: 30px; }
.sum-tbl tr.item td b { color: var(--ink); }
.sum-tbl tr.item:last-child td { border-bottom: 0; }
.mob-tone, .mob-line { display: none; align-items: center; gap: 4px; }
@media (max-width: 600px) {
  /* la columna sigue existiendo (si se quita, las cifras de la marca y de sus productos dejan de alinearse); solo se vacía */
  .sum-tbl .col-color { width: 0; padding: 0; font-size: 0; }
  .sum-tbl .col-color > * { display: none; }
  .mob-tone { display: inline-flex; vertical-align: -1px; }
  .mob-line { display: inline; }
  .sum-top { flex-wrap: wrap; }
  .sum-top .grow { flex-basis: calc(100% - 56px); }
  .sum-totals { width: 100%; justify-content: flex-start; gap: 26px; text-align: left; padding-left: 54px; }
  .sum-totals b { font-size: 26px; }
  .sum-tbl tr.item td:first-child { padding-left: 18px; }
  .sum-tbl tr.grp td { font-size: 14px; }
}
.report-grid .kpis { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .report-grid .kpis { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Rendimiento ----------
   El desenfoque (backdrop-filter) es lo que más trabajo le da a un celular, sobre todo al hacer scroll,
   y cuando hay uno dentro de otro (un botón con desenfoque dentro de una tarjeta con desenfoque) se multiplica.
   - En el celular: desenfoque solo en las barras fijas (arriba, menú de abajo, lista) y en las ventanas.
     Las tarjetas usan un vidrio un poco más blanco sin desenfoque: sobre el fondo claro se ven casi igual.
   - En la computadora: desenfoque en las piezas grandes; botones, chips y campos van sin él (ya están
     encima de una tarjeta de vidrio). */
.chip, .btn, .seg, .input, select.input, .kpi, .lot-row, .more-item, .user-chip, .keypad button { -webkit-backdrop-filter: none; backdrop-filter: none; }
@media (max-width: 959px) {
  .card, .subtabs, .login-box { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .card { background: linear-gradient(140deg, rgba(255, 255, 255, .84), rgba(255, 255, 255, .6)); }
  .card.flat { background: linear-gradient(140deg, rgba(255, 255, 255, .74), rgba(255, 255, 255, .48)); }
  .subtabs { background: linear-gradient(140deg, rgba(255, 255, 255, .86), rgba(255, 255, 255, .62)); }
  .login-box { background: linear-gradient(140deg, rgba(255, 255, 255, .82), rgba(255, 255, 255, .58)); }
  .kpi { background: linear-gradient(140deg, rgba(255, 255, 255, .94), rgba(255, 255, 255, .7)); }
  .topbar, .nav, .cart { -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%); }
  .modal { -webkit-backdrop-filter: blur(16px) saturate(160%); backdrop-filter: blur(16px) saturate(160%); background: linear-gradient(150deg, rgba(255, 252, 247, .94), rgba(255, 248, 238, .84)); }
  .modal-bg { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(46, 26, 20, .34); }
}

/* ---------- Celulares chicos: aprovechar el ancho ----------
   Márgenes laterales iguales a los dos lados (la vista queda centrada) y tablas del resumen más compactas. */
@media (max-width: 600px) {
  main.view { padding-left: 12px; padding-right: 12px; }
  .card { padding: 14px; }
  .sum-block { padding: 10px 6px 6px; }
  .sum-tbl .bottle { display: none; }
  .sum-tbl td, .sum-tbl th { padding-left: 6px; padding-right: 6px; }
  .sum-tbl tr.item td:first-child { padding-left: 14px; }
  .sum-tbl tr.grp td:first-child { padding-left: 12px; }
  .grp-meta { display: block; font-size: 11.5px; margin-top: 1px; }
}

/* ---------- Etiquetas QR: elegir cuáles imprimir ---------- */
.qr-pick { display: flex; flex-direction: column; gap: 8px; }
.qr-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: linear-gradient(140deg, rgba(255, 255, 255, .82), rgba(255, 255, 255, .55)); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); cursor: pointer; }
.qr-item.on { border-color: var(--gold-2); background: linear-gradient(140deg, rgba(255, 250, 238, .95), rgba(247, 236, 212, .8)); }
.qr-item .t { font-weight: 600; }
.qr-item .s { font-size: 12.5px; color: var(--muted); }
.qr-check { flex: none; width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--line-2); background: rgba(255, 255, 255, .9); display: grid; place-items: center; padding: 0; color: #fff; }
.qr-item.on .qr-check { background: var(--choco); border-color: var(--choco); }
.qr-check svg.i { width: 17px; height: 17px; stroke-width: 2.6; }
.qr-thumb { flex: none; width: 40px; display: grid; place-items: center; }
.qr-sec { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); }
.stepper.sm button { width: 34px; height: 34px; font-size: 18px; }
.stepper.sm input { width: 38px; height: 34px; font-size: 15px; }
.pill-n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--gold-2); color: #2a1a0c; font-size: 11.5px; font-weight: 800; }
@media (max-width: 600px) {
  .qr-item { flex-wrap: wrap; gap: 10px; }
  .qr-item > .grow { flex-basis: calc(100% - 100px); }
  .qr-item .stepper { margin-left: 38px; }
}

/* =====================================================================
   Etapa 1, mejora 3: que todo se pueda tocar y leer sin esfuerzo
   ===================================================================== */
/* Gris de los textos secundarios: antes #9A887D (contraste ~3:1 sobre el fondo claro); ahora ~5:1 */
:root { --muted: #776358; }
/* En pantallas táctiles, todo lo que se toca mide al menos 44 px de alto (mínimo de Apple; Android pide 48) */
@media (pointer: coarse) {
  .chip, .btn, .btn.sm, .seg button { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .stepper button, .stepper.sm button { width: 44px; height: 44px; }
  .stepper input, .stepper.sm input { height: 44px; }
  .cost-in input { height: 44px; }
  .scan-tool { min-height: 40px; padding: 8px 14px; }
  /* la casilla de las etiquetas se ve chica, pero se puede tocar en un área de 44 px */
  .qr-check { position: relative; }
  .qr-check::after { content: ""; position: absolute; inset: -8px; }
  /* casillas de marcar: más grandes y fáciles de acertar */
  input[type=checkbox] { width: 26px !important; height: 26px !important; accent-color: var(--choco); }
}
/* En el celular, los textos secundarios suben un punto */
@media (max-width: 600px) {
  .small { font-size: 14px; }
  .tiny { font-size: 13px; }
  .li .s, .lot-row .s, .qr-item .s { font-size: 13.5px; }
  .kpi .l { font-size: 14px; }
  .nav a { font-size: 12px; }
}

/* Etapa 1, mejora 4: los errores tienen botón para cerrarlos (no se van solos) */
.toast-x { flex: none; margin-left: auto; width: 36px; height: 36px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .18); color: #fff; display: grid; place-items: center; padding: 0; }
.toast-x:hover { background: rgba(255, 255, 255, .3); }
@media (pointer: coarse) { .toast-x { width: 44px; height: 44px; } }

/* Etapa 1, mejora 5: confirmación sin interrumpir (barra abajo con «Deshacer») */
.done-bar {
  position: fixed; z-index: 65; left: 10px; right: 10px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; border-radius: 20px;
  background: var(--choco); color: #fff; box-shadow: 0 14px 40px rgba(46, 26, 20, .35); animation: up .2s;
}
.done-bar .done-ic { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--ok); display: grid; place-items: center; }
.done-bar .done-ic svg.i { width: 20px; height: 20px; stroke-width: 2.6; }
.done-bar .done-sub { font-size: 13px; color: rgba(255, 255, 255, .78); }
.done-bar .btn { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .35); box-shadow: none; flex: none; }
@media (min-width: 960px) { .done-bar { left: 248px; right: auto; bottom: 18px; min-width: 420px; } }

/* Filas de botones (marcas, tonos, periodos…). Con el dedo se deslizan de lado; con mouse no se pueden
   arrastrar y la barra de desplazamiento está oculta, así que los del final quedaban fuera de alcance.
   En equipos con mouse se acomodan en varias líneas y se ven todos. */
@media (hover: hover) and (pointer: fine) {
  .chips { flex-wrap: wrap; overflow: visible; row-gap: 8px; }
}

/* ---------- Pedidos: marcas que se abren de a una (Armar pedido e Historial) ---------- */
.ord-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.ord-tools .chips { padding-bottom: 0; }
.ord-list { display: flex; flex-direction: column; gap: 10px; }
.ord-brand { border-radius: 18px; background: linear-gradient(140deg, rgba(255, 255, 255, .84), rgba(255, 255, 255, .6)); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); overflow: hidden; }
.ord-brand.sel { border-color: var(--gold-2); box-shadow: 0 0 0 1px var(--gold-2), var(--shadow-sm); }
.ord-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; min-height: 60px; }
.ord-head:focus-visible { outline: 3px solid var(--gold-2); outline-offset: -3px; border-radius: 18px; }
.ord-name { font-weight: 700; font-size: 16px; color: var(--choco); }
.ord-meta { font-size: 13px; color: var(--muted); }
.ord-status { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.ord-count { flex: none; text-align: right; font-size: 13px; color: var(--ink-2); line-height: 1.25; }
.ord-count b { font-size: 17px; color: var(--choco); font-variant-numeric: tabular-nums; }
.ord-count span { display: block; font-size: 12px; color: var(--muted); }
.ord-chev { flex: none; display: grid; place-items: center; width: 28px; height: 28px; color: var(--muted); transition: transform .2s; }
.ord-brand.open .ord-chev { transform: rotate(90deg); }
.ord-check { flex: none; position: relative; width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--line-2); background: rgba(255, 255, 255, .9); display: grid; place-items: center; padding: 0; color: #fff; }
.ord-check::after { content: ""; position: absolute; inset: -8px; }
.ord-check:disabled { opacity: .35; }
.ord-brand.sel .ord-check { background: var(--choco); border-color: var(--choco); }
.ord-check svg.i { width: 17px; height: 17px; stroke-width: 2.6; }
.ord-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid rgba(234, 223, 210, .8); padding-top: 12px; }
.ord-foot { padding: 0 14px 12px; }
.ord-rows { display: flex; flex-direction: column; }
.ord-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(234, 223, 210, .7); }
.ord-row:last-child { border-bottom: 0; }
.ord-row.off { opacity: .45; }
.ord-row .t { font-weight: 600; }
.ord-row .s { font-size: 13px; color: var(--muted); }
.ord-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--choco); flex: none; }
.ord-qty { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none; }
.stk { display: inline-block; padding: 1px 7px; border-radius: 6px; background: rgba(245, 238, 228, .9); color: var(--ink-2); font-weight: 700; font-size: 12px; margin-right: 4px; }
.stk.bad { background: var(--bad-soft); color: var(--bad); }
.hist-brand { padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, .55); border: 1px solid var(--glass-border); }
@media (max-width: 600px) {
  .ord-head { gap: 10px; padding: 12px; }
  .ord-row { flex-wrap: wrap; }
  .ord-row > .grow { flex-basis: calc(100% - 80px); }
  .ord-row .ord-qty { margin-left: auto; flex-direction: row; gap: 8px; }
}
/* Barra de abajo de «Armar pedido»: compacta, en una sola línea, para no tapar la lista */
.cart.ord-bar { flex-direction: row; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; }
.ord-bar #genBtn { flex: none; min-height: 48px; }
.linkbtn { border: 0; background: none; padding: 2px 0; color: var(--gold); font-size: 12.5px; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
/* Categorías de productos */
.cat-tag { display: inline-block; padding: 1px 7px; margin-right: 4px; border-radius: 6px; background: var(--gold-soft); color: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.cat-li { gap: 10px; }
.cat-li .input { flex: 1; min-width: 0; }
.cat-pick { max-height: min(52vh, 460px); overflow-y: auto; }
/* Panel: los productos se tocan para ver su ficha con la foto */
.tap[role="button"] { cursor: pointer; border-radius: 12px; transition: background-color .15s ease; -webkit-tap-highlight-color: transparent; }
.tap[role="button"]:active { background: rgba(168, 123, 34, .1); }
.tap[role="button"]:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .tap[role="button"]:hover { background: rgba(168, 123, 34, .07); } }
.ord-chev.on { transform: rotate(90deg); }
.staff-items { margin: 2px 0 8px 22px; padding-left: 10px; border-left: 2px solid var(--gold-soft); }
/* Movimientos: rango de fechas «Desde / Hasta» */
.range-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; max-width: 520px; }
.range-row.hide { display: none; }
.range-row .input { width: 100%; min-width: 0; }
@media (max-width: 480px) { .range-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .range-row .btn { grid-column: 1 / -1; } }
/* Existencias y Catálogo: primero se elige la categoría */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
.cat-card { display: grid; justify-items: start; gap: 2px; min-height: 112px; padding: 14px; border-radius: 18px; text-align: left; cursor: pointer;
  background: var(--glass-hi, rgba(255, 255, 255, .8)); border: 1px solid var(--glass-border, rgba(255, 255, 255, .9)); box-shadow: var(--shadow-sm, 0 2px 10px rgba(59, 31, 23, .06));
  transition: transform .15s ease, box-shadow .15s ease; -webkit-tap-highlight-color: transparent; }
.cat-card:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) { .cat-card:hover { box-shadow: 0 10px 28px rgba(59, 31, 23, .12); } }
.cat-card:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.cat-card b { font-size: 15.5px; line-height: 1.25; margin-top: 6px; }
.cat-sample { display: flex; gap: 2px; min-height: 34px; align-items: flex-end; }
.pick-hint { margin: 4px 2px 12px; }

/* Botón «?» de arriba a la izquierda: abre el manual de uso de quien entró */
.help-btn { justify-self: start; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; text-decoration: none; font-weight: 800; font-size: 17px; color: var(--gold); background: rgba(255, 255, 255, .8); border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(59, 31, 23, .08); -webkit-tap-highlight-color: transparent; }
.help-btn:active { transform: scale(.94); }
.help-btn:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }

/* ---------- Caja ---------- */
.caja-quick-grid { display: grid; grid-template-columns: 1fr 140px; gap: 12px; }
@media (max-width: 420px) { .caja-quick-grid { grid-template-columns: 1fr 110px; } }
.caja-row .badge { white-space: normal; }
.caja-math > div { display: flex; justify-content: space-between; padding: 6px 2px; border-bottom: 1px dashed var(--line); font-size: 14px; color: var(--ink-2); }
.caja-math > div.tot { border-bottom: 0; color: var(--choco); font-size: 16px; font-weight: 700; padding-top: 10px; }
.caja-done, .caja-pending, .caja-closed { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; margin-top: 12px; font-size: 14px; }
.caja-done { background: var(--ok-soft); color: var(--ink); }
.caja-done > .i { color: var(--ok); flex: none; }
.caja-done.big, .caja-pending { margin-top: 0; }
.caja-pending { background: var(--gold-soft); }
.caja-pending > .i { color: var(--gold); flex: none; }
.caja-closed { background: var(--surface-2); margin: 0 0 12px; }
@media (max-width: 600px) { .caja-pending, .caja-done.big { flex-wrap: wrap; } }
.caja-week tr.tap { cursor: pointer; }
.caja-week tr.tap:hover td { background: var(--surface-2); }
.caja-week td.pay { font-size: 16px; }
.caja-week tr.tot td { border-top: 2px solid var(--gold-2); font-weight: 700; }
.caja-week tr.detail td { background: var(--surface-2); padding: 10px 12px; }
.caja-detail { display: grid; gap: 10px; }
.cd-day .kicker { margin-bottom: 4px; }
.cd-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.cd-row:last-child { border-bottom: 0; }
.caja-dxw tr.grp td { background: var(--gold-soft); font-weight: 700; color: var(--choco); }
.caja-dxw tr.sub td:first-child { padding-left: 24px; color: var(--ink-2); }
/* Explorador de reportes de caja */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 16px 0 12px; font-size: 14px; }
.crumbs a { color: var(--gold); font-weight: 600; text-decoration: none; padding: 4px 2px; }
.crumbs a:hover { text-decoration: underline; }
.crumbs b { color: var(--choco); }
.crumbs .sep .i { width: 14px; height: 14px; color: var(--muted); vertical-align: middle; }
a.li.drill { text-decoration: none; color: inherit; cursor: pointer; }
a.li.drill:hover { background: var(--surface-2); border-radius: 10px; }
.li.drill.dim { opacity: .55; }
.drill-r { text-align: right; white-space: nowrap; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pager .btn.disabled { opacity: .4; pointer-events: none; }
