[hidden] { display: none !important; }
:root {
  --bg: #f4f6f8; --card: #fff; --ink: #0f172a; --muted: #475569; --line: #e2e8f0;
  --brand: #0f766e; --brand-ink: #fff; --brand-soft: #ccfbf1; --brand-deep: #115e59; --warn: #b45309; --bad: #b91c1c; --ok: #15803d;
  --radius: 14px; --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Sarabun", "Noto Sans Thai", system-ui, sans-serif; font-size: 16px; line-height: 1.45;
  background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; font-size: 16px; } /* >=16px: iOS won't zoom */
button { cursor: pointer; border: 0; border-radius: 10px; min-height: 44px; padding: 0 14px; background: #e2e8f0; color: var(--ink); }
button.primary { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
button.danger { background: #fee2e2; color: var(--bad); }
button.ghost { background: transparent; color: var(--brand); }
button:disabled { opacity: .45; }
input, select { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: var(--ink); }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 18px; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 14px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.topbar { position: sticky; top: 0; z-index: 5; background: var(--brand); color: #fff; padding: 10px 16px; }
.topbar .row { justify-content: space-between; }
.topbar h1 { font-size: 18px; }
.chip { background: rgba(255,255,255,.18); color: #fff; border-radius: 999px; padding: 4px 12px; min-height: 44px; font-size: 14px; white-space: nowrap; display: inline-flex; align-items: center; }
.tabs { display: flex; gap: 4px; margin-top: 8px; }
.tabs button { flex: 1; background: rgba(255,255,255,.12); color: #fff; min-height: 40px; }
.tabs button[aria-selected="true"] { background: #fff; color: var(--brand); font-weight: 600; }

.tile-img { display: grid; place-items: center; width: 100%; aspect-ratio: 1; border-radius: 10px; color: #fff; font-weight: 700; font-size: 20px; background-size: cover; background-position: center; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick button { display: flex; flex-direction: column; gap: 4px; padding: 6px; height: auto; background: var(--card); font-size: 13px; line-height: 1.2; box-shadow: 0 1px 2px rgba(15,23,42,.08); }
.quick button b { font-size: 14px; color: var(--brand); }

.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-line:last-child { border-bottom: 0; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { min-width: 44px; padding: 0; font-size: 20px; }
.qty span { min-width: 28px; text-align: center; font-weight: 600; }
.unit-toggle { min-height: 32px; font-size: 13px; padding: 0 10px; background: var(--brand-soft); color: var(--brand); }

.paybar { position: sticky; bottom: 0; z-index: 4; background: var(--card); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + var(--safe-b)); }
.paybar .total { font-size: 26px; font-weight: 700; }
.big-change { font-size: 44px; font-weight: 700; color: var(--ok); text-align: center; }
.cash-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cash-btns button { min-height: 52px; font-weight: 600; }

.sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(15,23,42,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; } }
.sheet .actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet .actions button { flex: 1; }
.qr { width: 240px; margin: 8px auto; }
.photo-prev { width: 96px; height: 96px; border-radius: 10px; object-fit: cover; background: #e2e8f0; }

.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); z-index: 30; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; max-width: 90vw; }
.toast.bad { background: var(--bad); }
.badge { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: 13px; background: #e2e8f0; color: var(--ink); }
.badge.warn { background: #fef3c7; color: var(--warn); }
.badge.bad { background: #fee2e2; color: var(--bad); }
.badge.ok { background: #dcfce7; color: var(--ok); }
.list > * + * { border-top: 1px solid var(--line); }
.list > * { padding: 10px 0; }
.search-results { margin-top: 6px; }
.search-results button { width: 100%; display: flex; justify-content: space-between; background: #fff; border: 1px solid var(--line); margin-top: 4px; text-align: left; }
video.scanner { width: 100%; border-radius: 10px; background: #000; max-height: 50vh; object-fit: cover; }

/* ---------- round 2: category boxes (2 columns, thumb-sized) ---------- */
.scanrow { margin-bottom: 6px; }
.crumbs { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; flex-wrap: wrap; }
.crumbs nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; min-width: 0; }
.crumbs nav button { background: none; min-height: 40px; padding: 0 6px; color: var(--brand); font-weight: 600; }
.crumbs nav span { color: var(--muted); }
.crumbs .back { background: var(--brand); color: #fff; font-weight: 600; min-height: 48px; padding: 0 16px; }
.boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 700px) { .boxes { grid-template-columns: repeat(4, 1fr); } }
.boxes .sect { grid-column: 1 / -1; font-size: 15px; color: var(--muted); margin: 6px 0 -2px; }
.box { position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; gap: 2px;
  min-height: 112px; padding: 12px; text-align: left; border-radius: 16px; background: var(--card); color: var(--ink);
  box-shadow: 0 1px 3px rgba(15,23,42,.10); overflow: hidden; line-height: 1.25; }
.box b { font-size: 17px; }
.box small { color: var(--muted); font-size: 13px; }
.box.cat { background: var(--c); color: #fff; }
.box.cat small { color: rgba(255,255,255,.9); }
.box.cat .ic { position: absolute; top: 10px; right: 12px; font-size: 22px; opacity: .85; }
.box.prod { border-left: 8px solid var(--c); }
.box.prod .price { font-size: 20px; font-weight: 700; color: var(--brand); }
.box.prod .ph { position: absolute; inset: 0 0 auto auto; width: 56px; height: 56px; border-radius: 0 0 0 12px; background-size: cover; background-position: center; }
.box .n { position: absolute; top: 8px; right: 8px; min-width: 30px; height: 30px; border-radius: 999px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; padding: 0 6px; }
.box.prod .ph ~ .n { right: 64px; }
.box.add { background: transparent; border: 2px dashed #94a3b8; color: var(--muted); box-shadow: none; justify-content: center; align-items: center; text-align: center; font-weight: 600; min-height: 72px; }
.stockmode .box.prod { border-left-color: #b45309; }
.stockmode .topbar { background: #92400e; }

.paybar { display: flex; gap: 10px; align-items: stretch; }
.billbtn { flex: 1; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; background: #f1f5f9; min-height: 60px; text-align: left; }
.billbtn b { font-size: 24px; }
.paybtn { min-height: 60px; min-width: 42%; font-size: 20px; }
.stockmode .paybtn { background: #b45309; }
.paytabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.paytabs button[aria-selected="true"] { background: var(--brand); color: #fff; font-weight: 600; }
.cash-btns .primary { grid-column: span 3; min-height: 56px; font-size: 18px; }
.qty input { width: 64px; text-align: center; min-height: 44px; padding: 4px; }
.sum { border-top: 2px solid var(--line); margin-top: 6px; padding-top: 8px; }
.receipt { font-size: 14px; line-height: 1.5; }
.receipt h3 { text-align: center; margin: 10px 0 2px; font-size: 16px; }
.receipt .lines, .receipt .buyer { border-top: 1px dashed #94a3b8; border-bottom: 1px dashed #94a3b8; padding: 6px 0; margin: 6px 0; }
.staff .paybar { position: fixed; left: 0; right: 0; bottom: 0; }
.staff main { padding-bottom: calc(100px + var(--safe-b)) !important; }
/* product photo on top, name + price under it */
.box.prod.has-ph { padding: 0 0 10px; border-left: 0; justify-content: flex-start; }
.box.prod.has-ph .ph { position: static; display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 0; margin-bottom: 6px; }
.box.prod.has-ph > b, .box.prod.has-ph > .price, .box.prod.has-ph > small { padding: 0 12px; }
.box.prod.has-ph .n { right: 8px; box-shadow: 0 0 0 3px #fff; }
.stockmode .box.prod.has-ph { outline: 3px solid #b45309; outline-offset: -3px; }

/* ---------- round 3: Claude Design (claude.ai/artifact/6K4eJZMowMpiVbuDaTKAQp) ---------- */
:root { --bg: #f5f3ee; --ink: #1c1917; --muted: #57534e; --line: #e7e5e4; --gold: #fbbf24; }
h1, h2, .box b, .box .price, .billbtn b, .paybtn, .big-change, .kpi b, .cash-btns button { font-family: "Prompt", "Sarabun", sans-serif; }
.topbar { padding: 14px 16px 12px; }
.topbar h1 { font-size: 20px; font-weight: 600; }
.topbar .sub { font-size: 14px; color: var(--brand-soft); }
#who { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px 0 6px; background: var(--brand-deep); font-size: 15px; }
#who .av { width: 32px; height: 32px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-deep); display: grid; place-items: center; font-weight: 700; }
.scanrow input { min-height: 52px; border-radius: 14px; border: 2px solid var(--brand); font-size: 17px; }
#cam { width: 52px; min-height: 52px; padding: 0; border-radius: 14px; background: var(--gold); color: var(--ink); display: grid; place-items: center; }
.crumbs .back { background: #e7e5e4; color: var(--ink); min-height: 44px; border-radius: 12px; }
.crumbs nav button { color: var(--muted); font-weight: 400; }
.crumbs nav button:last-child { color: var(--ink); font-weight: 700; }
.box { border-radius: 18px; }
.box.cat { background: #fff; color: var(--ink); border: 2px solid var(--c); justify-content: space-between; min-height: 104px; }
.box.cat .ic { position: static; color: var(--c); opacity: 1; }
.box.cat b { font-size: 19px; font-weight: 600; }
.box.cat small { color: var(--muted); }
.box.prod:not(.has-ph) { background: var(--c); color: #fff; border-left: 0; justify-content: space-between; min-height: 128px; }
.box.prod:not(.has-ph) .price { color: #fff; font-size: 24px; }
.box.prod:not(.has-ph) small { color: rgba(255,255,255,.92); }
.box.prod b { font-size: 18px; font-weight: 600; }
.box.prod.has-ph .price { font-size: 22px; }
.box .n { background: var(--gold); color: var(--ink); box-shadow: 0 0 0 3px #fff; }
.box.add { border-color: #a8a29e; border-radius: 18px; }
.stockmode .topbar { background: var(--brand); }
.stockmode .paybtn { background: var(--brand); }
.paybar { padding: 12px 16px calc(16px + var(--safe-b)); }
.billbtn { background: #f5f5f4; border-radius: 16px; min-height: 64px; }
.paybtn { min-height: 64px; flex: 1.2; border-radius: 16px; font-size: 22px; font-weight: 600; }
.paytabs { background: #e7e5e4; padding: 4px; border-radius: 14px; gap: 4px; }
.paytabs button { background: transparent; min-height: 48px; font-size: 17px; }
.paytabs button[aria-selected="true"] { background: #fff; color: var(--ink); font-weight: 700; }
.cash-btns { gap: 10px; }
.cash-btns button { min-height: 64px; border: 2px solid #d6d3d1; border-radius: 16px; background: #fff; font-size: 22px; font-weight: 600; }
.cash-btns .exact { background: var(--brand-soft); border-color: var(--brand); }
.change-panel { margin-top: 12px; padding: 14px; border-radius: 20px; background: var(--brand); color: #fff; text-align: center; font-weight: 600; }
.change-panel .big-change { color: #fff; font-size: 52px; line-height: 1.1; }
.change-panel.short { background: #fef3c7; color: #78350f; }
.change-panel.short .big-change { color: #78350f; }
.sheet .actions button { min-height: 56px; border-radius: 14px; }
.big-change { color: var(--brand); }
/* owner */
.owner .topbar { background: var(--ink); }
.owner .kpi { border-radius: 16px; }
.owner .kpi:first-child { background: var(--brand); color: #fff; }
.owner .kpi:first-child .muted { color: var(--brand-soft); }
.owner .card { border-radius: 18px; }
.paytotal { text-align: center; margin: 12px 0 8px; font-size: 34px; font-weight: 700; }

/* ร้านสังฆภัณฑ์: โทนจีวร (เหลือง-ส้ม) · ตัวขาวบน --brand ผ่าน 4.5:1 */
/* คู่มือ infographic ถ่ายจากร้านมินิมาร์ท ซ่อนไว้จนกว่าจะมีชุดของร้านนี้ */
:root[data-shop="sangkha"] .guide-link { display: none; }
:root[data-shop="sangkha"] { --brand: #b45309; --brand-soft: #fef3c7; --brand-deep: #78350f; --bg: #fbf6ec; --gold: #f59e0b; }

/* ลงยอดตอนว่าง: slot chips, same weight as the POS tabs */
.slots { display: flex; align-items: center; gap: 6px; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.slots button { flex: 1; min-height: 44px; white-space: nowrap; padding: 0 6px; border: 0; border-radius: 12px; background: #f5f5f4; color: var(--ink); font-weight: 600; }
.slots button[aria-pressed="true"] { background: var(--brand); color: #fff; }

/* "? ถามน้องฝาง 24 ชม." on every page, round-3 gold */
.helpbtn { position: fixed; right: 12px; bottom: 96px; z-index: 10; min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px;
  border-radius: 22px; background: #fbbf24; color: #422006; font-weight: 600; text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
/* ---------- r4 (ห้อง Designer · plans/2026-10-31_fang-saas/design-r4) · tokens map onto the names every page already uses ---------- */
:root {
  --teal-900:#0A3B37; --teal-700:#0B6E66; --teal-100:#DDF1EE;
  --sun-400:#F6B826; --sun-100:#FFF1CC; --sun-ink:#8A5A00;
  --ground:#FBF8F1; --card:#FFFFFF; --line:#E6E1D6; --muted:#4F6360;
  --ok:#15803D; --ok-soft:#DCF3E3; --bad:#B42318; --bad-soft:#FCE4E2;
  --bg:var(--ground); --ink:var(--teal-900); --brand:var(--teal-700); --brand-soft:var(--teal-100); --brand-deep:var(--teal-900); --gold:var(--sun-400);
  --font-head:"Prompt",sans-serif; --font-body:"Noto Sans Thai Looped",sans-serif;
  --r-card:16px; --r-btn:14px; --shadow:0 2px 8px rgba(10,59,55,.08);
}
body { font-family: var(--font-body); font-size: 17px; line-height: 1.55; background: var(--ground); color: var(--ink); }
button, input, select { font-size: 17px; }
button { border-radius: var(--r-btn); background: #EFEBE1; color: var(--ink); }
button.primary { background: var(--brand); color: #fff; }
button.ghost { background: transparent; color: var(--brand); }
input, select { border-color: var(--line); border-radius: 12px; }
.muted, label { color: var(--muted); }
.card { border-radius: var(--r-card); box-shadow: var(--shadow); }
.topbar { background: var(--brand); }
.topbar .row { flex-wrap: nowrap; }
.topbar h1 { font-family: var(--font-head); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { background: rgba(255,255,255,.16); }
/* "ถามน้องฝาง" lives in the top bar now (common.js moves it): no more floating button over content */
.helpbtn { position: static; box-shadow: none; flex: none; gap: 6px; min-height: 44px; padding: 0 12px; border-radius: var(--r-btn);
  background: var(--sun-400); color: var(--teal-900); font-size: 15px; font-weight: 600; }
.helpbtn svg { flex: none; }
@media (max-width: 420px) { .topbar .helpbtn span { display: none; } .topbar .helpbtn { padding: 0 10px; } }
/* product without a photo: a tinted box with the first syllable big, name and price under it (no fake pictures) */
.box.prod:not(.has-ph) { background: var(--card); color: var(--ink); padding: 0 0 10px; justify-content: flex-start; min-height: 0; border: 0; }
.box.prod .syl { display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; margin-bottom: 6px; background: var(--tint);
  font-family: var(--font-head); font-size: 36px; font-weight: 700; color: var(--teal-900); line-height: 1; }
.box.prod:not(.has-ph) > b, .box.prod:not(.has-ph) > .price, .box.prod:not(.has-ph) > small { padding: 0 12px; }
.box.prod:not(.has-ph) b { font-family: var(--font-body); font-size: 16px; font-weight: 500; }
.box.prod:not(.has-ph) .price, .box.prod.has-ph .price { color: var(--teal-900); font-size: 20px; font-family: var(--font-head); }
.box.prod:not(.has-ph) small { color: var(--muted); }
.box .n { background: var(--sun-400); color: var(--teal-900); }
.paybtn, .primary { font-family: var(--font-head); }
/* status = icon + word + colour, never colour alone */
.st { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 12px; font-size: 15px; font-weight: 600; }
.st.wait { background: var(--sun-100); color: var(--sun-ink); }
.st.doing { background: var(--teal-100); color: var(--teal-900); }
.st.done { background: var(--ok-soft); color: var(--ok); }
.st.off { background: var(--bad-soft); color: var(--bad); }
.ibar { display: flex; gap: 6px; flex: none; }
.ibtn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 52px; min-height: 52px; padding: 4px 6px;
  border-radius: var(--r-btn); background: rgba(255,255,255,.16); color: #fff; font-size: 14px; text-decoration: none; }
.logo { width: 36px; height: 36px; border-radius: 9px; flex: none; }
.topbar .row > h1 { flex: 1; }
.topbar .row > .helpbtn { margin-left: auto; }
.tabs { gap: 6px; margin-top: 10px; }
.tabs button { background: #fff; color: var(--ink); min-height: 48px; font-weight: 600; border: 0; }
.tabs button[aria-selected="true"] { background: var(--teal-900); color: #fff; }
.topbar .ibar .helpbtn { flex-direction: column; justify-content: center; gap: 2px; min-width: 52px; min-height: 52px; padding: 4px 8px; font-size: 14px; }
.topbar .ibar .helpbtn span { display: inline; }
.topbar .sub { color: var(--teal-100); }
.nw { white-space: nowrap; }
.tabs button { font-size: 15px; padding: 2px 4px; line-height: 1.25; }
#cam { background: var(--teal-900); color: #fff; }
.crumbs nav button { min-height: 44px; }
/* น้องฝาง panel (common.js helpPanel) */
dialog.hp { border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%; height: min(80vh, 640px); border-radius: 20px 20px 0 0;
  background: var(--ground); color: var(--ink); display: none; flex-direction: column; box-shadow: 0 -8px 30px rgba(10,59,55,.25); }
dialog.hp[open] { display: flex; }
dialog.hp::backdrop { background: rgba(10,59,55,.4); }
.hp header { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; background: var(--brand); color: #fff; font-family: var(--font-head); }
.hp .x { min-width: 44px; background: transparent; color: #fff; display: grid; place-items: center; padding: 0; }
.hp-chat { flex: 1; overflow: auto; display: grid; align-content: start; gap: 10px; padding: 14px 16px; }
.hp .msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; line-height: 1.5; }
.hp .msg.u { justify-self: end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.hp .msg.b { justify-self: start; background: #fff; border-bottom-left-radius: 4px; }
.hp .msg small { display: block; margin-top: 4px; }
.hp form { display: flex; gap: 8px; padding: 10px 16px calc(14px + var(--safe-b)); background: #fff; border-top: 1px solid var(--line); }
.hp form input { flex: 1; min-height: 48px; }
@media (min-width: 700px) {
  dialog.hp { margin: auto 24px 24px auto; width: 400px; height: min(620px, calc(100vh - 48px)); border-radius: 20px; }
}
.csvbtn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: var(--r-btn); background: var(--teal-100); color: var(--teal-900); font-weight: 600; text-decoration: none; }
/* every page: logo in the top bar goes to the fangai.app front page */
.topbar .home, .hero .home { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-right: 10px; border-radius: 10px; background: #fff; }
.topbar .home img, .hero .home img { width: 30px; height: 30px; }
.topbar .home + h1, .topbar .home + div { flex: 1; min-width: 0; }
/* sales page header: the shop name keeps its full width; the icon buttons drop to their own line when the screen is narrow */
.topbar .sellhead { flex-wrap: wrap; row-gap: 8px; }
.topbar .sellhead .name { flex: 1 1 200px; min-width: 0; }
.topbar .sellhead .ibar { margin-left: auto; }
