@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@600;700&family=DM+Sans:wght@400;500;700&display=swap');

:root {
  --ground: #F7F7F2; --ink: #10231B; --muted: #55625B; --brand: #0F5132; --accent: #C2410C;
  --line: #E3E6DD; --tint: #E4EFE8; --card: #FFFFFF; --col: #ECEEE6;
  --ok-bg: #DDEFE3; --ok-fg: #0F5132; --warn-bg: #FFE9C7; --warn-fg: #7A4300; --neutral-bg: #E7ECEF; --neutral-fg: #2F3E46;
  --danger: #B42318;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.4; }
h1, h2, h3 { font-family: var(--display); margin: 0; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Botones (mínimo 48 px de alto: se usan con manos ocupadas) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px; border: 0; border-radius: 14px; font-weight: 700; font-size: 16px; background: var(--brand); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.cta { background: var(--accent); }
.btn.ghost { background: transparent; color: var(--brand); border: 2px solid var(--brand); }
.btn.block { width: 100%; }
.btn.small { min-height: 44px; padding: 0 16px; font-size: 15px; border-radius: 12px; }
.btn.danger { background: transparent; color: var(--danger); border: 2px solid var(--danger); }

.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--neutral-bg); color: var(--neutral-fg); }
.chip.ok { background: var(--ok-bg); color: var(--ok-fg); }
.chip.warn { background: var(--warn-bg); color: var(--warn-fg); }

#toasts { position: fixed; left: 0; right: 0; bottom: 96px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 500; max-width: 420px; }
.banner { padding: 10px 16px; background: var(--warn-bg); color: var(--warn-fg); font-weight: 700; text-align: center; }

/* ---------- Cliente ---------- */
.app { max-width: 520px; margin: 0 auto; padding-bottom: 120px; }
.topbar { position: sticky; top: 0; z-index: 10; background: var(--ground); border-bottom: 1px solid var(--line); }
.topbar-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 8px; }
.brand { font-family: var(--display); font-size: 22px; font-weight: 700; color: var(--brand); }
.mesa-tag { background: var(--tint); color: var(--brand); padding: 6px 14px; border-radius: 999px; font-weight: 700; }
.tabs { display: flex; gap: 4px; margin: 0 16px 10px; padding: 4px; background: var(--col); border-radius: 14px; }
.tab { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 700; }
.tab[aria-selected='true'] { background: #fff; color: var(--ink); }
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 10px; scrollbar-width: none; }
.cat { flex: none; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 700; color: var(--muted); }
.section-title { padding: 20px 16px 8px; font-size: 24px; }
.cards { display: grid; gap: 16px; padding: 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.card img, .card .ph { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--tint); }
.card .ph { display: flex; align-items: center; justify-content: center; font-size: 44px; }
.card-body { padding: 14px 16px 16px; }
.card h3 { font-size: 20px; }
.card p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.price { font-family: var(--display); font-size: 22px; font-weight: 700; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.step-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.step-btn.minus { background: var(--tint); color: var(--brand); }
.qty { min-width: 32px; text-align: center; font-weight: 700; font-size: 18px; }
.sold { color: var(--danger); font-weight: 700; }
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--ground) 30%); }
.dock-inner { max-width: 520px; margin: 0 auto; display: flex; gap: 10px; }
.dock .btn { flex: 1; }
.dock .btn.help { flex: none; }

.panel { padding: 16px; }
.panel h2 { font-size: 26px; margin-bottom: 12px; }
.lines { background: #fff; border: 1px solid var(--line); border-radius: 18px; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line .name { font-weight: 700; }
.line .sub { color: var(--muted); font-size: 14px; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 4px; font-family: var(--display); font-size: 28px; font-weight: 700; }
.field { display: block; margin: 14px 0; font-weight: 700; }
.field textarea, .field input, .field select { display: block; width: 100%; margin-top: 6px; padding: 12px; min-height: 48px; border: 1px solid #C9CFC4; border-radius: 12px; background: #fff; font-weight: 400; }
.order-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; margin-bottom: 12px; }
.order-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.timer { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; --bar: var(--brand); }
.timer[data-level='warn'] { --bar: #D97706; }
.timer[data-level='late'] { --bar: var(--accent); }
.timer[data-level='done'] { --bar: var(--ok-fg); }
.timer-track { flex: 1; height: 10px; border-radius: 999px; background: var(--col); overflow: hidden; }
.timer-fill { height: 100%; width: 0; border-radius: inherit; background: var(--bar); transition: width 1s linear, background-color .4s; }
.timer-time { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--bar); font-size: 15px; }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; }
.modal-back { position: fixed; inset: 0; background: rgba(16, 35, 27, .5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal { width: 100%; max-width: 520px; background: var(--ground); border-radius: 24px 24px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.modal h2 { margin-bottom: 12px; }
.modal .btn { margin-top: 10px; }
.big-status { text-align: center; padding: 40px 24px; }
.big-status .tick { width: 72px; height: 72px; border-radius: 50%; background: var(--ok-bg); color: var(--ok-fg); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 16px; }

/* ---------- Personal ---------- */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 20px; text-align: center; }
.login h1 { font-size: 32px; margin-bottom: 8px; }
.login .pin { text-align: center; letter-spacing: .4em; font-size: 24px; }
.err { color: var(--danger); font-weight: 700; min-height: 1.4em; margin: 8px 0; }
.bar { display: flex; align-items: center; gap: 16px; padding: 0 24px; min-height: 72px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bar h1 { font-size: 26px; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--col); border-radius: 14px; }
.seg button { min-height: 44px; padding: 0 22px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 700; }
.seg button[aria-selected='true'] { background: #fff; color: var(--ink); }
.grow { flex: 1; }
.clock { font-family: var(--display); font-size: 26px; font-weight: 700; }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; padding: 20px 24px 32px; align-items: start; }
.col { background: var(--col); border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 14px; min-height: 160px; }
.col-head { display: flex; justify-content: space-between; align-items: center; }
.col-head h2 { font-size: 22px; }
.count { min-width: 32px; height: 32px; padding: 0 8px; border-radius: 999px; background: var(--brand); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.ticket { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.ticket-head { display: flex; justify-content: space-between; align-items: center; }
.ticket-head .mesa { font-family: var(--display); font-size: 26px; font-weight: 700; }
.ticket ul { margin: 12px 0; display: flex; flex-direction: column; gap: 6px; font-size: 18px; font-weight: 700; }
.note { margin-bottom: 14px; padding: 8px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-fg); font-weight: 700; font-size: 14px; }
.waiter { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; padding: 20px 24px 32px; align-items: start; }
.alert { display: flex; gap: 12px; align-items: center; justify-content: space-between; background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--accent); border-radius: 14px; padding: 12px 14px; }
.alert.ready { border-left-color: var(--brand); }
.alert.clear, .alert.bill { border-left-color: #2F3E46; }
.alert .t { font-weight: 700; font-size: 18px; }
.alert .d { color: var(--muted); font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.mesa-row { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; flex-wrap: wrap; }
.mesa-row .n { font-family: var(--display); font-size: 22px; font-weight: 700; min-width: 72px; }
.mesa-row .amt { margin-left: auto; font-family: var(--display); font-size: 20px; font-weight: 700; }
.sum { margin-top: 14px; padding: 14px 16px; background: var(--tint); border-radius: 14px; display: flex; justify-content: space-between; font-weight: 700; }
@media (max-width: 900px) {
  .board, .waiter { grid-template-columns: 1fr; padding: 16px; }
  .bar { padding: 12px 16px; }
}

/* ---------- Administración ---------- */
.admin { max-width: 960px; margin: 0 auto; padding: 16px; }
.admin h2 { font-size: 24px; margin: 24px 0 12px; }
.prod-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; }
.prod-row img, .prod-row .ph { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--tint); display: flex; align-items: center; justify-content: center; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.qr-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; text-align: center; break-inside: avoid; }
.qr-card canvas { width: 100%; max-width: 200px; height: auto; image-rendering: pixelated; }
.qr-card .mesa { font-family: var(--display); font-size: 24px; font-weight: 700; }
@media print {
  body * { visibility: hidden; }
  #qr-print, #qr-print * { visibility: visible; }
  #qr-print { position: absolute; left: 0; top: 0; width: 100%; }
}
