:root {
  --bg: #f6f3ec;
  --card: #ffffff;
  --text: #1d2420;
  --muted: #66706a;
  --line: #e4ded2;
  --brand: #1f6f4a;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1e9;
  --accent: #d9822b;
  --danger: #c0392b;
  --danger-soft: #fbe9e7;
  --warn: #b7791f;
  --warn-soft: #fdf3dc;
  --ok: #2f855a;
  --ok-soft: #e6f4ea;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
  --radius: 14px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614; --card: #1b211e; --text: #e9eee9; --muted: #9aa59f; --line: #2b332f;
    --brand: #3fa874; --brand-ink: #0b1510; --brand-soft: #1d3328; --danger-soft: #3a1f1c;
    --warn-soft: #3a2f17; --ok-soft: #1c3326; --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .tiny { font-size: .75rem; }
.right { text-align: right; } .center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.screen { padding: 12px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin: 4px 0 12px; }
.topbar h1 { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stack > * + * { margin-top: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card + .card { margin-top: 10px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: var(--brand-soft); }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-title { margin: 18px 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }

/* ---------- bottom nav ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--card); border-top: 1px solid var(--line); z-index: 20; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none;
  color: var(--muted); font-size: .72rem; font-weight: 600; }
.nav a .ic { font-size: 1.35rem; line-height: 1; }
.nav a.active { color: var(--brand); }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.soft { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 1.1rem; }
.btn.sm { min-height: 34px; padding: 6px 10px; font-size: .85rem; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  font-size: .9rem; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
label.field { display: block; }
label.field > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.check { display: flex; gap: 10px; align-items: center; padding: 8px 0; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }
.search { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 4px 0 8px; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; background: var(--line); color: var(--text); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi .label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 1.35rem; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .78rem; color: var(--muted); }
.up { color: var(--ok); } .down { color: var(--danger); }

/* ---------- vender ---------- */
.sell-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.today-pill { font-size: .85rem; color: var(--muted); }
.mic-wrap { display: flex; flex-direction: column; align-items: center; padding: 10px 0 6px; }
.mic { width: 132px; height: 132px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); font-size: 3rem;
  box-shadow: 0 8px 24px rgba(31,111,74,.35); cursor: pointer; display: grid; place-items: center; position: relative; touch-action: manipulation; user-select: none; }
.mic.small { width: 64px; height: 64px; font-size: 1.6rem; box-shadow: 0 4px 12px rgba(31,111,74,.3); }
.mic.rec { background: var(--danger); box-shadow: 0 0 0 0 rgba(192,57,43,.6); animation: pulse 1.2s infinite; }
.mic.busy { background: var(--muted); }
.mic.busy::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 4px solid transparent; border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(192,57,43,.55); } 70% { box-shadow: 0 0 0 22px rgba(192,57,43,0); } 100% { box-shadow: 0 0 0 0 rgba(192,57,43,0); } }
@keyframes spin { to { transform: rotate(360deg); } }
.mic-hint { margin-top: 10px; color: var(--muted); font-size: .9rem; text-align: center; min-height: 1.3em; }
.transcript { font-style: italic; color: var(--muted); font-size: .9rem; margin: 6px 0; text-align: center; }
.cart { margin-top: 8px; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line .name { font-weight: 700; }
.line .spoken { font-size: .78rem; color: var(--muted); }
.line .amt { font-weight: 800; font-size: 1.1rem; text-align: right; font-variant-numeric: tabular-nums; }
.line .editors { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; }
.line .editors .input { min-height: 38px; padding: 6px 8px; }
.line.unmatched { background: var(--warn-soft); }
.line .warn-txt { grid-column: 1 / -1; font-size: .8rem; color: var(--warn); }
.inp-pre { position: relative; flex: 1; }
.inp-pre > i { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: .85rem; pointer-events: none; }
.inp-pre > .input, .line .editors .inp-pre > .input { padding-left: 22px; }
.inp-post { position: relative; flex: 1; }
.inp-post > i { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: .8rem; pointer-events: none; }
.inp-post > .input, .line .editors .inp-post > .input { padding-right: 30px; }
.totalbar { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 15; background: var(--card);
  border-top: 1px solid var(--line); padding: 10px 16px; display: flex; gap: 12px; align-items: center; }
.totalbar .t { flex: 1; }
.totalbar .t .lbl { font-size: .75rem; color: var(--muted); font-weight: 700; }
.totalbar .t .val { font-size: 1.7rem; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; }
.with-totalbar { padding-bottom: calc(var(--nav-h) + 110px + env(safe-area-inset-bottom)); }
.quick-products { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.qp { padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); text-align: center; font-weight: 600; font-size: .88rem; cursor: pointer; }
.qp small { display: block; color: var(--muted); font-weight: 500; font-size: .75rem; }
.answer { background: var(--brand-soft); color: var(--text); border-radius: var(--radius); padding: 12px 14px; font-weight: 600; }

/* ---------- sheet / modal ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--card); width: 100%; max-width: 640px; max-height: 92dvh; overflow: auto; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.sheet .sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; position: sticky; top: -16px; background: var(--card); padding: 6px 0; z-index: 2; }
.sheet .sheet-head h2 { margin: 0; }
@media (min-width: 700px) { .backdrop { align-items: center; } .sheet { border-radius: 18px; } }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 80; background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: 92vw; box-shadow: var(--shadow); animation: fade .2s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* ---------- pay ---------- */
.pay-total { text-align: center; font-size: 2.6rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.pay-change { text-align: center; font-size: 1.4rem; font-weight: 800; color: var(--ok); }
.methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.methods .btn { flex-direction: column; font-size: .78rem; padding: 8px 4px; min-height: 60px; }
.methods .btn .ic { font-size: 1.3rem; }
.methods .btn.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.bills { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }

/* ---------- login ---------- */
.login { max-width: 360px; margin: 0 auto; padding: 48px 16px; text-align: center; }
.login .logo { font-size: 3rem; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 18px 0; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--brand); }
.pin-dots span.on { background: var(--brand); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button { height: 64px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); font-size: 1.5rem; font-weight: 700; cursor: pointer; }
.keypad button:active { background: var(--brand-soft); }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .bar { fill: var(--brand); }
.chart .bar2 { fill: var(--accent); }
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 8px; align-items: center; padding: 5px 0; font-size: .88rem; }
.hbar .track { background: var(--brand-soft); border-radius: 6px; height: 12px; overflow: hidden; }
.hbar .fill { background: var(--brand); height: 100%; border-radius: 6px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.tbl th { font-size: .72rem; text-transform: uppercase; color: var(--muted); }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .ic { font-size: 2.4rem; }
.fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 18; width: 58px; height: 58px; border-radius: 50%;
  background: var(--brand); color: var(--brand-ink); border: 0; font-size: 1.8rem; box-shadow: var(--shadow); cursor: pointer; }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.menu-grid a { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 8px; text-align: center; text-decoration: none;
  color: var(--text); font-weight: 600; font-size: .9rem; }
.menu-grid a .ic { font-size: 1.8rem; display: block; margin-bottom: 4px; }
.receipt-img { width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.alert { border-radius: 12px; padding: 10px 12px; font-size: .9rem; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 20px auto; }

/* ---------- impresión de ticket (58/80 mm) ---------- */
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; width: 58mm; font: 11px/1.3 ui-monospace, monospace; color: #000; }
  #print-area .c { text-align: center; } #print-area .r { text-align: right; }
  #print-area table { width: 100%; border-collapse: collapse; }
  #print-area hr { border: 0; border-top: 1px dashed #000; }
  @page { margin: 2mm; size: 58mm auto; }
}
