/* Phase 2: counter tablet. Big type and buttons, readable from a metre away, usable with wet hands. */
:root {
  --ink: #1f1a17;
  --muted: #6b625c;
  --paper: #faf7f2;
  --card: #ffffff;
  --line: #e3dcd2;
  --brand: #7a4b2a;
  --new: #c2410c;
  --new-soft: #fff1e6;
  --prep: #1d4ed8;
  --ready: #15803d;
  --danger: #b91c1c;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

/* Login and plain pages */
.plain { max-width: 28rem; margin: 10vh auto; padding: 2rem; background: var(--card); border-radius: 1rem; border: 1px solid var(--line); }
.plain h1 { font-size: 1.6rem; margin-top: 0; }
.plain label { display: block; margin: 1rem 0 .4rem; font-weight: 600; }
.plain input { width: 100%; font-size: 1.3rem; padding: .8rem; border-radius: .6rem; border: 2px solid var(--line); }
.plain button { margin-top: 1.4rem; width: 100%; min-height: 4rem; font-size: 1.3rem; font-weight: 700; border: 0; border-radius: .8rem; background: var(--brand); color: #fff; }
.plain [role="alert"] { color: var(--danger); font-weight: 700; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 800; font-size: 1.3rem; color: var(--brand); }
.topbar .who { color: var(--muted); flex: 1; }
.topbar form { margin: 0; }
.topbar button { min-height: 3rem; padding: 0 1.2rem; border-radius: .6rem; border: 2px solid var(--line); background: var(--card); }

.connection { padding: .5rem 1rem; font-size: 1rem; font-weight: 600; }
.connection.ok { background: #ecfdf3; color: var(--ready); }
.connection.waiting { background: #f1f5f9; color: var(--muted); }
.connection.error { background: var(--danger); color: #fff; font-size: 1.4rem; padding: 1rem; font-weight: 800; }

/* Phase 3: queue bar, pause and settings sheets */
.queue-bar { display: flex; align-items: center; gap: 1rem; margin: .6rem 1rem 0; padding: .8rem 1rem; border-radius: .8rem; border: 2px solid var(--line); background: var(--card); }
.queue-bar.open { border-color: var(--ready); }
.queue-bar.full { border-color: var(--new); background: var(--new-soft); }
.queue-bar.paused { border-color: var(--danger); background: #fef2f2; }
.queue-text { flex: 1; display: flex; flex-direction: column; gap: .2rem; }
.queue-text strong { font-size: 1.35rem; }
.queue-bar.paused .queue-text strong { color: var(--danger); }
.queue-text span { color: var(--muted); font-size: 1.05rem; }
.queue-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.queue-actions button { min-height: 3.6rem; padding: 0 1.3rem; border-radius: .8rem; border: 0; font-size: 1.15rem; font-weight: 800; color: #fff; }
.queue-actions .pause { background: var(--danger); }
.queue-actions .resume { background: var(--ready); }
.queue-actions .settings { background: var(--card); color: var(--ink); border: 2px solid var(--line); }
@media (max-width: 700px) { .queue-bar { flex-direction: column; align-items: stretch; } }

.sheet { border: 0; border-radius: 1.2rem; padding: 1.5rem; width: min(36rem, 94vw); max-height: 90vh; }
.sheet::backdrop { background: rgba(31, 26, 23, .6); }
.sheet h2 { margin: 0 0 .4rem; }
.sheet form + form { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.sheet .hint { color: var(--muted); margin: 0 0 .8rem; }
.sheet fieldset { border: 0; padding: 0; margin: 0 0 .8rem; }
.sheet legend, .sheet label { font-weight: 700; display: block; margin: .8rem 0 .4rem; }
.sheet input:not([type="radio"]), .sheet select { width: 100%; font: inherit; font-size: 1.2rem; padding: .7rem; border-radius: .6rem; border: 2px solid var(--line); background: #fff; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .6rem; }
.choice { display: flex; align-items: center; gap: .5rem; margin: 0; padding: .9rem; border: 2px solid var(--line); border-radius: .8rem; font-weight: 700; }
.choice:has(input:checked) { border-color: var(--brand); background: #f6ede4; }
.choice input { width: 1.4rem; height: 1.4rem; }
.choice-button { min-height: 3.4rem; border-radius: .8rem; border: 2px solid var(--line); background: #fff; font-weight: 700; font-size: 1.1rem; }
.sheet-actions { display: flex; gap: .8rem; margin-top: 1.2rem; }
.sheet-actions button { flex: 1; min-height: 3.8rem; border-radius: .8rem; font-size: 1.2rem; font-weight: 800; border: 0; }
.sheet-actions .cancel { background: #eee7df; color: var(--ink); }
.sheet-actions .confirm { background: var(--brand); color: #fff; }
.form-error { color: var(--danger); font-weight: 700; }

/* Phase 4: closed branch, stock and hours sheets */
.queue-bar.closed { border-color: #475569; background: #f1f5f9; }
.queue-bar.closed .queue-text strong { color: #334155; }
.sheet.wide { width: min(52rem, 96vw); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sheet-head .close { min-width: 3.2rem; min-height: 3.2rem; border-radius: 50%; border: 2px solid var(--line); background: #fff; font-size: 1.3rem; }
.sheet h3 { margin: 1.4rem 0 .6rem; font-size: 1.2rem; }
.stock-list { display: flex; flex-direction: column; gap: .5rem; }
.stock-row { display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem; border: 2px solid var(--line); border-radius: .8rem; }
.stock-row.off { border-color: var(--danger); background: #fef2f2; }
.stock-text { flex: 1; display: flex; flex-direction: column; gap: .15rem; }
.stock-text strong { font-size: 1.15rem; }
.stock-text span { color: var(--danger); font-size: .98rem; font-weight: 600; }
.stock-buttons { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.stock-buttons button { min-height: 3.2rem; padding: 0 1rem; border-radius: .7rem; font-weight: 800; font-size: 1.02rem; border: 2px solid var(--line); background: #fff; }
.stock-buttons .off-today { border-color: var(--new); color: var(--new); }
.stock-buttons .off-open { border-color: var(--danger); color: var(--danger); }
.stock-buttons .on { background: var(--ready); border-color: var(--ready); color: #fff; }
.weekly { display: flex; flex-direction: column; gap: .5rem; }
.weekly-row { display: grid; grid-template-columns: 6.5rem 4.5rem 1fr auto 1fr; align-items: center; gap: .6rem; }
.weekly-row input[type="time"], .weekly-row input.closes { width: 100%; }
.sheet label.inline { display: flex; align-items: center; gap: .4rem; margin: 0; font-weight: 600; }
.sheet label.inline input { width: 1.4rem; height: 1.4rem; }
.special-add { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .6rem; align-items: end; margin-top: .8rem; }
.special-add label { margin: 0; }
.empty-note { color: var(--muted); }

.confirm-message { font-size: 1.2rem; line-height: 1.6; margin: .4rem 0 0; }

/* Phase 5: cancel and refunds */
.card .cancel-order { color: var(--danger); border-color: #f3c4c4; }
.sheet-actions .danger { background: var(--danger); color: #fff; }
.refunds { margin: 1rem 1rem 0; padding: 1rem; border-radius: 1rem; border: 2px solid var(--danger); background: #fef2f2; }
.refunds h2 { margin: 0 0 .6rem; font-size: 1.3rem; color: var(--danger); }
.refund-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .7rem 0; border-top: 1px solid #f3c4c4; }
.refund-row.refund_pending .stock-text span { color: var(--muted); }
.refund-row .stock-text .refund-rule { font-weight: 700; color: #b42318; }
.manual-refund { display: flex; gap: .5rem; flex-wrap: wrap; }
.manual-refund input { min-height: 3.2rem; font: inherit; padding: 0 .8rem; border-radius: .7rem; border: 2px solid var(--line); min-width: 14rem; }
.manual-refund button { min-height: 3.2rem; padding: 0 1rem; border-radius: .7rem; font-weight: 800; border: 0; background: var(--ready); color: #fff; }

.notice { margin: .6rem 1rem 0; padding: .6rem 1rem; border-radius: .6rem; background: #fef9c3; color: #713f12; }

/* Lanes */
.lanes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; padding: 1rem; align-items: start; }
@media (max-width: 900px) { .lanes { grid-template-columns: 1fr; } }
.lane h2 { margin: 0 0 .6rem; font-size: 1.5rem; display: flex; align-items: center; gap: .5rem; }
.lane .count { display: inline-grid; place-items: center; min-width: 2.2rem; height: 2.2rem; border-radius: 1.1rem; background: var(--ink); color: #fff; font-size: 1.2rem; }
.lane-paid .count { background: var(--new); }
.lane-preparing .count { background: var(--prep); }
.lane-ready .count { background: var(--ready); }
.empty { color: var(--muted); font-size: 1.2rem; padding: 1.5rem 0; text-align: center; border: 2px dashed var(--line); border-radius: 1rem; }

/* Cards */
.card { background: var(--card); border: 2px solid var(--line); border-radius: 1rem; padding: 1rem; margin-bottom: 1rem; }
.card.status-paid { border-color: var(--new); background: var(--new-soft); }
.card.status-preparing { border-color: var(--prep); }
.card.status-ready { border-color: var(--ready); }
.card.status-picked_up { opacity: .8; }
.card.fresh { animation: flash 1s ease-in-out infinite alternate; }
@keyframes flash { from { box-shadow: 0 0 0 0 rgba(194, 65, 12, .0); } to { box-shadow: 0 0 0 .5rem rgba(194, 65, 12, .45); } }
@media (prefers-reduced-motion: reduce) { .card.fresh { animation: none; box-shadow: 0 0 0 .4rem rgba(194, 65, 12, .45); } }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.queue { font-size: 3rem; font-weight: 900; letter-spacing: .02em; line-height: 1; }
.meta { display: flex; flex-direction: column; align-items: flex-end; color: var(--muted); font-size: 1.05rem; }
.elapsed { font-weight: 700; color: var(--ink); }
.items { list-style: none; margin: .8rem 0; padding: 0; }
.items li { padding: .45rem 0; border-top: 1px solid var(--line); }
.items strong { display: block; font-size: 1.35rem; }
.items .options { display: block; font-size: 1.1rem; color: var(--muted); }
.total { margin: .2rem 0 .8rem; color: var(--muted); font-size: 1.05rem; }
/* Phase 6: guest (no account) orders show the masked phone; managers can reveal it (audited). */
.guest { margin: -.5rem 0 .8rem; color: var(--muted); font-size: 1rem; }
.card .guest .link-button, .guest .link-button { width: auto; display: inline; padding: .3rem .6rem; border: 1px solid currentColor; border-radius: .5rem; background: transparent; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.card button { width: 100%; border-radius: .8rem; border: 0; }
.card .primary { min-height: 4.5rem; font-size: 1.45rem; font-weight: 800; color: #fff; background: var(--ink); }
.card .next-preparing { background: var(--new); }
.card .next-ready { background: var(--prep); }
.card .next-picked_up { background: var(--ready); }
.card .secondary { margin-top: .6rem; min-height: 3.2rem; font-size: 1.05rem; background: transparent; border: 2px solid var(--line); color: var(--muted); }
.card button:disabled { opacity: .6; }

.recent { padding: 0 1rem 1rem; }
.recent h2 { font-size: 1.2rem; color: var(--muted); }
.recent-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; }
.recent .queue { font-size: 2rem; }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); max-width: 90vw; padding: 1rem 1.4rem; border-radius: .8rem; background: var(--ink); color: #fff; font-size: 1.2rem; font-weight: 700; }

/* Start of shift: one tap so the browser lets the page play sound */
.start-screen { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(31, 26, 23, .85); z-index: 10; padding: 1rem; }
.start-box { background: var(--card); border-radius: 1.2rem; padding: 2rem; max-width: 34rem; text-align: center; }
.start-box h1 { margin-top: 0; }
.start-box p { font-size: 1.15rem; color: var(--muted); }
#start { width: 100%; min-height: 5rem; font-size: 1.6rem; font-weight: 800; border: 0; border-radius: 1rem; background: var(--brand); color: #fff; }
body.has-waiting .start-box h1::after { content: " · มีออเดอร์ใหม่รออยู่"; color: var(--new); }

/* Phase 7: counter sales and the managers' reports page */
.topbar .top-link { min-height: 3rem; display: inline-flex; align-items: center; padding: 0 1.2rem; border-radius: .6rem; border: 2px solid var(--line); background: var(--card); color: var(--ink); font-weight: 700; text-decoration: none; }
.queue-actions .counter-sale { background: var(--brand); }
.reports { max-width: 72rem; margin: 0 auto; padding: 1rem; }
.report-range { display: flex; flex-wrap: wrap; align-items: end; gap: .8rem; margin-bottom: .6rem; }
.report-range label { display: grid; gap: .3rem; font-weight: 700; }
.report-range input { font: inherit; font-size: 1.1rem; padding: .6rem; border-radius: .6rem; border: 2px solid var(--line); }
.report-range .confirm, .report-range .choice-button { min-height: 3rem; padding: 0 1.2rem; }
.report-range .choices { flex-basis: 100%; }
.report-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .8rem; margin: 1rem 0; }
.report-tile { background: var(--card); border: 2px solid var(--line); border-radius: .9rem; padding: .9rem 1rem; }
.report-tile span { display: block; color: var(--muted); font-size: .95rem; }
.report-tile strong { display: block; font-size: 1.6rem; margin-top: .2rem; }
.report-block { background: var(--card); border: 2px solid var(--line); border-radius: 1rem; padding: 1rem; margin-bottom: 1rem; overflow-x: auto; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.report-head h2 { margin: 0; }
.report-block .csv { font-weight: 700; color: var(--brand); cursor: pointer; text-decoration: underline; }
.report-table { width: 100%; border-collapse: collapse; margin-top: .6rem; font-size: 1rem; }
.report-table th, .report-table td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.report-table td.num, .report-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table tfoot td { font-weight: 800; }

/* POS phase 1: the sale screen. Tablet first: big tiles, chips and buttons (at least 3.4rem tall). */
body.pos-open { overflow: hidden; }
.pos { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; background: var(--paper); }
.pos-bar { display: flex; align-items: center; gap: .8rem; padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.pos-title { font-size: 1.3rem; color: var(--brand); }
.pos-shift { flex: 1; color: var(--muted); font-weight: 600; }
.pos-back, .pos-small { min-height: 3.2rem; padding: 0 1.1rem; border-radius: .7rem; border: 2px solid var(--line); background: #fff; font-weight: 800; color: var(--ink); }
.pos-noshift { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1.2rem; margin: .8rem 1rem 0; padding: 1rem; border: 2px solid var(--new); border-radius: 1rem; background: var(--new-soft); }
.pos-noshift strong { font-size: 1.3rem; color: var(--new); }
.pos-noshift label { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.pos-noshift input { width: 10rem; font: inherit; font-size: 1.3rem; padding: .6rem; border-radius: .6rem; border: 2px solid var(--line); }
.pos-noshift .form-error { flex-basis: 100%; margin: 0; }
.pos-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(19rem, 26rem); gap: 1rem; padding: 1rem; }
.pos-menu { min-height: 0; display: flex; flex-direction: column; gap: .8rem; }
.pos-tabs { display: flex; gap: .5rem; overflow-x: auto; }
.pos-tab { flex: none; min-height: 3.4rem; padding: 0 1.3rem; border-radius: 2rem; border: 2px solid var(--line); background: #fff; font-weight: 800; font-size: 1.1rem; color: var(--ink); }
.pos-tab.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pos-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: .8rem; align-content: start; }
.pos-item { min-height: 7rem; display: flex; flex-direction: column; justify-content: space-between; gap: .4rem; text-align: left; padding: .9rem; border-radius: 1rem; border: 2px solid var(--line); background: #fff; color: var(--ink); }
.pos-item strong { font-size: 1.2rem; line-height: 1.3; }
.pos-item span { font-size: 1.15rem; font-weight: 800; color: var(--brand); }
.pos-item:active { background: #f6ede4; }
.pos-item.off { background: #f1ede8; color: #9a918a; border-style: dashed; }
.pos-item.off span { color: var(--danger); }
.pos-cart { min-height: 0; display: flex; flex-direction: column; gap: .6rem; padding: 1rem; border-radius: 1rem; border: 2px solid var(--line); background: var(--card); }
.cart-head { display: flex; align-items: center; justify-content: space-between; }
.cart-head h2 { margin: 0; }
.cart-lines { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: .3rem .6rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.cart-line.off .cart-text strong::after { content: " (หมด)"; color: var(--danger); }
.cart-text { display: flex; flex-direction: column; }
.cart-text strong { font-size: 1.15rem; }
.cart-text span { color: var(--muted); }
.cart-text .cart-custom { color: var(--new); font-weight: 700; }
.cart-amount { font-size: 1.15rem; }
.cart-controls { grid-column: 1 / -1; display: flex; gap: .4rem; }
.cart-controls button { min-height: 3rem; min-width: 3rem; padding: 0 .8rem; border-radius: .6rem; border: 2px solid var(--line); background: #fff; font-weight: 800; color: var(--ink); }
.cart-controls .step { font-size: 1.4rem; }
.cart-controls .remove { margin-left: auto; color: var(--danger); }
.cart-empty { color: var(--muted); text-align: center; padding: 1.5rem 0; }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; margin: 0; font-size: 1.2rem; color: var(--muted); }
.cart-total strong { font-size: 2rem; color: var(--ink); }
.pay { min-height: 4.4rem; border: 0; border-radius: 1rem; background: var(--ready); color: #fff; font-size: 1.45rem; font-weight: 900; padding: 0 1.4rem; }
.pay:disabled { background: #b8b0a8; }
.pos-recent summary { cursor: pointer; font-weight: 700; color: var(--muted); padding: .4rem 0; }
.pos-recent > div { max-height: 14rem; overflow-y: auto; }
.recent-sale { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-top: 1px solid var(--line); }
@media (max-width: 860px) {
  .pos-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .pos-cart { max-height: 45vh; }
}

/* Drink options panel */
.opt-group h3 { margin: 1rem 0 .5rem; }
.opt-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.opt { min-height: 3.6rem; padding: 0 1.2rem; border-radius: .9rem; border: 2px solid var(--line); background: #fff; font-weight: 800; font-size: 1.1rem; color: var(--ink); }
.opt.on { border-color: var(--brand); background: var(--brand); color: #fff; }
.opt.off { color: #9a918a; border-style: dashed; }
.item-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.2rem; }
.stepper { display: flex; align-items: center; gap: .6rem; }
.stepper button { width: 3.6rem; height: 3.6rem; border-radius: 50%; border: 2px solid var(--line); background: #fff; font-size: 1.6rem; font-weight: 900; }
.stepper output { min-width: 2.5rem; text-align: center; font-size: 1.8rem; font-weight: 900; }
.sheet label.item-price { display: flex; align-items: center; gap: .4rem; margin: 0; white-space: nowrap; }
.sheet label.item-price input { width: 7rem; }

/* Payment */
.pay-amount { font-size: 1.3rem; margin: .2rem 0 1rem; }
.pay-amount strong { font-size: 2.4rem; margin-left: .4rem; }
.pay-methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.pay-method { min-height: 5.5rem; border-radius: 1rem; border: 0; font-size: 1.4rem; font-weight: 900; color: #fff; }
.method-cash { background: var(--ready); }
.method-promptpay { background: #0e4d92; }
.method-other { background: #fff; color: var(--ink); border: 2px solid var(--line); font-size: 1.05rem; }
.sheet .pos-toggle { display: flex; align-items: center; gap: .6rem; margin: .5rem 0; font-weight: 700; }
.sheet .pos-toggle input { width: 1.6rem; height: 1.6rem; }
.cash-quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: .6rem; margin: .8rem 0; }
.cash-quick .quick { min-height: 3.8rem; border-radius: .8rem; border: 2px solid var(--line); background: #fff; font-size: 1.2rem; font-weight: 800; }
.change-line { font-size: 1.4rem; margin: .6rem 0; }
.change-line strong { font-size: 2.6rem; color: var(--ready); margin-left: .4rem; }
.qr-box { display: grid; place-items: center; min-height: 18rem; padding: 1rem; border-radius: 1rem; background: #fff; border: 2px solid var(--line); }
.qr-box img { width: min(20rem, 70vw); height: auto; image-rendering: pixelated; }
.qr-wait { color: var(--muted); font-size: 1.15rem; text-align: center; }
.qr-status { font-size: 1.15rem; font-weight: 700; text-align: center; }
.done-mark { font-size: 1.6rem; font-weight: 900; color: var(--ready); margin: .4rem 0; }
.done-queue { font-size: 4rem; font-weight: 900; margin: .2rem 0; }
.done-change { font-size: 2rem; font-weight: 800; margin: .2rem 0 1rem; }

/* Shift close */
.shift-summary { display: flex; flex-direction: column; gap: .2rem; margin: .6rem 0; }
.summary-row { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.shift-diff { font-size: 1.3rem; font-weight: 800; }

/* POS on its own page (/pos): the top bar, the connection bar, then the sale screen filling the rest. */
body.pos-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.pos-root { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pos-page .pos { position: static; flex: 1; min-height: 0; }
.topbar .pos-link { background: var(--brand); border-color: var(--brand); color: #fff; }

/* KDS: scan box, last scan result, label settings */
.kds-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin: .6rem 1rem 0; padding: .6rem 1rem; border-radius: .8rem; border: 2px solid var(--line); background: var(--card); }
.scan-form { display: flex; align-items: center; gap: .6rem; }
.scan-form label { font-weight: 800; }
.scan-form input { width: 17rem; font: inherit; font-size: 1.1rem; padding: .6rem; border-radius: .6rem; border: 2px solid var(--line); text-transform: uppercase; }
.scan-result { flex: 1; min-width: 14rem; margin: 0; padding: .5rem .9rem; border-radius: .6rem; font-size: 1.3rem; font-weight: 800; background: #f1f5f9; color: var(--muted); }
.scan-result.ok { background: #eff6ff; color: var(--prep); }
.scan-result.done { background: #ecfdf3; color: var(--ready); font-size: 1.6rem; }
.scan-result.warn { background: #fef9c3; color: #713f12; }
.scan-result.danger { background: var(--danger); color: #fff; font-size: 1.6rem; }
.label-settings { display: flex; align-items: center; gap: 1rem; }
.label-settings label { display: flex; align-items: center; gap: .4rem; font-weight: 700; }
.label-settings input[type="checkbox"] { width: 1.4rem; height: 1.4rem; }
.label-settings select { font: inherit; padding: .4rem; border-radius: .5rem; border: 2px solid var(--line); }
.cups-done { margin: -.4rem 0 .8rem; font-weight: 800; color: var(--muted); }
.cups-done.some { color: var(--prep); }

/* Printing: only #print-area. Receipts on 80 mm paper; labels one CSS page each, at the chosen size. */
.print-area { display: none; }
@media print {
  @page { size: 80mm auto; margin: 0; }
  @page label-40x60 { size: 40mm 60mm; margin: 0; }
  @page label-50x70 { size: 50mm 70mm; margin: 0; }
  @page label-50x80 { size: 50mm 80mm; margin: 0; }
  body > *:not(#print-area) { display: none !important; }
  html, body { background: #fff; min-height: 0; height: auto; overflow: visible; display: block; }
  .print-area { display: block; color: #000; }
  .print-area.paper-receipt { width: 72mm; padding: 2mm 4mm 6mm; font-size: 11pt; line-height: 1.35; }
  .r-logo { display: block; width: 30mm; height: auto; margin: 0 auto 1.5mm; }
  .r-shop { text-align: center; font-size: 16pt; font-weight: 900; }
  .r-center { text-align: center; }
  .r-queue { text-align: center; font-size: 20pt; font-weight: 900; margin: 1.5mm 0; }
  .r-small { font-size: 9pt; }
  .r-pair { display: flex; justify-content: space-between; gap: 2mm; }
  .r-item { font-weight: 700; }
  .r-detail { font-size: 9pt; padding-left: 3mm; }
  .r-total { font-size: 14pt; font-weight: 900; }
  .r-rule { border: 0; border-top: 1px dashed #000; margin: 1.5mm 0; }

  .label { break-after: page; }
  .label:last-child { break-after: auto; }
  .label-40x60 { page: label-40x60; }
  .label-50x70 { page: label-50x70; }
  .label-50x80 { page: label-50x80; }
}

/* Cup label (KDS), tall like a cup sticker. Shared by print and the on-screen sample; sizes in mm. */
.label { display: flex; flex-direction: column; overflow: hidden; box-sizing: border-box; padding: 2.5mm 2.5mm 2mm;
  background: #fff; color: #000; font-size: 6.5pt; line-height: 1.25; }
.label-40x60 { width: 40mm; height: 60mm; }
.label-50x70 { width: 50mm; height: 70mm; }
.label-50x80 { width: 50mm; height: 80mm; }
.label > * { flex-shrink: 0; } /* only the space above the QR row stretches; nothing gets squeezed out */
.l-brand { display: flex; align-items: center; gap: 2mm; padding-bottom: .8mm; border-bottom: .3mm solid #000; }
.l-logo { width: 10mm; height: auto; display: block; flex: none; }
.l-where { min-width: 0; text-align: right; margin-left: auto; font-size: 6pt; line-height: 1.3; }
.l-channel { font-size: 7pt; font-weight: 800; }
.l-queue { font-size: 18pt; font-weight: 500; letter-spacing: .02em; line-height: 1.1; margin: .6mm 0 .4mm; }
.l-title { font-size: 8.5pt; font-weight: 800; line-height: 1.2; max-height: 2.4em; overflow: hidden; }
.l-options { font-size: 7pt; margin-top: .5mm; }
.l-toppings { font-size: 7pt; font-weight: 700; }
.l-middle { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5mm; }
.l-info { min-width: 0; font-size: 6pt; line-height: 1.35; }
.l-cup { font-size: 8pt; font-weight: 800; }
.l-code { font-size: 5pt; letter-spacing: .02em; }
.l-qrbox { flex: none; display: flex; flex-direction: column; align-items: center; }
.l-hint { font-size: 5pt; }
.l-qr { width: 13mm; height: 13mm; display: block; }
.l-qr path { fill: #000; }
.l-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 1mm; margin-top: 1mm; padding-top: .8mm;
  border-top: .2mm solid #000; white-space: nowrap; }
.l-note { font-size: 5pt; }
.l-brandline { font-size: 5.5pt; font-weight: 800; letter-spacing: .03em; }
.label-50x70 .l-queue, .label-50x80 .l-queue { font-size: 26pt; }
.label-50x70 .l-title, .label-50x80 .l-title { font-size: 12pt; max-height: 3.6em; }
.label-50x70 .l-options, .label-50x80 .l-options, .label-50x70 .l-toppings, .label-50x80 .l-toppings { font-size: 9pt; }
.label-50x70 .l-info, .label-50x80 .l-info { font-size: 7pt; }
.label-50x70 .l-cup, .label-50x80 .l-cup { font-size: 9.5pt; }
.label-50x70 .l-qr, .label-50x80 .l-qr { width: 19mm; height: 19mm; }
.label-50x80 .l-qr { width: 21mm; height: 21mm; }
.label-50x70 .l-note, .label-50x80 .l-note { font-size: 6pt; }
.label-50x70 .l-logo, .label-50x80 .l-logo { width: 17mm; }
.label-50x70 .l-where, .label-50x80 .l-where { font-size: 7pt; }
.label-50x70 .l-channel, .label-50x80 .l-channel { font-size: 8.5pt; }
.label-50x70 .l-brandline, .label-50x80 .l-brandline { font-size: 6.5pt; }

/* On-screen sample ("ดูตัวอย่างใบปะหน้า" on the KDS) */
.label-preview { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1rem; padding: 1rem; background: #e7e2db; border-radius: .8rem; }
.label-preview { justify-content: center; }
.label-preview .label { box-shadow: 0 1px 4px rgba(0, 0, 0, .25); zoom: 2; }