@font-face{font-family:'Sarabun';font-style:normal;font-weight:400;font-display:swap;src:url(/fonts/sarabun-thai-400.woff2) format('woff2');unicode-range:U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;}
@font-face{font-family:'Sarabun';font-style:normal;font-weight:400;font-display:swap;src:url(/fonts/sarabun-latin-400.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}
@font-face{font-family:'Sarabun';font-style:normal;font-weight:500;font-display:swap;src:url(/fonts/sarabun-thai-500.woff2) format('woff2');unicode-range:U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;}
@font-face{font-family:'Sarabun';font-style:normal;font-weight:500;font-display:swap;src:url(/fonts/sarabun-latin-500.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}
@font-face{font-family:'Sarabun';font-style:normal;font-weight:600;font-display:swap;src:url(/fonts/sarabun-thai-600.woff2) format('woff2');unicode-range:U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;}
@font-face{font-family:'Sarabun';font-style:normal;font-weight:600;font-display:swap;src:url(/fonts/sarabun-latin-600.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}
@font-face{font-family:'Sarabun';font-style:normal;font-weight:700;font-display:swap;src:url(/fonts/sarabun-thai-700.woff2) format('woff2');unicode-range:U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;}
@font-face{font-family:'Sarabun';font-style:normal;font-weight:700;font-display:swap;src:url(/fonts/sarabun-latin-700.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}
/* FlowExpress POS — โทนสี light/dark */
:root {
  color-scheme: light;
  --page: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfa;
  --text: #14181f;
  --text-2: #5b6470;
  --muted: #8b95a3;
  --border: rgba(20, 24, 31, 0.12);
  --brand: #2a78d6;
  --brand-ink: #ffffff;
  --ems: #eb6834;
  --flash: #eda100;
  --kex: #1baf7a;
  --spx: #7c3aed;   /* SPX (Shopee Xpress) — ม่วง ให้ต่างจาก EMS (แดงส้ม) */
  --good: #0ca30c;
  --warn: #d03b3b;
  --shadow: 0 1px 3px rgba(20, 24, 31, 0.08), 0 1px 2px rgba(20, 24, 31, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0f13;
    --surface: #1a1d23;
    --surface-2: #21252c;
    --text: #f0f2f5;
    --text-2: #b3bcc9;
    --muted: #7d8896;
    --border: rgba(255, 255, 255, 0.12);
    --brand: #3987e5;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Sarabun', system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", sans-serif;
  background: var(--page);
  color: var(--text);
  font-size: 14px;
}
button, input, select { font: inherit; }

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--text-2); font-size: 13px; }
.btn {
  cursor: pointer; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); padding: 7px 14px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { opacity: .92; }

/* ---- layout ---- */
main { max-width: 1180px; margin: 0 auto; padding: 16px 18px 60px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 820px) { .grid2 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card h2 {
  font-size: 13px; margin: 0 0 12px; font-weight: 700; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .04em;
}
.field { margin-bottom: 10px; position: relative; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface-2); color: var(--text);
}
.field input:focus, .field select:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.row { display: flex; gap: 10px; }
/* แถวตัวกรองที่มีทั้งช่องกรอกและปุ่มในบรรทัดเดียว
   ⚠️ .field มี margin-bottom 10px — คู่กับ align-items:flex-end จะดันช่องกรอกสูงกว่าปุ่ม 10px
      (บทเรียนเดิมจากหน้า "ส่งเลขให้ลูกค้า") จึงล้าง margin แล้วบังคับความสูงให้เท่ากันที่เดียว */
.filter-row { align-items: flex-end; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.filter-row .field { margin-bottom: 0; }
.filter-row:last-child { margin-bottom: 0; }
.filter-row .btn { height: 38px; }
.filter-row .field input, .filter-row .field select { height: 38px; }
.row .field { flex: 1; }

/* autocomplete dropdown */
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; margin-top: 2px;
}
.ac-list div { padding: 8px 11px; cursor: pointer; font-size: 13px; }
.ac-list div:hover, .ac-list div.active { background: color-mix(in srgb, var(--brand) 12%, transparent); }

/* ---- courier buttons ---- */
.couriers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .couriers { grid-template-columns: 1fr; } }
.courier {
  position: relative; border: 2px solid var(--border); border-radius: 12px;
  padding: 14px; text-align: center; background: var(--surface-2);
  cursor: pointer; transition: transform .05s, border-color .1s;
}
/* พื้นสีอ่อน + ขอบตามสีแบรนด์ของขนส่ง (แยกการ์ดออกจากกันด้วยสายตา)
   ผสมกับ var(--surface) → โหมดมืดได้เฉดเข้มเองไม่ต้องเขียนซ้ำ
   ⚠️ ต้องอยู่ "ก่อน" .courier.selected ไม่งั้นทับขอบของใบที่เลือกอยู่ (specificity เท่ากัน) */
.courier.ems   { background: color-mix(in srgb, var(--ems) 9%, var(--surface));   border-color: color-mix(in srgb, var(--ems) 38%, transparent); }
.courier.flash { background: color-mix(in srgb, var(--flash) 11%, var(--surface)); border-color: color-mix(in srgb, var(--flash) 40%, transparent); }
.courier.kex   { background: color-mix(in srgb, var(--kex) 9%, var(--surface));   border-color: color-mix(in srgb, var(--kex) 38%, transparent); }
.courier.spx   { background: color-mix(in srgb, var(--spx) 8%, var(--surface));   border-color: color-mix(in srgb, var(--spx) 38%, transparent); }
.courier:hover:not(.disabled) { transform: translateY(-1px); }
.courier.selected { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.courier.disabled { opacity: .5; cursor: not-allowed; }
.courier .name { font-weight: 700; font-size: 17px; }
/* โลโก้ขนส่งแทนชื่อบนการ์ด (FLASH / FLASH Eco) — สูงเท่าบรรทัดชื่อเดิม ไม่ดันการ์ดให้สูงขึ้น */
/* การ์ดที่มีโลโก้ (FLASH / FLASH Eco): โลโก้คอลัมน์ซ้ายกลางแนวตั้ง · ข้อความคอลัมน์ขวา */
.courier.has-logo, #view-send .courier.has-logo { position: relative; padding-left: 86px; }
.courier.has-logo .name, .courier.has-logo .cost { white-space: nowrap; }
.courier.has-logo .clogo { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 67px; height: auto; max-height: 80%; object-fit: contain; }
/* โลโก้ FLASH ตัวบาง/เตี้ยกว่า Eco — ขยายให้ดูหนักเท่ากัน */
.courier.has-logo .clogo-flash { width: 72px; left: 10px; }
.courier.has-logo .clogo-eco { width: 67px; }
/* KEX Eco / SPX Eco โลโก้ซ้อน 2 ชั้น ตัวเล็กกว่า — ขยายให้อ่านออก (เจ้าของระบบสั่ง 2026-11-06) */
.courier.has-logo:has(.clogo-big), #view-send .courier.has-logo:has(.clogo-big) { padding-left: 104px; }
.courier.has-logo .clogo-big { width: 86px; left: 10px; max-height: 88%; }
.courier .name.ems { color: var(--ems); }
.courier .name.flash { color: var(--flash); }
.courier .name.kex { color: var(--kex); }
.courier .name.spx { color: var(--spx); }
/* 🍊 ผลไม้ (SHIPPOP Fruit) */
.courier.fruit { background: color-mix(in srgb, #2e9d4a 9%, var(--surface)); border-color: color-mix(in srgb, #2e9d4a 40%, transparent); }
.courier .name.fruit { color: #2e9d4a; }
.cart-item .tag.fruit { color: #2e9d4a; border-color: color-mix(in srgb, #2e9d4a 45%, transparent); }
.courier .price { font-size: 30px; font-weight: 800; line-height: 1.1; margin: 6px 0; font-variant-numeric: tabular-nums; }
.courier .cost { font-size: 12px; color: var(--text-2); }
.courier .warn { font-size: 12px; color: var(--warn); font-weight: 600; }
.courier .sp { font-size: 11.5px; color: var(--flash); margin-top: 2px; }
/* ตาราง "ดูรายการ" ของเมนูส่งเลขให้ลูกค้า — แถวไล่สีตามขนส่ง (สีแบรนด์ชุดเดียวกับป้ายขนส่งทั้งระบบ) */
.st-list th, .st-list td { padding: 5px 8px; font-size: 12.5px; }
.st-list tr.c-ems td { background: color-mix(in srgb, var(--ems) 7%, var(--surface)); }
.st-list tr.c-flash td { background: color-mix(in srgb, var(--flash) 8%, var(--surface)); }
.st-list tr.c-kex td { background: color-mix(in srgb, var(--kex) 7%, var(--surface)); }
.st-list tr.c-spx td { background: color-mix(in srgb, var(--spx) 7%, var(--surface)); }
/* เน้นคอลัมน์เลขพัสดุ — เป็นค่าที่พนักงานต้องกวาดตาหา/คัดลอกบ่อยสุดในตารางนี้ */
.st-list td.trk { font-weight: 700; color: var(--brand); letter-spacing: .2px; }

/* หมายเหตุใต้ราคาการ์ด Flash — บอกว่าราคานี้รวมค่า Flash Care แล้ว */
.courier .fcnote { font-size: 11.5px; color: var(--flash); font-weight: 600; margin-top: 2px; line-height: 1.25; }
.courier .rec {
  position: absolute; top: -9px; right: 8px; background: var(--good); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
}
.courier .user { font-size: 11px; color: var(--muted); margin-top: 3px; }

.hint { color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }

/* ---- รูปถ่ายพัสดุ (การ์ดคั่นระหว่างรายละเอียดพัสดุกับเลือกขนส่ง) ---- */
/* ตั้งใจให้สูงน้อย: หัวเรื่อง + แถบรูปย่อแถวเดียว (การ์ดเปล่า ~90px) */
#view-send .card-photo, #view-parcelcheck .card-photo { padding-top: 10px; padding-bottom: 10px; }
.card-photo h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.card-photo:has(.photo-strip.empty) h2 { margin-bottom: 0; }
.card-photo h2 .ph-count { font-size: 12px; font-weight: 500; color: var(--text-2); }
.card-photo h2 .btn.sm { margin-left: auto; }
.photo-strip { display: flex; gap: 8px; align-items: center; min-height: 44px; flex-wrap: wrap; }
/* ยังไม่มีรูป = ไม่ต้องมีแถบว่าง ๆ กินที่ (เหลือแค่หัวเรื่อง + ปุ่มเพิ่มรูป) */
.photo-strip.empty { display: none; }
.photo-strip .ph-empty { font-size: 12.5px; color: var(--muted); }
.ph-item { position: relative; width: 56px; height: 56px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface-2); cursor: zoom-in; flex: 0 0 auto; }
.ph-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-item .ph-x { position: absolute; top: 0; right: 0; border: none; cursor: pointer; line-height: 1;
  font-size: 11px; padding: 2px 4px; border-radius: 0 0 0 6px; background: rgba(0,0,0,.55); color: #fff; }
.ph-item .ph-x:hover { background: var(--warn); }
/* ป้ายบอกว่าพัสดุในตะกร้ามีรูปกี่รูป */
.cart-item .ph { font-size: 11px; color: var(--text-2); }
/* เวทีกล้อง — สูงคงที่ ไม่ให้โมดัลกระโดดตอนสลับภาพสด/ภาพที่ถ่าย */
.cam-stage { background: #000; border-radius: 10px; overflow: hidden; height: min(52vh, 420px);
  display: flex; align-items: center; justify-content: center; }
.cam-stage video, .cam-stage img { width: 100%; height: 100%; object-fit: contain; }
.err { color: var(--warn); font-size: 13px; }

/* ---- POS layout: main + sticky sidebar ---- */
/* ===== Sidebar shell (POS/หน้าร้าน) — เมนูซ้ายแบบ me2plus ===== */
.shell { display: flex; align-items: stretch; min-height: 100vh; }
/* ซ่อน view ที่ไม่ active ให้ชนะ display ของ .pos-layout/.stub-view (UA [hidden] แพ้ author) */
.app-view[hidden] { display: none !important; }
/* ไทม์ไลน์แนวนอน (ติดตามพัสดุ) — จุดเทา=ผ่านมา, เขียว=ปัจจุบัน, ลูกศรเทาเชื่อม */
.htl { display: flex; align-items: flex-start; overflow-x: auto; padding: 12px 4px 6px; }
.htl-step { flex: 0 0 auto; width: 104px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.htl-node { height: 22px; display: flex; align-items: center; justify-content: center; }
.htl-dot { width: 12px; height: 12px; border-radius: 50%; background: #c4ccd6; }
.htl-dot.now { width: 22px; height: 22px; background: var(--good); box-shadow: 0 0 0 5px color-mix(in srgb, var(--good) 28%, transparent); }
.htl-label { margin-top: 10px; font-size: 12.5px; font-weight: 600; line-height: 1.25; color: var(--text); }
.htl-time { margin-top: 3px; font-size: 11px; color: var(--text-2); line-height: 1.35; font-variant-numeric: tabular-nums; }
.htl-arrow { flex: 1 1 34px; min-width: 38px; height: 22px; position: relative; }
.htl-arrow::before { content: ''; position: absolute; left: 0; right: 9px; top: 50%; height: 3px; transform: translateY(-50%); background: #c4ccd6; border-radius: 2px; }
.htl-arrow::after { content: ''; position: absolute; right: 0; top: 50%; transform: translateY(-50%); border-left: 9px solid #c4ccd6; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.shell-main { flex: 1; min-width: 0; }
.sidebar { flex: 0 0 224px; width: 224px; background: var(--surface);
  border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 8px 0 20px; }
.side-brand { margin: 6px 12px 12px; padding: 8px 12px; }
.side-brand img { display: block; width: 100%; height: auto; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 18px; color: var(--text-2);
  text-decoration: none; font-size: 13.5px; font-weight: 500; cursor: pointer; border-left: 3px solid transparent; white-space: nowrap; }
/* ⚠️ display:flex ข้างบนชนะ attribute hidden (UA stylesheet แพ้ author) — เมนูที่ hidden จะโชว์ตลอด
   ถ้าไม่มีกฎนี้ (เจอจริงกับ "พัสดุร้านย่อย" ที่ปิดธงแล้วแต่ยังโผล่ 2026-08-16) */
.nav-item[hidden] { display: none !important; }
.nav-item .ico { width: 20px; flex: 0 0 20px; display: flex; align-items: center; justify-content: center; }
.nav-item .ico svg { width: 19px; height: 19px; }
.nav-item svg { stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: color-mix(in srgb, #EE7A1F 8%, transparent); color: var(--text); }
.nav-item.active { background: color-mix(in srgb, #EE7A1F 15%, transparent); color: #DC6512; font-weight: 600; border-left-color: #EE7A1F; }
.nav-sep { height: 1px; background: var(--border); margin: 9px 16px; }
.brand-logo-sm { height: 26px; width: auto; vertical-align: middle; }
.only-mobile { display: none; }
.stub-view { max-width: 1180px; margin: 0 auto; padding: 16px 18px 60px; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
  .sidebar.open { transform: translateX(0); }
  .nav-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; }
  .only-mobile { display: inline-flex; }
}

/* คอลัมน์ขวา 330px (เดิม 360) — ที่ว่างที่ได้ยกไปให้ช่อง "ชื่อ-สกุล"/"ที่อยู่" ของผู้ส่ง-ผู้รับ
   วัดแล้วบรรทัดในตะกร้าไม่ล้มที่ความกว้างนี้ (ชื่อผู้รับย่อด้วย ellipsis อยู่แล้ว) */
.pos-layout { display: grid; grid-template-columns: 1fr 330px; gap: 16px; align-items: start; }
/* จอกว้างมีที่เหลือ → ขยายคอลัมน์ตะกร้า (เจ้าของระบบสั่ง 2026-10-20) */
@media (min-width: 1700px) { .pos-layout { grid-template-columns: 1fr 380px; } }
@media (min-width: 2000px) { .pos-layout { grid-template-columns: 1fr 440px; } }
@media (max-width: 1000px) { .pos-layout { grid-template-columns: 1fr; } }
.pos-side { position: sticky; top: 70px; }

/* add-parcel bar */
.addbar { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.addbar .btn { padding: 10px 18px; font-weight: 600; }

/* ---- cart ---- */
.cart-list { display: flex; flex-direction: column; gap: 8px; }
/* พัสดุในตะกร้า = 1 บรรทัดยาว (ขนส่ง · ผู้รับ · เลข · ราคา · ลบ) คลิกที่บรรทัดเพื่อดูรายละเอียด */
.cart-item {
  display: flex; gap: 7px; align-items: center;
  padding: 6px 10px; min-height: 42px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
  font-size: 13px;
}
/* เฉพาะพัสดุที่คลิกเปิดรายละเอียดได้ (สินค้าไม่มีหน้ารายละเอียด) */
.cart-item[data-open-parcel] { cursor: pointer; }
.cart-item[data-open-parcel]:hover { border-color: var(--brand); }
.cart-item .t { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-item .s { color: var(--text-2); font-size: 12px; }
.cart-item .tag { flex: 0 0 auto; font-size: 10.5px; padding: 1px 6px; }
.cart-item .tag.ems { color: var(--ems); border-color: color-mix(in srgb, var(--ems) 45%, transparent); }
.cart-item .tag.flash { color: var(--flash); border-color: color-mix(in srgb, var(--flash) 45%, transparent); }
.cart-item .tag.kex { color: var(--kex); border-color: color-mix(in srgb, var(--kex) 45%, transparent); }
.cart-item .tag.spx { color: var(--spx); border-color: color-mix(in srgb, var(--spx) 45%, transparent); }

/* รายละเอียดในโมดัล (พัสดุ/Flash Care) — ใช้ prefix ik- (info key/value)
   ⚠️ ห้ามใช้ชื่อ .dt-* ซ้ำกับตารางลูกหนี้ (debtors.js ใช้ `tr.dt-row` เป็นแถวตาราง)
   เคยชนกันแล้วทำให้ทุกแถวในหน้าลูกหนี้กลายเป็น flex คอลัมน์เพี้ยนทั้งตาราง */
.ik-sec { font-size: 11.5px; font-weight: 700; color: var(--text-2); text-transform: uppercase;
  letter-spacing: .04em; margin: 12px 0 5px; border-bottom: 1px solid var(--border); padding-bottom: 3px; }
.ik-sec:first-child { margin-top: 0; }
.ik-row { display: flex; gap: 10px; padding: 2px 0; font-size: 13px; }
.ik-row .k { flex: 0 0 108px; color: var(--text-2); }
.ik-row .v { flex: 1; min-width: 0; word-break: break-word; }
/* เลข tracking ที่ดึงมาแล้ว (EMS ออกเลขตั้งแต่กดปุ่ม) — ตัวพิมพ์เดียวกันหมดเพื่ออ่านเทียบกับสติกเกอร์ง่าย */
.cart-item .trk { font-family: ui-monospace, "Consolas", monospace; font-size: 13.5px; letter-spacing: 0;
  color: var(--brand); font-weight: 600; flex: 0 0 auto; }
/* เลขที่กดได้ = พิมพ์ลาเบลใบนั้น — ต้องดูออกว่าคลิกได้ ไม่ใช่ข้อความเฉย ๆ */
.cart-item .trk.print { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
.cart-item .trk.print:hover { color: var(--brand-2, var(--brand)); text-decoration-style: solid; }
.cart-item .price { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; min-width: 38px; text-align: right; flex: 0 0 auto; }
.cart-item .x { cursor: pointer; color: var(--muted); border: none; background: none; font-size: 16px; }
.cart-item .x:hover { color: var(--warn); }
.cart-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 12px; }

.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--border); color: var(--text-2); }

/* summary */
.sum-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.sum-row.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; font-size: 20px; font-weight: 800; }
.sum-row .v { font-variant-numeric: tabular-nums; }
.sum-row input { width: 90px; text-align: right; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); }

/* ---- modal ---- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-bg[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.3);
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; padding: 20px;
}
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.modal-close { float: right; cursor: pointer; border: none; background: none; font-size: 20px; color: var(--muted); }

/* product picker grid */
.prod-groups { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.prod-groups .chip { cursor: pointer; padding: 5px 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-2); font-size: 13px; }
.prod-groups .chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
/* modal เลือกสินค้า — ขนาดคงที่ ไม่ยืด-หดตามจำนวนสินค้าของกลุ่มที่กด
   (ชิปกลุ่มแสดงครบทุกกลุ่มเสมอ ตัวแปรเดียวคือจำนวนสินค้าในตาราง → ล็อกความสูงตารางแล้วเลื่อนข้างใน) */
#productsModal .modal { width: 640px; max-width: 92vw; }
#productsModal .prod-grid { height: 46vh; min-height: 240px; overflow-y: auto; align-content: start; }
.prod-empty { color: var(--muted); font-size: 13px; padding: 12px 2px; }
.prod-btn {
  cursor: pointer; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  padding: 10px 6px; text-align: center;
}
.prod-btn:hover { border-color: var(--brand); }
.prod-btn .n { font-weight: 600; font-size: 13px; }
.prod-btn .p { color: var(--brand); font-weight: 700; margin-top: 2px; }

/* payment */
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.pay-method {
  cursor: pointer; border: 2px solid var(--border); border-radius: 10px; padding: 12px; text-align: center; font-weight: 600;
  background: var(--surface-2);
}
.pay-method.active { border-color: var(--brand); color: var(--brand); }
.pay-total { text-align: center; font-size: 34px; font-weight: 800; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.quick { display: flex; gap: 8px; margin: 10px 0; }
.quick button { flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 600; }
.quick button:hover { border-color: var(--brand); }
.pay-change { font-size: 18px; text-align: center; margin-top: 8px; }
.pay-change b { color: var(--good); }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card .sub { color: var(--text-2); font-size: 13px; margin-bottom: 18px; }
.login-card .btn { width: 100%; margin-top: 16px; padding: 10px; }
.login-card .err { margin-top: 10px; min-height: 18px; }

/* ---------- แจ้งเตือนพัสดุมีปัญหา ---------- */
#btAlerts { position: relative; }
#btAlerts.has-alert { border-color: var(--warn); }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--warn); color: #fff; font-size: 11px; line-height: 17px; text-align: center;
  border-radius: 9px; font-weight: 700;
}
.alert-item {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
  background: var(--surface-2); cursor: pointer; border-left: 3px solid var(--muted);
}
.alert-item.unread { border-left-color: var(--warn); background: rgba(208, 59, 59, 0.06); }
.alert-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.alert-top b { font-size: 15px; }
.alert-item .tag {
  font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--warn); color: #fff; white-space: nowrap;
}
.alert-item .sm { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.alert-msg { font-size: 12.5px; margin-top: 6px; color: var(--text); }

/* ---------- หน้า landing / สมัครใช้งาน ---------- */
.landing { max-width: 640px; margin: 0 auto; padding: 28px 16px 60px; }
.landing-hero { text-align: center; margin-bottom: 20px; }
.landing-hero h1 { font-size: 30px; margin: 0 0 6px; }
.landing-hero p { color: var(--text-2); margin: 0 0 14px; font-size: 14px; }
.reg-card { max-width: 560px; margin: 0 auto; }
.reg-card h2 { margin-top: 0; }
.reg-card .field { position: relative; }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.ac-box {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); max-height: 240px; overflow-y: auto;
}
.ac-item { padding: 8px 11px; cursor: pointer; font-size: 13px; }
.ac-item:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.ac-zip { color: var(--muted); font-size: 12px; float: right; }

/* ---------- Admin backoffice ---------- */
.admin-wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat-v { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-l { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th { text-align: left; color: var(--text-2); font-weight: 600; padding: 7px 9px; border-bottom: 2px solid var(--border); white-space: nowrap; }
table td { padding: 7px 9px; border-bottom: 1px solid var(--border); vertical-align: top; }
table td.empty { text-align: center; color: var(--muted); padding: 18px; }
.btn.sm { padding: 3px 10px; font-size: 12px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.pill.pending { background: color-mix(in srgb, var(--flash) 20%, transparent); color: var(--flash); }
.pill.approved { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.pill.rejected { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }

/* ---- Phase 3: จัดการผู้ใช้ในร้าน ---- */
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; padding: 3px 0; }
.chk input { width: auto; margin: 0; }
.perm-box { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line, #e2e6ee); border-radius: 10px; background: color-mix(in srgb, var(--brand) 4%, transparent); }
.perm-title { font-weight: 600; margin-bottom: 6px; font-size: 13px; color: var(--text-2); }
.nowrap { white-space: nowrap; }
table tr.inactive td { opacity: .5; }
table code { background: color-mix(in srgb, var(--text) 8%, transparent); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

/* ---- รายงาน: กราฟรายวัน (palette ผ่าน validate ทั้ง light/dark) ---- */
:root {
  --viz-ems: #eb6834;
  --viz-kex: #1baf7a;
  --viz-flash: #eda100;
  --viz-other: #8b95a3;
  --viz-grid: rgba(20, 24, 31, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --viz-ems: #df6430;
    --viz-kex: #19a674;
    --viz-flash: #c08300;
    --viz-other: #7d8896;
    --viz-grid: rgba(255, 255, 255, 0.08);
  }
}
.range-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.range-row .btn.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.viz-figure { margin: 14px 0 4px; }
.viz-title { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.viz-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; font-size: 12.5px; color: var(--text-2); }
.viz-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.viz-plot { position: relative; display: flex; align-items: flex-end; gap: 3px; height: 170px; padding-top: 6px;
  border-bottom: 1px solid var(--viz-grid); overflow-x: auto; }
.viz-col { flex: 1 1 0; min-width: 14px; max-width: 44px; display: flex; flex-direction: column-reverse; height: 100%;
  justify-content: flex-start; cursor: default; }
.viz-col .seg { width: 100%; margin-top: 2px; }              /* 2px surface gap ระหว่างชั้น */
.viz-col .seg:last-child { border-radius: 4px 4px 0 0; }     /* ปลายข้อมูลโค้ง 4px ชั้นบนสุด */
.viz-col:hover .seg { filter: brightness(1.08); }
.viz-x { display: flex; gap: 3px; margin-top: 4px; }
.viz-x span { flex: 1 1 0; min-width: 14px; max-width: 44px; text-align: center; font-size: 10.5px; color: var(--muted); }
.viz-tip { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 12.5px; pointer-events: none; min-width: 130px; }
.viz-tip b { display: block; margin-bottom: 3px; }
.viz-tip .row-t { display: flex; justify-content: space-between; gap: 12px; color: var(--text-2); }
.viz-empty { padding: 28px; text-align: center; color: var(--muted); font-size: 13px; }

/* ช่องวันที่แบบไทย (thai-date.js): ซ่อนข้อความ native ค.ศ. คง calendar picker + วางป้าย พ.ศ. ทับ */
.tdate-wrap { position: relative; display: block; }
/* ซ่อนข้อความ native เฉพาะช่องที่ thai-date.js ห่อ + วางป้ายให้แล้วเท่านั้น
   (ไม่งั้นหน้าที่ใส่ class="tdate" ไว้ใน markup แต่ JS ไม่ได้เติมป้าย = ช่องว่างเปล่า) */
.tdate-wrap > input.tdate { color: transparent; }
.tdate-wrap > input.tdate::-webkit-datetime-edit { color: transparent; }
.tdate-wrap > input.tdate:focus { color: transparent; }
.tdate-lbl { position: absolute; left: 11px; top: 0; height: 100%; display: flex; align-items: center;
  pointer-events: none; color: var(--text); font-variant-numeric: tabular-nums; font-size: 14px; }

/* ตารางแยกร้าน (dashboard) — ตัวเลขชิดขวา */
#dbShopTable th:nth-child(n+2), #dbShopTable td:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }

/* แถวรวมต่อขนส่ง (staff summary) — override .sum-row flex (บรรทัด 148) ให้กลับเป็น table-row ตัวเลขจะตรงคอลัมน์ */
table tr.sum-row { display: table-row; }
table tr.sum-row td { font-weight: 700; background: color-mix(in srgb, var(--brand) 7%, transparent); border-top: 1px solid var(--border); }
/* ตัวเลขในตารางสรุป — ชิดขวาให้เรียงหลักตรงกัน (ชิ้น/ยอดขาย/กำไร)
   แถวข้อมูล = คอลัมน์ 3-5 ; แถวรวม = 3 ช่องหลัง label (label เป็น colspan=2 จึงใช้ td+td) */
#shopTable th:nth-child(n+3),
#shopTable tr:not(.sum-row) td:nth-child(n+3),
#shopTable tr.sum-row td + td { text-align: right; font-variant-numeric: tabular-nums; }

/* timeline modal (ติดตามพัสดุ) */
.tn-link { text-decoration: none; }
.tn-link:hover code { text-decoration: underline; }
ul.timeline { list-style: none; margin: 4px 0 0; padding: 0; max-height: 340px; overflow-y: auto; }
ul.timeline li { position: relative; padding: 0 0 14px 22px; }
ul.timeline li::before { content: ''; position: absolute; left: 5px; top: 4px; bottom: -4px; width: 2px; background: var(--border); }
ul.timeline li:last-child::before { display: none; }
ul.timeline .tl-dot { position: absolute; left: 0; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); border: 2px solid var(--surface); }
ul.timeline li.now .tl-dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
ul.timeline li.now .tl-desc { font-weight: 700; }
.tl-desc { font-size: 14px; color: var(--text); }
.tl-meta { font-size: 12px; color: var(--text-2); margin-top: 1px; }

/* พัสดุมีปัญหา (staff) */
.stat-tile.clickable { cursor: pointer; transition: box-shadow .12s, transform .12s; }
.stat-tile.clickable:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.prob-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.prob-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 3px; }
.prob-cause { margin-top: 5px; font-size: 13.5px; color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); border-radius: 6px; padding: 5px 8px; }

/* ---------- แท็บแยกหมวด (หน้า admin / staff) ---------- */
.tabbar { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; border-bottom: 1px solid var(--border); }
.tabbtn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 10px 16px; font-size: 14.5px; font-weight: 600; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0;
}
.tabbtn:hover { background: color-mix(in srgb, #EE7A1F 8%, transparent); color: var(--text); }
.tabbtn.active { color: #DC6512; border-bottom-color: #EE7A1F; }
.tabbtn .cnt { font-weight: 700; margin-left: 5px; }

/* ---------- หน้าส่งพัสดุ: บีบให้พอดี 1 หน้าจอ ไม่ต้องเลื่อน ----------
   จอโน้ตบุ๊ก (~660-720px) เดิมต้องเลื่อนลงไปดู "เลือกขนส่ง" ทุกครั้ง
   บีบเฉพาะใน #view-send ไม่กระทบหน้าอื่นที่ใช้ .card/.field ร่วมกัน */
#view-send .card { padding: 10px 12px; margin-bottom: 8px; }
#view-send .card h2 { margin-bottom: 7px; }
#view-send .grid2 { gap: 10px; }
#view-send .field { margin-bottom: 5px; }
#view-send .field label { margin-bottom: 2px; font-size: 11.5px; }
/* สูงขึ้นอีกนิด + line-height 1.5 เพราะสระล่างภาษาไทย (ุ ู) โดนตัดที่ความสูงเดิม */
#view-send .field input, #view-send .field select { padding: 7px 10px; line-height: 1.5; }
#view-send .row { gap: 8px; }

/* การ์ดขนส่ง — ตัวเลขยังอ่านง่ายแต่เตี้ยลง */
#view-send .couriers { gap: 10px; }
#view-send .courier { padding: 9px 10px; }
#view-send .courier .price { font-size: 22px; margin: 2px 0; }
/* การ์ดขนส่งเลือกด้วยคีย์บอร์ดได้ (tabindex) — ต้องเห็นชัดว่าโฟกัสอยู่ใบไหน */
.courier:focus { outline: 2px solid var(--brand); outline-offset: 2px; }
.courier:focus-visible { outline: 3px solid var(--brand); }

/* 🔒 "ล็อก" ตัวเดียวที่หัวการ์ดรายละเอียดพัสดุ = คงค่าทุกช่องไว้หลังเพิ่มพัสดุ */
#view-send .card-parcel > h2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lock-all { display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text-2); }
.lock-all input { width: 14px; height: 14px; margin: 0; accent-color: var(--brand); cursor: pointer; }
#view-send .field.locked input, #view-send .field.locked select {
  border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, var(--surface));
}

/* ช่องตัวเลข (นน./กว้าง/ยาว/สูง/COD) แคบพอดีค่าที่กรอก
   ที่เหลือไปให้ดรอปดาวน์ + ช่องพื้นที่ ซึ่งข้อความยาวกว่ามาก */
/* 88px = ความกว้างที่ป้าย "น้ำหนัก (กก.)" / "COD (บาท)" อยู่บรรทัดเดียวพอดี
   แคบกว่านี้ป้ายตกบรรทัด แถวสูงขึ้น 15px แล้วหน้าเลยจอ */
#view-send .field.num { flex: 0 0 88px; }
#view-send .field.f-box { flex: 0 0 124px; }   /* ขนาดกล่อง — ชื่อยาวสุด "กำหนดเอง" */
/* สัดส่วนช่องในการ์ดผู้ส่ง/ผู้รับ — เบอร์ 10 หลักพอที่ 104px ที่เหลือแบ่งกัน */
#view-send .row .f-phone { flex: 0 0 104px; }
#view-send .row .f-name  { flex: 1.15; }
#view-send .row .f-addr  { flex: 1.55; }
#view-send .row .f-loc   { flex: 2.1; }
/* จอแคบ (โน้ตบุ๊ก ~1280) ยกที่ว่างกลับให้ "พื้นที่" เพราะ ตำบล-อำเภอ-จังหวัด-รหัส
   กว้างถึง 266px วัดจริงแล้วสัดส่วนของจอกว้างจะตัดข้อความ */

/* กว้าง/ยาว/สูง แคบกว่าเพราะเป็นเลข ซม. 2-3 หลัก — ที่ที่เหลือยกให้ประเภทพัสดุ
   (ชื่อยาวสุด "กระเป๋า/รองเท้า" ต้องการราว 145px ถึงจะไม่โดนตัด) */
#view-send .field.dim { flex: 0 0 62px; }
#view-send .field.num input, #view-send .field.dim input { padding-left: 7px; padding-right: 4px; }

@media (max-width: 1500px) {
  #view-send .row .f-name { flex: 1.2; }
  #view-send .row .f-addr { flex: 1.35; }
  #view-send .row .f-loc  { flex: 2.3; }
  /* แถวรายละเอียดพัสดุมี 7 ช่อง — จอแคบต้องบีบช่องตัวเลขลง ไม่งั้นดรอปดาวน์
     "ประเภทพัสดุ" เหลือ 84px แล้วชื่อยาว ("กระเป๋า/รองเท้า" = 127px) โดนตัด */
  #view-send .field.num { flex: 0 0 76px; }
  #view-send .field.dim { flex: 0 0 56px; }
  #view-send .field.f-box { flex: 0 0 104px; }
}

/* สีพื้นอ่อน ๆ แยกการ์ดผู้ส่ง / ผู้รับ / รายละเอียดพัสดุ
   ใช้ color-mix ผสมกับ --surface → โหมดมืดได้สีเข้มอ่อนเองไม่ต้องเขียนซ้ำ */
#view-send .card-sender   { background: color-mix(in srgb, #EE7A1F 7%, var(--surface)); }
#view-send .card-receiver { background: color-mix(in srgb, #2F80ED 7%, var(--surface)); }
#view-send .card-parcel   { background: color-mix(in srgb, #27AE60 7%, var(--surface)); }
#view-send .card-sender > h2   { color: #C55A0C; }
#view-send .card-receiver > h2 { color: #1B5FBF; }
#view-send .card-parcel > h2   { color: #1E8A4C; }
/* ช่องกรอกยังเป็นพื้นขาว/เข้มตามธีม เพื่อให้เห็นชัดว่าพิมพ์ได้ */
#view-send .card-sender .field input, #view-send .card-sender .field select,
#view-send .card-receiver .field input, #view-send .card-receiver .field select,
#view-send .card-parcel .field input, #view-send .card-parcel .field select { background: var(--surface); }

@media (prefers-color-scheme: dark) {
  #view-send .card-sender > h2   { color: #F5A15C; }
  #view-send .card-receiver > h2 { color: #79AEF5; }
  #view-send .card-parcel > h2   { color: #6FD79B; }
}

/* ---------- บริการเสริม Flash Care (เช็คบ็อกซ์เหนือปุ่ม Flash) ---------- */
.courier-wrap { display: flex; flex-direction: column; gap: 4px; }
.fcare {
  display: flex; align-items: center; gap: 5px; cursor: pointer;
  font-size: 11.5px; font-weight: 600; color: var(--flash);
  padding: 2px 4px; border-radius: 6px; line-height: 1.25;
}
.fcare input { width: 13px; height: 13px; margin: 0; accent-color: var(--flash); cursor: pointer; }
/* ไม่เข้าเงื่อนไข = จางลงและกดไม่ได้ (เมาส์ชี้จะเห็นเหตุผลใน title) */
.fcare.off { color: var(--muted); cursor: not-allowed; }
.fcare.off input { cursor: not-allowed; }

/* การ์ดขนส่งสูงเท่ากันทั้ง 3 ใบ — Flash มี label "Flash Care" อยู่ข้างบน
   จึงต้องให้ .courier-wrap เป็นตัวยืดเต็มแถว แล้วการ์ดข้างในกินที่ที่เหลือ
   (grid row สูงตามใบที่สูงสุดอยู่แล้ว เหลือแค่บังคับ height:100% ให้ทุกใบ) */
.couriers { align-items: stretch; }
.courier-wrap { height: 100%; }
.courier-wrap > .courier { flex: 1; }
.couriers > .courier, .courier-wrap > .courier {
  height: 100%; display: flex; flex-direction: column; justify-content: center;
}
/* label Flash Care สูงคงที่ ไม่ให้การ์ดขยับตอนข้อความยาวขึ้น (โชว์ค่าบริการ)
   และการ์ดที่ไม่มี label ใส่ที่ว่างความสูงเท่ากันไว้ → 3 ใบสูงเท่ากันเป๊ะ */
.fcare, .fcare-space { min-height: 18px; display: block; }
.fcare { display: flex; }

/* ปุ่มที่ปิดใช้งานต้องดูออกว่ากดไม่ได้ (เดิม .btn.primary ยังเป็นสีน้ำเงินเต็ม
   ทำให้ผู้ใช้กดแล้วไม่มีอะไรเกิดขึ้น) */
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- ปุ่มอ่านบัตรประชาชน (หน้าส่งพัสดุ) ---------- */
.field.f-idcard { flex: 0 0 44px; }
.btn.idcard { width: 100%; height: 37px; padding: 0; line-height: 0;
  display: inline-flex; align-items: center; justify-content: center; color: var(--brand); }
.btn.idcard svg { width: 26px; height: 19px; display: inline-block; vertical-align: middle; }
.btn.idcard.busy { opacity: .6; }

/* ===== เมนู "เช็คข้อมูลพัสดุ" — บีบให้เห็นครบใน 1 จอ (เจ้าของระบบสั่ง 2026-08-21)
   บีบเฉพาะใน #view-parcelcheck เหมือนที่ทำกับ #view-send ไม่กระทบหน้าอื่น */
#view-parcelcheck .card { padding: 9px 12px; margin-bottom: 8px; }
#view-parcelcheck .card h2 { margin-bottom: 6px; }
#view-parcelcheck .field { margin-bottom: 0; }
#view-parcelcheck .field label { margin-bottom: 2px; font-size: 11.5px; }
#view-parcelcheck .field input, #view-parcelcheck .field select { padding: 7px 10px; line-height: 1.5; }
#view-parcelcheck .row { gap: 8px; align-items: flex-end; }
#view-parcelcheck .field.num { flex: 0 0 88px; }
#view-parcelcheck .field.dim { flex: 0 0 62px; }
#view-parcelcheck .field.f-box { flex: 0 0 124px; }
#view-parcelcheck .row .f-phone { flex: 0 0 104px; }
#view-parcelcheck .row .f-name  { flex: 1; }
#view-parcelcheck .row .f-addr  { flex: 1.15; }
#view-parcelcheck .row .f-loc   { flex: 2.2; }
/* หัวเรื่อง + สรุปพัสดุ อยู่ขวาของช่องค้นหา (ไม่กินความสูงเพิ่ม) */
#view-parcelcheck .pe-info { flex: 1; min-width: 0; padding-bottom: 2px; }
#view-parcelcheck #pe_head { font-size: 15px; font-weight: 700; }
#view-parcelcheck #pe_sub { font-size: 12px; color: var(--text-2); }
#view-parcelcheck .pe-note { color: var(--text-2); margin-top: 4px; }
#view-parcelcheck #pe_msg:empty, #view-parcelcheck #pe_result:empty { display: none; }
#view-parcelcheck #pe_msg, #view-parcelcheck #pe_result { margin-top: 6px; }
/* แถบปุ่ม: ปุ่ม 2 ตัวกว้างคงที่ ข้อความผลลัพธ์ต่อท้ายในแถวเดียวกัน */
#view-parcelcheck .pe-actions .row { align-items: center; }
#view-parcelcheck .pe-actions .btn { flex: 0 0 190px; padding: 10px; }
#view-parcelcheck .pe-actions .err { flex: 1; margin-top: 0; }

/* ===== เมนู "ส่งเลขให้ลูกค้า" — คอลัมน์ตัวเลขชิดขวา (ธรรมเนียมเดียวกับตารางอื่นในระบบ) */
#st_table th.num, #st_table td.num, #mnTable th.num, #mnTable td.num, #mnShopTable th.num, #mnShopTable td.num { text-align: right; font-variant-numeric: tabular-nums; }
#st_table td { vertical-align: middle; }
#view-sendtracking #st_msg:empty { display: none; }

/* แถวตัวกรองของเมนู "ส่งเลขให้ลูกค้า" — ปุ่มค้นหา/ช่องติ๊ก อยู่ระดับเดียวกับช่องกรอก
   (.field มี margin-bottom ทำให้ปุ่มที่ไม่มี margin ดูต่ำกว่า เมื่อ align-items:flex-end) */
#view-sendtracking .field { margin-bottom: 0; }
#view-sendtracking #st_go { height: 38px; }
#view-sendtracking .st-all { display: inline-flex; align-items: center; gap: 6px; height: 38px;
  white-space: nowrap; font-size: 13px; color: var(--text); cursor: pointer; }
#view-sendtracking .st-all input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); cursor: pointer; }
#st_table .tag-guest { font-size: 11px; color: var(--text-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 6px; margin-left: 6px; white-space: nowrap; }

/* ติ๊ก "พิมพ์ใบเสร็จ" ในหน้าชำระเงิน — วางกลางเหนือปุ่มยืนยัน */
.pay-receipt { justify-content: center; margin-top: 12px; font-weight: 600; }
.pay-receipt input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }

/* ---- หน้าข้อมูลพัสดุ (POS): แถบตัวกรอง ----
   .field กลางมี margin-bottom 10px → ปุ่มที่จัดชิดล่างจะต่ำกว่าช่องกรอก 10px
   บีบเฉพาะแถบนี้ ไม่แตะ .field กลาง เพราะหน้าอื่นใช้ร่วมกัน */
.pi-bar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; }
.pi-bar .field { margin-bottom: 0; }
/* ช่องกรอกสูง 37px (padding 8+8 + border 2 + บรรทัด 19) → ปุ่ม/ตัวเลือกหน้าสูงเท่ากันจึงอยู่ระดับเดียวกัน */
.pi-bar .btn { height: 37px; }
.pi-bar .pager { display: flex; align-items: center; height: 37px; }
.pi-bar .pager .btn.sm { height: auto; }

/* ---------- หน้าเติมเงิน: การ์ด QR เป็นแถบแนวนอนแถวเดียว (2026-09-13) ---------- */
#view-topup .tw-band { display: flex; gap: 18px; align-items: stretch; flex-wrap: wrap; }
#view-topup .tw-left { flex: 0 0 300px; min-width: 240px; }
#view-topup .tw-right { flex: 1; min-width: 320px; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
/* คอลัมน์ขวา = แถบยอดที่จะเติม (บน) + กรอบ QR (ล่าง) */
#view-topup .tw-rightcol { flex: 1; min-width: 320px; display: flex; flex-direction: column; gap: 10px; }
#view-topup .tw-amtbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#view-topup .tw-amtlabel { margin: 0; font-size: 17px; font-weight: 700; color: var(--brand); white-space: nowrap; }
#view-topup .tw-amtbar input { width: 170px; height: 42px; font-size: 18px; font-weight: 700; border: 2px solid var(--brand); }
#view-topup .tw-amtbar .btn { height: 42px; white-space: nowrap; }
#view-topup .tw-qrrow { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
#view-topup .tw-qr { flex: 0 0 190px; }
#view-topup .tw-qr svg { display: block; width: 170px; height: 170px; }
#view-topup .tw-qr-empty { width: 170px; height: 170px; margin: 0 auto; border: 2px dashed var(--border); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; text-align: center; color: var(--text-2); font-size: 12.5px; padding: 10px; }
#view-topup .tw-info { flex: 1; min-width: 220px; }
#view-topup .tw-amt { font-size: 28px; font-weight: 800; line-height: 1.2; }
#view-topup .tw-acct-no { font-size: 20px; font-weight: 700; letter-spacing: 1px; margin: 2px 0; }

#view-topup .tw-checking span { animation: twBlink 1.2s infinite; opacity: .2; }
#view-topup .tw-checking span:nth-child(2) { animation-delay: .2s; }
#view-topup .tw-checking span:nth-child(3) { animation-delay: .4s; }
@keyframes twBlink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

/* ---- แถบบน POS: ยอดเงินในกระเป๋า + แถบแดงเติมเงิน (wallet-bar.js · 2026-09-13) ---- */
.wallet-pill { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px;
  height: 34px; padding: 0 10px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.wallet-pill b { color: var(--good); font-size: 14px; }
.wallet-pill .wp-l { color: var(--text-2); }
.wallet-pill.neg { border-color: var(--bad, #d33); }
.wallet-pill.neg b { color: var(--bad, #d33); }
.tw-wait { display: inline-block; font-size: 11px; font-weight: 600; color: var(--warn); padding: 1px 6px; border-radius: 10px;
  background: color-mix(in srgb, var(--warn) 14%, transparent); vertical-align: middle; }
.stat-v .tw-wait { font-size: 12px; }
/* แถบแฟรนไชส์ทดลอง (DEMO) ใต้แถบบนของ POS */
.demo-bar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 6px 14px;
  background: #fff4d6; color: #7a4b00; border-bottom: 1px solid #f1d38a; font-size: 13px; line-height: 1.45; }
.demo-bar[hidden] { display: none; }
.wallet-alert { background: #d32f2f; color: #fff; font-size: 14px; }
.wallet-alert .wa-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; }
.wallet-alert .wa-row + .wa-row { border-top: 1px solid rgba(255,255,255,.25); }
.wallet-alert .wa-row > span { flex: 1; font-weight: 600; }
.wallet-alert .wa-sub { font-weight: 400; opacity: .9; }
.wallet-alert .btn { background: #fff; color: #d32f2f; border-color: #fff; flex: 0 0 auto; }
#view-topup .tw-trust-note { margin-top: 8px; padding: 8px 10px; border-radius: 6px; font-size: 12.5px; line-height: 1.55;
  background: color-mix(in srgb, var(--warn) 10%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }
#view-topup .tw-trust-done { padding: 12px 8px; }
.wallet-pill { flex: 0 0 auto; }
.topbar .who { min-width: 0; }
/* จอแคบ: ตัดคำว่า "ยอดเงิน" + ย่อป้ายรอตรวจ ไม่ให้แถบบนล้นจนต้องเลื่อนซ้าย-ขวา */
@media (max-width: 1100px) { .wallet-pill .wp-l { display: none; } .wallet-pill { padding: 0 6px; } }
@media (max-width: 900px) { .wallet-pill .tw-wait { font-size: 10px; padding: 1px 4px; } }

/* ช่องเช็คเลขพัสดุบนแถบบนของหน้า staff (staff-lookup.js) */
.lookup-box { display: flex; align-items: center; gap: 6px; flex: 1 1 360px; max-width: 640px; min-width: 0; }
.lookup-box input { flex: 1 1 auto; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 14px; }
.lookup-box input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); border-color: var(--brand); }
.lookup-box .btn { white-space: nowrap; padding: 7px 10px; }
.lookup-box #lkMsg { white-space: nowrap; }
@media (max-width: 900px) { .topbar { flex-wrap: wrap; } .lookup-box { order: 10; flex-basis: 100%; max-width: none; } }

/* ตั้งค่าเมนู "ส่งเลขให้ลูกค้า" — รายการคอลัมน์ที่สลับลำดับได้ (เจ้าของระบบสั่ง 2026-09-18) */
.stcfg-list { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.stcfg-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 13.5px; }
.stcfg-row + .stcfg-row { border-top: 1px solid var(--border); }
.stcfg-row .no { flex: 0 0 20px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stcfg-row .nm { flex: 1; min-width: 0; }
.stcfg-row button { flex: 0 0 auto; padding: 2px 8px; line-height: 1.4; }

/* ---------- แท็บ "ข้อมูลสมาชิก" หน้า staff (staff-members.js · เจ้าของระบบสั่ง 2026-09-20) ----------
   ใช้บนมือถือเป็นหลัก → การ์ดรายคนเรียงลง (ไม่ใช่ตารางที่ต้องเลื่อนซ้าย-ขวา) + ปุ่มสูงพอให้แตะด้วยนิ้ว */
.mb-search { display: flex; gap: 8px; margin-bottom: 8px; }
.mb-search input { flex: 1; min-width: 0; padding: 11px 12px; font-size: 16px; /* 16px = iOS ไม่ซูมหน้าตอนโฟกัส */
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.mb-search .btn { padding: 11px 16px; font-weight: 600; white-space: nowrap; }

.mb-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.mb-chip { flex: 0 0 auto; appearance: none; cursor: pointer; font: inherit; font-size: 13.5px;
  padding: 7px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.mb-chip.on { background: color-mix(in srgb, var(--brand) 14%, var(--surface)); border-color: var(--brand); color: var(--brand); font-weight: 600; }

.mb-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px 13px; margin-top: 10px; background: var(--surface); }
.mb-card.off { opacity: .6; }
.mb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.mb-name { font-size: 16px; font-weight: 700; line-height: 1.3; min-width: 0; }
.mb-ph { font-size: 13px; font-weight: 400; color: var(--text-2); letter-spacing: .3px; }
.mb-lv { flex: 0 0 auto; font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.mb-lv.lv1 { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--text-2); }
.mb-lv.lv2 { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.mb-lv.lv3 { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }

/* ตัวเลขยอดส่ง — ข้อมูลที่ใช้ตัดสินใจปรับระดับ (เรียงเป็นกริดยืดหยุ่น 2-4 ช่องตามความกว้างจอ) */
.mb-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 6px 10px; margin-top: 9px; }
.mb-facts > div { display: flex; flex-direction: column; line-height: 1.35; }
.mb-facts span { font-size: 11.5px; color: var(--muted); }
.mb-facts b { font-size: 14.5px; }
.mb-facts i { font-size: 11.5px; color: var(--text-2); font-style: normal; }

.mb-ref { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 9px; padding-top: 8px;
  border-top: 1px dashed var(--border); font-size: 12.5px; color: var(--text-2); }

.mb-actions { display: flex; gap: 8px; margin-top: 10px; }
.mb-big { flex: 1; min-height: 42px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 14.5px; font-weight: 600; text-decoration: none; }

/* คำขอ (ลูกทีม / โอนค่าแนะนำ) */
.mb-req { border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; margin-bottom: 9px;
  background: color-mix(in srgb, var(--brand) 4%, var(--surface)); }
.mb-req-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.mb-amt { flex: 0 0 auto; font-size: 18px; font-weight: 700; color: var(--brand); }

/* ชีทเลือกระดับ — บนมือถือเลื่อนขึ้นจากขอบล่าง กดถึงง่ายกว่ากล่างจอ */
.mb-sheet .mb-lvopt { display: flex; align-items: center; justify-content: space-between; width: 100%;
  min-height: 48px; margin-top: 8px; padding: 10px 14px; font: inherit; font-size: 15px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); }
.mb-sheet .mb-lvopt i { font-style: normal; color: var(--brand); font-size: 13.5px; }
.mb-sheet .mb-lvopt b { color: var(--good); font-size: 13px; }
.mb-sheet .mb-lvopt.on { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--surface)); }
.mb-sheet .mb-big { width: 100%; }   /* ปุ่มปิดเต็มความกว้าง — กดพลาดยากบนมือถือ */
@media (max-width: 640px) {
  .mb-sheet-bg { align-items: flex-end; }
  .mb-sheet { width: 100%; max-width: none; border-radius: 16px 16px 0 0; margin: 0; max-height: 86vh; overflow-y: auto; }
}

/* ข้อความยืนยันลอย (แทน alert ที่ต้องแตะปิดบนมือถือ) */
.mb-flash { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 20px); z-index: 200;
  max-width: 92vw; padding: 11px 18px; border-radius: 24px; font-size: 14px; font-weight: 600;
  background: var(--good); color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
.mb-flash.show { opacity: 1; transform: translate(-50%, 0); }

/* หน้า staff บนมือถือ: บีบขอบ + ให้แท็บเลื่อนแนวนอนได้ (มี 4 แท็บแล้ว) */
@media (max-width: 640px) {
  .admin-wrap { padding: 10px; }
  .admin-wrap .card { padding: 12px; margin-bottom: 12px; }
  .tabbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tabbtn { flex: 0 0 auto; padding: 10px 12px; font-size: 14px; }
}

/* จอกว้าง: ปุ่มในการ์ดสมาชิกไม่ต้องยืดเต็มแถว (บนมือถือยังเต็มเพื่อให้กดง่าย) */
@media (min-width: 641px) {
  .mb-actions { justify-content: flex-start; }
  .mb-actions .mb-big { flex: 0 0 auto; min-width: 140px; }
}

/* แถบเหลืองใต้แถบบนของ POS: ยอดรับโอน/จำนวนครั้งถึงเกณฑ์ที่ตั้งไว้ (transfer-limit.js) */
.transfer-alert { background: #fff4d6; color: #7a4b00; border-bottom: 1px solid #f1d38a; font-size: 13.5px; }
.transfer-alert .ta-row { display: flex; align-items: center; gap: 10px; padding: 7px 14px; cursor: pointer; }
.transfer-alert .ta-row + .ta-row { border-top: 1px solid #f1d38a; }
.transfer-alert .ta-row > span { flex: 1; font-weight: 600; line-height: 1.45; }
.transfer-alert .ta-sub { font-weight: 400; }
.transfer-alert .btn { flex: 0 0 auto; background: #fff; color: #7a4b00; border-color: #e0bd6a; }
.transfer-alert .ta-row.danger { background: #d32f2f; color: #fff; }
.transfer-alert .ta-row.danger .btn { background: #fff; color: #d32f2f; border-color: #fff; }
.transfer-alert[hidden] { display: none; }

/* ===== ปุ่ม pill เลือกขนส่ง + ไอคอน (courier-ui.js) ===== */
.cpill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1.2;
  color: var(--text); background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 999px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  --ck: var(--brand);
}
.cpill svg { flex: 0 0 auto; color: var(--ck); transition: color .15s; }
.cpill.k-ems { --ck: #e0601f; } .cpill.k-flash { --ck: #c08300; } .cpill.k-kex { --ck: #19a674; }
.cpill.k-spx { --ck: #7c3aed; } .cpill.k-env { --ck: #3b82c4; } .cpill.k-fruit { --ck: #d6336c; }
.cpill:hover { border-color: var(--ck); background: color-mix(in srgb, var(--ck) 8%, var(--surface)); }
.cpill:active { transform: translateY(1px); }
.cpill:focus-visible { outline: 2px solid var(--ck); outline-offset: 2px; }
.cpill.on, .range-row .cpill.on {
  background: var(--ck); border-color: var(--ck); color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--ck) 35%, transparent);
}
.cpill.on svg { color: #fff; }
.cpill .cnt { font-weight: 500; opacity: .7; font-size: 12px; }
.cpill-row { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 640px) { .cpill { padding: 9px 14px; font-size: 14px; } }

/* ปุ่มทั่วไปให้นุ่มขึ้น (ทุกหน้า) */
.btn { transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s; }
.btn:not(:disabled):hover { box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.btn svg { vertical-align: -3px; }

/* ===== แบบ tab sheet : แท็บติดกับเนื้อหาด้านล่าง ===== */
.cpill-row {
  gap: 4px; align-items: flex-end; flex-wrap: wrap;
  border-bottom: 2px solid var(--border); margin-bottom: 14px !important; padding: 0 2px;
}
.cpill-row .cpill {
  border: 1.5px solid var(--border); border-bottom: 0; border-radius: 10px 10px 0 0;
  background: color-mix(in srgb, var(--text) 4%, var(--surface)); color: var(--text-2);
  padding: 9px 16px 8px; margin-bottom: -2px; box-shadow: none; transform: none;
  border-top: 3px solid transparent;
}
.cpill-row .cpill:hover { background: color-mix(in srgb, var(--ck) 8%, var(--surface)); color: var(--text); }
.cpill-row .cpill.on {
  background: var(--surface); color: var(--text); border-color: var(--border);
  border-top-color: var(--ck); box-shadow: none; padding-bottom: 10px;
  position: relative; z-index: 1;
}
.cpill-row .cpill.on svg { color: var(--ck); }
.cpill-row .cpill.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--surface); }

/* ไอคอนในปุ่ม (btn-icons.js) */
.btn.has-bi { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.has-bi .bi { flex: 0 0 auto; }

/* tab ที่ไม่ได้เลือก ให้เข้มขึ้น แยกจากแท็บที่เลือกชัด */
.cpill-row .cpill:not(.on) {
  background: color-mix(in srgb, var(--text) 13%, var(--surface));
  border-color: color-mix(in srgb, var(--text) 22%, var(--border));
  color: var(--text);
}
.cpill-row .cpill:not(.on):hover { background: color-mix(in srgb, var(--ck) 16%, var(--surface)); }

/* ===== tab sheet สำหรับแท็บหน้าหลัก (admin / staff / บัญชี) ===== */
.tabbar { gap: 4px; align-items: flex-end; border-bottom: 2px solid var(--border); padding: 0 2px; }
.tabbtn.has-bi { display: inline-flex; align-items: center; gap: 7px; }
.tabbtn {
  border: 1.5px solid color-mix(in srgb, var(--text) 22%, var(--border)); border-bottom: 0;
  border-top: 3px solid transparent; border-radius: 10px 10px 0 0; margin-bottom: -2px;
  background: color-mix(in srgb, var(--text) 13%, var(--surface)); color: var(--text);
  padding: 9px 16px 8px;
}
.tabbtn:hover { background: color-mix(in srgb, #EE7A1F 16%, var(--surface)); }
.tabbtn svg.bi { color: #EE7A1F; }
.tabbtn.active {
  background: var(--surface); color: #DC6512; border-color: var(--border); border-top-color: #EE7A1F;
  padding-bottom: 10px; position: relative; z-index: 1;
}
.tabbtn.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--surface); }

/* ===== ปุ่มมีสีตามความหมาย (ปุ่มหลัก .primary คงสีแบรนด์) ===== */
.btn.has-bi { --bc: #475569; }
.btn.has-bi:not(.primary):not(:disabled) {
  color: var(--bc, #475569); border-color: color-mix(in srgb, var(--bc) 45%, var(--border));
  background: color-mix(in srgb, var(--bc) 8%, var(--surface)); font-weight: 600;
}
.btn.has-bi:not(.primary):not(:disabled):hover { background: color-mix(in srgb, var(--bc) 17%, var(--surface)); border-color: var(--bc); }
.btn.bi-save, .btn.bi-ok, .btn.bi-pay { --bc: #15803d; }
.btn.bi-cancel, .btn.bi-del, .btn.bi-close { --bc: #dc2626; }
.btn.bi-edit, .btn.bi-search, .btn.bi-view, .btn.bi-next { --bc: #2563eb; }
.btn.bi-add, .btn.bi-user { --bc: #0d9488; }
.btn.bi-print, .btn.bi-qr { --bc: #7c3aed; }
.btn.bi-down, .btn.bi-upload, .btn.bi-copy { --bc: #4f46e5; }
.btn.bi-refresh, .btn.bi-camera, .btn.bi-back { --bc: #0891b2; }
.btn.bi-send, .btn.bi-call, .btn.bi-login { --bc: #ea580c; }
.btn.bi-folder, .btn.bi-tag, .btn.bi-box, .btn.bi-wallet { --bc: #b45309; }
/* ปุ่มหลัก (primary) ที่มีไอคอน: ไอคอนสีขาวตามตัวอักษร */
.btn.primary.has-bi { color: var(--brand-ink); }
.btn.bi-detail { --bc: #16a34a; }
.btn.has-bi.bi-detail:not(.primary):not(:disabled) { background: color-mix(in srgb, #16a34a 14%, var(--surface)); }
.btn.bi-cal { --bc: #7c3aed; } .btn.bi-gear, .btn.bi-list { --bc: #475569; } .btn.bi-logout { --bc: #dc2626; }
.btn.bi-wand { --bc: #c026d3; } .btn.bi-store, .btn.bi-receipt { --bc: #0369a1; } .btn.bi-lock { --bc: #b45309; }

/* สีอ่อนพาสเทลให้เห็นต่างกันชัดขึ้น */
.btn.has-bi:not(.primary):not(:disabled) {
  background: color-mix(in srgb, var(--bc) 15%, #fff);
  border-color: color-mix(in srgb, var(--bc) 55%, #fff);
}
.btn.has-bi:not(.primary):not(:disabled):hover { background: color-mix(in srgb, var(--bc) 26%, #fff); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn.has-bi:not(.primary):not(:disabled) { background: color-mix(in srgb, var(--bc) 22%, var(--surface)); color: color-mix(in srgb, var(--bc) 55%, #fff); }
}

.btn.bi-pdf { --bc: #e11d48; } .btn.bi-rows { --bc: #0d9488; }

/* ตารางข้อมูลพัสดุ: แถวสลับ ขาว / ส้มอ่อน 5% */
#piTable tbody tr:nth-child(even) td { background: color-mix(in srgb, #EE7A1F 5%, var(--surface)); }
#piTable tbody tr.sum-row td { background: color-mix(in srgb, var(--brand) 7%, transparent); }

/* ===== ทุกตาราง: ตรึงหัวตาราง + แถวสลับขาว/ส้มอ่อน 5% ===== */
.tbl-wrap { overflow: auto; max-height: 72vh; }
table th { position: sticky; top: 0; z-index: 3; background: var(--surface); box-shadow: 0 2px 0 var(--border); border-bottom: 0; }
table:not(.no-zebra):not(.st-list) tbody tr:not(.sum-row):not(.inactive):nth-child(even) td { background: color-mix(in srgb, #EE7A1F 5%, var(--surface)); }
[hidden] { display: none !important; }

.pill { white-space: nowrap; }
#piTable td { vertical-align: middle; }

/* เลื่อนถึงสุดตารางแล้วอย่าส่งต่อไปเลื่อนทั้งหน้า */
.tbl-wrap { overscroll-behavior: contain; }
#alertList > * { flex-shrink: 0; }
#alertsModal .modal { overflow-x: hidden; } #alertList { overflow-wrap: anywhere; }

/* คู่มือการใช้งานระบบ (manual.js) — การ์ดหัวข้อ + popup ภาพประกอบ */
#view-manual .mn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-top: 12px; }
#view-manual .mn-card { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; font: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
#view-manual .mn-card:hover { border-color: var(--brand); box-shadow: 0 4px 14px rgba(0,0,0,.08); transform: translateY(-1px); }
#view-manual .mn-cico { flex: 0 0 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 26px; background: color-mix(in srgb, var(--brand) 12%, var(--surface)); }
#view-manual .mn-cbody { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#view-manual .mn-ctitle { font-weight: 700; font-size: 15px; }
#view-manual .mn-cdesc { font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
#view-manual .mn-cmeta { font-size: 11.5px; color: var(--brand); font-weight: 600; }
#view-manual .mn-carrow { font-size: 24px; color: var(--text-2); }
#mnModal .mn-modal { max-width: 980px; width: 96vw; max-height: 92vh; overflow-y: auto; }
#mnModal .mn-ptitle { margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }
#mnModal .mn-pico { font-size: 28px; }
#mnModal .mn-h3 { margin: 18px 0 8px; font-size: 15px; padding-bottom: 4px; border-bottom: 2px solid color-mix(in srgb, var(--brand) 30%, transparent); }
#mnModal .mn-intro { color: var(--text-2); margin: 4px 0 0; }
#mnModal .mn-steps { margin: 6px 0 0; padding-left: 22px; line-height: 1.7; }
#mnModal .mn-steps li { margin-bottom: 4px; }
#mnModal .mn-shot { margin: 0 0 18px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
#mnModal .mn-shot figcaption { font-weight: 700; margin-bottom: 8px; }
#mnModal .mn-snum { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 12px; margin-right: 6px; }
#mnModal .mn-shot img { width: 100%; display: block; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
#mnModal .mn-legend { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
#mnModal .mn-legend li { display: flex; gap: 10px; align-items: flex-start; line-height: 1.5; }
#mnModal .mn-dot { flex: 0 0 24px; height: 24px; border-radius: 50%; background: #e11d1d; color: #fff; font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
#mnModal .mn-tips { margin-top: 10px; padding: 8px 12px; border-radius: 8px; background: color-mix(in srgb, var(--brand) 8%, var(--surface)); font-size: 13px; }
#mnModal .mn-tips ul { margin: 4px 0 0; padding-left: 18px; line-height: 1.6; }
#mnModal code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
@media (max-width: 640px) { #view-manual .mn-grid { grid-template-columns: 1fr; } #mnModal .mn-modal { padding: 14px 12px; } }

/* การ์ดที่มาขนส่งแต่ละเจ้า (หน้า admin รายละเอียดแฟรนไชส์) */
.src-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 10px; margin: 10px 0 6px; }
.src-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.src-card h3 { margin: 0 0 6px; font-size: 15px; }

/* แก้ราคาเก็บลูกค้าในตะกร้าพัสดุ (คลิกที่ราคา) */
.cart-item .price.editable { cursor: text; padding: 3px 6px; min-width: 43px; border: 1px dashed var(--border); border-radius: 6px; background: var(--surface); }
.cart-item .price.editable:hover { color: var(--brand); border-color: var(--brand); }
.cart-item .price-input { width: 58px; padding: 3px 6px; font-size: 15px; font: inherit; font-weight: 700; text-align: right; border: 1px solid var(--brand); border-radius: 6px; background: var(--surface); color: var(--text); }

/* ข้อความเตือนขนส่ง Flash ใต้การ์ดเลือกขนส่ง (หน้าส่งพัสดุ) */
.flash-note { margin: 10px 0 0; padding: 8px 12px; font-size: 12px; line-height: 1.5; color: var(--text);
  background: color-mix(in srgb, var(--muted) 12%, var(--surface)); border: 1px solid var(--border); border-radius: 8px; }
.flash-note > b { color: var(--flash); display: block; margin-bottom: 2px; }
.flash-note > div + div { margin-top: 3px; }

/* หน้าข้อมูลพัสดุ: ใช้ความกว้างจอที่เหลือ (เดิมจำกัด 1180px) ให้คอลัมน์ในตารางกว้างขึ้น — เจ้าของระบบสั่ง 2026-10-20 */
#view-parcels.stub-view { max-width: min(1760px, 100%); }

/* ตะกร้าพัสดุ: ชื่อผู้รับได้ที่มากขึ้น (ช่องราคาแคบลง) · ปุ่มชำระเงินไอคอนใหญ่ขึ้น — เจ้าของระบบสั่ง 2026-10-20 */
.cart-item { gap: 6px; }
.cart-item .t { flex: 1 1 auto; min-width: 90px; }
.cart-item .x { padding: 0 2px; }
#btPay, #btConfirmPay { font-size: 17px; font-weight: 700; letter-spacing: .01em; }
#btPay .bi, #btConfirmPay .bi { width: 26px; height: 26px; stroke-width: 1.8; margin-right: 4px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.18)); }

/* เมนูเรียกรถเข้ารับ: การ์ดข้อมูล 3 ใบ */
.pk-info { padding: 16px 18px; }
.pk-info .pk-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.pk-info .pk-head h2 { margin: 0; font-size: 17px; }
.pk-info .pk-ico { font-size: 26px; line-height: 1; }
.pk-info p { margin: 4px 0 12px; font-size: 14px; line-height: 1.6; color: var(--text); }
.pk-info p:last-child { margin-bottom: 0; }
.pk-badge { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); }
.pk-badge.auto { color: #15803d; border-color: color-mix(in srgb, #15803d 45%, transparent); background: color-mix(in srgb, #15803d 9%, var(--surface)); }
.pk-badge.manual { color: #b45309; border-color: color-mix(in srgb, #b45309 45%, transparent); background: color-mix(in srgb, #b45309 9%, var(--surface)); }
.pk-info .pk-tip { margin-top: 0; padding: 8px 12px; border-radius: 8px; background: color-mix(in srgb, #06c755 10%, var(--surface)); border: 1px solid color-mix(in srgb, #06c755 40%, transparent); }
.pk-info .pk-inner { margin-top: 10px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.pk-info .pk-inner-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.pk-info .pk-inner p { margin: 2px 0 0; }
.pk-info .pk-inner { background: color-mix(in srgb, #f97316 11%, var(--surface)); border-color: color-mix(in srgb, #f97316 40%, transparent); }
.pk-info .pk-inner-title { color: #c2410c; }

/* หน้าข้อมูลพัสดุ (จอคอม): ตรึงตัวกรอง/การ์ดสรุปไว้บน เลื่อนเฉพาะตาราง — หมุนลูกกลิ้งบนการ์ดแล้วหน้าไม่ขยับ (เจ้าของระบบสั่ง 2026-10-23)
   --tb-h = ความสูงแถบบน วัดด้วย JS (dashboard.js setTopbarH) */
@media (min-width: 901px) {
  #view-parcels:not([hidden]), #view-products:not([hidden]), #view-members:not([hidden]), #view-debtors:not([hidden]), #view-rate:not([hidden]), #view-boxsize:not([hidden]) { display: flex; flex-direction: column; height: calc(100vh - var(--tb-h, 57px)); padding-bottom: 14px; overflow: hidden; }
  #view-parcels > .card, #view-products > .card, #view-members > .card, #view-debtors > .card, #view-rate > .card, #view-boxsize > .card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  #view-parcels .tbl-wrap, #view-products .tbl-wrap, #view-members .tbl-wrap, #view-debtors .tbl-wrap, #view-rate .tbl-wrap, #view-boxsize .tbl-wrap { flex: 1 1 auto; min-height: 0; max-height: none; }
}

/* ตรึงหน้ารอบ 2 (เจ้าของระบบสั่ง 2026-10-23): ส่งเลขให้ลูกค้า · รายงานขายสินค้า · ค่าพื้นที่พิเศษ · เติมเงิน
   หลายการ์ดในหน้าเดียว → การ์ดสุดท้าย (ที่มีตาราง) ยืดเต็มที่เหลือ การ์ดอื่นขนาดตามเนื้อหา ; เนื้อหาเกินจอจริงๆ เลื่อนในหน้านั้น (ไม่ตัด) */
@media (min-width: 901px) {
  #view-sendtracking:not([hidden]), #view-sales:not([hidden]), #view-specialarea:not([hidden]), #view-topup:not([hidden]) {
    display: flex; flex-direction: column; height: calc(100vh - var(--tb-h, 57px)); padding-bottom: 14px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
  #view-sendtracking > *, #view-sales > *, #view-specialarea > *, #view-topup > * { flex: 0 0 auto; }
  #view-sendtracking > .card:last-child, #view-sales > .card:last-child, #view-specialarea > .card:last-child, #view-topup > .card:last-child {
    flex: 1 1 auto; min-height: 220px; display: flex; flex-direction: column; }
  #view-sendtracking .tbl-wrap, #view-sales .tbl-wrap, #view-specialarea .tbl-wrap, #view-topup .tbl-wrap { flex: 1 1 auto; min-height: 0; max-height: none; }
  /* การ์ดกติกาด้านบนของค่าพื้นที่พิเศษ: กันสูงเกินจนตารางรายการหมดที่ */
  #view-specialarea #saRules { max-width: 100%; }
  #view-specialarea > .card:not(:last-child) .tbl-wrap { flex: 0 1 auto; max-height: 30vh; }
}
/* เติมเงิน: การ์ดอยู่ใน #twMain — ให้การ์ด "คำขอเติมเงินล่าสุด" (สุดท้าย) ยืดเต็มที่เหลือ */
@media (min-width: 901px) {
  #view-topup > #twMain:not([hidden]) { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  #view-topup #twMain > .card { flex: 0 0 auto; }
  #view-topup #twMain > .card:last-child { flex: 1 1 auto; min-height: 200px; display: flex; flex-direction: column; }
}

/* แถบประกาศจากศูนย์ ด้านบนสุดของ POS (banner-bar.js) */
.fx-banners:empty { display: none; }
.fx-banner-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; color: #fff; font-size: 14px; }
.fx-banner-row + .fx-banner-row { border-top: 1px solid rgba(255,255,255,.28); }
.fx-banner-row .fb-icon { flex: 0 0 auto; font-size: 18px; line-height: 1; }
.fx-banner-row .fb-tag { flex: 0 0 auto; padding: 1px 8px; border-radius: 999px; background: rgba(255,255,255,.22); font-size: 12.5px; }
.fx-banner-row .fb-msg { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.fx-banner-row .fb-ack { flex: 0 0 auto; background: #fff; border: 0; border-radius: 6px; padding: 4px 12px; font-weight: 700; cursor: pointer; }
.fx-banner-row .fb-ack:disabled { opacity: .6; cursor: default; }
@media (max-width: 600px) { .fx-banner-row { flex-wrap: wrap; } .fx-banner-row .fb-msg { flex-basis: 100%; order: 3; } .fx-banner-row .fb-ack { margin-left: auto; } }

/* อัตราค่าบริการ: แท็บที่มีตารางซอง + การ์ดโปรโมชั่น (Flash Eco / SPX Eco) — เลื่อนทั้งหน้า ไม่บีบตารางในการ์ด (2026-11-05) */
#view-rate.rt-stack:not([hidden]) { overflow-y: auto; height: calc(100vh - var(--tb-h, 57px)); }
#view-rate.rt-stack > .card { flex: 0 0 auto; }
#view-rate.rt-stack .tbl-wrap { flex: 0 0 auto; max-height: none; overflow-y: visible; }

/* ---------- แท็บ "ติดตามพัสดุมีปัญหา" หน้า staff (staff-problems.js · 2026-11-09) — มือถือเป็นหลัก ---------- */
#tab-problems .mb-chips { margin-top: 6px; }
.pf-group { font-weight: 700; margin: 16px 0 2px; font-size: 14.5px; }
.pf-card { border: 1px solid var(--border); border-left: 5px solid var(--warn); border-radius: 12px; padding: 11px 13px; margin-top: 9px;
  background: var(--surface); cursor: pointer; }
.pf-card:hover, .pf-card:focus { border-color: var(--brand); outline: none; }
.pf-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pf-no { font-size: 16px; font-weight: 800; letter-spacing: .3px; word-break: break-all; }
.pf-age { flex: 0 0 auto; font-size: 12.5px; white-space: nowrap; }
.pf-tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin: 6px 0 4px; }
.pf-reason { font-weight: 600; font-size: 14px; line-height: 1.4; }
.pf-meta { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.pf-last { font-size: 12.5px; margin-top: 7px; padding-top: 6px; border-top: 1px dashed var(--border); color: var(--text-2); }
.pf-last.none { color: var(--warn); font-weight: 600; }
.pf-changed { font-size: 12.5px; margin-top: 6px; color: var(--good); }
.pf-modal { max-width: 680px; width: 100%; }
.pf-alert { background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  color: var(--warn); padding: 7px 10px; border-radius: 8px; margin: 8px 0; font-size: 13.5px; }
.pf-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.pf-sec { font-weight: 700; margin: 14px 0 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.pf-row { display: flex; gap: 10px; padding: 5px 0; font-size: 14px; }
.pf-row > div:first-child { flex: 0 0 92px; color: var(--text-2); }
.pf-row > div:last-child { flex: 1; min-width: 0; word-break: break-word; }
.pf-row a { white-space: nowrap; }
.pf-hist { display: flex; gap: 10px; font-size: 13px; padding: 3px 0; }
.pf-hist > span:first-child { flex: 0 0 auto; color: var(--text-2); white-space: nowrap; }
.pf-fu { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.pf-fu-n { flex: 0 0 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center; }
.pf-fu-b { flex: 1; min-width: 0; }
.pf-fu-r { font-weight: 600; font-size: 14.5px; }
.pf-closed { margin-top: 8px; padding: 9px 11px; border-radius: 10px; font-size: 13.5px;
  background: color-mix(in srgb, var(--good) 10%, transparent); border: 1px solid color-mix(in srgb, var(--good) 35%, transparent); }
.pf-form { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; gap: 8px; }
.pf-form label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--text-2); }
.pf-form input, .pf-form textarea { font: inherit; font-size: 16px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); }
.pf-sub { font-weight: 700; }
.pf-closebox summary { cursor: pointer; font-weight: 700; color: var(--good); }
.pf-closebox[open] summary { margin-bottom: 4px; }
@media (max-width: 640px) {
  .pf-bg { align-items: flex-end; }
  .pf-modal { max-width: none; border-radius: 16px 16px 0 0; margin: 0; max-height: 92vh; overflow-y: auto; }
}
.pf-side { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.pf-side.center { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.pf-side.shop { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }

/* ---------- Dashboard คอลัมน์ขวา: ประกาศจากศูนย์ (บน ~80%) + ข้อความระบบ (ล่าง ~20%) เลื่อนแยกกัน พอดีหน้า (2026-11-09) ---------- */
#dbAside { position: sticky; top: calc(var(--tb-h, 60px) + 12px); height: calc(100vh - var(--tb-h, 60px) - 36px);
  display: flex; flex-direction: column; gap: 12px; }
#dbAside .db-box { margin: 0; display: flex; flex-direction: column; min-height: 0; }
#dbAside .db-box h2 { margin-bottom: 6px; flex: 0 0 auto; }
#dbAside .db-notice { flex: 4 1 0; }
#dbAside .db-msg { flex: 1 1 0; min-height: 150px; }
#dbAside .db-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 4px; }
.db-msg-row { padding: 7px 2px; border-bottom: 1px solid var(--border); font-size: 13.5px; line-height: 1.45; }
@media (max-width: 1100px) {   /* คอลัมน์ขวาตกลงไปใต้สรุปยอด → ไม่ตรึง ให้แต่ละการ์ดสูงจำกัดแทน */
  #dbAside { position: static; height: auto; }
  #dbAside .db-notice, #dbAside .db-msg { flex: none; min-height: 0; }
  #dbAside .db-notice .db-scroll { max-height: 70vh; }
  #dbAside .db-msg .db-scroll { max-height: 40vh; }
}
