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

:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --ink: #1b201d;
  --ink-2: #525c56;
  --line: #e5e2da;
  --accent: #1f5c4a;
  --accent-hover: #174a3b;
  --accent-ink: #ffffff;
  --accent-soft: #e4efea;
  --accent-text: #1f5c4a;
  --gold: #8c6520;
  --gold-soft: #f6eedd;
  --ok: #24724a;
  --ok-soft: #e1f1e8;
  --warn: #8f5e00;
  --warn-soft: #faefd8;
  --bad: #b12a22;
  --bad-soft: #fbe6e4;
  --chart: #2a7a63;
  --shadow-sm: 0 1px 2px rgb(27 32 29 / .05);
  --shadow-md: 0 8px 28px rgb(27 32 29 / .09);
  --shadow-lg: 0 18px 50px rgb(27 32 29 / .2);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1311;
    --surface: #171c19;
    --surface-2: #212724;
    --ink: #edf0ed;
    --ink-2: #a8b2ac;
    --line: #2c3430;
    --accent: #6fc5a6;
    --accent-hover: #86d2b6;
    --accent-ink: #0c1e18;
    --accent-soft: #1c2f28;
    --accent-text: #86d2b6;
    --gold: #d9b26a;
    --gold-soft: #2e2715;
    --ok: #74cf9b;
    --ok-soft: #1a2e23;
    --warn: #e6b65c;
    --warn-soft: #30260f;
    --bad: #f28b82;
    --bad-soft: #3a1c1a;
    --chart: #6fc5a6;
    --shadow-sm: none;
    --shadow-md: 0 8px 28px rgb(0 0 0 / .35);
    --shadow-lg: 0 18px 50px rgb(0 0 0 / .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1311;
  --surface: #171c19;
  --surface-2: #212724;
  --ink: #edf0ed;
  --ink-2: #a8b2ac;
  --line: #2c3430;
  --accent: #6fc5a6;
  --accent-hover: #86d2b6;
  --accent-ink: #0c1e18;
  --accent-soft: #1c2f28;
  --accent-text: #86d2b6;
  --gold: #d9b26a;
  --gold-soft: #2e2715;
  --ok: #74cf9b;
  --ok-soft: #1a2e23;
  --warn: #e6b65c;
  --warn-soft: #30260f;
  --bad: #f28b82;
  --bad-soft: #3a1c1a;
  --chart: #6fc5a6;
  --shadow-sm: none;
  --shadow-md: 0 8px 28px rgb(0 0 0 / .35);
  --shadow-lg: 0 18px 50px rgb(0 0 0 / .55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; font-weight: 600; line-height: 1.3; letter-spacing: -.005em; }
h2 { font-size: 1.0625rem; font-weight: 600; line-height: 1.4; }
h3 { font-size: .9375rem; font-weight: 600; }
a { color: var(--accent-text); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.icon { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.xs { font-size: .8125rem; }
.strong { font-weight: 600; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stack { display: grid; gap: 12px; }
.mt { margin-top: 16px; }
.mt-s { margin-top: 8px; }

/* โครงหน้าจอพนักงาน */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100dvh; }
#side {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 24px;
  padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 600; line-height: 1.3; padding: 0 6px; }
.brand small { display: block; font-weight: 400; font-size: .8125rem; color: var(--ink-2); }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
#side nav { display: grid; gap: 2px; }
#side nav a, #tabbar a { color: var(--ink-2); text-decoration: none; }
#side nav a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px;
  border-radius: var(--r-sm); font-weight: 500; font-size: .9375rem; transition: background .15s, color .15s;
}
#side nav a:hover { background: var(--surface-2); color: var(--ink); }
#side nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.side-note { margin-top: auto; padding: 0 8px; font-size: .8125rem; color: var(--ink-2); }
.app-main { min-width: 0; display: flex; flex-direction: column; }
#top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 24px 32px 0; }
.sub { color: var(--ink-2); font-size: .9375rem; }
.top-actions { display: flex; align-items: center; gap: 10px; flex: none; }
main { width: 100%; max-width: 1320px; padding: 20px 32px 40px; }
#tabbar { display: none; }

/* ปุ่มและส่วนย่อย */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  font-weight: 600; font-size: .9375rem; color: var(--ink); text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn.quiet-danger { color: var(--bad); border-color: transparent; background: transparent; min-height: 40px; padding: 6px 10px; font-weight: 500; font-size: .875rem; }
.btn.quiet-danger:hover { background: var(--bad-soft); }
.btn:disabled { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); cursor: not-allowed; }
.btn.block { display: flex; width: 100%; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; background: var(--gold-soft); color: var(--gold); font-size: .8125rem; font-weight: 600; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: .8125rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.neutral { background: var(--surface-2); color: var(--ink-2); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow-sm); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 12px; }
.seg button { border: 0; background: transparent; min-height: 40px; padding: 6px 14px; border-radius: 9px; color: var(--ink-2); font-weight: 500; font-size: .9375rem; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.field { width: 100%; min-height: 46px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
.c-banner { height: 170px; background-size: cover; background-position: center; }
.c-logo { display: block; width: 84px; height: 84px; margin: -42px auto 0; border-radius: 50%; object-fit: cover; background: #fff; border: 3px solid var(--surface); position: relative; }
.thumb.photo { overflow: hidden; background: var(--surface-2); }
.thumb.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
body[data-template="grid"] .items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body[data-template="grid"] .item, body[data-template="large"] .item { flex-direction: column; align-items: stretch; position: relative; }
body[data-template="grid"] .item .thumb, body[data-template="large"] .item .thumb { width: 100%; height: auto; aspect-ratio: 4 / 3; }
body[data-template="large"] .item .thumb { aspect-ratio: 16 / 10; }
body[data-template="grid"] .item-add, body[data-template="large"] .item-add { position: absolute; right: 18px; bottom: 16px; }
.menu-layout.vertical { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: start; }
.menu-layout.vertical .cats { flex-direction: column; overflow-x: visible; overflow-y: auto; max-height: 100dvh; padding: 12px 6px; }
.menu-layout.vertical .cats button { border-radius: 10px; padding: 8px; min-height: 44px; font-size: .8125rem; text-align: left; width: 100%; flex: none; }
.menu-layout.vertical .menu-sec { padding: 8px 12px 12px 8px; }
.photo-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.photo-row .name { flex: 1; min-width: 0; }
.photo-box { width: 64px; height: 64px; flex: none; border-radius: 12px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--ink-2); }
.photo-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-img { max-width: 220px; max-height: 120px; border-radius: 10px; display: block; margin: 6px 0; }
.center-page { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); padding: 28px; }
.form-error { min-height: 1.5em; color: var(--bad); font-size: .875rem; }
.side-note p + p { margin-top: 2px; }
.bill-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.bill-actions .btn { min-height: 44px; padding: 6px 4px; font-size: .875rem; }
.line-edit { background: transparent; border: 0; color: var(--accent-text); font-size: .8125rem; font-weight: 600; min-height: 32px; padding: 0; }
.qr-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.qr-card { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; text-align: center; background: #fff; color: #111; }
.qr-card svg, .qr-card img { width: 100%; max-width: 180px; height: auto; }
@media print {
  #side, #top, #tabbar, #stats, .toolbar, .no-print { display: none !important; }
  .app { display: block; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .qr-card { break-inside: avoid; }
  body.printing { background: #fff !important; }
  body.printing > *:not(#printArea) { display: none !important; }
}
#printArea { display: none; }
@media print {
  #printArea { display: block; color: #000; font-size: 12px; line-height: 1.35; }
  #printArea .slip-c { text-align: center; white-space: pre-line; }
  #printArea .slip-t { font-size: 16px; font-weight: 700; }
  #printArea .slip-big { font-size: 18px; font-weight: 700; }
  #printArea .slip-r { display: flex; justify-content: space-between; gap: 8px; }
  #printArea hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
}
select.field { font: inherit; color: inherit; }
.form-grid { display: grid; gap: 12px; }
.form-grid label { display: grid; gap: 4px; font-size: .875rem; font-weight: 500; }
.form-wide { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: end; }
.form-wide .span-all { grid-column: 1 / -1; }
.search { position: relative; }
.search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-2); pointer-events: none; }
.search .field { padding-left: 42px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.stepper button:hover { background: var(--surface-2); }
.stepper strong { min-width: 32px; text-align: center; font-size: 1.0625rem; }

/* ตาราง */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .8125rem; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td:first-child { white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 0; }

/* ข้อความแจ้งและกล่องยืนยัน */
#toasts { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--ink); color: var(--bg); border-radius: 12px; box-shadow: var(--shadow-md); font-size: .9375rem; animation: rise .2s ease-out; }
.toast button { background: transparent; border: 0; color: inherit; font-weight: 700; text-decoration: underline; min-height: 32px; }
dialog { border: 0; padding: 0; color: var(--ink); background: var(--surface); }
dialog::backdrop { background: rgb(12 16 14 / .5); }
dialog.confirm { width: min(420px, calc(100vw - 32px)); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow-lg); }
dialog.confirm p { margin-top: 6px; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ภาพรวม */
.welcome { background: var(--accent); color: var(--accent-ink); border-radius: var(--r-lg); padding: 28px; display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: flex-end; }
.welcome h2 { font-size: 1.5rem; line-height: 1.3; }
.welcome p { opacity: .88; margin-top: 4px; max-width: 46ch; }
.welcome .btn { background: var(--accent-ink); color: var(--accent); border-color: transparent; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat .label { color: var(--ink-2); font-size: .875rem; }
.stat .value { font-size: 1.625rem; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--ink-2); font-size: .8125rem; }
.hub { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.hub a { display: flex; gap: 14px; align-items: flex-start; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
.hub a:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.hub-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }

/* หน้าลูกค้า */
.customer { max-width: 620px; margin: 0 auto; padding-bottom: 120px; }
.c-head { padding: 22px 20px 10px; }
.c-head h1 { font-size: 1.625rem; }
.table-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 14px; background: var(--accent); color: var(--accent-ink); border-radius: 99px; font-weight: 600; font-size: .9375rem; white-space: nowrap; }
.c-search { padding: 8px 20px 0; }
.cats { position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; overflow-x: auto; padding: 12px 20px; background: var(--bg); scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats button { flex: none; min-height: 42px; padding: 6px 16px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-weight: 500; }
.cats button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.menu-sec { padding: 8px 20px 12px; scroll-margin-top: 68px; }
.menu-sec > h2 { margin: 8px 0 10px; font-size: 1.125rem; }
.items { display: grid; gap: 10px; }
.item {
  width: 100%; display: flex; gap: 14px; align-items: center; text-align: left; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.item:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.thumb { width: 68px; height: 68px; flex: none; display: grid; place-items: center; border-radius: 13px; background: var(--accent-soft); color: var(--accent-text); }
.thumb.alt { background: var(--gold-soft); color: var(--gold); }
.item-body { flex: 1; min-width: 0; }
.item-name { font-weight: 600; line-height: 1.35; }
.item-price { font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.item-add { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); position: relative; }
.item:hover .item-add { background: var(--accent); color: var(--accent-ink); }
.in-cart { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; font-weight: 700; display: grid; place-items: center; }
.no-result { text-align: center; color: var(--ink-2); padding: 32px 20px; }
.cart-float { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; justify-content: center; pointer-events: none; }
.cart-float .btn { pointer-events: auto; width: 100%; max-width: 588px; min-height: 56px; justify-content: space-between; border-radius: 16px; box-shadow: var(--shadow-lg); font-size: 1rem; }
.cart-float .count { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 99px; background: var(--accent-ink); color: var(--accent); font-weight: 700; font-size: .875rem; }

dialog.sheet { width: 100%; max-width: 620px; max-height: 92dvh; margin: auto auto 0; border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-up .24s cubic-bezier(.2, .8, .2, 1); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; gap: 14px; align-items: center; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 1.1875rem; }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 20px 20px; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 12px; align-items: center; padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.sheet-foot .btn { flex: 1; min-height: 52px; }
.opt-group { margin-top: 18px; }
.opt-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.opt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.opt { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 50px; padding: 8px 14px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: .9375rem; }
.opt:hover { background: var(--surface-2); }
.opt[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent-text); font-weight: 600; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick button { min-height: 38px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); font-size: .875rem; }
.quick button:hover { background: var(--surface-2); color: var(--ink); }
.cart-line { padding: 14px 0; border-bottom: 1px solid var(--line); }
.tracker { margin: 8px 20px 10px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px; }
.step { position: relative; text-align: center; font-size: .8125rem; color: var(--ink-2); }
.step .dot { width: 26px; height: 26px; margin: 0 auto 4px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); position: relative; z-index: 1; }
.step::before { content: ""; position: absolute; top: 12px; left: -50%; width: 100%; height: 2px; background: var(--line); }
.step:first-child::before { display: none; }
.step.done { color: var(--ink); font-weight: 600; }
.step.done .dot { background: var(--accent); color: var(--accent-ink); }
.step.done::before { background: var(--accent); }

/* แคชเชียร์ */
.pos-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 390px; align-items: start; margin-top: 20px; }
.tables { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-top: 14px; }
.tbl { min-height: 118px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.tbl:hover { border-color: var(--accent); }
.tbl .t-name { font-weight: 600; }
.tbl .t-amount { margin-top: auto; font-weight: 600; font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.tbl.empty-t { background: transparent; box-shadow: none; }
.tbl[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), var(--shadow-md); }
.bill { position: sticky; top: 20px; padding: 0; overflow: hidden; }
.bill-head { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.bill-body { padding: 4px 20px 16px; max-height: 42dvh; overflow-y: auto; }
.bill-foot { padding: 16px 20px 20px; border-top: 1px solid var(--line); background: var(--surface); }
.bill-total { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.bill-line { padding: 10px 0; border-bottom: 1px solid var(--line); }
.bill-line:last-child { border-bottom: 0; }
.placeholder { padding: 44px 20px; text-align: center; color: var(--ink-2); }
.placeholder .icon { margin: 0 auto 10px; }
.quick-cash { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.quick-cash button { min-height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; font-weight: 500; font-size: .875rem; padding: 0; font-variant-numeric: tabular-nums; }
.quick-cash button:hover { background: var(--surface-2); }
.pp-box { display: grid; place-items: center; gap: 6px; padding: 22px; border: 1px dashed var(--line); border-radius: 14px; color: var(--ink-2); text-align: center; }
.success { text-align: center; padding: 28px 20px; }
.success-mark { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }

/* ครัว */
.prep { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.prep .tag { padding: 5px 13px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-weight: 500; font-size: .9375rem; }
.prep .tag b { font-weight: 700; margin-left: 4px; font-variant-numeric: tabular-nums; }
.kds { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.kds-col { display: grid; gap: 12px; }
.kds-head { display: flex; align-items: center; gap: 8px; }
.count-pill { min-width: 26px; height: 26px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); font-weight: 600; font-size: .875rem; }
.ticket { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); overflow: hidden; }
.ticket-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ticket-head .t { font-size: 1.125rem; font-weight: 700; }
.ticket-body { padding: 4px 16px; }
.ticket-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.ticket-item:last-child { border-bottom: 0; }
.ticket-item .n { font-size: 1.0625rem; font-weight: 600; line-height: 1.35; }
.ticket-item .q { font-variant-numeric: tabular-nums; color: var(--accent-text); font-weight: 700; margin-right: 4px; }
.ticket-item .note { display: inline-flex; gap: 5px; align-items: center; margin-top: 4px; padding: 1px 9px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); font-weight: 600; font-size: .875rem; }
.ticket-foot { padding: 4px 16px 14px; }
.ticket-foot .btn { min-height: 50px; }
.empty { padding: 36px 20px; text-align: center; color: var(--ink-2); border: 1px dashed var(--line); border-radius: var(--r); }

/* หลังบ้าน */
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; margin: 20px 0 14px; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 320px; }
.meter { width: 96px; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 99px; background: var(--chart); }
.meter span.warn { background: var(--warn); }
.meter span.bad { background: var(--bad); }

/* รายงาน */
.two { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; margin-top: 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.link-btn { background: transparent; border: 0; color: var(--accent-text); font-weight: 500; font-size: .875rem; min-height: 40px; padding: 0 4px; }
.vbars { position: relative; height: 210px; margin-left: 44px; display: flex; align-items: stretch; gap: 2px; border-bottom: 1px solid var(--line); }
.grid-line { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); opacity: .6; }
.grid-label { position: absolute; left: -44px; width: 38px; text-align: right; transform: translateY(-50%); font-size: .75rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.vcol { position: relative; flex: 1; min-width: 0; display: flex; align-items: flex-end; justify-content: center; background: transparent; border: 0; padding: 0; z-index: 1; border-radius: 6px 6px 0 0; }
.vcol:hover, .vcol:focus-visible { background: var(--surface-2); }
.vcol .bar { width: min(100%, 36px); background: var(--chart); border-radius: 4px 4px 0 0; }
.vticks { display: flex; gap: 2px; margin-left: 44px; margin-top: 6px; }
.vticks span { flex: 1; min-width: 0; text-align: center; font-size: .75rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tip { position: fixed; z-index: 40; pointer-events: none; padding: 7px 11px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: .8125rem; line-height: 1.45; box-shadow: var(--shadow-md); white-space: nowrap; }
.hbar { display: grid; grid-template-columns: minmax(120px, 150px) 1fr 60px; gap: 10px; align-items: center; min-height: 44px; border-radius: 8px; }
.hbar:hover { background: var(--surface-2); }
.hbar-track { height: 16px; }
.hbar-fill { display: block; height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; min-width: 3px; }
.pnl-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.pnl-row.sub-total { font-weight: 600; border-bottom-color: var(--ink-2); }
.pnl-row.net { border-bottom: 0; font-weight: 700; font-size: 1.125rem; padding-top: 12px; }

@media (max-width: 1080px) {
  .pos-grid { grid-template-columns: minmax(0, 1fr); }
  .bill { position: static; }
  .bill-body { max-height: none; }
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  #side { display: none; }
  #top { padding: 18px 16px 0; }
  main { padding: 16px 16px 28px; }
  h1 { font-size: 1.3125rem; }
  #tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  #tabbar a { display: grid; justify-items: center; gap: 1px; padding: 6px 0; min-height: 56px; font-size: .6875rem; border-radius: 10px; }
  #tabbar a[aria-current="page"] { color: var(--accent-text); font-weight: 600; background: var(--accent-soft); }
  .kds { grid-template-columns: minmax(0, 1fr); }
  .welcome { padding: 22px; }
  .stat .value { font-size: 1.375rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (min-width: 680px) {
  dialog.sheet { margin: auto; border-radius: var(--r-lg); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ธีมน้ำเงินตามระบบบัญชีเดิม และเมนูข้างแบบจัดกลุ่ม */
:root {
  --bg: #f2f5fb; --surface-2: #eaeff8; --ink: #1c2740; --ink-2: #55617a; --line: #dde4f0;
  --accent: #3a62ad; --accent-hover: #2f5296; --accent-soft: #e4ecfa; --accent-text: #2f5296; --chart: #4a76c4;
  --gold: #8a5a10; --gold-soft: #f8eedb;
  --side-a: #2f5296; --side-b: #4a7cc7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420; --surface: #171e2d; --surface-2: #212a3c; --ink: #e9eef8; --ink-2: #a6b1c6; --line: #2c3649;
    --accent: #8cb0ee; --accent-hover: #a3c1f3; --accent-ink: #0d1a33; --accent-soft: #1c2a44; --accent-text: #a3c1f3; --chart: #8cb0ee;
    --side-a: #16233f; --side-b: #1f3358;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1420; --surface: #171e2d; --surface-2: #212a3c; --ink: #e9eef8; --ink-2: #a6b1c6; --line: #2c3649;
  --accent: #8cb0ee; --accent-hover: #a3c1f3; --accent-ink: #0d1a33; --accent-soft: #1c2a44; --accent-text: #a3c1f3; --chart: #8cb0ee;
  --side-a: #16233f; --side-b: #1f3358;
}
body { background: var(--bg); }
#side { background: linear-gradient(180deg, var(--side-a), var(--side-b)); border-right: 0; color: #fff; gap: 14px; overflow: hidden; }
#side .brand, #side .brand small { color: #fff; }
#side .brand-mark { background: #fff; color: #2f5296; }
#side nav { flex: 1; min-height: 0; overflow-y: auto; align-content: start; scrollbar-width: thin; }
#side .nav-group { margin: 12px 12px 4px; font-size: .75rem; font-weight: 600; color: #fff; opacity: .72; }
#side nav a { color: #fff; min-height: 42px; padding: 6px 12px; font-size: .9rem; }
#side nav a:hover { background: rgb(255 255 255 / .14); color: #fff; }
#side nav a[aria-current="page"] { background: #fff; color: #2f5296; }
#side .side-note { color: #fff; opacity: .78; }
#tabbar button { background: none; border: 0; font: inherit; color: var(--ink-2); display: grid; justify-items: center; gap: 1px; padding: 6px 0; min-height: 56px; font-size: .6875rem; border-radius: 10px; }
#scrim { display: none; }
.welcome { background: linear-gradient(120deg, var(--side-a), var(--side-b)); color: #fff; }
.welcome .btn { background: #fff; color: #2f5296; }
.status-pill { display: inline-flex; gap: 8px; align-items: center; background: rgb(255 255 255 / .18); border-radius: 999px; padding: 4px 12px; font-size: .8125rem; margin-top: 10px; }
.quick { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.quick a { display: flex; align-items: center; gap: 12px; padding: 14px; color: inherit; text-decoration: none; font-weight: 600; }
.quick a:hover { border-color: var(--accent); }
@media (max-width: 860px) {
  #side { display: flex; position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 82vw); z-index: 40; transform: translateX(-102%); transition: transform .2s; }
  #side.open { transform: none; }
  #scrim.open { display: block; position: fixed; inset: 0; background: rgb(10 20 40 / .45); z-index: 39; }
}
@media print { #scrim { display: none !important; } }

/* Safari บน iPhone ยุบพื้นที่เนื้อหาเมื่อใช้ flex-basis 0 ในกล่องที่จำกัดแค่ max-height */
.sheet-body { flex: 1 1 auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.sheet-head, .sheet-foot { flex: none; }
dialog.sheet { max-height: 92vh; max-height: 92dvh; }
.sheet-hero { display: block; width: calc(100% + 40px); margin: -4px -20px 12px; aspect-ratio: 16 / 10; object-fit: cover; background: var(--surface-2); }
@media (max-width: 680px) {
  body:not([data-template="grid"]):not([data-template="large"]) .item .thumb { width: 88px; height: 88px; }
}


.move-btns { display: inline-flex; gap: 2px; flex: none; vertical-align: middle; }
.move-btns .btn { min-width: 40px; min-height: 40px; padding: 2px 8px; }

#bill a.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; }

/* หน้ารับออเดอร์ของพนักงาน */
dialog.op { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--bg); color: var(--ink); overflow: hidden; }
dialog.op[open] { display: grid; grid-template-columns: 150px minmax(0, 1fr) 340px; }
.op-cats { background: linear-gradient(180deg, var(--side-a), var(--side-b)); padding: 10px 8px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.op-cats button { border: 0; background: transparent; color: #fff; font: inherit; font-weight: 500; text-align: left; padding: 12px; min-height: 52px; border-radius: var(--r-sm); cursor: pointer; }
.op-cats button[aria-pressed="true"] { background: #fff; color: #2f5296; font-weight: 600; }
.op-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.op-search { padding: 12px 14px 8px; flex: none; }
.op-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 14px 16px; }
.op-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.op-tile { position: relative; display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); font: inherit; color: inherit; cursor: pointer; }
.op-tile:hover { border-color: var(--accent); }
.op-tile:disabled { opacity: .45; cursor: not-allowed; }
.op-tile img, .op-noimg { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.op-name { padding: 8px 10px 0; font-weight: 600; font-size: .9375rem; line-height: 1.3; }
.op-price { padding: 2px 10px 10px; color: var(--ink-2); font-size: .875rem; }
.op-count { position: absolute; top: 8px; right: 8px; min-width: 28px; height: 28px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.op-editor { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.op-editor h3 { margin-top: 16px; margin-bottom: 8px; }
.op-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.op-chip { min-height: 52px; min-width: 88px; padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: inherit; font: inherit; font-weight: 500; cursor: pointer; }
.op-chip small { display: block; color: var(--ink-2); }
.op-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.op-chip[aria-pressed="true"] small { color: inherit; }
.op-editor-foot { position: sticky; bottom: -16px; display: flex; gap: 12px; align-items: center; margin-top: 16px; padding: 12px 0; background: var(--surface); }
.op-editor-foot .btn { flex: 1; min-height: 52px; }
.op-cart { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.op-cart-head { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; }
.op-channel { flex: none; margin: 0 14px 8px; display: grid; grid-template-columns: 1fr 1fr; }
.op-lines { flex: 1; min-height: 0; overflow-y: auto; padding: 0 14px; }
.op-line { padding: 10px 0; border-bottom: 1px solid var(--line); }
.op-cart-foot { flex: none; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.op-cart-foot .btn { min-height: 56px; }
@media (max-width: 860px) {
  dialog.op[open] { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) 42%; }
  .op-cats { flex-direction: row; overflow-x: auto; }
  .op-cats button { flex: none; min-height: 44px; }
  .op-cart { border-left: 0; border-top: 1px solid var(--line); }
}

/* ตัวเลือกที่เลือกแล้ว: พื้นเข้ม ขอบหนา และเครื่องหมายถูก ไม่อาศัยสีอย่างเดียว */
dialog.op { width: 100%; height: 100%; }
.op-chip { position: relative; border-width: 2px; }
.op-tick { display: none; vertical-align: -3px; margin-right: 4px; }
.op-chip[aria-pressed="true"] .op-tick { display: inline-block; }
.op-chip[aria-pressed="true"] { font-weight: 700; box-shadow: 0 0 0 2px var(--accent-soft); }
.op-group-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 16px; margin-bottom: 8px; padding: 6px 10px; border-radius: var(--r-sm); background: var(--surface-2); }
.op-group-head h3 { margin: 0; }
.op-group-head.need { background: var(--warn-soft); }
.op-editor-foot { flex-wrap: wrap; }
.op-summary { flex: 1 0 100%; font-weight: 600; line-height: 1.35; }
.opt[aria-pressed="true"]::before { content: "✓"; font-weight: 700; margin-right: 6px; }
.opt[aria-pressed="true"] { font-weight: 700; }

/* รับออเดอร์บนมือถือ: เลือกเมนูเต็มจอ และเปิดรายการจากแถบล่าง */
.op-mobile-head, .op-cartbar, .op-phone { display: none; }
@media (max-width: 860px) {
  dialog.op[open] { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .op-mobile-head { display: flex; flex: none; justify-content: space-between; align-items: center; padding: 8px 12px 0; }
  .op-search { padding: 8px 12px; }
  .op-body { padding: 4px 12px 12px; }
  .op-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .op-tile img, .op-noimg { aspect-ratio: 16 / 10; }
  .op-cartbar:not([hidden]) { display: flex; flex: none; justify-content: space-between; align-items: center; margin: 0 12px calc(10px + env(safe-area-inset-bottom)); min-height: 56px; padding: 0 18px; border: 0; border-radius: var(--r); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; }
  .op-cart { position: absolute; inset: 0; z-index: 3; border: 0; display: none; }
  dialog.op.show-cart .op-cart { display: flex; }
  .op-desktop { display: none; }
  .op-phone { display: inline-flex; }
  .op-editor { padding: 12px; }
  .op-editor-foot { bottom: -12px; }
  .op-chip { flex: 1 1 calc(50% - 8px); min-width: 0; }
}

/* รูปเล็กหัวหน้าเลือกตัวเลือก */
.op-editor-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.op-editor-title img, .op-editor-noimg { width: 64px; height: 64px; flex: none; border-radius: var(--r-sm); object-fit: cover; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }

.menu-edit-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.menu-edit-photo { width: 72px; height: 72px; flex: none; border-radius: var(--r-sm); border: 1px dashed var(--line); background: var(--surface-2); color: var(--ink-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; overflow: hidden; cursor: pointer; font-size: .75rem; }
.menu-edit-photo:hover { border-color: var(--accent); }
.menu-edit-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* รูปของตัวเลือก */
.opt-edit { display: flex; align-items: center; gap: 8px; }
.opt-edit-name { flex: 1; min-width: 0; }
.opt-photo { width: 52px; height: 52px; }
.op-chip-img { display: block; width: 72px; height: 54px; object-fit: cover; border-radius: 8px; margin: 2px auto 4px; }
.opt-img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex: none; margin-right: 8px; }

.brand-mark { overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }

.side-admin { margin: 6px 8px 0; background: rgb(255 255 255 / .16); color: #fff; border-color: rgb(255 255 255 / .35); justify-content: center; }
.side-admin:hover { background: rgb(255 255 255 / .26); }

.ta-card { display: grid; gap: 4px; width: 100%; text-align: left; padding: 12px; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.ta-card:hover { border-color: var(--accent); }
.op-line-ta { min-height: 36px; padding: 2px 10px; font-size: .8125rem; }
.op-line-ta[aria-pressed="true"] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); font-weight: 700; }
.op-label { margin: 0 14px 8px; flex: none; }

/* สีโต๊ะตามสถานะ: พื้นเต็มสีและแถบซ้ายหนา มองจากไกลก็แยกได้ */
.tbl { position: relative; overflow: hidden; border-width: 2px; }
.tbl.st-warn { background: #fff4d6; border-color: #e0a100; }
.tbl.st-accent { background: #dfeafc; border-color: #3a62ad; }
.tbl.st-ok { background: #dcf3e5; border-color: #1f8a4c; }
.tbl.st-neutral { background: var(--surface); }
.tbl.st-warn::before, .tbl.st-accent::before, .tbl.st-ok::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; }
.tbl.st-warn::before { background: #e0a100; }
.tbl.st-accent::before { background: #3a62ad; }
.tbl.st-ok::before { background: #1f8a4c; }
.tbl.st-warn .badge { background: #e0a100; color: #fff; }
.tbl.st-accent .badge { background: #3a62ad; color: #fff; }
.tbl.st-ok .badge { background: #1f8a4c; color: #fff; }
.tbl.empty-t { opacity: .75; }
.tbl.empty-t .t-name { color: var(--ink-2); }
.tbl[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--accent), var(--shadow-md); }
:root[data-theme="dark"] .tbl.st-warn { background: #3a2c08; }
:root[data-theme="dark"] .tbl.st-accent { background: #1a2a48; }
:root[data-theme="dark"] .tbl.st-ok { background: #123222; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tbl.st-warn { background: #3a2c08; }
  :root:not([data-theme="light"]) .tbl.st-accent { background: #1a2a48; }
  :root:not([data-theme="light"]) .tbl.st-ok { background: #123222; }
}
.tbl-legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 10px; font-size: .8125rem; color: var(--ink-2); }
.tbl-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.tbl-legend .lg::before { content: ""; width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--line); }
.tbl-legend .st-warn::before { background: #fff4d6; border-color: #e0a100; }
.tbl-legend .st-accent::before { background: #dfeafc; border-color: #3a62ad; }
.tbl-legend .st-ok::before { background: #dcf3e5; border-color: #1f8a4c; }

/* จอครัว: ตัวใหญ่ ตัดกันชัด อ่านได้จากระยะ 1–2 เมตร */
.kds { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.kds-head h2 { font-size: 1.375rem; }
.ticket { border: 3px solid var(--line); }
.ticket-head { padding: 12px 16px; background: var(--surface-2); }
.kt-new .ticket-head { background: #e0a100; color: #fff; border-color: #e0a100; }
.kt-new { border-color: #e0a100; }
.kt-cooking .ticket-head { background: #3a62ad; color: #fff; border-color: #3a62ad; }
.kt-cooking { border-color: #3a62ad; }
.ticket.late { border-color: #c62828; }
.ticket.late .ticket-head { background: #c62828; color: #fff; }
.ticket-head .badge { background: rgb(255 255 255 / .92); color: #1c2740; font-size: .9375rem; font-weight: 700; }
.kt-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.ticket-head .t { font-size: 1.75rem; font-weight: 800; line-height: 1.1; }
.kt-no { font-size: 1.0625rem; font-weight: 700; opacity: .9; }
.kt-ta { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: #fde7c7; color: #8a4b00; font-size: 1.125rem; font-weight: 800; border-bottom: 2px solid #f0b55e; }
.ticket-body { padding: 4px 16px; }
.ticket-item { padding: 14px 0; border-bottom: 2px dashed var(--line); }
.ticket-item .n { display: flex; align-items: flex-start; gap: 10px; font-size: 1.5rem; font-weight: 800; line-height: 1.25; color: var(--ink); }
.ticket-item .q { flex: none; min-width: 44px; height: 44px; padding: 0 8px; display: grid; place-items: center; border-radius: 10px; background: var(--ink); color: var(--surface); font-size: 1.5rem; font-weight: 800; margin: 0; }
.kt-opts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0 54px; }
.kt-opt { padding: 4px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-text); font-size: 1.125rem; font-weight: 700; border: 1px solid var(--line); }
.kt-opt:first-child { background: var(--ink); color: var(--surface); }
.ticket-item .note { margin: 8px 0 0 54px; padding: 6px 12px; font-size: 1.125rem; font-weight: 800; background: #fde2e1; color: #b3261e; border: 2px solid #e57373; }
.ticket-foot .btn { min-height: 60px; font-size: 1.125rem; }
.prep .tag { font-size: 1.125rem; padding: 6px 14px; }
@media (max-width: 560px) {
  .ticket-head .t { font-size: 1.375rem; }
  .ticket-item .n { font-size: 1.25rem; }
  .kt-opts, .ticket-item .note { margin-left: 0; }
}

/* ใบพิมพ์ตัวใหญ่ขึ้นสำหรับเครื่องพิมพ์ความร้อน */
#printArea { font-size: 14px; line-height: 1.4; font-family: 'IBM Plex Sans Thai', sans-serif; }
#printArea .slip-t { font-size: 18px; }
#printArea .slip-big { font-size: 26px; }
#printArea .slip-r { font-size: 14px; }

/* หน้าแยกจ่าย */
dialog.sp { width: min(1100px, 96vw); height: 92vh; height: 92dvh; max-width: none; max-height: none; padding: 0; border: 0; border-radius: var(--r-lg); background: var(--bg); color: var(--ink); overflow: hidden; }
dialog.sp[open] { display: flex; flex-direction: column; }
dialog.sp::backdrop { background: rgb(10 20 40 / .5); }
.sp-head { flex: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sp-top { flex: none; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 12px 16px 0; }
.sp-people { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sp-n { min-width: 44px; min-height: 44px; border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--surface); font: inherit; font-weight: 700; color: inherit; cursor: pointer; }
.sp-n[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sp-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; }
.sp-tabs { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 12px; position: sticky; top: -12px; background: var(--bg); padding: 6px 0; z-index: 1; }
.sp-person { display: flex; gap: 10px; align-items: center; text-align: left; padding: 10px; border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--surface); font: inherit; color: inherit; cursor: pointer; }
.sp-person[aria-pressed="true"] { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
.sp-dot { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; font-weight: 800; font-size: .9375rem; }
.sp-units { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.sp-unit { position: relative; display: grid; gap: 2px; text-align: left; padding: 12px; min-height: 76px; border-radius: var(--r-sm); border: 3px solid var(--c); background: var(--surface); font: inherit; color: inherit; cursor: pointer; }
.sp-unit.on { background: color-mix(in srgb, var(--c) 12%, var(--surface)); }
.sp-unit .sp-dot { position: absolute; top: 6px; right: 6px; }
.sp-unit-name { font-weight: 700; padding-right: 30px; }
.sp-shares { display: grid; gap: 10px; }
.sp-share { display: grid; grid-template-columns: auto minmax(140px, 200px) 1fr; gap: 12px; align-items: center; padding: 12px; border-radius: var(--r-sm); border: 2px solid var(--c); background: var(--surface); }
.sp-methods { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-methods .op-chip { min-height: 44px; min-width: 0; }
.sp-foot { position: sticky; bottom: -12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 12px; padding: 12px 0; background: var(--bg); }
.sp-foot > span { flex: 1; }
.sp-foot .btn { min-height: 52px; }
@media (max-width: 680px) { .sp-share { grid-template-columns: auto 1fr; } .sp-methods { grid-column: 1 / -1; } }

/* จอครัวแบบกะทัดรัด: การ์ดหลายใบต่อแถว รูปเล็กช่วยจำ และแยกจุดในครัว */
.kt-stations { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.kt-stations button { min-height: 48px; padding: 0 18px; border-radius: 999px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; }
.kt-stations button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.kds { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
#colNew, #colCook { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); align-items: start; }
.ticket-head { padding: 8px 12px; }
.ticket-head .t { font-size: 1.5rem; }
.ticket-body { padding: 0 12px; }
.ticket-item { padding: 8px 0; cursor: pointer; border-bottom-width: 1px; }
.ticket-item .n { align-items: center; gap: 8px; font-size: 1.1875rem; }
.ticket-item .q { min-width: 34px; height: 34px; font-size: 1.1875rem; border-radius: 8px; }
.kt-img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; }
.kt-name { flex: 1; min-width: 0; }
.kt-opts { margin: 6px 0 0; gap: 4px; }
.kt-opt { font-size: .9375rem; padding: 2px 9px; }
.ticket-item .note { margin: 6px 0 0; font-size: 1rem; }
.ticket-item.done { opacity: .45; }
.ticket-item.done .kt-name { text-decoration: line-through; }
.kt-check { color: var(--ok); flex: none; }
.ticket-foot { padding: 4px 12px 10px; }
.ticket-foot .btn { min-height: 52px; }
.kt-ta { padding: 4px 12px; font-size: 1rem; }
@media (max-width: 900px) { .kds { grid-template-columns: minmax(0, 1fr); } }

.sp-share { grid-template-columns: auto minmax(130px, 180px) 1fr auto; }
.sp-pay { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; justify-content: flex-end; }
.sp-pay .field { width: 110px; }
.sp-share.paid { background: var(--ok-soft); }
.sp-qr { grid-column: 1 / -1; display: grid; justify-items: center; gap: 4px; }
@media (max-width: 900px) { .sp-share { grid-template-columns: auto 1fr; } .sp-methods, .sp-pay { grid-column: 1 / -1; } }

/* หน้ารับเงินกลางจอ */
#bill.pay-mode { position: fixed; z-index: 30; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, 94vw); max-height: 92vh; overflow-y: auto; box-shadow: 0 0 0 100vmax rgb(10 20 40 / .55), var(--shadow-lg); border-radius: var(--r-lg); }
#bill.pay-mode .bill-head h2 { font-size: 1.5rem; }
#bill.pay-mode .bill-foot { padding: 20px 24px 24px; }
#bill.pay-mode .bill-total { font-size: 2.5rem !important; }
#bill.pay-mode .btn { min-height: 56px; font-size: 1.0625rem; }
#bill.pay-mode .field { min-height: 56px; font-size: 1.5rem; }
#bill.pay-mode .quick-cash button { min-height: 56px; font-size: 1.125rem; }
#bill.pay-mode .confirm-actions { gap: 10px; }
#bill.pay-mode .success h2 { font-size: 1.75rem; }
body.paying #tabbar { z-index: 1; }

/* ปุ่มชำระเงินสีส้ม และหน้าเลือกวิธีจ่าย */
.pay-big { margin-top: 14px; min-height: 64px; font-size: 1.25rem; font-weight: 800; background: #ea580c; border-color: #ea580c; color: #fff; gap: 10px; }
.pay-big:hover { background: #c2410c; border-color: #c2410c; }
.pay-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 12px; }
.pay-tool { min-height: 52px; border-radius: var(--r-sm); border: 2px solid #b45309; background: #fef3c7; color: #92400e; font: inherit; font-weight: 700; cursor: pointer; }
.pay-methods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.pay-m { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 58px; border-radius: var(--r-sm); border: 2px solid var(--pc); background: color-mix(in srgb, var(--pc) 10%, var(--surface)); color: var(--pc); font: inherit; font-weight: 800; font-size: 1.0625rem; cursor: pointer; }
.pay-m.on { background: #16a34a; border-color: #16a34a; color: #fff; box-shadow: 0 0 0 3px #bbf7d0; }

/* หน้าชำระเงินแบบเรียบ ดูน่าเชื่อถือ: สีกลาง ไอคอนเดียวโทน และสีเขียวใช้เฉพาะสิ่งที่เลือก */
#bill.pay-mode { width: min(520px, 94vw); }
#bill.pay-mode .bill-head { padding: 18px 24px 14px; }
#bill.pay-mode .bill-head .btn { display: none; }
#bill.pay-mode .bill-foot { padding: 4px 24px 22px; border-top: 0; }
.pay-sum { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); padding: 12px 16px; }
.pay-sum-row { display: flex; justify-content: space-between; color: var(--ink-2); font-size: .9375rem; padding: 2px 0; }
.pay-sum-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; padding-top: 10px; border-top: 1px dashed var(--line); font-weight: 600; }
#bill.pay-mode .pay-sum-total .bill-total { font-size: 2.25rem !important; line-height: 1.1; }
.pay-note { margin-bottom: 8px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent-text); font-size: .875rem; font-weight: 600; }
.pay-tools { display: flex; gap: 8px; margin-top: 12px; }
.pay-tool { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: .9375rem; cursor: pointer; }
.pay-tool:hover { border-color: var(--accent); color: var(--accent-text); }
.pay-label { margin: 18px 0 8px; font-size: .8125rem; font-weight: 700; letter-spacing: .02em; color: var(--ink-2); text-transform: none; }
.pay-methods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.pay-m { position: relative; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 12px; text-align: left; border-radius: var(--r); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; transition: border-color .15s, background .15s; box-shadow: none; }
.pay-m:hover { border-color: var(--accent); }
.pay-m-ic { width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.pay-m-tx { display: grid; min-width: 0; line-height: 1.25; }
.pay-m-tx b { font-size: 1rem; }
.pay-m-tx small { color: var(--ink-2); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pay-m.on { border-color: #16a34a; background: #f0fdf4; box-shadow: 0 0 0 3px #dcfce7; color: var(--ink); }
.pay-m.on .pay-m-ic { background: #16a34a; color: #fff; }
.pay-m-ok { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #16a34a; color: #fff; box-shadow: 0 0 0 2px var(--surface); }
.pay-cancel { border-color: transparent; color: var(--ink-2); }
#bill.pay-mode .btn.primary { background: #16a34a; border-color: #16a34a; }
#bill.pay-mode .btn.primary:disabled { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }
:root[data-theme="dark"] .pay-m.on { background: #0f2a1a; box-shadow: 0 0 0 3px #14532d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pay-m.on { background: #0f2a1a; box-shadow: 0 0 0 3px #14532d; } }
.pay-big { background: #ea580c; }

/* รายการทวนในหน้าชำระเงิน */
#bill.pay-mode { width: min(980px, 96vw); }
.pay-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
.pay-review { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); display: flex; flex-direction: column; max-height: 70vh; }
.pay-review-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.pay-review-list { overflow-y: auto; padding: 4px 14px; }
.pay-review-line { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 1rem; }
.pay-review-line:last-child { border-bottom: 0; }
.pay-q { min-width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--ink); color: var(--surface); font-weight: 800; font-size: .9375rem; }
.pay-review-name { font-weight: 600; line-height: 1.3; }
.pay-review-name small { display: block; font-weight: 400; color: var(--ink-2); font-size: .8125rem; }
.pay-review-note { color: var(--bad) !important; font-weight: 600 !important; }
.pay-review-disc { padding: 8px 14px; color: var(--ink-2); border-top: 1px solid var(--line); }
.pay-review-total { display: flex; justify-content: space-between; padding: 12px 14px; border-top: 1px solid var(--line); font-weight: 800; font-size: 1.125rem; background: var(--surface-2); border-radius: 0 0 var(--r) var(--r); }
@media (max-width: 820px) { .pay-grid { grid-template-columns: minmax(0, 1fr); } .pay-review { max-height: 34vh; } }

/* จำนวนอยู่ข้างขนาด */
.op-size-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; }
.op-size-col { flex: 1; min-width: 0; }
.op-qty { flex: none; }
.op-qty h3 { margin-top: 16px; margin-bottom: 8px; }
.op-stepper button { width: 52px; height: 52px; }
.op-stepper strong { min-width: 44px; font-size: 1.5rem; text-align: center; }

/* ครัว: แถบสีหมวดเมนูด้านซ้ายของแต่ละรายการ */
.ticket-item { border-left: 8px solid var(--kc, transparent); padding-left: 10px; border-radius: 4px; }
.ticket-item.done { border-left-color: #16a34a; }
/* ใบเสร็จ: ตัวเลือกบรรทัดละรายการ และขนาดตัวอักษร */
#printArea .slip-o { padding-left: 14px; font-size: 13px; line-height: 1.35; }
#printArea .slip-l .slip-r { font-size: 17px; }
#printArea .slip-l .slip-o { font-size: 15px; }
#printArea .slip-l .slip-big { font-size: 30px; }
.slipf-opt { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
/* ครัว: แบ่งโซนออเดอร์ใหม่/กำลังทำให้ชัด และอัดการ์ดให้เห็นได้มากขึ้น */
.kds { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.kds-zone { border-radius: 14px; padding: 0 10px 10px; min-height: 200px; border: 2px solid; }
.zone-new { background: #fff8e6; border-color: #e0a100; }
.zone-cook { background: #eaf0fb; border-color: #3a62ad; }
.kds-zone .kds-head { margin: 0 -10px 10px; padding: 8px 14px; border-radius: 12px 12px 0 0; color: #fff; position: sticky; top: 0; z-index: 2; }
.zone-new .kds-head { background: #e0a100; }
.zone-cook .kds-head { background: #3a62ad; }
.kds-zone .kds-head h2 { font-size: 1.125rem; color: #fff; }
.kds-zone .count-pill { background: #fff; color: #1c2740; font-weight: 800; }
.kds-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-items: start; }
.kds-grid .empty { grid-column: 1 / -1; }
.kds-grid .ticket { border-width: 2px; }
.kds-grid .ticket-head { padding: 5px 9px; }
.kds-grid .ticket-head .t { font-size: 1.125rem; }
.kds-grid .kt-no { font-size: .875rem; }
.kds-grid .ticket-head .badge { font-size: .75rem; padding: 1px 6px; }
.kds-grid .ticket-body { padding: 0 8px; }
.kds-grid .ticket-item { padding: 5px 0 5px 7px; border-left-width: 5px; }
.kds-grid .ticket-item .n { font-size: .9375rem; gap: 6px; }
.kds-grid .ticket-item .q { min-width: 24px; height: 24px; font-size: .875rem; border-radius: 6px; }
.kds-grid .kt-img { width: 28px; height: 28px; border-radius: 6px; }
.kds-grid .kt-opts { margin-top: 3px; gap: 3px; }
.kds-grid .kt-opt { font-size: .75rem; padding: 1px 6px; border-radius: 6px; }
.kds-grid .ticket-item .note { font-size: .8125rem; padding: 2px 7px; margin-top: 3px; }
.kds-grid .kt-ta { padding: 2px 9px; font-size: .8125rem; }
.kds-grid .ticket-foot { padding: 4px 8px 8px; display: flex; gap: 6px; }
.kds-grid .ticket-foot .btn { min-height: 38px; font-size: .875rem; margin: 0; }
.kds-grid .ticket-foot .btn.primary { flex: 2; }
.kds-grid .ticket-foot .btn:not(.primary) { flex: 1; padding: 0 6px; }
.prep .tag { font-size: .875rem; padding: 3px 10px; }
.kt-stations button { min-height: 38px; font-size: .875rem; padding: 0 14px; }
@media (max-width: 900px) { .kds { grid-template-columns: minmax(0, 1fr); } }

/* รูปเมนูในรายการตอนรับเงิน */
.pay-review-line { grid-template-columns: auto 44px 1fr auto; align-items: center; }
.pay-img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; display: block; }
.pay-img-none { background: var(--surface-2); }

/* แถบเงินทอน ตัวใหญ่ เขียว = ทอนได้ แดง = เงินยังไม่พอ */
.change-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding: 12px 18px; border-radius: 12px; border: 2px solid; font-weight: 800; }
.change-bar span:first-child { font-size: 1.25rem; }
.change-bar .num { font-size: 2.25rem; line-height: 1.1; }
.change-bar.ok { background: #e3f6e8; border-color: #16a34a; color: #116b31; }
.change-bar.short { background: #fde2e1; border-color: #e57373; color: #b3261e; }

/* =====================================================================
   ดีไซน์ใหม่ 2026: พรีเมียม อ่านง่าย และเปลี่ยนโทนสีได้
   - สีหลักทั้งหมดมาจากธีม (--accent, --side-a/b) ที่ ui.js คำนวณให้
   - สีสถานะ (รอครัว เหลือง / กำลังทำ น้ำเงิน / รอเก็บเงิน เขียว / รอนาน แดง) คงที่ทุกธีม
     เพื่อให้พนักงานจำความหมายสีได้แม้เปลี่ยนธีม
   ===================================================================== */
:root {
  --r-sm: 12px; --r: 18px; --r-lg: 24px;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / .04), 0 1px 3px rgb(16 24 40 / .06);
  --shadow-md: 0 4px 8px -2px rgb(16 24 40 / .07), 0 14px 28px -6px rgb(16 24 40 / .10);
  --shadow-lg: 0 28px 56px -14px rgb(16 24 40 / .30);
  --ring: color-mix(in srgb, var(--accent) 32%, transparent);
  --side-active-bg: #ffffff; --side-active-ink: var(--accent-text);
}
:root[data-theme="dark"] { --side-active-bg: var(--accent); --side-active-ink: var(--accent-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --side-active-bg: var(--accent); --side-active-ink: var(--accent-ink); } }

body {
  background:
    radial-gradient(1100px 520px at 105% -12%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 62%),
    radial-gradient(900px 480px at -10% 110%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  font-feature-settings: "tnum" 1;
  letter-spacing: .002em;
}
h1 { font-size: 1.625rem; font-weight: 700; letter-spacing: -.012em; }
h2 { font-weight: 700; letter-spacing: -.005em; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink-2) 35%, transparent) transparent; }
:focus-visible { outline: 0; box-shadow: 0 0 0 4px var(--ring); border-radius: 10px; }

/* แถบข้าง: ไล่สีตามธีม มีแสงด้านบน และปุ่มที่เลือกเป็นเม็ดยาสีขาวเด่น */
#side {
  background:
    radial-gradient(420px 260px at 0% 0%, rgb(255 255 255 / .16), transparent 62%),
    linear-gradient(170deg, var(--side-a) 0%, var(--side-b) 100%);
  padding: 18px 12px 16px;
  box-shadow: inset -1px 0 0 rgb(255 255 255 / .06);
}
#side .brand { padding: 2px 6px 6px; }
#side .brand-mark { background: #fff; color: var(--side-active-ink); border-radius: 14px; overflow: hidden; box-shadow: 0 6px 16px rgb(0 0 0 / .2); width: 44px; height: 44px; }
#side .nav-group { letter-spacing: .04em; opacity: .62; margin-top: 16px; }
#side nav a { border-radius: 12px; min-height: 44px; font-weight: 500; transition: background .15s; }
#side nav a:hover { background: rgb(255 255 255 / .12); }
#side nav a[aria-current="page"] { background: var(--side-active-bg); color: var(--side-active-ink); font-weight: 700; box-shadow: 0 8px 18px -6px rgb(0 0 0 / .35); }
.side-admin { border-radius: 12px; }
.op-cats { background: radial-gradient(300px 200px at 0% 0%, rgb(255 255 255 / .14), transparent 60%), linear-gradient(170deg, var(--side-a), var(--side-b)); }
.op-cats button[aria-pressed="true"] { background: var(--side-active-bg); color: var(--side-active-ink); box-shadow: 0 6px 14px -6px rgb(0 0 0 / .35); }

/* แถบหัวหน้าติดด้านบน โปร่งแสงเบลอ เลื่อนลงก็ยังเห็นปุ่ม */
#top {
  position: sticky; top: 0; z-index: 15; padding: 18px 32px 14px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
#top .sub { margin-top: 2px; }
main { padding-top: 18px; }
.chip { border: 1px solid color-mix(in srgb, var(--gold) 25%, transparent); }

/* ปุ่ม ช่องกรอก และตัวเลือก */
.btn { border-radius: 12px; box-shadow: var(--shadow-sm); border-color: var(--line); }
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); }
.btn.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 86%, #fff), var(--accent));
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .2), 0 8px 18px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { box-shadow: none; background: var(--surface-2); }
.btn.quiet-danger { box-shadow: none; }
.icon-btn { border-radius: 12px; box-shadow: var(--shadow-sm); transition: background .15s, color .15s; }
.field { border-radius: 12px; transition: border-color .15s, box-shadow .15s; }
.field:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.seg { border-radius: 14px; padding: 4px; box-shadow: inset 0 0 0 1px var(--line); }
.seg button { border-radius: 10px; font-weight: 600; }
.seg button[aria-pressed="true"] { color: var(--accent-text); box-shadow: var(--shadow-md); }
.badge { font-weight: 700; letter-spacing: .01em; }

/* การ์ดและตัวเลขสรุป */
.card, .stat { border-color: color-mix(in srgb, var(--line) 85%, transparent); box-shadow: var(--shadow-sm); }
.stats { gap: 14px; }
.stat { position: relative; overflow: hidden; padding: 16px 18px 18px; display: grid; gap: 2px; align-content: start; }
.stat::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 15%, transparent)); opacity: .85; }
.stat .label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.stat-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.stat .value { font-size: 1.875rem; font-weight: 700; letter-spacing: -.015em; margin-top: 4px; }
.welcome {
  background: radial-gradient(500px 260px at 100% 0%, rgb(255 255 255 / .16), transparent 60%), linear-gradient(120deg, var(--side-a), var(--side-b));
  color: #fff; box-shadow: var(--shadow-md);
}
.welcome .btn { background: var(--side-active-bg); color: var(--side-active-ink); border-color: transparent; }
.hub a, .quick a { transition: border-color .15s, box-shadow .15s, transform .15s; }
.hub a:hover, .quick a:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* ผังโต๊ะ: การ์ดมน ยกขึ้นเมื่อชี้ ตัวเลขยอดชัด */
.tables { gap: 12px; }
.tbl { border-radius: 16px; transition: transform .15s, box-shadow .15s, border-color .15s; }
.tbl:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.tbl .t-name { font-size: 1.0625rem; font-weight: 700; }
.tbl .t-amount { font-size: 1.3125rem; font-weight: 700; letter-spacing: -.01em; }
.tbl.st-warn::before, .tbl.st-accent::before, .tbl.st-ok::before { width: 6px; }
.tbl.empty-t { background: color-mix(in srgb, var(--surface) 55%, transparent); border-style: dashed; }
.tbl[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--accent), var(--shadow-md); transform: translateY(-2px); }

/* บิลด้านขวา */
.bill { border-radius: var(--r-lg); box-shadow: var(--shadow-md); }
.bill-head { background: linear-gradient(180deg, var(--accent-soft), transparent); }
.bill-total { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; }
.quick-cash button { border-radius: 12px; font-weight: 700; box-shadow: var(--shadow-sm); }
.quick-cash button:hover { border-color: var(--accent); color: var(--accent-text); }

/* ตาราง: หัวตารางมีพื้น แถวสลับสีอ่อน อ่านตัวเลขยาวๆ ง่าย */
.table-wrap { border-radius: 14px; }
th { background: var(--surface-2); color: var(--ink-2); font-weight: 600; }
th:first-child { border-top-left-radius: 10px; }
th:last-child { border-top-right-radius: 10px; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
tbody tr:hover td { background: var(--accent-soft); }

/* กล่องโต้ตอบ: พื้นหลังเบลอ ขอบมน */
dialog { color: var(--ink); }
dialog::backdrop { background: rgb(10 14 22 / .45); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
dialog.confirm { border: 1px solid var(--line); background: var(--surface); }

/* หน้าต่างเลือกธีม */
dialog.theme-dialog { width: min(580px, calc(100vw - 32px)); }
.theme-dialog h2 { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; }
.theme-dialog .seg { display: flex; }
.theme-dialog .seg button { flex: 1; }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.theme-opt { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 68px; border: 2px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; font: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
.theme-opt:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.theme-opt[aria-pressed="true"] { border-color: var(--sw); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sw) 22%, transparent); }
.theme-opt b { display: block; font-size: .9375rem; line-height: 1.3; }
.theme-opt small { display: block; color: var(--ink-2); font-size: .75rem; line-height: 1.35; }
.theme-sw { display: grid; grid-template-columns: 1.3fr 1fr; grid-template-rows: 1fr 1fr; width: 48px; height: 48px; border-radius: 13px; overflow: hidden; flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .08), 0 4px 10px -4px var(--sw); }
.theme-sw i:nth-child(1) { grid-row: span 2; background: linear-gradient(170deg, color-mix(in srgb, var(--sw) 75%, #000), var(--sw)); }
.theme-sw i:nth-child(2) { background: var(--sw); }
.theme-sw i:nth-child(3) { background: color-mix(in srgb, var(--sw) 14%, #fff); }
.theme-tick { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--sw); color: #fff; }
.theme-custom input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.theme-custom[aria-pressed="false"] .theme-sw { background: conic-gradient(#ef4444, #f59e0b, #84cc16, #10b981, #06b6d4, #3b82f6, #8b5cf6, #ec4899, #ef4444); }
.theme-custom[aria-pressed="false"] .theme-sw i { display: none; }
@media (max-width: 520px) { .theme-grid { grid-template-columns: minmax(0, 1fr); } }

/* หน้าเข้าสู่ระบบ */
.center-page { background: radial-gradient(800px 420px at 50% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 65%); }
.login-card { border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }

/* มือถือ: แถบล่างโปร่งแสงเบลอ */
@media (max-width: 860px) {
  #top { padding: 14px 16px 12px; }
  #tabbar { background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); }
  #tabbar a[aria-current="page"] { border-radius: 12px; }
  .stat .value { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { .tbl, .btn, .theme-opt, .hub a, .quick a { transition: none; transform: none !important; } }
@media print { body { background: #fff; } #top { position: static; backdrop-filter: none; } }

/* แถบกะย่อเก็บได้: ซ่อนปุ่มทั้งหมด เหลือบรรทัดเดียว ผังโต๊ะขึ้นมาเห็นได้มากขึ้น */
#shiftBar > span:nth-child(2) { margin-left: auto; }
#shiftBar .tools-toggle { flex: none; min-height: 40px; padding: 6px 12px; font-size: .875rem; color: var(--ink-2); box-shadow: none; }
#shiftBar.collapsed { padding: 6px 8px 6px 16px !important; margin-bottom: 8px !important; }
#shiftBar.collapsed > span:nth-child(2) { display: none !important; }
#shiftBar.collapsed .tools-toggle { margin-left: auto; }
#shiftBar .badge .icon { display: inline-block; }

/* ปุ่มเสียงเตือน: ยังไม่ปลดล็อกเสียงให้เด่นชวนแตะ */
.sound-btn.on { color: var(--accent-text); }
.sound-btn.off { color: var(--ink-2); opacity: .8; }
.sound-btn.locked { min-height: 44px; padding: 6px 14px; font-size: .875rem; background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); animation: sound-pulse 1.6s ease-in-out infinite; }
@keyframes sound-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--warn) 18%, transparent); } }
/* หน้าต่างเลือกเสียงพูด: ป้ายเพศเสียงเป็นวงกลมแทนแถบสีของธีม */
.voice-dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
.voice-av { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: .8125rem; font-weight: 700; background: var(--accent-soft); color: var(--accent-text); }
.voice-av.m { background: color-mix(in srgb, var(--ink) 10%, var(--surface)); color: var(--ink); }
.voice-av.u { background: var(--surface-2); color: var(--ink-2); }
.voice-test { width: 100%; justify-content: center; }
.voice-help { padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--ink); font-size: .875rem; line-height: 1.5; }
.voice-help ul { margin: 6px 0 0; padding-left: 20px; }
/* คลังเสียงในหลังบ้าน */
.voice-packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.voice-pack { padding: 12px 14px; border: 2px solid var(--line); border-radius: 16px; background: var(--surface); }
.voice-pack.on { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.voice-pack b { overflow-wrap: anywhere; }
.voice-rec { display: grid; gap: 6px; max-height: 55vh; overflow-y: auto; }
.voice-rec-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.voice-rec-t { display: flex; align-items: center; gap: 8px; min-width: 0; }

/* จอครัว: การ์ดออเดอร์ใหม่กะพริบ 20 วินาที */
.ticket.kt-flash { animation: kt-flash 1s ease-in-out 0s 20; }
@keyframes kt-flash { 50% { box-shadow: 0 0 0 6px rgb(224 161 0 / .55), var(--shadow-md); transform: scale(1.015); } }
@media (prefers-reduced-motion: reduce) { .ticket.kt-flash, .sound-btn.locked { animation: none; } }

/* ระยะที่ 2: เหลือจำนวนต่อวัน, ส่งครัวทีหลัง, ลงเวลาเข้า-ออกงาน, ค่าแรง */
.op-tile { position: relative; }
.op-left { position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 99px; background: var(--surface); color: var(--ink); font-size: .75rem; font-weight: 700; box-shadow: var(--shadow-sm); }
.op-left.low { background: var(--warn); color: #fff; }
.clock-btn.in { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.fire-btn { min-height: 30px; padding: 2px 10px; font-size: .8125rem; margin-left: 4px; background: var(--warn); color: #fff; border-color: var(--warn); }
.wage-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.wage-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; }
.wage-row .field { width: 120px; min-height: 40px; }

/* ระยะที่ 3: สมาชิกในหน้ารับเงิน, คิวรอโต๊ะ, เลือกรูปแบบร้าน */
.member-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--ok-soft); color: var(--ok); font-size: .875rem; }
.member-row span { flex: 1 1 180px; color: var(--ink); }
.member-row .btn { min-height: 36px; padding: 4px 10px; font-size: .8125rem; }
dialog.wait-dialog { width: min(720px, calc(100vw - 32px)); }
.wait-add { display: grid; grid-template-columns: 2fr 80px 1.4fr auto; gap: 8px; }
.wait-list { display: grid; gap: 8px; max-height: 55vh; overflow-y: auto; }
.wait-item { display: grid; grid-template-columns: 48px 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.wait-item.seated, .wait-item.cancelled { opacity: .55; }
.wait-no { font-size: 1.5rem; font-weight: 800; text-align: center; }
.wait-acts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.wait-acts .btn, .wait-acts .field { min-height: 38px; padding: 4px 10px; width: auto; }
.mode-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
@media (max-width: 560px) { .wait-add { grid-template-columns: 1fr 1fr; } }

/* บุฟเฟต์ในบิลของแคชเชียร์ */
.buffet-info { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); font-weight: 600; font-size: .875rem; }

/* ระยะที่ 4: รหัสบัตรกำนัลในหน้ารับเงิน */
.voucher-box { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.voucher-box label { flex: 1 1 180px; }
.voucher-box .btn { min-height: 44px; }
#vcInfo { flex-basis: 100%; }

/* หลายสาขา: ป้าย/ตัวเลือกสาขาบนแถบบน และหน้าจัดการสาขา */
.branch-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: .875rem; white-space: nowrap; }
.branch-chip select { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 700; cursor: pointer; max-width: 180px; }
.branch-list { display: grid; gap: 8px; }
.branch-row { display: grid; grid-template-columns: 1.2fr 1.6fr auto auto; gap: 8px; align-items: center; }
@media (max-width: 720px) { .branch-row { grid-template-columns: 1fr; } }
