:root {
  --bg: #0a2229;
  --surface: #10323b;
  --surface-2: #16414c;
  --line: #1f5360;
  --text: #e6f4f1;
  --muted: #8fb3b8;
  --accent: #2dd4bf;
  --accent-ink: #04252a;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; }
.boot, .empty { color: var(--muted); text-align: center; padding: 40px 16px; }

/* Barra superior y navegación */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.top h1 { flex: 1; margin: 0; font-size: 19px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .who { color: var(--muted); font-size: 13px; }
.top .back {
  display: grid; place-items: center; width: 40px; height: 40px; margin: -6px 0 -6px -8px;
  color: var(--accent); font-size: 30px; line-height: 1; text-decoration: none; border-radius: 10px;
}
.top .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

main { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
main.has-bar { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; max-width: 640px; margin: 0 auto;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; min-width: 0; padding: 16px 2px 14px; text-align: center; text-decoration: none;
  color: var(--muted); font-size: 13px; font-weight: 600; border-top: 3px solid transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tabs a.on { color: var(--accent); border-top-color: var(--accent); }
.tabs .n {
  display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; line-height: 18px;
}

/* Botones y campos */
button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px;
  padding: 12px 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); font-size: 16px; font-weight: 650; text-decoration: none; text-align: center;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 96px; font-size: 22px; letter-spacing: .5px; }
.btn.small { width: auto; min-height: 44px; padding: 8px 14px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, input:focus-visible, .card:focus-visible, .tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.row.wrap { flex-wrap: wrap; }

label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
input[type="text"], input[type="password"], input[type="search"] {
  width: 100%; min-height: 52px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-size: 17px;
}
input::placeholder { color: #6b8f95; }
.check { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.msg { margin: 0; color: var(--danger); font-size: 14px; min-height: 20px; }
.hint { margin: 0; color: var(--muted); font-size: 13px; }
h2 { margin: 22px 0 10px; color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; }
h2:first-child { margin-top: 0; }

/* Tarjetas y listas */
.list { display: grid; gap: 10px; margin-top: 14px; }
.card {
  display: block; width: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-align: left; text-decoration: none;
}
.card.off { opacity: .55; }
.card > .btn.small { margin-top: 12px; }
.pname { font-size: 17px; font-weight: 650; overflow-wrap: anywhere; }
.pmeta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.price { font-size: 17px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.badge {
  display: inline-block; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.badge.zero { border-color: var(--danger); color: var(--danger); background: transparent; }
.badge.void { border-color: var(--danger); color: var(--danger); background: transparent; }
.badge.plus { border-color: var(--accent); color: var(--accent); background: transparent; }
.badge.minus { border-color: var(--warn); color: var(--warn); background: transparent; }
.sub { margin-top: 4px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.line2 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.num { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.struck { text-decoration: line-through; color: var(--muted); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { margin-top: 2px; font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: 13px; }

.totalbox {
  display: flex; justify-content: space-between; align-items: baseline; margin-top: 16px; padding: 16px;
  border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface);
}
.totalbox .k { font-size: 15px; font-weight: 700; letter-spacing: 1px; }
.totalbox .v { font-size: 28px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }

/* Selector de cantidad */
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 52px; height: 52px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); font-size: 26px; font-weight: 600; line-height: 1;
}
.stepper button:disabled { opacity: .4; }
.stepper input { width: 84px; text-align: center; font-size: 22px; font-weight: 700; }
.stepper.mini button { width: 44px; height: 44px; font-size: 22px; }
.stepper.mini .q { min-width: 36px; text-align: center; font-size: 18px; font-weight: 700; }

/* Barra fija del carrito */
.bar {
  position: fixed; left: 0; right: 0; bottom: calc(53px + env(safe-area-inset-bottom)); z-index: 5;
  max-width: 640px; margin: 0 auto; padding: 10px 16px; background: linear-gradient(transparent, var(--bg) 30%);
}

/* Hoja inferior */
.sheet-bg { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: rgba(3, 14, 18, .72); }
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0; background: var(--bg);
}
.sheet h3 { margin: 0 0 14px; font-size: 19px; overflow-wrap: anywhere; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(120px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 480px; margin: 0 auto; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); font-weight: 600; text-align: center; display: none;
}
#toast.show { display: block; }
#toast.bad { border-color: var(--danger); }

/* Login */
.login { display: flex; flex-direction: column; justify-content: center; min-height: 100dvh; padding: 24px 20px; }
.login .mark { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 14px; display: block; }
.login h1 { margin: 0; text-align: center; font-size: 30px; letter-spacing: 3px; }
.login .tag { margin: 4px 0 28px; text-align: center; color: var(--muted); }

/* Ticket en pantalla */
.ticket {
  max-width: 380px; margin: 0 auto; padding: 22px 20px; border-radius: 6px;
  background: #fbfdfc; color: #0f172a; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.ticket .t-title { text-align: center; font-size: 24px; font-weight: 800; letter-spacing: 4px; }
.ticket .t-sub { text-align: center; color: #64748b; font-size: 11px; letter-spacing: 2px; margin-bottom: 12px; }
.ticket .t-rule { height: 3px; background: #0f766e; margin-bottom: 12px; }
.ticket .t-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; }
.ticket .t-row .k { color: #64748b; font-size: 13px; }
.ticket .t-folio { font-size: 18px; font-weight: 800; }
.ticket .t-dash { border-top: 1px dashed #94a3b8; margin: 12px 0; }
.ticket .t-item { margin-bottom: 10px; }
.ticket .t-name { font-weight: 700; overflow-wrap: anywhere; }
.ticket .t-total { display: flex; justify-content: space-between; font-size: 22px; font-weight: 800; }
.ticket .t-void { margin-top: 12px; padding: 8px; border: 2px solid #b91c1c; border-radius: 6px; color: #b91c1c; text-align: center; font-weight: 800; letter-spacing: 3px; }
.ticket .t-void small { display: block; font-weight: 500; letter-spacing: 0; }
.ticket .t-foot { margin-top: 14px; padding-top: 10px; border-top: 1px solid #cbd5e1; color: #64748b; font-size: 11px; text-align: center; }
.ticket .num { font-weight: 600; }
.ok-banner { margin: 0 0 14px; padding: 12px; border: 1px solid var(--accent); border-radius: var(--radius); color: var(--accent); font-weight: 700; text-align: center; }

@media print {
  body { background: #fff; }
  .top, .tabs, .bar, .no-print, #toast { display: none !important; }
  main { padding: 0; }
  .ticket { box-shadow: none; margin: 0 auto; }
}
