/* Emporium POS · diseño mobile-first (referencia 360 px), tema negro/carbón con detalles dorados */
:root {
  --bg: #0e0e10;
  --surface: #18181b;
  --surface-2: #222226;
  --surface-3: #2c2c31;
  --line: #34343a;
  --text: #f6f6f7;
  --muted: #a3a3ad;
  --gold: #f5a524;
  --gold-2: #ffcf6b;
  --gold-ink: #1a1203;
  --ok: #34d399;
  --ok-bg: #0f2a20;
  --danger: #f87171;
  --danger-bg: #2d1414;
  --warn: #fbbf24;
  --info: #60a5fa;
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --nav-h: calc(64px + var(--safe-b));
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text-2, var(--gold-2)); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.gold { color: var(--accent-text, var(--gold)); }
.ok { color: var(--ok); }
.danger { color: var(--danger); }
.warn { color: var(--warn); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot img { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; transform: scale(.97); } }

/* --- Estructura --- */
.screen { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + 16px); }
.screen.no-nav { padding-bottom: 24px; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(14, 14, 16, .94); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: calc(8px + var(--safe-t)) 0 8px;
}
.topbar .wrap { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.topbar h1 { font-size: 1.1rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; flex: none; position: relative;
}
.icon-btn svg { width: 22px; height: 22px; }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; display: grid; place-items: center;
}
.context-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: .82rem; color: var(--muted); white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; }
.chip.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .2); }

/* Barra inferior (navegación con una mano) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: var(--nav-h); padding-bottom: var(--safe-b);
  background: rgba(20, 20, 23, .97); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(var(--items, 4), 1fr);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; position: relative;
}
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav a.active { color: var(--accent-text, var(--gold)); }
.bottom-nav a .badge { top: 6px; right: calc(50% - 22px); }

/* --- Tarjetas y listas --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 12px; }
.section { margin-top: 18px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.section-title h2 { font-size: 1rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap-row { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); text-align: left; width: 100%; cursor: pointer;
}
.list-item:active { background: var(--surface-2); }
.list-item > svg { width: 24px; height: 24px; flex: none; color: var(--accent-text, var(--gold)); }
.list-item .meta { font-size: .82rem; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* KPIs */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-width: 0; }
.kpi .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 1.3rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi.accent { border-color: rgba(245, 165, 36, .5); background: linear-gradient(160deg, rgba(245, 165, 36, .14), var(--surface) 60%); }
.kpi.accent .value { color: var(--accent-text-2, var(--gold-2)); }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row .bar-head { display: flex; justify-content: space-between; gap: 8px; font-size: .88rem; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 4px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 4px; }

/* --- Botones --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-weight: 650; font-size: 1rem; cursor: pointer;
  text-decoration: none; user-select: none; transition: transform .06s ease, background .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: var(--gold-ink); border-color: transparent; }
.btn.danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(248, 113, 113, .35); }
.btn.ok { background: var(--ok-bg); color: var(--ok); border-color: rgba(52, 211, 153, .35); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.lg { min-height: 60px; font-size: 1.1rem; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: .9rem; }

.hero-actions { display: grid; gap: 12px; margin-top: 16px; }
.hero-btn {
  display: flex; align-items: center; gap: 14px; min-height: 84px; padding: 0 20px; border-radius: 18px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none;
  font-size: 1.25rem; font-weight: 800; letter-spacing: .02em; cursor: pointer; width: 100%;
}
.hero-btn svg { width: 34px; height: 34px; flex: none; }
.hero-btn small { display: block; font-size: .8rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.hero-btn.primary { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: var(--gold-ink); border: 0; min-height: 104px; font-size: 1.45rem; }
.hero-btn.primary small { color: rgba(26, 18, 3, .75); }
.hero-btn:active { transform: scale(.99); }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; min-height: 92px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--text);
  text-decoration: none; font-weight: 650; cursor: pointer; text-align: left; width: 100%;
}
.tile svg { width: 26px; height: 26px; color: var(--accent-text, var(--gold)); }
.tile small { color: var(--muted); font-weight: 500; font-size: .78rem; }

/* Selector segmentado */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; background: var(--surface); border: 1px solid var(--line); padding: 4px; border-radius: 12px; }
.seg button { min-height: 46px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 650; cursor: pointer; padding: 0 6px; }
.seg button.on { background: var(--gold); color: var(--gold-ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 600; cursor: pointer; }
.chips button.on { background: var(--gold); color: var(--gold-ink); border-color: transparent; }

/* --- Formularios --- */
.field { display: block; }
.field + .field { margin-top: 12px; }
.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 1.05rem; outline: none;
}
textarea.input { padding: 12px 14px; min-height: 84px; resize: vertical; }
.input:focus { border-color: var(--accent-text, var(--gold)); box-shadow: 0 0 0 3px rgba(245, 165, 36, .2); }
.input.big { font-size: 1.6rem; font-weight: 700; text-align: center; min-height: 64px; font-variant-numeric: tabular-nums; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent-text, var(--gold)); }
.form-error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(248, 113, 113, .35); padding: 10px 12px; border-radius: var(--radius-sm); font-size: .92rem; }
.notice { background: rgba(96, 165, 250, .1); border: 1px solid rgba(96, 165, 250, .3); color: #cfe2ff; padding: 10px 12px; border-radius: var(--radius-sm); font-size: .9rem; }
.notice.warn { background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .35); color: #fde68a; }

/* --- Login --- */
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b)); }
.login-logo { width: min(64vw, 240px); aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 10px 30px rgba(245, 165, 36, .18)); }
.login-card { width: 100%; max-width: 420px; margin-top: 18px; }
.clock { font-size: .92rem; color: var(--muted); text-align: center; margin-top: 8px; font-variant-numeric: tabular-nums; }

/* --- Punto de venta --- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding-top: 12px; }
.pos > *, .stack > *, .section, .two-col > * { min-width: 0; }
.search-row { display: flex; gap: 8px; }
.search-row .input { flex: 1; min-width: 0; }
.scan-btn { min-width: 64px; }
.scan-big { width: 100%; min-height: 58px; font-size: 1.1rem; letter-spacing: .04em; }
.results { display: flex; flex-direction: column; gap: 6px; }
.prod-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.prod-tile {
  display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); text-align: left; cursor: pointer; min-height: 96px; color: var(--text);
}
.prod-tile:active { background: var(--surface-2); }
.prod-tile .name { font-weight: 650; font-size: .92rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prod-tile .price { color: var(--accent-text-2, var(--gold-2)); font-weight: 700; margin-top: auto; }
.prod-tile .sub { font-size: .75rem; color: var(--muted); }
.thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--surface-3); flex: none; display: grid; place-items: center; color: var(--muted); }
.thumb svg { width: 24px; height: 24px; }

.cart { display: flex; flex-direction: column; gap: 8px; }
.cart-line { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.cart-line.flash { animation: flash .6s ease; }
@keyframes flash { from { background: rgba(245, 165, 36, .25); } }
.cart-line .top { display: flex; gap: 10px; align-items: flex-start; }
.cart-line .name { font-weight: 650; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cart-line .sub { font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cart-line .bottom { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.cart-line .unit-price { font-size: .82rem; color: var(--muted); flex: 1; min-width: 120px; }
.cart-line .override { font-size: .78rem; color: var(--warn); }
.cart-line.weighted { border-left: 4px solid var(--gold); }
.cart-line .weight-detail { line-height: 1.45; color: var(--text); }
.cart-line .weight-detail b { font-variant-numeric: tabular-nums; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.qty button { width: 46px; height: 46px; border: 0; background: transparent; font-size: 1.4rem; cursor: pointer; color: var(--text); }
.qty .q { min-width: 56px; padding: 0 6px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; background: transparent; border: 0; height: 46px; }
.mini-btn { height: 46px; min-width: 46px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; display: inline-grid; place-items: center; font-weight: 650; font-size: .85rem; }
.mini-btn svg { width: 20px; height: 20px; }
.mini-btn.del { color: var(--danger); }

.checkout-bar {
  position: fixed; left: 0; right: 0; bottom: var(--nav-h); z-index: 25;
  background: rgba(24, 24, 27, .98); border-top: 1px solid var(--line); backdrop-filter: blur(10px);
  padding: 10px 16px;
}
.checkout-bar .inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.checkout-bar .total-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.checkout-bar .total { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.checkout-bar .btn { min-height: 58px; flex: 1; max-width: 260px; font-size: 1.15rem; }
.pos-screen { padding-bottom: calc(var(--nav-h) + 96px); }

/* Pesos rápidos */
.weights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.weights button { min-height: 58px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 750; font-size: 1.05rem; cursor: pointer; color: var(--text); }
.weights button.on { background: var(--gold); color: var(--gold-ink); border-color: transparent; }
.calc { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.calc .amount { font-size: 1.6rem; font-weight: 800; color: var(--accent-text-2, var(--gold-2)); font-variant-numeric: tabular-nums; }

/* Cobro */
.pay-total { text-align: center; padding: 6px 0 12px; }
.pay-total .label { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.pay-total .value { font-size: 2.4rem; font-weight: 800; color: var(--accent-text-2, var(--gold-2)); font-variant-numeric: tabular-nums; }
.quick-cash { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.quick-cash button { min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 700; cursor: pointer; color: var(--text); }
.change-box { margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--ok-bg); color: var(--ok); display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; }
.change-box .v { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.change-box.bad { background: var(--danger-bg); color: var(--danger); }
.success-mark { width: 84px; height: 84px; margin: 6px auto 10px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; }
.success-mark svg { width: 48px; height: 48px; }

/* --- Stock --- */
.stock-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.stock-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; grid-template-columns: 64px 1fr; gap: 12px; }
.stock-card.low { border-color: rgba(251, 191, 36, .45); }
.stock-card .img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }
.stock-card .img svg { width: 28px; height: 28px; }
.stock-card .name { font-weight: 700; overflow-wrap: anywhere; }
.stock-card .meta { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.stock-card .qty-now { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stock-card .actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.stock-card .actions .input { flex: 1; min-width: 0; text-align: center; font-weight: 700; }
.stock-card .actions .btn { flex: none; }

/* --- Tablas responsivas: tarjetas en celular, tabla en pantallas grandes --- */
.rt { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.rt thead { display: none; }
.rt tr { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; }
.rt tr.click { cursor: pointer; }
.rt td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: .92rem; min-width: 0; }
.rt td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; flex: none; }
.rt td > * { min-width: 0; }
.rt td.main { font-weight: 700; font-size: 1rem; }
.rt td.main::before { display: none; }
.rt td span.v { text-align: right; overflow-wrap: anywhere; }
.status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--surface-3); color: var(--muted); }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.bad { background: var(--danger-bg); color: var(--danger); }
.status.warn { background: rgba(251, 191, 36, .14); color: var(--warn); }

/* --- Hoja inferior (reemplaza ventanas emergentes en el celular) --- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; background: var(--surface); border-radius: 20px 20px 0 0;
  border: 1px solid var(--line); border-bottom: 0; display: flex; flex-direction: column; animation: up .2s ease;
  padding-bottom: var(--safe-b);
}
.sheet.full { max-height: 100dvh; height: 100dvh; border-radius: 0; max-width: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; font-size: 1.1rem; }
.sheet-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.sheet-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.sheet-foot .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }

/* --- Avisos --- */
#toast-root { position: fixed; left: 0; right: 0; top: calc(10px + var(--safe-t)); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; max-width: 520px; width: 100%; padding: 12px 14px; border-radius: 12px; background: #26262b; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); font-weight: 600; animation: up .2s ease; }
.toast.ok { border-color: rgba(52, 211, 153, .5); color: var(--ok); }
.toast.error { border-color: rgba(248, 113, 113, .5); color: var(--danger); }

/* --- Escáner de cámara --- */
.scanner { position: fixed; inset: 0; z-index: 80; background: #000; display: flex; flex-direction: column; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .scan-top { position: relative; z-index: 2; display: flex; gap: 8px; align-items: center; padding: calc(10px + var(--safe-t)) 12px 10px; background: linear-gradient(rgba(0,0,0,.7), transparent); }
.scanner .scan-top .title { flex: 1; font-weight: 700; }
.scanner .frame { position: absolute; z-index: 1; left: 50%; top: 42%; width: min(82vw, 420px); height: min(46vw, 230px); transform: translate(-50%, -50%); border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45); border: 3px solid var(--gold); }
.scanner .frame::after { content: ""; position: absolute; left: 8px; right: 8px; height: 2px; top: 50%; background: #ff3b30; box-shadow: 0 0 12px #ff3b30; animation: scanline 1.6s ease-in-out infinite; }
.scanner .frame.hit { border-color: var(--ok); }
@keyframes scanline { 0%, 100% { transform: translateY(-80px); } 50% { transform: translateY(80px); } }
.scanner .scan-bottom { position: relative; z-index: 2; margin-top: auto; padding: 12px 12px calc(12px + var(--safe-b)); background: linear-gradient(transparent, rgba(0,0,0,.85) 30%); display: flex; flex-direction: column; gap: 10px; }
.scan-feedback { min-height: 56px; padding: 10px 12px; border-radius: 12px; background: rgba(24, 24, 27, .92); border: 1px solid var(--line); font-weight: 650; }
.scan-feedback.ok { border-color: rgba(52, 211, 153, .6); color: var(--ok); }
.scan-feedback.error { border-color: rgba(248, 113, 113, .6); color: var(--danger); }
.scanner .icon-btn { background: rgba(24, 24, 27, .85); }
.scanner .icon-btn.on { background: var(--gold); color: var(--gold-ink); }
.scan-status { position: absolute; z-index: 2; left: 0; right: 0; top: 42%; transform: translateY(-50%); text-align: center; padding: 0 24px; font-weight: 600; }

/* --- Administración --- */
.admin-nav { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.admin-nav::-webkit-scrollbar { display: none; }
.admin-nav a { flex: none; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); text-decoration: none; font-weight: 650; font-size: .9rem; }
.admin-nav a.on { background: var(--gold); color: var(--gold-ink); border-color: transparent; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .full { grid-column: 1 / -1; }
.filters .input { min-height: 46px; font-size: .95rem; }
.pre { white-space: pre-wrap; font-size: .9rem; color: var(--muted); margin: 6px 0 0; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.kv .sep { grid-column: 1 / -1; border-top: 1px solid var(--line); margin: 4px 0; }
.kv .total { font-size: 1.15rem; color: var(--accent-text-2, var(--gold-2)); }
.img-preview { width: 120px; height: 120px; border-radius: 14px; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }

/* --- Pantallas medianas y grandes --- */
@media (min-width: 600px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .prod-grid { grid-template-columns: repeat(3, 1fr); }
  .stock-grid { grid-template-columns: 1fr 1fr; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .hero-actions { grid-template-columns: 2fr 1fr 1fr; }
  .hero-btn.primary { grid-row: span 1; }
  .filters { grid-template-columns: repeat(4, 1fr); }
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 20px; border-bottom: 1px solid var(--line); }
  .sheet.full { height: auto; max-height: 92dvh; max-width: 640px; border-radius: 20px; }
}
@media (min-width: 900px) {
  .bottom-nav { top: 0; bottom: 0; right: auto; width: 92px; height: auto; grid-template-columns: 1fr; grid-auto-rows: 84px; align-content: start; padding-top: 16px; border-top: 0; border-right: 1px solid var(--line); }
  .screen { padding-left: 92px; padding-bottom: 24px; }
  .checkout-bar { left: 92px; bottom: 0; }
  .pos-screen { padding-bottom: 110px; }
  .pos { grid-template-columns: minmax(0, 1.4fr) minmax(340px, 1fr); align-items: start; }
  .pos .cart-col { position: sticky; top: 76px; }
  .prod-grid { grid-template-columns: repeat(4, 1fr); }
  .stock-grid { grid-template-columns: repeat(3, 1fr); }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .rt { border-spacing: 0; }
  .rt thead { display: table-header-group; }
  .rt th { text-align: left; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
  .rt tr { display: table-row; background: transparent; border: 0; padding: 0; }
  .rt tbody tr:hover { background: var(--surface); }
  .rt td { display: table-cell; padding: 10px; border-bottom: 1px solid var(--line); font-size: .92rem; }
  .rt td::before { display: none; }
  .rt td.main { font-size: .95rem; }
  .rt td span.v { text-align: inherit; }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
}
@media (min-width: 900px) and (hover: hover) {
  .list-item:hover, .prod-tile:hover, .tile:hover { border-color: rgba(245, 165, 36, .5); }
}

/* --- Impresión de tickets térmicos (58/80 mm) --- */
#print-area { display: none; }
@media print {
  @page { margin: 0; }
  body > *:not(#print-area) { display: none !important; }
  html, body { background: #fff !important; color: #000 !important; }
  #print-area { display: block !important; }
}
.ticket { color: #000; background: #fff; font: 12px/1.3 "Courier New", ui-monospace, monospace; padding: 3mm 2mm; box-sizing: border-box; }
.ticket.w58 { width: 58mm; font-size: 10.5px; }
.ticket.w80 { width: 80mm; }
/* Logo: centrado y proporcional, al ancho imprimible del rollo (80 mm ≈ 72 mm útiles; 58 mm ≈ 48 mm útiles).
   object-fit: contain nunca recorta ni deforma; max-height evita que un logo vertical ocupe medio ticket. */
.ticket img { display: block; margin: 0 auto 2mm; width: 60mm; max-width: 100%; height: auto; max-height: 40mm; object-fit: contain; filter: grayscale(1) contrast(1.4); }
.ticket.w58 img { width: 44mm; max-height: 30mm; }
.ticket .c { text-align: center; }
.ticket .b { font-weight: 700; }
.ticket .big { font-size: 1.35em; font-weight: 700; }
.ticket hr { border: 0; border-top: 1px dashed #000; margin: 2mm 0; }
.ticket .ln { display: flex; justify-content: space-between; gap: 2mm; }
.ticket .ln span:last-child { text-align: right; white-space: nowrap; }
.ticket .item { margin-bottom: 1mm; }
/* Vista previa del ticket en Configuración (misma maqueta que se imprime). */
.ticket-preview { background: var(--surface-3); border-radius: 12px; padding: 12px; overflow-x: auto; display: flex; justify-content: center; }
.ticket-preview .ticket { box-shadow: 0 2px 10px rgba(0, 0, 0, .25); flex: none; }

/* --- Panel general de la plataforma: misma identidad oscura, acento violeta para distinguirlo --- */
body.platform { --gold: #a78bfa; --gold-2: #c4b5fd; --gold-ink: #120a24; --bg: #0b0a10; --surface: #15131d; --surface-2: #1e1b29; --surface-3: #2a2638; --line: #322d44; }
body.platform .screen { padding-left: 0; padding-bottom: 32px; }
body.platform .topbar { border-bottom-color: #3b3354; }
.platform-badge { font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-ink); background: var(--gold); padding: 3px 8px; border-radius: 6px; }
.link-box { word-break: break-all; font-family: ui-monospace, monospace; font-size: .85rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; user-select: all; }
.qr-box { background: #fff; border-radius: 12px; padding: 10px; width: 220px; margin: 0 auto; }
.qr-box img { display: block; width: 100%; }
details.err { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
details.err + details.err { margin-top: 8px; }
details.err pre { white-space: pre-wrap; font-size: .78rem; color: var(--muted); overflow-x: auto; }

/* Formularios en dos columnas: nunca desbordan; en celulares angostos pasan a una columna. */
.grid-2 > *, .grid-3 > * { min-width: 0; }
input[type="date"].input { min-width: 0; width: 100%; }
@media (max-width: 440px) { form .grid-2 { grid-template-columns: 1fr; } }

/* --- Avisos importantes --- */
.notice-card { align-items: flex-start; border-left: 4px solid var(--line); }
.notice-card.unread { border-left-color: var(--accent-text, var(--gold)); }
.notice-card.urgent { border-left-color: var(--danger); background: linear-gradient(90deg, rgba(248, 113, 113, .10), var(--surface) 55%); }
.notice-card.stock { border-left-color: var(--danger); }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.count-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--danger); color: #fff; font-size: .75rem; font-weight: 800; margin-left: 6px; vertical-align: middle; }
details summary { cursor: pointer; padding: 6px 0; }
/* Pies de hoja con varios botones: en pantallas angostas pasan a otra línea en lugar de cortarse. */
.sheet-foot { flex-wrap: wrap; }
.sheet-foot .btn { min-width: calc(50% - 5px); }
.sheet-foot .btn.primary { flex-basis: 100%; }
@media (min-width: 600px) { .sheet-foot .btn { min-width: 0; } .sheet-foot .btn.primary { flex-basis: auto; } }

/* Vista previa de etiquetas (papel blanco sobre fondo neutro en ambos temas) */
.label-preview { overflow: auto; background: #555; padding: 10px; border-radius: 12px; max-height: 60dvh; }

/* Ventanas abiertas durante una sesión de escaneo con cámara: por encima del visor */
.sheet-backdrop.over-scanner { z-index: 85; }
.scanner.paused video { filter: grayscale(1) brightness(.35); }

/* ===== TEMA CLARO (preferencia de cada usuario; el oscuro es el predeterminado) ===== */
html[data-theme="claro"] {
  --bg: #f3f3f5;
  --surface: #ffffff;
  --surface-2: #f1f1f4;
  --surface-3: #e5e5ea;
  --line: #d2d2d9;
  --text: #17171b;
  --muted: #55555f;
  --ok: #047857;
  --ok-bg: #d1fae5;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --warn: #92400e;
  --info: #1d4ed8;
  --accent-text: color-mix(in srgb, var(--gold) 55%, #000);
  --accent-text-2: color-mix(in srgb, var(--gold) 55%, #000);
  color-scheme: light;
}
html[data-theme="claro"] .topbar { background: rgba(255, 255, 255, .94); }
html[data-theme="claro"] .bottom-nav { background: rgba(255, 255, 255, .97); }
html[data-theme="claro"] .checkout-bar { background: rgba(255, 255, 255, .98); box-shadow: 0 -6px 18px rgba(0, 0, 0, .06); }
html[data-theme="claro"] .notice { background: rgba(37, 99, 235, .07); border-color: rgba(37, 99, 235, .3); color: #1e3a8a; }
html[data-theme="claro"] .notice.warn { background: rgba(245, 158, 11, .12); border-color: rgba(217, 119, 6, .45); color: #78350f; }
html[data-theme="claro"] .form-error { border-color: rgba(185, 28, 28, .35); }
html[data-theme="claro"] .toast { background: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); color: var(--text); }
html[data-theme="claro"] .sheet-backdrop { background: rgba(15, 15, 20, .45); }
html[data-theme="claro"] .status.warn { background: rgba(245, 158, 11, .16); }
html[data-theme="claro"] .kpi.accent { background: linear-gradient(160deg, rgba(245, 165, 36, .16), var(--surface) 60%); }
html[data-theme="claro"] .stock-card.low { border-color: rgba(217, 119, 6, .6); }
html[data-theme="claro"] .card, html[data-theme="claro"] .list-item, html[data-theme="claro"] .kpi, html[data-theme="claro"] .tile,
html[data-theme="claro"] .prod-tile, html[data-theme="claro"] .cart-line, html[data-theme="claro"] .stock-card { box-shadow: 0 1px 2px rgba(0, 0, 0, .05); }
/* El visor de la cámara siempre es oscuro (mejor lectura y contraste sobre la imagen). */
html[data-theme="claro"] .scanner { --text: #f6f6f7; --muted: #a3a3ad; --line: #34343a; --surface-2: #222226; color: #f6f6f7; }
html[data-theme="claro"] .scanner .scan-feedback { background: rgba(24, 24, 27, .92); }
/* Selector de tema */
.theme-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-pick button { min-height: 64px; border-radius: 12px; border: 2px solid var(--line); font-weight: 750; cursor: pointer; }
.theme-pick button.on { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 30%, transparent); }
.theme-pick [data-theme-v="oscuro"] { background: #18181b; color: #f6f6f7; }
.theme-pick [data-theme-v="claro"] { background: #ffffff; color: #17171b; }

/* Aviso de versión nueva */
.update-banner { position: fixed; left: 12px; right: 12px; top: calc(8px + var(--safe-t)); z-index: 95; display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--gold); box-shadow: 0 10px 30px rgba(0,0,0,.35); font-weight: 650; max-width: 560px; margin: 0 auto; }

/* Importe en pesos ("¿Cuánto quiere gastar?") */
.money-input { position: relative; }
.money-input > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 1.4rem; font-weight: 800; color: var(--muted); pointer-events: none; }
.money-input .input { padding-left: 36px; }
/* Registro interno de la venta (administración) */
.internal-log { border: 1px dashed var(--line); border-radius: 12px; padding: 8px 10px; }
.internal-log summary { cursor: pointer; }

/* ===== Menú de administración: pestañas en PC, botón + lista en el celular ===== */
.admin-menu-btn { display: none; width: 100%; margin: 10px 0 2px; min-height: 58px; padding: 8px 14px; border-radius: 14px; border: 1px solid var(--gold);
  background: var(--surface); color: var(--text); align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; text-align: left; }
.admin-menu-label { display: flex; flex-direction: column; min-width: 0; }
.admin-menu-label small { color: var(--muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.admin-menu-label b { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-menu-caret { color: var(--accent-text, var(--gold)); font-size: .9rem; flex: none; }
.admin-menu-list { display: flex; flex-direction: column; gap: 14px; }
.admin-menu-title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 4px 6px; }
.admin-menu-group { display: flex; flex-direction: column; gap: 6px; }
.admin-menu-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 50px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 650; }
.admin-menu-item.on { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 14%, var(--surface)); }
@media (max-width: 767px) {
  .admin-nav { display: none; }
  .admin-menu-btn { display: flex; }
  /* Filtros de fechas: los atajos se acomodan en varias filas, sin desplazamiento horizontal. */
  [data-filters] .chips { flex-wrap: wrap; overflow: visible; }
  [data-filters] .chips button { flex: 1 1 auto; padding: 0 10px; }
  .filters > * { min-width: 0; width: 100%; }
  .filters input[type="date"] { min-width: 0; }
}

/* ===== v2.7: orden del panel de venta, fondos y reservas ===== */
.sort-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg.sm button { min-height: 36px; padding: 0 10px; font-size: .85rem; }
.fund-box .seg { flex-wrap: wrap; }
.fund-box .seg button[disabled] { opacity: .45; }
.fund-info { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.fund-info .danger, .reserve-mov .danger { color: var(--danger); }
.fund-info .ok, .reserve-mov .ok, .kpi .value.ok { color: var(--ok); }
.fund-info .warn { color: var(--warn); }
.reserve-actions .btn { min-height: 52px; white-space: normal; }
.notice-search { display: grid; grid-template-columns: 1fr; gap: 8px; }
.notice-card mark { background: color-mix(in srgb, var(--gold) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
@media (max-width: 440px) { .reserve-actions { grid-template-columns: 1fr; } }

/* ===== Vencimientos ===== */
.expiry-box .check { font-weight: 650; }
.expiry-fields[hidden], [data-expiry-fields][hidden] { display: none !important; }
.stock-card .stock-expiry { grid-column: 1 / -1; margin: 0; }
.stock-card .stock-expiry span { font-size: .78rem; }
.expiry-row.is-expired { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.expiry-row.is-soon { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 7%, var(--surface)); }
.kpi .value .danger { color: var(--danger); }
.kpi .value .warn { color: var(--warn); }
.chips.chips-wrap { flex-wrap: wrap; overflow: visible; }
.chips.chips-wrap button { flex: 1 1 auto; }

/* --- Productos: buscador + filtro por categoría (v2.8). En PC van uno al lado del otro; en celular, apilados a todo el ancho. --- */
.prod-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.prod-filters > * { min-width: 0; }
.prod-filters select { width: 100%; max-width: 100%; text-overflow: ellipsis; }
@media (min-width: 600px) { .prod-filters { grid-template-columns: minmax(0, 1fr) minmax(180px, 260px); } }

/* --- Historial del turno: filtro por medio de pago (v2.10). Botones compactos que entran en celular sin desplazamiento. --- */
.pay-filter { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
.pay-filter button { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pay-kpis .kpi.accent .value { color: var(--gold); }
.pay-split { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .88rem; color: var(--muted); }
.pay-split b { color: var(--text); font-weight: 650; }
.sale-row { align-items: flex-start; }
.sale-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.sale-amount { text-align: right; flex-shrink: 0; }
@media (max-width: 420px) { .pay-filter { grid-template-columns: 1fr 1fr; } }
