/* ---------- tokens ---------- */
:root {
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --surface-3: #e7e7ec;
  --text: #17171c;
  --muted: #6e6e78;
  --border: #e3e3e8;
  --accent: #ff5a1f;
  --accent-2: #ff8a3d;
  --accent-text: #ffffff;
  --accent-soft: #fff0e9;
  --ok: #12a150;
  --ok-soft: #e7f7ee;
  --warn: #e8900c;
  --warn-soft: #fff5e1;
  --info: #2f6bff;
  --info-soft: #eaf0ff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --off: #a0a0aa;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(16 16 24 / 0.04), 0 4px 16px rgb(16 16 24 / 0.06);
  --shadow-lg: 0 10px 40px rgb(16 16 24 / 0.16);
  --font: "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e11;
    --surface: #18181c;
    --surface-2: #212126;
    --surface-3: #2b2b31;
    --text: #f3f3f5;
    --muted: #9d9da8;
    --border: #2c2c33;
    --accent: #ff7038;
    --accent-2: #ff9a55;
    --accent-text: #ffffff;
    --accent-soft: #33190f;
    --ok: #34c77b;
    --ok-soft: #10291b;
    --warn: #f5a524;
    --warn-soft: #2e2210;
    --info: #6b95ff;
    --info-soft: #141f3a;
    --danger: #ff6369;
    --danger-soft: #321517;
    --off: #6b6b75;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 40px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 19px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
code { font-size: 13px; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700; font-size: 16px;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 20px; display: grid; gap: 16px; }
.wrap.narrow { max-width: 600px; padding: 16px 16px 110px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input { flex: 1; min-width: 140px; }
.stack { display: grid; gap: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}

/* ---------- controls ---------- */
input, select {
  font: inherit; color: inherit; background: var(--surface-2);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 12px; min-width: 0; outline: none; transition: border-color .15s, background .15s;
}
input:focus { border-color: var(--accent); background: var(--surface); }

button {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: var(--radius-sm);
  padding: 10px 16px; background: var(--accent); color: var(--accent-text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .08s, filter .15s, background .15s; white-space: nowrap;
}
button:hover { filter: brightness(1.05); }
button:active { transform: scale(.97); }
button:disabled { opacity: .45; cursor: default; transform: none; }
button.soft { background: var(--surface-2); color: var(--text); font-weight: 500; }
button.soft:hover { background: var(--surface-3); filter: none; }
button.ok { background: var(--ok); }
button.danger { background: var(--danger-soft); color: var(--danger); font-weight: 500; }
button.sm { padding: 6px 12px; font-size: 13px; }
button.lg { padding: 14px 20px; font-size: 16px; border-radius: 14px; }
button.block { width: 100%; }
button.icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; font-size: 18px; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-weight: 500; }
.switch input { appearance: none; width: 46px; height: 26px; padding: 0; border-radius: 99px; background: var(--surface-3); position: relative; cursor: pointer; border: 0; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .2s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(20px); }

/* segmented tabs */
.seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; overflow-x: auto; max-width: 100%; }
.seg button { background: transparent; color: var(--muted); font-weight: 500; padding: 8px 16px; border-radius: 9px; }
.seg button:hover { filter: none; color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.badge { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 12px; font-weight: 700; line-height: 18px; min-width: 18px; display: inline-block; text-align: center; }

/* pills / status */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.live::before { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- admin ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { display: grid; gap: 4px; }
.stat b { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12.5px; color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: 0; }
.notice { background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); color: var(--text); }

/* ---------- shop: board ---------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 860px) { .board { grid-template-columns: 1fr; } }
.col { display: grid; gap: 10px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.col-head .count { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.col-dot { width: 10px; height: 10px; border-radius: 50%; }
.ticket {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: grid; gap: 10px; box-shadow: var(--shadow);
  animation: rise .25s ease-out;
}
.ticket.fresh { border-color: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent); }
.ticket .t-head { display: flex; align-items: center; gap: 8px; }
.ticket .t-table { font-size: 20px; font-weight: 700; }
.ticket ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.ticket li { display: flex; justify-content: space-between; gap: 8px; }
.ticket li b { font-variant-numeric: tabular-nums; }
.ticket .t-actions { display: flex; gap: 8px; }
.ticket .t-actions button:first-child { flex: 1; }
.ticket.done { opacity: .7; box-shadow: none; }
.late { color: var(--danger) !important; font-weight: 600; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.empty { color: var(--muted); font-size: 13.5px; text-align: center; padding: 28px 12px; border: 1.5px dashed var(--border); border-radius: var(--radius); }

.calls { display: grid; gap: 10px; }
.call {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  animation: rise .25s ease-out;
}
.call .ic { display: grid; color: var(--warn); animation: wiggle 1.2s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }

/* ---------- shop: tables ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.tcard { display: grid; gap: 12px; align-content: start; position: relative; overflow: hidden; }
.tcard::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--surface-3); }
.tcard.open::before { background: linear-gradient(90deg, var(--ok), color-mix(in srgb, var(--ok) 50%, var(--accent-2))); }
.tcard .t-name { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.tcard .t-total { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tcard .t-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tcard .t-actions .wide { grid-column: 1 / -1; }
.tcard.pick { border: 1.5px dashed var(--accent); background: var(--accent-soft); }
.add-tile { display: grid; place-items: center; min-height: 150px; border: 1.5px dashed var(--border); background: transparent; box-shadow: none; }

/* ลูกค้าที่รอเลือกโต๊ะ */
.wait {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius); background: var(--info-soft);
  border: 1px solid color-mix(in srgb, var(--info) 35%, transparent); animation: rise .25s ease-out;
}
.wait.on { background: var(--accent-soft); border-color: var(--accent); }
.wait .ic { display: grid; color: var(--info); }
.choices { display: grid; gap: 8px; }
.choice { justify-content: space-between; background: var(--surface-2); color: var(--text); font-weight: 500; border: 1.5px solid transparent; padding: 12px 14px; }
.choice:hover { filter: none; background: var(--surface-3); }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.slip-table { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }

/* บทบาท: ซ่อนส่วนที่บทบาทนั้นใช้ไม่ได้ (สิทธิ์จริงตรวจที่เซิร์ฟเวอร์) */
body:not(.role-manager) .mgr, .role-manager .mgr-hide, .role-kitchen .staff-only { display: none !important; }
body[data-mode="alacarte"] .buf-only { display: none !important; }
.role-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--border); }
.role-row .pin { font-size: 18px; font-weight: 700; letter-spacing: .12em; padding: 4px 10px; }
.role-row .grow { flex: 1; min-width: 200px; }

/* รายงาน: ออร์เดอร์รายชั่วโมง */
.hours { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; height: 170px; }
.hcol { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.hcol .bar { width: 100%; max-width: 36px; min-height: 2px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.hcol .muted { font-size: 11px; font-variant-numeric: tabular-nums; }

/* ---------- shop: menu ---------- */
.menu-edit td input[type="text"], .menu-edit td input:not([type]) { width: 100%; min-width: 120px; }
.menu-edit td input[type="number"] { width: 100px; }
.menu-edit td select { min-width: 150px; }

/* รูปเมนูในตารางแก้เมนู */
.pic-wrap { position: relative; display: inline-block; }
.pic {
  width: 52px; height: 52px; border-radius: 12px; overflow: hidden; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 500;
}
.pic img { width: 100%; height: 100%; object-fit: cover; }
.pic.editable { cursor: pointer; border: 1.5px dashed var(--border); transition: border-color .15s; }
.pic.editable:hover { border-color: var(--accent); }

/* หน้าต่างครอบรูป */
.crop-stage {
  position: relative; width: min(320px, 100%); aspect-ratio: 1; margin: 0 auto; border-radius: 18px; overflow: hidden;
  background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface-3) 0 50%) 0 0 / 20px 20px;
  touch-action: none; cursor: grab; user-select: none;
}
.crop-stage.dragging { cursor: grabbing; }
.crop-stage canvas { width: 100%; height: 100%; display: block; }
/* เส้นแบ่ง 3 ส่วนช่วยจัดองค์ประกอบ */
.crop-stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / .85);
  background:
    linear-gradient(90deg, transparent calc(33.33% - .5px), rgb(255 255 255 / .45) 0 calc(33.33% + .5px), transparent 0 calc(66.66% - .5px), rgb(255 255 255 / .45) 0 calc(66.66% + .5px), transparent 0),
    linear-gradient(180deg, transparent calc(33.33% - .5px), rgb(255 255 255 / .45) 0 calc(33.33% + .5px), transparent 0 calc(66.66% - .5px), rgb(255 255 255 / .45) 0 calc(66.66% + .5px), transparent 0);
}
.zoom-row { display: flex; align-items: center; gap: 10px; width: min(320px, 100%); margin: 0 auto; }
.zoom-row input[type="range"] { flex: 1; padding: 0; background: transparent; accent-color: var(--accent); }
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; width: min(320px, 100%); margin: 0 auto; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pic-del {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; padding: 0; border-radius: 50%;
  font-size: 11px; background: var(--text); color: var(--bg);
}

/* ---------- customer ---------- */
.hero { padding: 20px 16px 8px; max-width: 600px; margin: 0 auto; display: grid; gap: 6px; }
.hero h1 { font-size: 24px; }
.catbar {
  position: sticky; top: 0; z-index: 9; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; max-width: 568px; margin: 0 auto; }
.chips::-webkit-scrollbar { display: none; }
.chips a { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 7px 16px; white-space: nowrap; font-size: 14px; font-weight: 500; transition: all .15s; }
.chips a.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.menu-cat { display: grid; gap: 10px; scroll-margin-top: 64px; }
.menu-cat > h2 { margin-top: 10px; font-size: 18px; }
.item { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); transition: border-color .15s; }
.item.in-cart { border-color: var(--accent); }
.item .thumb { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; flex: none; }
.item .thumb.photo { object-fit: cover; background: var(--surface-2); } /* ขนาดเท่าไอคอน 56px */
.item .info { flex: 1; min-width: 0; display: grid; }
.item .name { font-weight: 600; }
.item .price { color: var(--muted); font-variant-numeric: tabular-nums; }
.item.sold { opacity: .5; box-shadow: none; }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 99px; padding: 3px; }
.stepper button { width: 32px; height: 32px; padding: 0; border-radius: 50%; font-size: 18px; }
.stepper button.minus { background: var(--surface); color: var(--text); }
.stepper span { min-width: 22px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.add-btn { width: 38px; height: 38px; padding: 0; border-radius: 50%; font-size: 22px; font-weight: 500; }

.banner { margin: 0 16px; padding: 12px 16px; border-radius: var(--radius); background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.banner-wrap { max-width: 600px; margin: 0 auto; }

.cartbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); pointer-events: none; }
.cartbar button {
  pointer-events: auto; width: 100%; max-width: 568px; margin: 0 auto; display: flex; justify-content: space-between;
  padding: 16px 20px; font-size: 16px; border-radius: 18px; box-shadow: var(--shadow-lg);
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); animation: rise .2s ease-out;
}
.cartbar .count { background: rgb(255 255 255 / .25); border-radius: 99px; padding: 0 9px; margin-right: 8px; }

.orderline { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.orderline:last-child { border-bottom: 0; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 17px; padding-top: 12px; border-top: 1px solid var(--border); margin-top: 4px; }
.total-row b { font-size: 22px; font-variant-numeric: tabular-nums; }
.actions-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.thanks { text-align: center; padding: 48px 20px; display: grid; gap: 10px; justify-items: center; }
.thanks .big { display: grid; color: var(--accent); }

/* ---------- dialog / bottom sheet ---------- */
dialog {
  border: 0; border-radius: 20px; background: var(--surface); color: var(--text); padding: 0;
  width: min(540px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop .18s ease-out; }
dialog::backdrop { background: rgb(10 10 14 / .5); backdrop-filter: blur(2px); }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
dialog.sheet { margin: auto auto 0; width: 100%; max-width: 600px; border-radius: 22px 22px 0 0; max-height: 85dvh; }
dialog.sheet[open] { animation: slideup .22s ease-out; }
@keyframes slideup { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.dlg-body { padding: 20px; display: grid; gap: 12px; }
.dlg-foot { padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface); }
.dlg-foot .grow { flex: 1; }
.qr { display: grid; justify-items: center; gap: 10px; text-align: center; }
.qr #qrBox svg { display: block; border-radius: 14px; }
.qr .link { word-break: break-all; font-size: 12px; color: var(--muted); }
.line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

#toast {
  position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 10px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
}
.plan { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 14px; }
.item .price.buf { color: var(--ok); font-weight: 500; }

/* พิมพ์ใบเสร็จ: เอาเฉพาะเนื้อหาใน dialog */
@media print {
  body > :not(dialog) { display: none !important; }
  body { background: #fff; }
  dialog { position: static; box-shadow: none; width: 100%; max-height: none; color: #000; background: #fff; }
  dialog::backdrop { display: none; }
  .dlg-foot, .qr .link { display: none !important; }
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ไอคอน SVG (public/icons.js) */
.i { flex: none; display: inline-block; vertical-align: -0.2em; }
#toast { display: flex; align-items: center; gap: 8px; }
.pic-add { display: grid; color: var(--muted); }
.banner .i { color: var(--warn); }
button.soft.warn { background: var(--warn-soft); color: var(--warn); }

/* ปุ่มเปลี่ยนชื่อโต๊ะ (ผู้จัดการ) ข้างชื่อบนการ์ดโต๊ะ */
.t-rename {
  width: 28px; height: 28px; padding: 0; margin-left: 6px; vertical-align: middle; border-radius: 8px;
  background: transparent; color: var(--muted);
}
.t-rename:hover { background: var(--surface-2); color: var(--text); filter: none; }
.tcard .t-name { overflow-wrap: anywhere; }

/* คูปองในบิล */
.coupon { display: grid; gap: 8px; padding: 12px; border-radius: var(--radius-sm); border: 1.5px dashed var(--border); }
.coupon.on { display: flex; align-items: center; gap: 10px; border-style: solid; border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: var(--ok-soft); color: var(--text); }
.coupon.on > .i { color: var(--ok); }
.coupon .grow { flex: 1; min-width: 0; }
.coupon-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.discount { color: var(--ok); }
.coupon-picks { align-items: center; }
.coupon-picks .pick.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }

/* เครื่องคิดเลข (เปิดทับหน้าต่างบิล) */
dialog.calc { width: min(340px, calc(100vw - 32px)); outline: none; }
.calc-screen { padding: 18px 20px 10px; display: grid; gap: 2px; text-align: right; }
.calc-expr { min-height: 22px; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-val { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 8px 20px 16px; }
.calc-key { height: 52px; padding: 0; font-size: 20px; background: var(--surface-2); color: var(--text); font-weight: 500; }
.calc-key:hover { background: var(--surface-3); filter: none; }
.calc-key.fn { font-size: 14px; color: var(--muted); }
.calc-key.op { background: var(--accent-soft); color: var(--accent); }
.calc-key.eq { background: var(--accent); color: var(--accent-text); }
.icon-btn { padding: 10px 12px; }

/* ขนาดเมนู */
.ticket li .size { color: var(--accent); }
.item .ctl { display: flex; align-items: center; gap: 8px; }
.size-row { padding: 10px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); }
.size-row.on { border-color: var(--accent); background: var(--accent-soft); }
.size-row .name { font-weight: 600; }
.row.nowrap { flex-wrap: nowrap; }

/* ---------- จอลูกค้า (display.html) ---------- */
body.display { min-height: 100dvh; overflow: hidden; }
.disp { min-height: 100dvh; display: grid; padding: 24px; }
.disp-center { display: grid; place-items: center; align-content: center; gap: 12px; text-align: center; color: var(--muted); }
.disp-center h1 { color: var(--text); }
.disp-shop { font-size: clamp(32px, 5vw, 56px); font-weight: 700; letter-spacing: -0.02em; }
.disp-sub { font-size: clamp(18px, 2.4vw, 26px); margin: 0; color: var(--muted); }
.disp-sub b { color: var(--text); }
.disp-ok { color: var(--ok); display: grid; }
.disp-wrap { max-width: 1280px; width: 100%; margin: 0 auto; display: grid; grid-template-rows: auto 1fr; gap: 20px; min-height: calc(100dvh - 48px); }
.disp-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.disp-logo { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }
.disp-name { font-size: clamp(28px, 3.4vw, 40px); font-weight: 700; letter-spacing: -0.02em; color: var(--accent); line-height: 1.15; }
.disp-tag { font-size: 17px; color: var(--muted); }
.disp-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 10px 20px; border-radius: 99px; }
.disp-bill { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: center; }
@media (max-width: 860px) { .disp-bill { grid-template-columns: 1fr; } body.display { overflow: auto; } }

/* ซ้าย: รายการสั่งซื้อ */
.disp-receipt { padding: 26px 28px; display: grid; gap: 16px; border-radius: 22px; }
.disp-rhead { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border); color: var(--accent); }
.disp-rhead h2 { font-size: 24px; color: var(--text); flex: 1; }
.disp-lines { max-height: calc(100dvh - 430px); overflow-y: auto; }
.disp-line { display: grid; grid-template-columns: 84px 1fr auto; gap: 18px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.disp-line:last-child { border-bottom: 0; }
.disp-line .thumb { position: relative; width: 84px; height: 84px; }
.disp-line .thumb img, .disp-line .thumb .ph { width: 100%; height: 100%; border-radius: 16px; object-fit: cover; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.disp-line .q { position: absolute; right: -6px; bottom: -6px; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 99px; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; font-size: 15px; border: 3px solid var(--surface); font-variant-numeric: tabular-nums; }
.disp-line .n { display: grid; gap: 2px; }
.disp-line .n b { font-size: 22px; font-weight: 700; }
.disp-line .n small { font-size: 17px; color: var(--muted); }
.disp-line .amt { font-size: 24px; font-weight: 700; }
.disp-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.disp-sum { display: grid; gap: 6px; font-size: 18px; }
.disp-net { display: flex; align-items: center; gap: 14px; padding: 18px 22px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); }
.disp-net span { flex: 1; font-size: 24px; font-weight: 700; color: var(--text); }
.disp-net b { font-size: clamp(36px, 4vw, 48px); font-weight: 700; letter-spacing: -0.02em; color: var(--accent); }

/* ขวา: ช่องทางการชำระเงิน */
.disp-pay { padding: 0; overflow: hidden; display: grid; border-radius: 22px; }
.disp-pay-head { display: flex; align-items: center; gap: 10px; padding: 18px 26px; font-size: 20px; font-weight: 700; color: #fff; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 88%, #000), var(--accent)); }
.disp-pay-top { color: #fff; padding: 20px 28px 26px; display: grid; gap: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.disp-pay-top span { font-size: 20px; opacity: .92; }
.disp-pay-top b { font-size: clamp(64px, 7vw, 96px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.disp-qr-box { padding: 22px 28px 26px; display: grid; justify-items: center; gap: 16px; text-align: center; }
.disp-pp-tag { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--info); background: var(--info-soft); padding: 8px 18px; border-radius: 99px; font-size: 17px; }
.disp-qr { padding: 14px; background: #fff; border-radius: 18px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.disp-qr svg { display: block; width: min(280px, 56vw); height: auto; }
.disp-pp-foot { display: flex; align-items: center; gap: 14px; text-align: left; }
.pp-badge { font-weight: 700; font-size: 18px; color: #1a3d8f; border: 2px solid #1a3d8f; border-radius: 6px; padding: 2px 10px; letter-spacing: .02em; }
.disp-nopp { padding: 40px 28px; text-align: center; font-size: 20px; color: var(--muted); }
.qr-mini svg { display: block; border-radius: 10px; border: 1px solid var(--border); }

/* รวมโต๊ะ / แยกจ่าย */
.table-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.pick.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.tcard.joined::before { background: color-mix(in srgb, var(--ok) 45%, var(--surface-3)); }
.split-box { display: grid; gap: 10px; padding: 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); }
.split-box .seg button { padding: 6px 12px; font-size: 13px; }
.split-foot { padding-top: 10px; border-top: 1px solid var(--border); }
.split-foot b { font-size: 20px; }

/* พื้นหลังจอลูกค้า */
body.display.has-bg { background-color: #fbf6f0; background-size: cover; background-position: center; background-repeat: no-repeat; }
.bg-row { align-items: center; gap: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.bg-thumb { width: 160px; aspect-ratio: 16 / 9; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); }
.bg-thumb.empty-bg { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }

/* ไกด์สร้างภาพพื้นหลัง */
.guide-steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; }
.prompt-box {
  margin: 0; max-height: 240px; overflow: auto; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); font: 12.5px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word;
}
.fix-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }

/* หน้าต่าง: กรอบไม่เลื่อน (มุมโค้งไม่โดนแถบเลื่อนทับ) ให้เลื่อนเฉพาะเนื้อหา แถบปุ่มล่างอยู่กับที่ */
dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
dialog > .dlg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
dialog > .dlg-foot { flex: none; }
