/* AGAMEMNON POS — ธีมสว่าง มินิมอล: งาช้างอ่อน / ขาว / เอสเปรสโซ / ทองโบราณ
   ตัวหนังสือเข้มบนพื้นอ่อนเพื่ออ่านง่ายในแสงจ้า; ทองสว่างใช้เป็นพื้นปุ่ม ทองเข้มใช้เป็นตัวหนังสือ */
:root {
  --bg: #faf7f0;
  --surface: #ffffff;
  --surface-2: #f4efe3;
  --line: #e6dfce;
  --line-strong: #cdc2a8;
  --ink: #2b2118;
  --ink-dim: #65584a;
  --ink-faint: #6f6454;
  --espresso: #4a3224;
  --espresso-ink: #fbf6ea;
  --gold: #c8a257;
  --gold-hi: #d5b169;
  --gold-soft: #f6ecd2;
  --gold-ink: #7d5f1c;
  --on-gold: #241a0d;
  --ok: #35702e;       --ok-soft: #e5f0df;
  --low: #8f5f00;      --low-soft: #fbefd0;
  --out: #ad3420;      --out-soft: #f8e1da;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(43, 33, 24, .06), 0 4px 14px rgba(43, 33, 24, .06);
  --font-body: "Sukhumvit Set", "Thonburi", "Noto Sans Thai", "Sarabun", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Cormorant Garamond", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --meander: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='8' viewBox='0 0 32 8'%3E%3Cpath d='M0 7.5h2V.5h12v5H6V3h4M16 7.5h2V.5h12v5h-8V3h4' fill='none' stroke='%23c8a257' stroke-width='1'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
body.modal-open { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
h1, h2, h3, p { margin: 0; }
button, a, input, select, summary { touch-action: manipulation; }
.tile, .btn, .rail-item, .chip { user-select: none; -webkit-user-select: none; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.muted { color: var(--ink-dim); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pad { padding: 20px; }

/* ---------- shell ---------- */
.shell { display: flex; flex-direction: column; height: 100dvh; padding-top: env(safe-area-inset-top); }
.topbar {
  position: relative; display: flex; align-items: center; gap: 24px; min-height: 60px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); flex: none;
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 6px; background: var(--meander) repeat-x; opacity: .45; pointer-events: none; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; flex: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1.5px solid var(--gold); color: var(--gold-ink); font-family: var(--font-display); font-size: 22px; font-weight: 700; border-radius: 4px; }
.brand-name { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: .14em; }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-link { display: inline-flex; align-items: center; min-height: 48px; padding: 0 14px; color: var(--ink-dim); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
.nav-link[aria-current="true"] { color: var(--ink); border-bottom-color: var(--gold); font-weight: 700; }
.who { display: flex; align-items: center; gap: 10px; flex: none; }
.role-pill { padding: 3px 12px; background: var(--gold-soft); color: var(--gold-ink); border-radius: 999px; font-size: 14px; font-weight: 600; }
.view { flex: 1; min-height: 0; overflow: auto; padding-top: 12px; }

/* ---------- buttons / forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; transition: transform .08s, background .12s; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn-lg { min-height: 60px; font-size: 18px; }
.btn-block { width: 100%; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.btn-gold:hover:not(:disabled) { background: var(--gold-hi); }
.btn-ghost { background: transparent; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-dim); font-weight: 500; }
.btn-danger { background: var(--out); border-color: var(--out); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #92291a; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink-dim); font-size: 28px; line-height: 1; border-radius: var(--radius); }
.input, .search {
  width: 100%; min-height: 48px; padding: 0 14px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 8px; font-size: 16px;
}
.input::placeholder, .search::placeholder { color: var(--ink-faint); }
.field { display: grid; gap: 6px; }
.field-label { color: var(--ink-dim); font-size: 14px; font-weight: 500; }
.field-hint { color: var(--ink-faint); font-size: 13px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-error { padding: 10px 12px; border-left: 3px solid var(--out); background: var(--out-soft); color: #7a2314; border-radius: 6px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink-dim); }
.chip[aria-pressed="true"] { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg-btn { min-height: 48px; padding: 0 16px; background: transparent; border: 0; color: var(--ink-dim); font-weight: 500; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line-strong); }
.seg-btn[aria-pressed="true"] { background: var(--espresso); color: var(--espresso-ink); font-weight: 700; }
.seg-btn:disabled { opacity: .4; }
.stepper { display: inline-flex; align-items: center; gap: 2px; }
.stepper button { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 22px; line-height: 1; }
.stepper .qty { min-width: 34px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper.big button { width: 56px; height: 56px; }
.stepper.big .qty { min-width: 56px; font-size: 24px; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.ok, .pill.paid { background: var(--ok-soft); color: var(--ok); }
.pill.low, .pill.pending { background: var(--low-soft); color: var(--low); }
.pill.out, .pill.cancelled { background: var(--out-soft); color: var(--out); }
.empty { padding: 36px 16px; text-align: center; color: var(--ink-dim); }
.empty-title { font-size: 18px; color: var(--ink); }
.empty-hint { margin-top: 6px; }

.toggle { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0; background: transparent; border: 0; color: var(--ink); text-align: left; }
.toggle-knob { position: relative; flex: none; width: 46px; height: 26px; border-radius: 999px; background: var(--line-strong); transition: background .15s; }
.toggle-knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.toggle[aria-checked="true"] .toggle-knob { background: var(--espresso); }
.toggle[aria-checked="true"] .toggle-knob::after { transform: translateX(20px); }
.toggle-row { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.toggle-col { display: grid; gap: 2px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); display: grid; gap: 18px; padding: 32px 28px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 12px; box-shadow: var(--shadow); }
.login-brand { display: grid; justify-items: center; gap: 8px; margin-bottom: 6px; }
.login-brand .brand-mark { width: 52px; height: 52px; font-size: 32px; }
.login-brand .brand-name { font-size: 28px; }
.login-sub { color: var(--ink-dim); }
.pin { text-align: center; letter-spacing: .3em; font-size: 20px; }

/* ---------- POS ---------- */
.pos { height: 100%; display: grid; grid-template-columns: 168px minmax(0, 1fr) 400px; }
.rail { display: flex; flex-direction: column; padding: 8px 0; overflow-y: auto; border-right: 1px solid var(--line); }
.rail-item { text-align: left; min-height: 56px; padding: 0 16px; background: transparent; border: 0; border-left: 4px solid transparent; color: var(--ink-dim); font-weight: 500; }
.rail-item[aria-current="true"] { background: var(--surface); border-left-color: var(--gold); color: var(--ink); font-weight: 700; }
.menu-area { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 10px 16px 16px; gap: 12px; }
.tiles { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; align-content: start; padding-bottom: 12px; }
.tile-group { grid-column: 1 / -1; margin-top: 6px; color: var(--gold-ink); font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: .03em; }
.tile {
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px; min-height: 116px; padding: 14px; text-align: left;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .08s;
}
.tile:hover:not(:disabled) { border-color: var(--gold); }
.tile:active:not(:disabled) { transform: scale(.985); background: var(--gold-soft); }
.tile-name { font-size: 18px; font-weight: 600; line-height: 1.25; }
.tile-en { margin-top: -6px; color: var(--ink-dim); font-size: 13px; }
.tile-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: auto; }
.tile-price { font-family: var(--font-display); font-size: 25px; font-weight: 700; color: var(--gold-ink); font-variant-numeric: tabular-nums; }
.tile-note { color: var(--ink-dim); font-size: 13px; text-align: right; }
.tile.off { background: repeating-linear-gradient(135deg, #f1ece0 0 8px, #f7f3e9 8px 16px); box-shadow: none; color: var(--ink-faint); }
.tile.off .tile-price { color: var(--ink-faint); }
.tile.off .tile-note { color: var(--out); font-weight: 600; }

.receipt {
  position: relative; display: flex; flex-direction: column; min-height: 0; margin: 0 14px 14px 0;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: var(--radius); box-shadow: var(--shadow);
}
.receipt-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 4px; }
.receipt-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.receipt-close { display: none; }
.receipt .seg { margin: 6px 16px 10px; }
.lines { flex: 1; min-height: 80px; overflow-y: auto; padding: 0 16px; }
.line { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px 10px; padding: 10px 0; border-bottom: 1px dashed var(--line-strong); }
.line-main { display: grid; min-width: 0; }
.line-name { font-weight: 600; }
.line-opts { color: var(--ink-dim); font-size: 14px; }
.line-err { color: var(--out); font-size: 14px; font-weight: 600; }
.line.invalid .line-name { text-decoration: line-through; }
.line-total { min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.extras { display: grid; gap: 10px; padding: 10px 16px 0; }
.notice-wrap { padding: 8px 16px 0; }
.notice.warn { padding: 10px 12px; border-left: 3px solid var(--out); background: var(--out-soft); color: #7a2314; border-radius: 6px; font-size: 14px; }
.receipt-foot { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 2px solid var(--ink); display: grid; gap: 10px; }
.total-row { display: flex; align-items: baseline; justify-content: space-between; }
.total { font-family: var(--font-display); font-size: 38px; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn-pay { min-height: 64px; font-size: 20px; }
.cart-bar { display: none; }

/* ---------- modal / sheet ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(43, 33, 24, .45); }
.modal { width: min(480px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 12px; box-shadow: 0 20px 50px rgba(43, 33, 24, .25); animation: rise .16s ease-out; }
.modal.wide { width: min(640px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 0 20px; }
.modal-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.modal-body { padding: 14px 20px 20px; overflow-y: auto; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

.opts { display: grid; gap: 18px; }
.opt-group { display: grid; gap: 8px; }
.opt-title { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.req-tag { padding: 1px 8px; background: var(--gold-soft); color: var(--gold-ink); border-radius: 999px; font-size: 12px; font-weight: 600; }
.hint { color: var(--ink-faint); font-size: 13px; font-weight: 400; }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.opt { min-height: 56px; padding: 6px 12px; display: grid; gap: 2px; place-content: center; text-align: center; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.opt[aria-pressed="true"] { background: var(--gold-soft); border-color: var(--gold); border-width: 2px; font-weight: 600; }
.opt-delta { color: var(--gold-ink); font-size: 13px; }
.opt-qty { display: flex; align-items: center; justify-content: space-between; }

.pay { display: grid; justify-items: center; gap: 14px; text-align: center; }
.pay > * { max-width: 100%; }
.pay-order { color: var(--ink-dim); }
.pay-amount { font-family: var(--font-display); font-size: 60px; font-weight: 700; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.qr { width: min(280px, 70vw); aspect-ratio: 1; object-fit: contain; background: #fff; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.qr-missing { padding: 16px; border: 1px dashed var(--line-strong); color: var(--ink-dim); border-radius: 8px; font-size: 14px; }
.pay .btn-block { margin-top: 4px; }
.pay-alt { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pay .form-error { text-align: left; width: 100%; }

/* ---------- pages ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 14px 20px 28px; display: grid; gap: 14px; align-content: start; }
.page.wide { max-width: 1400px; }
.page-head { display: flex; align-items: baseline; gap: 14px; }
.page-head h1 { font-family: var(--font-display); font-size: 32px; font-weight: 700; }
.count { color: var(--ink-dim); }
.lead { max-width: 60ch; }

.queue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.ticket { display: grid; gap: 10px; padding: 14px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-top: 5px solid var(--gold); border-radius: var(--radius); box-shadow: var(--shadow); }
.ticket.late { border-top-color: var(--out); background: #fffaf8; }
.ticket-head { display: flex; justify-content: space-between; align-items: baseline; }
.ticket-no { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.ticket-age { font-size: 14px; color: var(--ink-dim); }
.ticket.late .ticket-age { color: var(--out); font-weight: 700; }
.ticket-channel { color: var(--ink-dim); font-size: 14px; }
.ticket-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ticket-items li { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 20px; font-weight: 600; }
.ti-qty { color: var(--gold-ink); font-variant-numeric: tabular-nums; }
.ti-opts { flex-basis: 100%; font-size: 15px; font-weight: 400; color: var(--ink-dim); }

.order-list { display: grid; gap: 8px; }
.order-row { display: grid; grid-template-columns: 130px 1fr auto 90px; align-items: center; gap: 12px; min-height: 60px; padding: 8px 14px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.order-row:hover { border-color: var(--gold); }
.order-no { font-weight: 700; font-variant-numeric: tabular-nums; }
.order-meta { color: var(--ink-dim); font-size: 14px; }
.order-total { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.detail { display: grid; gap: 10px; }
.detail-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.detail-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.kv { display: flex; justify-content: space-between; gap: 12px; }
.kv .k { color: var(--ink-dim); }
.owner-only { display: grid; gap: 6px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.cancel-paid { display: grid; gap: 14px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.data { width: 100%; border-collapse: collapse; }
.data th { position: sticky; top: 0; text-align: left; padding: 10px 14px; background: var(--surface-2); color: var(--ink-dim); font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data th.num { text-align: right; }
.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data tr:last-child td { border-bottom: 0; }
.data tr.inactive td { opacity: .55; }
.data td.actions { white-space: nowrap; text-align: right; }
.data td[colspan] { color: var(--ink-dim); }
.data tfoot td { font-weight: 700; background: var(--surface-2); }
.cell-name { display: block; font-weight: 600; }

.usage-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.usage-form { display: grid; gap: 16px; }
.usage-history h2 { font-family: var(--font-display); font-size: 24px; margin-bottom: 8px; }
.qty-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.qty-row .input { width: 140px; }
.reason-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.reason-host { display: grid; gap: 10px; }
.evidence summary { cursor: pointer; color: var(--ink-dim); min-height: 44px; display: flex; align-items: center; }
.history { display: grid; gap: 6px; }
.history-row { display: grid; grid-template-columns: 52px auto 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.hr-reason { grid-column: 2 / -1; color: var(--ink-dim); font-size: 14px; }
.hr-item { font-weight: 600; }
.hr-qty, .hr-cost { font-variant-numeric: tabular-nums; }

/* ---------- picker ---------- */
.picker { position: relative; display: grid; gap: 8px; }
.picker-list { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; max-height: 340px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 12px 28px rgba(43, 33, 24, .18); }
.picker-item { min-height: 52px; padding: 8px 12px; display: flex; align-items: center; border-radius: 8px; cursor: pointer; }
.picker-item.active, .picker-item:hover { background: var(--gold-soft); }
.picker-note { padding: 14px 12px; color: var(--ink-dim); }
.pick-row { display: flex; align-items: center; gap: 12px; width: 100%; }
.pick-name { flex: 1; min-width: 0; font-weight: 600; }
.pick-meta { color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.picker-selected { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 14px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.picker-chosen { flex: 1; min-width: 0; }

/* ---------- toast / flash ---------- */
.toasts { position: fixed; z-index: 80; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; width: min(520px, calc(100% - 24px)); pointer-events: none; }
.toast { padding: 12px 16px; background: var(--espresso); color: var(--espresso-ink); border-left: 5px solid var(--gold); border-radius: 8px; box-shadow: 0 8px 22px rgba(43, 33, 24, .3); animation: rise .16s ease-out; }
.toast.ok { border-left-color: #8fc27f; }
.toast.error { border-left-color: #f08a73; }
.flash { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; justify-items: center; gap: 8px; background: rgba(250, 247, 240, .95); pointer-events: none; animation: flash-in .18s ease-out, flash-out .3s ease-in 1.2s forwards; }
.flash-mark { display: grid; place-items: center; width: 112px; height: 112px; border: 4px solid var(--gold); border-radius: 50%; color: var(--gold-ink); font-size: 64px; line-height: 1; }
.flash-title { font-family: var(--font-display); font-size: 44px; font-weight: 700; }
.flash-sub { color: var(--ink-dim); font-size: 20px; }
@keyframes flash-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes flash-out { to { opacity: 0; } }

/* ---------- จัดการ (เจ้าของ) ---------- */
.hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.hub-tile { display: grid; gap: 6px; align-content: start; min-height: 112px; padding: 20px; background: var(--surface); color: var(--ink); text-decoration: none; border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius); box-shadow: var(--shadow); }
.hub-tile:hover { border-color: var(--gold); }
.hub-tile:active { background: var(--gold-soft); }
.hub-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; }
.hub-hint { color: var(--ink-dim); }
.admin-head { align-items: center; flex-wrap: wrap; }
.admin-head .back { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink-dim); text-decoration: none; }
.head-actions { margin-left: auto; display: flex; gap: 8px; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; }
.card { display: grid; gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.sub-title { margin-top: 8px; font-family: var(--font-display); font-size: 20px; }
.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 200px; gap: 12px; align-items: end; }
.field.grow { min-width: 0; }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; min-width: 0; }
select.input { padding-right: 8px; }
.p-lines { display: grid; gap: 12px; }
.p-line { display: grid; gap: 8px; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.p-line-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.p-line-fields .input { width: 150px; flex: 0 1 150px; }
.unit-host { display: contents; }
.total-row.dark { padding: 6px 0; }
.adjust-preview { min-height: 24px; color: var(--gold-ink); font-weight: 600; }
.cost-est { color: var(--gold-ink); font-weight: 600; }
.cost-panel { display: grid; gap: 10px; }
.channel-list, .group-list { display: grid; gap: 12px; }
.banner-wrap:empty { display: none; }
.banner-wrap .notice.warn { background: var(--low-soft); color: #5e3d00; border-left-color: var(--low); }
.channel-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: var(--radius); box-shadow: var(--shadow); }
.channel-card.inactive { opacity: .6; }
.channel-main { display: grid; gap: 6px; justify-items: start; }
.channel-name { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.channel-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.group-card { display: grid; gap: 10px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.group-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.group-head .btn { margin-left: auto; }
.tags { display: flex; align-items: center; gap: 10px; }
.opt-editors { display: grid; gap: 12px; }
.opt-editor { display: grid; gap: 10px; padding: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.opt-editor-head { display: grid; grid-template-columns: minmax(160px, 1.4fr) minmax(120px, .8fr) auto auto; gap: 8px; align-items: center; }
.two-pane { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
.list-pane { display: grid; gap: 12px; }
.menu-list { display: grid; gap: 6px; }
.menu-row { display: grid; gap: 2px; padding: 12px 14px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid transparent; border-radius: 8px; }
.menu-row:hover { border-color: var(--line-strong); }
.menu-row[aria-current="true"] { background: var(--gold-soft); border-left-color: var(--gold); }
.mr-name { font-weight: 600; }
.mr-meta { color: var(--ink-dim); font-size: 14px; }
.mr-badges { display: flex; gap: 6px; }
.mr-badges:empty { display: none; }
.editor { display: grid; gap: 16px; }
.editor-head { display: flex; align-items: center; gap: 12px; }
.editor-head h2 { font-family: var(--font-display); font-size: 28px; font-weight: 700; }
.back-list { display: none; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.sticky-actions { position: sticky; bottom: 0; display: grid; gap: 8px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }

/* ---------- ภาพรวม / รายงาน / ปิดวัน / ค่าใช้จ่าย ---------- */
.period-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.period-row .input { width: 170px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.kpi { display: grid; gap: 2px; align-content: start; padding: 18px 20px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi-label { color: var(--ink-dim); font-size: 14px; font-weight: 500; }
.kpi-value { font-family: var(--font-display); font-size: 40px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--ink-faint); font-size: 14px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.attention { display: grid; gap: 8px; }
.attn-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 10px 14px; background: var(--low-soft); border-left: 4px solid var(--low); border-radius: 8px; color: #4d3200; text-decoration: none; }
.attn-item.bad { background: var(--out-soft); border-left-color: var(--out); color: #6b2112; }
.attn-item.calm { background: var(--ok-soft); border-left-color: var(--ok); color: #274d23; }
.attn-go { font-weight: 700; white-space: nowrap; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bar-row:last-child { border-bottom: 0; }
.bar-name { font-weight: 600; }
.bar-val { font-variant-numeric: tabular-nums; color: var(--ink-dim); text-align: right; }
.bar { grid-column: 1 / -1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--gold); border-radius: 999px; }
.waterfall { display: grid; }
.wf-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.wf-row.sum { font-weight: 700; border-bottom: 2px solid var(--ink); }
.wf-row.minus span:last-child { color: var(--out); }
.wf-row.final { font-family: var(--font-display); font-size: 24px; font-weight: 700; border-bottom: 0; }
.tab-row { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { min-height: 48px; padding: 0 16px; background: transparent; border: 0; border-bottom: 3px solid transparent; color: var(--ink-dim); font-weight: 500; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); font-weight: 700; }
.checks { display: grid; gap: 8px; }
.check { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: 8px; }
.check.ok { border-left-color: var(--ok); }
.check.warn { border-left-color: var(--low); background: #fffdf5; }
.check.error { border-left-color: var(--out); background: #fffaf8; }
.check.info { border-left-color: var(--gold); }
.check-title { font-weight: 600; }
.check-detail { grid-column: 2; color: var(--ink-dim); font-size: 14px; }
.check-items { grid-column: 2; margin: 0; padding-left: 18px; color: var(--ink-dim); font-size: 14px; }
.ack { display: flex; gap: 10px; align-items: center; min-height: 48px; }
.ack input { width: 24px; height: 24px; accent-color: var(--espresso); }
.expense-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 4px 14px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: 8px; }
.expense-row.overdue { border-left-color: var(--out); background: #fffaf8; }
.expense-row.paid { border-left-color: var(--ok); }
.expense-row.voided { opacity: .5; }
.expense-name { font-weight: 600; }
.expense-meta { grid-column: 1; color: var(--ink-dim); font-size: 14px; }
.expense-amount { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.expense-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1099px) {
  .pos { grid-template-columns: 132px minmax(0, 1fr) 340px; }
  .usage-grid { grid-template-columns: 1fr; }
}
@media (max-width: 899px) {
  .two-pane { grid-template-columns: 1fr; }
  .two-pane.editing .list-pane { display: none; }
  .two-pane:not(.editing) .menu-editor { display: none; }
  .back-list { display: inline-flex; }
  .form-row { grid-template-columns: 1fr; }
  .opt-editor-head { grid-template-columns: 1fr 1fr; }
  .kpi { border-right: 0; border-bottom: 1px solid var(--line); }
  .kpi:last-child { border-bottom: 0; }
}
@media (max-width: 699px) {
  .topbar { gap: 10px; padding: 0 10px; }
  .brand-name { display: none; }
  .who .btn { padding: 0 8px; }
  .pos { display: flex; flex-direction: column; }
  .rail { flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--line); padding: 0; flex: none; }
  .rail-item { flex: none; border-left: 0; border-bottom: 4px solid transparent; min-height: 52px; }
  .rail-item[aria-current="true"] { border-bottom-color: var(--gold); }
  .menu-area { flex: 1; padding-bottom: 76px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .receipt { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; margin: 0; max-height: 88dvh; border-radius: 16px 16px 0 0; transform: translateY(105%); transition: transform .2s ease-out; }
  .receipt.open { transform: none; }
  .receipt-close { display: block; }
  .cart-bar { display: block; position: fixed; z-index: 35; left: 0; right: 0; bottom: 0; min-height: 64px; padding-bottom: env(safe-area-inset-bottom); border: 0; background: var(--gold); color: var(--on-gold); font-size: 18px; font-weight: 700; }
  .order-row { grid-template-columns: 1fr auto; }
  .order-meta { grid-column: 1 / -1; order: 3; }
  .field-row { grid-template-columns: 1fr; }
  .page { padding: 10px 12px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- เงินสด / ชื่อลูกค้า ---------- */
.pay-methods { display: flex; width: 100%; }
.pay-methods .seg-btn { flex: 1; padding: 0 8px; }
.pay-panel { display: grid; justify-items: center; gap: 12px; width: 100%; }
.pay-panel > * { max-width: 100%; }
.qr-panel { display: grid; justify-items: center; gap: 12px; width: 100%; }
.pay-note { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--espresso); margin-top: -6px; }
.cash-panel { display: grid; gap: 12px; width: 100%; }
.cash-keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cash-keys .btn { min-width: 92px; min-height: 58px; font-size: 18px; font-variant-numeric: tabular-nums; }
.cash-input { min-height: 64px; text-align: center; font-size: 28px; font-variant-numeric: tabular-nums; }
.change-line { min-height: 48px; font-family: var(--font-display); font-size: 36px; font-weight: 700; font-variant-numeric: tabular-nums; }
.change-line.ok { color: var(--ok); }
.change-line.short { color: var(--out); }
.change-line.idle { color: var(--ink-faint); font-family: var(--font-body); font-size: 17px; font-weight: 500; line-height: 48px; }
.note-field { padding: 0 16px 6px; }
.note-input { min-height: 44px; }
.receipt .note-input { background: var(--surface); }
.ticket-note { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--espresso); line-height: 1.15; word-break: break-word; }
.order-who { color: var(--ink); }

/* ---------- เตรียมของ ---------- */
.stack { display: grid; gap: 14px; }
.prep-card { gap: 10px; }
.prep-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.prep-head .card-title { margin-right: auto; }
.prep-line { font-variant-numeric: tabular-nums; }
.to-make { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--gold-ink); }
.ratio { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--espresso); }
.cups-input { width: 110px; text-align: center; font-size: 20px; }
.plan-row .p-line-fields { align-items: center; }
.data tr.short-row td { background: var(--out-soft); }
.shopping .detail-lines strong { color: var(--out); font-variant-numeric: tabular-nums; }

/* ---------- สำรองข้อมูล ---------- */
.backup-status { font-size: 18px; font-weight: 600; }
.cmd-block { display: grid; gap: 4px; }
.cmd-title { color: var(--ink-dim); font-size: 14px; }
.cmd { margin: 0; padding: 12px 14px; overflow-x: auto; background: var(--espresso); color: var(--espresso-ink); border-radius: 8px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 15px; user-select: all; -webkit-user-select: all; }
