/* Packman — คำสั่งนอกแพลตฟอร์ม (xorder)
   ธีม A/B/C ยกมาจาก mockup ที่ Mai เคาะ (xorder/mockup/index.html) — ตัวแปรชุดเดียวกัน
   ปรับตาม feedback "ใช้พื้นที่เปลืองไป ต้องกระชับ": 2 คอลัมน์บนจอกว้าง · ช่องไฟครึ่งเดียว · หัวส่วนสั้น */

[hidden] { display: none !important; }   /* ต้องเป็นบรรทัดแรก — LESSONS ข้อ 25 (โดนซ้ำ 3 รอบ) */

/* ===== ชุดตัวแปร — ทุกธีมต้องกำหนดครบทุกตัว ===== */
:root, .theme-a {
  --font: "Noto Sans Thai", "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #f5f6f3; --surface: #ffffff; --surface-2: #f0f2ee;
  --border: #e4e7e1; --border-strong: #cfd4cc;
  --text: #182019; --text-2: #4b5550; --text-3: #66706a;
  --accent: #059669; --accent-strong: #047857; --accent-ink: #ffffff; --accent-soft: #e6f5ee;
  --ok: #047857; --ok-soft: #dcf5e8; --ok-ink: #065f46;
  --warn: #b45309; --warn-soft: #fdf0d8; --warn-ink: #7c3d00;
  --danger: #be123c; --danger-soft: #ffe4e6; --danger-ink: #9f1239;
  --info-soft: #e8f0fb; --info-ink: #1e4b8f;
  --commit: #c2410c; --commit-hover: #9a3412; --commit-ink: #ffffff;
  --save: #047857; --save-hover: #065f46; --save-ink: #ffffff;
  --neutral: #eceee9; --neutral-hover: #dfe3dc; --neutral-ink: #1f2a24;
  --input-bg: #ffffff; --input-border: #d3d9d0; --ring: rgba(5,150,105,.28);
  --radius: 14px; --radius-sm: 10px; --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(20,30,20,.04), 0 6px 18px rgba(20,30,20,.05);
  --shadow-lg: 0 14px 44px rgba(20,30,20,.16);
  --sec-bg: transparent; --sec-ink: #182019; --sec-sub: #66706a; --sec-num-bg: #e6f5ee; --sec-num-ink: #047857;
  --topbar-bg: rgba(245,246,243,.86); --bar-bg: rgba(255,255,255,.94);
  --chip-bg: #f0f2ee; --chip-ink: #2b352f; --chip-on-bg: #047857; --chip-on-ink: #ffffff;
  --card-ring: #059669; --pill-draft-bg: #eceee9; --pill-draft-ink: #3c463f;
  --thumb-bg: #f0f2ee; --step-done: #047857; --step-active: #0284c7; --step-todo: #cfd4cc;
  --switch-on: #047857; --switch-off: #cfd4cc; --link: #047857;
  --dd-bg: #ffffff;
}
.theme-b {
  --font: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #0f1117; --surface: rgba(255,255,255,.045); --surface-2: rgba(255,255,255,.075);
  --border: rgba(255,255,255,.09); --border-strong: rgba(255,255,255,.2);
  --text: #e8eaf0; --text-2: #b3bac7; --text-3: #8e97a8;
  --accent: #22d3ee; --accent-strong: #22d3ee; --accent-ink: #06131a; --accent-soft: rgba(34,211,238,.13);
  --ok: #34d399; --ok-soft: rgba(52,211,153,.15); --ok-ink: #8ff0c8;
  --warn: #fbbf24; --warn-soft: rgba(251,191,36,.15); --warn-ink: #fcd77f;
  --danger: #fb7185; --danger-soft: rgba(251,113,133,.16); --danger-ink: #fecdd3;
  --info-soft: rgba(96,165,250,.15); --info-ink: #a9ccff;
  --commit: #c2410c; --commit-hover: #9a3412; --commit-ink: #ffffff;
  --save: #10b981; --save-hover: #34d399; --save-ink: #052e1c;
  --neutral: rgba(255,255,255,.08); --neutral-hover: rgba(255,255,255,.15); --neutral-ink: #e8eaf0;
  --input-bg: rgba(0,0,0,.28); --input-border: rgba(255,255,255,.14); --ring: rgba(34,211,238,.38);
  --radius: 12px; --radius-sm: 9px; --radius-pill: 999px;
  --shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 18px 50px rgba(0,0,0,.6);
  --sec-bg: transparent; --sec-ink: #e8eaf0; --sec-sub: #8e97a8; --sec-num-bg: rgba(34,211,238,.13); --sec-num-ink: #22d3ee;
  --topbar-bg: rgba(15,17,23,.78); --bar-bg: rgba(19,22,30,.88);
  --chip-bg: rgba(255,255,255,.07); --chip-ink: #dfe3ea; --chip-on-bg: #22d3ee; --chip-on-ink: #06131a;
  --card-ring: #22d3ee; --pill-draft-bg: rgba(255,255,255,.1); --pill-draft-ink: #d7dbe3;
  --thumb-bg: rgba(255,255,255,.06); --step-done: #34d399; --step-active: #22d3ee; --step-todo: rgba(255,255,255,.22);
  --switch-on: #22d3ee; --switch-off: rgba(255,255,255,.22); --link: #22d3ee;
  --dd-bg: #171a23;
}
.theme-c {
  --font: "Noto Sans Thai", "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #eef1f8; --surface: #ffffff; --surface-2: #f4f6fb;
  --border: #e1e5ef; --border-strong: #c5cddd;
  --text: #151a2d; --text-2: #434a62; --text-3: #5f6781;
  --accent: #4f46e5; --accent-strong: #4338ca; --accent-ink: #ffffff; --accent-soft: #ebe9ff;
  --ok: #047857; --ok-soft: #d7f5e6; --ok-ink: #065f46;
  --warn: #b45309; --warn-soft: #fff1d6; --warn-ink: #7c3d00;
  --danger: #be123c; --danger-soft: #ffe4e6; --danger-ink: #9f1239;
  --info-soft: #e4efff; --info-ink: #1e4b8f;
  --commit: #be123c; --commit-hover: #9f1239; --commit-ink: #ffffff;
  --save: #047857; --save-hover: #065f46; --save-ink: #ffffff;
  --neutral: #e7eaf3; --neutral-hover: #d9ddea; --neutral-ink: #1f2540;
  --input-bg: #ffffff; --input-border: #cdd3e2; --ring: rgba(79,70,229,.28);
  --radius: 18px; --radius-sm: 12px; --radius-pill: 999px;
  --shadow: 0 2px 6px rgba(30,40,90,.05), 0 10px 28px rgba(30,40,90,.08);
  --shadow-lg: 0 18px 50px rgba(30,40,90,.2);
  --sec-bg: #4338ca; --sec-ink: #ffffff; --sec-sub: rgba(255,255,255,.82); --sec-num-bg: rgba(255,255,255,.22); --sec-num-ink: #ffffff;
  --topbar-bg: rgba(238,241,248,.9); --bar-bg: #ffffff;
  --chip-bg: #eef0f7; --chip-ink: #2a3150; --chip-on-bg: #151a2d; --chip-on-ink: #ffffff;
  --card-ring: #4f46e5; --pill-draft-bg: #ffe9a8; --pill-draft-ink: #6b4400;
  --thumb-bg: #f4f6fb; --step-done: #047857; --step-active: #4f46e5; --step-todo: #c5cddd;
  --switch-on: #4338ca; --switch-off: #c5cddd; --link: #4338ca;
  --dd-bg: #ffffff;
}
.theme-c .sec-1 { --sec-bg: #047857; }
.theme-c .sec-2 { --sec-bg: #4338ca; }
.theme-c .sec-3 { --sec-bg: #b45309; }
.theme-c .sec-4 { --sec-bg: #0369a1; }
.theme-c .sec-5 { --sec-bg: #be123c; }
.theme-c .sec-6 { --sec-bg: #6d28d9; }

/* ===== พื้นฐาน ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { color-scheme: light; }
html.theme-b { color-scheme: dark; }
body { background: var(--bg); font-family: var(--font); color: var(--text); font-size: 14.5px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; transition: background .25s, color .25s; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
a { color: var(--link); }
a.link, button.link { color: var(--link); text-decoration: underline; text-underline-offset: 3px; font-weight: 500;
  background: none; border: 0; cursor: pointer; padding: 0; font-size: 13px; }
svg.i { width: 17px; height: 17px; flex: none; vertical-align: -3px; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }

/* ===== แถบบน: ชื่อ · สลับสไตล์ · ปุ่มนำทาง (กลุ่มขวาสุดเสมอ — CLAUDE.md §10.7) ===== */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40; background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--border); }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 16px; }
.hdr { display: flex; align-items: center; gap: 10px; padding-block: 8px; min-height: 54px; }
.hdr .ttl { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; margin-right: auto; }
.hdr h1 { font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
.hdr .sub { font-size: 12.5px; color: var(--text-3); }
.docno { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; padding: 2px 9px;
  border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); }
.sw { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 2px; gap: 2px; flex: none; }
.sw button { white-space: nowrap; padding: 4px 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 700; color: var(--text-2); transition: background .2s, color .2s; }
.sw button[aria-pressed="true"] { background: var(--chip-on-bg); color: var(--chip-on-ink); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.nav { display: flex; gap: 6px; flex: none; margin-left: 4px; padding-left: 10px; border-left: 1px solid var(--border); }
.nav button { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: var(--radius-pill);
  background: var(--neutral); color: var(--neutral-ink); font-weight: 600; font-size: 13px; transition: background .15s, transform .1s; }
.nav button:hover:not(:disabled) { background: var(--neutral-hover); }
.nav button:active { transform: translateY(1px); }
.nav button:disabled { opacity: .38; }           /* ปุ่มย้อนกลับห้ามซ่อน ให้จางแทน — LESSONS ข้อ 20 */
.nav button .ic { font-size: 15px; line-height: 1; }
@media (max-width: 640px) { .nav button .lbl { display: none; } .nav button { padding: 0; width: 36px; justify-content: center; } .hdr h1 { font-size: 16px; } }
@media (max-width: 480px) { .sw button { padding: 4px 7px; } .sw button .lbl { display: none; } }

/* ===== แถบเตือน (ค้างจนกว่าจะปิด/ลองใหม่ — LESSONS ข้อ 36) ===== */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.4; }
.bar.err { background: var(--danger-soft); color: var(--danger-ink); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.bar.warn { background: var(--warn-soft); color: var(--warn-ink); }
.bar.info { background: var(--info-soft); color: var(--info-ink); }
.bar .msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.bar .btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.bar .x { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; opacity: .7; }
.bar .x:hover { opacity: 1; background: rgba(0,0,0,.06); }

/* ===== เนื้อหา ===== */
main.wrap { padding-block: 12px 110px; display: flex; flex-direction: column; gap: 12px; }
.cols { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 12px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (max-width: 980px) { .cols { grid-template-columns: 1fr; } }
.sec { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.theme-c .sec { border: 0; }
.sec-head { display: flex; align-items: center; gap: 9px; padding: 9px 14px 0; background: var(--sec-bg); color: var(--sec-ink); border-radius: var(--radius) var(--radius) 0 0; }
.theme-c .sec-head { padding: 8px 14px; }
.sec-num { width: 22px; height: 22px; border-radius: 50%; background: var(--sec-num-bg); color: var(--sec-num-ink); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.sec-head h2 { margin: 0; font-size: 14.5px; font-weight: 700; }
.sec-head .sub { font-size: 12px; color: var(--sec-sub); margin-left: auto; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-head .act { margin-left: auto; }
.sec-head .act + .sub { margin-left: 0; }
.sec-body { padding: 8px 14px 12px; display: flex; flex-direction: column; gap: 9px; }
.theme-c .sec-body { padding-top: 10px; }
label.lbl, .lbl-t { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 3px; letter-spacing: .01em; }
.field { display: flex; flex-direction: column; min-width: 0; }
.in { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--text);
  transition: border-color .15s, box-shadow .15s; }
.in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.in::placeholder { color: var(--text-3); opacity: .8; }
.in[readonly], .in:disabled { background: var(--surface-2); color: var(--text-2); }
.in.warn { border-color: var(--warn); }
select.in { padding-right: 28px; appearance: auto; }
textarea.in { height: auto; min-height: 58px; padding: 7px 10px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.grid-3eq { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kv { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kv .k { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.kv .v { font-size: 13.5px; color: var(--text); line-height: 1.4; overflow-wrap: anywhere; }
.kvgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.kvgrid .span2 { grid-column: 1 / -1; }
.note { display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; border-radius: 8px; background: var(--info-soft); color: var(--info-ink); font-size: 12.5px; line-height: 1.4; }
.note.warn { background: var(--warn-soft); color: var(--warn-ink); }
.note svg { flex: none; margin-top: 1px; }
details.raw summary { cursor: pointer; font-size: 12.5px; color: var(--text-3); }
details.raw pre { margin: 6px 0 0; white-space: pre-wrap; font: 12.5px/1.45 var(--font); color: var(--text-2); background: var(--surface-2); padding: 8px 10px; border-radius: 8px; }

/* ปุ่ม — สีตามความหมายของการกด (Mai 2026-09-13) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: var(--radius-sm); font-weight: 700; font-size: 13.5px;
  transition: background .15s, transform .1s, box-shadow .15s, filter .15s; white-space: nowrap; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.accent { background: var(--accent-strong); color: var(--accent-ink); }
.btn.accent:hover:not(:disabled) { filter: brightness(1.06); }
.btn.commit { background: var(--commit); color: var(--commit-ink); box-shadow: 0 6px 18px rgba(194,65,12,.22); }
.btn.commit:hover:not(:disabled) { background: var(--commit-hover); }
.btn.save { background: var(--save); color: var(--save-ink); }
.btn.save:hover:not(:disabled) { background: var(--save-hover); }
.btn.neutral { background: var(--neutral); color: var(--neutral-ink); }
.btn.neutral:hover:not(:disabled) { background: var(--neutral-hover); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn.icon { width: 32px; padding: 0; }
.btn .spin, .spin { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* pill / chip */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.pill.draft { background: var(--pill-draft-bg); color: var(--pill-draft-ink); }
.pill.ok { background: var(--ok-soft); color: var(--ok-ink); }
.pill.warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill.info { background: var(--info-soft); color: var(--info-ink); }
.pill.err { background: var(--danger-soft); color: var(--danger-ink); }
.pill.cancel { background: var(--neutral); color: var(--text-3); text-decoration: line-through; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: var(--radius-pill); background: var(--chip-bg); color: var(--chip-ink);
  font-weight: 600; font-size: 12.5px; border: 1px solid transparent; transition: background .15s, color .15s; max-width: 100%; }
.chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { border-color: var(--border-strong); }
.chip[aria-pressed="true"] { background: var(--chip-on-bg); color: var(--chip-on-ink); }
.chip .tag { font-size: 10.5px; font-weight: 600; opacity: .75; }
.chip.add { border: 1px dashed var(--border-strong); background: transparent; }
.chip.add[aria-pressed="true"] { border-style: solid; background: var(--chip-on-bg); color: var(--chip-on-ink); }
.chip.doc { height: 26px; padding: 0 6px 0 9px; gap: 3px; font-size: 12px; }
.chip.doc .pr { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; }
.chip.doc .pr:hover { background: rgba(0,0,0,.1); }
.warnchip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-ink); font-size: 11.5px; font-weight: 600; line-height: 1.5; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-weight: 500; font-size: 13px; position: relative; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .tr { width: 38px; height: 22px; border-radius: 999px; background: var(--switch-off); position: relative; transition: background .2s; flex: none; }
.toggle .tr::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.toggle input:checked + .tr { background: var(--switch-on); }
.toggle input:checked + .tr::after { transform: translateX(16px); }
.toggle input:focus-visible + .tr { outline: 3px solid var(--ring); outline-offset: 2px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 3px; max-width: 100%; }
.seg button { padding: 6px 12px; border-radius: calc(var(--radius-sm) - 3px); font-weight: 600; font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; transition: background .15s, color .15s; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.theme-b .seg button[aria-pressed="true"] { background: rgba(255,255,255,.12); }

/* ตารางทั่วไป (หน้าแรก) */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.link { cursor: pointer; }
.tbl tr.link:hover td { background: var(--accent-soft); }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl td.nw { white-space: nowrap; }
.tbl .empty { padding: 22px 10px; text-align: center; color: var(--text-3); }
.tbl tr.unknown td { background: color-mix(in srgb, var(--warn-soft) 70%, transparent); }
.tbl tr.unknown td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.toolrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolrow .in { height: 34px; }
.toolrow .search { flex: 1 1 200px; min-width: 0; }
.toolrow select.in { width: auto; flex: none; }
.pager { display: flex; gap: 6px; align-items: center; margin-left: auto; font-size: 12.5px; color: var(--text-3); }
.pager .btn { height: 30px; padding: 0 9px; }
.stages { display: inline-flex; gap: 4px; align-items: center; }
.stg { width: 11px; height: 11px; border-radius: 50%; background: var(--step-todo); display: inline-block; }
.stg.SENDING { background: var(--step-active); animation: blink 1s ease-in-out infinite; }
.stg.SENT { background: var(--step-done); }
.stg.ERROR { background: var(--danger); }
.stg.UNKNOWN { background: var(--warn); box-shadow: 0 0 0 2px var(--warn-soft); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.copy { font-size: 12px; padding: 1px 6px; border-radius: 6px; background: var(--neutral); color: var(--neutral-ink); margin-left: 4px; }
.copy:hover { background: var(--neutral-hover); }

/* ที่อยู่ — ค้นหาตำบล */
.smart { position: relative; }
.smart .in { padding-left: 32px; }
.smart .ico { position: absolute; left: 10px; top: 10px; color: var(--text-3); pointer-events: none; }
.dd { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--dd-bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 30; overflow: hidden; max-height: 300px; overflow-y: auto; }
.dd button { display: flex; width: 100%; text-align: left; padding: 8px 11px; gap: 8px; align-items: baseline; border-bottom: 1px solid var(--border); font-size: 13px; }
.dd button:last-child { border-bottom: 0; }
.dd button:hover, .dd button:focus-visible { background: var(--accent-soft); outline: none; }
.dd .z { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-3); font-size: 12px; }
.dd b { font-weight: 700; }
.dd .path { color: var(--text-2); font-size: 12.5px; }
.dd .empty { padding: 9px 11px; color: var(--text-3); font-size: 12.5px; }
.addr-fields { display: flex; flex-direction: column; gap: 8px; transition: opacity .2s; }
.addr-fields.locked { opacity: .6; }

/* รายการสินค้า */
.items { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.item, .items .head { display: grid; grid-template-columns: 44px minmax(0, 1.6fr) 108px 96px 100px 84px; gap: 8px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.items .head { padding: 5px 10px; font-size: 11.5px; font-weight: 600; color: var(--text-3); background: var(--surface-2); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.items .head span:nth-child(n+3) { text-align: right; }
.item:last-child { border-bottom: 0; }
.item .sku { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.item .nm { font-weight: 600; line-height: 1.3; font-size: 13.5px; overflow-wrap: anywhere; }
.item .col { text-align: right; }
.item .col .cap { display: none; font-size: 11px; color: var(--text-3); font-weight: 600; }
.item .price { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.item .unit { font-size: 11.5px; color: var(--text-3); }
.item .del { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: var(--text-3); margin-left: auto; }
.item .del:hover { background: var(--danger-soft); color: var(--danger); }
.wman .in { width: 74px; height: 30px; padding: 0 7px; text-align: right; font-variant-numeric: tabular-nums; border-color: var(--warn); display: inline-block; }
.items .empty { padding: 18px; text-align: center; color: var(--text-3); font-size: 13px; }
@media (max-width: 700px) {
  .items .head { display: none; }
  .item { grid-template-columns: 44px 1fr; grid-template-areas: "th nm" "qty pr" "wt tot"; row-gap: 6px; }
  .item .thumb { grid-area: th; } .item .info { grid-area: nm; } .item .c-qty { grid-area: qty; text-align: left; }
  .item .c-pr { grid-area: pr; } .item .c-wt { grid-area: wt; text-align: left; } .item .c-tot { grid-area: tot; }
  .item .col .cap { display: block; }
}
.step { display: inline-flex; align-items: center; border: 1px solid var(--input-border); border-radius: var(--radius-pill); background: var(--input-bg); overflow: hidden; height: 30px; }
.step button { width: 28px; height: 30px; display: grid; place-items: center; font-size: 16px; font-weight: 700; color: var(--text-2); }
.step button:hover { background: var(--surface-2); }
.step input { width: 40px; height: 30px; text-align: center; border: 0; background: transparent; font-weight: 700; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.step input::-webkit-inner-spin-button, .step input::-webkit-outer-spin-button { -webkit-appearance: none; }
.thumb { position: relative; width: 44px; height: 44px; border-radius: 9px; background: var(--thumb-bg); border: 1px solid var(--border); display: grid; place-items: center; cursor: zoom-in; overflow: visible; }
.thumb img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; display: block; }
.thumb .ph { font-size: 18px; opacity: .5; }
.thumb .zoom { position: absolute; left: 52px; top: -10px; width: 320px; height: 320px; padding: 10px; border-radius: 14px; background: var(--dd-bg); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  z-index: 35; opacity: 0; visibility: hidden; transform: scale(.94) translateX(-6px); transform-origin: left top; transition: opacity .16s ease, transform .18s ease, visibility 0s .16s; display: grid; grid-template-rows: 1fr auto; gap: 6px; }
.thumb .zoom img { width: 100%; height: 100%; object-fit: contain; max-height: 262px; }
.thumb .zoom .cap { font-size: 12px; color: var(--text-2); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb.flip .zoom { left: auto; right: 52px; transform-origin: right top; transform: scale(.94) translateX(6px); }
.thumb:hover .zoom, .thumb.open .zoom { opacity: 1; visibility: visible; transform: none; transition: opacity .16s ease, transform .18s ease, visibility 0s; }
@media (max-width: 700px) { .thumb .zoom, .thumb.flip .zoom { position: fixed; left: 50%; top: 50%; right: auto; width: min(320px, 88vw); height: min(320px, 88vw); transform: translate(-50%, -50%) scale(.94); }
  .thumb:hover .zoom, .thumb.open .zoom { transform: translate(-50%, -50%); } }
.tot { display: flex; justify-content: flex-end; gap: 18px; flex-wrap: wrap; }
.tot .kv .k, .tot .kv .v { text-align: right; }
.tot .kv .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* กล่อง + น้ำหนัก */
.boxes { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.box { display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 4px 10px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); min-width: 84px;
  transition: border-color .15s, background .15s; text-align: left; }
.box b { font-size: 13px; }
.box span { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.box:hover { border-color: var(--border-strong); }
.box[aria-pressed="true"] { border-color: var(--card-ring); background: var(--accent-soft); }
.boxes select.in { width: auto; height: 36px; }
.custom { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 320px; }
.wrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wrow .in { width: 120px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.auto { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ok-ink); background: var(--ok-soft); padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.auto.off { color: var(--warn-ink); background: var(--warn-soft); }

/* ขนส่ง — แถวกระชับ: โลโก้ · ชื่อ · ราคา · วัน */
.couriers { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.cr { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border); background: var(--surface); transition: background .15s; }
.cr:last-child { border-bottom: 0; }
.cr:hover { background: var(--surface-2); }
.cr[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--card-ring); }
.cr .logo { width: 30px; height: 30px; border-radius: 8px; background: #fff; border: 1px solid var(--border); object-fit: contain; display: block; }
.cr .mono { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 11px; background: var(--neutral); color: var(--neutral-ink); }
.cr .nm { font-weight: 700; font-size: 13.5px; line-height: 1.25; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cr .cond { font-size: 11.5px; color: var(--text-3); line-height: 1.3; }
.cr .pr { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cr .pr small { font-size: 11px; font-weight: 600; color: var(--text-3); margin-right: 1px; }
.cr .days { font-size: 12px; color: var(--text-2); white-space: nowrap; min-width: 46px; text-align: right; }
.cr .badge { font-size: 10.5px; padding: 0 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-ink); font-weight: 700; }
.couriers .empty { padding: 12px; text-align: center; color: var(--text-3); font-size: 13px; }

/* พัสดุ (หลายใบต่อออเดอร์) */
.parcels { display: flex; flex-direction: column; gap: 10px; }
.parcel { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 7px; background: var(--surface); }
.parcel .phead { display: flex; align-items: center; gap: 8px; }
.parcel .phead b { font-size: 13.5px; }
.parcel .phead .psum { font-size: 12px; color: var(--text-3); margin-left: auto; font-variant-numeric: tabular-nums; }
.parcel .phead .del { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: var(--text-3); }
.parcel .phead .del:hover { background: var(--danger-soft); color: var(--danger); }
.parcel .remark { height: 32px; font-size: 13px; }
.parcel.ro { background: var(--surface-2); }
.trow { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); font-size: 13px; flex-wrap: wrap; }
.trow .stg { width: 12px; height: 12px; }
.tparcels { display: flex; flex-direction: column; gap: 4px; }
.tparcels .trow .no { font-variant-numeric: tabular-nums; letter-spacing: .04em; font-weight: 700; }
.tparcels .trow .stage { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 12px; }
.tparcels .trow .btn { margin-left: auto; }

/* ชำระเงิน */
.cod { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--warn-soft); display: grid; grid-template-columns: 170px 1fr; gap: 10px; align-items: end; }
.cod .in { font-size: 15px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.cod p { margin: 0; font-size: 12px; color: var(--warn-ink); line-height: 1.4; padding-bottom: 6px; }
@media (max-width: 560px) { .cod { grid-template-columns: 1fr; } }

/* แถบล่างติดจอ */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: var(--bar-bg); border-top: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px); padding-bottom: env(safe-area-inset-bottom, 0px); box-shadow: 0 -8px 30px rgba(0,0,0,.06); }
.actionbar .wrap { display: flex; align-items: center; gap: 10px; padding-block: 9px; }
.sumry { display: flex; flex-direction: column; gap: 1px; min-width: 0; margin-right: auto; }
.sumry .s1 { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sumry .s2 { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .actionbar .btn { padding: 0 12px; } .actionbar .btn .lbl-long { display: none; } }

/* ตัวติดตาม 3 ขั้น (หลังยืนยัน) */
.track { display: grid; grid-template-columns: repeat(3, 1fr); position: relative; padding: 6px 0 2px; }
.track::before { content: ""; position: absolute; left: 16.6%; right: 16.6%; top: 22px; height: 3px; background: var(--step-todo); border-radius: 2px; }
.track .line { position: absolute; left: 16.6%; top: 22px; height: 3px; background: var(--step-done); border-radius: 2px; width: 0; transition: width .3s; }
.st { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 5px; padding: 0 4px; }
.st .c { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 3px solid var(--step-todo); background: var(--surface); color: var(--text-3); font-weight: 700; font-size: 13px; }
.theme-b .st .c { background: #171a23; }
.st.SENT .c { background: var(--step-done); border-color: var(--step-done); color: #fff; }
.st.SENDING .c { border-color: var(--step-active); color: var(--step-active); animation: ring 1.6s ease-in-out infinite; }
.st.ERROR .c { border-color: var(--danger); color: var(--danger); }
.st.UNKNOWN .c { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
@keyframes ring { 0%, 100% { box-shadow: 0 0 0 0 rgba(2,132,199,.35); } 50% { box-shadow: 0 0 0 8px rgba(2,132,199,0); } }
.st .t { font-weight: 700; font-size: 12.5px; line-height: 1.3; }
.st .d { font-size: 11.5px; color: var(--text-3); overflow-wrap: anywhere; }
.st.SENDING .d { color: var(--step-active); font-weight: 600; }
.st.ERROR .d { color: var(--danger); }
.st.UNKNOWN .d { color: var(--warn-ink); font-weight: 600; }
.trk { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 9px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.trk .no { font-size: 16px; font-weight: 700; letter-spacing: .05em; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .trk { grid-template-columns: 1fr; } .trk .btn { width: 100%; } }

/* ตั้งค่า */
.cklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; }
.ck { display: grid; grid-template-columns: auto 26px 1fr auto; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.ck:hover { background: var(--surface-2); }
.ck img { width: 26px; height: 26px; border-radius: 6px; object-fit: contain; background: #fff; border: 1px solid var(--border); }
.ck .code { font-size: 11px; color: var(--text-3); }
.ck input[type="checkbox"], .ck input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.ck .def { font-size: 11px; color: var(--text-3); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

/* dialog / toast / skeleton */
dialog.dlg { border: 0; border-radius: var(--radius); background: var(--dd-bg); color: var(--text); padding: 0; box-shadow: var(--shadow-lg); width: min(440px, calc(100vw - 32px)); font-family: var(--font); }
dialog.dlg::backdrop { background: rgba(10,14,12,.45); }
dialog.dlg .body { padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 8px; }
dialog.dlg h3 { margin: 0; font-size: 16px; }
dialog.dlg p { margin: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.5; overflow-wrap: anywhere; white-space: pre-line; }
dialog.dlg .acts { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 16px; }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 10px); z-index: 60; background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.skel { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; margin: 8px 0; }
@keyframes sk { to { background-position: -200% 0; } }
.readonly-banner { font-size: 12.5px; color: var(--text-3); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
