/* BillWai — โทเคนและคอมโพเนนต์หน้าจอ (โทนเดียวกับระบบเดิม: เทาอุ่น ตัวอักษรเข้ม สีสถานะแยกชัด) */
@font-face { font-family: Sarabun; src: url(fonts/Sarabun-Regular.ttf); font-weight: 400; }
@font-face { font-family: Sarabun; src: url(fonts/Sarabun-Medium.ttf); font-weight: 500; }
@font-face { font-family: Sarabun; src: url(fonts/Sarabun-SemiBold.ttf); font-weight: 600; }
@font-face { font-family: Sarabun; src: url(fonts/Sarabun-Bold.ttf); font-weight: 700; }
:root {
  --bg: #F5F4F0; --sf: #fff; --s2: #EFEFEB; --bd: #E0DED8; --bd2: #CCCAC3;
  --tx: #1A1A18; --tx2: #6B6A65; --tx3: #9E9D98;
  --blue: #1D4ED8; --bbg: #EFF6FF; --btx: #1E40AF;
  --green: #15803D; --gbg: #F0FDF4; --gtx: #166534;
  --amber: #B45309; --abg: #FFFBEB; --atx: #92400E;
  --red: #DC2626; --rbg: #FEF2F2; --rtx: #991B1B;
  --pur: #7C3AED; --pbg: #F5F3FF; --ptx: #5B21B6;
  --font: Sarabun, "Sukhumvit Set", "Thonburi", Tahoma, system-ui, sans-serif;
  --mono: "IBM Plex Mono", Menlo, Consolas, monospace;
  --r: 8px; --rl: 12px;
  --shadow: 0 1px 2px rgba(26,26,24,.05), 0 8px 24px -14px rgba(26,26,24,.25);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); font-size: 14px; background: var(--bg); color: var(--tx); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
.num, .mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--tx2); } .faint { color: var(--tx3); } .small { font-size: 12.5px; } .xs { font-size: 11.5px; }
.hide { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; } .wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.r { text-align: right; } .c { text-align: center; }

/* shell */
.shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.side { width: 212px; flex: none; background: var(--sf); border-right: 1px solid var(--bd); display: flex; flex-direction: column; }
.logo { padding: 16px 14px 12px; border-bottom: 1px solid var(--bd); }
.logo b { display: block; font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.logo span { font-size: 11px; color: var(--tx3); display: block; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { padding: 8px; flex: 1; overflow-y: auto; }
.nav .grp { font-size: 10.5px; font-weight: 600; color: var(--tx3); letter-spacing: .08em; text-transform: uppercase; padding: 12px 10px 4px; }
.ni { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: var(--r); font-size: 13px; color: var(--tx2); cursor: pointer; text-align: left; }
.ni svg { width: 17px; height: 17px; flex: none; }
.ni:hover { background: var(--s2); color: var(--tx); }
.ni.on { background: var(--tx); color: #fff; font-weight: 500; }
.ni .cnt { margin-left: auto; font-size: 11px; background: var(--s2); color: var(--tx2); border-radius: 99px; padding: 1px 7px; }
.ni.on .cnt { background: rgba(255,255,255,.2); color: #fff; }
.side .foot { padding: 10px; border-top: 1px solid var(--bd); font-size: 11.5px; color: var(--tx3); }
.side .foot b { color: var(--tx2); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { height: 54px; flex: none; background: var(--sf); border-bottom: 1px solid var(--bd); display: flex; align-items: center; gap: 10px; padding: 0 18px; }
.top h1 { font-size: 16px; font-weight: 600; }
.content { flex: 1; overflow: auto; padding: 18px; }
.content.flush { padding: 0; }
.mtop { display: none; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 13px; border-radius: var(--r); border: 1px solid var(--bd2); background: var(--sf); color: var(--tx); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--s2); } .btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.bp { background: var(--tx); border-color: var(--tx); color: #fff; } .btn.bp:hover { background: #000; }
.btn.bg { background: var(--green); border-color: var(--green); color: #fff; }
.btn.bl { background: var(--bbg); border-color: #BFDBFE; color: var(--btx); }
.btn.bd { color: var(--rtx); } .btn.bd:hover { background: var(--rbg); }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--s2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 18px; font-size: 14px; }
.btn.block { width: 100%; }
.ibtn { width: 32px; height: 32px; padding: 0; border-radius: 7px; }

/* inputs */
.f { display: block; }
.f > span { display: block; font-size: 11.5px; color: var(--tx2); margin-bottom: 4px; font-weight: 500; }
.in, select.in, textarea.in { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--bd2); border-radius: var(--r); background: var(--sf); outline: 0; font-size: 13.5px; }
textarea.in { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.in:focus { border-color: var(--tx); box-shadow: 0 0 0 3px rgba(26,26,24,.08); }
.in.sm { height: 30px; font-size: 12.5px; padding: 0 8px; }
.in.r { text-align: right; }
select.in { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%236B6A65' stroke-width='1.8'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; padding-right: 28px; }
.sw { position: relative; width: 38px; height: 22px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; position: absolute; }
.sw i { position: absolute; inset: 0; background: var(--bd2); border-radius: 99px; cursor: pointer; transition: .2s; }
.sw i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.sw input:checked + i { background: var(--green); } .sw input:checked + i::after { transform: translateX(16px); }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; } .g4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

/* cards & tables */
.card { background: var(--sf); border: 1px solid var(--bd); border-radius: var(--rl); }
.card.pad { padding: 16px 18px; }
.sec { padding: 16px 18px; border-top: 1px solid var(--bd); display: grid; grid-template-columns: 220px 1fr; gap: 20px; }
.sec:first-child { border-top: 0; }
.sec h3 { font-size: 14px; font-weight: 600; } .sec .sd p { font-size: 12px; color: var(--tx2); margin-top: 3px; line-height: 1.45; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--tx2); padding: 9px 10px; border-bottom: 1px solid var(--bd); background: var(--s2); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--bd); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #FAFAF7; }
.tbl .r { text-align: right; } .tbl .c { text-align: center; }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-draft { background: var(--s2); color: var(--tx2); } .st-issued { background: var(--bbg); color: var(--btx); } .st-paid { background: var(--gbg); color: var(--gtx); } .st-void { background: var(--rbg); color: var(--rtx); } .st-overdue { background: var(--rbg); color: var(--rtx); } .st-sent { background: var(--abg); color: var(--atx); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; color: #fff; border-radius: 5px; padding: 1px 7px; white-space: nowrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--sf); border: 1px solid var(--bd); border-radius: var(--rl); padding: 14px 16px; }
.kpi .l { font-size: 12px; color: var(--tx2); } .kpi .v { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; } .kpi .s { font-size: 11.5px; color: var(--tx3); margin-top: 2px; }
.empty { text-align: center; padding: 36px 16px; color: var(--tx3); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--bd2); background: var(--sf); font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--tx); color: #fff; border-color: var(--tx); }
.chip .n { font-size: 11px; opacity: .7; }
/* ตัวกรองแบบเลือก ให้หน้าตาเหมือนชิปข้าง ๆ (สูง/มุมมน/ขนาดตัวอักษรเท่ากัน) */
.in.sm.chipsel { width: auto; min-width: 0; height: 30px; padding: 0 30px 0 12px; border-radius: 99px; border-color: var(--bd2); background-color: var(--sf); font-size: 12.5px; background-position: right 10px center; }
.in.sm.chipsel:focus { border-color: var(--tx); }
.ph { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.ph h2 { font-size: 17px; font-weight: 600; margin-right: auto; }
.help { font-size: 12px; color: var(--tx2); background: var(--abg); border: 1px solid #FDE68A; border-radius: var(--r); padding: 8px 12px; line-height: 1.5; }
.help.info { background: var(--bbg); border-color: #BFDBFE; }
.help.danger { background: var(--rbg); border-color: #FECACA; color: var(--rtx); }

/* editor */
.ed { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: 100%; }
.ed .form { overflow: auto; padding: 16px 18px 0; display: flex; flex-direction: column; }
.ed .form > .body { flex: 1; padding-bottom: 24px; }
.ed .prev { border-left: 1px solid var(--bd); background: #e9e9e6; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.ed .prev iframe { border: 0; width: 100%; aspect-ratio: 210 / 297; background: #fff; box-shadow: 0 10px 30px -14px rgba(0,0,0,.4); border-radius: 3px; flex: none; }
.ed .prev .pl { font-size: 11.5px; color: var(--tx2); }
.edbar { position: sticky; bottom: 0; margin: 0 -18px; padding: 12px 18px; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--bd); display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; z-index: 5; }
.edbar .grpL, .edbar .grpR { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sel { height: 36px; padding: 0 30px 0 12px; border: 1px solid var(--bd2); border-radius: var(--r); background: var(--sf) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%236B6A65' stroke-width='1.8'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center; appearance: none; font-size: 13px; font-weight: 500; cursor: pointer; }
.items-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.items { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.items th { font-size: 11.5px; color: var(--tx2); font-weight: 600; padding: 6px 6px; text-align: left; border-bottom: 1px solid var(--bd); }
.items td { padding: 4px 3px; border-bottom: 1px solid var(--bd); vertical-align: top; position: relative; }
.items td .in { height: 34px; }
.items td textarea.in { min-height: 34px; height: 34px; padding: 6px 8px; overflow: hidden; line-height: 1.4; }
.items .amt { text-align: right; font-weight: 600; padding-top: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.items .del { border: 0; background: none; color: var(--tx3); cursor: pointer; font-size: 16px; padding: 8px 4px; }
.items .del:hover { color: var(--red); }
.tot { margin-left: auto; width: 320px; font-size: 13.5px; }
.tot .l { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; gap: 10px; }
.tot .l span:first-child { color: var(--tx2); }
.tot .g { border-top: 1.5px solid var(--tx); margin-top: 4px; padding-top: 8px; font-size: 17px; font-weight: 700; }
.tot .in { width: 110px; height: 30px; }
/* 1.7.8 หักยอดที่ชำระแล้ว (มัดจำ/งวด) + ยอดคงเหลือ · ตารางใบเสร็จแบบอ้างอิง */
.tot .pp { gap: 6px; } .tot .pp .in[data-pp=label] { flex: 1; min-width: 0; width: auto; } .tot .pp .in[data-pp=amount] { width: 100px; flex: none; }
.tot .pp .del { border: 0; background: none; color: var(--tx3); cursor: pointer; padding: 4px; display: grid; place-items: center; } .tot .pp .del:hover { color: var(--red); } .tot .pp .del svg { width: 16px; height: 16px; }
.tot .ppadd { margin-top: 4px; } .tot .bal { border-top: 1px solid var(--bd); margin-top: 4px; padding-top: 6px; font-weight: 700; } .tot .bal span:first-child { color: var(--tx); }
.items.refs { min-width: 0; font-size: 12px; } .items.refs th { font-size: 11px; padding: 6px 3px; } .items.refs td { padding: 4px 2px; } .items.refs .rt { padding-top: 9px; line-height: 1.3; } .items.refs .amt { font-size: 12px; padding-top: 9px; } .items.refs .linkchip { white-space: nowrap; font-size: 11.5px; padding: 3px 6px; } .items.refs .in.sm { padding: 0 6px; } /* QA L4: พอดีความกว้างฟอร์มที่ 1280 px ไม่ต้องเลื่อนแนวนอน */
.rrlist { display: grid; gap: 6px; } .rrlist .rr { gap: 10px; padding: 8px 10px; border: 1px solid var(--bd); border-radius: var(--r); cursor: pointer; } .rrlist .rr input { width: 18px; height: 18px; flex: none; }
.sug { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: var(--sf); border: 1px solid var(--bd2); border-radius: var(--r); box-shadow: 0 12px 30px -10px rgba(0,0,0,.25); max-height: 240px; overflow: auto; }
.sug div { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--bd); font-size: 13px; }
.sug div:last-child { border-bottom: 0; } .sug div:hover, .sug div.on { background: var(--s2); }
.sug small { display: block; color: var(--tx3); font-size: 11px; }
.cust-card { background: var(--s2); border-radius: var(--r); padding: 10px 12px; font-size: 12.5px; line-height: 1.5; }
.lock { background: var(--gbg); border: 1px solid #BBF7D0; color: var(--gtx); border-radius: var(--r); padding: 10px 12px; font-size: 13px; }

/* modal / toast */
.mbd { position: fixed; inset: 0; background: rgba(26,26,24,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; animation: fade .15s; }
.modal { background: var(--sf); border-radius: 14px; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; box-shadow: 0 30px 80px -20px rgba(0,0,0,.45); animation: up .2s cubic-bezier(.2,.8,.2,1); }
.modal.wide { max-width: 760px; } .modal.wide:has(#pf) { max-width: 900px; }
.mh { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; } .mh h3 { font-size: 15.5px; font-weight: 600; flex: 1; }
.mb { padding: 4px 18px 18px; } .modal .mf { position: sticky; bottom: 0; background: var(--sf); z-index: 1; } .mf { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--bd); }
@keyframes fade { from { opacity: 0; } } @keyframes up { from { transform: translateY(14px); opacity: 0; } }
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 200; display: grid; gap: 6px; }
.toast { background: #1A1A18; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow); animation: up .2s; }
.toast.err { background: #991B1B; }
/* 1.7.15: มีกล่องโต้ตอบเปิดอยู่ → ข้อความแจ้งขึ้นด้านบน ไม่บังปุ่มยืนยัน/ยกเลิกของกล่อง */
#modal:not(:empty) + .toasts { bottom: auto !important; top: calc(12px + env(safe-area-inset-top)); }
.trial { background: var(--abg); border-bottom: 1px solid #FDE68A; color: var(--atx); font-size: 12.5px; padding: 6px 18px; display: flex; gap: 10px; align-items: center; }
.trial.backup { background: var(--bbg); border-color: #BFDBFE; color: var(--btx); }
.trial .btn.sm { height: 26px; font-size: 12px; } .btn.ghost { border-color: transparent; background: transparent; }
.trial.over { background: var(--rbg); border-color: #FECACA; color: var(--rtx); }
.timeline { font-size: 12px; color: var(--tx2); display: grid; gap: 6px; }
.timeline b { color: var(--tx); font-weight: 500; }
.linkchip { display: inline-flex; align-items: center; gap: 6px; background: var(--s2); border-radius: 6px; padding: 3px 8px; font-size: 12px; cursor: pointer; }
.linkchip:hover { background: var(--bd); }

@media (max-width: 1100px) { .ed { grid-template-columns: 1fr; } .ed .prev { display: none; } }
@media (max-width: 820px) {
  .side { display: none; } .mtop { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--sf); border-bottom: 1px solid var(--bd); overflow-x: auto; }
  .mtop .ni { width: auto; white-space: nowrap; padding: 6px 10px; font-size: 12.5px; }
  .content { padding: 12px; } .g3, .g4 { grid-template-columns: 1fr 1fr; } .sec { grid-template-columns: 1fr; gap: 10px; } .tot { width: 100%; }
}
/* 1.7.15: 768–820px แถบเมนูบน 7 ปุ่มกว้างรวม 786px → ล้นจอ มี scrollbar แนวนอน (หน้าต่าง Windows กว้าง 800) · ลดช่องไฟให้พอดี (รวม ~734px) ความสูงแถบเท่าเดิม */
@media (min-width: 768px) and (max-width: 820px) { .mtop { gap: 4px; padding: 10px 8px; } .mtop .ni { padding: 6px 8px; } }
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .top h1 { font-size: 14px; } }
:focus-visible { outline: 2px solid var(--tx); outline-offset: 2px; }

/* ===== 1.3.0 · iPad / จอสัมผัส (PWA) ===== */
/* safe-area: iPad รุ่นจอขอบมน + แถบสถานะเมื่อเปิดจากหน้าจอโฮม */
.shell { padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
.side { padding-bottom: env(safe-area-inset-bottom); }
.content { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.edbar { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.toasts { bottom: max(22px, calc(env(safe-area-inset-bottom) + 12px)); }
html.standalone, html.standalone body { overscroll-behavior: none; }
.items-wrap { -webkit-overflow-scrolling: touch; }

/* iPad แนวนอน 11" (1180) / แนวตั้ง 13" (1024) / จอกลาง: เมนูซ้ายยุบเหลือไอคอน */
@media (min-width: 821px) and (max-width: 1180px) {
  .side { width: 64px; }
  .logo b { font-size: 0; } .logo b::before { content: "TB"; font-size: 15px; } .logo span { display: none; }
  .nav .grp { display: none; }
  .ni { justify-content: center; padding: 10px 0; font-size: 0; position: relative; }
  .ni svg { width: 21px; height: 21px; }
  .ni .cnt { position: absolute; top: 2px; right: 4px; font-size: 9.5px; padding: 0 4px; }
  .side .foot { font-size: 0; padding: 6px; } .side .foot b { display: none; }
}

/* จอสัมผัส: เป้ากดอย่างน้อย 44px · ช่องกรอก 16px (Safari ไม่ซูมเมื่อโฟกัส) · ไม่พึ่ง hover */
@media (pointer: coarse) {
  .btn, .chip, .sel { min-height: 44px; }
  .in.sm.chipsel { height: 44px; }
  .btn.sm, .trial .btn.sm { min-height: 40px; height: auto; padding-top: 6px; padding-bottom: 6px; }
  .ibtn { width: 44px; height: 44px; }
  .ni { min-height: 44px; }
  .mtop .ni { min-height: 40px; }
  .in, select.in, textarea.in, .in.sm, .sel { font-size: 16px; }
  .in, select.in, .in.sm { height: 44px; }
  .items td .in { height: 44px; } .items td textarea.in { min-height: 44px; height: 44px; padding: 10px 8px; }
  .items .amt { padding-top: 14px; } .items .del { padding: 12px 8px; font-size: 20px; }
  .tot .in { height: 40px; }
  .sw { width: 46px; height: 28px; } .sw i::after { width: 22px; height: 22px; } .sw input:checked + i::after { transform: translateX(18px); }
  .sug div { padding: 11px 12px; font-size: 15px; }
  .linkchip { padding: 8px 10px; }
  .tbl td { padding: 12px 10px; }
  .tbl tr.click:hover td { background: none; } .tbl tr.click:active td { background: #FAFAF7; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  .modal { max-height: calc(100dvh - 40px); }
}
/* iPad แนวตั้ง (768–820): ใช้แถบเมนูด้านบนเลื่อนแนวนอน (มีอยู่แล้ว) + ฟอร์มเต็มกว้าง */
@media (min-width: 700px) and (max-width: 820px) { .g4 { grid-template-columns: 1fr 1fr; } .ed .form { padding: 14px 16px 0; } }

/* พิมพ์ในหน้าเดียวกัน (iPad / แอปหน้าจอโฮม) */
#printroot { position: fixed; inset: 0; z-index: 150; background: #e9e9e6; display: flex; flex-direction: column; }
#printroot .pr-bar { display: flex; gap: 10px; align-items: center; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: #1A1A18; color: #fff; }
#printroot .pr-doc { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
html.printing .shell { visibility: hidden; }
@media print {
  html.printing body { background: #fff; }
  html.printing .shell, html.printing #modal, html.printing .toasts, html.printing #printroot .pr-bar { display: none !important; }
  html.printing #printroot { position: static; background: #fff; display: block; }
  html.printing #printroot .pr-doc { overflow: visible; }
  /* 1.7.16 fix2 (M-W-04): เอกสารที่แบ่งหน้าไม่ได้ — สั่งพิมพ์จากเมนูเบราว์เซอร์/แชร์ › พิมพ์ ได้หน้าข้อความแจ้งแทนเอกสารที่ถูกตัด */
  html.printing.noprint #printroot .pr-doc { display: none !important; }
  html.printing.noprint #printroot::after { content: attr(data-noprint); display: block; padding: 20mm; font: 600 16px/1.6 Sarabun, sans-serif; color: #111; }
}
/* iOS: ตรึงโครงหน้าไว้กับจอ (ไม่ให้ทั้งหน้าเลื่อนหลบคีย์บอร์ดจนแถบเมนูหายใต้แถบสถานะ) · เนื้อหาเลื่อนใน .content แทน */
html.ios, html.ios body { height: 100%; overflow: hidden; }
html.ios .shell { position: fixed; inset: 0; height: auto; }
/* iOS: ช่องวันที่มีความกว้างในตัว ทำให้ล้นคอลัมน์ข้าง ๆ → บังคับให้เต็มช่องของตัวเอง */
input[type=date].in { min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; display: block; text-align: left; }
#printroot .pr-bar .btn { background: #fff; color: #111; border-color: #fff; font-weight: 600; }
/* iOS Safari ไม่เปิดตัวเลือกไฟล์ถ้า <input type=file> ถูก display:none → ซ่อนแบบมองไม่เห็นแต่ยังอยู่ในหน้า (นำเข้าไฟล์สำรอง/โลโก้/ลายเซ็น) */
label:has(> input[type=file].hide) { position: relative; overflow: hidden; }
/* 1.8.0 (VM QA): ช่องเลือกไฟล์ที่ไม่ได้อยู่ใน <label> (เช่น #imp-new นำเข้าเป็นกิจการใหม่) เคยขยายเต็มหน้าต่างและบังการคลิกทั้งหน้าตั้งค่า → นอก label ให้เล็ก 1px มองไม่เห็น (ยังเปิดได้ด้วย .click()) · ใน label เท่านั้นที่ขยายเต็มปุ่ม */
input[type=file].hide { display: block !important; position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; font-size: 0; }
label > input[type=file].hide { inset: 0; width: 100%; height: 100%; cursor: pointer; pointer-events: auto; }

/* ===== 1.4.0 · โทรศัพท์ (< 768px) ===== */
.mtop .sl { display: none; }
.quick { display: none; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
@media (max-width: 767px) {
  /* แถบเมนูล่าง (bottom tab) */
  .mtop { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: grid !important; grid-template-columns: repeat(7, 1fr); gap: 0; padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); border-top: 1px solid var(--bd); border-bottom: 0; background: rgba(255,255,255,.97); backdrop-filter: blur(10px); overflow: visible; }
  .mtop .ni { flex-direction: column; gap: 2px; padding: 6px 0 4px; min-height: 52px; font-size: 10.5px; border-radius: 10px; justify-content: center; position: relative; white-space: nowrap; }
  .mtop .ni svg { width: 22px; height: 22px; }
  .mtop .ni .lb { display: none; } .mtop .ni .sl { display: block; }
  .mtop .ni.on { background: transparent; color: var(--tx); font-weight: 700; } .mtop .ni.on svg { color: var(--blue); }
  .mtop .ni .cnt { position: absolute; top: 2px; right: calc(50% - 22px); margin: 0; font-size: 9.5px; padding: 0 5px; background: var(--red); color: #fff; }
  .content { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }
  body.editing .mtop { display: none !important; }
  body.editing .content { padding-bottom: 0; }
  /* หัวหน้า: ชื่อหน้า + ปุ่มขึ้นบรรทัดใหม่เต็มกว้าง */
  .top { height: auto; min-height: 50px; flex-wrap: wrap; padding: 8px 12px; gap: 6px; }
  .top h1 { font-size: 16px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; max-width: 100%; }
  .top .grow { display: none; }
  #topact { width: 100%; } #topact .row { width: 100%; } #topact .row > select { flex: 1; width: auto !important; } #topact > .btn { margin-left: auto; }
  body.editing #topact { width: auto; margin-left: auto; }
  .trial { padding: 8px 12px; flex-wrap: wrap; font-size: 12.5px; }
  .quick { display: grid; grid-template-columns: 1fr 1fr; }
  .quick .btn:first-child { grid-column: 1 / -1; height: 56px; font-size: 16px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px 12px; } .kpi .v { font-size: 18px; } .kpi .l { font-size: 11.5px; }
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ph { gap: 8px; } .ph h2 { flex: 1; }
  .ph .chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; }
  .ph > select.in, .ph > input.in { width: 100% !important; }
  .ph > select.in { width: calc(50% - 4px) !important; }
  /* รายการเอกสาร → การ์ด */
  .doctbl thead { display: none; }
  .doctbl, .doctbl tbody { display: block; }
  .doctbl tr { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "no no tot" "cu cu st" "tg dt pr"; align-items: center; gap: 4px 10px; padding: 10px 14px; border-bottom: 1px solid var(--bd); }
  .doctbl td { padding: 0 !important; border: 0 !important; }
  .doctbl td:nth-child(1) { grid-area: no; font-size: 14px; }
  .doctbl td:nth-child(2) { grid-area: tg; }
  .doctbl td:nth-child(3) { grid-area: dt; font-size: 12px; color: var(--tx2); }
  .doctbl td:nth-child(4) { grid-area: cu; font-size: 13.5px; }
  .doctbl td:nth-child(5) { grid-area: tot; font-weight: 700; font-size: 15px; justify-self: end; }
  .doctbl td:nth-child(6) { grid-area: st; justify-self: end; }
  .doctbl td:nth-child(7) { grid-area: pr; justify-self: end; } .doctbl td:nth-child(7) .btn { min-height: 34px; height: 34px; width: 40px; }
  .doctbl td:nth-child(4) .xs { display: inline; margin-left: 6px; }
  /* ฟอร์มเอกสาร: หน้าเดียวเลื่อนลง · รายการเป็นการ์ด */
  .ed .form { padding: 12px 12px 0; }
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .g4 > label:nth-child(3), .g4 > label:nth-child(4) { } 
  .items-wrap { margin: 0; padding: 0; overflow: visible; }
  .items { min-width: 0; table-layout: auto; }
  .items thead { display: none; }
  .items, .items tbody { display: block; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr 1fr 44px; grid-template-areas: "desc desc desc del" "qty unit price price" "disc code amt amt"; gap: 8px 8px; padding: 12px; margin-bottom: 10px; background: var(--sf); border: 1px solid var(--bd); border-radius: var(--rl); }
  .items td { border: 0; padding: 0; }
  .items td:nth-child(1) { grid-area: code; } .items td:nth-child(2) { grid-area: desc; } .items td:nth-child(3) { grid-area: qty; } .items td:nth-child(4) { grid-area: unit; }
  .items td:nth-child(5) { grid-area: price; } .items td:nth-child(6) { grid-area: disc; } .items td:nth-child(7) { grid-area: amt; } .items td:nth-child(8) { grid-area: del; text-align: right; }
  .items td:nth-child(n+1):nth-child(-n+6)::before { display: block; font-size: 11px; color: var(--tx2); margin-bottom: 3px; font-weight: 500; }
  .items td:nth-child(1)::before { content: "รหัส"; } .items td:nth-child(2)::before { content: "รายละเอียด"; } .items td:nth-child(3)::before { content: "จำนวน"; }
  .items td:nth-child(4)::before { content: "หน่วย"; } .items td:nth-child(5)::before { content: "ราคา/หน่วย"; } .items td:nth-child(6)::before { content: "ส่วนลด"; }
  .items .amt { align-self: end; padding: 0 0 10px; font-size: 17px; }
  .items .amt::before { content: "จำนวนเงิน "; font-size: 11px; font-weight: 500; color: var(--tx2); }
  .items td textarea.in { height: auto; min-height: 44px; }
  [data-a="addrow"] { width: 100%; height: 50px !important; font-size: 15px; border-style: dashed; }
  .ed .form .row[style*="align-items:flex-start"] { flex-direction: column; }
  .tot { width: 100%; margin: 0; }
  .ph[style*="margin:18px 0 6px"] .row { flex-wrap: wrap; }
  /* ปุ่มออกเอกสารติดล่างจอ */
  .edbar { position: sticky; bottom: 0; margin: 0 -12px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .edbar .grpL, .edbar .grpR { width: 100%; }
  .edbar .grpL .btn.bp { flex: 1; height: 50px; font-size: 16px; }
  .edbar .grpR:empty { display: none; }
  .edbar .grpR .sel { width: 100%; }
  /* ตั้งค่า */
  .sec { padding: 14px; }
  /* modal เต็มกว้างแบบ bottom sheet */
  .mbd { align-items: flex-end; padding: 0; }
  .modal { max-width: none !important; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  /* หน้าพิมพ์/แชร์ */
  #printroot .pr-bar { flex-wrap: wrap; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; }
  #printroot .pr-bar .pr-t { order: -1; width: 100%; color: #ccc; }
  #printroot .pr-bar #pr-pdf { flex: 1; height: 46px; }
  .toasts { bottom: calc(90px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }
  .toast { text-align: center; }
}
#printroot .pr-bar .btn.ghost-l { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
#printroot .pr-bar .btn:disabled { opacity: .7; }
.trial svg { width: 16px; height: 16px; vertical-align: -3px; display: inline-block; }
@media (max-width: 767px) {
  body.editing #installbar { display: none; }
  body.editing .top { flex-wrap: nowrap; }
  body.editing .top h1 { flex: 1; min-width: 0; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
  body.editing .top h1 .badge { flex: none; }
  body.editing #topact .btn { padding: 0 10px; }
  .ed .form .g4 { grid-template-columns: 1fr 1fr; }
  .ed .form .g4 > label:first-child { grid-column: 1 / -1; }
}
details.more { margin-top: 8px; } details.more > summary { cursor: pointer; font-size: 13px; color: var(--blue); padding: 10px 0; list-style: none; } details.more > summary::before { content: "＋ "; } details.more[open] > summary::before { content: "－ "; }
details.more > .g2:first-of-type > div:empty { display: none; }
.items .del svg { width: 18px; height: 18px; }
@media (max-width: 767px) {
  .items tr { grid-template-areas: "desc desc desc del" "qty unit price price" "disc disc amt amt"; }
  .items td:nth-child(1) { display: none; }
  .items .del { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--bd); border-radius: 10px; margin-top: 18px; }
}
@media (max-width: 767px) {
  #printroot .pr-bar .pr-t { flex: 0 0 100%; }
  .doctbl td:nth-child(7) .btn { min-height: 44px !important; height: 44px !important; width: 44px; margin: -6px -8px -6px 0; }
}
@media (max-width: 767px) {
  .ed .form .row[style*="align-items:flex-start"] { align-items: stretch !important; }
  .ed .form .row[style*="align-items:flex-start"] > .grow { min-width: 0 !important; width: 100%; }
  .items td .sug { position: absolute; left: 0; right: 0; top: 100%; z-index: 40; }
  html.kb body.editing .edbar { padding-bottom: 8px; }
  html.kb .mtop { display: none !important; }
}
.pplist { display: grid; gap: 8px; }
.pp { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 10px 12px; border: 1px solid var(--bd); border-radius: 12px; background: var(--sf); text-align: left; cursor: pointer; font-size: 15px; }
.pp:active { background: var(--s2); }
.pp .pn { flex: 1; min-width: 0; font-weight: 600; } .pp small { display: block; font-weight: 400; font-size: 12.5px; color: var(--tx2); margin-top: 2px; }
.pp .pq { flex: none; min-width: 44px; height: 36px; border-radius: 99px; background: var(--bbg); color: var(--btx); display: grid; place-items: center; font-weight: 700; padding: 0 10px; }
.pickbtn svg { width: 16px; height: 16px; }
@media (max-width: 767px) { .pickbtn { flex: 1; height: 50px !important; font-size: 15px; } [data-a="addrow"] { flex: 1; width: auto; } .modal .mh .btn.bp.sm { min-height: 40px; } }
/* แตะซ้ำเร็ว ๆ (เช่นเพิ่มสินค้าทีละชิ้น) ต้องไม่ซูมหน้าจอแบบ double-tap ของ iOS */
html, button, a, input, select, textarea, label, .pp { touch-action: manipulation; }
.pp.bump .pq { animation: ppbump .25s ease-out; background: var(--blue); color: #fff; }
@keyframes ppbump { 0% { transform: scale(1); } 50% { transform: scale(1.18); } 100% { transform: scale(1); } }
@media (max-width: 767px) { .ph .chips .chip { flex: none; white-space: nowrap; height: 40px; } .in.sm.chipsel { height: 40px; } }
.convbtns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%; }
.convbtns .xs { width: 100%; }
.convbtns .btn { flex: 1 1 30%; min-width: 0; padding: 0 8px; font-size: 14px; }
#installbar .trial { flex-wrap: nowrap; align-items: center; } #installbar .trial > span:first-child { flex: 1; min-width: 0; } #installbar .trial .grow { display: none; } #installbar .trial .btn { flex: none; }

/* ---------- รีวิว 25 ต.ค.: มือถือ ---------- */
/* คีย์บอร์ดเปิด: หน้าต่าง (bottom sheet) อยู่ในพื้นที่ที่มองเห็นเหนือคีย์บอร์ด ปุ่มบันทึกไม่ถูกบัง */
html.kb .mbd { top: var(--vvt, 0); bottom: auto; height: var(--vvh, 100%); }
html.kb .modal { max-height: calc(var(--vvh, 100dvh) - 12px); }
@media (max-width: 767px) {
  /* ลูกค้า: การ์ด (ชื่อ+ที่อยู่ / เลขผู้เสียภาษี · โทร / สาขา · ปุ่ม) */
  .cutbl thead { display: none; } .cutbl, .cutbl tbody { display: block; }
  .cutbl tr { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "nm nm" "tx ph" "br bt"; gap: 4px 10px; padding: 10px 14px; border-bottom: 1px solid var(--bd); align-items: center; }
  .cutbl td { padding: 0 !important; border: 0 !important; }
  .cutbl td:nth-child(1) { grid-area: nm; } .cutbl td:nth-child(2) { grid-area: tx; font-size: 12.5px; color: var(--tx2); }
  .cutbl td:nth-child(3) { grid-area: br; font-size: 12.5px; color: var(--tx2); } .cutbl td:nth-child(4) { grid-area: ph; justify-self: end; white-space: nowrap; font-size: 13px; }
  .cutbl td:nth-child(5) { display: none; } .cutbl td:nth-child(6) { grid-area: bt; justify-self: end; }
  /* รายงานภาษีขาย: การ์ด (เลขที่ · รวม / ผู้ซื้อ / วันที่ · มูลค่า · VAT) */
  .vattbl thead { display: none; } .vattbl, .vattbl tbody { display: block; }
  .vattbl tr { display: grid; grid-template-columns: 1fr auto auto; grid-template-areas: "no no gr" "by by by" "dt nt vt"; gap: 3px 12px; padding: 10px 14px; border-bottom: 1px solid var(--bd); }
  .vattbl td { padding: 0 !important; border: 0 !important; }
  .vattbl td:nth-child(1) { grid-area: dt; font-size: 12px; color: var(--tx2); } .vattbl td:nth-child(2) { grid-area: no; font-weight: 600; }
  .vattbl td:nth-child(3) { grid-area: by; font-size: 13px; } .vattbl td:nth-child(4), .vattbl td:nth-child(5) { display: none; }
  .vattbl td:nth-child(6) { grid-area: nt; font-size: 12px; } .vattbl td:nth-child(6)::before { content: "มูลค่า "; color: var(--tx3); }
  .vattbl td:nth-child(7) { grid-area: vt; font-size: 12px; } .vattbl td:nth-child(7)::before { content: "VAT "; color: var(--tx3); }
  .vattbl td:nth-child(8) { grid-area: gr; font-weight: 700; justify-self: end; }
}

/* ---------- เข้าสู่ระบบ / ผู้ใช้ (1.5.0) ---------- */
.login { max-width: 420px; margin: 36px auto; text-align: center; }
.login .lk svg { width: 34px; height: 34px; color: var(--mut, #6B7280); }
.login h2 { font-size: 19px; margin: 6px 0 2px; }
.login .ulist { display: grid; gap: 8px; margin: 16px 0; text-align: left; }
.login .ulist .btn { justify-content: flex-start; gap: 10px; width: 100%; }
.login .ulist .btn svg { width: 18px; height: 18px; flex: none; }
.login .ulist .xs { margin-left: auto; opacity: .75; font-weight: 400; }
.login form { text-align: left; }
.in.pin { font-size: 20px; letter-spacing: 6px; text-align: center; }
.in.pin::placeholder { font-size: 13px; letter-spacing: 0; }
[data-a="lock"] svg { width: 16px; height: 16px; vertical-align: -3px; }
@media (max-width: 767px) { .hide-sm { display: none; } .login { margin: 16px auto; } }

/* ช่องรายละเอียดสินค้า: ปุ่ม ▾ เปิดรายการสินค้า + พิมพ์เองได้ (1.5.2) */
.ddbtn { position: absolute; right: 8px; top: 8px; width: 24px; height: 24px; border: 0; border-radius: 6px; background: var(--s2); color: var(--tx2); font-size: 13px; cursor: pointer; line-height: 24px; padding: 0; }
.ddbtn:hover { background: var(--bd2); color: var(--tx); }
.sug .free { color: var(--btx); font-weight: 600; background: var(--bbg); }

/* สีเอกสาร (1.7.5) */
.dcrow{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:6px 0;border-bottom:1px solid var(--bd,#eee)}
.dcrow .dcname{min-width:150px;font-weight:600}
.dcrow .dcbar{width:64px;height:22px;border-radius:6px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.12)}
.dcrow .dcpick{width:40px;height:30px;padding:0;border:1px solid var(--bd2,#ddd);border-radius:8px;background:none;cursor:pointer}
.dcrow .dcsw{display:flex;gap:5px;flex-wrap:wrap}
.dcrow .sw-c{width:22px;height:22px;border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 1px rgba(0,0,0,.18);cursor:pointer;padding:0}
.dcrow .sw-c:focus-visible{outline:2px solid #111;outline-offset:2px}
@media (pointer:coarse){.dcrow .sw-c{width:30px;height:30px}.dcrow .dcpick{width:48px;height:40px}}
.dcrow .sw-c.on{box-shadow:0 0 0 2px #fff,0 0 0 4px #111}

/* นำเข้าสินค้าจากไฟล์ (1.7.6) */
.imp-prev{overflow:auto;max-height:44vh;border:1px solid var(--bd,#e5e5e5);border-radius:8px;background:var(--sf,#fff)}
.imp-prev table{min-width:100%;border-collapse:collapse}
.imp-prev th{position:sticky;top:0;background:var(--sf,#fff);z-index:1;padding:6px 6px}
.imp-prev td{white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;font-size:12.5px;padding:4px 8px}
.imp-prev tr.imp-hdr td{color:var(--tx3,#888);font-style:italic}
.imp-prev select{min-width:92px}
/* 1.7.8 ใบเสร็จแบบอ้างอิง บนจอสัมผัส/มือถือ: ตารางกลายเป็นการ์ดใบละใบ (ตารางสินค้าเดิมใช้ nth-child 8 ช่อง · ตารางนี้ 9 ช่อง จึงกำหนดเอง) */
@media (pointer: coarse), (max-width: 767px) {
  .items.refs { min-width: 0; }
  .items.refs tr { grid-template-columns: 1fr 1fr 1fr 44px; grid-template-areas: "no no no del" "date due bill bill" "amount remain paid paid"; }
  .items.refs td:nth-child(1) { display: none; } .items.refs td:nth-child(2) { grid-area: no; } .items.refs td:nth-child(3) { grid-area: date; } .items.refs td:nth-child(4) { grid-area: due; }
  .items.refs td:nth-child(5) { grid-area: bill; } .items.refs td:nth-child(6) { grid-area: amount; } .items.refs td:nth-child(7) { grid-area: remain; } .items.refs td:nth-child(8) { grid-area: paid; } .items.refs td:nth-child(9) { grid-area: del; text-align: right; }
  .items.refs td.rt { padding-top: 0; white-space: normal; }
  .items.refs td:nth-child(n+2):nth-child(-n+8)::before { display: block; font-size: 11px; color: var(--tx2); margin-bottom: 3px; font-weight: 500; }
  .items.refs td:nth-child(2)::before { content: "เลขที่ใบกำกับ"; } .items.refs td:nth-child(3)::before { content: "วันที่"; } .items.refs td:nth-child(4)::before { content: "ครบกำหนด"; } .items.refs td:nth-child(5)::before { content: "ใบวางบิล"; }
  .items.refs td:nth-child(6)::before { content: "จำนวนเงิน"; } .items.refs td:nth-child(7)::before { content: "ยอดคงค้าง"; } .items.refs td:nth-child(8)::before { content: "ยอดชำระ"; }
  .items.refs .amt { align-self: start; padding: 0; font-size: 15px; text-align: left; } .items.refs .amt::before { content: none; }
  .items.refs td:nth-child(6)::before, .items.refs td:nth-child(7)::before { display: block; }
  .items.refs .del { margin-top: 0; }
  #topact #newtype { max-width: 46vw; }
}

/* 1.7.9 ฟอร์มงวดงาน / มัดจำ */
.instsw { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--bd); border-radius: var(--r); background: var(--sf); }
.instsw label { gap: 6px; cursor: pointer; } .instsw input { width: 16px; height: 16px; }
.tot .instrow { display: flex; gap: 6px; padding: 4px 0; } .tot .instrow .in[data-inst=label] { flex: 1; min-width: 0; width: auto; }
.tot .instamt { font-weight: 700; } .tot .instamt span:first-child { color: var(--tx); }
.instsum-ed { margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--bd2); border-radius: var(--r); font-size: 12.5px; } .instsum-ed .l { padding: 2px 0; }
/*1.7.10*/ /* ใบส่งของ: ไม่แสดงราคา → ซ่อนคอลัมน์ ราคา/ส่วนลด/จำนวนเงิน ในฟอร์ม (ข้อมูลราคายังเก็บไว้) */
/*1.7.10*/ #items.noprice th:nth-child(5), #items.noprice th:nth-child(6), #items.noprice th:nth-child(7), #items.noprice td:nth-child(5), #items.noprice td:nth-child(6), #items.noprice td:nth-child(7) { display: none; }
/*1.7.10*/ .ph .doprice { margin-left: auto; cursor: pointer; font-weight: 600; } .ph .doprice + .row { margin-left: 8px; }
/*1.7.10*/ @media (max-width: 767px) { #items.noprice tr { grid-template-areas: "desc desc desc del" "qty unit code code"; } .ph .doprice { margin-left: 0; width: 100%; } }

/* 1.7.15: คำแนะนำขนาดกระดาษตอนพิมพ์จาก Android */
#printroot .pr-hint { background: #1A1A18; color: #ccc; font-size: 12px; line-height: 1.45; padding: 0 14px 8px; }
@media print { #printroot .pr-hint { display: none !important; } }

/* ===== 1.8.0 หลายกิจการ: ปุ่มเปลี่ยนกิจการ · แถบสีกิจการ · บรรทัด "ออกในนามของ" · รายการกิจการในตั้งค่า ===== */
body.multico .shell { border-top: 4px solid var(--coc, var(--blue)); }
.codot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--coc, var(--blue)); box-shadow: 0 0 0 2px var(--sf), 0 0 0 3px rgba(26,26,24,.14); }
.codot.lg { width: 14px; height: 14px; }
body.multico .logo #side-co { overflow: visible; white-space: normal; margin-top: 8px; }
.cosw { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 6px 8px; border: 1px solid var(--bd2); border-radius: var(--r); background: var(--s2); color: var(--tx); cursor: pointer; text-align: left; font-size: 12.5px; }
.cosw:hover { background: var(--sf); border-color: var(--tx3); }
.cosw:focus-visible, .coit:focus-visible, .cocolors .sw-c:focus-visible, .btn.linkish:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.cosw .con { display: block; flex: 1; min-width: 0; margin: 0; font-size: 12.5px; font-weight: 600; color: var(--tx); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cosw .con small { display: block; font-size: 11px; font-weight: 400; color: var(--tx3); overflow: hidden; text-overflow: ellipsis; }
.cosw .cocar { display: inline; margin: 0; font-size: 11px; color: var(--tx3); }
#mco { display: none; }
.cosw.top { width: auto; max-width: 100%; height: 34px; min-height: 34px; padding: 0 10px; }
@media (min-width: 821px) and (max-width: 1180px) {
  body.multico .logo #side-co { display: block; }
  .cosw { justify-content: center; padding: 8px 0; } .cosw .con, .cosw .cocar { display: none; } .cosw .codot { width: 14px; height: 14px; }
}
@media (max-width: 820px) { body.multico #mco { display: flex; flex: none; min-width: 0; max-width: 40%; } }
@media (max-width: 767px) { body.multico #mco { max-width: 46%; } body.editing .cosw.top .con, body.editing .cosw.top .cocar { display: none; } }
.comenu { position: fixed; z-index: 120; min-width: 260px; max-width: calc(100vw - 24px); max-height: min(70vh, 540px); overflow: auto; background: var(--sf); border: 1px solid var(--bd2); border-radius: var(--rl); box-shadow: 0 18px 44px -14px rgba(0,0,0,.32); padding: 6px; animation: up .15s; }
.comenu .cmh { font-size: 11px; font-weight: 600; color: var(--tx3); padding: 6px 10px 4px; }
.coit { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 7px 10px; border: 0; border-radius: var(--r); background: none; color: var(--tx); cursor: pointer; text-align: left; font-size: 13px; }
.coit:hover, .coit:focus { background: var(--s2); }
.coit.on { background: var(--bbg); }
.coit b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coit small { display: block; font-size: 11px; color: var(--tx3); }
.coit .tick { width: 16px; flex: none; text-align: center; font-weight: 700; color: var(--green); }
.cmsep { height: 1px; background: var(--bd); margin: 6px 4px; }
.coline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; padding: 8px 12px; border-radius: var(--r); background: var(--s2); border-left: 4px solid var(--coc, var(--blue)); font-size: 13px; color: var(--tx2); }
.coline b { color: var(--tx); }
.colist { border: 1px solid var(--bd); border-radius: var(--rl); overflow: hidden; }
.corow { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--bd); }
.corow:first-child { border-top: 0; }
.corow.on { background: #FAFAF7; }
.corow > .codot { margin-top: 4px; }
.corow.arch b { color: var(--tx2); } .corow.arch > .codot { opacity: .5; }
.corow .coinfo > div + div { margin-top: 3px; }
.corow .coinfo b { font-weight: 600; word-break: break-word; }
.coact { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.cotag { display: inline-block; font-size: 11px; font-weight: 600; line-height: 18px; border-radius: 5px; padding: 0 7px; background: var(--s2); color: var(--tx2); border: 1px solid var(--bd); white-space: nowrap; }
.cotag.cur { background: var(--gbg); color: var(--gtx); border-color: #BBF7D0; }
.cotag.vat { background: var(--bbg); color: var(--btx); border-color: #BFDBFE; }
.cocolors { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.cocolors .sw-c { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.18); cursor: pointer; }
.cocolors .sw-c.on { box-shadow: 0 0 0 2px var(--tx); }
@media (pointer: coarse) { .cocolors .sw-c { width: 32px; height: 32px; } .coit { min-height: 48px; } .cosw.top { height: 40px; } }
.btn.linkish { height: auto; min-height: 0; padding: 4px 6px; border: 0; background: none; color: var(--blue); text-decoration: underline; }
.cologin { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--bd); }
.login h2 .codot { margin-right: 8px; vertical-align: 1px; }
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cmp > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--bd); border-radius: var(--r); word-break: break-word; }
.cmp > div:first-child { background: var(--rbg); border-color: #FECACA; }
@media (max-width: 560px) { .cmp { grid-template-columns: 1fr; } .corow { flex-wrap: wrap; } .coact { width: 100%; justify-content: flex-start; padding-left: 26px; } }
@media print { .comenu { display: none !important; } }
.cofs { border: 0; padding: 0; margin: 0; min-width: 0; }
.cofs legend { font-size: 12.5px; color: var(--tx2); margin-bottom: 6px; padding: 0; }
.cofs input[type=radio] { width: 18px; height: 18px; }
/* 1.8.1 รับชำระหลายช่องทาง · จัดตามความกว้างของกล่องเอง (ข้างตัวอย่างเอกสารกล่องแคบ ~280px): ค่าตั้งต้น 2 บรรทัด (วิธี+จำนวน / อ้างอิง) · กล่อง ≥ 520px = บรรทัดเดียว */
[data-paybox], #pd-parts { container-type: inline-size; }
.payhead { display: none; gap: 6px; margin-bottom: 4px; } .payhead .r { text-align: right; }
.payrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 30px; gap: 6px; align-items: center; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px dashed var(--bd); }
.payrow .in { min-width: 0; width: 100%; }
.payrow [data-pay=ref], .payrow [data-pdp=ref] { grid-column: 1 / 3; grid-row: 2; }
.payrow .del { grid-column: 3; grid-row: 1; border: 0; background: none; color: var(--tx3); cursor: pointer; padding: 4px; display: grid; place-items: center; } .payrow .del:hover { color: var(--red); } .payrow .del svg { width: 16px; height: 16px; }
@container (min-width: 520px) {
  .payhead { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.6fr) 30px; }
  .payrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.6fr) 30px; margin-bottom: 6px; padding-bottom: 0; border-bottom: 0; }
  .payrow [data-pay=ref], .payrow [data-pdp=ref] { grid-column: 3; grid-row: 1; } .payrow .del { grid-column: 4; }
}
.paysum { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 12.5px; border-radius: 6px; padding: 6px 10px; margin: 2px 0 8px; }
.paysum.ok { background: var(--sf); color: var(--gtx); border: 1px solid #BBF7D0; } .paysum.bad { background: var(--rbg); color: var(--rtx); border: 1px solid #FECACA; }
.payadd { margin-top: 8px; }
