/* ============================================================
   Jong D Design System — "Warm & Friendly"
   ม่วง = identity ของระบบงาน / แดง Jong D = สีแบรนด์ ใช้เป็นจุดเสริมเท่านั้น
   ============================================================ */
:root {
  /* สีหลัก */
  --jd-purple: #5b3fa8;
  --jd-purple-600: #6a4fc0;      /* hover / ไล่เฉดสว่าง */
  --jd-purple-dark: #46307f;
  --jd-purple-soft: #efeafa;     /* พื้นจางโทนม่วง */
  --jd-blue: #2c5fd8;
  --jd-brand-red: #e5402f;       /* แดงโลโก้จงดี — ใช้น้อยจุดแต่คม */
  /* พื้น/ตัวหนังสือ: ม่วงจางอมอุ่น (user เลือกแทนครีม) */
  --jd-cream: #f5f2fa;           /* พื้นหลังทั้งระบบ — lavender อ่อน (ชื่อ var คงเดิมเพื่อไม่แตะทุกไฟล์) */
  --jd-card: #ffffff;
  --jd-ink: #3c3357;             /* ตัวหนังสือหลัก (ม่วงเข้มอมเทา) */
  --jd-muted: #8a7f9e;
  --jd-hint: #b3abc9;            /* คำอธิบาย/คำใบ้ — จางสุด ไม่แย่งซีน */
  --jd-line: #e6e0f0;            /* เส้นขอบโทนม่วงจาง */
  /* สีสถานะแบบนุ่ม (คู่ เข้ม + พื้นจาง) */
  --ok: #2f9e63;   --ok-soft: #e4f5eb;   --ok-line: #bfe5cd;
  --warn: #c98a10; --warn-soft: #fcf3de; --warn-line: #efdcae;
  --bad: #d9534f;  --bad-soft: #fdeae8;  --bad-line: #f3c4bd;
  /* สเกลมุมโค้ง + เงา — ใช้ชุดเดียวทั้งระบบ */
  --radius-s: 10px; --radius-m: 14px; --radius-l: 20px;
  --shadow-1: 0 2px 10px rgba(91, 63, 168, .08);
  --shadow-2: 0 8px 22px rgba(91, 63, 168, .16);
}

body { font-family: 'Sarabun', sans-serif; background: var(--jd-cream); color: var(--jd-ink); }

/* ---- Navbar: ม่วงนุ่ม + โลโก้จงดีบนชิปขาว + เมนูทรงแคปซูล ---- */
.navbar-jd {
  background: linear-gradient(100deg, var(--jd-purple-dark), var(--jd-purple) 55%, var(--jd-purple-600));
  box-shadow: 0 2px 12px rgba(70, 48, 127, .25);
  padding-top: .45rem; padding-bottom: .45rem;
}
.navbar-brand { font-weight: 700; display: flex; align-items: center; gap: .55rem; }
/* ชิปโลโก้: ขอบขาวบางที่สุด เน้นเครื่องหมายแดงให้ใหญ่เด่น */
.brand-chip {
  background: #fff; border-radius: 8px; padding: 3px 5px; display: inline-flex; align-items: center;
}
.brand-chip img { height: 27px; display: block; }
.navbar-jd .nav-link {
  border-radius: 999px; padding: .42rem 1rem !important; margin-right: .15rem;
  color: rgba(255, 255, 255, .82); transition: background .15s, color .15s;
}
.navbar-jd .nav-link:hover { background: rgba(255, 255, 255, .13); color: #fff; }
.navbar-jd .nav-link.active { background: rgba(255, 255, 255, .2); color: #fff; }
.navbar-jd .dropdown-menu {
  border: 0; border-radius: var(--radius-m); box-shadow: var(--shadow-2); padding: .45rem;
  margin-top: .45rem;
}
.navbar-jd .dropdown-item { border-radius: 9px; padding: .5rem .9rem; }
.navbar-jd .dropdown-item:hover { background: var(--jd-purple-soft); }
.navbar-jd .dropdown-item.active { background: var(--jd-purple); }

/* ---- คุมหน้าตา component มาตรฐานให้เข้าธีม ---- */
.btn { border-radius: 12px; }
.btn-sm { border-radius: 9px; }
.btn-primary { background: var(--jd-purple); border-color: var(--jd-purple); }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active { background: var(--jd-purple-dark) !important; border-color: var(--jd-purple-dark) !important; }
.btn-outline-primary { color: var(--jd-purple); border-color: var(--jd-purple); }
.btn-outline-primary:hover { background: var(--jd-purple); border-color: var(--jd-purple); }
.bg-primary { background: var(--jd-purple) !important; }
/* ปุ่ม "สร้าง QC / สร้าง RT" ในหน้าคิวรถขาเข้า — พื้นจางโทนของฟอร์ม (QC ม่วง / RT ฟ้าตามธีมใบรับคืน) ไม่มีเส้นขอบ */
.btn-newdoc { background: var(--jd-purple-soft); color: var(--jd-purple); border: 0; font-weight: 600; border-radius: 8px;
  padding: .1rem .6rem; font-size: .86rem; line-height: 1.55; display: inline-flex; align-items: center; gap: .25rem;
  box-shadow: inset 0 0 0 1px rgba(91, 63, 168, .18); }
.btn-newdoc .bi { font-size: .8em; }
/* เซลล์เอกสารในคิวรถขาเข้า: เลขใบ + สถานะ Odoo + ชิปสร้างใหม่ ไหลต่อกัน ไม่บังคับขึ้นบรรทัด */
/* กว้างพอให้ เลขใบย่อ + ชิปสร้าง อยู่บรรทัดเดียว (ตารางเคยบีบคอลัมน์นี้เหลือ ~106px) */
.qc-cell { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .35rem; min-width: 150px; }
.qc-cell .qc-doc { display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap; font-size: .86rem; }

.btn-newdoc:hover, .btn-newdoc:focus { background: var(--jd-purple); color: #fff; box-shadow: none; }
.btn-newdoc.rt { background: #e4ebfb; color: #2f54b8; box-shadow: inset 0 0 0 1px rgba(47, 84, 184, .2); }
.btn-newdoc.rt:hover, .btn-newdoc.rt:focus { background: #2f54b8; color: #fff; box-shadow: none; }
.btn-newdoc.btn-lg { padding: .55rem 1.1rem; font-size: 1.05rem; border-radius: 999px; }
.text-primary { color: var(--jd-blue) !important; }
.form-control, .form-select { border-radius: 11px; border-color: var(--jd-line); }
.form-control:focus, .form-select:focus { border-color: var(--jd-purple-600); box-shadow: 0 0 0 .2rem rgba(91, 63, 168, .12); }
.form-check-input:checked { background-color: var(--jd-purple); border-color: var(--jd-purple); }
.nav-tabs .nav-link.active { color: var(--jd-purple); font-weight: 700; border-bottom: 3px solid var(--jd-purple); }
.nav-tabs .nav-link { color: #6c757d; }
.card { background: var(--jd-card); border-color: var(--jd-line); border-radius: var(--radius-m); box-shadow: 0 1px 5px rgba(91, 63, 168, .05); }
.table thead.table-light th { background: #efeaf8; }
/* คำอธิบาย/คำใบ้การใช้งาน — จางกว่า text-muted เพื่อไม่แย่งซีนหัวข้อหลัก */
.hint { color: var(--jd-hint) !important; }
.modal-content { border: 0; border-radius: var(--radius-l); box-shadow: var(--shadow-2); }
.modal-header { border-bottom: 0; padding-bottom: .3rem; }
.modal-footer { border-top: 0; }
.badge { border-radius: 8px; }

/* Badge สถานะแบบนุ่ม: พื้นจาง + ตัวเข้ม (ป้ายที่กำหนดสีเองด้วย style เช่นประเภทงาน ยังทึบตามเดิม) */
.badge.bg-success { background: var(--ok-soft) !important; color: #1e7a48; }
.badge.bg-danger { background: var(--bad-soft) !important; color: #b3372f; }
.badge.bg-warning { background: var(--warn-soft) !important; color: #96660a !important; }
.badge.bg-secondary { background: #ece8f5 !important; color: #6d6488; }
.badge.bg-primary { background: var(--jd-purple-soft) !important; color: var(--jd-purple); }
.badge.bg-info { background: #e2f1f8 !important; color: #1f7a99; }

/* การ์ดตัวเลขสรุป: ขอบบาง + แถบสีคาดบน */
.card-summary { border-radius: var(--radius-m); }
.card-summary[class*="border-"] { border: 1px solid var(--jd-line) !important; border-top-width: 4px !important; }
.card-summary.border-success { border-top-color: var(--ok) !important; }
.card-summary.border-danger { border-top-color: var(--bad) !important; }
.card-summary.border-warning { border-top-color: var(--warn) !important; }
.card-summary.border-primary { border-top-color: var(--jd-purple) !important; }
.card-summary.border-secondary { border-top-color: var(--jd-muted) !important; }
.card-summary.border-info { border-top-color: var(--jd-blue) !important; }
.card-summary.border-bill { border: 1px solid var(--jd-line) !important; border-top: 4px solid #8657c9 !important; }
.card-summary.border-bill .num { color: #8657c9; }

/* ตาราง: hover ม่วงจาง + หัวตารางโทนเดียวกัน */
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f4f0fc; }
.table thead.table-light th { color: #5c5375; }
.nav-tabs .nav-link:hover { background: var(--jd-purple-soft); border-radius: 10px 10px 0 0; }

/* สีสถานะมาตรฐาน Bootstrap (สดจัด) → เฉดนุ่มของระบบ — มีผลทุกหน้าอัตโนมัติ
   (badge ใช้ชุดพาสเทลด้านบนแล้ว — ที่นี่เก็บเฉพาะ text-*/border-*) */
.text-success { color: var(--ok) !important; }
.text-danger { color: var(--bad) !important; }
.text-warning { color: var(--warn) !important; }
.border-primary { border-color: #c3b4ec !important; }
.border-success { border-color: #b3dfc4 !important; }
.border-warning { border-color: #ecd9a8 !important; }
.border-danger { border-color: #f0bcb8 !important; }
.border-secondary { border-color: #d8d2e4 !important; }
.card-summary .num { color: var(--jd-ink); }
.table-hover > tbody > tr:hover > * { background-color: #f6f3fc; }

.card-summary .num { font-size: 2rem; font-weight: 700; line-height: 1; }
.doc-no-big { font-size: 1.9rem; font-weight: 700; color: var(--jd-purple); letter-spacing: .5px; line-height: 1.2; }
.table td, .table th { vertical-align: middle; }
.badge-job { color: #fff; font-size: .85rem; }
.return-flag { color: #dc3545; font-weight: 700; }
.v-icon { font-size: 1.5rem; line-height: 1; }
.v-img { height: 1.7em; vertical-align: -0.45em; }
.bc-icon .v-img { height: 2.4rem; vertical-align: baseline; }
.note-cell { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #7d7395; }

/* timestamp ที่กดเพื่อย้อนสถานะได้ */
.ts-revert { color: var(--jd-blue); text-decoration: underline dotted; cursor: pointer; font-weight: 600; }
.ts-revert:hover { color: #dc3545; }

/* autocomplete สินค้า */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; z-index: 2000; top: 100%; left: 0; right: 0;
  background: #fff; border: 1px solid #ced4da; border-radius: .375rem;
  max-height: 260px; overflow-y: auto; box-shadow: 0 4px 10px rgba(0,0,0,.15);
}
.ac-item { padding: .4rem .7rem; cursor: pointer; }
.ac-item:hover, .ac-item.active { background: #efe9fb; }
.ac-item .code { font-weight: 600; color: var(--jd-purple); margin-right: .5rem; }
.ac-item.ac-create { color: var(--jd-blue); font-weight: 600; border-top: 1px dashed #ced4da; }

/* ปุ่มใหญ่สำหรับ tablet */
.btn-touch { min-height: 44px; }

/* ---- notification เด้งขวาล่าง ---- */
#notifyBox { position: fixed; bottom: 16px; right: 16px; z-index: 4000; display: flex; flex-direction: column-reverse; gap: 10px; max-width: 360px; }
.notify-card {
  background: #fff; border-left: 6px solid var(--jd-purple); border-radius: .5rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.25); padding: .7rem 1rem;
  animation: slideIn .3s ease-out;
}
.notify-card .n-title { font-weight: 700; }
.notify-card .n-body { font-size: .92rem; color: #555; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- จอ TV (board / driver-board / control-tower) — ม่วงเข้มตระกูลเดียวกับระบบ ---- */
body.board {
  background: linear-gradient(180deg, #221a48 0%, #171128 55%, #14101f 100%);
  background-attachment: fixed;
  min-height: 100vh; color: #f1edfa; overflow-x: hidden;
}
.board-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem 1.3rem; margin-bottom: .9rem;
  background: rgba(38, 30, 72, .6); border-bottom: 1px solid #352b5e;
}
.board-clock { font-size: 2.3rem; font-weight: 700; letter-spacing: 1px; }
.wh-section { margin-bottom: 1.2rem; }
.wh-section-header {
  display: flex; align-items: baseline; gap: .8rem; padding: .45rem 1.1rem; margin-bottom: .6rem;
  background: #261e4a; border-radius: 12px; border-left: 6px solid var(--jd-brand-red);
}
.wh-section-header .wh-code { font-size: 1.7rem; font-weight: 700; }
.wh-section-header .wh-name { font-size: 1.1rem; color: #a89bd0; }
.board-col {
  background: #251d42; border: 1px solid #342a5c; border-radius: 16px;
  min-height: 160px; height: 100%; overflow: hidden;
}
.board-col-header {
  font-size: 1.15rem; font-weight: 700; padding: .55rem .95rem;
  border-bottom: 1px solid #342a5c; background: rgba(255, 255, 255, .03);
  display: flex; justify-content: space-between;
}
.board-card {
  background: #2e2557; border: 1px solid #3a3066; border-left: 6px solid var(--jd-blue);
  border-radius: 12px; margin: .55rem; padding: .55rem .75rem; display: flex; gap: .6rem;
}
.board-card .bc-icon { font-size: 2.3rem; line-height: 1.1; }
.board-card .plate { font-size: 1.45rem; font-weight: 700; }
.board-card .plate .no-plate { color: #8d7fb8; font-size: 1.1rem; font-style: italic; }
.board-card .meta { font-size: .92rem; color: #a89bd0; }
.board-card.status-unloading { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,193,7,.35); } 50% { box-shadow: 0 0 0 8px rgba(255,193,7,0); } }

/* ---- Phase 2: บอร์ดรถขาออก (fleet.html) — drag & drop เป็นหลัก (นิ้ว+เมาส์) ---- */
.spot-strip { display: flex; flex-wrap: wrap; gap: .55rem; }
.spot-chip {
  min-width: 106px; text-align: center; border-radius: 12px; padding: .38rem .7rem;
  border: 0; box-shadow: inset 0 0 0 1.5px var(--ok-line);
  background: var(--ok-soft); color: #1e7a48; font-weight: 700; font-size: 1.02rem;
  transition: transform .12s, background .12s;
}
.spot-chip .sp-plate { font-size: .8rem; font-weight: 600; display: block; line-height: 1.15; opacity: .85; }
.spot-chip.occupied { background: var(--bad-soft); color: #b3372f; box-shadow: inset 0 0 0 1.5px var(--bad-line); }
/* ปิดชั่วคราวหน้างาน (มีสิ่งกีดขวาง) — เทาลายเฉียง เห็นชัดว่าใช้ไม่ได้แต่ไม่ใช่ "มีรถ" */
.spot-chip.blocked {
  color: #6c6580; box-shadow: inset 0 0 0 1.5px #c9c3d6;
  background: repeating-linear-gradient(45deg, #ece9f1, #ece9f1 6px, #e0dce8 6px, #e0dce8 12px);
}
.spot-chip.clickable { cursor: pointer; }
.spot-chip.clickable:hover { transform: translateY(-1px); filter: brightness(.97); }
.spot-chip.pickable { cursor: pointer; }
.spot-chip.pickable:hover, .spot-chip.picked { outline: 3px solid var(--jd-purple); outline-offset: 2px; }
/* ระหว่างลาก: จุดว่างที่รับการวางได้ */
.spot-chip.drop-ok { outline: 3px dashed var(--jd-purple); outline-offset: 2px; }
.spot-chip.drop-hover { background: var(--jd-purple); color: #fff; box-shadow: none; transform: scale(1.1); }

/* คอลัมน์สถานะ: หัวพาสเทล + ป้ายนับสีเข้ม — นุ่มแต่เขตยังชัด */
.fleet-col {
  --acc: #7a6ab8;
  border: 1px solid color-mix(in srgb, var(--acc) 28%, #fff);
  border-radius: var(--radius-l); background: #fff;
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; height: 100%; min-height: 420px; overflow: hidden;
}
.fleet-col.c-waiting { --acc: #6a4fc0; }
.fleet-col.c-unloading { --acc: #d99416; }
.fleet-col.c-docked { --acc: #2c5fd8; }
.fleet-col.c-loaded { --acc: #d98324; }
.fleet-col.c-billed { --acc: #8657c9; }
/* คอลัมน์สถานะกว้างเท่ากันเสมอ — flex item ต้อง min-width:0 ไม่งั้นการ์ดที่ข้อความยาว
   (เช่น ชื่อลูกค้าหลายรายต่อบิล) จะดันคอลัมน์ตัวเองให้บานออก (user 24/08)
   ผูกกับ .fleet-col ผ่าน :has เพราะหน้า fleet.html ไม่มี class ที่ body */
.row > [class*="col-"]:has(> .fleet-col) { min-width: 0; }
.fleet-col.c-departed { --acc: #2f9e63; }
.fleet-col-header {
  background: color-mix(in srgb, var(--acc) 13%, #fff);
  color: color-mix(in srgb, var(--acc) 80%, #000);
  font-weight: 700; font-size: 1.1rem;
  padding: .6rem .9rem; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid color-mix(in srgb, var(--acc) 16%, #fff);
}
.fleet-col-header .cnt {
  background: var(--acc); color: #fff; border-radius: 999px;
  padding: 0 .7rem; min-width: 2rem; text-align: center; font-size: 1rem;
}
.fleet-col-body {
  padding: .65rem; flex: 1; display: flex; flex-direction: column; gap: .6rem;
  background: color-mix(in srgb, var(--acc) 4%, #fff);
}
.fleet-col.drop-ok { border: 2px dashed var(--acc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--acc) 25%, transparent); }
.fleet-col.drop-ok .fleet-col-body { background: color-mix(in srgb, var(--acc) 12%, #fff); }
.fleet-col.drop-hover { box-shadow: 0 0 0 6px color-mix(in srgb, var(--acc) 50%, transparent); }
.fleet-col .empty-hint { color: #b3a8c5; text-align: center; padding: 1.6rem 0; font-size: .95rem; }

/* การ์ดรถขาออก: 2 บรรทัดจบ — ตัวใหญ่เต็มความกว้างการ์ด (จอคอมการ์ดกว้าง ~400px ต้องไม่เหลือที่ว่าง) */
/* การ์ดรถ: บอร์ด 5 คอลัมน์แล้ว — ขนาดกะทัดรัด ประหยัดแนวตั้ง แต่ทะเบียนยังอ่านชัด */
.fleet-card {
  background: #fff; border: 1.5px solid var(--jd-line); border-radius: var(--radius-m); padding: .45rem .6rem;
  display: flex; align-items: center; gap: .55rem; text-align: left;
  cursor: grab; position: relative;
  box-shadow: var(--shadow-1); user-select: none; -webkit-user-select: none;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.fleet-card:hover { border-color: #cbbcf0; box-shadow: var(--shadow-2); transform: translateY(-1px); }
.fleet-card:active { cursor: grabbing; }
.fleet-card.drag-src { opacity: .35; }
.fleet-card .fc-icon { font-size: 1.9rem; line-height: 1.1; pointer-events: none; flex-shrink: 0; }
.fleet-card .fc-icon .v-img { height: 1.9rem; vertical-align: baseline; }
.fleet-card .fc-body { min-width: 0; flex: 1; pointer-events: none; }
.fleet-card .fc-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.fleet-card .fc-plate { font-size: 1.12rem; font-weight: 700; line-height: 1.2; pointer-events: none; white-space: nowrap; }
.fleet-card .fc-time { font-size: .82rem; color: #6c757d; white-space: nowrap; flex-shrink: 0; }
.fleet-card .fc-meta {
  font-size: .82rem; color: var(--jd-muted); pointer-events: none; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* เช็คเกอร์ = ข้อมูลที่หน้างานมองหาบ่อยสุด → เน้นสีม่วงตามดีไซน์ */
.fleet-card .fc-chk { color: var(--jd-purple); font-weight: 600; white-space: nowrap; }
.fleet-card .fc-chk i { margin-right: .15rem; }
.fleet-card .fc-queue {
  position: absolute; top: -8px; left: -8px; width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--jd-purple-600), var(--jd-purple-dark));
  color: #fff; font-weight: 700; font-size: .92rem;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(70, 48, 127, .35);
}
.fleet-card .fc-spot { position: absolute; top: -8px; right: -8px; font-size: .8rem; }
.fleet-card .fc-spot.badge { background: var(--jd-brand-red) !important; border-radius: 999px; padding: .35em .8em;
  color: #000 !important; font-weight: 700; }  /* ตัวอักษรดำสนิท — แดงเข้มบนพื้นแดงจัดอ่านไม่ออก */
/* modal เลือกบิลเปิดซ้อนบน dock/job modal — ต้องอยู่เหนือทั้ง modal และ backdrop ของตัวแรก (bootstrap 1055/1050) */
#billModal { z-index: 1075; }
.modal-backdrop.bill-backdrop { z-index: 1070; }
.fleet-card.departed { opacity: .8; cursor: default; }
/* เป้าแทรกคิวระหว่างลากในคอลัมน์จอดรอ */
.fleet-card.drop-before { box-shadow: 0 -5px 0 0 var(--jd-purple), 0 2px 6px rgba(0,0,0,.12); }

.pool-chip {
  display: inline-flex; align-items: center; gap: .5rem; background: #fff; border: 1.5px solid var(--jd-line);
  border-radius: 999px; padding: .4rem 1rem .4rem .8rem; cursor: grab; user-select: none; -webkit-user-select: none;
  box-shadow: var(--shadow-1); transition: box-shadow .15s, border-color .15s;
}
.pool-chip:hover { border-color: #cbbcf0; box-shadow: var(--shadow-2); }
.pool-chip .fc-icon { font-size: 2.2rem; line-height: 1; pointer-events: none; }
.pool-chip .fc-icon .v-img { height: 2.2rem; vertical-align: baseline; }
.pool-chip .fc-plate { font-weight: 700; font-size: 1.02rem; pointer-events: none; }
/* ข้อมูลอยู่บรรทัดเดียว — ชิปยาวขึ้นได้ แต่ไม่หนาขึ้น (user 24/08) */
.pool-chip .pc-text { display: inline-flex; align-items: baseline; gap: .4rem; white-space: nowrap; pointer-events: none; }
.pool-chip .pc-sub { font-size: .8rem; color: var(--jd-muted); }
.pool-chip .fc-icon { font-size: 1.7rem; }
.pool-chip .fc-icon .v-img { height: 1.7rem; }
.pool-chip { padding: .3rem .9rem .3rem .7rem; }
.pool-chip.off { opacity: .7; background: #f4f2f7; cursor: pointer; }
.pool-chip.drag-src { opacity: .35; }

/* คอลัมน์ส่งออกแล้ว: รวบเป็นกลุ่มต่อคัน — คันเดียวหลายรอบไม่กินพื้นที่ */
.dep-group {
  background: #fff; border: 1.5px solid var(--ok-line); border-radius: var(--radius-m);
  padding: .45rem .65rem; box-shadow: var(--shadow-1);
}
.dep-group .dg-head { display: flex; align-items: center; gap: .45rem; font-weight: 700; font-size: 1.02rem; }
.dep-group .dg-head .fc-icon { font-size: 1.5rem; line-height: 1; }
.dep-group .dg-head .fc-icon .v-img { height: 1.5rem; vertical-align: baseline; }
.dep-group .dg-driver { font-size: .82rem; font-weight: 400; color: #6c757d; }
.dep-trip {
  display: flex; align-items: baseline; gap: .4rem; flex-wrap: nowrap;
  font-size: .82rem; color: #5c5375; padding: .1rem 0 .1rem 1.9rem; cursor: pointer;
  border-top: 1px dashed #e3efe7;
}
.dep-trip .dt-time { font-weight: 600; color: var(--jd-ink); flex: none; }
.dep-trip .dt-dest { flex: 1 1 auto; min-width: 0; }
.dep-trip .dt-chk { flex: none; color: var(--jd-purple); font-weight: 600; }
.dep-trip:first-of-type { border-top: 0; }
/* แต่ละชิ้นข้อมูลในรอบส่งออก ยาวเกินคอลัมน์ = ตัดเป็น … (ไม่ดันการ์ดกว้าง) */
.dep-trip > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep-trip:hover { color: var(--jd-purple); }

/* แดชบอร์ดสรุป: กราฟแท่งคู่ต่อช่วงเวลา */
.duo-chart { display: flex; align-items: flex-end; gap: 6px; height: 230px; }
.duo-bars { width: 100%; display: flex; align-items: flex-end; gap: 2px; height: calc(100% - 2.2em); }
.duo-bars .db { flex: 1; border-radius: 3px 3px 0 0; min-height: 2px; }

/* ปุ่มเลื่อนใบเอกสาร ◀ 2/40 ▶ (มุมขวาบนหน้าใบ QC) — ม่วงจางให้เด่นจากเนื้อหา */
.btn.doc-nav-btn {
  background: var(--jd-purple-soft); color: var(--jd-purple); border: 0;
  border-radius: 10px; font-weight: 700; padding: .25rem .75rem;
}
.btn.doc-nav-btn:hover { background: var(--jd-purple); color: #fff; }
.btn.doc-nav-btn.disabled { background: var(--jd-purple-soft); color: var(--jd-purple); opacity: .35; }
.doc-nav-count { color: var(--jd-purple); font-weight: 700; font-size: .95rem; padding: 0 .15rem; }

/* หัวคอลัมน์คลิกเรียงได้ (หน้าสถิติรถขาออก) */
th[data-k] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-k]:hover { background: #ece4d4; }

/* กราฟแท่งรายชั่วโมง (หน้าสถิติรถขาออก) — CSS ล้วน */
.hour-chart { display: flex; align-items: flex-end; gap: 3px; height: 240px; }
.hc-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.hc-val { font-size: .72rem; color: var(--jd-purple); font-weight: 700; line-height: 1.2; }
.hc-bar { width: 100%; background: linear-gradient(180deg, var(--jd-purple), #8f7ac9); border-radius: 3px 3px 0 0; min-height: 2px; }
.hc-lbl { font-size: .68rem; color: #999; line-height: 1.4; }

/* ก้อนลอยตามนิ้ว/เมาส์ระหว่างลาก */
.drag-ghost {
  position: fixed; z-index: 6000; pointer-events: none; width: 210px;
  transform: translate(-50%, -75%) rotate(-3deg); opacity: .93;
}
.drag-ghost .fleet-card { box-shadow: 0 10px 24px rgba(0,0,0,.35); border-color: var(--jd-purple); }

/* ปุ่มจุดจอดใน modal เรียกเข้า Dock — แตะครั้งเดียวจบ */
.dock-pick-btn {
  min-width: 108px; font-size: 1.25rem; font-weight: 700; padding: .8rem .6rem;
}

/* chips เลือกเช็คเกอร์ — แตะเลือก/แตะซ้ำเอาออก */
.chk-chip {
  background: #fff; box-shadow: inset 0 0 0 1.5px var(--jd-line); color: var(--jd-ink);
  border-radius: 12px; padding: .42rem .9rem; font-weight: 700; cursor: pointer;
  user-select: none; transition: background .12s, transform .12s;
}
.chk-chip:hover { box-shadow: inset 0 0 0 1.5px #cbbcf0; }
.chk-chip.picked { background: var(--jd-purple); color: #fff; box-shadow: none; transform: scale(1.04); }

/* ---- Phase 2: จอเรียกคนขับ (driver-board.html) — จอใหญ่ธีมมืด ---- */
.drv-called-row {
  display: flex; align-items: center; justify-content: center; gap: 2.5rem;
  background: linear-gradient(90deg, rgba(47, 158, 99, .22), #251d42 60%);
  border: 1px solid #342a5c; border-left: 14px solid #2f9e63;
  border-radius: 18px; padding: 1.2rem 2rem; margin-bottom: 1.2rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
}
.drv-called-row .d-plate { font-size: 4.5rem; font-weight: 700; line-height: 1.1; }
.drv-called-row .d-arrow { font-size: 3.5rem; color: #8d7fb8; }
.drv-called-row .d-spot {
  font-size: 4.5rem; font-weight: 700; line-height: 1.1; color: #5ad48e;
  background: rgba(74, 190, 120, .13); border-radius: 20px; padding: 0 1.6rem;
  box-shadow: inset 0 0 0 2px rgba(74, 190, 120, .4);
}
.drv-called-row .d-icon { font-size: 4rem; }
.drv-called-row .d-icon .v-img { height: 4.2rem; vertical-align: baseline; }
.drv-wait-row {
  display: flex; align-items: center; gap: 1.2rem;
  background: #251d42; border: 1px solid #342a5c;
  border-radius: 14px; padding: .6rem 1.4rem; margin-bottom: .6rem;
}
.drv-wait-row .w-no { font-size: 2rem; font-weight: 700; color: #a89bd0; min-width: 64px; }
.drv-wait-row .w-plate { font-size: 2.2rem; font-weight: 700; }
.drv-wait-row .w-icon { font-size: 2.2rem; }
.drv-wait-row .w-icon .v-img { height: 2.4rem; vertical-align: baseline; }
.drv-head { font-size: 1.6rem; font-weight: 700; margin: .8rem 0 .6rem; color: #a89bd0; }

/* ---- Phase 3: Control Tower (control-tower.html) — จอ TV read-only ---- */
.tw-section {
  background: #251d42; border: 1px solid #342a5c; border-radius: 16px;
  padding: .75rem 1.05rem; margin-bottom: 1rem;
}
.tw-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .55rem; }
.tw-head .wh-code { font-size: 1.6rem; font-weight: 700; }
.tw-head .wh-name { color: #a89bd0; }
.tw-kpi { display: flex; gap: .5rem; flex-wrap: wrap; margin-left: auto; }
.tw-kpi .chip {
  background: #2e2557; border: 1px solid #3a3066; border-radius: 999px;
  padding: .18rem .85rem; font-size: .92rem; color: #a89bd0;
}
.tw-kpi .chip b { font-size: 1.12rem; color: #fff; margin-right: .15rem; }
.tw-kpi .chip.warn b { color: #ffd35c; }
.tw-kpi .chip.crit b { color: #ff8b95; }
.tw-spots { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .6rem; }
.tw-spot {
  min-width: 100px; text-align: center; border: 0; border-radius: 12px;
  background: rgba(74, 190, 120, .13); box-shadow: inset 0 0 0 1.5px rgba(74, 190, 120, .4);
  padding: .3rem .6rem; color: #7fe3aa; font-weight: 700;
}
.tw-spot.occupied {
  background: rgba(226, 92, 82, .14); box-shadow: inset 0 0 0 1.5px rgba(226, 92, 82, .42);
  color: #ffb3ac;
}
.tw-spot .sp-sub { display: block; font-size: .78rem; font-weight: 600; color: #cfc4ec; line-height: 1.15; }
.tw-spot.blocked {
  background: rgba(150, 140, 175, .16); box-shadow: inset 0 0 0 1.5px rgba(150, 140, 175, .4);
  color: #b3aacb;
}
.tw-lane { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.tw-lane .lane-label { font-size: .95rem; color: #a89bd0; min-width: 145px; }

/* Control Tower: แบ่งครึ่งจอต่อคลัง — ซ้ายขาเข้า / ขวาขาออก */
.tw-split { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; align-items: start; }
.tw-side {
  background: rgba(255, 255, 255, .035); border: 1px solid #342a5c;
  border-radius: 14px; padding: .55rem .7rem .3rem;
}
.tw-side .side-title {
  font-weight: 700; font-size: 1.05rem; letter-spacing: .3px;
  margin-bottom: .45rem; padding-bottom: .35rem; border-bottom: 1px solid #3a3067;
}
.tw-side.s-in .side-title { color: #8fc4ff; }
.tw-side.s-out .side-title { color: #ffc98f; }
@media (max-width: 1100px) { .tw-split { grid-template-columns: 1fr; } }
.tw-truck {
  display: inline-flex; align-items: center; gap: .45rem;
  background: #2e2557; border: 1.5px solid #453a76; border-radius: 999px; padding: .28rem .8rem;
}
.tw-truck .t-icon { font-size: 1.6rem; line-height: 1; }
.tw-truck .t-icon .v-img { height: 1.7rem; vertical-align: baseline; }
.tw-truck .t-plate { font-weight: 700; }
.tw-truck .t-min { font-size: .85rem; color: #b6a8dd; }
/* aging: เหลือง ≥30 นาที / แดงกะพริบ ≥60 นาที (เกณฑ์อยู่ใน JS) */
.age-warn { border-color: #e0a800 !important; }
.age-warn .t-min, .age-warn .sp-sub { color: #ffd35c !important; }
.age-crit { border-color: #dc3545 !important; animation: pulse 2s infinite; }
.age-crit .t-min, .age-crit .sp-sub { color: #ff8b95 !important; }
/* กราฟชั่วโมง: วันนี้ (สว่าง) เทียบเฉลี่ย 7 วัน (ทึบ) */
.tw-hours { display: flex; align-items: flex-end; gap: 4px; height: 150px; }
.tw-hc { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.tw-hc .val { font-size: .7rem; color: #cbbdf0; font-weight: 700; line-height: 1.1; }
.tw-hc .bars { width: 100%; flex: 0 0 auto; display: flex; align-items: flex-end; gap: 2px; height: calc(100% - 2.1em); }
.tw-hc .b-avg { flex: 1; background: #443a6e; border-radius: 2px 2px 0 0; }
.tw-hc .b-today { flex: 1; background: linear-gradient(180deg, #8f7ac9, #5b3fa8); border-radius: 2px 2px 0 0; }
.tw-hc .lbl { font-size: .68rem; color: #8d7fb8; line-height: 1.3; }
.tw-legend { color: #b6a8dd; font-size: .85rem; }
.tw-legend .sw { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin: 0 .3rem 0 .8rem; }

/* ---- รูปแนบ ---- */
.img-thumb { width: 110px; height: 110px; object-fit: cover; border-radius: .4rem; cursor: pointer; border: 2px solid #ded3ba; }

/* ---- งานพิมพ์ (print.html) : ทุกแบบฟอร์ม = A4 แนวนอน ---- */
.paper-preview { background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.2); margin: 0 auto 14px; padding: 8mm; width: 100%; max-width: 297mm; aspect-ratio: 297/210; overflow: hidden; }
.print-doc { font-size: 14px; color: #000; }
.print-doc h4 { font-weight: 700; }
.print-doc table.doc-table { width: 100%; border-collapse: collapse; }
.print-doc table.doc-table th, .print-doc table.doc-table td { border: 1px solid #000; padding: 4px 8px; }
.sign-box { display: inline-block; width: 23%; text-align: center; margin-top: 46px; }
.sign-line { border-top: 1px dotted #000; margin: 0 15px; padding-top: 4px; }

/* ----- ใบ QC ตามฟอร์ม FM-QC01-01 ----- */
.qc-form { font-size: 11.5px; }
.qc-frame { border: 2px solid #000; }
.qc-title { text-align: center; font-weight: 700; font-size: 15px; padding: 4px; border-bottom: 1px solid #000; }
.qc-cols { display: flex; }
.qc-col { flex: 1; padding: 4px; min-width: 0; }
.qc-col + .qc-col { border-left: 0; }
.qc-sect { background: #fbe5c0; font-weight: 700; text-align: center; border: 1px solid #000; padding: 2px 4px; margin-top: 6px; }
/* ใบรับสินค้าคืน = ธีมฟ้าม่วง (แยกจากใบรับเข้าที่เป็นส้มครีม) */
.rt-form .qc-sect { background: #dde3f7; }
.qc-sect:first-child { margin-top: 0; }
.qc-form table { width: 100%; border-collapse: collapse; }
.qc-form table.bx td, .qc-form table.bx th { border: 1px solid #000; padding: 2px 5px; vertical-align: middle; }
.qc-form .lbl { width: 38%; background: #fff; }
.qc-form .ck { width: 34px; text-align: center; font-weight: 700; }
.qc-line { border-bottom: 1px solid #000; min-height: 17px; padding: 1px 4px; }
.qc-sign { margin-top: 14px; }
.qc-sign .s-line { border-bottom: 1px dotted #000; display: inline-block; min-width: 130px; text-align: center; padding: 0 6px; }

/* ---------- บล็อกแบ่งช่วงของฟอร์มกรอกเอกสาร — ตัดหลังจุดลายเซ็นของแต่ละฝ่าย ---------- */
.form-block {
  border: 1.5px solid var(--jd-line);
  border-radius: var(--radius-m);
  background: #fff;
  padding: 0 .9rem .3rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow-1);
}
.form-block > .fb-title {
  margin: 0 -.9rem .8rem;
  padding: .5rem .9rem;
  background: var(--jd-purple-soft);
  color: var(--jd-purple);
  font-weight: 700;
  border-bottom: 1px solid var(--jd-line);
  border-radius: calc(var(--radius-m) - 2px) calc(var(--radius-m) - 2px) 0 0;
  display: flex; align-items: center; gap: .4rem;
}
/* ลายเซ็นคือบรรทัดปิดท้ายบล็อก — คั่นด้วยเส้นบางให้เห็นว่าจบช่วงความรับผิดชอบ */
.form-block .qcn-sign, .form-block .rt-sign { border-top: 1px dashed var(--jd-line); padding-top: .55rem; }

/* ---------- ช่องวันที่แสดง DD/MM/YYYY (overlay ทับ native ที่แสดงตามภาษาเครื่อง) ---------- */
input.jd-dt:not(:focus)::-webkit-datetime-edit { color: transparent; }
.jd-dt-ov {
  position: absolute; pointer-events: none; color: var(--jd-ink);
  white-space: nowrap; overflow: hidden;
}

/* ---------- Pagination มาตรฐานของระบบ (แบบ Odoo) — ใช้ทุกหน้าที่มีการแบ่งหน้า ---------- */
.jd-pager { display: inline-flex; align-items: center; gap: .15rem; user-select: none; }
.jd-pager-range {
  font-weight: 600; color: var(--jd-ink); padding: .2rem .55rem; border-radius: 8px;
  cursor: pointer; white-space: nowrap;
}
.jd-pager-range:hover { background: var(--jd-purple-soft); color: var(--jd-purple); }
.jd-pager-input {
  width: 90px; font-weight: 600; text-align: center; padding: .15rem .35rem;
  border: 1px solid var(--jd-purple); border-radius: 8px; outline: none;
}
.jd-pager-btn {
  background: transparent; border: 0; color: var(--jd-purple); font-size: 1.15rem; line-height: 1;
  padding: .1rem .45rem; border-radius: 8px; cursor: pointer;
}
.jd-pager-btn:hover:not(:disabled) { background: var(--jd-purple-soft); }
.jd-pager-btn:disabled { opacity: .3; cursor: default; }

/* ---------- คิวรถขาเข้า: เซลล์เวลาแบบกดเพื่อ stamp (แทนปุ่มสถานะ) ---------- */
.ts-cell { text-align: center; white-space: nowrap; }
.ts-act {
  border: 0; border-radius: 8px; padding: .2rem .8rem; font-weight: 700; color: #fff;
  font-size: .86rem; line-height: 1.5; cursor: pointer; box-shadow: var(--shadow-1);
}
.ts-act:hover { filter: brightness(1.07); }
.ts-act.a-arrived { background: #2f9e5f; }     /* มาถึง */
.ts-act.a-unloading { background: #d98324; }   /* เริ่มลงของ */
.ts-act.a-done { background: #d64545; }        /* เสร็จสิ้น */
/* ชิปเวลา: บาง อ่านง่าย ไม่ดันความสูงแถว (user 23/08 — เดิมหนาเกินไป ดูเทอะทะ) */
.ts-stamp {
  display: inline-block; min-width: 56px; padding: .1rem .6rem; border-radius: 8px;
  background: #eceaf3; color: #5c5375; font-weight: 600; font-size: .86rem; line-height: 1.55;
  border: 1px solid var(--jd-line);
}
.ts-stamp.can-revert { cursor: pointer; }
.ts-stamp.can-revert:hover { background: #fde8e8; color: #b02a2a; border-color: #f3c6c6; }
.ts-none { color: #cfc9dd; }

/* พื้นแถวบอกสถานะคิว — เห็นได้ทันทีว่ากำลังจัดการคิวไหน */
tr.qrow-arrived > * { background-color: #eaf3ff !important; }
tr.qrow-unloading > * { background-color: #fff4e2 !important; }
tr.qrow-done > * { background-color: #e9f7ee !important; }
tr.qrow-cancelled > * { background-color: #f5f3f7 !important; color: #9a93ad; }
tr.qrow-cancelled .fw-bold { text-decoration: line-through; }

/* ปุ่ม ผ่าน/ไม่ผ่าน บนหน้าจอกรอก */
.pf-btn { min-width: 64px; }
.pf-btn.active-pass { background: #198754; color: #fff; border-color: #198754; }
.pf-btn.active-fail { background: #dc3545; color: #fff; border-color: #dc3545; }

/* ป้ายขาเหล็ก: 3 ใบชิดกันเต็มหน้า A4 แนวนอน ไม่มีขอบ — ตัดตามเส้นแบ่งแค่ 2 ครั้ง */
.label-row { display: flex; height: 100%; }
.paper-preview.label-page { padding: 0; }
.pallet-label {
  width: 33.333%; border: 3px solid #000; padding: 6mm 5mm; margin: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.pallet-label + .pallet-label { border-left: 0; }  /* เส้นแบ่งใช้ร่วมกัน = แนวตัดกรรไกร */
.pallet-label .lbl-head { border-bottom: 3px solid #000; padding-bottom: 4px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.pallet-label .product-name { font-size: 26px; font-weight: 700; line-height: 1.25; }
.pallet-label .big { font-size: 19px; font-weight: 700; }
.pallet-label table { width: 100%; font-size: 15px; margin-top: auto; }
.pallet-label td { padding: 3px 4px; }

/* ----- บิล OUT จาก Odoo แนบการ์ดรถ: chip + picker ----- */
.bill-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; }
.bill-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px 3px 10px; border-radius: 999px;
  font-size: .84rem; font-weight: 600; border: 1px solid #cfd8dc; background: #eceff1; color: #37474f; }
.bill-chip.co-JD { background: #e3f1f6; border-color: #bcd9e4; color: #1f6f8b; }
.bill-chip.co-JF { background: #fbeedd; border-color: #eccfa6; color: #b45f06; }
.bill-chip.co-BAH { background: #e4f3e8; border-color: #b9dcc3; color: #1f6f3b; }   /* ใบสั่งเบิกซื้อฝาก */
.bill-chip small { font-weight: 400; color: #6e6979; }
.bill-chip .bc-pdf, .bill-chip .bc-x { border: 0; background: transparent; cursor: pointer; padding: 0 3px; line-height: 1; font-size: .95rem; color: inherit; opacity: .75; }
.bill-chip .bc-pdf:hover, .bill-chip .bc-x:hover { opacity: 1; }
.bill-chip .bc-x { font-size: 1.05rem; }
#bpList .bp-day { position: sticky; top: 0; z-index: 2; background: #faf9fc; border-bottom: 1px solid #dcd8e3;
  padding: 7px 14px; font-weight: 700; font-size: .9rem; display: flex; gap: 10px; align-items: baseline; cursor: pointer; user-select: none; }
#bpList .bp-day:hover { background: #f3f0f8; }
#bpList .bp-day.today { background: #ede8f7; color: #5b3fa3; }
#bpList .bp-day.past { color: #6e6979; }
#bpList .bp-day small { font-weight: 500; color: #6e6979; }
#bpList .bp-day .caret { display: inline-block; width: 1em; transition: transform .15s; color: #6e6979; }
#bpList .bp-day.open .caret { transform: rotate(90deg); }
#bpList .bp-hint { margin-left: auto; font-weight: 500; font-size: .8rem; color: #6e6979; }
#bpList .bp-day.past .bp-hint { color: #b26a00; }
#bpList .bp-cust { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px; padding: 6px 14px 4px; border-top: 1px solid #eeecf2; }
#bpList .bp-cust .bp-name { font-weight: 700; }
#bpList .bp-cust .bp-cnt { color: #6e6979; font-size: .84rem; }
#bpList .bp-cust input, #bpList .bp-bill input { width: 18px; height: 18px; accent-color: #5b3fa3; cursor: pointer; }
#bpList .bp-bill { display: grid; grid-template-columns: 32px 26px 1fr auto; align-items: center; gap: 8px; padding: 5px 14px 5px 28px; cursor: pointer; }
#bpList .bp-bill:hover { background: #f8f6fb; }
#bpList .bp-bill.on { background: #ede8f7; }
#bpList .bp-bill.taken { opacity: .45; cursor: not-allowed; }
.bp-co { font-size: .7rem; font-weight: 800; padding: 1px 5px; border-radius: 4px; text-align: center; }
.bp-co.co-JD { background: #e3f1f6; color: #1f6f8b; } .bp-co.co-JF { background: #fbeedd; color: #b45f06; }
.bp-co.co-BAH { background: #e4f3e8; color: #1f6f3b; }
#bpList .bp-no { font-weight: 700; font-variant-numeric: tabular-nums; }
#bpList .bp-items { color: #6e6979; font-size: .82rem; margin-left: 8px; }
#bpList .bp-tail { display: inline-flex; align-items: center; gap: 6px; }
.bp-st { font-size: .74rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.bp-st.assigned { background: #e4f3e5; color: #2e7d32; }
.bp-st.confirmed { background: #fff1d6; color: #b26a00; }
#bpList .bc-pdf { border: 1px solid #dcd8e3; background: #fff; border-radius: 6px; cursor: pointer; font-size: .85rem; padding: 1px 6px; line-height: 1.4; }
#bpList .bc-pdf:hover { border-color: #5b3fa3; }
@media (max-width: 640px) { #bpList .bp-items { display: none; } }

/* ----- ป้ายขาเหล็ก: A4 แนวนอนแบ่ง 4 คอลัมน์แนวตั้ง — ป้ายละ 74.25×210mm ----- */
/* โครงหน้าตาตามแบบเดิม: กรอบหนา + หัวป้าย + ข้อมูลเป็นแถวมีเส้นแบ่ง */
/* กรอบระหว่างป้ายใช้เส้นร่วมกัน = แนวตัดกรรไกร 3 ครั้ง (ที่ 74.25 / 148.5 / 222.75 mm) */
.strip-page { width: 297mm; height: 210mm; background: #fff; overflow: hidden; display: flex; }
/* หัวแผ่นใน preview (แผ่นที่ N · คลัง JD_01) — ไม่พิมพ์ */
.strip-page-head { font-weight: 700; font-size: 2.2rem; color: var(--jd-purple); margin: 12px 0 6px; }  /* preview ถูก zoom .42 */
.strip-page + .strip-page-head { margin-top: 30px; }
/* เน้นอ่านไกล: ไม่มีหัวบริษัท, หัวข้อจิ๋ว, ค่าใหญ่เต็มแถว (ทุกแถว flex ยืดเต็มความสูง 210mm), จัดกึ่งกลาง */
.strip-col {
  width: 74.25mm; height: 210mm; padding: 1.5mm 3mm; overflow: hidden;
  display: flex; flex-direction: column;
  border: 3px solid #000;
  background: #fff; color: #000; font-family: 'Sarabun', sans-serif;
}
.strip-col + .strip-col { border-left: 0; }  /* เส้นแบ่งใช้ร่วมกัน = แนวตัด */
/* สีตัวอักษรรายบรรทัดต้องออกทางเครื่องพิมพ์เสมอ (บาง browser ตัดสีทิ้งตอนพิมพ์) */
.strip-col, .strip-col * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.sc-row {
  flex: 1; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; border-bottom: 1px solid #999; padding: 0;
}
.sc-row:last-child { border-bottom: 0; }
.sc-row .cap { font-size: 4pt; font-weight: 600; color: #666; line-height: 1; margin: 0; }
/* ขนาดจริงถูก auto-fit ด้วย JS ให้เต็มพื้นที่แถว — ค่านี้เป็นแค่ fallback */
.sc-row .val { font-size: 30pt; font-weight: 700; line-height: 1.1; word-break: break-word;
  width: 100%; margin: 0; }
/* แถวล่าง: 3 ช่องเท่ากันมีเส้นคั่น — ซ้าย=คลังจากระบบ, กลาง=ว่าง (เขียนมือเมื่อย้ายคลัง), ขวา=QR */
.sc-last { flex: 2.4; flex-direction: row; align-items: stretch; gap: 0; padding: 0; }
.sc-last .cell {
  flex: 1 1 0; min-width: 0; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
}
.sc-last .cell + .cell { border-left: 1px solid #999; }
.sc-last .whv { font-size: 44pt; font-weight: 700; line-height: 1; margin: 0; }
/* QR ต้องเล็กกว่าช่อง 1/3 ของป้าย 74.25mm (~22.7mm หักเส้น/ขอบ) */
.sc-qr img, .sc-qr canvas { width: 20mm !important; height: 20mm !important; }

/* ==================== โหมดประหยัดพื้นที่จอ (แท็บเล็ตแนวตั้ง / มือถือ) ====================
   จุดตัด 992px เลือกให้แท็บเล็ต 10-11" แนวตั้ง (~800px) ได้ประโยชน์ด้วย ไม่ใช่แค่มือถือ
   ปัญหาเดิมที่วัดได้ (มือถือ 375px): เมนู 57 + การ์ดสรุป 269 + แถบตัวกรอง 263 = 589px
   จากจอ 812px หมดไปก่อนเห็นข้อมูลแถวแรก — ส่วนนี้คืนพื้นที่ให้ตาราง */

/* 1) การ์ดตัวเลขสรุป → แถบเลื่อนแนวนอนแถวเดียว (~270px เหลือ ~76px) */
@media (max-width: 991.98px) {
  .sum-row {
    flex-wrap: nowrap; overflow-x: auto; margin-inline: 0;
    scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; padding-bottom: .3rem;
  }
  .sum-row::-webkit-scrollbar { height: 4px; }
  .sum-row::-webkit-scrollbar-thumb { background: #d5cfe6; border-radius: 4px; }
  .sum-row > [class*="col-"] { flex: 0 0 auto; width: auto; min-width: 5.4rem; scroll-snap-align: start; }
  .sum-row .card-summary { padding: .35rem .55rem !important; }
  .sum-row .card-summary .num { font-size: 1.35rem; }
  .sum-row .card-summary small { font-size: .72rem; white-space: nowrap; }
}

/* 2) แถบตัวกรองยุบเป็นปุ่ม "ตัวกรอง" (จอ lg ขึ้นไปกางเสมอเหมือนเดิม — desktop ไม่เปลี่ยน) */
@media (max-width: 991.98px) {
  /* min-width:0 จำเป็น — flex item ค่าเริ่มต้น min-width:auto ดันให้กว้างตามเนื้อหาจนล้นจอ */
  .filter-body { flex: 0 0 100%; min-width: 0; }
}
@media (max-width: 575.98px) {
  .filter-body > .row > .col-auto, .filter-body > .row > .col { flex: 1 1 45%; }
  .filter-body .form-select, .filter-body .form-control { width: 100%; }
}

/* 3) ตรึง 2 คอลัมน์แรกตอนเลื่อนตารางไปขวา (เวลา+ทะเบียน / ดาว+เลขที่เอกสาร)
      ตารางกว้าง 1,400px+ ในจอ 375-800px — ไม่ตรึงแล้วเลื่อนไปดูเวลา ทะเบียนหลุดออกนอกจอ */
@media (max-width: 1399.98px) {   /* ครอบคลุมแท็บเล็ต 10-11" แนวนอน (1280px) ที่ตารางยังล้นจอ */
  .tbl-sticky2 { --c1w: 62px; }
  .tbl-sticky2 > thead > tr > th:nth-child(1),
  .tbl-sticky2 > tbody > tr:not(.grp-head) > td:nth-child(1) {
    position: sticky; left: 0; z-index: 3;
    width: var(--c1w); min-width: var(--c1w); max-width: var(--c1w);
  }
  .tbl-sticky2 > thead > tr > th:nth-child(2),
  .tbl-sticky2 > tbody > tr:not(.grp-head) > td:nth-child(2) { position: sticky; left: var(--c1w); z-index: 3; }
  /* พื้นทึบ (แถวมีสีสถานะจะชนะเพราะเป็น !important) + เส้นเงาบอกขอบเขตที่ตรึง */
  .tbl-sticky2 > tbody > tr:not(.grp-head) > td:nth-child(-n+2) { background-color: #fff; }
  .tbl-sticky2 > thead > tr > th:nth-child(-n+2) { background: #efeaf8; z-index: 4; }
  .tbl-sticky2.table-hover > tbody > tr:not(.grp-head):hover > td:nth-child(-n+2) { background-color: #f6f3fc; }
  .tbl-sticky2 > thead > tr > th:nth-child(2),
  .tbl-sticky2 > tbody > tr:not(.grp-head) > td:nth-child(2) { box-shadow: 6px 0 6px -6px rgba(0, 0, 0, .18); }
}

/* 4) บอร์ดรถขาออกบนจอเล็ก: คอลัมน์สูงตามเนื้อหา (เดิมตายตัว 420px × 5 คอลัมน์ = เลื่อน 5 จอ)
      + ผังจุดจอดเป็นแถบเลื่อนแนวนอนแทนการตัดขึ้นบรรทัดใหม่ (เดิมสูง 232px) */
@media (max-width: 991.98px) {
  .fleet-col { min-height: 120px; }
  .fleet-col .empty-hint { padding: .55rem 0; font-size: .85rem; }
  .spot-strip { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .3rem; }
  .spot-strip > * { flex: 0 0 auto; }
  .spot-strip::-webkit-scrollbar { height: 4px; }
  .spot-strip::-webkit-scrollbar-thumb { background: #d5cfe6; border-radius: 4px; }
}

/* 5) นิ้วกด: อุปกรณ์สัมผัสทุกขนาด (รวมแท็บเล็ตแนวนอน) ปุ่ม/ช่องกรอก ≥44px — คนงานใส่ถุงมือ */
@media (pointer: coarse) {
  .table .btn { min-height: 44px; }
  /* ชิปสร้างเอกสารเตี้ยกว่าปุ่มทั่วไป — ไม่งั้นดันแถวคิวรถให้หนา (user 24/08) */
  .btn-newdoc { min-height: 30px; }
  .form-control:not(.form-control-sm), .form-select:not(.form-select-sm) { min-height: 44px; }
}

/* ==================== Redesign 1a "Refined" (23/08/2026) ====================
   ทิศทาง: โครงเดิมทั้งหมด แค่จัดระเบียบใหม่ให้ตาอ่านไวขึ้น — ทำด้วย CSS ล้วน ไม่แตะ markup/JS
   1) การ์ดตัวเลขสรุป 6 ใบ → รวมเป็นแถบเดียว มีเส้นคั่น + จุดสีนำหน้าป้ายกำกับ
   2) แถวในตาราง: เดิมย้อมสีทั้งแถว → เหลือแถบสีริมซ้าย 4px + พื้นจางมาก (ตัวหนังสืออ่านชัดขึ้น)
   3) แถบตัวกรองเป็นชิปลอยบนพื้น ไม่มีการ์ดครอบ */

/* --- 1) การ์ดสรุปรวมเป็นแถบเดียว --- */
.sum-row {
  background: var(--jd-card); border: 1px solid var(--jd-line);
  border-radius: var(--radius-m); box-shadow: 0 1px 5px rgba(91, 63, 168, .05);
  margin-inline: 0;
}
@media (min-width: 992px) { .sum-row { overflow: hidden; } }   /* จอเล็กต้องเลื่อนแนวนอนได้ ห้าม hidden */
/* จอกว้าง: ช่องกว้างตามเนื้อหา ไม่ยืดเต็มจอ (เดิมบานออกจนตัวเลขลอยห่างกันมาก) */
@media (min-width: 992px) {
  .sum-row { width: fit-content; max-width: 100%; }
  .sum-row > [class*="col-"] { flex: 0 0 auto; width: auto; min-width: 8.5rem; }
}
.sum-row > [class*="col-"] { padding: 0; }
.sum-row .card-summary,
.sum-row .card-summary[class*="border-"] {
  border: 0 !important; border-left: 1px solid #efeaf7 !important;
  border-radius: 0; box-shadow: none; background: transparent;
  text-align: left !important; padding: .7rem 1rem !important;
}
.sum-row > [class*="col-"]:first-child .card-summary { border-left: 0 !important; }
/* ป้ายกำกับอยู่บน ตัวเลขอยู่ล่าง (ตามภาพดีไซน์) — DOM เรียงตัวเลขก่อน จึงใช้ column-reverse */
.sum-row .card-summary { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 2px; }
.sum-row .card-summary .num { font-size: 1.6rem; line-height: 1.05; font-weight: 700; }
.sum-row .card-summary small { font-size: .74rem; color: var(--jd-muted) !important; }
/* จุดสีนำหน้าป้ายกำกับ แทนแถบสีด้านบนการ์ดแบบเดิม */
.sum-row .card-summary[class*="border-"] small::before {
  content: ""; display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; margin-right: 5px; vertical-align: middle; background: var(--jd-muted);
}
.sum-row .border-primary small::before { background: var(--jd-purple); }
.sum-row .border-info small::before { background: var(--jd-blue); }
.sum-row .border-warning small::before { background: var(--warn); }
.sum-row .border-success small::before { background: var(--ok); }
.sum-row .border-danger small::before { background: var(--bad); }
.sum-row .border-bill small::before { background: #8657c9; }

/* --- 2) แถวตาราง: แถบสีริมซ้าย แทนการย้อมทั้งแถว --- */
tr.qrow-arrived > * { background-color: #fafbff !important; }
tr.qrow-unloading > * { background-color: #fffdf8 !important; }
tr.qrow-done > * { background-color: #f8fdfa !important; }
tr.qrow-cancelled > * { background-color: #faf9fb !important; color: #9a93ad; }
/* ทุกกฎต้อง specificity เท่ากัน ไม่งั้นกฎรวมด้านบนชนะกฎเฉพาะสถานะ (แถบออกมาเทาหมด) */
tr[class*="qrow-"]:not(.grp-head) > td:first-child { box-shadow: inset 4px 0 0 var(--jd-line); }
tr.qrow-scheduled:not(.grp-head) > td:first-child { box-shadow: inset 4px 0 0 var(--jd-muted); }
tr.qrow-arrived:not(.grp-head) > td:first-child { box-shadow: inset 4px 0 0 var(--jd-blue); }
tr.qrow-unloading:not(.grp-head) > td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
tr.qrow-done:not(.grp-head) > td:first-child { box-shadow: inset 4px 0 0 var(--ok); }
tr.qrow-cancelled:not(.grp-head) > td:first-child { box-shadow: inset 4px 0 0 var(--bad); }

/* ---- หน้าเอกสาร (2b): ชิป "ต้องทำต่อ" + ป้ายประเภทใต้เลขที่เอกสาร ---- */
.doc-kind {
  display: inline-block; border-radius: 5px; padding: 1px 7px; margin-top: 3px;
  font-size: .68rem; font-weight: 600; line-height: 1.5;
}
.doc-kind.k-qc { background: var(--jd-purple-soft); color: var(--jd-purple); }
.doc-kind.k-rt { background: #fbeedd; color: #b45f06; }
.todo-cell { white-space: normal; min-width: 11rem; }
.tdo {
  display: inline-block; border-radius: 7px; padding: 1px 9px; margin: 1px 0;
  font-size: .72rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.tdo-red { background: var(--bad-soft); color: #b3372f; }
.tdo-purple { background: #ece8f5; color: #4d3a8f; }
.tdo-amber { background: var(--warn-soft); color: #96660a; }
.tdo-ok { background: var(--ok-soft); color: #1e7a48; font-weight: 500; }
.tdo-blue { background: #e7f0fb; color: #2b5e9c; }
/* ชิปตัวกรองที่มีสีบอกความเร่งด่วน (ยังไม่ถูกเลือก) */
.fpill.f-red { color: #b3372f; }
.fpill.f-purple { color: #4d3a8f; }
.fpill.f-amber { color: #96660a; }
.fpill.f-red.on { background: #b3372f; color: #fff; }
.fpill.f-purple.on { background: #4d3a8f; color: #fff; }
.fpill.f-amber.on { background: #96660a; color: #fff; }
.fpill.f-blue { color: #2b5e9c; }
.fpill.f-blue.on { background: #2b5e9c; color: #fff; }
/* ---- แดชบอร์ด (2c) ---- */
.dash-kpi { border-top: 4px solid var(--jd-purple); padding: .65rem .85rem; height: 100%; }
.dash-kpi .k-title { font-size: .76rem; color: var(--jd-muted); line-height: 1.3; }
.dash-kpi .k-main { display: flex; align-items: baseline; gap: .45rem; flex-wrap: wrap; }
.dash-kpi .k-num { font-size: 1.35rem; font-weight: 700; line-height: 1.15; }
.dash-kpi .k-prev { font-size: .72rem; color: var(--jd-hint); }
.dash-kpi .badge { font-size: .7rem; padding: .12rem .45rem; }
/* คำอธิบายกราฟอยู่ในหัวการ์ดบรรทัดเดียว แทนบรรทัดใต้กราฟ */
.chart-legend { font-size: .76rem; color: var(--jd-muted); }
.chart-legend .lg-sw {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  margin: 0 .28rem 0 .55rem; vertical-align: baseline;
}
.chart-legend .lg-sw:first-child { margin-left: 0; }
/* Top 5 แบบแถบสัดส่วน */
.top-bars { display: flex; flex-direction: column; gap: .55rem; }
.tb-head { display: flex; gap: .5rem; font-size: .82rem; margin-bottom: .2rem; }
.tb-head .tb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-head b { margin-left: auto; white-space: nowrap; }
.tb-track { height: 7px; border-radius: 4px; background: var(--jd-purple-soft); }
.tb-fill { height: 7px; border-radius: 4px; }

/* ================= หน้ากรอกเอกสาร QC/RT + ป้าย (redesign 3c) =================
   ดีไซน์: ฟอร์มกว้างซ้าย + พรีวิว/แผงคุมกว้าง 672px ติดขวา
           ช่องข้อมูลกรอบ 1.5px มุมมน 10px · ป้ายกำกับ 11.5px
           ช่องบังคับที่ยังว่างขึ้นกรอบแดงอ่อน + แถบ "ยังขาด N ช่อง" ค้างล่างจอ */

@media (min-width: 1400px) {
  .qc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 672px; gap: 14px; margin: 0; align-items: start; }
  .qc-layout > [class*="col-"] { width: auto; max-width: none; flex: none; padding: 0; }
}
/* คอลัมน์ของหน้ากรอกเอกสารต้อง min-width:0 — ไม่งั้นกระดาษพรีวิว (กว้างจริง A4)
   ดันคอลัมน์จนหน้าเลื่อนแนวนอนบนแท็บเล็ต (user 24/08) */
.qc-layout > [class*="col-"], .qc-page .preview-col, .qc-page .side-card { min-width: 0; }
.prev-stage { max-width: 100%; }
@media (min-width: 992px) {
  .preview-col { position: sticky; top: .6rem; align-self: flex-start; max-height: calc(100vh - 1.2rem); overflow: auto; }
  .preview-col::-webkit-scrollbar { width: 6px; }
  .preview-col::-webkit-scrollbar-thumb { background: #d5cfe6; border-radius: 4px; }
}

/* ---- แถบหัวการ์ดฟอร์ม (ม่วงไล่เฉด ตามดีไซน์) ---- */
.qc-page .qc-bar {
  background: linear-gradient(100deg, #46307f, #5b3fa8 55%, #6a4fc0);
  color: #fff; border-bottom: 0; padding: .55rem .9rem;
}
.qc-page .qc-bar a, .qc-page .qc-bar .bi { color: #fff; }
.qc-formcode {
  background: #efeafa; color: #4d3a8f; border-radius: 8px;
  padding: .18rem .65rem; font-size: .74rem; font-weight: 700; margin-left: .5rem; white-space: nowrap;
}
.qc-page .qc-bar .btn-outline-secondary { color: #fff; border-color: rgba(255,255,255,.5); }
.qc-page .qc-bar .btn-outline-secondary:hover { background: rgba(255,255,255,.18); border-color: #fff; }

/* ---- แถบเลขที่เอกสาร: บรรทัดเดียว ไม่ใช่บล็อกกลางหน้า ---- */
.doc-head {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  background: #faf8fd; border: 1px solid #efeaf8; border-radius: 11px;
  padding: .55rem .85rem; margin-bottom: .8rem;
}
.doc-head .dh-cap { font-size: .78rem; color: var(--jd-muted); line-height: 1.1; }
.doc-head .doc-no-big { font-size: 1.32rem; font-weight: 700; color: var(--jd-purple); line-height: 1.15; }
.dh-kind { border-radius: 7px; padding: .22rem .62rem; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.dh-kind.k-qc { background: #efeafa; color: #5b3fa8; }
.dh-kind.k-rt { background: #fbeedd; color: #b45f06; }
.doc-head .dh-ver { margin-left: auto; font-size: .75rem; color: var(--jd-muted); white-space: nowrap; }
.dh-audit { border: 0; background: transparent; color: var(--jd-purple); font-weight: 600; font-size: .75rem; padding: 0 0 0 .3rem; cursor: pointer; }
.dh-audit:hover { text-decoration: underline; }
.doc-head .dh-tag { font-size: 1.25rem; line-height: 1; }
.doc-head .dh-img { flex: 0 0 100%; font-size: .74rem; }
.doc-head .dh-img:empty { display: none; }

/* ---- ช่องกรอก: กรอบ 1.5px มุม 10px ตัวหนา ตามดีไซน์ ---- */
.qc-edit .form-control, .qc-edit .form-select {
  border: 1.5px solid var(--jd-line); border-radius: 10px;
  padding: .5rem .7rem; font-size: .92rem; font-weight: 600; color: var(--jd-ink);
}
.qc-edit .form-control-sm, .qc-edit .form-select-sm { padding: .3rem .5rem; font-size: .88rem; border-radius: 8px; }
.qc-edit textarea.form-control { font-weight: 400; min-height: 44px; }
.qc-edit .form-control::placeholder { font-weight: 400; color: #c9c2da; }
.qc-edit .form-control:focus, .qc-edit .form-select:focus {
  border-color: var(--jd-purple); box-shadow: 0 0 0 3px rgba(91, 63, 168, .12);
}
/* ป้ายกำกับใหญ่กว่าดีไซน์เล็กน้อย — พนักงานอายุมากต้องอ่านออก (user 24/08) */
.qc-edit .form-label { font-size: .88rem; color: #5c5375; font-weight: 500; margin-bottom: 4px !important; }
.qc-edit .form-label .hint, .qc-edit .form-label small { font-size: .82rem; }
/* ช่องบังคับที่ยังว่าง */
.qc-edit .is-missing { border-color: #f3c4bd !important; background: #fffbfa; }
.req-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #d64545; margin-left: .3rem; vertical-align: middle;
}

/* ---- หัวข้อย่อย ①②③ ---- */
.qc-edit .sub-t { font-size: .92rem; font-weight: 700; color: var(--jd-purple); margin: 0 0 .5rem; }
.qc-edit .sub-t small, .qc-edit .sub-t .hint { font-size: .8rem; font-weight: 400; color: var(--jd-muted); }

/* ---- การ์ดหัวข้อส่วน ---- */
.qc-edit .form-block { border: 1px solid var(--jd-line); border-radius: 14px; padding: 0 .95rem .55rem; margin-bottom: .8rem; }
.qc-edit .form-block > .fb-title {
  margin: 0 -.95rem .8rem; padding: .5rem .9rem;
  background: #f4f0fb; color: #4d3a8f; font-size: .95rem; border-bottom: 1px solid #eae2f7;
}

/* ---- ตารางย่อยในฟอร์ม (การถ่ายรถ / เช็คลิสต์) ---- */
.mini-tbl { border: 1px solid var(--jd-line); border-radius: 11px; overflow: hidden; }
.mini-tbl .mt-h { background: var(--jd-cream); font-size: .85rem; color: #6b6285; }
.mini-tbl .mt-h > div { padding: .35rem .6rem; }
.tr-grid { display: grid; grid-template-columns: 1fr 1fr 34px; align-items: center; }
.tr-grid + .tr-grid, .mini-tbl .mt-h + .tr-grid { border-top: 1px solid #f3eff9; }
.tr-row > div { padding: .28rem .4rem; }
.tr-row > div:last-child { padding: 0; text-align: center; }
.row-x { border: 0; background: transparent; color: #b3abc9; font-size: .9rem; line-height: 1; cursor: pointer; padding: .3rem; }
.row-x:hover { color: var(--bad); }
.chk-grid { display: grid; grid-template-columns: 1fr 84px 84px; align-items: center; font-size: .92rem; }
.chk-grid > div { padding: .3rem .6rem; }
.chk-grid > div:nth-child(n+2) { text-align: center; }
.chk-r { border-top: 1px solid #f3eff9; }
.chk-box {
  width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid #ded8ea;
  background: #fff; color: transparent; font-size: .78rem; line-height: 1; cursor: pointer; padding: 0;
}
.chk-box.f { border-color: #f3c4bd; }
.chk-box:hover { border-color: var(--jd-purple); }
.chk-box.on.p { background: #2f9e5f; border-color: #2f9e5f; color: #fff; }
.chk-box.on.f { background: #d64545; border-color: #d64545; color: #fff; }

/* ---- ปุ่มเพิ่มแถวแบบเส้นประ ---- */
.btn-dash {
  font-size: .88rem; color: var(--jd-purple); font-weight: 600; background: transparent;
  border: 1.5px dashed #cfc7e2; border-radius: 9px; padding: .28rem .8rem; cursor: pointer;
}
.btn-dash:hover { background: var(--jd-purple-soft); }

/* ---- ผลการตรวจสอบ: ปุ่มคู่เต็มความกว้าง ---- */
.pf-seg { display: flex; gap: .55rem; }
.pf-seg .pf-btn {
  flex: 1; border: 1.5px solid var(--jd-line); background: #fff; color: var(--jd-muted);
  border-radius: 10px; padding: .45rem; font-size: .88rem; font-weight: 600; cursor: pointer;
}
.pf-seg .seg-pass:hover { border-color: #2f9e5f; color: #1e7a48; }
.pf-seg .seg-fail:hover { border-color: #f0c0ba; color: #b3372f; }
.pf-seg .pf-btn.active-pass { background: #2f9e5f; border-color: #2f9e5f; color: #fff; font-weight: 700; }
.pf-seg .pf-btn.active-fail { background: #fff; border-color: #f0c0ba; color: #b3372f; font-weight: 700; }

/* ---- กลุ่มนับจริง ---- */
.qc-edit .cnt-grp { border: 1px solid var(--jd-line) !important; border-radius: 11px !important; overflow: hidden; }
.qc-edit .cnt-grp-head { background: var(--jd-cream) !important; font-size: .9rem; }
.qc-edit .cnt-grp .row.small { font-size: .85rem !important; color: #6b6285 !important; }

/* ---- ช่องลายเซ็นใต้แต่ละส่วน ---- */
.sign-card {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  border: 1.5px dashed #ded8ea; border-radius: 11px; padding: .45rem .7rem; margin-bottom: .35rem;
}
.sign-card.signed { border: 1.5px solid #cfe7d9; border-style: solid; background: #fbfefc; }
.sign-card .sc-lab { font-size: .82rem; color: var(--jd-muted); }
.sign-card .sc-val { font-size: .9rem; font-weight: 600; color: #1e7a48; }
.qc-edit .form-block .qcn-sign, .qc-edit .form-block .rt-sign { border-top: 0; padding-top: .2rem; }

/* ---- ภาพประกอบ: ช่องสี่เหลี่ยมเรียงกัน กดช่องเส้นประเพื่อแนบรูป (user 24/08) ---- */
.photo-grid { display: flex; flex-wrap: wrap; gap: .55rem; align-items: flex-start; }
.photo-tile { position: relative; width: 74px; }
.photo-tile .img-thumb {
  width: 74px; height: 74px; object-fit: cover; border-radius: 11px;
  background: #efeaf8; display: block; border: 1px solid var(--jd-line);
}
.photo-tile.is-old { opacity: .6; }
.photo-tile.is-old .img-thumb { filter: grayscale(60%); }
.photo-tile .pt-cap { font-size: .7rem; color: var(--jd-muted); line-height: 1.25; margin-top: .15rem; text-align: center; }
.photo-tile .pt-x {
  position: absolute; top: -5px; right: -5px; width: 20px; height: 20px; padding: 0;
  border: 0; border-radius: 50%; background: var(--bad); color: #fff;
  font-size: .8rem; line-height: 20px; cursor: pointer; box-shadow: var(--shadow-1);
}
.photo-add {
  width: 74px; height: 74px; border: 1.5px dashed #ded8ea; border-radius: 11px;
  background: #fff; color: var(--jd-muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  font-size: .8rem; padding: 0;
}
.photo-add i { font-size: 1.25rem; color: var(--jd-purple); }
.photo-add:hover { border-color: var(--jd-purple); background: var(--jd-purple-soft); color: var(--jd-purple); }

/* ================= คอลัมน์ขวา: พรีวิว + แผงคุม ================= */
.side-card { background: #fff; border: 1px solid var(--jd-line); border-radius: 14px; padding: .7rem .8rem; margin-bottom: .7rem; }
.side-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; font-size: .82rem; }
.side-head .hint { font-size: .7rem; }
/* เวทีพรีวิว: กระดาษอยู่ขนาดจริงเสมอ (A4 แนวนอน) แล้ว zoom ย่อทั้งใบ —
   เดิมบีบกระดาษด้วย width:100% ทำให้ตัวอักษรข้างในไม่ย่อตาม หน้าจึงเพี้ยนบนแท็บเล็ต */
.prev-stage { background: #eceaf1; border-radius: 9px; padding: .55rem; overflow: auto; }
.prev-stage .paper-preview { width: 297mm; max-width: none; margin: 0 auto 10px; }
.prev-stage .paper-preview.label-page { width: 297mm; }
.zoom-seg { display: inline-flex; gap: 2px; background: var(--jd-cream); border-radius: 8px; padding: 2px; }
.zoom-seg button {
  border: 0; background: transparent; color: #6b6285; font-size: .72rem; font-weight: 600;
  border-radius: 6px; padding: .15rem .5rem; cursor: pointer; white-space: nowrap;
}
.zoom-seg button.on { background: var(--jd-purple); color: #fff; }
.zoom-full {
  border: 0; background: transparent; color: var(--jd-purple); font-size: .85rem;
  padding: .15rem .35rem; cursor: pointer; border-radius: 6px;
}
.zoom-full:hover { background: var(--jd-purple-soft); }
/* ดูเต็มจอ — ใช้การ์ดใบเดิม ไม่ต้องมี modal แยก (พรีวิวจึงไม่ต้อง render ซ้ำ) */
.side-card.prev-max {
  position: fixed; inset: 8px; z-index: 1060; margin: 0; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: var(--shadow-2);
}
.side-card.prev-max .prev-stage { flex: 1; }
body.prev-max-open { overflow: hidden; }

.fill-pct { font-size: .8rem; font-weight: 700; color: var(--jd-purple); }
.fill-bar { height: 7px; border-radius: 4px; background: #f0ebfa; overflow: hidden; }
.fill-bar .fill-in { height: 7px; width: 0; background: linear-gradient(90deg, #6a4fc0, #5b3fa8); transition: width .25s; }
.sec-list { display: flex; flex-direction: column; gap: .3rem; margin-top: .55rem; }
.sec-row {
  display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left;
  border: 1px solid #efeaf8; background: #faf8fd; border-radius: 9px;
  padding: .35rem .6rem; font-size: .76rem; cursor: pointer;
}
.sec-row .sec-dot { width: 7px; height: 7px; border-radius: 50%; background: #c9c2da; flex: none; }
.sec-row .sec-name { flex: 1; color: var(--jd-ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-row .sec-note { color: var(--jd-muted); white-space: nowrap; }
.sec-row .bi { font-size: .6rem; color: #b3abc9; }
.sec-row.s-warn { background: #fffbfa; border-color: #f7e3df; }
.sec-row.s-warn .sec-dot { background: #d99416; }
.sec-row.s-warn .sec-note { color: #b3372f; }
.sec-row.s-ok { background: #fbfefc; border-color: #dcefe4; }
.sec-row.s-ok .sec-dot { background: #2f9e63; }
.sec-row.s-ok .sec-note { color: #1e7a48; }
.sec-tip { margin-top: .4rem; font-size: .66rem; color: #b3abc9; }

.sign-list { display: flex; flex-direction: column; gap: .3rem; }
.sg-row { display: flex; align-items: center; gap: .5rem; font-size: .78rem; }
.sg-row .sg-lab { flex: 1; color: #6b6285; }
.sg-row .sg-ok { color: #1e7a48; }
.sg-row .sg-wait { color: #c9c2da; }

.act-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.act-grid .btn { border-radius: 11px; padding: .55rem; font-size: .86rem; font-weight: 600; }

/* ---- ป้ายขาเหล็ก (3c): ชิป template / ช่องสแกน / แถบสี / ตารางต่อขา ---- */
.tpl-chip {
  border: 0; background: var(--jd-cream); color: #6b6285; border-radius: 9px;
  padding: .4rem .85rem; font-size: .85rem; font-weight: 500; cursor: pointer;
}
.tpl-chip.on {
  background: #efeafa; color: var(--jd-purple); font-weight: 700;
  box-shadow: inset 0 0 0 1.5px var(--jd-purple);
}
.scan-box {
  display: flex; align-items: center; gap: .5rem;
  border: 1.5px solid var(--jd-purple); border-radius: 11px; padding: 0 .3rem 0 .8rem; background: #fff;
}
.scan-box .bi-upc-scan { color: var(--jd-purple); font-size: 1.15rem; }
.qc-edit .scan-box input.form-control { border: 0 !important; box-shadow: none !important; padding-left: .2rem; }
/* กล่อง "พบสินค้า" เขียวแบบ design */
.qc-edit #productInfo { background: #e4f5eb; border: 0; color: #1e7a48; border-radius: 9px; font-size: .85rem; }
.qc-edit #productInfo .text-primary { color: #1e7a48 !important; }
/* แถบสี่เหลี่ยมเลือกสี */
.color-swatches { display: inline-flex; gap: 6px; align-items: center; padding: .15rem 0; }
.color-swatches .csw {
  width: 22px; height: 22px; border-radius: 6px; border: 0; padding: 0; cursor: pointer; flex: none;
}
.color-swatches .csw.on { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--jd-ink); }
@media (pointer: coarse) { .color-swatches .csw { width: 28px; height: 28px; } }
/* ช่องข้อความบนป้าย: บรรทัดละแถว — ป้ายกำกับ | ช่อง | แถบสี */
.tpl-field-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .45rem; }
.tpl-field-row label { flex: 0 0 92px; }
.tpl-field-row input { flex: 1; min-width: 0; }
.tpl-field-row .color-swatches { flex: none; }
/* ตารางจำนวนต่อขาเหล็ก */
/* คลัง กับ =ต่อขา ต้องกว้าง (ข้อความยาว เช่น 4x15=60) — ฐาน/ชั้น/เศษ/พาเลท ใช้พื้นที่น้อย
   ใช้สัดส่วน + ขั้นต่ำ: จอแคบทุกช่องหดพร้อมกันแต่ไม่ต่ำกว่าที่อ่านออก (จอ 1024 เคยเหลือ 18px) */
.stand-grid {
  display: grid; align-items: center;
  grid-template-columns: minmax(88px, 1.5fr) minmax(44px, 1fr) minmax(40px, .9fr) minmax(40px, .9fr)
                         minmax(88px, 1.4fr) minmax(46px, .8fr) 30px;
}
.mini-tbl .mt-h.stand-grid > div { text-align: center; }
.mini-tbl .mt-h.stand-grid > div:first-child { text-align: left; }
.stand-row { border-top: 1px solid #f3eff9; }
.stand-row > div { padding: .25rem .25rem; }
.stand-row .st { background: #faf8fd; color: var(--jd-purple); text-align: center; }

/* ---- แถบ "ยังขาด N ช่อง" ค้างล่างจอ ---- */
.miss-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 1050;
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; max-width: min(92vw, 60rem);
  background: var(--bad-soft); border: 1px solid var(--bad-line); color: #a3322c;
  border-radius: 999px; padding: .45rem .8rem; box-shadow: var(--shadow-2);
}
.miss-bar.ok { background: var(--ok-soft); border-color: var(--ok-line); color: #1e7a48; }
.miss-bar .miss-head { font-weight: 700; font-size: .88rem; white-space: nowrap; }
.miss-bar .miss-list { display: flex; gap: .35rem; flex-wrap: wrap; }
.miss-chip {
  border: 0; background: #fff; color: #a3322c; border-radius: 999px;
  padding: .18rem .7rem; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.miss-chip:hover { background: var(--bad); color: #fff; }
.field-flash { animation: fieldFlash 1.5s ease-out; }
@keyframes fieldFlash {
  0%, 40% { box-shadow: 0 0 0 3px rgba(217, 83, 79, .45); border-color: var(--bad); }
  100% { box-shadow: none; }
}
/* จอแคบ: ชิปเรียงบรรทัดเดียวเลื่อนได้ ไม่งั้นแถบสูงจนบังฟอร์ม */
@media (max-width: 767.98px) {
  .miss-bar { width: 92vw; flex-wrap: nowrap; }
  .miss-bar .miss-list { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .miss-bar .miss-list::-webkit-scrollbar { display: none; }
  .miss-chip { flex: none; }
}
@media print { .miss-bar { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .field-flash { animation: none; outline: 2px solid var(--bad); } }

/* หมายเหตุงานบนการ์ดรถ — ตัวแดงเสมอให้เตะตาคนทำงาน (user 25/08) */
#jobNote { color: #d64545; font-weight: 600; }
#jobNote::placeholder { color: #cfc9dd; font-weight: 400; }
.job-ico {
  border: 0; background: transparent; color: var(--jd-purple); font-size: 1.1rem;
  padding: .1rem .45rem; border-radius: 8px; line-height: 1;
}
.job-ico:hover { background: var(--jd-purple-soft); }

/* ---- บอร์ดคิวรถขาออก (2a) ---- */
/* แถวบน: ตัวเลขสรุปซ้าย + ผังจุดจอดขวา */
.board-top { display: flex; gap: .75rem; align-items: stretch; }
.board-top .board-nums { flex: 0 0 auto; }
.board-top .board-spots { flex: 1 1 auto; min-width: 0; margin: 0; }
.board-top .sp-head { line-height: 1.2; font-size: .8rem; }
.board-top .sp-head .fw-bold { font-size: .95rem; color: var(--jd-ink); }
/* ป้ายกำกับต้องอยู่บรรทัดเดียว ไม่งั้นตัวเลขของแต่ละช่องหล่นคนละระดับ (โย้เย้) */
.board-nums .card-summary { justify-content: flex-end; }
.board-nums .card-summary small { white-space: nowrap; }
.board-nums .card-summary .num { font-size: 1.5rem; }
.board-nums > [class*="col-"] { flex: 0 0 auto; width: auto; }
@media (max-width: 1199.98px) { .board-top { flex-direction: column; } }
/* แถบรถนอกคลัง/ลางาน — บรรทัดละแถว เลื่อนแนวนอนแทนการตัดขึ้นบรรทัดใหม่ */
.pool-bar { display: flex; flex-direction: column; gap: .4rem; }
.pool-row { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.pool-lbl { flex: 0 0 auto; font-weight: 700; font-size: .88rem; cursor: help; }
.pool-list { flex: 1 1 auto; min-width: 0; display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .15rem; }
.pool-list > * { flex: 0 0 auto; }
.pool-list::-webkit-scrollbar { height: 4px; }
.pool-list::-webkit-scrollbar-thumb { background: #d5cfe6; border-radius: 4px; }

/* ช่องเวลาแบบต่อเนื่อง (สถิติ 3b) — รวมหลายเวลาไว้ช่องเดียว อ่านเป็นลำดับ */
.tflow { white-space: nowrap; color: #6b6285; font-size: .85rem; }
.tflow i { color: var(--jd-hint); font-style: normal; margin: 0 .28rem; }

/* ป้ายนำหน้ากลุ่มชิป + เลขลำดับการจัดกลุ่ม */
.fpill-lbl { color: var(--jd-muted); font-size: .82rem; padding: .3rem .5rem .3rem .6rem; white-space: nowrap; }
.fpill-lbl i { color: var(--jd-purple); }
.gnum {
  display: inline-block; min-width: 15px; height: 15px; line-height: 15px; margin-right: .3rem;
  border-radius: 50%; background: rgba(255, 255, 255, .3); font-size: .64rem; text-align: center;
}
.gsep { width: 1px; align-self: stretch; background: var(--jd-line); margin: 0 .15rem; }
/* หัวกลุ่มชั้นลึกลง — จางลงทีละชั้น เห็นลำดับชั้นชัด */
tr.grp-head.grp-lv1 > td { background: #f7f4fc !important; font-weight: 600; }
tr.grp-head.grp-lv2 > td { background: #fbf9fe !important; font-weight: 500; }
/* คอลัมน์คลัง: คลังหลัก + คลังย่อย */
.wh-cell { white-space: nowrap; }
.wh-cell .wh-sub { color: var(--jd-muted); }

/* เมนูลอยท้ายแถว — ใช้ fixed เพราะตารางมี overflow (dropdown ปกติโดนตัด) */
.row-menu-pop {
  position: fixed; z-index: 1080; min-width: 11rem; padding: .3rem;
  background: var(--jd-card); border: 1px solid var(--jd-line);
  border-radius: 10px; box-shadow: var(--shadow-2);
}
.row-menu-pop button {
  display: flex; align-items: center; gap: .55rem; width: 100%;
  border: 0; background: transparent; text-align: left; color: var(--jd-ink);
  padding: .5rem .7rem; border-radius: 8px; font-size: .92rem; cursor: pointer;
}
.row-menu-pop button:hover { background: var(--jd-purple-soft); color: var(--jd-purple); }

/* ปุ่มเมนูท้ายแถว (จุด 3 จุด) — แทนปุ่ม "แก้ไข" ที่กินพื้นที่และดึงสายตา */
.row-menu {
  border: 0; background: transparent; color: var(--jd-hint); cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px; line-height: 1; padding: 0; font-size: 1rem;
}
.row-menu:hover { background: var(--jd-purple-soft); color: var(--jd-purple); }

/* --- 3) แถบตัวกรอง: ชิปลอยบนพื้น (ไม่มีป้ายกำกับเหนือช่อง — ไอคอน/ข้อความในชิปบอกอยู่แล้ว) --- */
.fbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; max-width: 100%; }
.fchip {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--jd-card); border: 1px solid var(--jd-line); border-radius: 11px;
  padding: .42rem .75rem; font-size: .9rem; color: var(--jd-ink); min-height: 42px;
}
.fchip > i { color: var(--jd-purple); font-size: .95rem; }
.fchip input, .fchip select {
  border: 0; outline: 0; background: transparent; color: inherit; font: inherit;
  padding: 0; min-height: 0; max-width: 100%;
}
.fchip select { cursor: pointer; padding-right: .2rem; }
.fchip input[type="date"] { min-width: 7.4rem; }
.fchip.fsearch { min-width: 12rem; flex: 0 1 15rem; }
.fchip.fsearch input { flex: 1; min-width: 0; }
.fchip.fsearch i { color: var(--jd-hint); }
.fchip.fico { padding: .42rem .7rem; color: var(--jd-purple); cursor: pointer; }
.fchip.fico:hover { background: var(--jd-purple-soft); }
/* กลุ่มปุ่มสถานะ: กล่องขาวใบเดียว ปุ่มที่เลือกเป็นม่วงทึบ */
.fpills {
  display: inline-flex; gap: .2rem; background: var(--jd-card);
  border: 1px solid var(--jd-line); border-radius: 11px; padding: .22rem;
}
.fpill {
  border: 0; background: transparent; border-radius: 8px;
  padding: .3rem .8rem; font-size: .86rem; color: #6b6285; cursor: pointer; white-space: nowrap;
}
.fpill:hover { background: var(--jd-purple-soft); }
.fpill.on { background: var(--jd-purple); color: #fff; font-weight: 600; }
/* ปุ่มหลักในแถบตัวกรอง — เงาม่วงตามดีไซน์ */
.filter-card .btn-primary { border-radius: 11px; box-shadow: 0 2px 10px rgba(91, 63, 168, .28); }
@media (max-width: 575.98px) {
  .fbar { gap: .4rem; }
  /* width:100% ทำให้ชิปได้บรรทัดของตัวเองอยู่แล้ว — ไม่ใช้ order เพราะจะสลับลำดับหน้าอื่นด้วย */
  .fpills { width: 100%; max-width: 100%; overflow-x: auto; }
  .fchip.fsearch { flex: 1 1 100%; }
}

.filter-card { background: transparent; border: 0; box-shadow: none; }
.filter-card > .card-body { padding: 0 !important; }
.filter-card .form-control, .filter-card .form-select,
.filter-card .btn-outline-primary, .filter-card .btn-outline-secondary {
  border-radius: 11px; border-color: var(--jd-line); background-color: var(--jd-card);
}
.filter-card .form-label { color: var(--jd-muted); }

@media print {
  @page { size: A4 landscape; margin: 0; }  /* ไร้ขอบ — ใช้พื้นที่เต็มแผ่นสำหรับป้ายขาเหล็ก */
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  .paper-preview { box-shadow: none; padding: 0; max-width: none; aspect-ratio: auto; height: 100vh; page-break-after: always; }
  .paper-preview:last-child { page-break-after: auto; }
  .strip-page { page-break-after: always; }
  .strip-page:last-child { page-break-after: auto; }
  .no-print, .strip-page-head { display: none !important; }
  .print-doc { padding: 10mm; }             /* ใบ QC ยังมีขอบในเนื้อเอกสารเอง */
  body { background: #fff; }
}
