:root {
  --blue: #2A458C;
  --blue-dark: #1E3366;
  --red: #B4372A;
  --red-soft: #FBEAE8;
  --green: #1F7A4D;
  --bg: #F3F5FA;
  --card: #FFFFFF;
  --ink: #1B2233;
  --muted: #687089;
  --line: #DFE3EE;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(27, 34, 51, .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); min-width: 0; }
input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(42, 69, 140, .35); outline-offset: 1px; }
h1 { font-size: 1.5rem; margin: .25rem 0 .5rem; color: var(--blue); }
h2 { font-size: 1.05rem; margin: 0; }
h3 { margin: 1.5rem 0 .6rem; color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: .85em; font-weight: normal; }
.fine { color: var(--muted); font-size: .8rem; margin-top: 1rem; }
.error { color: var(--red); min-height: 1.2em; margin: .25rem 0; }
.pad { padding: 2rem; }
.empty { color: var(--muted); text-align: center; margin: auto; padding: 1rem; }
.empty.big { font-size: 1.2rem; }
.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

/* buttons */
.btn { border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: 10px 16px; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:not(:disabled):active { background: var(--blue-dark); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-ghost { color: var(--red); border-color: #F1C9C4; }
.btn.ghost { background: transparent; }
.btn.light { background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .35); }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.btn.tiny { padding: 4px 10px; font-size: .85rem; }
.btn.big { width: 100%; padding: 14px; font-size: 1.1rem; }

/* centered screens */
.center-screen { min-height: 100%; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--blue) 0 40%, var(--bg) 40%); }
.card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 28px; }
.card.narrow { width: min(420px, 100%); text-align: center; }
.card label { display: block; text-align: left; margin: 10px 0; font-weight: 600; font-size: .9rem; }
.card label input { display: block; width: 100%; margin-top: 4px; }
.hero-logo { width: 120px; height: 120px; object-fit: contain; }
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.btn.user { padding: 18px 10px; font-size: 1.05rem; }

/* pin pad */
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 12px 0 16px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--blue); }
.pin-dots i.on { background: var(--blue); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key { padding: 16px 0; font-size: 1.4rem; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; }
.key:active { background: #E8ECF6; }
.key.muted { font-size: 1rem; color: var(--muted); }
.key.primary { background: var(--blue); color: #fff; border-color: var(--blue); font-size: 1rem; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--blue); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; letter-spacing: .02em; }
.brand img { width: 40px; height: 40px; background: #fff; border-radius: 50%; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.who { opacity: .9; margin-right: 4px; }

/* register layout: top half orders, bottom half register */
.register { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr 1fr; overflow: hidden; }
.queue-pane { display: flex; flex-direction: column; min-height: 0; padding: 10px 14px 6px; border-bottom: 4px solid var(--red); }
.pane-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.pane-head .hint { color: var(--muted); font-size: .85rem; }
.count { color: var(--red); }
.queue { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; align-content: start; padding: 2px; }
.order { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border-top: 6px solid var(--blue); padding: 10px 12px; touch-action: pan-y; user-select: none; cursor: grab; transition: transform .15s, opacity .15s; }
.order.dragging { transition: none; cursor: grabbing; }
.order:nth-child(odd) { border-top-color: var(--red); }
.order header { display: flex; justify-content: space-between; align-items: baseline; }
.o-num { font-size: 1.6rem; font-weight: 800; color: var(--blue); }
.o-time { color: var(--muted); font-size: .8rem; }
.order ul { list-style: none; margin: 6px 0 0; padding: 0; font-size: 1.05rem; }
.order li { padding: 2px 0; }

.pos-pane { display: grid; grid-template-columns: 1fr minmax(300px, 380px); min-height: 0; }
.menu { overflow-y: auto; padding: 12px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; align-content: start; }
.drink { --c: var(--blue); gap: 4px; border: none; border-radius: var(--radius); background: var(--c); color: #fff; min-height: 84px; padding: 10px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; text-align: left; box-shadow: var(--shadow); }
.drink:active { transform: scale(.97); filter: brightness(.92); }
.d-name { font-weight: 700; font-size: 1.05rem; line-height: 1.15; }
.d-price { font-size: .95rem; opacity: .95; }
.ticket { background: var(--card); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ticket-lines { flex: 1; overflow-y: auto; padding: 8px 14px; min-height: 0; }
.line { display: grid; grid-template-columns: 1fr auto 70px; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.l-name { font-weight: 600; }
.l-amt { text-align: right; font-variant-numeric: tabular-nums; }
.qty { display: inline-flex; align-items: center; gap: 6px; }
.qty button { width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; font-weight: 700; }
.qty b { min-width: 18px; text-align: center; }
.ticket-sum { padding: 10px 14px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: grid; gap: 8px; }
.sum-row { display: flex; justify-content: space-between; align-items: center; font-size: 1.1rem; }
.sum-row strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.sum-row.tender input { width: 130px; text-align: right; font-size: 1.2rem; font-weight: 700; }
.quick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.quick button { padding: 8px 0; border-radius: 8px; border: 1.5px solid var(--line); background: #F7F8FC; font-weight: 600; font-size: .9rem; }
.quick button:active { background: #E8ECF6; }
.sum-row.change { background: #E7F4EC; color: var(--green); border-radius: 10px; padding: 6px 10px; }
.sum-row.change.short { background: var(--red-soft); color: var(--red); }

/* toast & modal */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; display: flex; gap: 14px; align-items: center; box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 50; max-width: 90vw; }
.toast-btn { background: none; border: none; color: #9FB6FF; font-weight: 700; padding: 0; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 20, 35, .5); display: grid; place-items: center; z-index: 40; padding: 20px; }
.modal-backdrop[hidden], .toast[hidden] { display: none; }
.modal { background: #fff; border-radius: 18px; padding: 22px; width: min(420px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.3); display: grid; gap: 12px; }
.modal h3 { margin: 0; }
.modal-text { margin: 0; font-size: 1.05rem; }
.change-modal { text-align: center; }
.change-modal p { margin: 4px 0; }
.big-label { font-size: 1.2rem; font-weight: 700; }
.big-money { font-size: 3.4rem; font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; }

/* admin */
.admin { min-height: 100%; display: flex; flex-direction: column; }
.admin .topbar { position: sticky; top: 0; z-index: 5; }
.tabs { display: flex; gap: 4px; padding: 0 14px; background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; position: sticky; top: 56px; z-index: 4; }
.tab { border: none; background: none; padding: 14px 16px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.on { color: var(--blue); border-bottom-color: var(--red); }
.admin-body { padding: 16px 18px 60px; max-width: 1100px; width: 100%; margin: 0 auto; }
.report-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.report-controls label { display: flex; gap: 6px; align-items: center; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 600; }
.chip.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat span { display: block; color: var(--muted); font-size: .9rem; }
.stat b { font-size: 1.8rem; color: var(--blue); font-variant-numeric: tabular-nums; }
.tbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { background: #F7F8FC; font-size: .85rem; color: var(--muted); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.void td { color: var(--muted); text-decoration: line-through; }
.tbl tr.void td:last-child { text-decoration: none; }
.bar-col { width: 35%; }
.bar { display: block; height: 12px; background: var(--blue); border-radius: 6px; min-width: 2px; }
.drink-list { display: grid; gap: 8px; }
.drink-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: #fff; padding: 10px; border-radius: 12px; box-shadow: var(--shadow); }
.drink-row input[type=color] { width: 46px; height: 42px; padding: 2px; }
.price-in { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.price-in input { width: 90px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.notice { background: #EEF2FB; border-left: 4px solid var(--blue); padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; }
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 18px 18px; margin-bottom: 14px; }
.panel label { display: grid; gap: 6px; font-weight: 600; max-width: 520px; }
.panel label input { max-width: 120px; }
.danger-zone { border: 1.5px solid #F1C9C4; }

/* smaller screens: keep the 50/50 split, tighten everything */
@media (max-width: 760px) {
  .pos-pane { grid-template-columns: 1fr 1fr; }
  .menu { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); padding: 8px; gap: 6px; }
  .drink { min-height: 64px; }
  .quick { grid-template-columns: repeat(3, 1fr); }
  .pane-head .hint, .who, .brand span { display: none; }
  .stats { grid-template-columns: 1fr; }
  .bar-col { display: none; }
}

/* sync */
.sync-pill { font-size: .8rem; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.15); color: #fff; white-space: nowrap; }
.sync-pill.ok::before, .sync-pill.syncing::before, .sync-pill.offline::before, .sync-pill.error::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #7BE0A5; }
.sync-pill.offline::before { background: #F5C451; }
.sync-pill.error { background: var(--red); }
.sync-pill.error::before { background: #fff; }
.stack-label { display: grid; gap: 4px; font-weight: 600; }
.card hr { border: none; border-top: 1px solid var(--line); margin: 18px 0 8px; }
@media (max-width: 760px) { .sync-pill { font-size: .7rem; padding: 3px 8px; } }
