:root {
  --bg: #f2f5f9; --surface: #fff; --surface-2: #f7f9fc; --ink: #0f172a; --ink-2: #334155; --muted: #64748b;
  --line: #e2e8f0; --line-2: #cbd5e1;
  --pri: #0b7285; --pri-2: #0c8599; --pri-soft: #e3f3f6; --side: #0b2530; --side-2: #12404f;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2; --info: #1d4ed8; --info-soft: #dbeafe;
  --radius: 10px; --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 2px 10px rgba(15, 23, 42, .05);
  --font: 'IBM Plex Sans Thai', 'Leelawadee UI', 'Noto Sans Thai', Tahoma, system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%; }
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
h4 { margin: 18px 0 8px; font-size: 15px; }
small { font-size: 12.5px; }
.ic { width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); } .neg { color: var(--bad); font-weight: 600; } .ok-t { color: var(--ok); } .warn-t { color: var(--warn); font-weight: 600; }
.r { text-align: right; } .c { text-align: center; } .nowrap { white-space: nowrap; } .block { display: block; } .pre { white-space: pre-wrap; }
.row { display: flex; align-items: center; } .gap { gap: 8px; } .wrap { flex-wrap: wrap; } .between { justify-content: space-between; } .end { justify-content: flex-end; } .grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 8px; margin-top: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0; }
.ellipsis { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- ปุ่ม/ฟอร์ม ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; cursor: pointer; white-space: nowrap; font-weight: 500; color: var(--ink); text-decoration: none !important; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.primary:hover { background: var(--pri-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-o { color: var(--bad); border-color: #f1b4b4; }
.btn.sm { min-height: 30px; padding: 3px 10px; font-size: 13.5px; }
.btn.big { min-height: 46px; font-size: 16px; padding: 10px 20px; }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: inherit; flex-shrink: 0; }
.icon-btn:hover { background: rgba(100, 116, 139, .14); }
.link { border: 0; background: none; color: var(--pri); cursor: pointer; padding: 8px 0; }
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--pri); outline-offset: 1px; border-color: var(--pri); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
.field { display: grid; gap: 4px; margin-bottom: 4px; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 14px; margin-bottom: 8px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--pri); }
.check.big { font-size: 15px; font-weight: 500; }
.date-wrap { display: grid; gap: 1px; } .date-wrap .be { color: var(--muted); font-size: 12px; min-height: 0; }
label.inline { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
label.inline .date-wrap { display: inline-grid; }

/* ---------- โครงหน้า ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: var(--side); color: #cfe2e9; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; color: #fff; font-weight: 600; line-height: 1.3; }
.brand small { display: block; font-weight: 400; color: #8fb2bf; font-size: 12px; margin-top: 2px; }
.logo { width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(135deg, #22b8cf, #0b7285); color: #fff; display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.nav { flex: 1; overflow: auto; padding: 4px 10px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin-bottom: 2px; border-radius: 8px; color: #cfe2e9; text-decoration: none; }
.nav a:hover { background: rgba(255, 255, 255, .07); }
.nav a.active { background: var(--side-2); color: #fff; box-shadow: inset 3px 0 0 #3bc9db; }
.sidebar .install-btn { margin: 6px 12px; background: transparent; color: #cfe2e9; border-color: rgba(255, 255, 255, .25); }
.sidebar .install-btn:hover { background: rgba(255, 255, 255, .08); }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.side-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-user small { display: block; color: #8fb2bf; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.topbar h1 { flex: 1; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; }
.mode { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.mode.demo { background: var(--warn-soft); color: var(--warn); } .mode.live { background: var(--ok-soft); color: var(--ok); }
#view { padding: 18px 20px 40px; width: 100%; max-width: 1440px; margin: 0 auto; }
.scrim { display: none; }
.banner { padding: 9px 14px; border-radius: 8px; margin: 0 0 12px; font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.main > .banner { margin: 0; border-radius: 0; padding: 7px 20px; }
.banner.demo { background: #fff8e6; color: #7c4a03; border-bottom: 1px solid #f6e3b0; }
.banner.warn { background: var(--warn-soft); color: #7c4a03; } .banner.info { background: var(--info-soft); color: #1e3a8a; } .banner.bad { background: var(--bad-soft); color: var(--bad); }
.back { display: inline-block; margin-bottom: 10px; }

/* ---------- การ์ด/KPI ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; min-width: 0; }
.card > h3 { margin-bottom: 12px; font-size: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h3 { font-size: 15.5px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.grid-2 > .card { margin-bottom: 0; } .grid-2 + .card, .grid-2 + section { margin-top: 14px; } .grid-2.top { margin-bottom: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow); display: grid; gap: 2px; min-width: 0; }
.kpi span { font-size: 13px; color: var(--muted); } .kpi b { font-size: 22px; font-weight: 700; letter-spacing: -.01em; } .kpi small { color: var(--muted); }
.kpi.bad { border-left: 4px solid var(--bad); } .kpi.warn { border-left: 4px solid #f59f00; }
.bars { display: flex; align-items: flex-end; gap: 5px; height: 170px; padding-top: 8px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.bar-fill { width: 100%; max-width: 28px; background: linear-gradient(180deg, #22b8cf, #0b7285); border-radius: 4px 4px 0 0; }
.bar em { font-style: normal; font-size: 11px; color: var(--muted); }
.list { display: grid; }
.li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; width: 100%; color: inherit; text-decoration: none !important; }
.li:last-child { border-bottom: 0; }
button.li, a.li { cursor: pointer; } button.li:hover, a.li:hover { background: var(--surface-2); }
.li small { display: block; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 22px 10px; font-size: 14px; }

/* ---------- ตาราง/แท็บ/แบดจ์ ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--ink-2); background: var(--surface-2); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 13px; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tfoot td { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--line-2); padding: 9px 10px; }
.tbl th.r, .tbl td.r { text-align: right; white-space: nowrap; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #f3f9fb; }
.tbl tr.void td { color: var(--muted); text-decoration: line-through; } .tbl tr.void td .badge { text-decoration: none; }
.tbl input { min-height: 32px !important; padding: 4px 8px !important; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-2); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tab { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.active { color: var(--pri); border-bottom-color: var(--pri); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar > select { width: auto; min-width: 140px; }
.toolbar > input.grow { min-width: 200px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: 99px; padding: 5px 13px; cursor: pointer; font-size: 13.5px; white-space: nowrap; }
.chip.active { background: var(--pri); color: #fff; border-color: var(--pri); }
.chip.check { display: inline-flex; gap: 6px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #eef2f6; color: var(--ink-2); white-space: nowrap; vertical-align: middle; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); } .badge.pri { background: var(--pri-soft); color: var(--pri); } .badge.muted { background: #eef2f6; color: var(--muted); }

/* ---------- POS ---------- */
.v-pos { margin: -18px -20px -40px; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: calc(100vh - 56px - 34px); min-height: 520px; }
.pos-left { padding: 16px 18px; overflow: auto; }
.pos-search { position: relative; display: flex; gap: 6px; align-items: center; margin-bottom: 10px; }
.pos-search > .ic { position: absolute; left: 12px; color: var(--muted); }
.pos-search input { padding-left: 38px !important; min-height: 46px !important; font-size: 16px; }
.pos-left .chips { margin-bottom: 12px; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.pcard { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-height: 122px; box-shadow: var(--shadow); border-top: 3px solid var(--line-2); }
.pcard:hover { border-color: var(--pri); }
.pcard:active { transform: scale(.98); }
.pcard b { font-size: 14px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard small { color: var(--muted); }
.pcard-cat { font-size: 11px; color: var(--muted); }
.pcard-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.pcard .price { font-weight: 700; font-size: 15px; color: var(--pri); }
.cat-air { border-top-color: #22b8cf; } .cat-part { border-top-color: #f59f00; } .cat-electric { border-top-color: #845ef7; } .cat-service { border-top-color: #40c057; }
.pos-cart { background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.cart-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 6px; }
.cart-cust { padding: 0 16px 10px; display: grid; gap: 6px; border-bottom: 1px solid var(--line); }
.cust-btn { text-align: left; width: 100%; border: 1px dashed var(--line-2); background: var(--surface-2); border-radius: 8px; padding: 8px 12px; cursor: pointer; display: grid; gap: 1px; }
.cust-btn span { font-size: 12px; color: var(--muted); } .cust-btn small { color: var(--muted); }
.cust-btn:hover:not(:disabled) { border-color: var(--pri); }
.cart-lines { flex: 1; overflow: auto; padding: 4px 16px; }
.cline { padding: 10px 0; border-bottom: 1px solid var(--line); }
.cline-top { display: flex; justify-content: space-between; gap: 6px; }
.cline-top b { font-size: 14px; font-weight: 600; } .cline-top small { display: block; color: var(--muted); }
.cline-ctl { display: grid; grid-template-columns: 112px 1fr 1fr auto; gap: 6px; align-items: end; margin-top: 6px; }
.cline-ctl label { font-size: 11.5px; color: var(--muted); display: grid; gap: 1px; }
.cline-ctl input { min-height: 34px !important; padding: 4px 7px !important; }
.cline-sum { font-size: 14.5px; white-space: nowrap; padding-bottom: 7px; min-width: 76px; text-align: right; }
.stepper { display: flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; height: 34px; }
.stepper button { width: 32px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 17px; }
.stepper input { border: 0 !important; border-radius: 0 !important; text-align: center; min-width: 0; padding: 0 !important; min-height: 32px !important; }
.sn-btn { margin-top: 6px; border: 1px solid #f1c27d; background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; font-weight: 600; }
.sn-btn.ok { border-color: #9be3b4; background: var(--ok-soft); color: var(--ok); }
.cart-foot { border-top: 1px solid var(--line); padding: 10px 16px 14px; display: grid; gap: 8px; background: var(--surface-2); }
.cart-foot label { font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.cart-foot input { min-height: 34px !important; }
.job-opt { background: var(--pri-soft); border-radius: 8px; padding: 8px 10px; display: grid; gap: 6px; font-size: 14px; }
.job-opt input[type=time] { width: 120px; }
.totals { display: grid; gap: 2px; font-size: 14px; }
.totals > div { display: flex; justify-content: space-between; }
.totals .grand { font-size: 21px; font-weight: 700; color: var(--ink); padding-top: 4px; border-top: 1px dashed var(--line-2); margin-top: 3px; }
.cart-btns { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; }
.kit-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; padding: 7px 10px; background: var(--pri-soft); border-radius: 8px; }
.kit-head small { display: block; color: var(--muted); }
.kit-line { padding-left: 10px; border-left: 3px solid var(--pri-soft); }
.cline-unit { display: grid; gap: 1px; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.cline-unit select { min-height: 34px; padding: 4px 7px; }
.cat-kit { border-top-color: var(--pri); }
.pack-head, .pack-row { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr 1.2fr 36px; gap: 6px; align-items: center; }
.pack-head { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.pack-row { margin-bottom: 6px; }
.pos-fab { display: none; }
.mobile-only { display: none; }
.sn-list { max-height: 300px; overflow: auto; display: grid; gap: 4px; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.pay-total { display: flex; justify-content: space-between; align-items: baseline; background: var(--pri-soft); padding: 12px 14px; border-radius: 10px; margin-bottom: 10px; }
.pay-total b { font-size: 26px; color: var(--pri); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.quick .btn { flex: 1; }
.pay-note { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; color: var(--muted); margin-bottom: 6px; }
.qr-box { display: grid; justify-items: center; gap: 4px; text-align: center; }
.qr-box .qr { width: min(280px, 100%); }
.sn-inline { display: grid; gap: 3px; margin-top: 4px; font-size: 13px; }
.d-qr { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.d-qr .qr { width: 110px; flex-shrink: 0; }
.slip-doc .d-qr { flex-direction: column; text-align: center; gap: 2px; margin-top: 6px; }
.slip-doc .d-qr .qr { width: 34mm; }
.pay-sum { display: grid; gap: 4px; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.pay-sum > div { display: flex; justify-content: space-between; } .pay-sum b { font-size: 17px; }
.success { text-align: center; display: grid; gap: 4px; }
.big-check { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; font-size: 30px; margin: 0 auto 6px; }
.change { font-size: 18px; margin-top: 6px; } .change b { font-size: 26px; color: var(--ok); }

/* ---------- Modal / Toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .12s ease-out; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 620px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(15, 23, 42, .3); }
.modal.sm { max-width: 440px; } .modal.lg { max-width: 920px; } .modal.xl { max-width: 1000px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 16px 18px; overflow: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
#toast-root { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 6px; width: min(460px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); font-size: 14px; transition: opacity .3s, transform .3s; }
.toast.error { background: var(--bad); } .toast.warn { background: #b45309; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.pick-list { display: grid; gap: 4px; margin-top: 10px; max-height: 55vh; overflow: auto; }
.pick { text-align: left; border: 1px solid var(--line); background: var(--surface); padding: 9px 12px; border-radius: 8px; cursor: pointer; display: grid; }
.pick:hover { border-color: var(--pri); background: var(--pri-soft); } .pick small { color: var(--muted); }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 16px; margin-bottom: 12px; }
.info-grid > div { display: grid; gap: 1px; min-width: 0; } .info-grid .full { grid-column: 1 / -1; }
.info-grid span { font-size: 12.5px; color: var(--muted); } .info-grid b { font-weight: 600; word-break: break-word; }
.sum-box { margin: 10px 0 0 auto; max-width: 340px; display: grid; gap: 3px; font-size: 14px; }
.sum-box > div { display: flex; justify-content: space-between; gap: 12px; } .sum-box .grand { font-size: 18px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 4px; }
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; padding-top: 12px; border-top: 1px solid var(--line); align-items: center; }

/* ---------- ลูกค้า ---------- */
.credit-meter { height: 8px; background: #e9eef3; border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.credit-meter > div { height: 100%; background: var(--pri); } .credit-meter > div.over { background: var(--bad); }
.aging { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.aging > div { background: var(--surface-2); border-radius: 8px; padding: 8px; display: grid; gap: 2px; min-width: 0; }
.aging span { font-size: 12px; color: var(--muted); } .aging b { font-size: 14px; }
.aging .bad { background: var(--bad-soft); } .aging .bad b { color: var(--bad); }
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.site { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 3px; }
.site small { color: var(--muted); }

/* ---------- งานช่าง ---------- */
.job-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.job-card { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; display: grid; gap: 4px; box-shadow: var(--shadow); border-left: 4px solid var(--line-2); }
.job-card:hover { border-color: var(--pri); }
.job-card.today { border-left-color: var(--pri); } .job-card.late { border-left-color: var(--bad); }
.progress { height: 5px; background: #e9eef3; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.progress > div { height: 100%; background: var(--ok); }
.queue { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.q-col { background: #e9eef3; border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 6px; min-height: 200px; }
.q-col.pending { background: #fdf3e1; }
.q-head { display: flex; justify-content: space-between; padding: 2px 4px 4px; font-size: 14px; }
.q-card { text-align: left; border: 0; background: var(--surface); border-radius: 8px; padding: 8px 10px; cursor: pointer; display: grid; gap: 2px; box-shadow: var(--shadow); font-size: 13.5px; border-left: 3px solid var(--info); }
.q-card.done { border-left-color: var(--ok); opacity: .75; } .q-card.inprogress { border-left-color: var(--pri); }
.q-card small { color: var(--muted); }
.q-free { color: var(--muted); text-align: center; padding: 18px 0; font-size: 13px; }
.job-status { display: flex; gap: 4px; margin-bottom: 14px; }
.job-status .step { flex: 1; text-align: center; padding: 6px 4px; font-size: 12.5px; background: #eef2f6; color: var(--muted); border-radius: 6px; }
.job-status .step.on { background: var(--pri); color: #fff; } .job-status .step.bad { background: var(--bad); }
.checklist { display: grid; gap: 6px; margin-bottom: 8px; } .checklist .check { align-items: flex-start; } .checklist .check input { margin-top: 2px; flex-shrink: 0; }
.photo-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-top: 6px; }
.ph { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #e9eef3; }
.ph img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.ph .icon-btn { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; }
.ph.add { display: grid; place-items: center; cursor: pointer; border: 2px dashed var(--line-2); background: var(--surface-2); color: var(--muted); font-size: 12.5px; text-align: center; padding: 6px; }
.sig-pad { width: 100%; height: 160px; border: 1px dashed var(--line-2); border-radius: 8px; background: #fff; touch-action: none; display: block; margin-bottom: 6px; }
.sig-img { max-width: 320px; width: 100%; border: 1px solid var(--line); border-radius: 8px; display: block; margin-bottom: 6px; }
.recv-line { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; padding: 10px 0; border-bottom: 1px solid var(--line); }
.recv-line > div { flex: 1 1 240px; } .recv-line label { display: grid; gap: 2px; font-size: 12.5px; color: var(--muted); } .recv-line .full { flex-basis: 100%; }

/* ---------- ตั้งค่า ---------- */
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-bottom: 12px; }
.rc { border: 1.5px solid var(--line-2); border-radius: 10px; padding: 10px 12px; cursor: pointer; display: grid; gap: 2px; }
.rc input { position: absolute; opacity: 0; pointer-events: none; }
.rc.on { border-color: var(--pri); background: var(--pri-soft); } .rc small { color: var(--muted); }
.changes { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 3px; font-size: 12.5px; color: var(--ink-2); }
.changes span { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
.danger-zone { border-color: #f5c2c2; }

/* ---------- เข้าสู่ระบบ ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 20% 10%, #d3f0f5, transparent 45%), var(--bg); }
.login-card { width: 100%; max-width: 560px; background: var(--surface); border-radius: 16px; padding: 24px; box-shadow: 0 10px 40px rgba(15, 23, 42, .12); display: grid; gap: 12px; }
.login-card .brand { padding: 0; color: var(--ink); } .login-card .brand small { color: var(--muted); }
.login-card .mode { justify-self: start; } .login-card h2 { font-size: 16px; margin-top: 6px; }
.brand.big { font-size: 19px; } .brand.big .logo { width: 46px; height: 46px; font-size: 25px; }
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.user-btn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 10px; padding: 12px; cursor: pointer; text-align: left; display: grid; gap: 2px; }
.user-btn:hover { border-color: var(--pri); background: var(--pri-soft); } .user-btn small { color: var(--muted); }
.pin { font-size: 28px; letter-spacing: .5em; text-align: center; min-height: 56px !important; }

/* ---------- เอกสาร ---------- */
.doc-tools { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.doc-preview { background: #e9eef3; padding: 16px; border-radius: 8px; overflow: auto; }
.doc { background: #fff; color: #000; width: 100%; max-width: 794px; margin: 0 auto; padding: 32px 36px; font-size: 13px; line-height: 1.45; position: relative; overflow: hidden; box-shadow: 0 2px 10px rgba(0, 0, 0, .1); }
.doc.copy::before { content: 'สำเนา'; position: absolute; top: 14px; right: 36px; border: 1.5px solid #000; padding: 1px 10px; font-weight: 700; }
.d-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #000; padding-bottom: 12px; margin-bottom: 12px; }
.d-shop-name { font-size: 17px; font-weight: 700; }
.d-title { text-align: right; flex-shrink: 0; max-width: 50%; }
.d-title h1 { font-size: 18px; margin-bottom: 6px; }
.d-meta { margin-left: auto; border-collapse: collapse; } .d-meta th { text-align: right; font-weight: 400; padding: 1px 8px 1px 0; color: #444; } .d-meta td { text-align: left; font-weight: 600; }
.d-party { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; border: 1px solid #999; border-radius: 4px; padding: 8px 12px; margin-bottom: 12px; }
.d-lbl { font-size: 11.5px; color: #555; font-weight: 600; }
.d-items { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.d-items th { background: #eee; border: 1px solid #999; padding: 5px 6px; font-weight: 600; text-align: left; }
.d-items td { border: 1px solid #bbb; padding: 5px 6px; vertical-align: top; }
.d-items .r { text-align: right; white-space: nowrap; }
.d-sub { font-size: 11px; color: #555; }
.d-sum { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.d-words { flex: 1; background: #f3f3f3; padding: 6px 10px; border-radius: 4px; font-weight: 600; }
.d-sum table { border-collapse: collapse; min-width: 280px; }
.d-sum th { text-align: left; font-weight: 400; padding: 2px 10px 2px 0; } .d-sum td { text-align: right; padding: 2px 0; white-space: nowrap; }
.d-sum .grand th, .d-sum .grand td { font-weight: 700; font-size: 14.5px; border-top: 1.5px solid #000; border-bottom: 3px double #000; padding: 4px 0; }
.d-pay, .d-note, .d-block { margin-top: 10px; } .d-foot { margin-top: 10px; text-align: center; color: #444; }
.d-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.d-check { padding: 1px 0; }
.d-photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.d-photos figure { margin: 0; } .d-photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border: 1px solid #ccc; } .d-photos figcaption { text-align: center; font-size: 11px; }
.d-sign { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 30px; margin-top: 36px; text-align: center; }
.d-sign .line { border-bottom: 1px dotted #000; height: 34px; margin-bottom: 4px; }
.d-sign .sig { height: 50px; display: block; margin: 0 auto 4px; }
.d-wm { position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%) rotate(-28deg); font-size: 56px; font-weight: 700; color: rgba(200, 0, 0, .1); white-space: nowrap; pointer-events: none; }
.doc.slip { max-width: 302px; padding: 12px; font-size: 12px; }
.doc.slip .d-head { flex-direction: column; gap: 6px; text-align: center; } .doc.slip .d-title { text-align: center; max-width: none; } .doc.slip .d-meta { margin: 0 auto; }
.doc.slip .d-party, .doc.slip .d-cols { grid-template-columns: 1fr; } .doc.slip .d-sum { flex-direction: column; } .doc.slip .d-sum table { min-width: 0; width: 100%; }
.doc.slip .d-items th:nth-child(1), .doc.slip .d-items td:nth-child(1), .doc.slip .d-items th:nth-child(5), .doc.slip .d-items td:nth-child(5) { display: none; }
.doc.slip .d-sign { grid-template-columns: 1fr; gap: 16px; } .doc.slip .d-wm { font-size: 28px; }
.doc.slip.s58 { max-width: 48mm; padding: 2mm 0; font-size: 10px; } .doc.slip.s80 { max-width: 72mm; padding: 2mm 0; }
.doc.report h1 { font-size: 18px; margin-bottom: 12px; }
/* สลิปเครื่องพิมพ์ความร้อน: ดำล้วน ตัวหนาพอให้อ่านชัด */
.slip-doc { background: #fff; color: #000; margin: 0 auto; padding: 3mm 0 8mm; font-family: var(--font); font-weight: 500; line-height: 1.35; box-shadow: 0 0 0 6px #fff, 0 2px 12px rgba(0, 0, 0, .15); word-break: break-word; }
.slip-doc.s58 { width: 48mm; font-size: 8.5pt; } .slip-doc.s80 { width: 72mm; font-size: 9.5pt; }
.slip-doc * { color: #000 !important; }
.s-c { text-align: center; } .s-b { font-weight: 700; } .s-lg { font-size: 1.2em; } .s-title { margin: 2px 0; }
.s-row { display: flex; justify-content: space-between; gap: 6px; }
.s-row span:last-child { text-align: right; white-space: nowrap; }
.s-hr { border-top: 1px dashed #000; margin: 4px 0; }
.s-item { margin-bottom: 3px; } .s-sub { font-size: .9em; }
.s-sign { margin-top: 16px; text-align: center; }
#print-area { display: none; }

@media print {
  body { background: #fff; }
  #print-area .slip-doc { box-shadow: none; padding-top: 0; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  #print-area .doc { box-shadow: none; max-width: none; padding: 0; }
  #print-area .doc.slip.s58 { max-width: 48mm; } #print-area .doc.slip.s80 { max-width: 72mm; }
  .d-wm { color: rgba(200, 0, 0, .12) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .d-items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc.report .card { box-shadow: none; break-inside: avoid; } .doc.report .btn, .doc.report a { display: none; }
}

/* ---------- มือถือ/แท็บเล็ต ---------- */
@media (max-width: 1100px) { .pos { grid-template-columns: minmax(0, 1fr) 370px; } .cline-ctl { grid-template-columns: 104px 1fr 1fr; } .cline-sum { grid-column: 1 / -1; padding: 0; } }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s ease; }
  .app.nav-open .sidebar { transform: none; box-shadow: 10px 0 30px rgba(0, 0, 0, .3); }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 55; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 10px 0 6px; }
  #view { padding: 14px 16px 40px; }
  .main > .banner { padding: 6px 16px; font-size: 13px; }
  .v-pos { margin: -14px -16px -40px; }
  .pos { display: block; height: auto; min-height: 0; }
  .pos-left { padding: 12px 16px 90px; }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .pcard { min-height: 110px; }
  .pos-cart { position: fixed; inset: 0; z-index: 70; transform: translateY(100%); transition: transform .22s ease; border: 0; }
  .pos-cart.open { transform: none; }
  .mobile-only { display: inline-flex; }
  .pos-fab { display: block; position: fixed; left: 16px; right: 16px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 40; background: var(--pri); color: #fff; border: 0; border-radius: 12px; padding: 14px; font-size: 16px; box-shadow: 0 8px 24px rgba(11, 114, 133, .4); cursor: pointer; }
  .grid-2 { grid-template-columns: 1fr; }
  .aging { grid-template-columns: repeat(3, 1fr); }
  .photo-cols { grid-template-columns: 1fr; }
  .modal-wrap { padding: 0; align-items: flex-end; }
  .modal, .modal.sm, .modal.lg, .modal.xl { max-width: none; max-height: 94vh; border-radius: 16px 16px 0 0; }
  .doc-preview { padding: 6px; }
  .doc { padding: 16px; font-size: 11.5px; }
  .d-head { flex-direction: column; } .d-title { text-align: left; max-width: none; } .d-meta { margin-left: 0; }
  .d-party, .d-cols { grid-template-columns: 1fr; }
  .d-sum { flex-direction: column; } .d-sum table { min-width: 0; width: 100%; }
}
@media (max-width: 560px) {
  .pack-head { display: none; }
  .pack-row { grid-template-columns: 1fr 1fr; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  body { font-size: 14.5px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px 12px; } .kpi b { font-size: 18px; }
  .toolbar > * { flex: 1 1 auto; }
  .toolbar > input.grow { flex-basis: 100%; min-width: 0; }
  label.inline { flex: 1 1 45%; }
  .form-grid { grid-template-columns: 1fr; }
  .job-cards { grid-template-columns: 1fr; }
  .aging { grid-template-columns: 1fr 1fr; }
  .cart-btns { grid-template-columns: 1fr 1fr; } .cart-btns .big { grid-column: 1 / -1; }
  .bars { height: 130px; gap: 3px; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .d-photos { grid-template-columns: repeat(2, 1fr); }
  .sum-box { max-width: none; }
}
