/* =====================================================================
   POS ชุด A (รอบ 17): ลูกค้าในหน้าขาย, จัดส่งจากหน้าขาย, ใบเสร็จ 80mm / A4
   ===================================================================== */

/* ---------- ชิปลูกค้าในหัวตะกร้า ---------- */
.posa-cust { display: flex; align-items: center; gap: 6px; min-width: 0; }
.posa-chip {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; min-height: 36px;
  padding: 4px 10px 4px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--chip); color: var(--ink); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.posa-chip:hover { border-color: var(--brand); }
.posa-chip.on { background: var(--brand-tint); border-color: var(--brand); color: var(--brand-strong); }
.posa-chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.posa-chip small { flex: none; font-weight: 500; opacity: .8; }
.posa-chip-caret { flex: none; opacity: .6; }
.posa-chip-x {
  flex: none; width: 32px; height: 32px; border: 0; border-radius: 999px; background: var(--chip); color: var(--ink);
  font: inherit; font-size: 1.15rem; line-height: 1; cursor: pointer;
}
.posa-chip-x:hover { background: var(--line); }

/* ---------- ป๊อปอัปเลือกลูกค้า ---------- */
.posa-picker { display: flex; flex-direction: column; gap: 10px; }
.posa-picker-search {
  display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--muted);
}
.posa-picker-search:focus-within { outline: 2px solid var(--brand); border-color: transparent; }
.posa-picker-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; font-size: 16px; color: var(--ink); }
.posa-cust-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.posa-cust-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; text-align: left;
  border: 1px solid transparent; border-radius: 14px; background: none; color: var(--ink); font: inherit; cursor: pointer;
}
.posa-cust-row:hover { background: var(--chip); }
.posa-cust-row.on { border-color: var(--brand); background: var(--brand-tint); }
.posa-cust-row.general { border-color: var(--line); }
.posa-cust-row.general.on { border-color: var(--brand); }
.posa-avatar {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong); font-weight: 700;
}
.posa-cust-text { display: flex; flex-direction: column; min-width: 0; }
.posa-cust-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.posa-picker-note { margin: 4px 2px; }

/* ---------- จัดส่งในแผ่นชำระเงิน ---------- */
.posa-ship { display: flex; flex-direction: column; gap: 10px; }
.posa-ship-toggle { width: 100%; }
.posa-ship-toggle button { min-height: 42px; font-weight: 600; }
.posa-ship textarea { resize: vertical; }
.posa-ship textarea.invalid { border-color: var(--danger); outline-color: var(--danger); }
.posa-ship-none { margin: 0; background: var(--chip); }
.posa-fee { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.posa-fee .field { flex: 0 1 200px; }
.posa-fee .link, .posa-fee > span { padding-bottom: 10px; }
.posa-due-fee { color: var(--muted); }

/* ---------- ใบเสร็จ: โครงที่ใช้ทั้งจอและสลิป ---------- */
.ra4-only { display: none; }
.receipt-shop-info, .receipt-doc { display: flex; flex-direction: column; gap: 2px; }
.receipt-party { display: flex; flex-direction: column; }
.receipt-delivery { display: flex; flex-direction: column; font-size: .9rem; padding: 8px 0; border-bottom: 2px dashed var(--line); }
.receipt-party-title { color: var(--muted); font-size: .78rem; }
.receipt-totals { display: flex; flex-direction: column; gap: 12px; }

/* ---------- พิมพ์ A4 (html[data-print="a4"]) ----------
   ค่าเริ่มต้น (ไม่มี data-print หรือ = "slip") ใช้สลิป 80mm ตาม app.css ไม่เปลี่ยน */
@page a4 { size: A4; margin: 14mm; }

@media print {
  html[data-print="a4"], html[data-print="a4"] body { page: a4; }
  html[data-print="a4"] .receipt-paper {
    page: a4; right: 0; width: auto; padding: 0; gap: 5mm;
    font-size: 10.5pt; line-height: 1.45; color: #111; background: #fff;
  }
  html[data-print="a4"] .receipt-paper .muted { color: #555; }
  html[data-print="a4"] .rslip-only { display: none !important; }
  html[data-print="a4"] span.ra4-only { display: block; }
  html[data-print="a4"] div.ra4-only { display: flex; }
  html[data-print="a4"] table.ra4-only { display: table; }

  /* หัวเอกสาร: ร้านซ้าย ชื่อเอกสารขวา */
  html[data-print="a4"] .receipt-shop {
    flex-direction: row; justify-content: space-between; align-items: flex-start; gap: 10mm;
    text-align: left; padding-bottom: 4mm; border-bottom: 2px solid #111;
  }
  html[data-print="a4"] .receipt-shop-info { align-items: flex-start; max-width: 60%; }
  html[data-print="a4"] .receipt-shop-name { font-size: 16pt; line-height: 1.25; }
  html[data-print="a4"] .receipt-doc { align-items: flex-end; text-align: right; gap: 1mm; }
  html[data-print="a4"] .receipt-doc-title { font-size: 15pt; letter-spacing: .02em; margin-bottom: 1mm; }

  /* กล่องลูกค้า / จัดส่ง */
  html[data-print="a4"] .receipt-party { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; }
  html[data-print="a4"] .receipt-customer,
  html[data-print="a4"] .receipt-delivery {
    font-size: 10pt; padding: 3mm 4mm; border: 1px solid #999; border-radius: 2mm; gap: .5mm;
  }
  html[data-print="a4"] .receipt-party-title { font-size: 8.5pt; font-weight: 700; color: #555; letter-spacing: .04em; margin-bottom: 1mm; }

  /* ตารางรายการ */
  html[data-print="a4"] .receipt-a4-items { width: 100%; border-collapse: collapse; font-size: 10pt; }
  html[data-print="a4"] .receipt-a4-items thead { display: table-header-group; }
  html[data-print="a4"] .receipt-a4-items th {
    padding: 2mm; text-align: left; font-size: 9pt; font-weight: 700;
    background: #eee; border-top: 1.5px solid #111; border-bottom: 1.5px solid #111;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  html[data-print="a4"] .receipt-a4-items td { padding: 2mm; border-bottom: 1px solid #ddd; vertical-align: top; }
  html[data-print="a4"] .receipt-a4-items .num { text-align: right; white-space: nowrap; }
  html[data-print="a4"] .receipt-a4-items .c-no { width: 8mm; text-align: center; }
  html[data-print="a4"] .receipt-a4-items tr { break-inside: avoid; }

  /* สรุปยอดชิดขวา */
  html[data-print="a4"] .receipt-totals { width: 48%; margin-left: auto; gap: 1.5mm; break-inside: avoid; }
  html[data-print="a4"] .receipt-total { padding: 2mm 0; border-top: 2px solid #111; border-bottom: 2px solid #111; }
  html[data-print="a4"] .receipt-total strong { font-size: 14pt; }
  html[data-print="a4"] .receipt-row strong { font-size: inherit; color: inherit; }
  html[data-print="a4"] .receipt-promos { font-size: 9pt; }

  /* ช่องลงชื่อ + ท้ายเอกสาร */
  html[data-print="a4"] .receipt-sign { justify-content: space-between; gap: 24mm; margin-top: 14mm; break-inside: avoid; }
  html[data-print="a4"] .receipt-sign span { flex: 1; padding-top: 2mm; border-top: 1px solid #111; text-align: center; font-size: 9pt; }
  html[data-print="a4"] .receipt-foot { margin-top: 4mm; padding-top: 3mm; border-top: 1px solid #ccc; font-size: 9pt; }
}

/* ช่องรับเงินในหน้าชำระเงิน: กรอบอยู่ที่ตัวห่อ ไม่ให้ช่องกรอกมีกรอบ/พื้นซ้อนอีกชั้น
   (.stack.tight input ใน app.css มีน้ำหนักมากกว่า เลยต้องระบุให้แรงกว่า) */
.stack.tight .paysheet-amount input,
.paysheet-amount input.num {
  border: 0; border-radius: 0; background: transparent; box-shadow: none;
  padding: 0; min-height: 0; height: 100%; outline: none;
  font-size: 1.7rem; font-weight: 700; color: var(--ink);
}
.paysheet-amount:focus-within { box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .18); }

/* =====================================================================
   รอบ 19: พักบิล / บิลค้าง (หน้าขาย) + ใบรายการ + เตือนตอนปิดกะ
   ===================================================================== */

/* ---------- แถบชิปบิลค้าง (เลื่อนแนวนอน ไม่ดันหน้าจอออกข้าง) ---------- */
.heldb {
  display: flex; gap: 8px; min-width: 0; max-width: 100%; flex: none;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; padding: 2px;
}
.heldb::-webkit-scrollbar { display: none; }
.heldb-chip {
  flex: none; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px;
  max-width: 190px; min-height: 46px; padding: 5px 12px; text-align: left;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink);
  font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.heldb-chip:hover { border-color: var(--brand); }
.heldb-chip.on { border: 2px solid var(--brand); padding: 4px 11px; background: var(--brand-tint); }
.heldb-chip-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; font-weight: 700; }
.heldb-chip-meta { display: flex; gap: 5px; max-width: 100%; overflow: hidden; white-space: nowrap; font-size: .74rem; color: var(--muted); }
.heldb-chip.on .heldb-chip-meta { color: var(--brand-strong); }
.heldb-new { flex-direction: row; align-items: center; gap: 6px; border-style: dashed; background: var(--chip); }
.heldb-new.on { border-style: solid; }
.heldb-plus { font-size: 1.2rem; font-weight: 700; line-height: 1; color: var(--brand); }

/* ในตะกร้า (จอใหญ่: บนสุดของตะกร้า) */
.heldb-in-cart { margin: -4px -4px 0; padding: 4px; }

/* ลอยเหนือแถบตะกร้า: มือถือ/แท็บเล็ตเท่านั้น */
.heldb-float { display: none; }
@media (max-width: 1024px) {
  .heldb-float {
    display: flex; position: fixed; z-index: 20; left: 12px; right: 12px;
    bottom: calc(14px + env(safe-area-inset-bottom)); padding: 4px 2px;
  }
  .heldb-float.has-bar { bottom: calc(82px + env(safe-area-inset-bottom)); }
  .heldb-float .heldb-chip { box-shadow: 0 4px 14px rgba(31,26,23,.16); }
  .posb.has-held .posb-catalog { padding-bottom: 140px; }
}
@media (max-width: 760px) {
  .heldb-float { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .heldb-float.has-bar { bottom: calc(146px + env(safe-area-inset-bottom)); }
  .posb.has-held .posb-catalog { padding-bottom: 210px; }
  .heldb-chip { max-width: 160px; }
}

/* ---------- ปุ่มพักบิล + หัวบิลค้างในตะกร้า ---------- */
.heldb-hold-btn { flex: none; border-radius: 999px; font-weight: 700; }
.heldb-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px;
  padding: 10px 12px; border-radius: 14px; background: var(--brand-tint); border: 1px solid var(--brand-soft);
}
.heldb-head-title { display: flex; flex-direction: column; min-width: 0; }
.heldb-head-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--brand-strong); }
.heldb-head-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.heldb-head-note { flex-basis: 100%; margin: 0; }
.heldb-error { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.heldb-msg { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.heldb-msg .link { text-decoration: none; font-size: 1.1rem; color: inherit; }
@media screen and (min-width: 1025px) {
  .heldb-alert-m { display: none; }
}
.heldb-form { gap: 12px; }
.heldb-form p { margin: 0; }

/* จำนวนที่ถูกจองในบิลค้างอื่น (บนการ์ดสินค้า) */
.heldb-reserved {
  align-self: flex-start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 1px 7px; border-radius: 999px; background: var(--warn-soft); color: #8A5A00; font-size: .7rem; font-weight: 600;
}

/* ---------- เตือนบิลค้างตอนปิดกะ ---------- */
.heldb-shift-warn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap;
  margin: 10px 0; background: var(--warn-soft); color: #6B4500;
}
.heldb-shift-warn p { margin: 2px 0 0; }

/* ---------- ใบรายการบิลค้าง (ไม่ใช่ใบเสร็จ): ซ่อนบนจอ พิมพ์เมื่อ html[data-print="held"] ---------- */
.heldp-wrap { display: none; }
.heldp-info { display: flex; flex-direction: column; gap: 2px; padding-bottom: 6px; border-bottom: 2px dashed var(--line); }
.heldp-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.heldp-lines li { display: flex; flex-direction: column; gap: 1px; }
.heldp-lines .receipt-row { align-items: flex-start; }
.heldp-rows { display: flex; flex-direction: column; gap: 2px; }
.heldp-note { margin: 4px 0 0; text-align: center; font-weight: 700; letter-spacing: .02em; }
@media print {
  html[data-print="held"] .heldp-wrap { display: block; position: fixed; inset: 0; background: #fff; }
  html[data-print="held"] .heldp-paper { gap: 6px; color: #111; background: #fff; }
  html[data-print="held"] .heldp-paper .receipt-row strong { font-size: inherit; color: inherit; }
  html[data-print="held"] .heldp-paper .receipt-total strong { font-size: 1.3em; }
  html[data-print="held"] .heldp-note { padding-top: 4px; border-top: 1px dashed #999; }
}

/* รอบ 20: จอใหญ่ เมาส์เลื่อนแนวนอนไม่ได้ → ชิปบิลค้างในตะกร้าเรียงเป็นตาราง ขึ้นบรรทัดใหม่
   ถ้าบิลเยอะ เลื่อนขึ้นลงได้ในกรอบ (สูงสุดประมาณ 3 แถว) */
@media (min-width: 1025px) {
  .heldb.heldb-in-cart {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px;
    overflow-x: hidden; overflow-y: auto; max-height: 172px;
    scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  }
  .heldb.heldb-in-cart::-webkit-scrollbar { display: block; width: 6px; }
  .heldb.heldb-in-cart::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
  .heldb.heldb-in-cart .heldb-chip { max-width: none; width: 100%; min-width: 0; }
  .heldb.heldb-in-cart .heldb-new { justify-content: center; }
}

/* =====================================================================
   รอบ 21: บิลค้างเป็นปุ่ม + ป๊อปอัปรายการ (แทนแถบชิปเลื่อน)
   ===================================================================== */
.held-pill {
  order: 3; flex: none; display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 10px 0 14px;
  border: 0; border-radius: 14px; background: rgba(255,255,255,.18); color: #fff;
  font: inherit; font-weight: 700; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.held-pill:hover { background: rgba(255,255,255,.28); }
.held-pill-count {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px;
  background: #fff; color: var(--brand-strong, var(--brand)); font-size: .8rem; font-weight: 800;
}
.held-list-btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; font-weight: 700; }
.held-list-btn .held-pill-count { background: var(--brand); color: #fff; min-width: 20px; height: 20px; font-size: .72rem; }
@media (min-width: 1025px) { .held-list-btn { display: none; } } /* จอใหญ่ใช้ปุ่มบนแถบสีพอ */
@media (max-width: 760px) {
  .posb-hero .posb-search { flex: 1 1 160px; min-width: 0; }
  .posb-hero .posb-search input { width: 100%; }
  .held-pill { order: 0; height: 46px; padding: 0 8px 0 12px; }
}

/* ป๊อปอัปรายการบิลค้าง */
.hpk { display: flex; flex-direction: column; gap: 14px; padding-bottom: 18px; }
.hpk-top { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hpk-new {
  display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 18px; border-radius: 14px;
  border: 1.5px dashed var(--brand); background: var(--brand-tint); color: var(--brand-strong, var(--brand));
  font: inherit; font-weight: 700; cursor: pointer;
}
.hpk-new.on { border-style: solid; }
.hpk-plus { font-size: 1.3rem; line-height: 1; }
.hpk-search {
  flex: 1 1 200px; display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--muted);
}
.hpk-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; color: var(--ink); }
.hpk-empty { margin: 8px 0; text-align: center; }
.hpk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.hpk-card {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-width: 0;
  padding: 12px 14px; text-align: left; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.hpk-card:hover { border-color: var(--brand); box-shadow: 0 6px 18px rgba(120,60,20,.10); transform: translateY(-1px); }
.hpk-card.on { border: 2px solid var(--brand); padding: 11px 13px; background: var(--brand-tint); }
.hpk-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; }
.hpk-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; }
.hpk-age { flex: none; font-size: .74rem; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.hpk-card.old .hpk-age { background: #FDECC8; color: #8A5300; }
.hpk-cust { font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hpk-card-bottom { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 2px; }
.hpk-total { font-size: 1.12rem; }
.hpk-current { align-self: flex-start; font-size: .72rem; font-weight: 700; color: var(--brand-strong, var(--brand)); }
.hpk-by { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .hpk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .hpk-card { padding: 10px 12px; }
  .hpk-card-bottom { flex-direction: column; align-items: flex-start; gap: 0; }
  .hpk-new { flex: 1 1 auto; justify-content: center; }
}

/* =====================================================================
   รอบ 22: ไอคอนบิลค้างข้างตะกร้า (แทนปุ่มบนแถบสี)
   ===================================================================== */
.posb-cart-head { flex-wrap: nowrap; }
.posb-cart-head > .muted { white-space: nowrap; }
.held-icon-btn {
  position: relative; flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted);
  cursor: pointer; -webkit-tap-highlight-color: transparent; transition: border-color .12s, color .12s, background .12s;
}
.held-icon-btn:hover { border-color: var(--brand); color: var(--brand-strong, var(--brand)); }
.held-icon-btn.has { color: var(--brand-strong, var(--brand)); background: var(--brand-tint); border-color: rgba(var(--brand-rgb), .35); }
.held-icon-btn.danger:hover { border-color: #E5A39A; color: #B42318; background: #FDF0EE; }
.held-badge {
  position: absolute; top: -6px; right: -6px; display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; border: 2px solid var(--surface);
  background: var(--brand); color: #fff; font-size: .7rem; font-weight: 800; line-height: 1;
}
.posb-cart-head .heldb-hold-btn { height: 40px; padding: 0 14px; }

/* มือถือ: ไอคอนบิลค้างที่ซ้ายสุดของแถบตะกร้าด้านล่าง */
.posb-bar-held {
  position: relative; flex: none; display: grid; place-items: center; width: 46px; height: 46px; margin-left: 2px;
  border: 0; border-radius: 999px; background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
}
.posb-bar-held .held-badge { top: -4px; right: -4px; border-color: var(--ink); }
.posb-bar-held + .posb-bar-summary { padding-left: 10px; }
.posb-bar-summary { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.posb-bar-held + .posb-bar-summary { font-size: .9rem; }

/* =====================================================================
   รอบ 23: ตะกร้า (หัว/ท้ายติดที่ เลื่อนเฉพาะรายการ) + ส่วนลดพับเก็บ
           + แผ่นชำระเงินแบบไม่ต้องเลื่อน (จอใหญ่ 2 คอลัมน์ / มือถือปุ่มยืนยันติดล่าง)
   ===================================================================== */

/* ---------- ตะกร้า: ทุกส่วนสูงคงที่ ยกเว้นรายการสินค้า ---------- */
.posb-cart > :not(.posb-lines):not(.posb-cart-empty) { flex: none; }
.posl-foot { display: flex; flex-direction: column; gap: 10px; }

/* ปุ่มแถว "ส่วนลด / โค้ดส่วนลด +" */
.posl-more-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 6px 8px 6px 14px;
  border: 1px dashed var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
  font: inherit; font-size: .9rem; font-weight: 600; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.posl-more-btn:hover { border-color: var(--brand); }
.posl-more-btn.open { border-style: solid; background: var(--chip); }
.posl-more-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.posl-more-sum {
  flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 2px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong, var(--brand)); font-size: .8rem; font-weight: 700;
}
.posl-more-ico {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong, var(--brand)); font-size: 1.15rem; font-weight: 700; line-height: 1;
}
.posl-more { display: flex; flex-direction: column; gap: 8px; }
.posl-more .bill-discount { padding-top: 0; border-top: 0; }
.posl-more .pospromo-coupon { padding-top: 0; }
.posl-more .check { font-size: .9rem; }
.posl-foot .pospromo-error { margin: 0; }
.posl-foot .vat-note { margin: -4px 0 0; }
.posl-foot .receipt-sums { padding-top: 8px; border-top: 2px dashed var(--line); gap: 2px; font-size: .92rem; }
.posl-foot .receipt-total { padding: 6px 0; }
.posl-foot .receipt-total strong { font-size: 1.45rem; }
.posl-foot .posb-pay-btn { min-height: 54px; }
.posl-foot .posb-pay-btn strong { padding: 8px 16px; }
/* ส่วนลดท้ายบิล: ป้ายอยู่ซ้ายช่องในบรรทัดเดียว */
.posl-more .bill-discount { align-items: center; }
.posl-more .bill-discount .field.inline { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; white-space: nowrap; font-size: .85rem; }
.posl-more .bill-discount .segmented { flex: none; }
.posl-more .bill-discount .field.inline input { flex: 1 1 auto; min-width: 0; width: 100%; }
.posl-more .segmented.two button { padding-top: 6px; padding-bottom: 6px; }
/* ส่วนที่กางออก (มีช่องใบกำกับภาษี) ไม่ให้ดันรายการจนหาย */
.posl-more { max-height: 34vh; max-height: 34dvh; overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 1025px) {
  .posb-cart .posb-lines { min-height: 120px; }
}

@media (max-width: 1024px) {
  /* แผ่นบิลบนมือถือ: สูงคงที่ หัวติดบน ท้ายติดล่าง เลื่อนเฉพาะรายการ */
  .posb-cart { overflow: hidden; gap: 10px; padding-top: 12px; }
  .posb-cart:has(.posl-foot) { height: 90dvh; max-height: 90dvh; }
  .posb-cart .posb-lines {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 2px 16px;
  }
  .posl-foot { gap: 8px; margin: 0 -16px; padding: 10px 16px 0; border-top: 1px solid var(--line); box-shadow: 0 -6px 14px rgba(31,26,23,.05); }
  .posl-foot .receipt-sums { padding-top: 0; border-top: 0; }
  .posl-foot .receipt-total strong { font-size: 1.35rem; }
  .posl-foot .posb-pay-btn { min-height: 52px; }
  .posl-more { max-height: 30dvh; }
}

/* ---------- แผ่นชำระเงิน ---------- */
.paysheet.posl-pay { gap: 10px; overflow: hidden; }
.posl-pay-grid { flex: 1 1 auto; min-height: 0; }
.posl-pay-sum, .posl-pay-entry, .posl-pay-foot { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.posl-pay .paysheet-head h2 { font-size: 1.15rem; }
.posl-pay .posa-ship-toggle button { min-height: 40px; }
.posl-pay .pay-lines li { padding: 6px 10px; }

/* วิธีชำระ: ไอคอน + ชื่อในแถวเดียว */
.posl-pay .paysheet-methods button { flex-direction: row; gap: 8px; min-height: 48px; font-size: .9rem; }
.posl-pay .paysheet-methods svg { width: 20px; height: 20px; flex: none; }

/* บัญชี + QR ในแถวเดียว */
.posl-acct { display: flex; align-items: flex-end; gap: 10px; min-width: 0; }
.posl-acct .field { flex: 1 1 auto; min-width: 0; }
.posl-acct select { width: 100%; }
.posl-acct .qr-mini { flex: none; gap: 8px; max-width: 150px; padding: 4px 8px 4px 4px; border-radius: 12px; font-size: .74rem; line-height: 1.3; }
.posl-acct .qr-mini img { width: 52px; height: 52px; }

/* สกุลเงิน */
.posl-cur { display: flex; align-items: center; gap: 10px; min-width: 0; }
.posl-cur > span { flex: none; }
.posl-cur .paysheet-chips { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.posl-cur .paysheet-chips::-webkit-scrollbar { display: none; }
.posl-cur .paysheet-chips button { flex: 1 0 auto; min-height: 38px; padding: 0 12px; white-space: nowrap; }

/* ช่องจำนวนเงิน + ปุ่มพอดี */
.posl-amt { display: flex; align-items: flex-end; gap: 8px; min-width: 0; }
.posl-amt-field { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.posl-pay .paysheet-amount { height: 56px; padding: 0 14px; }
.posl-exact {
  flex: none; height: 56px; min-width: 72px; padding: 0 16px; border: 0; border-radius: 16px;
  background: var(--brand-soft); color: var(--brand-strong, var(--brand)); font: inherit; font-weight: 700; cursor: pointer;
}
.posl-exact:hover { background: rgba(var(--brand-rgb), .2); }

/* ธนบัตรด่วน */
.posl-pay .posl-notes { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.posl-pay .posl-notes button { min-height: 42px; }

/* ยอดคงเหลือ/เงินทอน + ปุ่มยืนยัน */
.posl-pay .paysheet-result { padding: 10px 14px; border-radius: 14px; }
.posl-pay .paysheet-result strong { font-size: 1.35rem; }
.posl-pay-msg { margin: 0; }
.posl-split { padding: 2px 0; font-size: .88rem; }
.posl-pay .paysheet-confirm { margin-top: 0; min-height: 56px; }

/* จอใหญ่: กว้าง 2 คอลัมน์ ซ้าย = สรุป + ยืนยัน (ล่าง), ขวา = กรอกการชำระ
   รอบ 98: แท็บเล็ตแนวนอน (900–1024px) ใช้แบบนี้ด้วย — เดิมเป็นแผ่นล่างกว้างเต็มจอ 1024px (ยืดจนอ่านยาก) */
@media (min-width: 900px) {
  .paysheet.posl-pay { left: 50%; right: auto; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(900px, calc(100vw - 48px)); max-height: calc(100dvh - 32px); padding: 16px 24px 20px; border-radius: 26px; }
  .posl-pay .sheet-grip { display: none; }
  .posl-pay-grid {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: 1fr auto;
    column-gap: 0; row-gap: 12px; overflow-y: auto; overscroll-behavior: contain;
  }
  .posl-pay-sum { grid-column: 1; grid-row: 1; padding-right: 22px; }
  .posl-pay-foot { grid-column: 1; grid-row: 2; padding-right: 22px; align-self: end; }
  .posl-pay-entry { grid-column: 2; grid-row: 1 / span 2; padding-left: 22px; border-left: 1px solid var(--line); }
  .posl-pay .paysheet-due { padding: 16px 18px; }
  .posl-pay .paysheet-methods button { min-height: 52px; }
  .posl-pay .paysheet-confirm { min-height: 60px; }
}

/* มือถือ/แท็บเล็ต: คอลัมน์เดียวแบบกระชับ ปุ่มยืนยันติดล่างเสมอ */
@media (max-width: 899px) {
  .paysheet.posl-pay { max-height: 94dvh; padding: 8px 16px 0; gap: 6px; }
  .posl-pay .paysheet-head { min-height: 36px; }
  .posl-pay .paysheet-head .icon-btn.round { width: 36px; height: 36px; }
  .posl-pay-grid {
    display: flex; flex-direction: column; gap: 10px; overflow-y: auto; overscroll-behavior: contain;
    margin: 0 -16px; padding: 0 16px;
  }
  .posl-pay-sum, .posl-pay-entry { gap: 10px; }
  /* การ์ดยอด: ป้าย + ยอดในบรรทัดเดียว */
  .posl-pay .paysheet-due {
    flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 0 10px; padding: 8px 14px; border-radius: 16px;
  }
  .posl-pay .paysheet-due > .muted { flex: 1 1 auto; min-width: 0; }
  .posl-pay .paysheet-due strong { font-size: 1.75rem; line-height: 1.25; }
  .posl-pay .paysheet-due .posa-due-fee, .posl-pay .paysheet-conv { flex: 1 1 100%; }
  .posl-pay .paysheet-conv { font-size: .8rem; gap: 0 12px; justify-content: flex-end; }
  .posl-pay .paysheet-methods { gap: 6px; }
  .posl-pay .paysheet-methods button { min-height: 44px; gap: 6px; border-radius: 12px; font-size: .85rem; }
  .posl-pay .paysheet-methods svg { width: 18px; height: 18px; }
  .posl-acct .qr-mini span { display: none; }
  .posl-acct .qr-mini { padding: 3px; }
  .posl-acct .qr-mini img { width: 46px; height: 46px; }
  .posl-pay .paysheet-amount, .posl-exact { height: 52px; }
  /* ธนบัตรด่วน: แถวเดียวเลื่อนแนวนอน */
  .posl-pay .posl-notes {
    display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: none;
    margin: 0 -16px; padding: 0 16px; -webkit-overflow-scrolling: touch;
  }
  .posl-pay .posl-notes::-webkit-scrollbar { display: none; }
  .posl-pay .posl-notes button { flex: 1 0 auto; min-width: 64px; min-height: 40px; padding: 0 12px; }
  .posl-pay-foot {
    position: sticky; bottom: 0; z-index: 2; gap: 6px; margin: auto -16px 0; padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .posl-pay .paysheet-result { padding: 6px 14px; border-radius: 12px; }
  .posl-pay .paysheet-result strong { font-size: 1.2rem; }
  .posl-pay .paysheet-confirm { min-height: 52px; font-size: 1.05rem; }
  .posl-pay .posa-ship textarea { min-height: 0; }
}

/* =====================================================================
   รอบ 24: ช่องค้นหา + หมวดสินค้า ติดด้านบนตลอด (สินค้าเยอะเลื่อนลงไปแล้วยังค้นหาได้)
   - จอใหญ่: รายการสินค้าเลื่อนในกรอบอยู่แล้ว ส่วนนี้จึงอยู่กับที่
   - แท็บเล็ต/มือถือ: position: sticky ใต้หัวจอ
   ===================================================================== */
.posb-sticky { display: flex; flex-direction: column; gap: 12px; flex: none; }
@media (max-width: 1024px) {
  .posb-sticky {
    position: sticky; top: 0; z-index: 12;
    background: var(--bg); padding-bottom: 8px; margin-bottom: -4px;
  }
}
@media (max-width: 760px) {
  .posb-sticky {
    top: calc(52px + env(safe-area-inset-top)); /* ใต้แถบหัวจอมือถือ */
    margin: -16px -16px 0; padding: 0 16px 8px; gap: 10px;
  }
  .posb-sticky .posb-hero { margin: 0 -16px; }
  .posb-sticky .posb-cats { padding-top: 2px; }
}

/* =====================================================================
   รอบ 98: แท็บเล็ต (761–1024px) — เมนูซ้ายยังแสดงอยู่
   - แถบสรุปตะกร้าด้านล่างเริ่มหลังเมนู (เดิม left: 12px ทับชื่อผู้ใช้/ภาษาในเมนู)
   - แผ่นตะกร้า/แผ่นชำระเงิน (แบบแผ่นล่าง) กว้างไม่เกิน 760px อยู่กลางจอ ไม่ยืดเต็ม 1024px
   ===================================================================== */
@media (min-width: 761px) and (max-width: 1024px) {
  .posb-bar, .heldb-float { left: calc(232px + 16px); right: 16px; }
  .posb-cart { left: max(0px, calc(50% - 380px)); right: max(0px, calc(50% - 380px)); }
}
@media (min-width: 761px) and (max-width: 899px) {
  .paysheet.posl-pay { left: max(0px, calc(50% - 380px)); right: max(0px, calc(50% - 380px)); }
}

/* =====================================================================
   รอบ 100b: <PosHero> — แถบสีตัวเดียวกันของหน้าขายและบิลโต๊ะ
   (หน้าขายไม่ใช้ส่วนเพิ่มด้านล่าง: .posb-hero-back / .posb-hero-meta / .posb-hero-keep → หน้าตาหน้าขายเหมือนเดิม)
   ===================================================================== */
.posb-hero-back { align-self: flex-start; color: #fff; text-decoration: none; font-weight: 600; }
.posb-hero-back:hover { text-decoration: underline; }
.posb-hero-meta { flex: 1 1 100%; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.posb-hero-keep .posb-hero-title { min-width: 0; }
.posb-hero-keep .posb-hero-title h1 { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  /* บิลโต๊ะ: มือถือยังแสดงชื่อโต๊ะ · ลำดับ = ชื่อ → ชิป → ช่องค้นหา */
  .posb-hero.posb-hero-keep { gap: 8px; padding-top: 6px; }
  .posb-hero-keep .posb-hero-title { display: flex; flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
  .posb-hero-keep .posb-hero-title h1 { font-size: 1.2rem; line-height: 1.25; }
  .posb-hero-keep .posb-hero-back { align-self: baseline; }
  /* ชิปแถวเดียว เลื่อนข้างได้ (แบบแถวหมวด .posb-cats) — แถบติดบนไม่สูงเกินไป */
  .posb-hero-keep .posb-hero-meta { order: 1; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .posb-hero-keep .posb-hero-meta::-webkit-scrollbar { display: none; }
  .posb-hero-keep .posb-hero-meta > * { flex: none; }
  .posb-hero-keep .posb-search { order: 2; flex-basis: 100%; }
}

/* =====================================================================
   รอบ 121a: แท็บเล็ตแนวนอน — เมนูซ้าย + บิลขวา วางข้างกันแบบจอคอม (หน้าขาย /pos + บิลโต๊ะ /restaurant/tab)
   - ช่วง = 900–1024px + แนวนอน + สูง ≥ 600px (ตัดมือถือแนวนอนที่สูง ~390px ออก) — 1025px ขึ้นไปเป็นแบบจอคอมอยู่แล้ว (รวม 1025–1180)
     ต่ำกว่า 900px บิล 336px เหลือที่เมนูไม่พอ ≥ 2 คอลัมน์ → ใช้แผ่นบิลเลื่อนขึ้นเหมือนเดิม
   - แท็บเล็ตแนวตั้ง / 761–899px / มือถือแนวนอน / มือถือ ≤760px = แผ่นบิลเลื่อนขึ้นเหมือนเดิม (จุดตัดมือถือ 760px ไม่เปลี่ยน)
   - ยกเลิกกฎแผ่นล่างของ app.css / pos2.css (max-width: 1024px) เฉพาะ .posb แล้วใช้โครงเดียวกับ ≥1025px (รายการเลื่อนในกรอบ บิลสูงเต็มกรอบ)
   - แผ่นชำระเงินยังเป็นแผ่นล่างกลางจอ (กฎรอบ 98) · ไม่มีตรรกะใหม่ (ปุ่ม/สถานะเดิม) — ดู docs/conventions/ui-shared.md
   ===================================================================== */
@media screen and (min-width: 900px) and (max-width: 1024px) and (orientation: landscape) and (min-height: 600px) {
  .main:has(.content > .posb) { overflow: hidden; display: flex; flex-direction: column; }
  .content:has(> .posb) { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 16px; max-width: none; }
  .posb { grid-template-columns: minmax(0, 1fr) 336px; gap: 16px; flex: 1 1 auto; min-height: 0; align-items: stretch; }
  .posb .posb-catalog, .posb.has-held .posb-catalog { padding-bottom: 0; min-height: 0; overflow: hidden; }
  .posb-catalog > :not(.posb-grid) { flex: none; }
  .posb .posb-sticky { position: static; background: none; padding-bottom: 0; margin-bottom: 0; }
  .posb .posb-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px;
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    align-content: start; padding: 2px 4px 16px 2px; margin-right: -4px;
  }
  .posb > .posb-cart, .posb > .posb-cart:has(.posl-foot) {
    position: static; left: auto; right: auto; bottom: auto; z-index: auto; transform: none; transition: none;
    height: 100%; max-height: none; min-height: 0; padding: 14px; border-radius: var(--radius-lg); box-shadow: var(--shadow);
  }
  html[data-theme="dark"] .posb > .posb-cart { box-shadow: 0 0 0 1px #2A2724, var(--shadow); }
  .posb > .posb-cart .posb-lines { margin: 0 -14px; padding: 2px 14px; min-height: 96px; }
  .posb > .posb-cart .posl-foot { margin: 0 -14px; padding: 10px 14px 0; }
  .posb > .posb-cart .icon-btn.sheet-close { display: none; }
  .posb > .sheet-scrim, .posb > .posb-bar, .heldb-alert-m { display: none; }
  .held-list-btn { display: none; } /* เหมือน ≥1025px: ใช้ไอคอนบิลค้างที่หัวบิลพอ */
}
