/* =====================================================================
   JEANO Gestión — estilos. Tema claro, letra grande, botones táctiles.
   Mobile-first (360 px); desde 960 px aparece el menú lateral.
   ===================================================================== */
:root {
  color-scheme: light;
  --bg: #f8f5ee;          /* crema */
  --surface: #ffffff;
  --surface-2: #f2eee4;
  --ink: #1c2421;         /* texto principal (contraste 15:1 sobre blanco) */
  --muted: #55605b;       /* texto secundario (6,6:1) */
  --line: #ddd7ca;
  --line-strong: #b9b1a1;
  --brand: #0b6e4f;       /* verde (6,1:1 con blanco) */
  --brand-dark: #08563d;
  --brand-soft: #e2f1ea;
  --accent: #b45309;      /* naranja para destacar (5,0:1) */
  --accent-soft: #fdf0dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn-ink: #7a4b00;
  --warn-soft: #fff4d6;
  --info-ink: #1d4f91;
  --info-soft: #e6effb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(28, 36, 33, .06), 0 4px 14px rgba(28, 36, 33, .06);
  --tap: 52px;
  --nav-h: 68px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  line-height: 1.45; min-height: 100vh; min-height: 100dvh;
}
body.modal-open { overflow: hidden; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); }
.num, .money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.lead { font-size: 1.1rem; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 1.3em; height: 1.3em; flex: none; vertical-align: middle; }

:focus-visible { outline: 3px solid #1d6fd8; outline-offset: 2px; border-radius: 6px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); padding: .6rem 1.1rem; border-radius: var(--radius-sm);
  border: 2px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; touch-action: manipulation;
  transition: background .12s, transform .06s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.outline-danger { color: var(--danger); border-color: var(--danger); }
.btn.ghost { background: var(--surface); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--brand-soft); border-color: transparent; color: var(--brand-dark); }
.btn.big { min-height: 64px; font-size: 1.2rem; padding: .8rem 1.4rem; }
.btn.block { width: 100%; }
.btn.sm { min-height: 44px; padding: .35rem .8rem; font-size: .95rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px;
  border-radius: 12px; border: 0; background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.btn-row > .btn { flex: 1 1 auto; }

/* ---------- Formularios ---------- */
label, .label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field .hint { font-size: .85rem; color: var(--muted); margin-top: .25rem; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: .55rem .8rem; font: inherit; color: var(--ink);
  background: #fff; border: 2px solid var(--line-strong); border-radius: var(--radius-sm);
}
textarea { min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 3px solid rgba(11, 110, 79, .25); outline-offset: 0; }
input[aria-invalid="true"] { border-color: var(--danger); }
.field-err { color: var(--danger); font-size: .9rem; margin-top: .3rem; font-weight: 600; }
input[type=checkbox], input[type=radio] { width: 24px; height: 24px; min-height: 0; accent-color: var(--brand); }
.check { display: flex; align-items: center; gap: .6rem; min-height: 48px; font-weight: 500; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 .8rem; }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.money-input { font-size: 1.5rem; font-weight: 700; text-align: right; }

/* Selector segmentado (radios grandes) */
.seg { display: flex; flex-wrap: wrap; gap: .5rem; border: 0; padding: 0; margin: 0 0 1rem; }
.seg legend { font-weight: 600; margin-bottom: .4rem; padding: 0; }
.seg label { margin: 0; flex: 1 1 0; min-width: max-content; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: var(--tap);
  padding: .4rem .8rem; border: 2px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; font-weight: 600; cursor: pointer;
}
.seg input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid #1d6fd8; outline-offset: 2px; }
.seg input:disabled + span { opacity: .5; cursor: not-allowed; }

/* ---------- Estructura general ---------- */
.app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .5rem;
  min-height: 60px; padding: .3rem .5rem .3rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.2rem; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-pill {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; padding: .3rem .6rem;
  border-radius: 999px; background: var(--warn-soft); color: var(--warn-ink); border: 0; cursor: pointer; min-height: 36px; white-space: nowrap;
}
/* Sucursal de este equipo (solo si el comercio tiene varias) */
.branch-chip {
  display: inline-flex; align-items: center; gap: .35rem; max-width: 42vw; min-height: 36px; padding: .3rem .7rem;
  border-radius: 999px; border: 2px solid var(--brand); background: #fff; color: var(--brand-dark);
  font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.branch-chip span { overflow: hidden; text-overflow: ellipsis; }
/* En el celu, con el chip de sucursal, el estado de la nube queda solo con el ícono (el texto sigue en el título del botón) */
@media (max-width: 559px) {
  .topbar.has-branch { gap: .35rem; }
  .topbar.has-branch h1 { min-width: 5.5em; }
  .topbar.has-branch .branch-chip { max-width: 38vw; }
  .topbar.has-branch .sync-pill span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.branch-pick { justify-content: flex-start; text-align: left; gap: .75rem; }
.branch-tag { display: inline-block; font-size: .78rem; font-weight: 700; color: var(--brand-dark); background: var(--brand-soft); border-radius: 999px; padding: .05rem .5rem; }
.sync-pill.ok { background: var(--brand-soft); color: var(--brand-dark); }
.sync-pill.err { background: var(--danger-soft); color: var(--danger); }
.main { flex: 1; padding: 1rem 1rem calc(var(--nav-h) + 1.5rem); width: 100%; max-width: 1200px; margin: 0 auto; }
.banner-slot { width: 100%; max-width: 1200px; margin: 0 auto; padding: 1rem 1rem 0; }
.banner-slot:empty { display: none; }
.banner-slot .notice { margin: 0; }
.banner-slot .btn-row { margin-top: .5rem; }

/* Barra inferior (celular) */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a, .bottomnav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--nav-h);
  font: inherit; font-size: .75rem; font-weight: 600; color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer;
}
.bottomnav .ico { width: 26px; height: 26px; }
.bottomnav [aria-current="page"] { color: var(--brand); }
.bottomnav [aria-current="page"] .ico { stroke-width: 2.6; }

/* Menú lateral (PC) y cajón (celu) */
.sidenav { display: none; }
.drawer-wrap { position: fixed; inset: 0; background: rgba(20, 24, 22, .4); z-index: 50; }
.drawer {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(320px, 86vw); background: var(--surface); padding: 1rem .75rem;
  overflow-y: auto; box-shadow: var(--shadow);
}
.navlist { list-style: none; margin: 0; padding: 0; }
.navlist a, .navlist button {
  display: flex; align-items: center; gap: .8rem; min-height: 54px; padding: .5rem .9rem; border-radius: 12px; width: 100%;
  color: var(--ink); text-decoration: none; font: inherit; font-weight: 600; background: none; border: 0; cursor: pointer; text-align: left;
}
.navlist a:hover, .navlist button:hover { background: var(--surface-2); }
.navlist a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-dark); }
.brand { display: flex; align-items: center; gap: .6rem; padding: .3rem .6rem 1rem; }
.brand img { width: 40px; height: 40px; border-radius: 10px; }
.brand b { display: block; font-size: 1.05rem; }
.brand small { color: var(--muted); font-size: .8rem; }
.nav-user { border-top: 1px solid var(--line); margin-top: .75rem; padding-top: .75rem; }

@media (min-width: 960px) {
  .app { flex-direction: row; }
  .sidenav {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; width: 250px; flex: none;
    background: var(--surface); border-right: 1px solid var(--line); padding: 1rem .75rem; overflow-y: auto;
  }
  .content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .bottomnav, .topbar .menu-btn { display: none; }
  .main { padding: 1.5rem 2rem 2rem; }
  .banner-slot { padding: 1.5rem 2rem 0; }
}

/* ---------- Tarjetas y listas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card h2 { font-size: 1.1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.stack > * + * { margin-top: .75rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: .75rem; padding: .7rem .2rem; border-bottom: 1px solid var(--line); min-height: 60px;
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { font-size: .85rem; color: var(--muted); }
button.row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); font: inherit; color: inherit; text-align: left; cursor: pointer; }
button.row:hover { background: var(--surface-2); }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; }

.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.badge.ok { background: var(--brand-soft); color: var(--brand-dark); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info-ink); }

.notice { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border-left: 5px solid; }
.notice-info { background: var(--info-soft); border-color: var(--info-ink); color: #163b6b; }
.notice-warn { background: var(--warn-soft); border-color: #c98a00; color: var(--warn-ink); }
.notice-error { background: var(--danger-soft); border-color: var(--danger); color: #7d1810; }
.notice-ok { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.notice p:last-child { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .k { font-size: .85rem; color: var(--muted); font-weight: 600; }
.stat .v { font-size: clamp(1.1rem, 5.2vw, 1.45rem); font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat.hero { grid-column: 1 / -1; background: var(--brand); color: #fff; border-color: var(--brand); }
.stat.hero .k { color: #d9f0e6; }
.stat.hero .v { font-size: 2.2rem; }

.chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; margin-bottom: .75rem; scrollbar-width: thin; }
.chip { flex: none; min-height: 44px; padding: .3rem 1rem; border-radius: 999px; border: 2px solid var(--line-strong); background: #fff; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: var(--surface-2); font-weight: 700; position: sticky; top: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 800; background: var(--surface-2); }

/* Barras simples (reportes) — una sola serie, el valor va en texto */
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { margin-bottom: .7rem; }
.bars .lbl { display: flex; justify-content: space-between; gap: .5rem; font-weight: 600; font-size: .95rem; }
.bars .track { height: 12px; background: var(--surface-2); border-radius: 6px; margin-top: .25rem; overflow: hidden; }
.bars .fill { height: 100%; background: var(--brand); border-radius: 0 4px 4px 0; min-width: 4px; }
.bars .sub-lbl { font-size: .85rem; color: var(--muted); }

/* ---------- Vender ---------- */
/* minmax(0, 1fr): un producto de nombre largo en el carrito no ensancha la pantalla (en celu se salía del ancho) */
.pos { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) {
  .pos { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; }
  .pos .cart-panel { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); display: flex; flex-direction: column; }
  .pos .cart-panel .cart-list { overflow-y: auto; }
  .pay-bar { display: none !important; }
}
.searchbox { position: relative; }
.searchbox .ico { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.searchbox input { min-height: 60px; font-size: 1.15rem; padding-left: 3rem; border-radius: var(--radius); }
.results { margin-top: .5rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); max-height: 55vh; overflow-y: auto; }
.result {
  display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 60px; padding: .5rem .9rem; border: 0; border-bottom: 1px solid var(--line);
  background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.result:hover, .result:focus-visible { background: var(--brand-soft); }
.result .grow { flex: 1; min-width: 0; }
.result .title { font-weight: 600; overflow-wrap: anywhere; }
.result .price { font-weight: 800; font-size: 1.1rem; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
  display: flex; flex-direction: column; justify-content: space-between; gap: .3rem; min-height: 92px; padding: .7rem .8rem;
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius); font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.tile:hover { border-color: var(--brand); }
.tile .t { font-weight: 600; font-size: .95rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.tile .p { font-weight: 800; font-size: 1.1rem; color: var(--brand-dark); }
.tile.libre { border-style: dashed; border-color: var(--line-strong); background: var(--surface-2); }
.cart-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.cart-panel .card-head { padding: .8rem 1rem 0; }
.cart-list { list-style: none; margin: 0; padding: 0 1rem; }
.cart-item { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.cart-item .top { display: flex; gap: .5rem; align-items: flex-start; }
.cart-item .name { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.cart-item .sub { font-weight: 800; white-space: nowrap; }
.cart-item .ctrl { display: flex; align-items: center; gap: .4rem; margin-top: .4rem; }
.cart-item .unit { color: var(--muted); font-size: .85rem; margin-left: auto; }
.qty-btn { width: 48px; height: 48px; border-radius: 12px; border: 2px solid var(--line-strong); background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); }
.qty-val { min-width: 64px; height: 48px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface-2); font: inherit; font-weight: 700; text-align: center; cursor: pointer; padding: 0 .5rem; color: var(--ink); }
.cart-totals { padding: .8rem 1rem 1rem; }
.cart-totals .line { display: flex; justify-content: space-between; gap: .5rem; }
.cart-totals .total { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cart-opts { display: flex; gap: .5rem; flex-wrap: wrap; margin: .6rem 0; }
.cart-opts .btn { flex: 1 1 140px; }
.pay-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 25; display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem; background: #fff; border-top: 2px solid var(--brand); box-shadow: 0 -4px 14px rgba(0, 0, 0, .08);
}
.pay-bar .tot { flex: 1; min-width: 0; }
.pay-bar .tot small { display: block; color: var(--muted); font-size: .8rem; font-weight: 600; }
.pay-bar .tot b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.pay-bar .btn { min-width: 140px; }
.has-paybar .main { padding-bottom: calc(var(--nav-h) + 110px); }

/* Cobro */
.pay-total { text-align: center; padding: .5rem 0 1rem; }
.pay-total .v { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.methods { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: 1rem; }
@media (min-width: 560px) { .methods { grid-template-columns: repeat(3, 1fr); } }
.pay-line { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.pay-line .m { flex: 0 0 38%; font-weight: 700; }
.pay-line input { flex: 1; text-align: right; font-weight: 700; font-size: 1.2rem; }
.quick-bills { display: flex; flex-wrap: wrap; gap: .4rem; margin: .25rem 0 1rem; }
.quick-bills .btn { flex: 1 1 22%; min-height: 48px; padding: .3rem .4rem; font-size: .95rem; }
.change-box { text-align: center; border-radius: var(--radius); padding: .8rem; margin: .5rem 0 1rem; background: var(--surface-2); }
.change-box .k { font-weight: 700; color: var(--muted); }
.change-box .v { font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.change-box.ok { background: var(--brand-soft); }
.change-box.ok .v { color: var(--brand-dark); }
.change-box.miss { background: var(--danger-soft); }
.change-box.miss .v { color: var(--danger); }

/* ---------- Ingreso ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: flex-start; justify-content: center; padding: 1.5rem 1rem; }
.login-box { width: 100%; max-width: 520px; }
.login-logo { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.25rem; }
.login-logo img { width: 56px; height: 56px; border-radius: 14px; }
.login-logo b { font-size: 1.4rem; display: block; }
.users-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.user-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; min-height: 110px; padding: .8rem;
  border-radius: var(--radius); border: 2px solid var(--line); background: #fff; font: inherit; cursor: pointer; color: var(--ink);
}
.user-btn:hover { border-color: var(--brand); }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.3rem; }
.user-btn b { font-size: 1.05rem; }
.user-btn small { color: var(--muted); }
.pin-dots { display: flex; justify-content: center; gap: .9rem; margin: 1rem 0; }
.pin-dots i { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--ink); }
.pin-dots i.on { background: var(--ink); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; max-width: 340px; margin: 0 auto; }
.pinpad button { min-height: 68px; font: inherit; font-size: 1.6rem; font-weight: 700; border-radius: var(--radius); border: 2px solid var(--line); background: #fff; cursor: pointer; color: var(--ink); }
.pinpad button:active { background: var(--brand-soft); }
.steps { display: flex; gap: .4rem; margin-bottom: 1rem; }
.steps i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--brand); }

/* ---------- Ventanas ---------- */
.modal-wrap {
  position: fixed; inset: 0; z-index: 100; background: rgba(20, 24, 22, .45); display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface); width: 100%; max-height: 94vh; max-height: 94dvh; display: flex; flex-direction: column;
  border-radius: 18px 18px 0 0; box-shadow: 0 -6px 30px rgba(0, 0, 0, .2);
}
@media (min-width: 640px) {
  .modal-wrap { align-items: center; padding: 1rem; }
  .modal { max-width: 560px; border-radius: 18px; }
  .modal.wide { max-width: 860px; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem .6rem .5rem 1.1rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.2rem; }
.modal-body { padding: 1rem 1.1rem; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; flex-wrap: wrap; gap: .6rem; padding: .75rem 1.1rem calc(.75rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.modal-foot .btn { flex: 1 1 140px; }
/* Con una ventana abierta los avisos van arriba para no tapar el contenido */
body.modal-open #toasts { top: 12px; bottom: auto; }

/* ---------- Avisos flotantes ---------- */
#toasts { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 460px); pointer-events: none; }
.toast { padding: .55rem .9rem; font-size: .95rem; text-align: center; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); background: var(--ink); color: #fff; transition: opacity .3s; }
.toast-ok { background: var(--brand-dark); }
.toast-error { background: var(--danger); }
.toast-warn { background: #7a4b00; }
.toast.out { opacity: 0; }

/* ---------- Ticket (vista previa e impresión) ---------- */
.ticket { font-family: "Courier New", ui-monospace, monospace; font-size: 13px; line-height: 1.35; color: #000; background: #fff; width: 100%; max-width: 300px; margin: 0 auto; padding: 8px; border: 1px dashed var(--line-strong); }
.ticket .c { text-align: center; }
.ticket .b { font-weight: 700; }
.ticket .big { font-size: 17px; font-weight: 700; }
.ticket hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
.ticket .ln { display: flex; justify-content: space-between; gap: 6px; }
.ticket .ln span:last-child { white-space: nowrap; }
.ticket .it { margin-bottom: 3px; }
.ticket .qr { display: flex; justify-content: center; margin: 6px 0; }
.ticket .qr img, .ticket .qr canvas { width: 120px; height: 120px; }
#print-area { display: none; }

@media print {
  @page { margin: 0; }
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  #print-area .ticket { border: 0; max-width: none; padding: 2mm; }
  #print-area.w58 .ticket { width: 54mm; font-size: 11px; }
  #print-area.w80 .ticket { width: 76mm; font-size: 12.5px; }
  #print-area.w80 .tk-logo { width: 56mm; max-width: none; }
  #print-area.w58 .tk-logo { width: 42mm; max-width: none; }
  .ticket .tk-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-area.a4 .ticket { width: auto; max-width: 180mm; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Orden de la pantalla Vender: en celu el carrito va entre la búsqueda y los más vendidos */
.pos { grid-template-areas: "search" "cart" "quick"; }
.pos-search { grid-area: search; }
.pos .cart-panel { grid-area: cart; }
.pos-quick { grid-area: quick; }
@media (min-width: 960px) {
  .pos { grid-template-areas: "search cart" "quick cart"; grid-template-rows: auto 1fr; }
}
@media (max-width: 959px) { .pos .cart-panel.is-empty { display: none; } }
a.chip { display: inline-flex; align-items: center; text-decoration: none; }

@media (min-width: 960px) { #toasts { bottom: 24px; } }

/* ---------- Escanear con la cámara ---------- */
.searchbox .scan-btn { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; color: var(--brand-dark); background: var(--brand-soft); }
.searchbox .scan-btn .ico { position: static; transform: none; color: inherit; width: 26px; height: 26px; }
.searchbox.has-scan input { padding-right: 3.8rem; }
.field-scan { display: flex; gap: .4rem; align-items: stretch; }
.field-scan input { flex: 1; min-width: 0; }
.field-scan .scan-btn { width: var(--tap); height: auto; min-height: var(--tap); flex: none; color: var(--brand-dark); background: var(--brand-soft); border: 2px solid transparent; }
.field-scan .scan-btn .ico { width: 26px; height: 26px; }
body.scan-open { overflow: hidden; }
.scan-wrap { position: fixed; inset: 0; z-index: 150; display: flex; flex-direction: column; background: var(--bg); }
.scan-head { padding: .6rem 1rem .5rem; padding-top: calc(.6rem + env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--line); }
.scan-head h2 { margin: 0; font-size: 1.25rem; }
.scan-hint { margin: .2rem 0 0; color: var(--muted); font-size: .95rem; }
.scan-view { position: relative; flex: 1; min-height: 0; background: #1c2421; overflow: hidden; }
.scan-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; left: 50%; top: 50%; width: min(86%, 520px); height: min(42%, 260px); transform: translate(-50%, -50%);
  border-radius: 16px; box-shadow: 0 0 0 100vmax rgba(20, 24, 22, .45); outline: 4px solid #fff; outline-offset: 0;
}
.scan-wrap.hit .scan-frame { outline-color: #3ddc97; }
.scan-laser { position: absolute; left: 6%; right: 6%; top: 50%; height: 3px; background: #ff3b30; box-shadow: 0 0 8px #ff3b30; border-radius: 2px; animation: scan-laser 1.6s ease-in-out infinite alternate; }
@keyframes scan-laser { from { transform: translateY(-38px); } to { transform: translateY(38px); } }
@media (prefers-reduced-motion: reduce) { .scan-laser { animation: none; } }
.scan-state { position: absolute; left: 0; right: 0; top: 1rem; text-align: center; color: #fff; font-weight: 700; text-shadow: 0 1px 3px #000; }
.scan-error { position: absolute; inset: 0; overflow-y: auto; background: var(--surface); padding: 1.1rem; }
.scan-error h3 { margin: 0 0 .6rem; font-size: 1.25rem; color: var(--danger); }
.scan-steps { padding-left: 1.2rem; }
.scan-steps li { margin-bottom: .5rem; }
.scan-foot { background: var(--surface); border-top: 1px solid var(--line); padding: .6rem 1rem calc(.75rem + env(safe-area-inset-bottom)); display: grid; gap: .55rem; }
.scan-msg { margin: 0; min-height: 1.6em; font-weight: 700; text-align: center; border-radius: 10px; padding: .2rem .5rem; }
.scan-msg.ok { background: var(--brand-soft); color: var(--brand-dark); }
.scan-msg.warn { background: var(--warn-soft); color: var(--warn-ink); }
.scan-msg.error { background: var(--danger-soft); color: var(--danger); }
.scan-type label { display: block; font-weight: 600; margin-bottom: .25rem; }
.scan-type-row { display: flex; gap: .5rem; }
.scan-type-row input { flex: 1; min-width: 0; font-size: 1.2rem; }
.scan-multi { justify-content: center; }
.scan-btns { display: flex; flex-wrap: wrap; gap: .5rem; }
.scan-btns .btn { flex: 1 1 120px; }
.scan-btns .btn[aria-pressed="true"] { background: var(--warn-soft); border-color: var(--accent); }
/* Mientras la cámara está abierta, los avisos van en la línea de mensajes de la propia ventana */
body.scan-open #toasts { display: none; }

/* ---------- Contar stock (góndola) ---------- */
a.btn { text-decoration: none; }
.ct-diff { align-self: center; flex: none; min-width: 3.2rem; text-align: center; font-weight: 800; font-size: 1.15rem; border-radius: 10px; padding: .2rem .5rem; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.ct-diff.down { background: var(--danger-soft); color: var(--danger); }
.ct-diff.up { background: var(--brand-soft); color: var(--brand-dark); }
.ct-resume { display: grid; gap: .6rem; margin-bottom: 1rem; }
.ct-sys { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; padding: .6rem .8rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.ct-sys b { font-size: 1.3rem; }
.ct-already { margin: .6rem 0 0; padding: .5rem .8rem; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn-ink); }
.ct-qty-label { display: block; font-weight: 700; margin: .9rem 0 .3rem; font-size: 1.1rem; }
.ct-qty { font-size: 2.6rem !important; font-weight: 800; text-align: center; min-height: 76px !important; font-variant-numeric: tabular-nums; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .6rem; }
.keypad .key { min-height: 62px; font: inherit; font-size: 1.7rem; font-weight: 700; border-radius: 12px; border: 2px solid var(--line-strong); background: #fff; color: var(--ink); cursor: pointer; }
.keypad .key:active { background: var(--brand-soft); }
@media (max-height: 700px) { .keypad .key { min-height: 52px; } }

/* ---------- Devoluciones / notas de crédito y remitos (renglones con cantidad) ---------- */
.ret-line { padding: .7rem .5rem; border-bottom: 1px solid var(--line); border-radius: 10px; }
.ret-line.on { background: var(--brand-soft); }
.ret-line .top { display: flex; gap: .5rem; align-items: flex-start; }
.ret-line .name { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.ret-line .top .money { font-weight: 800; white-space: nowrap; }
.ret-line .ctrl { display: flex; align-items: center; gap: .4rem; margin-top: .4rem; flex-wrap: wrap; }
.ret-line .qty-val { width: 84px; }

/* ---------- Tablero "Hoy" ---------- */
.stats.dash .stat.hero .v { font-size: clamp(2rem, 9vw, 2.8rem); }
.hero-sub { font-size: 1rem; color: #e8f6ef; margin-top: .1rem; }
.cmps { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.cmp { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .9rem; background: rgba(255, 255, 255, .16); }
.cmp.up { background: #e2f1ea; color: var(--brand-dark); }
.cmp.down { background: var(--danger-soft); color: var(--danger); }
.dash-grid { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 900px) { .dash-grid { grid-template-columns: 1fr 1fr; } }
.todos { list-style: none; margin: 0; padding: 0; }
.todo { display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem; border-radius: 10px; margin-bottom: .5rem; border-left: 5px solid; }
.todo .grow { flex: 1; min-width: 0; }
.todo .sub { display: block; font-size: .85rem; color: var(--muted); }
.todo.err { background: var(--danger-soft); border-color: var(--danger); }
.todo.warn { background: var(--warn-soft); border-color: #c98a00; }
.todo.info { background: var(--info-soft); border-color: var(--info-ink); }
.ok-line { color: var(--brand-dark); font-weight: 600; margin: 0; }
.hours { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding-top: .3rem; }
.hours .h { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.hours .b { width: 100%; background: var(--brand); border-radius: 4px 4px 0 0; }
.hours span { font-size: .72rem; color: var(--muted); margin-top: .15rem; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--info-ink); text-decoration: underline; cursor: pointer; min-height: 0; }

/* Tira "Hoy" arriba de Vender (dueño y encargado) */
.hoy-strip { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .7rem; padding: .55rem .9rem; margin-bottom: .75rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
.hoy-strip .k { font-weight: 700; color: var(--muted); }
.hoy-strip b { font-size: 1.2rem; }
.hoy-strip .cmp { background: var(--surface-2); }
.hoy-strip .cmp.up { background: var(--brand-soft); }
.hoy-strip .go { margin-left: auto; font-weight: 700; color: var(--brand-dark); }

/* Atajos de teclado (Alt + letra, estilo SGI) */
.kbd-hint { display: inline-grid; place-items: center; min-width: 1.35em; height: 1.35em; margin-left: .4em; padding: 0 .25em;
  border-radius: 5px; background: #f2b705; color: #3d0508; font: 700 .78rem/1 system-ui, sans-serif; box-shadow: 0 1px 0 #0003; vertical-align: middle; }
kbd { display: inline-block; padding: .1em .45em; border: 1px solid var(--line, #d9d2c3); border-bottom-width: 2px; border-radius: 6px; background: #fff; font: 600 .9rem/1.3 ui-monospace, monospace; white-space: nowrap; }
@media (hover: none) and (pointer: coarse) { .kbd-only { display: none; } }

/* ---------- Controles: filtros, lote, arqueo por billetes, auditoría ---------- */
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: .5rem; font-weight: 600; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; color: var(--muted); transition: transform .12s; }
details[open] > summary::before { transform: rotate(90deg); }
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .8rem; }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 360px) { .filters { grid-template-columns: 1fr; } }
.filters-card { padding: .5rem 1rem; }
.filters-card[open] { padding-bottom: 1rem; }
.check-chip { display: inline-flex; align-items: center; gap: .45rem; margin: 0; font-weight: 600; }
.check-chip input { width: 20px; height: 20px; }
.check-chip:has(input:checked) { background: var(--ink); border-color: var(--ink); color: #fff; }
.bulk-bar { position: sticky; top: 64px; z-index: 15; background: var(--info-soft); border: 2px solid var(--info-ink); border-radius: var(--radius); padding: .6rem .8rem; margin-bottom: .75rem; }
.bulk-bar .bulk-info { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .7rem; margin-bottom: .5rem; color: #163b6b; }
.bulk-bar .btn-row > .btn { flex: 1 1 auto; }
.sel-box { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border: 2px solid var(--line-strong); border-radius: 8px; background: #fff; color: #fff; }
.sel-box.on { background: var(--brand); border-color: var(--brand); }
.selecting button.row[aria-checked="true"] { background: var(--brand-soft); }
.bills { display: grid; gap: .35rem; margin-bottom: .5rem; }
.bill-row { display: grid; grid-template-columns: 6.2rem 1rem minmax(4rem, 1fr) 6.5rem; align-items: center; gap: .4rem; }
.bill-row label { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.bill-row .x { color: var(--muted); text-align: center; }
.bill-row input { min-height: 46px; text-align: right; font-weight: 700; font-size: 1.15rem; padding: .3rem .6rem; }
.bill-row .sub { text-align: right; color: var(--muted); font-size: .9rem; }
.bill-row.other { grid-template-columns: 1fr minmax(6rem, 10rem); margin-top: .3rem; }
.bill-row.other label { text-align: left; }
.bill-row.other span { display: none; }
@media (max-width: 380px) { .bill-row { grid-template-columns: 5.4rem .8rem minmax(3.5rem, 1fr) 5.4rem; gap: .3rem; } }
.shortage-card .row { flex-wrap: wrap; }
.shortage-card .btn-row { gap: .4rem; }

/* ---------- Cuentas corrientes, comisiones y fotos de productos ---------- */
.pthumb { flex: none; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.pthumb-sm { width: 44px; height: 44px; }
.pthumb-md { width: 72px; height: 72px; }
.pthumb-lg { display: block; width: min(240px, 70vw); height: auto; aspect-ratio: 1; margin: 0 auto 1rem; }
.result .pthumb { margin-right: .2rem; }
.photo-row { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.photo-preview { width: 120px; height: 120px; flex: none; display: grid; place-items: center; border: 2px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.stmt-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .8rem; align-items: end; }
.stmt-filters .stmt-btns { grid-column: 1 / -1; margin-bottom: .8rem; }
@media (min-width: 900px) { .stmt-filters { grid-template-columns: repeat(4, minmax(0, 1fr)); } .stmt-filters .stmt-btns { grid-column: auto; } }
.stmt { list-style: none; margin: 0; padding: 0; }
.stmt-row { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.stmt-row .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.stmt-row .d { display: block; font-size: .85rem; color: var(--muted); }
.stmt-row .nums { display: flex; flex-direction: column; align-items: flex-end; text-align: right; white-space: nowrap; }
.stmt-row .bal { font-size: .85rem; color: var(--muted); }
.stmt-row .deb { color: var(--danger); font-weight: 700; }
.stmt-row .cre { color: var(--brand-dark); font-weight: 700; }
.stmt-open { background: var(--surface-2); padding: .6rem .6rem; border-radius: var(--radius-sm); }
.stmt-tot { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; padding: .7rem 0; font-size: .95rem; }
#print-area .ph { display: flex; justify-content: space-between; gap: 1rem; font-size: 11px; }
#print-area .ptable { width: 100%; border-collapse: collapse; margin: .5rem 0; font-size: 11px; }
#print-area .ptable th, #print-area .ptable td { border-bottom: 1px solid #999; padding: 3px 4px; text-align: left; vertical-align: top; }
#print-area .ptable .r { text-align: right; white-space: nowrap; }
#print-area .ptable tfoot td { font-weight: 700; border-top: 2px solid #000; }
/* Las fechas (input type=date) tienen un ancho mínimo propio: en el celu no tienen que empujar la página */
.grid2, .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid2 > *, .grid3 > *, .filters > * { min-width: 0; }
input[type=date], input[type=month], input[type=time] { min-width: 0; max-width: 100%; }
@media (max-width: 360px) { .filters { grid-template-columns: 1fr; } }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Reloj de la barra superior */
.clock { margin-left: auto; margin-right: .6rem; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted, #5d5a66); font-size: .95rem; text-align: right; line-height: 1.15; }
.clock-t { color: var(--ink, #17151b); font-size: 1.15rem; }
.clock-ds, .clock-ts { display: none; }
.clock { flex-shrink: 0; }
#page-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) {
  .clock { display: flex; flex-direction: column; align-items: flex-end; font-size: .7rem; margin-right: .25rem; }
  .clock-d, .clock-t { display: none; } .clock-ds, .clock-ts { display: inline; } .clock-ts { font-size: .9rem; color: var(--ink, #17151b); }
}

@media (max-width: 480px) { .sync-pill span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } .sync-pill { padding-inline: .5rem; } }

/* ---------- Productos sin foto: cuadro de reemplazo (se arma en el momento, no se guarda) ---------- */
.pph {
  display: inline-grid; place-items: center; overflow: hidden; text-align: center; line-height: 1;
  font-weight: 800; letter-spacing: .02em; user-select: none; border-color: rgba(28, 36, 33, .08);
}
.pthumb-sm.pph { font-size: .9rem; }
.pthumb-md.pph { font-size: 1.4rem; }
.pthumb-lg.pph { display: grid; grid-template-rows: 1fr auto auto; gap: .35rem; padding: 1.1rem 1rem 1rem; border-radius: var(--radius); }
.pph-ini { align-self: end; font-size: 3.6rem; font-weight: 800; letter-spacing: .04em; }
.pph-name { font-size: 1rem; font-weight: 700; line-height: 1.25; letter-spacing: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.pph-cat { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .78; }
.pph-0 { background: #fde2e4; color: #8a2432; }
.pph-1 { background: #fde8d7; color: #853a0c; }
.pph-2 { background: #faf0c8; color: #664d00; }
.pph-3 { background: #e8f4cc; color: #3f5a09; }
.pph-4 { background: #d8f2e3; color: #155d3b; }
.pph-5 { background: #d3efee; color: #0e5754; }
.pph-6 { background: #d9ebfa; color: #194b79; }
.pph-7 { background: #e1e5fb; color: #2d3c88; }
.pph-8 { background: #ebe2fa; color: #55308a; }
.pph-9 { background: #f6dff9; color: #772580; }
.pph-10 { background: #fbe1ee; color: #842152; }
.pph-11 { background: #ebe7df; color: #4a453d; }
@media print { .pph { display: none; } }

/* ---------- Fotos faltantes ---------- */
.ph-top { display: grid; gap: .9rem; }
.ph-count { display: grid; gap: .2rem; }
.ph-big { font-size: clamp(1.6rem, 7vw, 2.2rem); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: .4rem; }
.ph-sub { color: var(--muted); font-size: .95rem; }
.ph-bar { display: block; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: .35rem; }
.ph-bar > span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.ph-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .6rem; align-items: end; margin: .25rem 0 .75rem; }
.ph-filters .field { margin-bottom: .5rem; min-width: 0; }
.ph-filters .ph-stock { grid-column: 1 / -1; justify-self: start; margin-bottom: .25rem; }
@media (min-width: 720px) { .ph-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; } .ph-filters .ph-stock { grid-column: auto; margin-bottom: .5rem; } }
.ph-list .row.is-next { box-shadow: inset 4px 0 0 var(--brand); background: var(--brand-soft); }
.ph-cam { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); }
.ph-next {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + .5rem); z-index: 20; display: grid; gap: .45rem;
  background: var(--surface); border: 2px solid var(--brand); border-radius: var(--radius); padding: .55rem .65rem .65rem;
  box-shadow: 0 -2px 18px rgba(28, 36, 33, .14);
}
.ph-next.hidden { display: none; }
@media (min-width: 960px) { .ph-next { bottom: 1rem; max-width: 720px; margin-inline: auto; } }
.ph-next-row, .ph-saved { display: flex; align-items: center; gap: .6rem; margin: 0; min-width: 0; }
.ph-next-row .grow, .ph-saved .grow { flex: 1; min-width: 0; }
.ph-saved { color: var(--brand-dark); font-size: .88rem; border-bottom: 1px solid var(--line); padding-bottom: .35rem; }
.ph-saved .grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-saved .ico { width: 18px; height: 18px; vertical-align: -3px; }
.ph-link { flex: none; min-height: 36px; padding: 0 .4rem; border: 0; background: none; font: inherit; font-weight: 700; color: var(--brand-dark); text-decoration: underline; cursor: pointer; }
.ph-k { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0; }
.ph-n { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; line-height: 1.2; }
.ph-next .btn.primary { min-height: 54px; font-size: 1.1rem; }
.ph-next-btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.ph-next-btns .btn.primary { flex: 3 1 10rem; }
.ph-next-btns .btn.ghost { flex: 1 1 8rem; }
.ph-busy { margin: 0; font-weight: 700; color: var(--brand-dark); text-align: center; padding: .9rem 0; }
.ph-confirm { text-align: center; }
.ph-confirm .lead { overflow-wrap: anywhere; }
.ph-rules code { font-size: .88em; background: var(--surface-2); padding: .05rem .3rem; border-radius: 6px; overflow-wrap: anywhere; }
.ph-pick { display: grid; gap: .5rem; margin: .5rem 0 1rem; }
.ph-h { font-size: 1rem; margin: 0 0 .3rem; }
.ph-rules { padding-left: 1.2rem; margin: 0 0 .6rem; }
.ph-rules li + li { margin-top: .25rem; }
@media (min-width: 640px) { .ph-pick { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ph-plan { padding-left: 1.2rem; margin: 0 0 .5rem; }
.ph-plan li + li { margin-top: .3rem; }
.ph-sum { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin-bottom: .9rem; }
@media (min-width: 640px) { .ph-sum { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); } }
.ph-sum .stat.ok .v { color: var(--brand); }
.ph-sum .stat.warn .v { color: var(--accent); }
.ph-sum .stat.err .v { color: var(--danger); }
.ph-unm { max-height: 40vh; overflow: auto; padding-left: 1.2rem; overflow-wrap: anywhere; font-size: .92rem; }

/* Permisos por usuario (Ajustes → Usuarios → Permisos): interruptores agrupados */
.perm-group { margin: 0 0 1rem; padding: 0; border: 0; }
.perm-group > legend { font-weight: 700; font-size: 1rem; padding: 0; margin-bottom: .25rem; }
.perm-row { display: flex; align-items: center; gap: .75rem; min-height: 52px; padding: .45rem 0; border-top: 1px solid var(--line); cursor: pointer; }
.perm-row:first-of-type { border-top: 0; }
.perm-row .perm-txt { flex: 1; min-width: 0; }
.perm-row .perm-txt b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.perm-row .perm-txt small { display: block; color: var(--muted); font-size: .84rem; }
.perm-row .perm-txt .badge { margin-top: .2rem; }
.switch { position: relative; flex: none; width: 52px; height: 30px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(22px); }
.switch input:focus-visible + i { outline: 3px solid var(--brand); outline-offset: 2px; }
.perm-max { display: flex; align-items: center; gap: .5rem; padding: 0 0 .5rem; flex-wrap: wrap; }
.perm-max input { max-width: 110px; }

/* Productos "a mano" en Vender (fijos al lado de Monto libre) */
.tiles .tile.quick { box-shadow: inset 0 0 0 2px color-mix(in srgb, currentColor 22%, transparent); }
.tiles .tile.quick .t { -webkit-line-clamp: 4; font-size: .8rem; line-height: 1.2; overflow-wrap: normal; word-break: break-word; }

/* Alerta roja de vencimientos (Vender) */
.notice.venc-red { background: #fde8e8; border: 2px solid #c62828; color: #7f1010; }
.notice.venc-red .btn { background: #c62828; color: #fff; border-color: #c62828; }

/* Logo en el ticket */
.ticket .tk-logo-box { margin: 0 0 4px; }
.ticket .tk-logo { display: block; margin: 0 auto; width: 70%; max-width: 230px; height: auto; image-rendering: crisp-edges; }

/* ---------- IA (v31): botón de la barra, asistente, semáforo de la carga con foto ---------- */
.ia-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .25rem; min-height: 36px; min-width: 44px; padding: .3rem .65rem;
  border-radius: 999px; border: 2px solid var(--info-ink); background: var(--info-soft); color: var(--info-ink);
  font: inherit; font-size: .85rem; font-weight: 800; cursor: pointer; white-space: nowrap;
}
.ia-btn:focus-visible { outline: 3px solid #1d6fd8; outline-offset: 2px; }
.ia-light { display: inline-block; width: .85rem; height: .85rem; border-radius: 50%; vertical-align: -.1rem; border: 1px solid rgba(0,0,0,.2); flex: none; }
.ia-light.ia-verde { background: #1f9d55; }
.ia-light.ia-amarillo { background: #f2b705; }
.ia-light.ia-rojo { background: #d93025; }
.ia-sum { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-left: .25rem; font-weight: 600; }
.ia-notice ul { margin: .3rem 0 .3rem 1.1rem; padding: 0; }
.ia-thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.ia-thumb { padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; cursor: zoom-in; width: 76px; height: 96px; overflow: hidden; }
.ia-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ia-docbig img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: var(--radius-sm); }
.cp-line .cp-ia { grid-column: 1 / -1; order: 10; display: flex; flex-direction: column; gap: .35rem; }
.cp-ia-read { display: flex; gap: .45rem; align-items: flex-start; overflow-wrap: anywhere; }
.cp-ia-acts { gap: .4rem; }
.cp-ia-acts .chip { min-height: 36px; font-size: .85rem; }
.cp-ia-price { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; padding: .35rem .5rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.cp-ia-price .check { margin: 0; }
.cp-ia-price input[data-pnew] { width: 8.5rem; font-size: 1rem; }
.ia-pick { color: var(--danger); font-weight: 700; }
.ia-busy { text-align: center; padding: 1rem 0; }
.spinner { display: inline-block; width: 42px; height: 42px; border: 4px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: jg-spin .9s linear infinite; }
@keyframes jg-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.ia-chat { display: flex; flex-direction: column; gap: .6rem; max-height: 52vh; overflow-y: auto; padding: .25rem 0; }
.ia-msg { padding: .6rem .8rem; border-radius: var(--radius-sm); max-width: 92%; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.ia-msg.q { align-self: flex-end; background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.ia-msg.a { align-self: flex-start; background: var(--surface-2); }
.ia-msg.err { align-self: stretch; background: var(--danger-soft); color: var(--danger); }
.ia-sugs { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.ia-sugs .chip { min-height: 40px; white-space: normal; text-align: left; max-width: 100%; height: auto; flex: 0 1 auto; }
.ia-ask { display: flex; gap: .5rem; align-items: stretch; }
.ia-ask input { flex: 1; min-width: 0; }
.ia-state { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); }
.ia-state.claude { background: var(--info-soft); color: var(--info-ink); }
.ia-state.off { background: var(--warn-soft); color: var(--warn-ink); }
.venc-seguido { display: flex; flex-direction: column; gap: .6rem; }
.venc-step { display: flex; gap: .5rem; align-items: center; font-weight: 700; }
.venc-step .n { display: inline-flex; width: 1.8rem; height: 1.8rem; border-radius: 50%; align-items: center; justify-content: center; background: var(--brand); color: #fff; font-size: .9rem; }
.venc-step.off { opacity: .45; }
.cp-ia-acts > .btn, .cp-ia-acts > .chip { flex: 0 1 auto; width: auto; }
.cp-ia-price [data-pold] { white-space: nowrap; }
#vs-res:empty { display: none; }
/* En el celu con chip de sucursal no entra todo en la barra: el asistente queda en el menú ("Asistente IA") */
@media (max-width: 559px) { .topbar.has-branch .ia-btn { display: none; } }

/* ---------- Factura A4 (Ajustes → Impresora → Hoja A4): depósito / mayorista, papel A4 (puede ser de color) ---------- */
.inv { font-family: Arial, Helvetica, sans-serif; font-size: 10.5pt; line-height: 1.3; color: #111; background: transparent; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.inv-head { display: grid; grid-template-columns: 1fr 22mm 1fr; border: 1.2px solid #222; border-radius: 3mm; margin-bottom: 3mm; position: relative; }
.inv-emisor, .inv-doc { padding: 3mm 4mm; }
.inv-emisor { border-right: 1.2px solid #222; }
.inv-doc { border-left: 1.2px solid #222; }
.inv-logo { display: block; max-width: 62mm; max-height: 26mm; object-fit: contain; margin-bottom: 2mm; }
.inv-bn { font-size: 15pt; font-weight: 700; }
.inv-letter { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 2mm; }
.inv-l { width: 15mm; height: 15mm; border: 1.6px solid #222; display: grid; place-items: center; font-size: 26pt; font-weight: 700; background: #fff; }
.inv-cod { font-size: 7.5pt; font-weight: 700; margin-top: 1mm; text-align: center; }
.inv-title { font-size: 16pt; font-weight: 700; letter-spacing: .03em; margin-bottom: 1mm; }
.inv-sub { font-size: 8.5pt; margin-bottom: 1.5mm; }
.inv-kv { display: flex; gap: 2mm; }
.inv-kv .k { color: #444; min-width: 28mm; }
.inv-kv .k::after { content: ":"; }
.inv-cust { display: grid; grid-template-columns: 1fr 1fr; gap: 2mm 6mm; border: 1.2px solid #222; border-radius: 3mm; padding: 2.5mm 4mm; margin-bottom: 3mm; }
.inv-void { text-align: center; font-weight: 700; font-size: 14pt; border: 2px solid #b00; color: #b00; padding: 1mm; margin-bottom: 3mm; }
.inv-items { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.inv-items thead th { background: #e9edf1; border-top: 1.2px solid #222; border-bottom: 1.2px solid #222; padding: 1.6mm 1.5mm; text-align: left; font-weight: 700; }
.inv-items td { padding: 1.2mm 1.5mm; border-bottom: .5px solid #bbb; vertical-align: top; }
.inv-items tr { break-inside: avoid; page-break-inside: avoid; }
.inv-items .r, .inv-totals .r { text-align: right; white-space: nowrap; }
.inv-items .code { white-space: nowrap; font-size: 8.5pt; }
.inv-promo { font-size: 8pt; color: #555; }
.inv-bottom { display: grid; grid-template-columns: 1fr 70mm; gap: 6mm; margin-top: 4mm; break-inside: avoid; page-break-inside: avoid; }
.inv-left > div { margin-bottom: 1.5mm; }
.inv-totals { width: 100%; border-collapse: collapse; border: 1.2px solid #222; }
.inv-totals td { padding: 1.2mm 2.5mm; }
.inv-totals .inv-grand td { border-top: 1.2px solid #222; font-size: 13pt; font-weight: 700; background: #e9edf1; }
.inv-cae { display: flex; gap: 5mm; align-items: center; margin-top: 4mm; border-top: 1px solid #222; padding-top: 3mm; break-inside: avoid; page-break-inside: avoid; }
.inv-cae .qr img, .inv-cae .qr canvas { width: 28mm; height: 28mm; }
.inv-arca { font-weight: 700; font-style: italic; margin-bottom: 1mm; }
.inv-footer { margin-top: 4mm; text-align: center; font-size: 9pt; }
@media print {
  /* Hoja A4 vertical con márgenes de 12 mm y número de página abajo (solo en la factura A4) */
  @page factura-a4 {
    size: A4 portrait;
    margin: 12mm;
    @bottom-right { content: "Página " counter(page) " de " counter(pages); font: 8pt Arial, sans-serif; color: #555; }
    @top-left { font: 8pt Arial, sans-serif; color: #555; }
    @top-right { font: 8pt Arial, sans-serif; color: #555; }
  }
  #print-area.a4 .inv { page: factura-a4; width: auto; }
  /* Los títulos de las columnas se repiten en cada hoja */
  #print-area.a4 .inv-items > thead { display: table-header-group; }
}
