/* =========================================================
   POS Bodega
   Identidad: verde de tienda de barrio, etiqueta de precio
   amarillo señal y un carrito que se lee como ticket.
   ========================================================= */
:root {
  --ink: #15221d;
  --ink-2: #4a5b54;
  --paper: #e8eee8;
  --surface: #ffffff;
  --line: #d3dcd5;
  --brand: #0e5a4a;
  --brand-dark: #0a4539;
  --brand-soft: #d9ebe4;
  --signal: #ffc629;
  --signal-ink: #2b2100;
  --danger: #b93a2a;
  --danger-soft: #f8e2de;
  --ok-soft: #d9ebe4;
  --r-sm: 8px;
  --r-md: 14px;
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 15px/1.45 var(--font-body);
  color: var(--ink);
  background: var(--paper);
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 800; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--ink-2); font-size: 13px; }
.right { text-align: right; }
.low { color: var(--danger); font-weight: 700; }
[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; gap: 28px;
  padding: 0 20px;
}
.brand {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  color: #fff; text-decoration: none; white-space: nowrap; border-radius: 12px; padding: 4px 6px 4px 4px; margin-left: -4px;
}
.brand:hover { background: rgb(255 255 255 / .08); }
.brand-ico {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: #fff; box-shadow: 0 6px 14px -6px rgb(0 0 0 / .45), inset 0 -2px 0 rgb(0 0 0 / .06);
}
.brand-ico img { width: 34px; height: auto; display: block; }
.brand-txt { display: flex; flex-direction: column; gap: 3px; line-height: 1; }
.brand-txt img { height: 22px; width: auto; display: block; filter: drop-shadow(0 1px 0 rgb(0 0 0 / .18)); }
.brand-txt small {
  font: 700 10px/1 var(--font-body); letter-spacing: .26em; text-transform: uppercase; color: var(--signal);
  padding-left: 2px;
}
.nav { display: flex; gap: 4px; overflow-x: auto; }
.nav a {
  color: #d3eae2; text-decoration: none; font-weight: 600;
  padding: 8px 14px; border-radius: 999px; white-space: nowrap;
}
.nav a:hover { background: rgb(255 255 255 / .12); }
.nav a[aria-current="page"] { background: #fff; color: var(--brand); }
.topbar :focus-visible { outline-color: var(--signal); }

/* ---------- Controles ---------- */
.input {
  width: 100%; min-height: 42px; padding: 8px 12px;
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm);
}
.input:focus { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
.input.search { background-image: none; }
select.input { padding-right: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 18px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-weight: 700; background: var(--surface);
  transition: background-color .12s, border-color .12s, transform .06s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); border-color: var(--ink-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-link { background: none; border: 0; min-height: 0; padding: 4px 6px; color: var(--ink-2); font-weight: 600; text-decoration: underline; }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > label, fieldset legend { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.req { color: var(--danger); }
.check-label { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check-label input { width: 18px; height: 18px; accent-color: var(--brand); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-on { background: var(--ok-soft); color: var(--brand-dark); }
.badge-off { background: #ece9e4; color: #6a5f55; }

/* =========================================================
   PANTALLA DE VENTA
   ========================================================= */
.pos {
  display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 26px;
  height: calc(100dvh - var(--topbar-h));
  padding: 16px 20px 28px;
}
.catalog { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; flex-shrink: 0; padding-bottom: 2px; }
.chip {
  padding: 6px 16px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600;
}
.chip:hover { border-color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.grid {
  flex: 1; min-height: 0; overflow: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; align-content: start; padding: 2px 6px 10px 2px;
}
.empty { grid-column: 1 / -1; padding: 32px 12px; text-align: center; color: var(--ink-2); }

/* Producto = botón con imagen, etiqueta de precio y descripción corta */
.tile {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 8px 8px 10px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color .12s, transform .06s;
}
.tile:hover:not(:disabled) { border-color: var(--brand); }
.tile:active:not(:disabled) { transform: scale(.97); }
.tile:disabled { opacity: .55; }
.tile-img {
  position: relative; display: block; aspect-ratio: 4 / 3;
  border-radius: 9px; overflow: hidden; background: var(--brand-soft); margin-bottom: 4px;
}
.tile-img img, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  background: hsl(var(--h) 42% 85%); color: hsl(var(--h) 45% 26%);
  font: 800 38px var(--font-display);
}
.price {
  position: absolute; right: 6px; bottom: 6px;
  display: flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 8px; border-radius: 6px;
  background: var(--signal); color: var(--signal-ink);
  font: 800 14px var(--font-display); font-variant-numeric: tabular-nums;
}
.price::before {            /* ojal de la etiqueta */
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: rgb(43 33 0 / .55);
}
.in-cart {
  position: absolute; left: 6px; top: 6px;
  min-width: 26px; height: 26px; padding: 0 7px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--brand); color: #fff; font: 800 14px var(--font-display);
  box-shadow: 0 0 0 2px #fff;
}
.tile-name { font-weight: 700; line-height: 1.25; }
.tile-desc { font-size: 13px; color: var(--ink-2); line-height: 1.3; min-height: 2.6em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-stock { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.tile-stock.low { color: var(--danger); }
.tile-stock.out { color: var(--danger); }

/* Carrito = ticket con borde rasgado */
.receipt {
  position: relative; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-radius: var(--r-md) var(--r-md) 0 0;
  box-shadow: 0 1px 0 var(--line), 0 10px 30px -18px rgb(21 34 29 / .5);
}
.receipt::after {
  content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 10px;
  background:
    linear-gradient(135deg, var(--surface) 5px, transparent 0) 0 0 / 14px 10px,
    linear-gradient(225deg, var(--surface) 5px, transparent 0) 0 0 / 14px 10px;
}
.receipt-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; }
.cart-items { list-style: none; margin: 0; padding: 0 18px; flex: 1; min-height: 110px; overflow: auto; }
.cart-empty { padding: 28px 8px; text-align: center; color: var(--ink-2); border-top: 1px dashed var(--line); }
.line {
  display: grid; grid-template-columns: 1fr auto auto; grid-template-areas: "info step total" "info step total";
  align-items: center; column-gap: 10px; padding: 10px 0; border-top: 1px dashed var(--line);
  position: relative;
}
.line-info { grid-area: info; display: flex; flex-direction: column; min-width: 0; padding-left: 16px; }
.line-name { font-weight: 700; line-height: 1.2; }
.line-unit { font-size: 12px; color: var(--ink-2); }
.stepper { grid-area: step; display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); }
.stepper button { width: 32px; height: 32px; border: 0; background: none; font-size: 18px; font-weight: 700; border-radius: var(--r-sm); }
.stepper button:hover { background: var(--brand-soft); }
.stepper output { min-width: 26px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.line-total { grid-area: total; min-width: 74px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.line-x {
  position: absolute; left: -6px; top: 6px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: none; color: var(--ink-2); font-size: 16px; line-height: 1;
}
.line-x:hover { background: var(--danger-soft); color: var(--danger); }

.receipt-foot { padding: 12px 18px 20px; display: flex; flex-direction: column; gap: 10px; border-top: 2px dashed var(--line); }
.cliente-row, .ref-row { display: flex; gap: 6px; }
.cliente-row .input, .ref-row .input { flex: 1; min-width: 0; }
.cliente-row .btn-icon { flex: 0 0 42px; color: var(--brand); border-color: var(--brand); font-weight: 700; }
.cliente-row .btn-icon:hover { background: var(--brand); color: #fff; }
.ref-row .btn-icon { flex: 0 0 42px; color: var(--ink-2); font-size: 20px; }
.ref-toggle { align-self: flex-start; padding-left: 0; color: var(--brand); }
.doc-row { display: flex; gap: 6px; }
.doc-row .input { flex: 1; min-width: 0; }
.doc-row .btn { flex: 0 0 auto; min-height: 42px; }
.nc-status { margin: -4px 0 0; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; font-weight: 600; background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); }
.nc-status.is-ok { background: var(--ok-soft); color: var(--brand-dark); border-color: transparent; }
.nc-status.is-warn { background: #fff4d1; color: #6b4e00; border-color: transparent; }
.nc-status.is-error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pagos { border: 0; margin: 0; padding: 0; min-width: 0; }
.pagos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 6px; margin-top: 4px; }
.pagos-grid.comps { grid-template-columns: repeat(3, 1fr); }
.pago span em { display: block; font-style: normal; font-size: 11px; font-weight: 600; opacity: .8; }
.pago input:disabled + span { opacity: .45; cursor: not-allowed; background: transparent; border-style: dashed; }
.pago input:disabled + span:hover { border-color: var(--line); }
.pago { position: relative; }
.pago input { position: absolute; opacity: 0; pointer-events: none; }
.pago span {
  display: block; text-align: center; padding: 9px 6px; font-weight: 700;
  border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; background: var(--surface);
}
.pago span:hover { border-color: var(--ink-2); }
.pago input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.pago input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }
.pago-ico {
  display: block; width: 26px; height: 26px; margin: 0 auto 3px;
  border-radius: 7px; overflow: hidden; font-style: normal;
}
#comps .pago span, #pagos .pago span { padding: 6px 4px; line-height: 1.15; }
.pago-ico img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pago-ico .ph { font-size: 14px; border-radius: 7px; }
.pago input:checked + span .pago-ico { box-shadow: 0 0 0 2px #fff; }

.totals { margin: 0; display: grid; gap: 2px; }
.totals > div { display: flex; justify-content: space-between; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.totals dt, .totals dd { margin: 0; }
.totals .grand { color: var(--ink); align-items: baseline; padding-top: 6px; }
.totals .grand dt { font: 800 18px var(--font-display); }
.totals .grand dd { font: 800 30px var(--font-display); letter-spacing: -0.02em; }

.btn-cobrar {
  min-height: 56px; font: 800 20px var(--font-display);
  background: var(--signal); color: var(--signal-ink); border-radius: 10px;
}
.btn-cobrar:hover:not(:disabled) { background: #ffd04d; }
.btn-cobrar:focus-visible { outline-color: var(--ink); }
.btn-cobrar:disabled { background: #e9e2cb; color: #8a806a; opacity: 1; }

.mobile-bar {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20;
  display: none; align-items: center; justify-content: space-between;
  min-height: 52px; padding: 0 20px; border: 0; border-radius: 12px;
  background: var(--ink); color: #fff; font-weight: 700;
  box-shadow: 0 10px 24px -8px rgb(0 0 0 / .5);
}
.mobile-bar strong { font: 800 20px var(--font-display); color: var(--signal); }

/* =========================================================
   MAESTROS E HISTORIAL
   ========================================================= */
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 48px; }
.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar h1 { margin-right: auto; }
.toolbar .search { width: 280px; }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink-2); }
.inline .input { width: auto; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th { text-align: left; padding: 12px 14px; font-size: 13px; color: var(--ink-2); font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid #eaf0ea; vertical-align: middle; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table th.right, .table td.right { text-align: right; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.empty { padding: 36px; }
.table tr.is-void td { color: #8a938e; }
.table tr.is-void td strong { text-decoration: line-through; }
.thumb { width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: var(--brand-soft); }
.thumb .ph { font-size: 20px; }
.thumb-lg { width: 84px; height: 84px; flex-shrink: 0; }
.thumb-lg .ph { font-size: 34px; }

.summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 16px; display: flex; flex-direction: column; min-width: 140px; }
.stat span { font-size: 13px; color: var(--ink-2); }
.stat strong { font: 800 22px var(--font-display); font-variant-numeric: tabular-nums; }

/* ---------- Diálogos ---------- */
.dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 24px; border: 0; border-radius: 16px; color: var(--ink);
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / .5);
}
.dialog::backdrop { background: rgb(21 34 29 / .55); }
.dialog h2 { margin-bottom: 16px; }
.dialog-sm { width: min(420px, calc(100vw - 24px)); }
.confirm-msg { margin: 0 0 20px; font-size: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-error { margin: 14px 0 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.img-field { display: flex; gap: 14px; align-items: center; }
.img-controls { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* ---------- Pantalla de cobro (cliente, comprobante y tipo de pago) ---------- */
.dialog-cobro { width: min(860px, calc(100vw - 24px)); padding: 22px 24px 24px; }
.cobro-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dialog-cobro .cobro-head h2 { margin: 0; }
.cobro-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(240px, 1fr); gap: 22px; align-items: start; }
.cobro-campos { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.cobro-resumen {
  position: sticky; top: 0; display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border-radius: var(--r-md); background: var(--paper); border: 1px solid var(--line);
}
.cobro-resumen p { margin: 0; }
.cobro-resumen .btn-cobrar { width: 100%; }
.dialog-cobro #pagos { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
@media (max-width: 720px) {
  .cobro-grid { grid-template-columns: 1fr; }
  .cobro-resumen { position: static; }
}

/* ---------- Crédito financiado ---------- */
.cuotas-box {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px dashed var(--brand); border-radius: var(--r-sm); background: var(--brand-soft);
}
.cuotas-info { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.cuotas-info strong { font-variant-numeric: tabular-nums; }
.cuotas-box .btn { flex: 0 0 auto; background: var(--surface); }
.dialog-cuotas { width: min(560px, calc(100vw - 24px)); }
.cq-total { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 14px; border-radius: var(--r-sm); background: var(--brand-soft); }
.cq-total span { font-weight: 600; color: var(--brand-dark); }
.cq-total strong { font: 800 26px var(--font-display); font-variant-numeric: tabular-nums; color: var(--brand-dark); }
.cq-help { margin: 10px 0; }
.cq-gen { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 12px; margin-bottom: 12px; }
.cq-gen summary { cursor: pointer; font-weight: 700; color: var(--brand); }
.cq-gen-row { display: grid; grid-template-columns: 104px minmax(110px, 1fr) minmax(150px, 1fr) auto; gap: 8px; align-items: end; margin-top: 10px; }
.cq-head, .cq-row { display: grid; grid-template-columns: 34px 1fr 110px 32px; gap: 8px; align-items: center; }
.cq-head { font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 0 0 4px; border-bottom: 1px solid var(--line); }
.cq-head .right, .cq-row .right { text-align: right; }
.cq-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.cq-row { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.cq-num { font-weight: 700; color: var(--ink-2); text-align: center; font-variant-numeric: tabular-nums; }
.cq-monto { font-weight: 700; font-variant-numeric: tabular-nums; }
.cq-row .line-x { position: static; width: 32px; height: 32px; border-radius: var(--r-sm); font-size: 20px; }
.cq-empty { padding: 16px 4px; text-align: center; color: var(--ink-2); font-size: 13px; }
.cq-sum { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cq-sum strong { color: var(--ink); }
@media (max-width: 560px) {
  .cq-gen-row { grid-template-columns: 1fr 1fr; }
  .cq-gen-row .btn { grid-column: 1 / -1; }
  .cq-head, .cq-row { grid-template-columns: 26px 1fr 92px 32px; gap: 6px; }
}
.ticket-cuotas { border-top: 1px dashed var(--ink-2); margin-top: 8px; padding-top: 8px; font-size: 13px; }
.ticket-cuotas th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 2px 0; }
.ticket-cuotas th.right { text-align: right; }
.ticket-cuotas .ticket-lines td { padding: 2px 0; }
.ticket-firma { margin: 28px 16px 0; padding-top: 4px; border-top: 1px solid var(--ink); text-align: center; color: var(--ink-2); font-size: 12px; }

/* ---------- Cuotas por cobrar (administrador) ---------- */
.stat-btn { font: inherit; color: inherit; text-align: left; cursor: pointer; }
.stat-btn:hover { border-color: var(--brand); }
.stat em { font-style: normal; font-size: 12px; color: var(--ink-2); }
.stat-danger { border-color: var(--danger); background: var(--danger-soft); }
.stat-danger strong { color: var(--danger); }
.table tr.is-late td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.dialog-cuota { width: min(940px, calc(100vw - 24px)); }
.dq-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.dialog-cuota .dq-head h2 { margin: 0 0 4px; }
.dq-head p { margin: 0; }
.dq-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dq-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dq-montos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dq-montos > div { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: var(--r-sm); background: var(--paper); }
.dq-montos span { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.dq-montos strong { font: 800 18px var(--font-display); font-variant-numeric: tabular-nums; }
.dq-montos .badge { align-self: flex-start; font-size: 11px; padding: 1px 7px; }
.dq-montos .is-saldo { background: var(--signal); }
.dq-montos .is-saldo span, .dq-montos .is-saldo strong { color: var(--signal-ink); }
.dq-box { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.dq-box h3 { font-size: 15px; margin-bottom: 10px; }
.dq-box[hidden] { display: none; }
.dq-caja { margin: 10px 0 0; font-size: 13px; }
.dq-caja.is-warn { padding: 8px 10px; border-radius: var(--r-sm); background: #fff4d1; color: #6b4e00; font-weight: 600; }
.dq-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.dq-reprog-row { display: flex; gap: 8px; }
.dq-reprog-row .input { flex: 1; min-width: 0; }
.dq-pagos { list-style: none; margin: 0; padding: 0; }
.dq-pagos li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); font-size: 14px; }
.dq-pagos li:first-child { border-top: 0; padding-top: 0; }
.dq-pagos li.is-void > div:first-child { opacity: .6; }
.dq-pago-acts { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.dq-crono { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.dq-crono button {
  width: 100%; display: grid; grid-template-columns: 28px 1fr auto 96px; gap: 8px; align-items: center;
  padding: 7px 6px; border: 0; border-top: 1px dashed var(--line); background: none; font: inherit; color: inherit;
  text-align: left; cursor: pointer; border-radius: var(--r-sm); font-variant-numeric: tabular-nums;
}
.dq-crono li:first-child button { border-top: 0; }
.dq-crono button:hover { background: var(--paper); }
.dq-crono .is-current button { background: var(--brand-soft); font-weight: 700; }
.dq-crono .dq-n { font-weight: 700; color: var(--ink-2); text-align: center; }
.dq-crono .badge { font-size: 11px; }
.dq-crono .right { white-space: nowrap; text-align: right; }
@media (max-width: 760px) {
  .dq-grid { grid-template-columns: 1fr; }
  .dq-montos { grid-template-columns: 1fr 1fr; }
  .dq-head { flex-direction: column; }
  .dq-crono button { grid-template-columns: 20px 1fr auto auto; gap: 6px; font-size: 14px; }
}

/* ---------- Gastos ---------- */
.neg { color: var(--danger); }
.btn-gasto { color: var(--danger); border-color: var(--danger); }
.btn-gasto:hover { background: var(--danger-soft); border-color: var(--danger); }
.g-filtros2 { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.stat-gasto { border-color: var(--danger); background: var(--danger-soft); }
.stat-gasto strong { color: var(--danger); }
.stat-wide { flex: 1 1 320px; }
.cat-bars { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.cat-bars li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 13px; }
.cat-bars li strong { font: 700 13px var(--font-body); font-variant-numeric: tabular-nums; }
.cat-bars em { font-style: normal; color: var(--ink-2); }
.cat-bars i { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--paper); position: relative; overflow: hidden; }
.cat-bars i::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--p); background: var(--danger); border-radius: 3px; }
.dialog-gasto { width: min(620px, calc(100vw - 24px)); }
.dialog-gasto h2 { margin-bottom: 4px; }
.gs-sub { margin: 0 0 16px; }
.gs-prov { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 12px; border-radius: var(--r-sm); background: var(--paper); }
.gs-prov[hidden] { display: none; }
.gs-prov .gs-wide { grid-column: 1 / -1; }
@media (max-width: 560px) {
  .gs-prov { grid-template-columns: 1fr; }
}

/* ---------- Ticket ---------- */
.dialog-ticket { width: min(360px, calc(100vw - 24px)); }
.ticket { position: relative; }
.ticket-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding-bottom: 12px; border-bottom: 1px dashed var(--ink-2); }
.ticket-head strong { font: 800 22px var(--font-display); }
.ticket-logo { display: block; width: 168px; max-width: 70%; margin: 0 auto 8px; }
.ticket-logo img { width: 100%; height: auto; display: block; }
.ticket-logo .tl-impresion { display: none; }
.ticket-meta { padding: 10px 0; font-size: 13px; color: var(--ink-2); border-bottom: 1px dashed var(--ink-2); }
.ticket-lines { width: 100%; border-collapse: collapse; margin: 8px 0; }
.ticket-lines td { padding: 5px 0; vertical-align: top; font-variant-numeric: tabular-nums; }
.ticket .totals { border-top: 1px dashed var(--ink-2); padding-top: 8px; }
.ticket-thanks { text-align: center; margin: 14px 0 0; color: var(--ink-2); }
.ticket.is-void .ticket-lines, .ticket.is-void .totals { opacity: .5; }
.stamp {
  margin: 14px auto 0; width: fit-content; padding: 4px 16px;
  border: 3px solid var(--danger); border-radius: 6px; color: var(--danger);
  font: 800 22px var(--font-display); transform: rotate(-6deg);
}

/* ---------- Avisos ---------- */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); }
.toast { padding: 12px 16px; border-radius: 10px; font-weight: 600; background: var(--ink); color: #fff; box-shadow: 0 10px 30px -10px rgb(0 0 0 / .5); }
.toast-error { background: var(--danger); }

/* ---------- Adaptación a pantallas pequeñas ---------- */
@media (max-width: 960px) {
  .pos { grid-template-columns: minmax(0, 1fr); height: auto; padding-bottom: 96px; }
  .grid { overflow: visible; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .cart-items { max-height: none; overflow: visible; }
  .mobile-bar { display: flex; }
  .toolbar .search { width: 100%; order: 3; }
}
@media (max-width: 560px) {
  .topbar { gap: 14px; padding: 0 12px; }
  .brand-txt { display: none; }
  .brand-ico { width: 40px; height: 40px; }
  .form-grid { grid-template-columns: 1fr; }
  h1 { font-size: 24px; }
}

/* ---------- Impresión del ticket ---------- */
@media print {
  body * { visibility: hidden; }
  #ticket, #ticket * { visibility: visible; }
  dialog { position: static !important; inset: auto; padding: 0; border: 0; box-shadow: none; max-height: none; overflow: visible; }
  #ticket { position: absolute; left: 0; top: 0; width: 76mm; font-size: 12px; }
  .ticket-logo { width: 42mm; max-width: none; }
  .ticket-logo .tl-pantalla { display: none; }
  .ticket-logo .tl-impresion { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .login-logo { animation: none; }
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Interruptor (categorías) y notas ---------- */
.hint { margin: -6px 0 16px; max-width: 70ch; color: var(--ink-2); }
.switch {
  position: relative; width: 44px; height: 26px; padding: 0; vertical-align: middle;
  border: 0; border-radius: 999px; background: #b9c4bd;
  transition: background-color .15s;
}
.switch span {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .3); transition: transform .15s;
}
.switch[aria-checked="true"] { background: var(--brand); }
.switch[aria-checked="true"] span { transform: translateX(18px); }
.switch:disabled { opacity: .6; }
.switch-text { margin-left: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); vertical-align: middle; }

.ticket-num { font: 800 18px var(--font-display); letter-spacing: -0.01em; }

.note { margin: -4px 0 0; min-height: 1.3em; font-size: 13px; color: var(--ink-2); }
.note-warn { color: var(--danger); font-weight: 600; }

/* ---------- Inventario ---------- */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar.sub { margin-bottom: 12px; }
.input.auto { width: auto; min-width: 180px; }
.saldo { font: 800 20px var(--font-display); font-variant-numeric: tabular-nums; }
.saldo.low { color: var(--danger); }
.saldo.zero { color: var(--danger); opacity: .8; }
.badge-in { background: var(--ok-soft); color: var(--brand-dark); }
.badge-out { background: var(--danger-soft); color: var(--danger); }
.badge-adj { background: #fff1c2; color: #6b4d00; }
.badge-warn { background: #fff1c2; color: #6b4d00; }
.badge-neutral { background: #ece9e4; color: #5b5147; }
.qty-in, .qty-out { font-weight: 700; font-variant-numeric: tabular-nums; }
.qty-in { color: var(--brand); }
.qty-out { color: var(--danger); }
.foot-note { margin: 10px 2px 0; }

/* ---------- Filtros de ventas ---------- */
.filtros { padding: 14px 16px; margin-bottom: 16px; }
.filtros-fila { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.nav-fecha { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav-fecha .input { width: auto; }
.nav-fecha .input.anio { width: 92px; }
.btn-icon { min-width: 42px; padding: 0; font-size: 22px; line-height: 1; }
.rango { margin: 10px 0 0; font-weight: 600; color: var(--ink-2); }

/* =========================================================
   SESIÓN: barra superior (caja y usuario) y login
   ========================================================= */
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.caja-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap;
  background: rgb(255 255 255 / .12); color: #fff;
}
.caja-chip:hover { background: rgb(255 255 255 / .2); }
.caja-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: #b9c4bd; }
.caja-chip.is-open .dot { background: #7ee2a8; box-shadow: 0 0 0 3px rgb(126 226 168 / .25); }
.caja-chip.is-closed { background: var(--signal); color: var(--signal-ink); }
.caja-chip.is-closed .dot { background: var(--signal-ink); }

.menu { position: relative; }
.menu summary::-webkit-details-marker { display: none; }
.ajustes-menu summary {
  list-style: none; cursor: pointer; padding: 8px 12px; border-radius: 999px;
  color: #d3eae2; font-weight: 600; white-space: nowrap;
}
.ajustes-menu summary:hover, .ajustes-menu[open] summary { background: rgb(255 255 255 / .12); }
.ajustes-menu summary[aria-current="page"] { background: #fff; color: var(--brand); }
.ajustes-menu .user-pop { width: 210px; }
a.user-item { text-decoration: none; color: var(--ink); }
.user-item[aria-current="page"] { background: var(--brand-soft); color: var(--brand-dark); }
.user-menu summary {
  list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 4px 10px 4px 4px; border-radius: 999px; color: #fff; font-weight: 600;
}
.user-menu summary:hover, .user-menu[open] summary { background: rgb(255 255 255 / .12); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; color: var(--brand); font: 800 15px var(--font-display);
}
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: 240px;
  background: var(--surface); color: var(--ink); border-radius: 12px; padding: 8px;
  box-shadow: 0 20px 50px -18px rgb(0 0 0 / .45), 0 0 0 1px var(--line);
}
.user-who { margin: 0 0 6px; padding: 8px 10px; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); }
.user-item {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: 8px;
  background: none; font-weight: 600;
}
.user-item:hover { background: var(--brand-soft); }
.user-salir { color: var(--danger); }
.user-salir:hover { background: var(--danger-soft); }
.user-pop form { margin: 0; }

.login-body { min-height: 100dvh; }
.login { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 480px); }
.login-brand {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--brand); color: #fff; padding: 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px;
  background-image:
    radial-gradient(circle at 50% 42%, rgb(255 255 255 / .16) 0, transparent 46%),
    radial-gradient(circle at 12% 12%, rgb(255 255 255 / .07) 0 140px, transparent 141px),
    radial-gradient(circle at 88% 86%, rgb(255 198 41 / .16) 0 200px, transparent 201px),
    linear-gradient(160deg, #0f6552 0%, var(--brand) 45%, var(--brand-dark) 100%);
}
/* textura sutil de cortes en el fondo */
.login-brand::before {
  content: ''; position: absolute; inset: -40%; z-index: -1; opacity: .035;
  background: url(../img/marca/icono-blanco.webp) 0 0 / 170px auto repeat;
  transform: rotate(-14deg);
}
.login-logo {
  width: clamp(230px, 30vw, 360px); padding: clamp(22px, 2.6vw, 34px);
  background: #fff; border-radius: 32px;
  box-shadow: 0 0 0 9px rgb(255 255 255 / .14),
              0 40px 80px -30px rgb(0 0 0 / .65), 0 12px 24px -12px rgb(0 0 0 / .35);
  animation: logo-in .7s cubic-bezier(.2, .8, .2, 1) both;
}
.login-logo img { width: 100%; height: auto; display: block; }
.login-brand-foot { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
@keyframes logo-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.login-tag {
  padding: 4px 12px 4px 10px; border-radius: 6px;
  background: var(--signal); color: var(--signal-ink); font: 800 14px var(--font-display);
}
.login-sub { color: #cfe7de; font-weight: 600; letter-spacing: .02em; }
.login-card-logo { width: 68px; height: auto; margin-bottom: 10px; }
.login-card { background: var(--surface); padding: 48px 40px; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.login-lead { margin: 4px 0 14px; font-size: 15px; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.login-card .form-error { margin: 0 0 8px; }
.btn-block { width: 100%; min-height: 48px; font-size: 16px; }

/* ---------- Estados generales ---------- */
.empty-state { padding: 32px; text-align: center; }
.empty-state h1 { margin-bottom: 8px; }
.callout { padding: 16px 18px; margin-bottom: 16px; border-left: 6px solid var(--signal); }
.callout p { margin: 4px 0 0; color: var(--ink-2); }
.upper { text-transform: uppercase; }
.is-off { opacity: .4; pointer-events: none; }
.filtro-extra { margin-top: 10px; gap: 8px; }
.hist-bar { margin-top: 28px; }
.hist-bar h2 { margin-right: auto; }

/* =========================================================
   CAJA
   ========================================================= */
.caja-open { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; padding: 26px; align-items: center; }
.caja-open-txt h2 { font-size: 26px; margin: 10px 0 6px; }
.caja-open-txt p { margin: 0; max-width: 52ch; }
.caja-open-form { display: flex; flex-direction: column; gap: 12px; }
.money-input { display: flex; align-items: stretch; }
.money-input span {
  display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line); border-right: 0;
  border-radius: var(--r-sm) 0 0 var(--r-sm); background: var(--paper); font-weight: 700; color: var(--ink-2);
}
.money-input .input { border-radius: 0 var(--r-sm) var(--r-sm) 0; font: 800 22px var(--font-display); font-variant-numeric: tabular-nums; }
.caja-live { padding: 20px 22px; }
.caja-live-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.caja-live-head h2 { margin: 8px 0 2px; font-size: 24px; }
.caja-live-head p { margin: 0; }
.caja-live-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.caja-live .summary { margin-bottom: 14px; }
.table.mini { min-width: 0; }
.table.mini th, .table.mini td { padding: 8px 10px; }

.dialog-cierre { width: min(640px, calc(100vw - 24px)); }
.arqueo { min-width: 0; margin: 12px 0 16px; }
.arqueo th, .arqueo td { padding: 8px 8px; }
.arqueo tfoot th { border-top: 2px solid var(--line); border-bottom: 0; color: var(--ink); font-size: 14px; }
.input-money { width: 120px; min-height: 38px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.dif { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dif-ok { color: var(--brand); }
.dif-mas { color: #8a5a00; }
.dif-menos { color: var(--danger); }

.reporte .ticket-lines th { font-size: 12px; text-align: left; padding: 4px 0; border-bottom: 1px dashed var(--ink-2); }
.reporte .ticket-lines th.right { text-align: right; }
.reporte .ticket-lines td { font-size: 13px; }
.firmas { display: flex; justify-content: space-between; gap: 20px; margin-top: 44px; }
.firmas span { flex: 1; text-align: center; padding-top: 6px; border-top: 1px solid var(--ink); font-size: 12px; }

/* ---------- Ticket: datos del emisor y firma ---------- */
.ticket-tipo { margin-top: 6px; font-weight: 700; }
.ticket-hash { margin: 10px 0 0; font-size: 11px; word-break: break-all; text-align: center; color: var(--ink-2); }
.ticket-legal { margin: 6px 0 0; font-size: 11px; text-align: center; color: var(--ink-2); }
.ticket-sunat { margin: 12px 0 0; font-size: 13px; }

/* =========================================================
   EMPRESA
   ========================================================= */
.emp-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.emp-main, .emp-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.panel { padding: 20px 22px; }
.panel h2 { margin-bottom: 2px; }
.panel-sub { margin: 0 0 16px; }
.pagos-grid.amb { grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
.pago-prod input:checked + span { background: var(--signal); border-color: #e0a800; color: var(--signal-ink); }
.sunat-grid { margin-top: 4px; }
.prefix-row { display: flex; }
.prefix {
  display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--line); border-right: 0;
  border-radius: var(--r-sm) 0 0 var(--r-sm); background: var(--paper); color: var(--ink-2); font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.prefix-row .input { border-radius: 0 var(--r-sm) var(--r-sm) 0; min-width: 0; }
.save-bar {
  position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 12px 30px -18px rgb(21 34 29 / .6);
}
.save-bar .form-error { margin: 0; flex: 1; }
.cert-card { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; margin-bottom: 16px; background: #fbfcfb; }
.cert-card.is-empty p { margin: 8px 0 0; color: var(--ink-2); }
.cert-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cert-dl { margin: 0; display: grid; gap: 8px; }
.cert-dl div { display: grid; gap: 1px; }
.cert-dl dt { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.cert-dl dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.cert-form { display: flex; flex-direction: column; gap: 12px; }
.cert-form .form-error { margin: 0; }
.cert-seg { margin: 0; }
.input-file { padding: 8px; }
.serie-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.serie-row + .serie-row { border-top: 1px dashed var(--line); }
.serie-cod { font: 800 22px var(--font-display); }
a.badge { text-decoration: none; }

@media (max-width: 1240px) {
  .topbar { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding: 10px 16px; row-gap: 8px; }
  .nav { order: 3; width: 100%; }
  .pos { height: auto; min-height: calc(100dvh - var(--topbar-h)); }
}
@media (max-width: 960px) {
  .emp-grid, .caja-open { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 32px 24px 28px; min-height: 0; gap: 18px; }
  .login-logo { width: min(220px, 62vw); border-radius: 24px; padding: 18px; }
  .login-card-logo { display: none; }
  .login-card { padding: 28px 24px 40px; }
}
@media (max-width: 560px) {
  .user-name, .caja-chip { font-size: 12px; }
  .user-name { display: none; }
  .input-money { width: 92px; }
}
@media (min-width: 1241px) and (max-width: 1480px) {
  .topbar { gap: 18px; }
  .nav a, .ajustes-menu summary { padding: 8px 11px; }
  .topbar-end { gap: 6px; }
  .user-name { display: none; }        /* solo la inicial: el nombre sigue en el menú */
}
.table td.right { white-space: nowrap; }
.badge { white-space: nowrap; }
