/* ═══════════════════════════════════════════════════════════════
 * tukteaw.css — หน้าตาร่วมของหน้าต่างทุกบาน (โครง ไม่ใช่สี)
 * ═══════════════════════════════════════════════════════════════
 * สีมาจาก /theme.css (สร้างจากบัตรตอนปั๊ม) ผ่านตัวแปร --brand --brand-dark --brand-light --brand-mid
 * ไฟล์นี้ห้ามมีสีแบรนด์ตายตัว — มีแค่ค่าสำรองกลางๆ เผื่อ theme.css หาย
 * ขนาด: ตัวหนังสือ 18px ปุ่มสูง ≥ 52px — Boomer กดถูก
 * z-index (ผังชั้น — บทเรียน 1 ก.ย.): 100 แถบบน · 900 ลิ้นชัก/กล่อง · 999 toast · 2000 รูปเต็มจอ
 * ═══════════════════════════════════════════════════════════════ */
:root {
  --brand: #5a6672; --brand-dark: #3a434c; --brand-light: #eef1f4; --brand-mid: #ccd4dc;
  --txt: #1d2126; --mid: #5f6770; --lt: #9aa3ad; --bd: #e3e7eb; --bg: #fafbfc; --card: #ffffff;
  --ok: #2e8b57; --warn: #b8860b; --bad: #c0392b;
  --r: 14px; --sh: 0 2px 10px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 18px/1.5 -apple-system, "Segoe UI", Roboto, "Noto Sans Thai", "Sarabun", sans-serif; color: var(--txt); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: var(--brand-dark); }
.hidden { display: none !important; }
.muted { color: var(--mid); font-size: 15px; }
.small { font-size: 15px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.wrap { max-width: 860px; margin: 0 auto; padding: 14px; }

/* แถบบน */
.topbar { position: sticky; top: 0; z-index: 100; background: var(--brand); color: #fff; padding: 10px 14px; display: flex; align-items: center; gap: 12px; box-shadow: var(--sh); }
.topbar .logo { width: 44px; height: 44px; border-radius: 10px; background: #fff; object-fit: cover; }
.topbar .title { font-weight: 700; font-size: 20px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar button { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 12px; padding: 10px 14px; min-height: 48px; font-weight: 600; }

/* ปุ่ม */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 10px 20px; border-radius: var(--r); border: 0; background: var(--brand); color: #fff; font-weight: 700; font-size: 18px; cursor: pointer; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.big { width: 100%; font-size: 20px; min-height: 60px; }
.btn.line { background: #06c755; }
.btn.ghost { background: var(--card); color: var(--brand-dark); border: 2px solid var(--brand-mid); }
.btn.soft { background: var(--brand-light); color: var(--brand-dark); }
.btn.danger { background: var(--bad); }
.btn.sm { min-height: 42px; padding: 6px 14px; font-size: 16px; }

/* กล่อง */
.card { background: var(--card); border: 1px solid var(--bd); border-radius: var(--r); padding: 16px; margin-bottom: 14px; box-shadow: var(--sh); }
.card h2 { margin: 0 0 10px; font-size: 20px; }
.card h3 { margin: 14px 0 6px; font-size: 17px; color: var(--mid); }

/* ฟอร์ม */
label.f { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 16px; }
input.f, select.f, textarea.f { width: 100%; min-height: 52px; padding: 12px 14px; border: 2px solid var(--bd); border-radius: 12px; background: #fff; }
input.f:focus, select.f:focus, textarea.f:focus { outline: 0; border-color: var(--brand); }
textarea.f { min-height: 100px; }
.help { color: var(--mid); font-size: 14px; margin-top: 4px; }
.err { color: var(--bad); font-weight: 600; margin: 8px 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 2px solid var(--brand-mid); background: #fff; color: var(--brand-dark); border-radius: 999px; padding: 8px 16px; min-height: 44px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.toggle { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.toggle input { width: 26px; height: 26px; }

/* สินค้า (ตะแกรง) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.pcard { background: var(--card); border: 1px solid var(--bd); border-radius: var(--r); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.pcard .ph { aspect-ratio: 1; background: var(--brand-light); display: flex; align-items: center; justify-content: center; color: var(--lt); font-size: 40px; }
.pcard img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.pcard .pn { padding: 8px 10px 0; font-weight: 600; font-size: 16px; line-height: 1.3; min-height: 44px; }
.pcard .pp { padding: 4px 10px 10px; color: var(--brand-dark); font-weight: 700; font-size: 18px; }
.badge { display: inline-block; font-size: 13px; padding: 2px 8px; border-radius: 999px; background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.badge.out { background: #fdecea; color: var(--bad); }
.badge.ok { background: #e8f6ee; color: var(--ok); }
.badge.warn { background: #fdf6e3; color: var(--warn); }

/* รายการ (หลังร้าน) */
.list .item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--bd); cursor: pointer; }
.list .item:last-child { border-bottom: 0; }
.list .thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--brand-light); flex: none; }
.list .t1 { font-weight: 600; }
.list .t2 { color: var(--mid); font-size: 15px; }

/* ลิ้นชัก / กล่องลอย */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 900; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 720px; max-height: 92dvh; overflow: auto; border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 720px) { .overlay { align-items: center; } .sheet { border-radius: 20px; max-height: 88vh; } }
.sheet h2 { margin: 0 0 8px; }
.sheet .close { position: sticky; top: 0; float: right; background: var(--brand-light); border: 0; border-radius: 999px; width: 44px; height: 44px; font-size: 22px; }
.lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; }

/* toast */
.tt-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); z-index: 999; background: #222; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 16px; opacity: 0; transition: .2s; max-width: 92vw; pointer-events: none; }
.tt-toast.show { opacity: 1; transform: translateX(-50%); }
.tt-toast.ok { background: var(--ok); } .tt-toast.bad { background: var(--bad); } .tt-toast.warn { background: var(--warn); }

/* แถบล่าง (หลังร้าน) */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; background: var(--card); border-top: 1px solid var(--bd); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; background: none; border: 0; padding: 8px 4px; min-height: 60px; color: var(--mid); font-size: 13px; font-weight: 600; }
.tabbar button .ic { display: block; font-size: 24px; }
.tabbar button.on { color: var(--brand); }
.has-tabbar { padding-bottom: 80px; }

/* ตาราง/สรุป */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 16px; }
.kv b { color: var(--mid); font-weight: 600; }
.total { display: flex; justify-content: space-between; font-size: 20px; font-weight: 700; padding: 10px 0; border-top: 2px solid var(--bd); margin-top: 8px; }
.qty { display: inline-flex; align-items: center; border: 2px solid var(--bd); border-radius: 12px; overflow: hidden; }
.qty button { width: 46px; height: 46px; border: 0; background: var(--brand-light); font-size: 22px; font-weight: 700; color: var(--brand-dark); }
.qty span { min-width: 44px; text-align: center; font-weight: 700; }
.qr-box { text-align: center; padding: 10px; }
.qr-box img { margin: 0 auto; }
.qr-manual { background: #fff; border: 2px dashed var(--brand-mid); border-radius: 12px; padding: 14px; }
.qr-num { font-size: 26px; font-weight: 700; letter-spacing: 1px; color: var(--brand-dark); }
.steps { display: flex; gap: 6px; margin: 6px 0 14px; }
.steps span { flex: 1; height: 6px; border-radius: 3px; background: var(--bd); }
.steps span.on { background: var(--brand); }
.usage { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.usage .u { background: var(--brand-light); border-radius: 12px; padding: 10px 12px; }
.usage .u b { display: block; font-size: 22px; color: var(--brand-dark); }
.bar { height: 8px; border-radius: 4px; background: var(--bd); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--brand); }
.bar i.warn { background: var(--warn); } .bar i.bad { background: var(--bad); }
.empty { text-align: center; padding: 40px 10px; color: var(--mid); }
.empty .ic { font-size: 48px; }
.banner { border-radius: var(--r); overflow: hidden; background: var(--brand-light); margin-bottom: 12px; position: relative; }
.banner img, .banner video, .banner iframe { width: 100%; aspect-ratio: 16/9; object-fit: cover; border: 0; display: block; }
.banner .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px; background: linear-gradient(transparent, rgba(0,0,0,.6)); color: #fff; }
.banner .cap b { font-size: 20px; }
.search { display: flex; gap: 8px; margin: 10px 0; }
.search input { flex: 1; }
.cartbtn { position: fixed; right: 16px; bottom: 16px; z-index: 100; min-height: 60px; border-radius: 999px; padding: 0 22px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.cartbtn .n { background: #fff; color: var(--brand-dark); border-radius: 999px; padding: 2px 10px; font-size: 15px; }

/* ปุ่มเลือกไฟล์แบบไทย (ซ่อน input ของเบราว์เซอร์) */
.filebtn { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.filebtn input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.filebtn .fname { color: var(--mid); font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
