/* TEGH นัดหมาย — Trackado design language
   โทนสว่างอย่างเดียว (ไม่มีโหมดมืด) · flat · มุมเหลี่ยม · เงาบาง · สีสื่อความหมาย
   ค่าทั้งหมดวัดจาก app.trackado.com (computed style) — แก้ที่นี่ลามทั้งระบบ */
:root {
  color-scheme: light;

  /* ── พื้นหลัง / การ์ด ── */
  --canvas: #f5f8fb;
  --bg-grad-1: #f5f8fb; --bg-grad-2: #f5f8fb;
  --card-bg: #ffffff;
  --card-border: #dee1e7;

  /* ── ตัวอักษร (เข้มกว่า Trackado เล็กน้อย เพื่อให้ภาษาไทยอ่านชัด) ── */
  --text: #596679;
  --text-soft: #7f8ca3;
  --text-faint: #97a8b6;

  /* ── สีสื่อความหมาย (Trackado) ── */
  --primary: #54c08a; --primary-dark: #46a876; --primary-soft: #e8f6ef;
  --success: #54c08a; --success-dark: #46a876; --success-soft: #e8f6ef;   /* สี "สำเร็จ/พร้อม" แยกจากสีแบรนด์ (--primary) */
  --ok-text: #1f7a44;   /* ข้อความ "สำเร็จ" บนพื้นอ่อน (คอนทราสต์สูงกว่า --primary) */
  --info: #638ca5; --info-dark: #54788e; --info-soft: #eaf0f4;
  --accent: #6dc6cd; --accent-soft: #e4f5f6;
  --warn: #e8b71a; --warn-soft: #fcf4d9;
  --orange: #f46800; --orange-soft: #fde8db;
  --danger: #c31414; --danger-soft: #fbe4e4;
  --brown: #7f8ca3; --brown-soft: #f5f8fb;

  /* ── ช่องกรอก ── */
  --field-bg: #f6f7f9;
  --field-border: #dee1e7;

  /* ── รูปทรง: Trackado = เหลี่ยม เงาบางเฉียบ ── */
  --radius: 0px; --radius-sm: 0px; --radius-btn: 3px; --radius-pill: 999px;
  --shadow-sm: 0 1px 1px rgba(0,0,0,.05);
  --shadow: 0 1px 4px rgba(0,0,0,.10);

  /* ── แถบข้าง + แถบบน (สีเดียวกัน กลืนเป็นผืนเดียว) ── */
  --side-w: 300px;
  --side-bg: #35404f; --side-bg-2: #35404f;
  --side-text: #ffffff;
  --side-text-faint: #97a8b6;
  --side-active: #576473; --side-hover: #576473;
  --side-line: #303947;
  --topbar-h: 90px;

  /* ── หัวพาเนล (ลายเซ็น Trackado) ── */
  --panelhead: #638ca5; --panelhead-2: #638ca5;

  /* ── สีไอคอนหมวดเมนู (วงกลมสีในแถบข้าง) ── */
  --ic-ops: #54c08a;
  --ic-display: #41949f;
  --ic-data: #e8b71a;
  --ic-system: #ae84a4;
  --ic-alert: #c31414;
  --ic-report: #5a7fb8;
  --ic-eqr:    #54c08a;

  /* ── จังหวะการเคลื่อนไหว (ใช้ร่วมทั้งระบบ) ──
     ค่าเดียวกันทุกที่ = ความรู้สึกเป็นระบบเดียว ไม่ใช่แต่ละหน้าเคลื่อนคนละจังหวะ */
  --dur-fast: 120ms;   /* hover · กดปุ่ม — ต้องตอบทันมือ */
  --dur: 200ms;        /* เมนูย่อย · แท็บ · dropdown */
  --dur-slow: 380ms;   /* เปลี่ยนหน้า · กราฟ */
  --ease-out: cubic-bezier(.22, .61, .36, 1);      /* ออกตัวเร็ว จบนุ่ม */
  --ease-spring: cubic-bezier(.34, 1.3, .64, 1);   /* เด้งเล็กน้อยตอนปล่อยปุ่ม */
}

/* ผู้ใช้ที่ตั้งค่าเครื่องว่า "ลดการเคลื่อนไหว" (เมาเวลาเห็นภาพขยับ / คีออสก์)
   ปิดทุกอย่างจากจุดเดียว ไม่ต้องไล่ปิดรายที่ */
@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 1ms; --dur: 1ms; --dur-slow: 1ms; }
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Noto Sans Thai", "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px; font-weight: 400;
  background: var(--canvas);
  color: var(--text); min-height: 100vh; padding: 18px 14px 40px;
  display: flex; flex-direction: column; align-items: center;
}
a { color: var(--info); }
.topbar { width: 100%; max-width: 880px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; }
.brand .logo { width: 38px; height: 38px; border-radius: var(--radius-btn);  display: grid; place-items: center; color: #fff; font-size: 1.2rem; }
.brand small { display: block; font-weight: 500; font-size: .68rem; color: var(--text-faint); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.card { width: 100%; max-width: 480px; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 22px 26px; }
.card.wide { max-width: 880px; }
h1.title { font-size: 1.3rem; margin-bottom: 4px; }
p.sub { font-size: .9rem; color: var(--text-soft); margin-bottom: 18px; line-height: 1.5; }

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.req { color: var(--danger); }
.field { margin-bottom: 15px; }
input, select, textarea { width: 100%; font-family: inherit; font-size: .95rem; color: var(--text); background-color: #fff; border: 1px solid var(--field-border); border-radius: var(--radius-btn); padding: 11px 12px; }
input[readonly] { background: var(--brown-soft); color: var(--text-soft); }
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--info); box-shadow: 0 0 0 2px var(--info-soft); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 120px; }
.err { color: var(--danger); font-size: .78rem; margin-top: 5px; }

/* [hidden] ต้องชนะกฎ display ที่เรากำหนดเอง — ไม่งั้นซ่อนไม่ลง
   (กฎ [hidden]{display:none} ของเบราว์เซอร์มีน้ำหนักต่ำกว่า .btn{display:inline-flex}) */
[hidden] { display: none !important; }
.btn { width: 100%; font-family: inherit; font-size: 1rem; font-weight: 600; border: 1px solid transparent; border-radius: var(--radius-btn); padding: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: none; }
.btn-ghost { background: #fff; color: var(--info); border: 1px solid var(--card-border); }
/* .btn-sm ใช้ทั้งกับ <button> และ <a> — ถ้าไม่ตั้ง display ให้ตรงกัน
   <button> จะเป็น inline-block ส่วน <a> เป็น inline → สูงไม่เท่ากัน 3–4px
   เห็นชัดมากเวลาวางปุ่มสองแบบติดกันในแถวตาราง */
.btn-sm {
  width: auto; font-size: .82rem; padding: 7px 13px; border-radius: var(--radius-btn);
  border: 1px solid var(--card-border); background: #fff; color: var(--info);
  font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  line-height: 1.25; vertical-align: middle;
}
.btn-sm.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-sm.info { background: var(--info); border-color: var(--info); color: #fff; }
.btn-sm.danger { border-color: var(--danger); color: var(--danger); }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }
.btn-row .btn { flex: 1; }

.alert { border-radius: var(--radius-sm); padding: 12px 14px; font-size: .9rem; margin-bottom: 14px;
  display: flex; align-items: flex-start; gap: 10px; }
.alert .alert-msg { flex: 1 1 auto; }
.alert .alert-close { flex: 0 0 auto; appearance: none; border: none; background: transparent; cursor: pointer;
  font-size: 1.25rem; line-height: 1; padding: 0 2px; color: inherit; opacity: .55; transition: opacity .15s; }
.alert .alert-close:hover { opacity: 1; }
.alert.alert-hide { opacity: 0; transform: translateY(-8px); transition: opacity .25s, transform .25s; }
.alert.error { background: var(--danger-soft); border: 1px solid var(--danger); color: var(--danger); }
.alert.ok { background: var(--success-soft); border: 1px solid var(--success); color: var(--success-dark); }

.store-card { display: flex; align-items: center; gap: 14px; border: 1.5px solid var(--field-border); background: var(--field-bg); border-radius: var(--radius-sm); padding: 15px; margin-bottom: 12px; cursor: pointer; width: 100%; text-align: left; font-family: inherit; color: var(--text); }
.store-card:hover { border-color: var(--primary); }
.store-card .ic { width: 42px; height: 42px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 1.25rem; }
.store-card .nm { font-weight: 700; }

.summary { border-top: 1px solid var(--card-border); margin-top: 8px; }
.summary .r { display: flex; justify-content: space-between; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--card-border); font-size: .92rem; }
.summary .r .k { color: var(--text-soft); }
.summary .r .v { font-weight: 600; text-align: right; }
.code-box { text-align: center; background: var(--primary-soft); border: 1px dashed var(--primary); border-radius: var(--radius-sm); padding: 14px; margin: 14px 0; }
.code-box .code { font-size: 1.5rem; font-weight: 800; color: var(--primary-dark); }

/* status badges — Trackado pill ทรงแคปซูลสีทึบ ตัวอักษรขาว */
.st { font-size: .72rem; font-weight: 600; padding: 4px 12px; border-radius: var(--radius-btn); color: #fff; display: inline-block; text-align: center; }
.st-pending { background: var(--warn); }
.st-late, .st-overdue { background: var(--orange); }
.st-confirmed { background: var(--info); }
.st-arrived { background: var(--accent); }
.st-completed { background: var(--success); }
.st-cancelled { background: #97a8b6; }

/* staff */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.toolbar > * { flex: 1; min-width: 120px; }
.bk { border: 1px solid var(--card-border); background: var(--field-bg); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 12px; }
.bk-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.bk-store { font-weight: 700; font-size: 1rem; }
.bk-code { color: var(--primary); font-weight: 700; font-size: .85rem; }
.bk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 14px; font-size: .83rem; margin-top: 8px; }
.bk-grid .k { color: var(--text-faint); }
.bk-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--card-border); align-items: center; }
.bk-actions form { display: inline; }
.rs-inline { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; width: 100%; }
.rs-inline input, .rs-inline select { width: auto; flex: 1; min-width: 110px; padding: 7px 9px; font-size: .85rem; }
details.rs > summary { cursor: pointer; font-size: .8rem; color: var(--primary); font-weight: 700; margin-top: 8px; }

.dash-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.dash-card { border: 1px solid var(--card-border); background: var(--field-bg); border-radius: var(--radius-sm); padding: 14px; }
.dash-card.wide { grid-column: 1 / -1; }
.dash-card .lbl { font-size: .78rem; color: var(--text-faint); }
.dash-card .val { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.dash-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--card-border); font-size: .86rem; }
.dash-row:last-child { border: none; }

/* wallboard */
.wall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.wall-tile { border-radius: var(--radius); padding: 18px; border: 2px solid var(--card-border); background: var(--card-bg); }
.wall-tile.s-pending { border-color: var(--warn); }
.wall-tile.s-confirmed { border-color: var(--info); }
.wall-tile.s-arrived { border-color: var(--success); }
.wall-tile.s-completed { border-color: var(--text-faint); opacity: .7; }
.wall-tile.s-cancelled { border-color: var(--danger); opacity: .55; }
.wall-tile .qno { font-size: 2.4rem; font-weight: 800; color: var(--primary); line-height: 1.1; }
.wall-tile .slot { font-size: 1.5rem; font-weight: 800; }
.wall-tile .code { font-size: 1.05rem; font-weight: 700; color: var(--primary); margin-top: 6px; }
.wall-tile .store { font-weight: 600; margin-top: 6px; }
.wall-tile .rubber { font-size: .85rem; color: var(--text-soft); margin-top: 4px; }
.wall-tile .status { margin-top: 10px; font-size: 1.1rem; font-weight: 800; }

.muted { color: var(--text-faint); font-size: .8rem; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.nav { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.nav a, .nav button { font-size: .85rem; }
.footnote { text-align: center; font-size: .72rem; color: var(--text-faint); margin-top: 18px; }

/* ============================================================
   Premium polish (Bold Eco/Nature) — ทรานสิชันลื่น, ยกเงาเมื่อ hover,
   หัวข้อคมขึ้น, การ์ดมีไฮไลต์อุ่น — ใช้ token กลางจึงลามทุกหน้า
   ============================================================ */
.btn, .btn-sm, .btn-primary, .btn-ghost, .store-card, .card,
input, select, textarea {
  transition: transform .12s ease, box-shadow .18s ease, border-color .15s ease, background-color .15s ease, filter .15s ease;
}
.btn-primary:hover { filter: brightness(.95); }
.btn-primary:active { filter: brightness(.9); }
.btn-sm:hover { border-color: var(--info); }
.btn-ghost:hover { border-color: var(--info); color: var(--info-dark); }
.store-card:hover { border-color: var(--primary); background: var(--primary-soft); }

h1.title, h1 { letter-spacing: -.01em; }
h1.title { font-weight: 700; }

/* การ์ด Trackado: สะอาด ไม่มีแถบสีด้านบน (มุมมนเล็ก เงานุ่ม) */
.card { position: relative; }

/* ช่องกรอกโฟกัส: วงแหวนน้ำเงินบาง (โทนข้อมูล) */
input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 3px var(--info-soft);
  border-color: var(--info);
}

/* =====================================================================
   TEGH นัดหมาย — Brand refresh (โลโก้ + ไอคอนใหม่)
   วาง/แปะต่อท้าย  app/static/style.css  และ  app/static/staff.css
   (หรือสร้างไฟล์นี้แล้ว <link> ต่อหลัง style.css / staff.css ใน base)
   ===================================================================== */

/* ---- 1) ไทล์โลโก้ทุกที่ใช้สีแบรนด์เดียวกัน (น้ำเงินเข้ม) ----
   เดิมไล่เฉด #638ca5→#35404f / มี slate ปน — รวมให้เป็นน้ำเงินแบรนด์ */
.brand .logo,
.side-brand .logo,
.tv-head .logo,
.wb-head .logo,
.yard-bar .logo,
.doc-logo {
  color: #fff;
}

/* ---- 2) มาร์กโลโก้ (SVG) เต็มไทล์พอดี ----
   logo_mark() ออก SVG ขนาด 1em → คุมขนาดด้วย font-size ของ .logo เดิมได้เลย
   ปรับ font-size เล็กน้อยให้หยดน้ำเต็มไทล์สวยงาม */
.brand .logo .logo-mark,
.side-brand .logo .logo-mark,
.tv-head .logo .logo-mark,
.wb-head .logo .logo-mark,
.yard-bar .logo .logo-mark,
.doc-logo .logo-mark { width: 64%; height: 64%; }
/* Cockpit/Scanner (face-bar): ไทล์น้ำเงินสด + หยดน้ำเต็มไทล์ ให้โลโก้เห็นชัด ไม่จาง */
.face-bar .logo { color: #fff; }
.face-bar .logo .logo-mark { width: 66% !important; height: 66% !important; }

/* auth-head (หน้า login): โลโก้ใหญ่บนหัวการ์ดน้ำเงิน — ไม่มีไทล์ */
.auth-head .logo { font-size: 0; }
.auth-head .logo .logo-mark { width: 56px; height: 56px; margin: 0 auto; }

/* สลิป/พิมพ์: ใช้โทนขาวดำ (เรียก {{ logo_mark('mono') }}) */
.s-logo .logo-mark { width: 9mm; height: 9mm; margin: 0 auto; }

/* ---- 3) ไอคอนเส้น (icon()) ----
   ออก SVG ขนาด 1em รับสี currentColor — แทนอิโมจิในข้อความได้ทันที */
.ic-svg { vertical-align: -0.16em; }

/* เมนูข้าง: ช่องไอคอน .ic ให้ไอคอนพอดีกลาง */
.side-nav .ic { display: inline-grid; place-items: center; width: 22px; }
.side-nav .ic .ic-svg { width: 19px; height: 19px; vertical-align: 0; }

/* การ์ด KPI: ไอคอนรับสีของชิป (ic-green/ic-blue/...) ผ่าน currentColor */
.kpi-ic { color: var(--info); }
.kpi-ic .ic-svg { width: 22px; height: 22px; vertical-align: 0; }
.kpi-ic.ic-green  { color: var(--success); }
.kpi-ic.ic-blue   { color: var(--info); }
.kpi-ic.ic-amber  { color: var(--warn); }
.kpi-ic.ic-sky    { color: var(--accent); }
.kpi-ic.ic-violet { color: var(--ic-system); }
.kpi-ic.ic-orange { color: var(--orange); }

/* หัวพาเนล / ปุ่มเล็ก: จัดไอคอนให้ชิดข้อความ */
.panel-h .ic-svg,
.btn-sm .ic-svg,
.btn .ic-svg { margin-right: 2px; }



/* =====================================================================
   โลโก้ TEGH — static/logo-tegh.png (lockup แนวนอน: มาร์กแดง + อักษรน้ำเงิน)
   อักษรเป็นสีน้ำเงินเข้ม จึงอ่านไม่ออกบนแถบกรมท่า → ใส่ "แผ่นขาว" รองให้
   ===================================================================== */
.logo-img { display: block; height: 28px; width: auto; max-width: 100%; }

/* ล้างไทล์สี่เหลี่ยมสีเขียวเดิมของทุกจุดที่วางโลโก้ */
.brand .logo,
.side-brand .logo,
.face-bar .logo,
.tv-head .logo,
.wb-head .logo,
.yard-bar .logo,
.doc-logo,
.auth-head .logo,
.s-logo {
  width: auto !important; height: auto !important;
  background: transparent !important; box-shadow: none !important;
  border-radius: 0; font-size: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- บนพื้นสว่าง: วางโลโก้ตรง ๆ ---------- */
.brand .logo .logo-img { height: 30px; }
.face-bar .logo .logo-img { height: 26px; }
.yard-bar .logo .logo-img { height: 28px; }
.doc-logo .logo-img { height: 34px; }
.s-logo .logo-img { height: 11mm; width: auto; margin: 0 auto; }

/* ---------- บนพื้นเข้ม: แผ่นขาวรองให้อ่านออก ---------- */
.side-brand .logo,
.auth-head .logo,
.wb-head .logo,
.tv-head .logo {
  background: #fff !important;
  padding: 7px 11px;
  border-radius: var(--radius-btn);
}
.side-brand .logo .logo-img { height: 26px; }
.auth-head .logo .logo-img { height: 34px; }
.wb-head .logo .logo-img,
.tv-head .logo .logo-img { height: 30px; }

/* แถบข้าง: แสดงชื่อระบบบรรทัดเดียว */
.side-brand .nm { font-size: .95rem; line-height: 1.25; font-weight: 700; color: #fff; }

/* เมนูย่อ (86px): ครอปเหลือเฉพาะสัญลักษณ์ด้านซ้าย */
body.staff.nav-collapsed .side-brand .logo { padding: 6px; }
body.staff.nav-collapsed .side-brand .logo .logo-img {
  width: 34px; height: 30px; object-fit: cover; object-position: left center;
}

/* หน้า login: โลโก้อยู่กลางหัวการ์ด */
.auth-head .logo { margin: 0 auto 10px; }

/* สลิป/เอกสารพิมพ์: บังคับพื้นขาว ไม่ให้เปลืองหมึก */
@media print {
  .logo-img { height: 11mm; }
  .side-brand .logo, .auth-head .logo, .wb-head .logo, .tv-head .logo {
    background: transparent !important; padding: 0;
  }
}


/* =====================================================================
   ฟอร์ม: วันที่ · เวลา · แนบไฟล์  (ใช้ร่วมทุกหน้า — ธีม Trackado)
   ===================================================================== */

/* ---------- วันที่: คลิกที่ไหนก็ได้ในช่อง (ไอคอนปฏิทินขยายเต็มช่อง) ---------- */
input[type="date"],
input[type="datetime-local"],
input[type="month"] { cursor: pointer; position: relative; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  position: absolute; inset: 0; width: auto; height: auto;
  margin: 0; padding: 0; opacity: 0; cursor: pointer;
}
/* ไอคอนปฏิทินที่มองเห็น (วาดเอง ชิดขวา) — ใช้กับช่องวันที่ทุกที่ */
input[type="date"],
input[type="datetime-local"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%237f8ca3' stroke-width='1.9' stroke-linecap='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='1'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 11px center !important;
  padding-right: 38px !important;
}

/* ---------- เวลา: dropdown ทีละ 30 นาที ---------- */
select.time-select {
  cursor: pointer;
  /* ไอคอนนาฬิกาชิดซ้าย — เว้นที่ขวาไว้ให้ลูกศรของ select */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%237f8ca3' stroke-width='1.9' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: left 11px center !important;
  padding-left: 38px !important;
  font-variant-numeric: tabular-nums;
}

/* ---------- ยานพาหนะ: dropdown ประเภทรถ ----------
   โครงเดียวกับ .time-select แต่เปลี่ยนเป็นไอคอนรถ
   (เดิมใช้คลาส .time-select ซ้ำ เลยได้ไอคอนนาฬิกามาด้วยทั้งที่ไม่เกี่ยวกับเวลา) */
select.veh-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%237f8ca3' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 11 6.7 6.5A2 2 0 0 1 8.6 5.2h6.8a2 2 0 0 1 1.9 1.3L19 11'/%3E%3Cpath d='M3.5 11h17v4.5h-17z'/%3E%3Ccircle cx='7.5' cy='16.5' r='1.5'/%3E%3Ccircle cx='16.5' cy='16.5' r='1.5'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: left 11px center !important;
  padding-left: 38px !important;
}

/* ---------- ช่องแนบไฟล์ธรรมดา → กล่องแบบ Trackado ---------- */
.filepick {
  display: block; cursor: pointer;
  border: 1px dashed var(--field-border); border-radius: var(--radius-btn);
  background: var(--field-bg); padding: 14px 16px;
  transition: border-color .15s, background .15s;
}
.filepick:hover,
.filepick.is-drag { border-color: var(--primary); background: var(--primary-soft); }
.filepick .fp-input {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.filepick .fp-head { display: flex; align-items: center; gap: 12px; }
.filepick .fp-ic {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  background: var(--primary); display: grid; place-items: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}
.filepick .fp-txt { min-width: 0; }
.filepick .fp-title { display: block; font-weight: 700; font-size: .92rem; color: var(--text); }
.filepick .fp-sub { display: block; font-size: .78rem; color: var(--text-faint); margin-top: 2px; }

/* รายการไฟล์ที่เลือกแล้ว */
.filepick .fp-list { display: none; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.filepick.has-file .fp-list { display: flex; }
.filepick .fp-item {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--card-border); border-radius: var(--radius-btn);
  padding: 5px 10px 5px 5px; max-width: 100%;
}
.filepick .fp-thumb {
  width: 30px; height: 30px; border-radius: 2px; object-fit: cover; flex: 0 0 auto;
  border: 1px solid var(--card-border);
}
.filepick .fp-name {
  font-size: .8rem; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px;
}
.filepick .fp-size { font-size: .72rem; color: var(--text-faint); flex: 0 0 auto; }

/* ---------- dropzone (หน้านัดหมาย / ผู้มาติดต่อ) ---------- */
.file-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.dropzone {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 4px; padding: 22px 18px;
  border: 1px dashed var(--field-border); border-radius: var(--radius-btn);
  background: var(--field-bg);
  transition: border-color .15s, background .15s;
}
.dropzone:hover,
.dropzone.is-drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .dz-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; margin-bottom: 6px;
}
.dropzone .dz-icon .ic-svg { width: 21px; height: 21px; color: #fff; }
.dropzone .dz-title { font-weight: 700; font-size: 1rem; color: var(--text); }
.dropzone .dz-sub { font-size: .8rem; color: var(--text-faint); line-height: 1.45; }
.dropzone .dz-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }
.dropzone .dz-btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: #fff; border: 1px solid var(--card-border); border-radius: var(--radius-btn);
  padding: 9px 15px; font-size: .87rem; font-weight: 600; color: var(--info);
  transition: border-color .15s, color .15s, background .15s;
}
.dropzone .dz-btn:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-soft); }
.dropzone .dz-btn .ic-svg { width: 16px; height: 16px; }

/* รูปตัวอย่างที่แนบ */
.photo-preview { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.photo-preview:empty { margin-top: 0; }
.photo-preview .pp-thumb {
  width: 84px; height: 84px; object-fit: cover;
  border: 1px solid var(--card-border); border-radius: var(--radius-btn); background: #fff;
}

/* ---------- มือถือ: ปุ่มเต็มความกว้าง แตะง่าย ---------- */
@media (max-width: 560px) {
  .dropzone .dz-actions { width: 100%; }
  .dropzone .dz-btn { flex: 1 1 100%; justify-content: center; min-height: 44px; }
  .filepick .fp-name { max-width: 130px; }
  .photo-preview .pp-thumb { width: 72px; height: 72px; }
}

/* จอแคบ: ลดระยะไอคอนนาฬิกา เพื่อให้ข้อความในช่องเวลาไม่ถูกตัด */
@media (max-width: 480px) {
  select.time-select,
  select.veh-select { background-position: left 8px center !important; padding-left: 30px !important; }
}

/* =====================================================================
   สถานะกำลังโหลด — ใช้ร่วมทุกหน้า (หลังบ้าน · ลูกค้า · ผู้มาติดต่อ)
   ขับด้วย ui-motion.js
   ===================================================================== */
.nav-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 9999;
  background: var(--primary); transform-origin: 0 50%; transform: scaleX(0);
  transition: transform 1.6s var(--ease-out), opacity .3s linear;
  pointer-events: none;
}
button.is-busy { position: relative; color: transparent !important; pointer-events: none; }
button.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  color: #fff; animation: btnSpin .7s linear infinite;
}
body.staff .btn-sm.is-busy:not(.primary)::after { color: var(--text-soft); }
@keyframes btnSpin { to { transform: rotate(360deg); } }

/* =====================================================================
   ปฏิทินเลือกวันที่ (static/datepick.js) — แทนหน้าต่างปฏิทินของเบราว์เซอร์ ทุกหน้า
   ===================================================================== */
/* ช่องวันที่: ปิดไอคอนปฏิทินของเบราว์เซอร์ (เฉพาะเมื่อสคริปต์ทำงาน) — คลิกช่อง = เปิดปฏิทินของระบบ */
html.dp-js input[type="date"]:not([data-native])::-webkit-calendar-picker-indicator { display: none; }
html.dp-js input[type="date"]:not([data-native]) { cursor: pointer; }
input[type="date"].dp-active { border-color: var(--primary) !important; box-shadow: 0 0 0 3px var(--primary-soft) !important; }
input[type="date"].dp-invalid { border-color: var(--danger) !important; }

.dp-back { position: fixed; inset: 0; z-index: 10990; background: rgba(16,29,53,.42); opacity: 0; transition: opacity .16s ease; }
.dp-back.open { opacity: 1; }
.dp-pop {
  position: fixed; z-index: 11000; width: 318px; max-width: calc(100vw - 16px);
  background: var(--card-bg, #fff); color: var(--text); border: 1px solid var(--card-border);
  border-radius: 12px; box-shadow: 0 18px 48px rgba(16,29,53,.22), 0 2px 6px rgba(16,29,53,.08);
  overflow: hidden; font-family: inherit;
  opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top left;
  transition: opacity .14s ease, transform .14s ease;
}
.dp-pop.open { opacity: 1; transform: none; }
.dp-pop[hidden], .dp-back[hidden] { display: none !important; }
.dp-grab { display: none; }

/* หัว: เดือน ปี (ค.ศ. + พ.ศ.) · ‹ › */
.dp-head { display: flex; align-items: center; gap: 4px; padding: 10px 10px 8px; background: var(--panelhead, #638ca5); color: #fff; }
.dp-title { flex: 1 1 auto; min-width: 0; border: 0; background: transparent; color: #fff; font-family: inherit;
  font-size: 1rem; font-weight: 800; padding: 6px 8px; border-radius: 8px; cursor: pointer; text-align: center; line-height: 1.2; }
.dp-title small { display: inline-block; margin-left: 4px; font-size: .72rem; font-weight: 600; opacity: .8; }
.dp-title .dp-caret { font-style: normal; font-size: .7rem; margin-left: 5px; opacity: .8; }
.dp-title:hover { background: rgba(255,255,255,.14); }
.dp-nav { flex: 0 0 34px; height: 34px; border: 0; border-radius: 8px; background: rgba(255,255,255,.14); color: #fff;
  font-size: 1.35rem; font-weight: 700; line-height: 1; cursor: pointer; font-family: inherit; }
.dp-nav:hover:not(:disabled) { background: rgba(255,255,255,.26); }
.dp-nav:disabled { opacity: .35; cursor: default; }

.dp-body { padding: 8px 10px 4px; }
.dp-dow { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 2px; }
.dp-dow span { text-align: center; font-size: .72rem; font-weight: 800; color: var(--text-faint); padding: 4px 0; }
.dp-dow span.sun { color: #d0453b; }
.dp-dow span.sat { color: var(--info, #638ca5); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }

/* วัน */
.dp-d { position: relative; height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--text);
  font-family: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; padding: 0; transition: background .1s ease; }
.dp-d .dp-n { font-size: .92rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dp-d .dp-c { font-size: .6rem; font-weight: 800; line-height: 1; color: var(--primary-dark); min-height: 8px; margin-top: 1px; }
.dp-d .dp-p { position: absolute; top: 4px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--warn, #e8b71a); }
.dp-d.sun .dp-n { color: #d0453b; }
.dp-d:hover:not(:disabled) { background: var(--primary-soft); }
.dp-d:focus-visible { outline: 2px solid var(--info, #638ca5); outline-offset: -2px; }
.dp-d.out { opacity: .38; }
.dp-d.today { box-shadow: inset 0 0 0 2px var(--primary); }
.dp-d.today .dp-n { color: var(--primary-dark); }
.dp-d.sel { background: var(--primary) !important; box-shadow: 0 4px 10px rgba(84,192,138,.35); }
.dp-d.sel .dp-n, .dp-d.sel .dp-c { color: #fff !important; }
.dp-d.sel .dp-p { background: #fff; }
.dp-d.dis { opacity: .28; cursor: not-allowed; }
.dp-d.dis .dp-n { text-decoration: line-through; text-decoration-thickness: 1px; }

/* เลือกเดือน */
.dp-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 6px 0 8px; }
.dp-m { height: 46px; border: 1px solid var(--card-border); border-radius: 8px; background: var(--card-bg, #fff); color: var(--text);
  font-family: inherit; font-size: .92rem; font-weight: 700; cursor: pointer; }
.dp-m:hover:not(:disabled) { background: var(--primary-soft); border-color: var(--primary); }
.dp-m.today { border-color: var(--primary); color: var(--primary-dark); }
.dp-m.sel { background: var(--primary); border-color: var(--primary); color: #fff; }
.dp-m:disabled { opacity: .35; cursor: not-allowed; }

.dp-legend { display: flex; gap: 12px; justify-content: center; padding: 2px 10px 6px; font-size: .68rem; color: var(--text-faint); font-weight: 600; }
.dp-legend .lg-n { color: var(--primary-dark); font-weight: 800; }
.dp-legend .lg-p { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--warn, #e8b71a); margin-right: 3px; vertical-align: 1px; }
.dp-legend[hidden] { display: none; }

/* ท้าย: วันนี้ · พรุ่งนี้ · ล้าง */
.dp-foot { display: flex; align-items: center; gap: 6px; padding: 8px 10px 10px; border-top: 1px solid var(--card-border); }
.dp-foot:empty { display: none; }
.dp-sp { flex: 1 1 auto; }
.dp-btn { height: 32px; padding: 0 12px; border: 1px solid var(--card-border); border-radius: 8px; background: var(--field-bg, #f4f6fa);
  color: var(--text-soft); font-family: inherit; font-size: .82rem; font-weight: 700; cursor: pointer; }
.dp-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-soft); }
.dp-btn.on { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-soft); }
.dp-btn:disabled { opacity: .4; cursor: not-allowed; }
.dp-btn.dp-clear { background: transparent; border-color: transparent; color: var(--danger, #c31414); }
.dp-btn.dp-clear:hover { background: var(--danger-soft, #fbe4e4); border-color: transparent; color: var(--danger, #c31414); }

/* มือถือ: แผ่นล่าง (bottom sheet) ปุ่มใหญ่ */
.dp-pop.dp-sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; max-width: none;
  border-radius: 16px 16px 0 0; transform: translateY(24px); transform-origin: bottom center;
  padding-bottom: env(safe-area-inset-bottom, 0); }
.dp-pop.dp-sheet.open { transform: none; }
.dp-sheet .dp-grab { display: block; width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.6);
  position: absolute; top: 5px; left: 50%; margin-left: -20px; z-index: 1; }
.dp-sheet .dp-head { padding-top: 16px; }
.dp-sheet .dp-title { font-size: 1.08rem; }
.dp-sheet .dp-nav { flex-basis: 42px; height: 42px; }
.dp-sheet .dp-d { height: 48px; }
.dp-sheet .dp-d .dp-n { font-size: 1.02rem; }
.dp-sheet .dp-btn { height: 42px; padding: 0 16px; font-size: .9rem; }
.dp-sheet .dp-foot { padding-bottom: 14px; }
@media (prefers-reduced-motion: reduce) { .dp-pop, .dp-back { transition: none; } }
