:root {
  --primary: #1d4ed8;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --green: #059669;
  --green-50: #ecfdf5;
  --red: #dc2626;
  --red-50: #fef2f2;
  --amber: #b45309;
  --amber-50: #fffbeb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Sarabun', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: #0f1e46; color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px; color: #fff; }
.brand small { display: block; color: #94a3b8; font-size: 12px; }
.nav { display: flex; flex-direction: column; padding: 4px 10px; gap: 2px; }
.nav a { color: #cbd5e1; padding: 9px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav-group { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #64748b; padding: 14px 12px 4px; }
.user-box { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, .08); color: #fff; }
.user-box > div { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-box small { display: block; color: #94a3b8; font-size: 12px; }
.user-box .btn { background: transparent; color: #cbd5e1; border-color: #334155; }
.nav { flex: 1; }

/* ---------- auth ---------- */
.auth { display: none; }
body.logged-out .app { display: none; }
body.logged-out .auth { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: min(420px, 100%); }
.install-btn { margin: 12px 16px; padding: 10px; border-radius: 8px; border: 1px dashed #475569; background: transparent; color: #e2e8f0; cursor: pointer; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 20px; margin: 0; flex: 1; }
.company-chip { font-size: 13px; color: var(--muted); background: var(--bg); padding: 6px 12px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.menu-btn { display: none; }
.view { padding: 24px 28px 60px; max-width: 1280px; width: 100%; }
.scrim { display: none; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 20; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .view { padding: 16px 16px 60px; }
  .company-chip { display: none; }
}

/* ---------- common ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.right { text-align: right; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-dash { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-dash { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .grid-4, .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1e40af; }
.btn.danger { color: var(--red); }
.btn.btn-close { background: var(--red); border-color: var(--red); color: #fff; min-width: 88px; justify-content: center; }
.btn.btn-close:hover { background: #b91c1c; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.icon-btn { border: 0; background: transparent; font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--bg); }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); font-size: 15px;
}
.input:focus { outline: 2px solid var(--primary-100); border-color: var(--primary); }
textarea.input { resize: vertical; min-height: 70px; }

.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin: 4px 0 2px; }
.stat .sub { font-size: 13px; color: var(--muted); }
.stat.blue .value { color: var(--primary); }
.stat.green .value { color: var(--green); }
.stat.red .value { color: var(--red); }
.stat.amber .value { color: var(--amber); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #f8fafc; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--primary-50); }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 40px; color: var(--muted); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--green-50); color: var(--green); }
.badge.red { background: var(--red-50); color: var(--red); }
.badge.amber { background: var(--amber-50); color: var(--amber); }
.badge.blue { background: var(--primary-50); color: var(--primary); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-color: var(--primary); }

/* ---------- editor ---------- */
.items-table td { padding: 6px; }
.items-table .input { padding: 6px 8px; }
.items-table td.amount { text-align: right; font-weight: 600; white-space: nowrap; padding-right: 12px; }
.totals { margin-left: auto; width: min(380px, 100%); }
.totals .line { display: flex; justify-content: space-between; padding: 6px 0; gap: 12px; align-items: center; }
.totals .line.grand { border-top: 2px solid var(--text); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 700; }
.totals .input { width: 120px; text-align: right; }

/* ---------- chart ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: min(640px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal header h3 { margin: 0; flex: 1; font-size: 17px; }
.modal .body { padding: 20px; display: grid; gap: 12px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 60; box-shadow: var(--shadow); }

/* ---------- printable document (A4) ---------- */
.paper-wrap { overflow-x: auto; }
.paper {
  background: #fff; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 14mm 14mm; color: #111;
  box-shadow: var(--shadow); font-size: 13.5px;
}
.paper .doc-head { display: flex; justify-content: space-between; gap: 20px; }
.paper .doc-head img { max-height: 60px; max-width: 160px; margin-bottom: 6px; }
.paper .co-name { font-size: 17px; font-weight: 700; }
.paper .doc-title { text-align: right; }
.paper .doc-title h2 { margin: 0; color: var(--primary); font-size: 22px; }
.paper .doc-title .en { color: var(--muted); font-size: 13px; }
.paper .doc-title .copy { display: inline-block; margin-top: 6px; border: 1px solid var(--primary); color: var(--primary); padding: 1px 10px; border-radius: 4px; font-size: 12px; }
.paper .party { display: grid; grid-template-columns: 1fr 240px; gap: 16px; margin: 18px 0 14px; }
.paper .box { border: 1px solid #cbd5e1; border-radius: 6px; padding: 10px 12px; }
.paper .meta div { display: flex; justify-content: space-between; padding: 2px 0; }
.paper table { width: 100%; border-collapse: collapse; }
.paper th { background: var(--primary); color: #fff; padding: 7px 8px; font-weight: 600; font-size: 13px; }
.paper td { padding: 7px 8px; border-bottom: 1px solid #e5e7eb; vertical-align: top; }
.paper .sum { display: flex; justify-content: space-between; gap: 20px; margin-top: 12px; }
.paper .sum .words { flex: 1; align-self: flex-start; background: var(--primary-50); padding: 8px 12px; border-radius: 6px; font-weight: 600; }
.paper .sum table { width: 280px; }
.paper .sum td { border: 0; padding: 3px 8px; }
.paper .sum tr.grand td { border-top: 2px solid #111; font-weight: 700; font-size: 15px; padding-top: 6px; }
.paper .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 60px; text-align: center; }
.paper .sign .line { border-top: 1px dotted #111; padding-top: 6px; margin: 0 20px; }

.center { text-align: center; }
.center svg { display: block; margin: 0 auto 6px; }
.pay-box { display: flex; gap: 14px; align-items: center; margin-top: 16px; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 6px; }
.pay-box svg { flex-shrink: 0; }

/* ---------- POS ---------- */
body.pos-mode .view { max-width: none; padding-bottom: 16px; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.pos > * { min-width: 0; } /* กันแถบหมวดหมู่ยืดความกว้างจนจอมือถือล้น */
.chip { flex-shrink: 0; }
.pos-search { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 61px; z-index: 3; background: var(--bg); padding-bottom: 8px; }
.pos-search .input { font-size: 16px; padding: 10px 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; cursor: pointer; white-space: nowrap; font-weight: 500; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pos-today { font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; text-align: left;
  min-height: 96px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer;
  box-shadow: var(--shadow); -webkit-tap-highlight-color: transparent; transition: transform .06s;
}
.tile:active { transform: scale(.97); }
.tile:hover { border-color: var(--primary); }
.tile-name { font-weight: 600; line-height: 1.3; }
.tile-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.tile-foot b { color: var(--primary); }
.tile-stock { font-size: 12px; color: var(--muted); }
.tile-stock.low { color: var(--amber); font-weight: 600; }
.tile-stock.out { color: var(--red); font-weight: 600; }
.tile-qty { position: absolute; top: -6px; right: -6px; background: var(--primary); color: #fff; border-radius: 999px; min-width: 24px; height: 24px; display: grid; place-items: center; font-size: 13px; font-weight: 700; padding: 0 6px; }
.pos-cart { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); position: sticky; top: 77px; display: flex; flex-direction: column; max-height: calc(100vh - 100px); }
.cart-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.cart-close { display: none; }
.cart-lines { flex: 1; overflow-y: auto; padding: 4px 16px; min-height: 120px; }
.cart-line { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cl-info { flex: 1; min-width: 0; }
.cl-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-amt { width: 76px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button { width: 34px; height: 34px; border: 0; background: #f8fafc; font-size: 18px; cursor: pointer; }
.stepper span { min-width: 28px; text-align: center; font-weight: 600; }
.cart-foot { padding: 12px 16px 16px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.cart-foot .line { display: flex; justify-content: space-between; font-size: 14px; }
.cart-foot .line.grand { font-size: 20px; font-weight: 700; }
.pay-btn { justify-content: center; padding: 14px; font-size: 17px; }
.pay-btn:disabled { opacity: .5; cursor: not-allowed; }
.pos-bar { display: none; }
a.chip { color: var(--muted); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; }
.tile-icon { margin-right: 4px; }
.order-meta { display: flex; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.order-meta .input { flex: 1; min-width: 0; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.seg button { border: 0; background: #fff; padding: 6px 10px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.seg button.active { background: var(--primary); color: #fff; }
.cl-sub { font-size: 13px; color: var(--muted); }
.cl-sub .sent { color: var(--green); }
.cl-note { border: 0; background: none; padding: 2px 0; color: var(--muted); font-size: 13px; cursor: pointer; text-align: left; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-note.has { color: var(--amber); font-weight: 600; }
.pay-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.kitchen-btn { justify-content: center; padding: 14px 12px; font-size: 15px; background: var(--amber-50); border-color: #fcd34d; color: var(--amber); }
.kitchen-btn:disabled, .pay-btn:disabled { opacity: .5; cursor: not-allowed; }
.bill-list { display: grid; gap: 8px; }
.bill { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px 6px 0; }
.bill.current { border-color: var(--primary); background: var(--primary-50); }
.bill-main { flex: 1; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; border: 0; background: none; text-align: left; padding: 6px 12px; cursor: pointer; min-width: 0; }
.bill-main .muted { grid-column: 1; font-size: 13px; }
.bill-total { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: 17px; color: var(--primary); }
.ticket { font-size: 15px; }
.ticket-table { text-align: center; font-size: 26px; font-weight: 700; margin: 4px 0; }
.ticket-item { font-size: 17px; margin-top: 4px; }
.ticket-note { font-size: 15px; font-weight: 700; padding-left: 18px; }
.slip-note { font-size: 12px; }
#printArea { display: none; }
.notice { background: var(--amber-50); border: 1px solid #fcd34d; color: #78350f; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.tile.soldout { opacity: .45; }

/* ---------- ช่องทางการเงิน ---------- */
.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 12px; }
.channel-grid .card + .card { margin-top: 0; }
.channel.inactive { opacity: .55; }
.ch-qr svg, .ch-qr img { display: block; border-radius: 6px; border: 1px solid var(--line); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.pay-boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.pay-box img { flex-shrink: 0; object-fit: contain; }

/* ---------- โต๊ะ ---------- */
.table-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.table-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.qr-card { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 18px; border: 2px dashed #cbd5e1; border-radius: 14px; background: #fff; color: #000; text-align: center; }
.qr-card svg { display: block; margin: 4px 0; }
.qr-shop { font-weight: 700; font-size: 15px; }
.qr-table { font-size: 26px; font-weight: 700; color: var(--primary); }
.qr-sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10mm; padding: 6mm; }
.qr-sheet .qr-card { break-inside: avoid; }
.zone { font-weight: 700; color: var(--muted); margin: 14px 0 8px; font-size: 14px; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tcard {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 96px; padding: 12px; text-align: left;
  border-radius: 14px; border: 2px solid var(--line); background: var(--card); cursor: pointer; box-shadow: var(--shadow);
}
.tcard b { font-size: 20px; }
.tcard.free { border-color: #a7f3d0; }
.tcard.free .tstate { color: var(--green); font-weight: 600; }
.tcard.busy { border-color: #fcd34d; background: #fffdf5; }
.tcard.calling { border-color: var(--red); animation: pulse 1.2s infinite; }
.tcard.take { border-style: dashed; }
a.tcard { color: inherit; }
.tcard.manage { border-color: #c4b5fd; }
.count-card { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.count-card > div:first-child { flex: 1; min-width: 220px; }
.count-ctl { display: flex; align-items: center; gap: 8px; }
.count-ctl .input { width: 80px; text-align: center; font-size: 22px; font-weight: 700; padding: 8px; }
.count-btn { width: 48px; height: 48px; border-radius: 12px; border: 0; font-size: 26px; font-weight: 700; color: #fff; cursor: pointer; }
.count-btn.minus { background: var(--red); }
.count-btn.plus { background: var(--green); }
.tcard.paidwait { border-color: #93c5fd; background: var(--primary-50); }
.tcard.paidwait .tstate { color: var(--primary); font-weight: 600; }
.tamt { font-weight: 700; color: var(--amber); font-size: 17px; }
.tstate { font-size: 12px; color: var(--muted); }
.tflag { font-size: 12px; font-weight: 600; background: var(--primary-50); color: var(--primary); border-radius: 6px; padding: 1px 6px; }
.tflag.call { background: var(--red-50); color: var(--red); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(220, 38, 38, .25); } }

/* หน้ารายละเอียดโต๊ะ: แถบสถานะ + ปุ่มใหญ่ */
.bill-status {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 18px; border-radius: 16px;
  background: linear-gradient(135deg, #fff7ed, #fee2e2); border: 2px solid #fca5a5;
}
.bill-status > div:first-child { flex: 1; min-width: 180px; }
.bs-table { font-size: 26px; font-weight: 700; }
.bs-badge { display: inline-block; margin: 6px 0 4px; padding: 4px 14px; border-radius: 999px; background: var(--red); color: #fff; font-weight: 700; font-size: 16px; animation: pulse 1.6s infinite; }
.bs-meta { font-size: 13px; color: #7f1d1d; }
.bs-total { text-align: right; font-size: 32px; font-weight: 800; color: var(--red); line-height: 1.1; }
.bs-total small { display: block; font-size: 13px; font-weight: 600; color: #7f1d1d; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 10px; border-radius: 14px; cursor: pointer;
  border: 2px solid transparent; font: inherit; color: #fff; box-shadow: 0 4px 12px rgba(15, 23, 42, .15); transition: transform .06s;
}
.action-btn:active { transform: scale(.97); }
.action-btn .ai { font-size: 30px; line-height: 1.1; }
.action-btn b { font-size: 17px; }
.action-btn small { font-size: 12px; opacity: .92; }
.action-btn.add { background: var(--primary); }
.action-btn.print { background: #475569; }
.action-btn.qr { background: #7c3aed; }
.modal footer .btn.primary { font-size: 16px; padding: 10px 18px; }

.action-btn.close-t { background: #b91c1c; }
.action-btn.move { background: #0e7490; }
.action-btn.merge { background: #4d7c0f; }
.action-btn.split { background: #c2410c; }
.action-btn.divide { background: #9d174d; }
.bs-badge.seated { background: var(--primary); animation: none; }
.bs-pin { margin-top: 6px; font-size: 15px; }
.bs-pin b { font-size: 22px; letter-spacing: 4px; color: var(--primary); }
.tcard.seated { border-color: #93c5fd; background: var(--primary-50); }
.seated-txt { color: var(--primary) !important; font-weight: 600; }
.tguests { font-size: 13px; font-weight: 500; color: var(--muted); }
.tflag.pin { background: #ede9fe; color: #6d28d9; letter-spacing: 1px; }
.pin-big { font-size: 40px; font-weight: 800; letter-spacing: 10px; color: var(--primary); }
.split-info { color: var(--muted); }
.cl-opt { font-size: 13px; color: #6d28d9; }
/* ตัวเลือกเมนู */
.opt-pick { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; margin: 0; }
.opt-pick legend { font-weight: 700; padding: 0 6px; }
.opt-choice { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.opt-choice:last-child { border-bottom: 0; }
.opt-choice input { width: 20px; height: 20px; accent-color: var(--primary); }
.opt-choice span { flex: 1; }
.opt-choice b { font-size: 14px; color: var(--muted); font-weight: 500; }
.opt-group { border: 1px dashed #cbd5e1; border-radius: 10px; padding: 10px; margin-top: 8px; }
/* ตั้งค่ากันสั่งจากนอกร้าน */
.protect { display: grid; gap: 10px; margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; }
/* หน้าลูกค้า */
.closed-banner { display: flex; gap: 12px; align-items: center; margin: 10px 0; padding: 12px 14px; border-radius: 14px; background: #fef3c7; border: 1px solid #fcd34d; font-size: 15px; }
.closed-banner > :first-child { font-size: 28px; }
.pin-input { font-size: 34px; text-align: center; letter-spacing: 14px; font-weight: 700; }
/* กะการขาย */
.shift-chip { font-weight: 600; white-space: nowrap; }
.shift-chip.on { color: var(--green); }
.shift-chip.off { color: var(--red); }
.shift-now { border-left: 6px solid var(--green); }
.denoms { display: grid; gap: 6px; margin: 8px 0; }
.denom { display: grid; grid-template-columns: 70px 16px 1fr 90px; align-items: center; gap: 6px; }
.denom .input { padding: 6px 8px; text-align: right; }
.denom b { text-align: right; font-variant-numeric: tabular-nums; }
.close-sum { display: grid; gap: 6px; background: #f8fafc; border-radius: 12px; padding: 12px 14px; }
.close-sum .big-row { font-size: 18px; border-top: 1px solid var(--line); padding-top: 6px; }
.diff { text-align: center; font-size: 22px; font-weight: 800; padding: 8px; border-radius: 10px; }
.diff.ok { background: var(--green-50); color: var(--green); }
.diff.over { background: var(--amber-50); color: var(--amber); }
.diff.short { background: var(--red-50); color: var(--red); }
.seg label { display: flex; }
.seg-opt { flex: 1; text-align: center; padding: 10px; cursor: pointer; font-weight: 600; }
.seg input:checked + .seg-opt { background: var(--primary); color: #fff; }
.kds-card.cancel { border-top-color: var(--red); background: #fef2f2; }
.kds-card.cancel .kds-lines { text-decoration: line-through; color: var(--red); }
.kds-opt, .ticket-opt { font-size: 14px; color: #6d28d9; font-weight: 600; padding-left: 22px; }

/* หน้าลูกค้า: ปุ่มภาษา / ปุ่มคำขอ / ติดดาว */
.lang-btn { flex-shrink: 0; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 10px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.req-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.req-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 96px; padding: 10px 8px;
  border: 2px solid var(--line); border-radius: 16px; background: #fff; font: inherit; font-size: 15px; font-weight: 600; text-align: center; cursor: pointer;
}
.req-btn:active { transform: scale(.97); }
.req-btn .req-ic { font-size: 32px; line-height: 1; }
.req-btn small { font-size: 12px; font-weight: 500; color: var(--muted); }
.req-btn.general { grid-column: 1 / -1; min-height: 64px; flex-direction: row; gap: 10px; background: #fff7ed; border-color: #fdba74; }
.req-btn.urgent { border-color: #fca5a5; }
.req-btn.sent, .req-btn:disabled { opacity: .55; cursor: default; }
.req-btn.sent small { color: var(--green); font-weight: 700; }
.stars { display: flex; justify-content: center; gap: 6px; }
.stars button { border: 0; background: none; font-size: 46px; line-height: 1; color: #cbd5e1; cursor: pointer; padding: 0 2px; transition: transform .1s; }
.stars button.on { color: #f59e0b; transform: scale(1.08); }
#tagBox .chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
/* POS: คำขอของลูกค้า */
.tflag.req { background: #fff7ed; color: #c2410c; }
.tflag.req.late, .tcard.late .tflag.call { background: var(--red); color: #fff; }
.tcard.late { border-color: var(--red); background: #fef2f2; }
.req-list { border: 2px solid #fdba74; background: #fff7ed; border-radius: 14px; padding: 10px 12px; }
.req-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid #fed7aa; font-size: 15px; }
.req-row > span { flex: 1; min-width: 0; }
.req-row small { color: var(--muted); white-space: nowrap; }
.req-row.late small { color: var(--red); font-weight: 700; }
.req-edit { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
/* ความพึงพอใจลูกค้า */
.fb-top { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.fb-avg { text-align: center; min-width: 150px; }
.fb-num { font-size: 52px; font-weight: 800; line-height: 1; }
.fb-stars { color: #f59e0b; font-size: 22px; letter-spacing: 2px; }
.fb-stars span { color: #e2e8f0; }
.fb-stars.sm { font-size: 16px; letter-spacing: 1px; }
.fb-dist { flex: 1; min-width: 220px; display: grid; gap: 6px; }
.fb-bar { display: grid; grid-template-columns: 40px 1fr 36px; align-items: center; gap: 8px; font-size: 14px; }
.fb-bar div { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.fb-bar i { display: block; height: 100%; background: #f59e0b; border-radius: 999px; }
.fb-bar b { text-align: right; }
.chip.good { background: var(--green-50); border-color: #a7f3d0; color: var(--green); }
.chip.bad { background: var(--red-50); border-color: #fecaca; color: var(--red); }
.fb-item { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.fb-item.low { background: #fff7f7; margin: 0 -8px; padding: 10px 8px; border-radius: 8px; }
.fb-comment { font-size: 15px; }

/* สถานะการเชื่อมต่อ */
.net-status { font-size: 13px; font-weight: 700; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.net-status.off { background: var(--red); color: #fff; }
.net-status.sync { background: var(--amber-50); color: var(--amber); }
/* รายงานรายชั่วโมง */
.hour-bars { display: flex; align-items: flex-end; gap: 4px; height: 220px; padding: 8px 0 0; border-bottom: 1px solid var(--line); }
.hb { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; }
.hb-bar { width: 100%; max-width: 38px; min-height: 2px; background: #93c5fd; border-radius: 6px 6px 0 0; }
.hb-bar.peak { background: var(--primary); }
.hb-amt { font-size: 11px; color: var(--muted); }
.hb-h { font-size: 12px; color: var(--muted); padding-bottom: 4px; }
table.heat { border-collapse: separate; border-spacing: 3px; font-size: 11px; }
table.heat th { font-weight: 600; color: var(--muted); padding: 2px 4px; }
table.heat td { min-width: 34px; height: 28px; text-align: center; border-radius: 6px; border: 1px solid var(--line); }

/* ---------- จอครัว ---------- */
body.kitchen-mode .view { max-width: none; }
.kds { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; align-items: start; }
.kds-card { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px; border-top: 6px solid var(--primary); display: grid; gap: 8px; }
.kds-card.qr { border-top-color: #7c3aed; }
.kds-card.late { border-top-color: var(--red); background: #fff7f7; }
.kds-head { display: flex; justify-content: space-between; align-items: baseline; }
.kds-head b { font-size: 22px; }
.kds-head span { font-weight: 700; color: var(--muted); }
.kds-card.late .kds-head span { color: var(--red); }
.kds-src { font-size: 13px; color: var(--muted); }
.kds-lines { font-size: 18px; display: grid; gap: 4px; }
.kds-note { font-size: 15px; font-weight: 700; color: var(--amber); padding-left: 22px; }

/* ---------- หน้าลูกค้าสั่งอาหาร ---------- */
/* หน้าเต็มจอ: ส่วนบน (ร้าน/แท็บ/หมวด) และส่วนล่าง (ปุ่มเรียกพนักงาน/เช็คบิล) อยู่กับที่ เลื่อนได้เฉพาะรายการเมนู */
body.cust {
  background: var(--bg); height: 100vh; height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column;
}
body.cust .cust-head, body.cust .cust-tabs { flex-shrink: 0; }
body.cust .cust-tabs { position: relative; box-shadow: 0 4px 10px -6px rgba(15, 23, 42, .25); z-index: 5; }
body.cust .cust-tabs .chips { position: relative; scrollbar-width: none; }
body.cust .cust-tabs .chips::-webkit-scrollbar { display: none; }
body.cust .cust-main {
  flex: 1; min-height: 0; width: 100%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding-bottom: 90px; /* เผื่อพื้นที่ให้แถบตะกร้าที่ลอยอยู่ */
}
body.cust .cust-dock { position: relative; flex-shrink: 0; }
.cust-table { flex-shrink: 0; background: var(--primary); color: #fff; font-weight: 700; font-size: 17px; padding: 6px 14px; border-radius: 999px; }
/* แถบปุ่มใหญ่ด้านล่าง: เรียกพนักงาน / เช็คบิล */
.cust-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 36; display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--card); box-shadow: 0 -6px 24px rgba(15, 23, 42, .14);
}
.dock-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 62px; padding: 8px 10px;
  border: 0; border-radius: 16px; color: #fff; font: inherit; font-size: 18px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .18); -webkit-tap-highlight-color: transparent; transition: transform .06s;
}
.dock-btn:active { transform: scale(.97); }
.dock-btn.staff { background: #b45309; }
.dock-btn.bill { background: #15803d; }
.dock-btn.sent { animation: dockPulse 1.4s infinite; }
.dock-ic { font-size: 26px; line-height: 1; }
.dock-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; text-align: left; }
.dock-txt small { font-size: 13px; font-weight: 500; opacity: .92; }
@keyframes dockPulse { 50% { box-shadow: 0 0 0 6px rgba(21, 128, 61, .25); } }
.dock-btn.staff.sent { animation-name: dockPulseAmber; }
/* ป๊อปอัป "พนักงานรับทราบแล้ว" */
.ack-pop { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(15, 23, 42, .5); }
.ack-pop[hidden] { display: none; }
.ack-card { width: min(340px, 100%); background: #fff; border-radius: 22px; padding: 26px 22px 20px; text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); animation: ackIn .35s cubic-bezier(.2, 1.4, .4, 1); }
.ack-icon { font-size: 64px; line-height: 1; }
.ack-title { font-size: 24px; font-weight: 700; color: var(--green); margin: 10px 0 6px; }
.ack-msg { font-size: 17px; color: var(--text); margin-bottom: 18px; line-height: 1.5; }
@keyframes ackIn { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes dockPulseAmber { 50% { box-shadow: 0 0 0 6px rgba(180, 83, 9, .25); } }
.cust-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.cust-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; }
.cust-tabs { background: var(--bg); padding: 10px 16px 8px; display: grid; gap: 8px; }
.cust-tabs .seg button { padding: 9px; font-size: 15px; }
.cust-main { padding: 4px 16px 16px; max-width: 720px; margin: 0 auto; }
.cust-cat { margin: 18px 0 8px; font-size: 17px; }
.cust-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 10px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 10px; }
.cust-item.soldout { opacity: .5; }
.cust-item.soldout .cust-img img { filter: grayscale(1); }
.cust-img { flex-shrink: 0; width: 92px; height: 92px; padding: 0; border: 0; border-radius: 12px; overflow: hidden; cursor: pointer; background: linear-gradient(135deg, #fef3c7, #fde68a); }
.cust-img img, .item-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cust-img .ph, .item-photo .ph { display: grid; place-items: center; width: 100%; height: 100%; font-size: 40px; }
.cust-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; text-align: left; border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: inherit; }
.cust-desc { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-photo { width: 100%; aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: linear-gradient(135deg, #fef3c7, #fde68a); }
.item-photo .ph { font-size: 80px; }
.stepper.big button { width: 48px; height: 48px; font-size: 24px; }
.stepper.big span { min-width: 48px; font-size: 20px; }
.cust-name { font-weight: 600; }
/* รูปสินค้า: หน้า POS และรายการสินค้า */
.pos-grid { align-items: start; } /* ไม่ยืดการ์ดที่ไม่มีรูปให้สูงเท่าการ์ดที่มีรูป */
.tile.has-img { padding: 0 0 10px; overflow: hidden; }
.tile.has-img .tile-name, .tile.has-img .tile-foot { padding: 0 10px; }
.tile-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.thumb.ph { display: grid; place-items: center; background: var(--bg); font-size: 18px; }
.img-field { display: flex; gap: 14px; align-items: flex-start; }
.img-preview { width: 120px; height: 120px; flex-shrink: 0; border-radius: 12px; overflow: hidden; border: 1px dashed #cbd5e1; display: grid; place-items: center; font-size: 40px; background: var(--bg); }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.cust-price { color: var(--primary); }
.add-btn { width: 40px; height: 40px; border-radius: 999px; border: 0; background: var(--primary); color: #fff; font-size: 24px; cursor: pointer; flex-shrink: 0; }
.cust-bar {
  display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(94px + env(safe-area-inset-bottom)); z-index: 35; max-width: 696px; margin: 0 auto;
  align-items: center; gap: 12px; padding: 14px 18px; border: 0; border-radius: 14px; background: var(--primary); color: #fff;
  font-size: 16px; box-shadow: 0 8px 24px rgba(29, 78, 216, .4); cursor: pointer;
}
.cust-bar[hidden] { display: none; }
/* อยู่เหนือแถบปุ่มเรียกพนักงาน/เช็คบิล (ต้องชนะกฎ .pos-bar ของจอมือถือที่อยู่ด้านล่างไฟล์) */
body.cust .cust-bar { bottom: calc(94px + env(safe-area-inset-bottom)); }
.cust-bar b { font-size: 18px; }
body.cust .modal-bg { align-items: flex-end; padding: 0; }
body.cust .modal { border-radius: 18px 18px 0 0; max-height: 90vh; }
body.cust .modal footer { display: block; }
/* หน้าต่างของลูกค้า: ปุ่มด้านล่าง (เช่น ยืนยัน) มองเห็นตลอด เลื่อนเฉพาะเนื้อหา */
body.cust .modal { display: flex; flex-direction: column; overflow: hidden; }
body.cust .modal .body { overflow-y: auto; min-height: 0; flex: 1; overscroll-behavior: contain; }
body.cust .modal header, body.cust .modal footer { flex-shrink: 0; }
/* ไม่ให้แถบชิป (หมายเหตุด่วน) ดันความกว้างจนล้นหน้าต่าง — ชิปเลื่อนซ้ายขวาในแถวของตัวเองแทน */
body.cust .modal .body { overflow-x: hidden; }
body.cust .modal .body > *, body.cust .cart-line > * { min-width: 0; }
body.cust .cart-line .stepper, body.cust .cart-line .cl-amt { flex-shrink: 0; }
/* หน้าต่างกลางจอ (เช่น เช็คบิล) */
body.cust .modal-bg.mid { align-items: center; padding: 16px; }
body.cust .modal-bg.mid .modal { border-radius: 20px; width: min(440px, 100%); max-height: 88vh; animation: ackIn .25s ease-out; }
body.cust .modal-bg.mid header h3 { font-size: 22px; font-weight: 800; }
/* หน้าเช็คบิล */
.bill-head { text-align: center; padding: 6px 0 12px; border-bottom: 2px dashed var(--line); }
.bill-label { font-size: 15px; font-weight: 700; color: var(--muted); }
.bill-amt { font-size: 40px; font-weight: 800; color: var(--primary); line-height: 1.15; }
.bill-lines { display: grid; gap: 2px; }
.bill-line { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 17px; text-align: left; }
.bl-name { flex: 1; min-width: 0; }
.bl-name small { display: block; font-size: 13px; color: #6d28d9; }
.bl-amt { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pay-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pay-pick .bill-label { grid-column: 1 / -1; }
.pay-pick label { display: flex; }
.pay-pick input { position: absolute; opacity: 0; pointer-events: none; }
.pay-pick span { flex: 1; text-align: center; padding: 12px 6px; border: 2px solid var(--line); border-radius: 12px; font-weight: 700; font-size: 16px; cursor: pointer; }
.pay-pick input:checked + span { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.scan-box { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px; border: 2px solid var(--primary-100); border-radius: 16px; background: #fff; text-align: center; }
.scan-box svg, .scan-box img { display: block; max-width: 100%; height: auto; }
.scan-amt { font-size: 28px; font-weight: 800; color: var(--primary); }
/* ส่งออเดอร์แล้ว */
.sent-ok { text-align: center; padding: 8px 0; }
.sent-ic { font-size: 64px; line-height: 1; }
.sent-ok p { margin: 10px 0 0; font-size: 19px; }
/* จอครัว: รายการเสร็จล่าสุด */
.done-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.done-main { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; }
.done-time { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; }
.stale-box { margin-top: 16px; padding: 10px 14px; border: 1px dashed #fcd34d; border-radius: 12px; background: var(--amber-50); }
.stale-box summary { cursor: pointer; font-weight: 700; color: var(--amber); }
.pay-total { font-size: 36px; font-weight: 700; text-align: center; color: var(--primary); }
.method-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.method { padding: 12px 4px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 600; font-size: 14px; }
.method.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.input.big { font-size: 24px; text-align: right; font-weight: 700; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick .btn { flex: 1; justify-content: center; }
.change { display: flex; justify-content: space-between; font-size: 18px; padding: 8px 12px; background: var(--green-50); border-radius: 8px; }
.change b { color: var(--green); }

@media (max-width: 900px) {
  .pos { grid-template-columns: minmax(0, 1fr); padding-bottom: 70px; }
  .pos-search { top: 57px; }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .pos-cart { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 40; max-height: 88vh; border-radius: 18px 18px 0 0; transform: translateY(105%); transition: transform .22s; box-shadow: 0 -10px 40px rgba(0, 0, 0, .2); }
  .pos.cart-open .pos-cart { transform: none; }
  .cart-close { display: inline-flex; }
  .pos-bar {
    display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 35;
    align-items: center; gap: 12px; padding: 14px 18px; border: 0; border-radius: 14px; background: var(--primary); color: #fff;
    font-size: 16px; box-shadow: 0 8px 24px rgba(29, 78, 216, .4); cursor: pointer;
  }
  .pos-bar[hidden] { display: none; }
  .pos-bar b { font-size: 18px; }
  .pos-bar-go { margin-left: auto; font-weight: 600; }
  .method-row { grid-template-columns: repeat(2, 1fr); }
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; }
}

/* ---------- slip (80mm) ---------- */
.slip-wrap { display: flex; justify-content: center; }
.slip { width: 76mm; background: #fff; color: #000; padding: 4mm; font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow); }
.modal .slip { box-shadow: none; border: 1px dashed #cbd5e1; }
.slip-logo { display: block; max-height: 40px; max-width: 50%; margin: 0 auto 4px; }
.slip-c { text-align: center; }
.slip-title { text-align: center; font-weight: 700; margin: 6px 0; }
.slip-row { display: flex; justify-content: space-between; gap: 8px; }
.slip-total { font-weight: 700; font-size: 15px; }
.slip-hr { border-top: 1px dashed #000; margin: 5px 0; }

@media print {
  .slip { box-shadow: none; width: 72mm; padding: 0; }
  .slip-wrap { justify-content: flex-start; }
  .pos-bar, .modal-bg { display: none !important; }
  body.print-area .app, body.print-area #modalRoot, body.print-area #auth { display: none !important; }
  body.print-area #printArea { display: block; }

  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .toast, .scrim { display: none !important; }
  .view { padding: 0; max-width: none; }
  .paper { box-shadow: none; margin: 0; width: auto; min-height: auto; }
  .paper th, .paper .sum .words { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- หน้าต่างป๊อปอัป: อยู่กึ่งกลางจอเสมอ (คอม/มือถือ/หน้าลูกค้า) — หัวและปุ่มล่างอยู่กับที่ เลื่อนเฉพาะเนื้อหา */
.modal-bg, body.cust .modal-bg {
  align-items: center; justify-content: center; padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.modal, body.cust .modal {
  display: flex; flex-direction: column; overflow: hidden; border-radius: 18px;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); animation: modalIn .18s ease-out;
}
.modal > .body { overflow-y: auto; min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; }
.modal > header, .modal > footer { flex-shrink: 0; }
@keyframes modalIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
/* ปุ่มปิด ✕ สีแดงเด่นชัด */
.modal header [data-close], .icon-btn.cart-close {
  width: 40px; height: 40px; padding: 0; border-radius: 50%; border: 0; flex-shrink: 0; margin-left: 8px;
  background: var(--red, #dc2626); color: #fff; font-size: 19px; font-weight: 800; line-height: 1;
  align-items: center; justify-content: center; box-shadow: 0 3px 10px rgba(220, 38, 38, .35); cursor: pointer;
}
.modal header [data-close] { display: inline-flex; }
.modal header [data-close]:hover, .icon-btn.cart-close:hover { background: #b91c1c; }

/* ---------- แจ้งเตือนสินค้าใกล้หมด */
.low-bell {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 6px 12px; border-radius: 999px;
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; font-size: 14px; font-weight: 700; white-space: nowrap; text-decoration: none;
}
.low-bell b { background: #dc2626; color: #fff; border-radius: 999px; padding: 0 7px; font-size: 13px; }
.low-bell[hidden] { display: none; }
.low-bell + .net-status { margin-left: 8px; }
.stock-alert {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 70; width: min(420px, calc(100% - 32px));
  background: #fff; border: 2px solid #fca5a5; border-radius: 16px; box-shadow: 0 16px 40px rgba(0, 0, 0, .2); padding: 14px 16px; animation: saIn .25s ease-out;
}
.stock-alert .sa-head { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 800; color: #b91c1c; }
.stock-alert .sa-head span { flex: 1; }
.stock-alert .sa-x { width: 32px; height: 32px; border-radius: 50%; border: 0; background: #dc2626; color: #fff; font-weight: 800; cursor: pointer; }
.stock-alert ul { margin: 8px 0 10px; padding: 0; list-style: none; display: grid; gap: 4px; max-height: 40vh; overflow-y: auto; }
.stock-alert li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.stock-alert li b.out { color: #b91c1c; }
.stock-alert li b.low { color: #b45309; }
.adj-done { padding: 10px 12px; border-radius: 10px; background: var(--green-50, #ecfdf5); color: var(--green, #047857); font-weight: 700; }@keyframes saIn { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- ภาพรวม: เลือกช่วงเวลา / สรุปยอด / ยอดขายตามสินค้า */
.period-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.period-seg { max-width: 100%; overflow-x: auto; flex-shrink: 1; }
.period-seg button { padding: 8px 14px; font-size: 14px; }
.sum-list { display: grid; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.sum-row b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.sum-row.big { font-size: 15px; }
.sum-row.big b { font-size: 18px; color: #2563eb; }
.sum-row.big.exp b { color: #dc2626; }
.sum-row.ok b { color: var(--green, #047857); }
.sum-row.warn b { color: #b45309; }
.prod-sales { display: grid; gap: 2px; margin-top: 10px; }
.ps-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.ps-row[hidden] { display: none; }
.ps-rank { width: 24px; height: 24px; border-radius: 50%; background: #eff6ff; color: #2563eb; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ps-main { flex: 1; min-width: 0; }
.ps-name { display: flex; gap: 8px; align-items: baseline; }
.ps-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-name span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.ps-bar { height: 6px; background: #eff6ff; border-radius: 99px; margin-top: 4px; overflow: hidden; }
.ps-bar i { display: block; height: 100%; background: #2563eb; border-radius: 99px; }
.ps-amt { text-align: right; display: flex; flex-direction: column; flex-shrink: 0; }
.ps-amt b { font-variant-numeric: tabular-nums; }
.ps-amt small { color: var(--muted); font-size: 12px; }.grid-dash.dash-top { align-items: start; }

/* ---------- กราฟแท่งแนวนอน รายได้ (ฟ้า) / ค่าใช้จ่าย (แดง) + กล่องข้อมูลเมื่อชี้ */
.hbar { position: relative; --lab: 92px; padding-top: 8px; }
.hbar-grid { position: absolute; top: 8px; bottom: 26px; left: calc(var(--lab) + 8px); right: 44px; pointer-events: none; }
.hbar-grid i { position: absolute; top: 0; bottom: 0; border-left: 1px dashed #e2e8f0; }
.hbar-row { position: relative; display: flex; align-items: center; gap: 8px; padding: 4px 0; border-radius: 8px; cursor: pointer; outline: none; }
.hbar-row:hover, .hbar-row.on, .hbar-row:focus-visible { background: #f1f5f9; }
.hbar-label { width: var(--lab); flex-shrink: 0; text-align: right; font-size: 13px; color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 2px; }
.hbar-bars { flex: 1; min-width: 0; display: grid; gap: 3px; margin-right: 44px; }
.hbar-line { display: flex; align-items: center; gap: 6px; height: 11px; }
.hbar-line i { display: block; height: 100%; border-radius: 0 6px 6px 0; transition: width .3s; flex-shrink: 0; }
.hbar-line i.inc { background: #2563eb; }
.hbar-line i.exp { background: #dc2626; }
.hbar-line em { font-style: normal; font-size: 11px; color: #64748b; white-space: nowrap; margin-right: -44px; }
.hbar.dense .hbar-row { padding: 2px 0; }
.hbar.dense .hbar-line { height: 7px; }
.hbar.dense .hbar-line em { font-size: 10px; }
.hbar-axis { display: flex; gap: 8px; margin-top: 6px; height: 18px; }
.hbar-axis > span { width: var(--lab); flex-shrink: 0; }
.hbar-axis > div { position: relative; flex: 1; margin-right: 44px; }
.hbar-axis b { position: absolute; transform: translateX(-50%); font-size: 11px; font-weight: 400; color: #94a3b8; white-space: nowrap; }
.chart-tip {
  position: absolute; right: 8px; z-index: 5; min-width: 210px; padding: 10px 12px; border-radius: 12px; pointer-events: none;
  background: #0f172a; color: #fff; box-shadow: 0 10px 30px rgba(15, 23, 42, .35); font-size: 13px;
}
.chart-tip .tip-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.chart-tip .tip-row { display: flex; justify-content: space-between; gap: 14px; }
.chart-tip .tip-row span { display: inline-flex; align-items: center; gap: 6px; }
.chart-tip .tip-row i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-tip .tip-row b { font-variant-numeric: tabular-nums; }
.chart-tip .tip-sub { color: #94a3b8; font-size: 11px; margin: 0 0 4px 16px; }
.chart-tip .total { border-top: 1px solid #334155; margin-top: 4px; padding-top: 6px; }
.chart-tip .pos { color: #4ade80; }
.chart-tip .neg { color: #f87171; }
@media (max-width: 600px) { .hbar { --lab: 64px; } .hbar-label { font-size: 12px; } }.chart-tip { width: 250px; min-width: 0; }
.chart-tip .tip-row span { white-space: nowrap; }

/* ---------- กราฟเส้น รายได้ (ฟ้า) / ค่าใช้จ่าย (แดง) */
.lc { position: relative; }
.lc svg { width: 100%; height: auto; display: block; overflow: visible; }
.lc .lc-hit { cursor: crosshair; }
.lc .chart-tip { right: auto; transition: left .08s, top .08s; }.lc .chart-tip { transition: none; }

/* ---------- ภาพรวม: กราฟเต็มความกว้าง + เต็มจอ + เลือกปี/ช่วงเอง */
.period-year { width: auto; padding: 7px 10px; font-size: 14px; }
.period-year.active, .period-custom.active { border-color: var(--primary); background: var(--primary-50, #eff6ff); color: var(--primary); font-weight: 700; }
.period-text { margin-left: auto; }
.custom-range { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: -6px 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.custom-range[hidden] { display: none; }
.custom-range label { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.custom-range .input { width: auto; }
.chart-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 8px; }
.chart-card .chart { width: 100%; }
.chart-card .lc svg { width: 100%; height: auto; }
.grid-dash3 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .grid-dash3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .grid-dash3 > :last-child { grid-column: 1 / -1; } }
@media (max-width: 700px) { .grid-dash3 { grid-template-columns: 1fr; } .period-text { margin-left: 0; width: 100%; } }
/* เต็มจอ (Fullscreen API) หรือเต็มหน้าต่าง (iPhone) */
.chart-card:fullscreen, .chart-card.fs { display: flex; flex-direction: column; margin: 0 !important; padding: 20px 24px; border-radius: 0; background: #fff; }
.chart-card.fs { position: fixed; inset: 0; z-index: 90; padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.chart-card:fullscreen .chart, .chart-card.fs .chart { flex: 1; min-height: 0; position: relative; }
.chart-card:fullscreen .lc, .chart-card.fs .lc { position: absolute; inset: 0; }
.chart-card:fullscreen .chart-head h3, .chart-card.fs .chart-head h3 { font-size: 20px; }
.chart-card:fullscreen .legend, .chart-card.fs .legend { font-size: 15px; }
body.chart-fs-open { overflow: hidden; }.period-bar .input.period-year { width: auto; flex: 0 0 auto; min-width: 130px; }
@media (max-width: 1360px) { .grid-dash3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .grid-dash3 > :last-child { grid-column: 1 / -1; } }
@media (max-width: 700px) { .grid-dash3 { grid-template-columns: 1fr; } }

/* กะ: นำเงินออก → ค่าใช้จ่าย */
.exp-opt { display: grid; gap: 8px; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; background: #f8fafc; }
.exp-opt[hidden], .exp-opt [hidden] { display: none; }
.moves-list { margin-top: 8px; font-size: 14px; display: grid; gap: 4px; }
.move-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }

/* POS รายละเอียดโต๊ะ: สถานะเสิร์ฟต่อรายการ */
.serve { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.serve.ok { background: #dcfce7; color: #15803d; }
.serve.ok b { font-weight: 800; }
.serve.part { background: #ecfdf5; color: #047857; border: 1px dashed #86efac; }
.serve.cook { background: #fef3c7; color: #b45309; }
.serve.wait { background: #f1f5f9; color: #64748b; }
.bill-lines-t td { vertical-align: middle; }
.modal .bill-lines-t + .action-grid, .modal .table-wrap ~ .action-grid { margin-top: 4px; }
.tflag.draft { background: #ede9fe; color: #6d28d9; border-color: #c4b5fd; }
.serve.sent { background: #dbeafe; color: #1d4ed8; }
.serve.sent b { font-weight: 800; }

/* หน้าลูกค้า: เมนูที่สั่งแล้ว + สถานะอาหารในแถวเดียวกัน */
.mine-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.mine-name { flex: 1; min-width: 0; font-size: 15px; }
.mine-amt { flex-shrink: 0; min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; }
.cserve { flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.cserve.ok { background: #16a34a; color: #fff; }
.cserve.ok b { font-weight: 800; }
.cserve.ok.part { background: #dcfce7; color: #15803d; }
.cserve.cook { background: #fef3c7; color: #b45309; }
.cserve.wait { background: #f1f5f9; color: #64748b; }
@media (max-width: 380px) { .cserve { font-size: 12px; padding: 3px 8px; } }
.action-btn.cancel-t { background: #7f1d1d; }
.modal .action-grid { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 7px; }
.modal .action-btn b { font-size: 16px; }

/* ยกเลิกโต๊ะไม่ได้เพราะมียอดค้างชำระ */
.cancel-block { text-align: center; display: grid; gap: 6px; padding: 6px 0; }
.cancel-block .cb-ic { font-size: 48px; line-height: 1; }
.cancel-block > b { font-size: 20px; color: #b91c1c; }
.cancel-block p { margin: 0; font-size: 16px; line-height: 1.6; }
.cancel-block .cb-amt { color: #b91c1c; font-size: 20px; }
/* จอครัว: เครื่องดื่มเสิร์ฟก่อน */
.drink-bar { margin-bottom: 14px; padding: 12px 14px; border-radius: 14px; background: #eff6ff; border: 2px solid #93c5fd; }
.drink-head { font-size: 17px; font-weight: 800; color: #1d4ed8; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.drink-head .count { background: #1d4ed8; color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 14px; }
.drink-list { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.drink-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: #fff; border: 1px solid #bfdbfe; }
.drink-item.late { border-color: #f87171; background: #fef2f2; }
.di-table { font-weight: 800; white-space: nowrap; }
.di-name { flex: 1; min-width: 0; }
.di-name small { display: block; color: var(--amber); }
.di-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.kds-lines .kds-drink { background: #eff6ff; border-radius: 8px; padding: 4px 6px; margin: 0 -6px; color: #1e3a8a; }
.kds-dtag { margin-right: 4px; }
.kds-lines .kds-served { opacity: .55; text-decoration: line-through; }
.kds-lines .kds-served .badge { text-decoration: none; }
.kds-lines .btn.sm { padding: 2px 8px; margin-left: 4px; }
/* นำเข้าคำสั่งซื้อ Shopee */
.shopee-steps { margin: 0; padding-left: 20px; font-size: 14px; display: grid; gap: 2px; }
.shopee-paste { font-family: inherit; font-size: 14px; resize: vertical; min-height: 200px; }
.shopee-warn { margin: 0; background: #fffbeb; border-color: #fcd34d; color: #92400e; font-size: 14px; }
.shopee-dup { margin: 0; background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.shopee-items .input { padding: 6px 8px; }
.shopee-items .num { text-align: right; }
.shopee-sum { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: flex-end; }
.shopee-sum label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.shopee-sum .input { width: 150px; text-align: right; }
.sp-total { display: grid; justify-items: end; min-width: 200px; }
.sp-total span { font-size: 13px; color: var(--muted); }
.sp-total b { font-size: 24px; color: #dc2626; }
.sp-total small.ok { color: var(--green, #047857); font-weight: 600; }
.sp-total small.bad { color: #b45309; font-weight: 600; }.shopee-drop { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; border: 2px dashed #93c5fd; border-radius: 14px; background: #eff6ff; outline: none; }
.shopee-drop:focus, .shopee-drop.over { border-color: #2563eb; background: #dbeafe; }
.shopee-drop .sd-ic { font-size: 30px; }
.shopee-drop small { display: block; margin-top: 2px; }
.sd-pick { color: #1d4ed8; font-weight: 700; text-decoration: underline; cursor: pointer; }
.sd-prog { width: 100%; display: grid; gap: 4px; font-size: 13px; color: #1d4ed8; }
.sd-bar { height: 8px; background: #fff; border-radius: 99px; overflow: hidden; }
.sd-bar i { display: block; height: 100%; width: 0; background: #2563eb; transition: width .2s; }
.shopee-or { font-size: 13px; color: var(--muted); }