:root {
  --bg: #F4F3EF;
  --surface: #FFFFFF;
  --surface-2: #F9F8F5;
  --ink: #111111;
  --ink-2: #4A4A46;
  --ink-3: #85847E;
  --line: #E2E0D9;
  --line-2: #EEEDE8;
  --ok: #1D7A4B;
  --ok-bg: #E4F2EA;
  --warn: #9A5A00;
  --warn-bg: #FFF2DC;
  --bad: #BE3328;
  --bad-bg: #FBE9E7;
  --accent: #FFAF21;          /* amarillo BUFF */
  --accent-bg: #FFF2D6;
  --radius: 14px;
  --top-h: 56px;
  --tab-h: 60px;
  --cart-bar-h: 78px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
/* evita el zoom por doble toque sin bloquear el zoom con dos dedos */
html { touch-action: manipulation; }
body { font-size: 15px; line-height: 1.35; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
input, select, textarea { font: inherit; font-size: 16px; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
.muted { color: var(--ink-3); }
.hint { color: var(--ink-3); font-size: 13px; margin: 0 0 12px; }
.sub { display: block; font-size: 11px; color: var(--ink-3); font-weight: 400; }
.neg { color: var(--bad); font-weight: 700; }
.zero { color: #C4C2BB; }
.grow { flex: 1; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Shell ---------- */
#app { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: calc(var(--top-h) + var(--safe-t)) minmax(0, 1fr) calc(var(--tab-h) + var(--safe-b)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: var(--safe-t) 14px 0; background: var(--ink); color: #fff; min-width: 0; }
.top-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-title { font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: 14px; }
.fair-chip { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; color: #fff; text-align: left; }
.fair-chip b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.fair-chip small { font-size: 12px; color: rgba(255,255,255,.65); white-space: nowrap; }
.top-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 17px; background: rgba(255,255,255,.12); color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; }
@media (max-width: 430px) { .top { gap: 6px; padding-left: 10px; padding-right: 10px; } .top-left { gap: 6px; } .fair-chip b { max-width: 34vw; font-size: 15px; } .top-btn { padding: 0 10px; } }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 17px; background: rgba(255,255,255,.12); color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: #3DDC84; flex: none; }
.dot.warn { background: #FFB020; }
.dot.busy { background: #8AB4FF; }
@media (max-width: 430px) { .pill.ok { padding: 0 12px; } .pill.ok .pill-txt { display: none; } }
#view { min-height: 0; min-width: 0; position: relative; }
.tabs { display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--ink-3); }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--ink); }

/* ---------- Botones y formularios ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; white-space: nowrap; }
.btn:active { background: var(--surface-2); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:active { background: #333; }
.btn-danger { color: var(--bad); border-color: #EFC9C4; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.link { color: var(--ink-2); text-decoration: underline; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > label, .lbl { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.input, .field input, .field select, .field textarea { height: 46px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; width: 100%; }
.field textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 4px 0 12px; }
.check input { width: 22px; height: 22px; }
.seg { display: inline-flex; background: var(--line-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { height: 36px; padding: 0 14px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
select.input { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

/* ---------- TPV ---------- */
.tpv { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: 100%; }
.tpv-main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.tpv-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0; }
.tpv-mode { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }
.tool { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; white-space: nowrap; flex: none; }
.tool svg { width: 20px; height: 20px; }
.tool:active { background: var(--surface-2); }
@media (max-width: 600px) { .tool { width: 44px; padding: 0; } .tool span { display: none; } }
.tpv-body { flex: 1; min-height: 0; min-width: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px 70px; }

/* modo escáner */
.scan-pane { display: flex; flex-direction: column; gap: 14px; max-width: 680px; margin: 0 auto; }
.scan-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 44px 18px; border: 2px dashed var(--line); border-radius: 22px; background: var(--surface); }
.scan-hero.small { flex-direction: row; text-align: left; padding: 12px 16px; gap: 14px; }
.scan-ico { display: inline-flex; color: var(--ink); }
.scan-ico svg { width: 108px; height: 72px; }
.scan-hero.small .scan-ico svg { width: 42px; height: 28px; }
.scan-title { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.scan-hero.small .scan-title { font-size: 17px; }
.scan-sub { color: var(--ink-3); font-size: 14px; margin-top: 4px; }
.scan-hero.small .scan-sub { font-size: 12.5px; margin-top: 1px; }
.last-card { background: var(--surface); border: 2px solid var(--ink); border-radius: 22px; padding: 18px 20px; }
.last-card.pop { animation: pop .45s ease; }
@keyframes pop { 0% { transform: scale(.97); box-shadow: 0 0 0 0 rgba(255, 175, 33, .95); } 100% { transform: none; box-shadow: 0 0 0 16px rgba(255, 175, 33, 0); } }
.lc-type { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.lc-model { font-size: 32px; font-weight: 800; line-height: 1.08; letter-spacing: -0.02em; margin-top: 4px; overflow-wrap: anywhere; }
.lc-var { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; margin-top: 8px; }
.lc-foot { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; margin-top: 14px; }
.lc-price { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.lc-info { color: var(--ink-2); font-weight: 600; }
.lc-actions { display: flex; gap: 8px; margin-top: 14px; }
.lc-actions .btn { flex: 1; height: 48px; }
@media (max-width: 520px) { .scan-hero { padding: 28px 14px; } .scan-title { font-size: 24px; } .lc-model { font-size: 26px; } .lc-price { font-size: 28px; } }

/* últimos añadidos */
.recent > .lbl { display: block; margin-bottom: 6px; }
.recent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.recent.compact { margin-top: 16px; }
.recent.compact .recent-list { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.recent.compact .rc { flex: none; width: 230px; }
.rc { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-align: left; }
.rc:active { background: var(--surface-2); }
.rc > span { flex: 1; min-width: 0; }
.rc b, .rc small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc b { font-size: 14px; }
.rc small { font-size: 12px; color: var(--ink-3); }
.rc em { font-style: normal; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 520px) { .recent-list { grid-template-columns: minmax(0, 1fr); } }

/* selección manual: miga de pan y baldosas */
.crumbs { display: flex; align-items: center; gap: 4px; overflow-x: auto; white-space: nowrap; margin-bottom: 10px; scrollbar-width: none; }
.crumbs::-webkit-scrollbar { display: none; }
.crumb { flex: none; height: 38px; padding: 0 14px; border-radius: 19px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 14px; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; }
.crumb.cur { background: var(--ink); border-color: var(--ink); color: #fff; cursor: default; }
.crumb.skip { background: none; border-color: transparent; color: var(--ink-3); padding: 0 6px; cursor: default; }
.crumbs .sep { color: var(--ink-3); flex: none; }
.step-lbl { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin: 2px 2px 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 10px; }
.tile2 { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; min-height: 108px; padding: 12px 13px; border-radius: 16px; background: var(--c, var(--surface)); border: 1px solid rgba(0, 0, 0, .08); text-align: left; user-select: none; -webkit-user-select: none; transition: transform .06s ease; }
.tile2:active { transform: scale(.97); }
.tile2.dim { opacity: .45; }
.tile2 > .sw { width: 30px; height: 30px; }
.tl-title { font-weight: 800; font-size: 17px; line-height: 1.15; overflow-wrap: anywhere; }
.tile2.big { align-items: center; text-align: center; }
.tile2.big .tl-title { font-size: 32px; margin-top: 4px; }
.tl-sub { font-size: 12.5px; color: var(--ink-2); }
.tl-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: baseline; gap: 6px; width: 100%; }
.tl-price { font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.tl-stock { font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.tl-stock.out { color: var(--bad); }
@media (max-width: 520px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .tile2 { min-height: 96px; padding: 10px 11px; } .tl-title { font-size: 16px; } }

/* aviso de producto añadido */
.added { position: absolute; left: 50%; bottom: 14px; z-index: 5; display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100% - 24px); padding: 10px 14px; border-radius: 16px; background: var(--ink); color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); opacity: 0; transform: translate(-50%, 16px); transition: opacity .15s ease, transform .15s ease; pointer-events: none; }
.added.on { opacity: 1; transform: translate(-50%, 0); }
.added span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.added em { font-style: normal; font-weight: 800; color: var(--accent); white-space: nowrap; }

/* muestras de color */
.sw { display: inline-block; flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .18); vertical-align: middle; background: #fff; }
.sw.none { background: repeating-linear-gradient(45deg, #E2E0D9 0 3px, #fff 3px 6px); }
.sw.lg { width: 26px; height: 26px; }
.sw.xl { width: 40px; height: 40px; }

/* cesta */
.cart { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); border-left: 1px solid var(--line); }
.cart-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cart-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line-2); font-weight: 800; }
.cart-head .actions { gap: 6px; flex-wrap: nowrap; }
.btn-on { background: var(--accent-bg); border-color: var(--accent); }
.cart-lines { flex: 1; overflow-y: auto; }
.cart-empty { padding: 36px 20px; color: var(--ink-3); text-align: center; }
.cl { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 10px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); }
.cl-name { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 700; font-size: 14px; }
.cl-name > span { min-width: 0; }
.cl-name small { display: block; color: var(--ink-3); font-weight: 500; font-size: 12px; }
.cl-amt { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.cl-qty { display: flex; align-items: center; gap: 4px; grid-column: 1 / -1; }
.cl-qty button { width: 40px; height: 36px; border-radius: 10px; background: var(--line-2); font-size: 20px; font-weight: 700; }
.cl-qty span { min-width: 34px; text-align: center; font-weight: 800; font-size: 16px; }
.cl-qty .cl-del { margin-left: auto; width: auto; padding: 0 10px; font-size: 13px; color: var(--ink-3); background: none; }
.cart-disc { display: grid; gap: 4px; padding: 10px 16px; border-top: 1px solid var(--line-2); font-size: 14px; color: var(--ink-2); }
.cart-disc > div { display: flex; justify-content: space-between; gap: 10px; }
.cart-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.cart-sum { display: none; flex-direction: column; align-items: flex-start; height: 56px; justify-content: center; padding: 0 4px; min-width: 76px; }
.cart-sum b { font-size: 15px; }
.cart-sum small { font-size: 12px; color: var(--ink-3); }
.btn-pay { flex: 1; height: 60px; border-radius: 14px; background: var(--ink); color: #fff; font-size: 19px; font-weight: 800; }
.btn-pay:disabled { background: #D3D1CA; }
.btn-pay:not(:disabled):active { background: #333; }

@media (max-width: 899px) {
  .tpv { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) var(--cart-bar-h); }
  .cart { border-left: 0; border-top: 1px solid var(--line); }
  .cart-panel { display: none; }
  .cart.expanded .cart-panel { display: flex; position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b) + var(--cart-bar-h)); max-height: 62vh; background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: 0 -12px 30px rgba(0,0,0,.16); z-index: 20; }
  .cart-foot { height: var(--cart-bar-h); padding: 10px 12px; border-top: 0; }
  .cart-sum { display: flex; }
}

/* buscador, teclado numérico, cámara, código desconocido */
.list-row.sr { gap: 12px; }
.list-row.sr .lr-main small { white-space: normal; }
.kp-display { height: 66px; border: 1px solid var(--line); border-radius: 14px; display: flex; align-items: center; justify-content: center; padding: 0 10px; background: var(--surface-2); font: 800 28px/1 ui-monospace, Menlo, monospace; letter-spacing: .05em; overflow: hidden; }
.kp-msg { min-height: 22px; text-align: center; margin: 8px 0 10px; font-weight: 600; font-size: 14px; }
.kp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kp button { height: 64px; border-radius: 14px; background: var(--line-2); font-size: 27px; font-weight: 800; }
.kp button.kp-fn { font-size: 22px; color: var(--ink-2); }
.kp button:active { background: var(--line); }
.cam { position: relative; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.cam video { display: block; width: 100%; height: 100%; object-fit: cover; }
.cam-frame { position: absolute; left: 12%; right: 12%; top: 36%; bottom: 36%; border: 3px solid var(--accent); border-radius: 12px; }
.unk-code { text-align: center; font: 800 30px/1.2 ui-monospace, Menlo, monospace; margin: 6px 0 10px; overflow-wrap: anywhere; }

/* ---------- Páginas ---------- */
.page { height: 100%; min-width: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 18px 16px 32px; }
.page-inner { max-width: 1100px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card h3 { margin-bottom: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); text-align: right; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); text-align: right; font-variant-numeric: tabular-nums; vertical-align: top; }
.tbl th:first-child, .tbl td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .pname { font-weight: 700; text-transform: uppercase; font-size: 13px; white-space: nowrap; }
.tbl .strong { font-weight: 800; }
.tbl .grp-row td { background: var(--surface-2); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); padding: 7px 10px; }
.tbl tfoot td { font-weight: 800; border-top: 1px solid var(--line); }
.badge { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge.abierta { background: var(--ok-bg); color: var(--ok); }
.badge.planificada { background: var(--warn-bg); color: var(--warn); }
.badge.cerrada { background: var(--line-2); color: var(--ink-3); }
.badge.out { background: var(--bad-bg); color: var(--bad); }

.fair-card .fc-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.fair-card .fc-head .muted { font-size: 13px; margin-top: 2px; }
.fc-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 12px 0; }
.fc-stats div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.fc-stats span { display: block; font-size: 12px; color: var(--ink-3); }
.fc-stats b { font-size: 17px; font-variant-numeric: tabular-nums; }
.fc-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.kpi-l { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.kpi-v { font-size: 24px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi-s { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

.meter { display: inline-block; vertical-align: middle; width: 64px; height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; margin-left: 8px; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--ink-2); }

.hours-day { margin-bottom: 14px; }
.hours-day .lbl { display: block; margin-bottom: 6px; }
.hours { display: flex; align-items: flex-end; gap: 2px; height: 130px; border-bottom: 1px solid var(--line); position: relative; }
.hbar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.hbar i { display: block; width: 100%; max-width: 34px; background: #2F2F2C; border-radius: 4px 4px 0 0; min-height: 0; }
.hbar.sel i { background: var(--ink); outline: 2px solid var(--surface); }
.hbar em { position: absolute; font-style: normal; font-size: 11px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.hlabels { display: flex; gap: 2px; margin-top: 4px; }
.hlabels span { flex: 1; text-align: center; font-size: 10px; color: var(--ink-3); }
.chart-caption { min-height: 20px; font-size: 13px; color: var(--ink-2); margin-top: 4px; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-2); width: 100%; text-align: left; }
.list-row:last-child { border-bottom: 0; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-main b { display: block; }
.list-row .lr-main small { display: block; color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .lr-amt { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.list-row.void { opacity: .45; }
.list-row.void .lr-amt { text-decoration: line-through; }

/* rótulo de grupo */
.qt-g { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); padding: 12px 0 6px; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; color: var(--ink-3); font-size: 16px; }
.icon-btn:active { background: var(--line-2); }

/* ---------- Modal ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(17,17,17,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade .12s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet { background: var(--surface); width: 100%; max-width: 620px; max-height: 92vh; max-height: 92dvh; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; padding-bottom: var(--safe-b); animation: up .16s ease; }
.sheet.wide { max-width: 760px; }
@keyframes up { from { transform: translateY(24px); } to { transform: none; } }
@media (min-width: 700px) {
  .backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: 20px; padding-bottom: 0; max-height: 88vh; max-height: 88dvh; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line-2); }
.sheet-head .x { width: 36px; height: 36px; border-radius: 18px; background: var(--line-2); font-size: 15px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 18px; flex: 1; min-height: 0; }
.sheet-foot { padding: 12px 18px; border-top: 1px solid var(--line-2); display: flex; gap: 10px; align-items: center; }
.sheet-foot .foot-info { font-size: 13px; color: var(--ink-2); font-weight: 600; }

/* cobro */
.pay-total { text-align: center; font-size: 44px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin: 4px 0 2px; }
.pay-items { text-align: center; color: var(--ink-3); font-size: 14px; margin-bottom: 16px; }
.pay-main { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pm { height: 104px; border-radius: 18px; font-size: 24px; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.pm small { font-size: 13px; font-weight: 600; opacity: .7; }
.pm-cash { background: var(--ok-bg); color: var(--ok); border: 2px solid #BFE0CC; }
.pm-card { background: var(--ink); color: #fff; }
.pm:active { transform: scale(.98); }
.pay-alt { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.pay-alt .btn { height: 52px; }
.change { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.change-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.change-row button { height: 40px; min-width: 56px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); font-weight: 700; }
.change-row button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.change-out { margin-top: 8px; font-size: 18px; font-weight: 800; min-height: 24px; }
.mixed-out { display: flex; justify-content: space-between; padding: 12px 0; font-size: 17px; font-weight: 700; }
.big-input { height: 60px !important; font-size: 26px !important; font-weight: 800; text-align: center; }
pre.receipt { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px; font: 13px/1.45 ui-monospace, Menlo, monospace; margin: 0 0 12px; }

/* ---------- Toast y banner ---------- */
#toast-root { position: fixed; top: calc(var(--safe-t) + 7px); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 70; pointer-events: none; }
.toast { pointer-events: auto; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 10px; max-width: calc(100% - 24px); background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 12px 10px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 700; animation: up .16s ease; }
.toast .t-actions { display: flex; gap: 6px; }
.toast button { color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 10px; height: 36px; padding: 0 12px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--bad); }
.banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + var(--safe-b) + 12px); z-index: 65; display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 10px 10px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 600; width: max-content; max-width: calc(100% - 24px); }
.banner button { background: #fff; color: var(--ink); border-radius: 10px; height: 36px; padding: 0 12px; font-weight: 800; }

/* ---------- Login y selector ---------- */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--ink); color: #fff; padding: 24px; }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.logo { width: 72px; height: 72px; border-radius: 18px; border: 2px solid #fff; display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 800; margin: 0 auto 18px; }
.logo-img { display: block; width: 132px; height: auto; margin: 0 auto 22px; }
.login-box h1 { letter-spacing: .14em; text-transform: uppercase; font-size: 20px; margin-bottom: 8px; }
.login-box p { color: rgba(255,255,255,.7); margin: 0 0 18px; }
.login-box input { width: 100%; height: 52px; border-radius: 12px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; padding: 0 14px; text-align: center; margin-bottom: 12px; }
.login-box .btn-primary { background: #fff; color: var(--ink); border-color: #fff; height: 52px; }
.login-box .err { color: #FF8A80; min-height: 20px; margin-top: 12px; }
.pick { max-width: 560px; margin: 0 auto; padding: 28px 16px; }
.pick h2 { margin-bottom: 6px; }
.pick-list { display: grid; gap: 10px; margin-top: 14px; }
.pick-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-align: left; width: 100%; }
.pick-item b { display: block; font-size: 16px; }
.pick-item small { color: var(--ink-3); }
.empty { text-align: center; color: var(--ink-3); padding: 40px 16px; }
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.settings-list .list-row { cursor: pointer; }
.price-list { font-size: 12px; color: var(--ink-3); }
.warn-box { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 600; margin-bottom: 12px; }

/* caja */
.ses-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.ses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.ses-grid > div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.ses-grid span { display: block; font-size: 12px; color: var(--ink-3); font-weight: 600; }
.ses-grid b { font-size: 20px; font-variant-numeric: tabular-nums; }
.ses-grid small { display: block; font-size: 12px; color: var(--ink-2); }
.ses-grid .hl { background: var(--ink); color: #fff; }
.ses-grid .hl span { color: rgba(255,255,255,.7); }
.diff { font-weight: 800; white-space: nowrap; }
.diff.ok { color: var(--ok); }
.diff.bad { color: var(--bad); }
.diff.warn { color: var(--warn); }
.close-out { display: grid; gap: 8px; margin: 4px 0 12px; font-size: 16px; }
.close-out > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; height: 46px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; }
.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1; padding: 0 6px; }
.seg button:disabled { opacity: .4; }
.list-sum { font-size: 13px; color: var(--ink-2); margin: 12px 0 2px; font-weight: 700; }
.badge.test { background: #ECE6F7; color: #5B3FA0; }

/* ---------- Productos, stock por SKU y listas por escaneo ---------- */
.filter-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.filter-row .input { flex: 1; min-width: 0; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.tbl tr.m-row { cursor: pointer; }
.tbl tr.m-row td { background: var(--surface); }
.tbl .vname { white-space: nowrap; font-size: 13px; text-align: left; padding-left: 24px; }
.tbl .vname .sw { width: 14px; height: 14px; margin-right: 7px; }
.tbl tr.inactive td { opacity: .5; }
.tbl td.na { color: #C4C2BB; }
.diff.okp { color: var(--ok); }

.model-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; margin-bottom: 6px; }
.model-card { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-align: left; }
.model-card:active { background: var(--surface-2); }
.model-card.inactive { opacity: .5; }
.mc-sw { display: flex; flex: none; }
.mc-sw .sw { width: 22px; height: 22px; margin-left: -6px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.mc-sw .sw:first-child { margin-left: 0; }
.mc-main { flex: 1; min-width: 0; }
.mc-main b { display: block; }
.mc-main small { display: block; color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-side { text-align: right; flex: none; }
.mc-side b { display: block; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mc-side small { color: var(--ink-3); font-size: 12px; }
@media (max-width: 560px) { .model-list { grid-template-columns: minmax(0, 1fr); } }

.grid-tbl th, .grid-tbl td { text-align: center; }
.grid-tbl th:first-child, .grid-tbl td:first-child { text-align: left; }
.grid-tbl .vname { padding-left: 10px; }
.grid-tbl .gi { width: 64px; height: 42px; text-align: center; border: 1px solid var(--line); border-radius: 10px; font-weight: 800; background: #fff; }
.grid-tbl .gi + .sub { margin-top: 2px; }
.cat-grid td { padding: 5px; vertical-align: middle; }
.cat-grid .cell { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; min-width: 118px; padding: 8px 6px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-2); }
.cat-grid .cell:active { background: var(--line-2); }
.cat-grid .cell.inactive { opacity: .45; }
.cat-grid .cell.target { outline: 3px solid var(--accent); background: var(--accent-bg); }
.c-ean { font: 600 11.5px/1.3 ui-monospace, Menlo, monospace; }
.c-price { font-weight: 800; }
.c-stock { font-size: 12px; color: var(--ink-3); }
.cell-add { width: 100%; min-width: 64px; height: 62px; border-radius: 10px; border: 1px dashed var(--line); color: var(--ink-3); font-size: 22px; }
.assign-box { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 10px 12px; margin-bottom: 12px; border: 2px solid var(--accent); border-radius: 12px; background: var(--accent-bg); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.check-chip input { width: 18px; height: 18px; }
.field-msg { min-height: 18px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.field-msg.ok { color: var(--ok); }
.field-msg.err { color: var(--bad); }
.row.sw-row { align-items: center; gap: 12px; flex-wrap: wrap; }
.row.sw-row input[type=checkbox] { flex: none; width: 22px; height: 22px; }
.row.sw-row input[type=color] { flex: none; width: 56px; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.row.sw-row input[type=color]:disabled { opacity: .35; }
.sku-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }

.ed-scan { display: grid; gap: 10px; padding: 12px; margin-bottom: 12px; border: 2px dashed var(--line); border-radius: 16px; }
.ed-scan-msg { display: flex; align-items: center; gap: 12px; }
.ed-scan-msg .scan-ico svg { width: 42px; height: 28px; }
.ed-scan-msg b { display: block; font-size: 16px; }
.ed-scan-msg small { color: var(--ink-3); }
.ed-msg { min-height: 20px; font-size: 14px; font-weight: 600; }
.ed-full { margin-bottom: 10px; }
.ed-full .lbl { display: block; margin-bottom: 6px; }
.ed-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 60px 34px; grid-template-areas: "name qty diff del"; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.ed-row.flash { animation: rowflash 1.1s ease; }
@keyframes rowflash { 0% { background: #FFE2A8; } 100% { background: transparent; } }
.ed-name { grid-area: name; display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 14px; }
.ed-name > span { min-width: 0; }
.ed-name small { display: block; color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-qty { grid-area: qty; display: flex; align-items: center; gap: 4px; }
.ed-qty button { width: 38px; height: 42px; border-radius: 10px; background: var(--line-2); font-size: 20px; font-weight: 700; }
.ed-qty input { width: 58px; height: 42px; text-align: center; border: 1px solid var(--line); border-radius: 10px; font-weight: 800; background: #fff; }
.ed-diff { grid-area: diff; text-align: right; font-weight: 800; font-size: 14px; }
.ed-row .icon-btn { grid-area: del; }
@media (max-width: 560px) {
  .ed-row { grid-template-columns: auto minmax(0, 1fr) 34px; grid-template-areas: "name name name" "qty diff del"; row-gap: 6px; }
  .ed-diff { text-align: left; }
}

/* informes */
.rep-2col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0 12px; }
.tbl.curve td { text-align: center; }
.tbl.curve td:first-child { text-align: left; }
.tbl.curve th { text-align: center; }
.tbl.curve th:first-child { text-align: left; }
.bar { display: block; height: 4px; border-radius: 2px; background: var(--line-2); margin-top: 3px; overflow: hidden; min-width: 36px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

.scan-test { margin-top: 12px; padding: 12px; border: 2px dashed var(--line); border-radius: 14px; font-size: 14px; display: grid; gap: 4px; }
.scan-test-code { font: 800 22px/1.2 ui-monospace, Menlo, monospace; overflow-wrap: anywhere; }
.sheet-foot { flex-wrap: wrap; }
