:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1b2430; --muted: #66707e; --line: #dfe3e8;
  --brand: #0f6b5c; --brand-ink: #fff; --brand-soft: #e3f2ef;
  --danger: #b3261e; --warn: #9a6700; --warn-soft: #fff4d6; --ok: #1a7f37;
  --radius: 8px; --shadow: 0 8px 28px rgb(20 30 45 / 18%);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; min-width: 0;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}
input[type=checkbox] { width: auto; }
label.field { display: block; font-size: .85rem; color: var(--muted); }
label.field > span { display: block; margin-bottom: .2rem; }
label.check { display: flex; gap: .5rem; align-items: center; font-size: .92rem; }
button {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: .5rem .8rem; cursor: pointer;
}
button:hover { background: #f0f2f4; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.primary:hover { background: #0b574a; }
button.danger { color: var(--danger); border-color: #e7c1be; }
button.small { padding: .2rem .5rem; font-size: .85rem; }
kbd { font: .75em ui-monospace, monospace; background: rgb(0 0 0 / 8%); border-radius: 3px; padding: .05em .3em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: grid; gap: .7rem; }
.badge { font-size: .78rem; padding: .1rem .45rem; border-radius: 99px; background: #eceff2; white-space: nowrap; }
.badge.ok { background: #dcf3e3; color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: #fbe4e2; color: var(--danger); }

/* Estructura */
.shell { display: grid; grid-template-columns: 220px 1fr; height: 100%; }
.side { background: #16232f; color: #d6dee6; overflow-y: auto; padding: .7rem .5rem; display: flex; flex-direction: column; gap: .1rem; }
.side .brand { font-weight: 700; color: #fff; padding: .3rem .6rem .6rem; overflow-wrap: anywhere; }
.side a { color: inherit; text-decoration: none; padding: .42rem .6rem; border-radius: 6px; font-size: .93rem; }
.side a:hover { background: rgb(255 255 255 / 8%); }
.side a.active { background: var(--brand); color: #fff; }
.side h3 { font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: #8798a8; margin: .7rem .6rem .15rem; }
.side .foot { margin-top: auto; padding: .6rem; display: grid; gap: .4rem; font-size: .85rem; }
.side .foot button { background: transparent; color: inherit; border-color: #3a4a59; }
.side select { background: #223341; border-color: #3a4a59; color: #fff; }
.main { overflow-y: auto; padding: 1rem 1.2rem; min-width: 0; }
.menu-toggle { display: none; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; }
.page-head { display: flex; justify-content: space-between; gap: .8rem; align-items: center; margin-bottom: .8rem; flex-wrap: wrap; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; align-items: end; margin-bottom: .8rem; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: .78rem; color: var(--muted); font-weight: 600; background: #fafbfc; }
th, td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.empty { padding: 1.6rem; text-align: center; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem; margin-bottom: .8rem; }
.stat b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .82rem; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: .8rem; align-items: start; }

/* Terminal de venta */
.main.pos-main { padding: 0; overflow: hidden; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 330px; height: 100%; }
.pos-left { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: .7rem; gap: .6rem; }
.pos-right { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: .7rem; padding: .8rem; overflow-y: auto; }
.tabs { display: flex; gap: .3rem; overflow-x: auto; flex: none; }
.tabs button { white-space: nowrap; padding: .3rem .6rem; font-size: .88rem; }
.tabs button.active { background: var(--brand-soft); border-color: var(--brand); }
.scan { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; flex: none; }
.scan input { padding: .65rem .7rem; }
.scan input#scan { font-size: 1.1rem; border-color: var(--brand); }
.suggest { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); max-height: 340px; overflow-y: auto; }
.suggest button { display: flex; justify-content: space-between; gap: .8rem; width: 100%; border: 0; border-radius: 0; text-align: left; }
.suggest button.active { background: var(--brand-soft); }
.lines { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.lines input { padding: .25rem .35rem; text-align: right; width: 5.6rem; }
.lines .desc { min-width: 180px; }
.banner { background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: .5rem .7rem; display: flex; gap: .7rem; align-items: center; justify-content: space-between; flex: none; }
.total-box { background: #16232f; color: #fff; border-radius: var(--radius); padding: .8rem; text-align: right; }
.total-box span { font-size: .85rem; color: #b8c5d1; }
.total-box b { display: block; font-size: 2.2rem; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.breakdown { display: grid; grid-template-columns: 1fr auto; gap: .15rem .6rem; font-size: .92rem; }
button.pay { font-size: 1.15rem; padding: .85rem; font-weight: 600; }

/* Diálogos */
.overlay { position: fixed; inset: 0; background: rgb(15 23 32 / 45%); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; z-index: 50; overflow-y: auto; }
.dialog { background: #fff; border-radius: 10px; box-shadow: var(--shadow); width: 100%; max-width: 480px; padding: 1rem; }
.dialog.wide { max-width: 760px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.dialog-foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .9rem; flex-wrap: wrap; }
.pay-total { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; text-align: center; margin-bottom: .7rem; }
.pay-total div { background: var(--bg); border-radius: 6px; padding: .45rem .3rem; min-width: 0; }
.pay-total b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pay-total small { color: var(--muted); }
.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: .4rem; z-index: 90; max-width: min(360px, calc(100vw - 32px)); }
.toast { background: #16232f; color: #fff; padding: .55rem .8rem; border-radius: 6px; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); color: #fff; }
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; }

/* Ticket */
.ticket { font: 12px/1.3 "Courier New", ui-monospace, monospace; color: #000; background: #fff; }
.ticket.w80 { width: 72mm; }
.ticket.w58 { width: 48mm; font-size: 10.5px; }
.ticket .center { text-align: center; }
.ticket h4 { font-size: 1.2em; margin: 0; text-align: center; }
.ticket hr { border: 0; border-top: 1px dashed #000; margin: 4px 0; }
.ticket .line { display: flex; justify-content: space-between; gap: 6px; }
.ticket .pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.ticket .total { font-weight: 700; font-size: 1.25em; }
.ticket-preview { display: flex; justify-content: center; background: var(--bg); padding: .7rem; border-radius: 6px; max-height: 48vh; overflow: auto; }
.label-sheet { display: flex; flex-wrap: wrap; gap: 8px; }
.label { background: #fff; border: 1px dashed var(--line); padding: 6px; text-align: center; font-size: 11px; width: 190px; }
.label svg { max-width: 100%; height: 60px; }
#print-root { display: none; }

@page ticket58 { size: 58mm auto; margin: 2mm; }
@page ticket80 { size: 80mm auto; margin: 3mm; }

@media print {
  html, body { background: #fff; height: auto; }
  #app, #toasts, .overlay { display: none !important; }
  #print-root { display: block; }
  #print-root .w58 { page: ticket58; }
  #print-root .w80 { page: ticket80; }
  .label { border: 0; break-inside: avoid; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .menu-toggle { display: block; position: fixed; top: 8px; right: 12px; z-index: 40; }
  .side { display: none; position: fixed; inset: 0 25% 0 0; z-index: 35; }
  .side.open { display: flex; }
  .main { padding: .8rem 16px; padding-top: 3.2rem; }
  .main.pos-main { overflow-y: auto; padding-top: 2.8rem; }
  .pos { grid-template-columns: 1fr; height: auto; }
  .pos-right { border-left: 0; border-top: 1px solid var(--line); }
  .lines { max-height: 50vh; }
  .scan { grid-template-columns: 1fr; }
}
