:root {
  --bg: #f4f5f7; --panel: #fff; --text: #17202a; --muted: #5f6b7a; --line: #dde1e6;
  --brand: #0f766e; --brand-ink: #fff; --warn: #b45309; --bad: #b91c1c; --ok: #15803d;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161c; --panel: #1a222b; --text: #e8edf2; --muted: #9aa7b5; --line: #2c3743; --brand: #2dd4bf; --brand-ink: #062f2b; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
input, select { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); width: 100%; }
#app { display: flex; flex-direction: column; height: 100%; }
.bar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bar .grow { flex: 1; }
.pill { padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--ok); color: #fff; }
.pill.off { background: var(--warn); }
.pill.count { background: var(--muted); }
.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--panel); }
.tabs button { flex: 1; border: 0; border-radius: 0; border-bottom: 3px solid transparent; background: none; }
.tabs button.on { border-bottom-color: var(--brand); font-weight: 600; }
main { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 360px; gap: 12px; padding: 12px; }
@media (max-width: 800px) { main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow-y: auto; } }
.col { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; overflow-y: auto; align-content: start; }
.prod { height: auto; min-height: 76px; padding: 8px; text-align: left; display: flex; flex-direction: column; justify-content: space-between; }
.prod small { color: var(--muted); }
.cart { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.lines { overflow-y: auto; flex: 1; min-height: 80px; }
.line { display: grid; grid-template-columns: 1fr 70px 80px 36px; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.line select.rate { min-height: 32px; width: auto; min-width: 84px; margin-top: 4px; padding: 0 6px; display: block; }
.line input { min-height: 36px; padding: 0 6px; text-align: right; }
.line button { min-height: 36px; padding: 0; }
.right { text-align: right; font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-size: 24px; font-weight: 700; }
.muted { color: var(--muted); }
.list { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; color: #fff; }
.badge.pending { background: var(--warn); } .badge.synced { background: var(--ok); } .badge.rejected { background: var(--bad); }
.center { margin: auto; width: min(420px, 92vw); display: flex; flex-direction: column; gap: 10px; }
.msg { color: var(--bad); min-height: 1.4em; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; padding: 12px; }
.modal .card { width: min(380px, 100%); max-height: 92vh; overflow-y: auto; }
.row { display: flex; justify-content: space-between; gap: 8px; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; }
.print-only { display: none; }
.center-text { text-align: center; }
@media print {
  @page { margin: 2mm; }
  /* Solo se imprime el recibo/ticket abierto: todo lo demas de la pantalla se oculta (si no, sale la caja entera) */
  #app > :not(.modal) { display: none !important; }
  #app { display: block !important; height: auto !important; }
  .bar, .tabs, main, .toast { display: none !important; }
  html, body { height: auto !important; min-height: 0; overflow: visible; background: #fff; color: #000; font: 12px/1.3 ui-monospace, Menlo, Consolas, monospace; }
  .modal { position: static; display: block; background: none; padding: 0; }
  .modal .card { border: 0; border-radius: 0; padding: 0; width: 100%; max-height: none; overflow: visible; background: #fff; color: #000; }
  #receipt[data-paper="58"] .card, #ret-ticket[data-paper="58"] .card { width: 54mm; }
  #receipt[data-paper="80"] .card, #ret-ticket[data-paper="80"] .card { width: 76mm; }
  #ret-ticket[data-paper="58"] .qr svg { width: 44mm; }
  #ret-ticket[data-paper="80"] .qr svg { width: 52mm; }
  .modal .muted { color: #000; }
  .badge { display: none; }
  hr { border: 0; border-top: 1px dashed #000; }
  .noprint { display: none !important; }
  .print-only { display: block; }
}

.ok { color: var(--ok); font-weight: 600; min-height: 1.4em; }
.qr { display: inline-block; background: #fff; padding: 4px; }
.qr svg { display: block; width: 180px; height: auto; }
.ticket-btn { min-height: 36px; margin-top: 6px; }
label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; font-size: 14px; color: var(--muted); }
