/* ==============================================================
   Factorium app — ส่วนเสริมที่ factorium.css ไม่มี (โหลดต่อจาก factorium.css)
   ใช้ var(--token) จาก design-system/tokens.css เท่านั้น ห้ามรหัสสีตายตัว
   ขนาดตัวอักษร/ไอคอนใช้ค่าจาก type scale ของ tokens.css และ Icon.md เพราะ tokens ไม่มีตัวแปรขนาดตัวอักษร
   ============================================================== */

/* ================= App shell (layout.php) ================= */
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
#wrapper { display: flex; width: 100%; height: 100vh; overflow: hidden; }
#page-content-wrapper { flex: 1 1 auto; min-width: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; position: relative; }
#main-content { flex: 1 1 auto; overflow-x: hidden; overflow-y: auto; padding: var(--space-6) var(--space-7); }
/* README: เนื้อหากว้างไม่เกิน 1280px */
/* .fx-page { max-width: 1280px; margin: 0 auto; } */

/* SidebarNav: #sidebar.show / body.sidebar-collapsed ถูกสลับโดย JS ใน layout.php */
#sidebar.fx-side { height: 100vh; min-height: 0; flex-shrink: 0; overflow-y: auto; z-index: 1050; transition: transform .2s ease; }
.fx-side-item > i { width: 18px; font-size: 17px; text-align: center; color: var(--on-sidebar-muted); flex: none; }
.fx-side-item.active { background: var(--sidebar-active); font-weight: 500; }
.fx-side-item.active > i { color: var(--on-sidebar); }
.fx-side-item[data-bs-toggle] { cursor: pointer; }
.fx-side-caret { margin-left: auto; font-size: 13px !important; transition: transform .2s ease; }
.fx-side-item[aria-expanded="true"] .fx-side-caret { transform: rotate(180deg); }
/* วงกลมแดงจำนวนรายการใหม่ในเมนู (layout.php menuBadge) */
.fx-side-count {
  margin-left: auto; flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill);
  background: var(--danger); color: var(--on-danger); font-family: var(--font-mono); font-size: 12px; font-weight: 600; line-height: 20px; text-align: center;
}
.fx-side-count + .fx-side-caret { margin-left: var(--space-2); }
.fx-side ul ul { margin-top: 2px; }
.fx-side-sub { padding-left: calc(var(--space-3) * 2 + 18px); }
.fx-side li > .fx-side-title { margin-top: var(--space-4); }
.fx-side-user-text { min-width: 0; flex: 1; }
.fx-side-uname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-side .fx-btn-ghost { color: var(--on-sidebar); }
.fx-side .fx-btn-ghost:hover { background: var(--sidebar-active); }

#sidebarOverlay { display: none; position: fixed; inset: 0; background: var(--sidebar); opacity: .5; z-index: 1045; }

/* Top bar */
.fx-topbar {
  display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; z-index: 1040;
  min-height: calc(var(--space-7) + var(--space-3)); padding: 0 var(--space-4);
  background: var(--surface-raised); border-bottom: 1px solid var(--line);
}
.fx-topbar-title { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.fx-topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.fx-topbar .fx-btn { position: relative; }
.fx-topbar-count {
  position: absolute; top: var(--space-1); right: var(--space-1); min-width: var(--space-4); height: var(--space-4);
  padding: 0 var(--space-1); border-radius: var(--radius-pill); background: var(--danger); color: var(--on-danger);
  font-family: var(--font-mono); font-size: 12px; line-height: var(--space-4); text-align: center;
}
.fx-topbar-user { color: var(--ink); }
.fx-topbar-uname { max-width: calc(var(--space-7) * 3); overflow: hidden; text-overflow: ellipsis; }

/* Avatar ตัวอักษรย่อ */
.fx-avatar {
  width: var(--space-6); height: var(--space-6); border-radius: var(--radius-pill); flex: none;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 600;
}

/* Menu (หน้าตาของ Bootstrap .dropdown-menu, JS เดิม) */
.fx-menu.dropdown-menu {
  --bs-dropdown-bg: var(--surface-raised);
  --bs-dropdown-color: var(--ink);
  --bs-dropdown-border-color: var(--line);
  --bs-dropdown-border-radius: var(--radius-md);
  --bs-dropdown-inner-border-radius: var(--radius-md);
  --bs-dropdown-link-color: var(--ink);
  --bs-dropdown-link-hover-color: var(--ink);
  --bs-dropdown-link-hover-bg: var(--surface-sunken);
  --bs-dropdown-link-active-color: var(--ink);
  --bs-dropdown-link-active-bg: var(--brand-soft);
  --bs-dropdown-header-color: var(--ink-muted);
  --bs-dropdown-divider-bg: var(--line);
  --bs-dropdown-item-padding-x: var(--space-4);
  --bs-dropdown-item-padding-y: var(--space-2);
  --bs-dropdown-padding-y: var(--space-1);
  --bs-dropdown-font-size: 15px;
  box-shadow: var(--shadow-2); overflow: hidden;
}
.fx-menu-wide { width: min(calc(var(--space-7) * 6), calc(100vw - var(--space-6))); padding: 0; }
.fx-menu-wide .dropdown-item { white-space: normal; padding-top: var(--space-3); padding-bottom: var(--space-3); }
.fx-menu-wide li + li { border-top: 1px solid var(--line); }
.fx-menu-head { padding: var(--space-2) var(--space-4); font-size: 14px; line-height: 22px; font-weight: 600; color: var(--ink); background: var(--surface-sunken); }
.fx-menu-time { display: block; margin-top: 2px; font-size: 13px; line-height: 21px; color: var(--ink-muted); }
.fx-menu-link { text-align: center; color: var(--brand) !important; font-weight: 500; }

/* ระดับความเร่งด่วน: ตัวอักษรสี + ไอคอน ไม่มีพื้น (ไม่ให้ดูเหมือน StatusBadge) */
.fx-urgency { display: inline-flex; align-items: center; gap: var(--space-1); font-weight: 500; }
.fx-urgency-high { color: var(--danger); }
.fx-urgency-mid { color: var(--warning); }
.fx-urgency-low { color: var(--ink-muted); }

/* Mobile bottom navigation (เฉพาะ tech/sale) */
.fx-bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1045;
  min-height: calc(var(--space-7) + var(--space-4)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface-raised); border-top: 1px solid var(--line); box-shadow: var(--shadow-1);
}
.fx-bottom-nav-item {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: var(--space-1) 0; color: var(--ink-muted); text-decoration: none; font-size: 13px; line-height: 18px; font-weight: 500;
}
.fx-bottom-nav-item i { font-size: 21px; }
.fx-bottom-nav-item.active { color: var(--brand); }
.fx-bottom-nav-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.fx-bottom-nav-main { flex: 0 0 calc(var(--space-7) + var(--space-5)); }
.fx-bottom-nav-center {
  width: var(--space-7); height: var(--space-7); margin-top: calc(-1 * var(--space-5)); border-radius: var(--radius-pill);
  display: grid; place-items: center; background: var(--brand); color: var(--on-brand);
  border: var(--space-1) solid var(--surface); box-shadow: var(--shadow-1);
}
.fx-bottom-nav-main[aria-current="page"] .fx-bottom-nav-center { background: var(--brand-strong); }

@media (min-width: 992px) {
  body.sidebar-collapsed #sidebar { display: none; }
}
@media (max-width: 991.98px) {
  #sidebar.fx-side { position: fixed; top: 0; left: 0; transform: translateX(-100%); box-shadow: var(--shadow-2); }
  #sidebar.fx-side.show { transform: none; }
  #sidebarOverlay.show { display: block; }
  .fx-bottom-nav { display: flex; }
  #main-content { padding: var(--space-4) var(--space-4) calc(var(--space-7) * 2); }
}
@media (prefers-reduced-motion: reduce) {
  #sidebar.fx-side, .fx-side-caret { transition: none; }
}

/* ================= Print =================
   พิมพ์หน้าในแอป (เช่น สติกเกอร์ QR): คืนขนาดตัวอักษร/ระยะบรรทัดของ Bootstrap
   แทนค่า body ของ factorium.css (ฟอนต์ Prompt โหลดด้วย <link media="print"> ใน layout.php) */
@media print {
  body { font-size: var(--bs-body-font-size) !important; line-height: var(--bs-body-line-height) !important; }
  .fx-page { max-width: none; }
}

/* ================= Login (login.php) ================= */
body.fx-login { overflow-y: auto; min-height: 100vh; margin: 0; background: linear-gradient(135deg, var(--brand) 0%, var(--sidebar) 100%); }
.fx-login-shell { min-height: 100vh; display: grid; place-items: center; padding: var(--space-4); }
@media (min-width: 992px) { .fx-login-shell { padding: var(--space-7); } }
/* การ์ดขาวมุมโค้ง แบ่งซ้าย (แบรนด์) / ขวา (ฟอร์ม) ตามแบบ login.png */
.fx-login-card {
  width: 100%; max-width: 1040px; display: grid; grid-template-columns: 1fr;
  background: var(--surface-raised); border-radius: calc(var(--radius-lg) * 2); box-shadow: var(--shadow-2); overflow: hidden;
}
@media (min-width: 992px) { .fx-login-card { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); min-height: 620px; } }
/* แผงแบรนด์: วงกลมสีน้ำเงินซ้อนกันเป็นลวดลาย */
.fx-login-hero {
  position: relative; overflow: hidden; isolation: isolate;
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-strong) 100%); color: var(--on-brand);
  padding: var(--space-6) var(--space-5); display: flex; flex-direction: column; justify-content: center; gap: var(--space-2);
}
.fx-login-hero::before, .fx-login-hero::after, .fx-login-orb {
  content: ""; position: absolute; z-index: -1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--brand-muted) 55%, var(--brand)) 0%, var(--brand) 45%, var(--brand-strong) 90%);
  box-shadow: var(--shadow-2);
}
.fx-login-hero::before { width: 140%; aspect-ratio: 1; top: -55%; left: -55%; background: radial-gradient(circle at 75% 75%, color-mix(in srgb, var(--brand-muted) 55%, var(--brand)) 0%, var(--brand) 35%, var(--brand-strong) 80%); }
.fx-login-hero::after { width: 260px; aspect-ratio: 1; bottom: -110px; left: -90px; }
.fx-login-orb { width: 200px; aspect-ratio: 1; bottom: 40px; right: -40px; }
@media (min-width: 992px) { .fx-login-hero { padding: var(--space-7); } .fx-login-orb { width: 240px; bottom: 60px; right: 40px; } }
.fx-login-mark { margin: 0 0 var(--space-3); font-size: 17px; line-height: 24px; font-weight: 700; letter-spacing: .02em; color: var(--on-brand); }
.fx-login-mark span { font-weight: 500; opacity: .8; }
.fx-login-headline { margin: 0; font-size: 40px; line-height: 52px; font-weight: 700; letter-spacing: .02em; color: var(--on-brand); }
.fx-login-sub { margin: 0; font-size: 19px; line-height: 28px; font-weight: 600; color: var(--on-brand); }
.fx-login-lead { margin: var(--space-2) 0 0; color: var(--on-brand); opacity: .85; max-width: 40ch; font-size: 15px; line-height: 24px; }
/* มือถือ: ย่อแผงแบรนด์ให้ฟอร์มขึ้นมาเร็ว */
@media (max-width: 991.98px) {
  .fx-login-headline { font-size: 26px; line-height: 36px; }
  .fx-login-sub { font-size: 16px; line-height: 26px; }
  .fx-login-lead, .fx-login-orb { display: none; }
}
.fx-login-panel { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: var(--space-6) var(--space-4); }
@media (min-width: 992px) { .fx-login-panel { padding: var(--space-7); } }
/* วงกลมมุมขวาล่างของฝั่งฟอร์ม */
.fx-login-panel::after {
  content: ""; position: absolute; width: 140px; aspect-ratio: 1; right: -50px; bottom: -50px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--brand-muted) 55%, var(--brand)) 0%, var(--brand) 45%, var(--brand-strong) 90%);
}
.fx-login-box { position: relative; z-index: 1; width: 100%; max-width: calc(var(--space-7) * 9); }
.fx-login-title { margin: 0 0 var(--space-1); font-size: 32px; line-height: 44px; font-weight: 700; color: var(--ink); }
.fx-login-form { display: grid; gap: var(--space-4); }
/* ช่องกรอกแบบพื้นทึบไม่มีเส้นขอบ */
.fx-login-form .fx-input { height: 48px; border-color: transparent; background: var(--surface-sunken); border-radius: var(--radius-lg); }
.fx-login-form .fx-input:focus { border-color: var(--brand); background: var(--surface-raised); }
.fx-login-pass { padding-right: calc(var(--space-7) + var(--space-3)) !important; }
.fx-login-eye {
  position: absolute; right: var(--space-1); top: 50%; transform: translateY(-50%); min-height: 40px; padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius-md); background: none; color: var(--brand); font-size: 14px; font-weight: 700; letter-spacing: .04em; cursor: pointer;
}
.fx-login-eye:hover { background: var(--brand-soft); }
.fx-login-eye:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fx-login-sim { margin: 0; padding: var(--space-3); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); min-width: 0; }
.fx-login-sim legend { float: none; width: auto; padding: 0 var(--space-1); margin: 0; font-size: inherit; }
.fx-login-roles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
@media (min-width: 420px) { .fx-login-roles { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.fx-login-roles .fx-choice { padding: var(--space-2) var(--space-1); min-height: 64px; justify-content: center; }
.fx-login-roles .body-sm { font-size: 13px; line-height: 21px; }
.fx-login-submit { height: 48px; border-radius: var(--radius-lg); font-size: 17px; }
.fx-login-foot { text-align: center; margin-top: var(--space-5); }

/* ================= แก้จากการตรวจในเบราว์เซอร์ ================= */
/* fx-field เป็น grid: ให้ลูกหดได้ (ช่องวันที่คู่ในตัวกรองไม่ล้นทับช่องถัดไป) */
.fx-field { grid-template-columns: minmax(0, 1fr); }
/* fx-tabs: แท็บมี margin-bottom -1px ทำให้เกิดแถบเลื่อนแนวตั้งในหน้า profile */
.fx-tabs { overflow-y: hidden; }
/* ปุ่มที่เป็นลิงก์ไม่ขีดเส้นใต้; ลิงก์ทั่วไปใช้สี brand แทนน้ำเงินของ Bootstrap */
a { color: var(--brand); }
/* เฉพาะลิงก์ข้อความ: ห้ามทับสีของปุ่ม/เมนูที่เป็น <a> (เดิมทำให้ปุ่มน้ำเงินและเมนูข้างตัวหนังสือกลืนพื้นตอนชี้เมาส์) */
a:not([class*="fx-"]):not(.dropdown-item):not(.btn):hover { color: var(--brand-strong); }
a.fx-btn, a.fx-btn:hover { text-decoration: none; }
/* .fx-table td ของ design system กำหนดสี ink จึงชนะ fx-tone-* ที่ใส่บนเซลล์ */
.fx-table td.fx-tone-success { color: var(--success); }
.fx-table td.fx-tone-danger { color: var(--danger); }
.fx-table td.fx-tone-warning { color: var(--warning); }
.fx-table td.fx-tone-neutral { color: var(--ink-muted); }
/* ส่วนที่ต้องมีระยะขอบในการ์ด fx-card-flush (receive_parts: ไฟล์แนบ/ยอดรวม) */
.fx-card-flush .fx-card-body.fx-card-pad { padding: var(--space-5); }

/* ================= Page header (heading-1 + ปุ่มขวาบน) ================= */
.fx-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-4); margin-bottom: var(--space-5); }
.fx-page-head .heading-1 { margin: 0; color: var(--ink); }
.fx-page-desc { margin: var(--space-1) 0 0; font-size: 15px; line-height: 24px; color: var(--ink-muted); }
.fx-page-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

/* ================= Shared helpers ================= */
.fx-divider { border-bottom: 1px solid var(--line); }
.fx-divider-top { border-top: 1px solid var(--line); }
.fx-select-inline { width: auto; }
.fx-form-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.fx-form-actions .fx-hint { flex: 1 1 auto; }
/* fx-tabs ที่สลับด้วย Bootstrap Tab JS (ใส่คลาส active แทน is-active) */
.fx-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.fx-tab.active .fx-tab-count { background: var(--brand-soft); color: var(--brand); }
/* แท็บที่มีสีตามสถานะ (my_tasks): ตัวนับมีสีเสมอ, แท็บที่เลือกขีดเส้นใต้สีเดียวกัน */
.fx-tab-tone-warning .fx-tab-count, .fx-tab-tone-warning.active .fx-tab-count { background: var(--warning-soft); color: var(--warning); }
.fx-tab-tone-brand .fx-tab-count, .fx-tab-tone-brand.active .fx-tab-count { background: var(--brand-soft); color: var(--brand); }
.fx-tab-tone-success .fx-tab-count, .fx-tab-tone-success.active .fx-tab-count { background: var(--success-soft); color: var(--success); }
.fx-tab-tone-warning.active { color: var(--warning); border-bottom-color: var(--warning); }
.fx-tab-tone-success.active { color: var(--success); border-bottom-color: var(--success); }
.fx-tab-tone-warning.active, .fx-tab-tone-brand.active, .fx-tab-tone-success.active { font-weight: 600; }

/* ข้อความตัวอย่างในช่องกรอกจางกว่าหัวข้อ (label ใช้ --ink) ค่าที่พิมพ์แล้วยังเป็น --ink */
.fx-input::placeholder { color: var(--ink-disabled); opacity: 1; }

/* StatCard: แถวท้ายการ์ด (สถานะ + ลิงก์) */
.fx-stat { display: flex; flex-direction: column; }
.fx-stat-foot { margin-top: auto; padding-top: var(--space-3); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.fx-stat-foot .fx-stat-delta { margin: 0 !important; }

/* Chart container (Chart.js ใช้ maintainAspectRatio: false) */
.fx-chart { position: relative; height: calc(var(--space-7) * 6 + var(--space-6)); }
.fx-chart-sm { height: calc(var(--space-7) * 5); }
/* dl แบบ ป้าย ↔ ค่า ชิดขวา */
.fx-dl-split { grid-template-columns: 1fr max-content; border-top: 1px solid var(--line); }
.fx-dl-split dd { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ประเภทงาน (CM/PM/Cal/ติดตั้ง): แท็ก outline ไม่ใช้สี แยกด้วยข้อความ */
.fx-tag {
  display: inline-flex; align-items: center; gap: var(--space-1); white-space: nowrap;
  padding: 0 6px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-muted); font-size: 13px; line-height: 18px; font-weight: 500;
}

/* Avatar ขนาดใหญ่ + ปุ่มเปลี่ยนรูป (profile) */
.fx-avatar-lg { width: calc(var(--space-7) * 2); height: calc(var(--space-7) * 2); font-size: 32px; }
.fx-avatar-wrap { position: relative; display: inline-block; }
.fx-avatar-btn { position: absolute; right: 0; bottom: 0; width: 38px; padding: 0; border-radius: var(--radius-pill); }

/* List ภายในการ์ด (fx-card-flush) */
.fx-list { list-style: none; margin: 0; padding: 0; }
.fx-list-item { padding: var(--space-3) var(--space-5); }
.fx-list-item + .fx-list-item { border-top: 1px solid var(--line); }
.fx-list-meta { margin-top: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--surface-sunken); color: var(--ink-muted); font-size: 14px; line-height: 22px; display: flex; align-items: center; }
.fx-list-item.is-idle .fw-medium { color: var(--ink-muted); }

/* ================= Calendar (calibration_calendar) ================= */
.fx-cal-legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-4); font-size: 14px; line-height: 22px; color: var(--ink-muted); }
.fx-calendar { min-width: calc(var(--space-7) * 14); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--line); }
.fx-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.fx-cal-cell { background: var(--surface-raised); min-height: calc(var(--space-7) * 3); padding: var(--space-2); display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.fx-cal-cell.is-head { min-height: 0; text-align: center; background: var(--surface-sunken); color: var(--ink-muted); font-size: 14px; line-height: 22px; font-weight: 500; }
.fx-cal-cell.is-weekend { background: var(--surface); }
.fx-cal-cell.is-outside .fx-cal-date { color: var(--ink-disabled); }
.fx-cal-cell.is-holiday { text-align: center; }
.fx-cal-cell.is-today { background: var(--brand-soft); }
.fx-cal-date { text-align: right; font-family: var(--font-mono); font-size: 14px; line-height: 22px; font-weight: 500; color: var(--ink-muted); }
.fx-cal-cell.is-today .fx-cal-date span { display: inline-grid; place-items: center; min-width: var(--space-5); height: var(--space-5); border-radius: var(--radius-pill); background: var(--brand); color: var(--on-brand); }
.fx-cal-note { margin-top: var(--space-2); color: var(--ink-muted); font-weight: 500; }
.fx-cal-event {
  font: inherit; display: block; width: 100%; min-width: 0; text-align: left; cursor: pointer;
  padding: var(--space-1) var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface-raised); color: var(--ink); font-size: 13px; line-height: 18px; font-weight: 500;
  /* ตัดบรรทัดได้ เพื่อให้เห็นชื่อช่างและสถานที่ครบในช่องแคบ */
  white-space: normal; overflow-wrap: anywhere;
}
.fx-cal-event .fx-tag { margin-right: var(--space-1); }
.fx-cal-event:hover { border-color: var(--line-strong); background: var(--surface-sunken); }
.fx-cal-event:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ปฏิทิน: สีพาสเทลประจำตัวช่าง (fx-person-N) และสีประเภทวัน (is-holiday / is-company-off / is-weekend / is-today) */
:root {
  --pastel-1: #dbe8fd; --pastel-1-edge: #6b93d6;
  --pastel-2: #d8f2e1; --pastel-2-edge: #5fae7d;
  --pastel-3: #ebe3fb; --pastel-3-edge: #9a82d4;
  --pastel-4: #ffe4d1; --pastel-4-edge: #d98a52;
  --day-holiday: #fde7e9; --day-holiday-ink: #a3313e;
  --day-company: #fff3cf; --day-company-ink: #7a5600;
}
[data-theme="dark"] {
  --pastel-1: #1c2c48; --pastel-1-edge: #78a6f2;
  --pastel-2: #16301f; --pastel-2-edge: #5cc98a;
  --pastel-3: #2a2342; --pastel-3-edge: #b9a8ec;
  --pastel-4: #3a2616; --pastel-4-edge: #f0a868;
  --day-holiday: #3a1a1e; --day-holiday-ink: #ff9aa5;
  --day-company: #332a10; --day-company-ink: #f0bb5a;
}
.fx-person-1 { --person-bg: var(--pastel-1); --person-edge: var(--pastel-1-edge); }
.fx-person-2 { --person-bg: var(--pastel-2); --person-edge: var(--pastel-2-edge); }
.fx-person-3 { --person-bg: var(--pastel-3); --person-edge: var(--pastel-3-edge); }
.fx-person-4 { --person-bg: var(--pastel-4); --person-edge: var(--pastel-4-edge); }
.fx-cal-event[class*="fx-person-"] { background: var(--person-bg); border-color: var(--person-bg); border-left: 3px solid var(--person-edge); }
.fx-cal-event[class*="fx-person-"]:hover { background: var(--person-bg); border-color: var(--person-edge); }
.fx-avatar[class*="fx-person-"] { background: var(--person-bg); color: var(--ink); box-shadow: inset 0 0 0 2px var(--person-edge); }
.fx-cal-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: var(--space-1); border: 1px solid var(--line); }
.fx-cal-swatch[class*="fx-person-"] { background: var(--person-bg); border-color: var(--person-edge); }
.fx-cal-cell.is-holiday { background: var(--day-holiday); }
.fx-cal-cell.is-holiday .fx-cal-note, .fx-cal-cell.is-holiday .fx-cal-date { color: var(--day-holiday-ink); }
.fx-cal-cell.is-company-off { background: var(--day-company); text-align: center; }
.fx-cal-cell.is-company-off .fx-cal-note, .fx-cal-cell.is-company-off .fx-cal-date { color: var(--day-company-ink); }
.fx-cal-swatch.is-holiday { background: var(--day-holiday); border-color: var(--day-holiday-ink); }
.fx-cal-swatch.is-company-off { background: var(--day-company); border-color: var(--day-company-ink); }
.fx-cal-swatch.is-weekend { background: var(--surface); border-color: var(--line-strong); }
.fx-cal-swatch.is-today { background: var(--brand-soft); border-color: var(--brand); }

/* ================= Bootstrap text utilities → tokens (หน้าที่ยังใช้ text-* และ hook ที่ JS ใช้ เช่น .text-danger) ================= */
.text-primary { color: var(--brand) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--brand) !important; }
.text-secondary, .text-muted { color: var(--ink-muted) !important; }
.text-dark, .text-body { color: var(--ink) !important; }

/* ================= Modal (หน้าตาของ Bootstrap .modal, JS เดิม) ================= */
.fx-modal .modal-content { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); }
.fx-modal .modal-header { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--line); gap: var(--space-3); }
.fx-modal .modal-title { margin: 0; font-size: 17px; line-height: 24px; font-weight: 600; color: var(--ink); }
.fx-modal .modal-body { padding: var(--space-5); }
.fx-modal .modal-footer { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--line); gap: var(--space-2); flex-wrap: nowrap; }
.fx-modal .modal-footer > * { margin: 0; }
.fx-modal .btn-close:focus-visible { box-shadow: none; outline: 2px solid var(--focus); outline-offset: 2px; }
.modal-backdrop { --bs-backdrop-bg: var(--sidebar); --bs-backdrop-opacity: .5; }

/* ================= Form extras ================= */
.fx-input-group { display: flex; gap: var(--space-2); align-items: stretch; }
.fx-input-group > .fx-input, .fx-input-group > .fx-input-wrap { flex: 1 1 auto; min-width: 0; }
.fx-input-group > .fx-btn { height: 40px; flex: none; }
.fx-input-unit { display: inline-flex; align-items: center; color: var(--ink-muted); font-size: 15px; }
.fx-input-file { padding: var(--space-2) var(--space-3); height: auto; }
.fx-input-sm { height: 32px; font-size: 15px; }
.fx-num { font-family: var(--font-mono); text-align: center; font-variant-numeric: tabular-nums; }
/* radio ของเบราว์เซอร์ + สีจาก token (ยังไม่มี Radio ใน design system) */
.fx-radio { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-weight: 500; }
.fx-radio input, input.fx-radio-input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.fx-btn-dashed { border-style: dashed; }
.fx-btn-icon { width: 38px; padding: 0; }
.fx-btn-sm.fx-btn-icon { width: 30px; }
/* ปุ่มโทนอ่อน (หน้างานของฉัน): แยกปุ่มรองด้วยสีโดยไม่แย่งความเด่นจากปุ่ม primary */
.fx-btn-soft-brand { background: var(--brand-soft); border-color: var(--brand-soft); color: var(--brand); }
.fx-btn-soft-brand:hover { background: var(--brand-soft); border-color: var(--brand); }
.fx-btn-soft-warning { background: var(--warning-soft); border-color: var(--warning-soft); color: var(--warning); }
.fx-btn-soft-warning:hover { background: var(--warning-soft); border-color: var(--warning); }
.fx-section-title { margin: 0 0 var(--space-3); font-size: 17px; line-height: 24px; font-weight: 600; color: var(--ink); }
.fx-section + .fx-section { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--line); }

/* กล่องข้อความรอง (อาการแจ้งซ่อม ข้อมูลอ้างอิง) */
.fx-note { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-sunken); color: var(--ink); font-size: 15px; line-height: 24px; }
.fx-alert.is-clickable { cursor: pointer; }
.fx-alert.is-clickable:hover { border-color: var(--line-strong); }

/* Breadcrumb */
.fx-breadcrumb { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: var(--space-1) 0 0; padding: 0; list-style: none; font-size: 14px; line-height: 22px; color: var(--ink-muted); }
.fx-breadcrumb li + li::before { content: "/"; margin-right: var(--space-1); color: var(--ink-disabled); }
.fx-breadcrumb a { color: var(--ink-muted); text-decoration: none; }
.fx-breadcrumb a:hover { color: var(--brand); text-decoration: underline; }
.fx-breadcrumb [aria-current] { color: var(--ink); font-family: var(--font-mono); }

/* Empty state */
.fx-empty { text-align: center; padding: var(--space-7) var(--space-4); }
@media (max-width: 767.98px) { .fx-empty { padding: var(--space-5) var(--space-3); } .fx-empty-icon { width: var(--space-7); height: var(--space-7); font-size: 22px; margin-bottom: var(--space-3); } }
.fx-empty-icon { width: calc(var(--space-7) * 2); height: calc(var(--space-7) * 2); margin: 0 auto var(--space-4); border-radius: var(--radius-pill); display: grid; place-items: center; background: var(--surface-sunken); color: var(--ink-muted); font-size: 32px; }
.fx-empty p { max-width: calc(var(--space-7) * 8); margin: var(--space-2) auto 0; color: var(--ink-muted); }

/* Combobox: รายการค้นหาที่ JS สร้างเอง */
.fx-combo { position: relative; }
.fx-combo-menu { display: none; position: absolute; left: 0; right: 0; top: calc(100% + var(--space-1)); z-index: 1060; max-height: calc(var(--space-7) * 5); overflow-y: auto; margin: 0; padding: var(--space-1) 0; list-style: none; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-2); }
.fx-combo-item { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); cursor: pointer; font-size: 15px; line-height: 24px; }
.fx-combo-item:hover { background: var(--surface-sunken); }
.fx-combo-empty { padding: var(--space-3) var(--space-4); text-align: center; color: var(--ink-muted); font-size: 14px; }

/* Upload box (รูปภาพ/สแกน QR) */
.fx-upload { position: relative; display: grid; place-items: center; min-height: calc(var(--space-7) * 4); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--surface-sunken); color: var(--ink-muted); overflow: hidden; cursor: pointer; text-align: center; }
.fx-upload:hover { border-color: var(--brand); background: var(--brand-soft); }
.fx-upload-sm { min-height: calc(var(--space-7) * 3 + var(--space-4)); }
.fx-upload img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.fx-upload-overlay { position: relative; z-index: 2; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); font-size: 14px; line-height: 22px; font-weight: 500; }
.fx-upload-overlay i { font-size: 21px; }
.fx-upload-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 3; }
.fx-upload-input:focus-visible + img + .fx-upload-overlay, .fx-upload:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.fx-upload-tap { min-height: 0; padding: var(--space-5); gap: var(--space-2); }
/* มีรูปแล้ว (JS เอาคลาส danger-box ออก): ป้ายบนรูปต้องอ่านได้ */
.fx-upload:not(.danger-box):not(.fx-upload-tap) .fx-upload-overlay { background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow-1); }

/* หัวการ์ดที่เป็นปุ่มพับ/กาง (Bootstrap collapse) */
.fx-collapse-toggle { font: inherit; color: var(--ink); background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; }
.fx-collapse-toggle[aria-expanded="false"] { border-bottom-color: transparent; }
.fx-collapse-toggle[aria-expanded="true"] .fx-side-caret { transform: rotate(180deg); }
.fx-collapse-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* ตารางกรอกผล (inspection_form / calibration_form) เลื่อนแนวนอนบนจอแคบ */
.fx-table-check { min-width: calc(var(--space-7) * 11); }
.fx-table-cal { min-width: calc(var(--space-7) * 12); }
.fx-table-check td, .fx-table-cal td { padding-left: var(--space-2); padding-right: var(--space-2); }
/* ตารางที่ช่างกรอกบนมือถือ: จอแคบแต่ละแถวเป็นการ์ด (2 คอลัมน์, -3 = 3 คอลัมน์) ป้ายจาก data-label แทนหัวตาราง */
@media (max-width: 767.98px) {
  .fx-table.fx-table-stack { min-width: 0; } /* ชนะ min-width ของ .fx-table-wide/-cal/-check ที่ประกาศทีหลัง */
  .fx-table-stack thead { display: none; }
  .fx-table-stack, .fx-table-stack tbody { display: block; }
  .fx-table-stack tr { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2) var(--space-3); padding: var(--space-3); border-bottom: 1px solid var(--line); }
  .fx-table-stack-3 tr { grid-template-columns: repeat(3, 1fr); }
  .fx-table-stack td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  .fx-table-stack td .text-truncate, .fx-table-stack td .fx-truncate { white-space: normal; }
  .fx-table-stack td.text-center:not(.fx-stack-end) { text-align: left !important; }
  .fx-table-stack td[data-label]::before { content: attr(data-label); display: block; margin-bottom: var(--space-1); font-size: 13px; color: var(--ink-muted); }
  .fx-table-stack .fx-stack-full { grid-column: 1 / -1; }
  .fx-table-stack .fx-stack-end { text-align: right; }
}
.fx-input-narrow { max-width: calc(var(--space-7) * 4); }

/* Segmented control: radio (.btn-check ของ Bootstrap ซ่อน input) หรือปุ่ม .is-active
   ใช้ selector 2 ระดับให้ชนะ .btn ในหน้าที่ JS ยังหา label ด้วยคลาส .btn */
.fx-segment { position: relative; /* ให้ปุ่มวิทยุที่ซ่อน (btn-check, position:absolute) อยู่ในกล่องนี้ กดแล้วหน้าไม่เลื่อนหนี */ display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-sunken); }
.fx-segment .fx-segment-item {
  font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 38px; margin: 0 !important;
  padding: 0 var(--space-3); border: 1px solid transparent; border-radius: var(--radius-sm) !important; background: transparent;
  color: var(--ink-muted); font-size: 15px; line-height: 20px; font-weight: 500; cursor: pointer; white-space: nowrap; box-shadow: none;
}
.fx-segment .fx-segment-item:hover { color: var(--ink); background: var(--surface-raised); }
.fx-segment .btn-check:checked + .fx-segment-item, .fx-segment .fx-segment-item.is-active { background: var(--surface-raised); border-color: var(--line); color: var(--ink); box-shadow: var(--shadow-1); }
.fx-segment .btn-check:focus-visible + .fx-segment-item, .fx-segment .fx-segment-item:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Avatar ขนาดเล็ก (Kanban / ตาราง) */
.fx-avatar-sm { width: var(--space-5); height: var(--space-5); font-size: 13px; }

/* Kanban (ticket_tracking) */
.fx-kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(calc(var(--space-7) * 6), 1fr); gap: var(--space-4); overflow-x: auto; padding-bottom: var(--space-2); }
.fx-kanban-col { background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.fx-kanban-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding-bottom: var(--space-2); border-bottom: 1px solid var(--line); }
.fx-kanban-card { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-3); box-shadow: var(--shadow-1); }
.fx-kanban-card[role="button"] { cursor: pointer; }
.fx-kanban-card[role="button"]:hover { border-color: var(--line-strong); }
.fx-kanban-card[role="button"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fx-kanban-card.is-done { color: var(--ink-muted); }
.fx-kanban-title { margin: 0 0 var(--space-1); font-size: 16px; line-height: 26px; font-weight: 600; color: inherit; }
.fx-kanban-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); margin-top: var(--space-3); padding-top: var(--space-2); border-top: 1px solid var(--line); font-size: 14px; line-height: 22px; }
.fx-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Progress (README: แทร็ก brand-muted, มุม pill) */
.fx-progress { height: 6px; border-radius: var(--radius-pill); background: var(--brand-muted); overflow: hidden; }
.fx-progress-bar { height: 100%; border-radius: var(--radius-pill); background: var(--brand); }

/* Rating (ดาว) — JS สลับคลาส is-on */
.fx-rating { display: inline-flex; gap: var(--space-1); }
.fx-rating-star { font: inherit; background: none; border: 0; padding: var(--space-1); border-radius: var(--radius-sm); color: var(--line-strong); font-size: 28px; line-height: 1; cursor: pointer; }
.fx-rating-star.is-on { color: var(--warning); }
.fx-rating-star:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fx-stars { color: var(--warning); white-space: nowrap; }
.fx-stars .is-off { color: var(--line-strong); }

/* ลิงก์เอกสาร (ticket_history_customer) */
.fx-doc-link { font: inherit; display: flex; align-items: center; gap: var(--space-3); width: 100%; text-align: left; padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-raised); color: var(--ink); font-size: 15px; line-height: 24px; font-weight: 500; cursor: pointer; }
.fx-doc-link:hover { border-color: var(--line-strong); background: var(--surface-sunken); }
.fx-doc-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fx-doc-link > i { color: var(--ink-muted); width: 18px; text-align: center; flex: none; }
/* ปุ่มไฟล์มีสีตามความหมาย: is-pdf = ไฟล์ PDF (แดง), is-cal = Calibration/ใบรับรอง (น้ำเงิน), is-check = ใบตรวจเช็ค (เขียว) */
.fx-doc-link.is-pdf { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.fx-doc-link.is-cal { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.fx-doc-link.is-check { background: var(--success-soft); border-color: transparent; color: var(--success); }
.fx-doc-link.is-pdf > i, .fx-doc-link.is-cal > i, .fx-doc-link.is-check > i { color: inherit; }
.fx-doc-link.is-pdf, .fx-doc-link.is-cal, .fx-doc-link.is-check { text-decoration: none; }
.fx-doc-link.is-check:hover { border-color: currentColor; }
.fx-doc-link.is-pdf:hover, .fx-doc-link.is-cal:hover { border-color: currentColor; }
.fx-gallery-img { width: 100%; height: calc(var(--space-7) * 2 + var(--space-5)); object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--line); cursor: pointer; }
.fx-gallery-img:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fx-photo-empty { display: grid; place-items: center; gap: var(--space-1); height: calc(var(--space-7) * 3); border: 1px dashed var(--line-strong); border-radius: var(--radius-md); background: var(--surface-sunken); color: var(--ink-muted); font-size: 14px; }

/* แถวหัวกลุ่มในตาราง (เช่น เดือน) */
.fx-table tr.fx-table-group td { background: var(--surface-sunken); color: var(--ink-muted); font-size: 14px; line-height: 22px; font-weight: 600; padding-top: var(--space-2); padding-bottom: var(--space-2); }
.fx-table tfoot td, .fx-table tr.fx-table-total td { background: var(--surface-sunken); font-weight: 600; }

/* ตัวเลขงานค้าง (workload) */
.fx-count { min-width: calc(var(--space-7) + var(--space-3)); padding: var(--space-1) var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-sunken); text-align: center; flex: none; }
.fx-count strong { display: block; font-family: var(--font-mono); font-size: 20px; line-height: 26px; font-weight: 500; }
.fx-count span { font-size: 13px; line-height: 21px; color: var(--ink-muted); }

/* checkbox ของเบราว์เซอร์ + สีจาก token (ในตาราง) */
input.fx-checkbox-input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); cursor: pointer; }

/* ตารางกว้าง (เลื่อนแนวนอนใน fx-table-wrap) / ตัดข้อความยาวในเซลล์ */
.fx-table-wide { min-width: calc(var(--space-7) * 19); }
.fx-truncate { max-width: calc(var(--space-7) * 5); }
.fx-truncate-sm { max-width: calc(var(--space-7) * 2 + var(--space-5)); }
/* เลขหน้าปัจจุบันในแถบแบ่งหน้า (ไม่ใช้ primary เพราะ 1 ปุ่ม primary ต่อหน้าจอ) */
.fx-btn.fx-btn-current { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
.fx-thumb-lg { width: calc(var(--space-7) * 2); height: calc(var(--space-7) * 2); }
.fx-search-sm { width: min(100%, calc(var(--space-7) * 5)); }
.fx-table-parts { min-width: calc(var(--space-7) * 12); }
.fx-table-receive { min-width: calc(var(--space-7) * 12); }
/* แถบค้นหา/ตัวกรองบนตาราง (อยู่ใน fx-table-wrap) */
.fx-table-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
.fx-search-md { width: min(100%, calc(var(--space-7) * 8)); }
/* หน้าที่ JS หา select ด้วย .input-group (assets): กันกฎของ Bootstrap ที่ตัดมุม/ดึงขอบปุ่ม */
.fx-input-group.input-group { flex-wrap: nowrap; }
.fx-input-group.input-group > .fx-btn { margin-left: 0 !important; border-radius: var(--radius-md) !important; }
/* รูป QR ใน popup ขึ้นทะเบียนเครื่อง */
.fx-qr-img { width: calc(var(--space-7) * 3 + var(--space-4)); height: calc(var(--space-7) * 3 + var(--space-4)); padding: var(--space-2); background: var(--surface-raised); border-radius: var(--radius-md); }
/* การ์ดหมวดหมู่และไอคอนไฟล์ (asset_manuals) */
.fx-file-icon { display: block; margin-bottom: var(--space-3); font-size: 48px; color: var(--ink-muted); }
/* สถานะไฟล์ใน drop zone (asset_manuals): JS สลับคลาส is-selected */
.fx-upload.is-selected { border-color: var(--success); background: var(--success-soft); }

/* ตารางสูงจำกัด เลื่อนแนวตั้งในการ์ด (receive_summary) */
.fx-scroll-y { max-height: calc(var(--space-7) * 8); overflow-y: auto; }

/* การ์ดตัวเลือกแบบ radio (defective_parts) */
.fx-choice { display: flex; align-items: flex-start; gap: var(--space-3); margin: 0; padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-raised); cursor: pointer; }
.fx-choice:hover { border-color: var(--line-strong); }
.fx-choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.fx-choice:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.fx-choice input { width: 18px; height: 18px; margin: 3px 0 0; flex: none; accent-color: var(--brand); }
.fx-choice-icon { width: 18px; margin-top: 3px; text-align: center; color: var(--ink-muted); flex: none; }

/* การ์ดตัวเลือกแนวตั้ง (เลือกบทบาทใน user_management): ซ่อน radio ไว้แต่ยังเลือกด้วยคีย์บอร์ดได้ */
.fx-choice-stack { flex-direction: column; align-items: center; gap: var(--space-1); text-align: center; }
.fx-choice-stack input { position: absolute; opacity: 0; pointer-events: none; }
.fx-choice-stack .fx-choice-icon { width: auto; margin: 0 0 var(--space-1); font-size: 21px; }
.fx-choice { position: relative; }
/* แถวที่ถูกระงับ/ไม่ใช้งาน */
.fx-table tr.fx-row-muted td { color: var(--ink-muted); }

/* กล่องสรุปยอด (part_history) */
.fx-metric-box { padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-raised); text-align: center; height: 100%; }
.fx-metric-box.is-current { border-color: var(--brand); background: var(--brand-soft); }
.fx-metric-box .metric { margin: 0; }
/* แถวที่ JS เพิ่ม/ลบ (receive_parts): JS ตั้ง opacity/transform, CSS คุมเวลาเปลี่ยน */
.fx-row-anim, #receiveTableBody tr { transition: opacity .3s ease, transform .3s ease; }
/* รูปว่างขนาดเท่า fx-thumb ในตาราง */
.fx-photo-empty.fx-thumb { height: calc(var(--space-7) + var(--space-4)); }

/* Code block (แสดง JSON demo) */
.fx-code { margin: 0; padding: var(--space-4); background: var(--surface-sunken); color: var(--ink); font-family: var(--font-mono); font-size: 14px; line-height: 22px; white-space: pre-wrap; overflow-x: auto; }

/* Task card (my_tasks) */
.fx-task-meta { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); color: var(--ink-muted); font-size: 14px; line-height: 22px; }
.fx-task-actions { display: grid; gap: var(--space-2); }
.fx-task-actions-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.fx-tabs-scroll { scrollbar-width: none; }
.fx-tabs-scroll::-webkit-scrollbar { display: none; }

/* sticky column (tech_work_entry) */
@media (min-width: 992px) { .fx-sticky { position: sticky; top: 0; } }
.fx-thumb { width: calc(var(--space-7) + var(--space-4)); height: calc(var(--space-7) + var(--space-4)); object-fit: cover; border-radius: var(--radius-md); flex: none; }

/* ================= SweetAlert2(หน้าตาเท่านั้น; ห้ามส่ง confirmButtonColor ที่เป็นสีตายตัว) ================= */
.swal2-popup { font-family: var(--font-sans); background: var(--surface-raised); color: var(--ink); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); }
.swal2-title { color: var(--ink); font-size: 20px; line-height: 28px; font-weight: 600; }
.swal2-html-container { color: var(--ink-muted); font-size: 16px; line-height: 26px; }
.swal2-actions { gap: var(--space-2); }
.swal2-styled { margin: 0; min-height: 38px; padding: 0 var(--space-4); border-radius: var(--radius-md); font-size: 15px; line-height: 24px; font-weight: 500; box-shadow: none; }
.swal2-styled:focus-visible { box-shadow: none; outline: 2px solid var(--focus); outline-offset: 2px; }
.swal2-styled.swal2-confirm { background-color: var(--brand); color: var(--on-brand); }
.swal2-styled.swal2-confirm:hover { background-image: none; background-color: var(--brand-strong); }
.swal2-styled.swal2-cancel, .swal2-styled.swal2-deny { background-color: var(--surface-raised); color: var(--ink); border: 1px solid var(--line-strong); }
.swal2-styled.swal2-cancel:hover, .swal2-styled.swal2-deny:hover { background-image: none; background-color: var(--surface-sunken); }
/* ปุ่มยืนยันการกระทำที่ย้อนกลับไม่ได้: customClass: { confirmButton: 'fx-swal-danger' } */
.swal2-styled.swal2-confirm.fx-swal-danger { background-color: var(--danger); color: var(--on-danger); }
.swal2-icon.swal2-success { border-color: var(--success); color: var(--success); }
.swal2-icon.swal2-success .swal2-success-ring { border-color: var(--success-soft); }
.swal2-icon.swal2-success [class^="swal2-success-line"] { background-color: var(--success); }
.swal2-icon.swal2-warning { border-color: var(--warning); color: var(--warning); }
.swal2-icon.swal2-error { border-color: var(--danger); color: var(--danger); }
.swal2-icon.swal2-error [class^="swal2-x-mark-line"] { background-color: var(--danger); }
.swal2-icon.swal2-info, .swal2-icon.swal2-question { border-color: var(--brand); color: var(--brand); }
.swal2-loader { border-color: var(--brand) transparent var(--brand) transparent; }
.swal2-timer-progress-bar { background: var(--brand-muted); }
/* Lightbox ดูรูป (ticket_history_customer) */
.swal2-container.fx-swal-lightbox.swal2-backdrop-show { background: color-mix(in srgb, var(--sidebar) 85%, transparent); }
.fx-swal-lightbox .swal2-image { margin: 0; border-radius: var(--radius-lg); }
.swal2-close.fx-swal-close { margin: var(--space-2); border-radius: var(--radius-pill); background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow-2); }
.swal2-close.fx-swal-close:focus-visible { box-shadow: none; outline: 2px solid var(--focus); outline-offset: 2px; }

/* dl แบบหัวข้ออยู่บนค่า (หน้าลูกค้า) */
.fx-dl-stack { grid-template-columns: 1fr; gap: 0; }
.fx-dl-stack dt { font-size: 14px; line-height: 22px; }
.fx-dl-stack dd { margin-bottom: var(--space-3); font-weight: 500; }
.fx-dl-stack dd:last-child { margin-bottom: 0; }

/* ปุ่มที่หน้าตาเป็นลิงก์ (เลข GR ใน receive_summary เปิด modal) */
.fx-link-btn { padding: 0; border: 0; background: none; color: var(--brand); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; min-height: 24px; }
.fx-link-btn:hover { color: var(--brand-strong); }
.fx-link-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }

/* หน้า error 403/404 (templates/errors/error.php) */
body.fx-error-page { overflow-y: auto; min-height: 100vh; margin: 0; display: grid; place-items: center; padding: var(--space-4); background: var(--surface); }

/* ================= หน้า public เครื่อง (templates/public/machine.php) ================= */
body.fx-public { overflow-y: auto; min-height: 100vh; margin: 0; background: var(--surface-sunken); } /* body ทั่วไปตั้ง overflow: hidden */
.fx-public-shell { max-width: 560px; margin: 0 auto; padding: var(--space-4); display: grid; gap: var(--space-3); }
@media (min-width: 768px) { .fx-public-shell { padding: var(--space-7) var(--space-4); } }
.fx-public-brand { margin: 0; font-weight: 600; color: var(--brand); }
.fx-public-shell.fx-public-wide { max-width: 1040px; } /* หน้าข้อมูลเครื่องแบบ 2 คอลัมน์ */
.fx-public-shell > .justify-self-start { justify-self: start; }
/* ป้ายกลุ่มรูปก่อนทำ/หลังทำ ขึ้นบรรทัดใหม่ทุกกลุ่ม */
.fx-photo-tag { flex-basis: 100%; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--ink-muted); }
.fx-public-more > summary { min-height: 44px; display: flex; align-items: center; color: var(--brand); font-weight: 500; cursor: pointer; }

/* ================= สติกเกอร์ QR (assets.php) =================
   ตอนพิมพ์ซ่อนทุกอย่างใต้ body ยกเว้น #qrPrint (JS ย้ายมาเป็นลูกตรงของ body) */
.fx-sticker { text-align: center; padding: var(--space-3); }
.fx-sticker-qr { display: inline-block; padding: var(--space-2); background: #fff; }
.fx-sticker-pec { font-family: var(--font-mono); font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: 2px; margin: var(--space-2) 0 0; }
.fx-sticker p { margin: 0; }
#qrPrint { display: none; }
@media print {
  body.fx-printing-sticker > :not(#qrPrint) { display: none !important; }
  body.fx-printing-sticker #qrPrint { display: block; color: #000; }
}

/* ================= สีที่สื่อความหมาย ================= */
/* ปุ่มยืนยัน/อนุมัติ (สีเขียว) คู่กับ fx-btn-danger ของ design system */
.fx-btn-success { background: var(--success); border-color: var(--success); color: var(--surface-raised); }
.fx-btn-success:hover { filter: brightness(0.92); background: var(--success); }

/* ไอคอนหัวข้อการ์ด/หน้าต่าง ใช้สีแบรนด์แทนสีจาง */
.fx-card-title > i.fx-muted, .heading-3 > i.fx-muted, .modal-title > i.fx-muted, .fx-section-title > i.fx-muted { color: var(--brand); }

/* ไอคอนในปุ่มธรรมดา: ลบ/ยกเลิก = แดง, บันทึก/ยืนยัน = เขียว, แก้ไข = เหลือง, เพิ่ม/ดู/พิมพ์ = น้ำเงิน */
.fx-btn:not(.fx-btn-primary):not(.fx-btn-danger):not(.fx-btn-success) > i:is(.fa-trash, .fa-trash-alt, .fa-trash-can, .fa-times, .fa-times-circle, .fa-ban, .fa-xmark) { color: var(--danger); }
.fx-btn:not(.fx-btn-primary):not(.fx-btn-danger):not(.fx-btn-success) > i:is(.fa-check, .fa-check-circle, .fa-save, .fa-paper-plane) { color: var(--success); }
.fx-btn:not(.fx-btn-primary):not(.fx-btn-danger):not(.fx-btn-success) > i:is(.fa-pen, .fa-edit, .fa-pen-to-square, .fa-undo-alt) { color: var(--warning); }
.fx-btn:not(.fx-btn-primary):not(.fx-btn-danger):not(.fx-btn-success) > i:is(.fa-plus, .fa-eye, .fa-print, .fa-download, .fa-file-pdf, .fa-qrcode) { color: var(--brand); }

/* ไอคอนเมนูแถบข้าง: สีเดียวทั้งแถบ (ฟ้าอ่อนของธีม) เมนูที่เลือกอยู่เป็นสีขาว */
.fx-side-item > i:not(.fx-side-caret) { color: var(--side-icon); }
.fx-side-item.active > i, .fx-side-item[aria-current="page"] > i { color: var(--on-sidebar); }
a.fx-segment-item { text-decoration: none; white-space: normal; text-align: center; max-width: 100%; }
.fx-segment { max-width: 100%; }
/* ไอคอนชนิดไฟล์ในแฟ้มเอกสาร */
.fx-file-icon.fa-file-pdf { color: var(--danger); }
.fx-file-icon.fa-file-video { color: var(--brand); }
.fx-file-icon.fa-file-image { color: var(--success); }
@media (max-width: 767.98px) {
  /* ช่องปุ่มจัดการ (คอลัมน์สุดท้าย) กินเต็มแถวและชิดขวา ให้กดง่าย */
  .fx-table-stack td:last-child:has(button, a.fx-btn) { grid-column: 1 / -1; text-align: right !important; }
  .fx-table-stack td:last-child:has(button, a.fx-btn)::before { display: none !important; }
  /* แถวว่าง (colspan) ไม่ต้องแบ่งช่อง */
  .fx-table-stack td[colspan], .fx-table-stack td.text-center[colspan] { grid-column: 1 / -1; text-align: center !important; }
}

/* ================= UX: ใช้งานบนมือถือ ================= */
/* ไอคอนในช่องค้นหา/ลูกศร select อยู่กึ่งกลางเสมอ ไม่ว่าช่องจะสูงเท่าไร */
.fx-input-icon, .fx-select-caret { top: 50%; transform: translateY(-50%); }

@media (max-width: 767.98px) {
  /* เป้ากดอย่างน้อย 44px (ช่างใช้นิ้ว/สวมถุงมือ) */
  .fx-btn { height: 44px; }
  .fx-btn-sm { height: 40px; min-width: 40px; }
  .fx-btn-icon { width: 44px; }
  .fx-btn-sm.fx-btn-icon { width: 40px; }
  .fx-input:not(textarea) { height: 44px; }
  .fx-input-sm:not(textarea) { height: 40px; }
  .fx-segment .fx-segment-item { min-height: 44px; }
  .fx-segment-stack { display: grid; grid-template-columns: 1fr; }
  .fx-segment-stack .fx-segment-item { justify-content: flex-start; }
  /* iPhone ซูมหน้าเมื่อช่องกรอกตัวอักษรเล็กกว่า 16px */
  .fx-input, .fx-input-sm, select, textarea { font-size: 16px; }

  /* การ์ดตัวเลขสรุป: 2 ใบต่อแถว ให้เห็นภาพรวมโดยไม่ต้องเลื่อนยาว */
  .row > :has(> .fx-stat) { width: 50%; }
  .fx-stat { padding: var(--space-3); }
  .fx-stat-value { font-size: 24px; line-height: 32px; }
}
/* ตัวเลือกที่เลือกอยู่ต้องเห็นชัด ไม่ใช่แค่พื้นขาว */
.fx-segment .btn-check:checked + .fx-segment-item, .fx-segment .fx-segment-item.is-active { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); color: var(--brand); }
/* ปุ่มที่กำลังส่งข้อมูล: แสดงวงหมุนให้รู้ว่าระบบกำลังทำงาน */
.fx-btn[aria-busy="true"] { position: relative; color: transparent !important; }
.fx-btn[aria-busy="true"]::after { content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid var(--ink-disabled); border-top-color: transparent; border-radius: 50%; animation: fx-spin .7s linear infinite; }
@keyframes fx-spin { to { transform: rotate(360deg); } }
/* ช่องติ๊กของ design system: ขนาดไอคอนให้พอดีกล่อง 18px */
.fx-check-box > i { font-size: 11px; }

@media (max-width: 767.98px) {
  /* สต็อกอะไหล่บนมือถือ: รูปเล็กซ้าย | รหัส-ชื่อ | ยอดคงเหลือขวา แล้วปุ่มเป็นแถวล่าง */
  .fx-parts-list tr { grid-template-columns: 56px minmax(0, 1fr) auto; align-items: start; }
  .fx-parts-list td[data-label=""]::before { display: none; }
  .fx-parts-list .fx-thumb { width: 56px; height: 56px; }
  .fx-parts-list td:last-child > div { justify-content: flex-end !important; flex-wrap: wrap; }
  .fx-parts-list .fx-truncate { white-space: normal; }
}
@media (max-width: 767.98px) {
  /* แท็บงานของช่าง: 3 แท็บกว้างเท่ากันและเห็นครบโดยไม่ต้องปัด */
  #taskTabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow-x: visible; }
  #taskTabs .fx-tab { white-space: normal; justify-content: center; text-align: center; flex-wrap: wrap; gap: var(--space-1); padding-left: var(--space-1); padding-right: var(--space-1); }
}

/* ================= Calibration Report (calibration_form) ================= */
/* ค่าที่ระบบเติมให้ (แก้ไม่ได้) แสดงเป็นกล่องเหมือนช่องกรอก แต่พื้นเทา */
.fx-input-static { display: flex; flex-wrap: wrap; gap: 0 var(--space-1); align-items: center; min-height: 40px; height: auto; padding: var(--space-2) var(--space-3); background: var(--surface-sunken); border-color: var(--line); color: var(--ink); overflow-wrap: anywhere; }
.fx-input-multiline { align-items: flex-start; }
/* ช่องแสดงผลต้องสูงตามข้อความ: ชนะกฎ .fx-input:not(textarea) { height: 44px } บนมือถือ ที่ทำให้ที่อยู่หลายบรรทัดล้นกรอบ */
.fx-input.fx-input-static { height: auto; }
.fx-cal-group { padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.fx-cal-standard { padding-bottom: var(--space-3); border-bottom: 1px dashed var(--line); }
.fx-check-opt { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; cursor: pointer; }
.fx-check-opt input { width: 22px; height: 22px; }
@media (max-width: 767.98px) { .fx-input-static { min-height: 44px; } }
/* ลูกของ grid กว้างตามเนื้อหาที่ยาวที่สุดเป็นค่าเริ่มต้น (เช่น select ที่ตัวเลือกยาว) ทำให้ล้นจอมือถือ */
.d-grid > * { min-width: 0; }
select.fx-input { max-width: 100%; text-overflow: ellipsis; }
/* ปุ่มข้อความยาว: ให้ขึ้นบรรทัดใหม่ได้แทนการล้นจอ */
.fx-btn.fx-btn-wrap { white-space: normal; height: auto; min-height: 38px; padding-top: var(--space-2); padding-bottom: var(--space-2); text-align: center; }
@media (max-width: 767.98px) { .fx-btn.fx-btn-wrap { min-height: 44px; } }

/* ================= ปฏิทินงาน: แผงพิกัดทีมช่าง / งานพรุ่งนี้ ================= */
.min-w-0 { min-width: 0; }
.fx-note.fx-note-sm { padding: var(--space-2) var(--space-3); font-size: 14px; line-height: 22px; }
.fx-cal-event-text { overflow: hidden; text-overflow: ellipsis; }
.fx-cal-cell.is-today .fx-cal-date span { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 4px; border-radius: var(--radius-pill); background: var(--brand); color: var(--on-brand); }
.fx-cal-event:not([class*="fx-person-"]) { border-left: 3px solid var(--line-strong); }
a.fx-cal-event, a.fx-cal-event:hover { text-decoration: none; }

/* ================= กรอบข้อมูลมีสี (ทุกหน้า) =================
   การ์ด/ตาราง: แถบสีด้านบน + หัวการ์ดพื้นอ่อน แยกจากพื้นหลังได้ทันที
   ใส่ fx-card-danger / -warning / -success ให้การ์ดที่ต้องสื่อความหมาย (ค่าเริ่มต้น = สีแบรนด์) */
.fx-card, .fx-table-wrap { --accent: var(--brand); --accent-soft: var(--brand-soft); border-top: 4px solid var(--accent); }
.fx-card-danger { --accent: var(--danger); --accent-soft: var(--danger-soft); }
.fx-card-warning { --accent: var(--warning); --accent-soft: var(--warning-soft); }
.fx-card-success { --accent: var(--success); --accent-soft: var(--success-soft); }
.fx-card-head, .fx-table-toolbar { background: var(--accent-soft); }
.fx-card-head .fx-card-title { color: var(--accent); }
.fx-card .fx-table th, .fx-table-wrap .fx-table th { color: var(--ink); font-weight: 600; }

/* ตัวเลขสรุป: แดง = เกินกำหนด, เหลือง = รอดำเนินการ, เขียว = ไม่มีค้าง, น้ำเงิน = ข้อมูลทั่วไป */
.fx-stat { --accent: var(--brand); --accent-soft: var(--brand-soft); border-left: 5px solid var(--accent); background: linear-gradient(90deg, var(--accent-soft), var(--surface-raised) 70%); }
.fx-stat:has(.fx-stat-value.fx-tone-warning) { --accent: var(--warning); --accent-soft: var(--warning-soft); }
.fx-stat:has(.fx-stat-value.fx-tone-success) { --accent: var(--success); --accent-soft: var(--success-soft); }
.fx-stat:has(.fx-stat-value.fx-tone-danger, .fx-stat-delta.fx-tone-danger) { --accent: var(--danger); --accent-soft: var(--danger-soft); }
.fx-stat-label > i { color: var(--accent); }

/* ================= เลือกข้อมูลที่แสดง (assets.php) ================= */
.fx-menu.fx-col-picker { width: min(calc(var(--space-7) * 9), calc(100vw - var(--space-6))); padding: 0; max-height: 70vh; overflow-y: auto; } /* .fx-menu.dropdown-menu ตั้ง overflow: hidden จึงต้องเจาะจงเท่ากัน */
.fx-col-picker fieldset { margin: 0; padding: 0; border: 0; }
.fx-col-picker legend { float: none; width: 100%; margin: 0; }
.fx-col-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-1) var(--space-3); padding: var(--space-2) var(--space-4) var(--space-3); }
.fx-col-grid .fx-check { min-height: 36px; }
.fx-col-actions { position: sticky; bottom: 0; display: flex; gap: var(--space-2); justify-content: flex-end; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); background: var(--surface-raised); }
#machineTable td { vertical-align: top; }
.fx-col-notes { display: block; min-width: 180px; max-width: 320px; white-space: normal; }

/* ================= แบ่งหน้าตาราง (assets/js/pager.js) ================= */
.fx-table tr.fx-pager-off { display: none !important; }
.fx-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-2) var(--space-4); margin-left: auto; }
.fx-table-foot-pager { justify-content: flex-end; }
.fx-pager-size { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; white-space: nowrap; }
.fx-pager-size .fx-select { width: auto; min-height: 36px; padding-top: 4px; padding-bottom: 4px; padding-right: var(--space-6); }
.fx-pager-info { white-space: nowrap; font-variant-numeric: tabular-nums; }
.fx-pager-nav { display: inline-flex; align-items: center; gap: var(--space-1); }
.fx-pager-btn { min-width: 36px; height: 36px; padding: 0 var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-raised); color: var(--ink); font: inherit; font-variant-numeric: tabular-nums; cursor: pointer; }
.fx-pager-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.fx-pager-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fx-pager-btn.is-current { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; cursor: default; }
.fx-pager-btn:disabled:not(.is-current) { opacity: .45; cursor: default; }
.fx-pager-gap { padding: 0 var(--space-1); color: var(--ink-muted); }
@media (max-width: 575.98px) {
  .fx-table-foot:has(.fx-pager) { flex-direction: column; align-items: stretch; }
  .fx-pager { justify-content: space-between; margin-left: 0; }
  .fx-pager-nav { width: 100%; justify-content: center; }
}

/* ================= แถบตัวกรองแถวเดียว (assets.php) =================
   จอกว้าง: ทุกตัวอยู่แถวเดียว ช่องค้นหายืดได้ ตัวเลือกกว้างเท่ากัน; จอแคบ: ตัดขึ้นบรรทัดใหม่ ไม่ตัดข้อความทิ้ง */
.fx-filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); width: 100%; }
.fx-filter-bar > .fx-filter-search { flex: 2 1 150px; min-width: 0; }
.fx-filter-bar > .fx-select-wrap { flex: 1 1 104px; min-width: 0; }
.fx-filter-bar > .fx-select-wrap .fx-select { width: 100%; text-overflow: ellipsis; }
.fx-filter-bar > .fx-check, .fx-filter-bar > .fx-btn, .fx-filter-bar > .dropdown { flex: none; }
.fx-filter-search .fx-input { padding-right: 44px; }
.fx-filter-search input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
.fx-filter-go { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--brand); cursor: pointer; }
.fx-filter-go:hover { background: var(--brand-soft); }
.fx-filter-go:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
/* ตัวกรองที่เลือกค่าอยู่: กรอบ/พื้นสีแบรนด์ เห็นทันทีว่ากรองอะไรอยู่ */
.fx-select.is-active { border-color: var(--brand); background-color: var(--brand-soft); color: var(--brand-strong); font-weight: 500; }
.fx-select-wrap:has(.fx-select.is-active) .fx-select-caret { color: var(--brand); }
@media (max-width: 767.98px) {
  .fx-filter-bar > .fx-filter-search { flex-basis: 100%; }
  .fx-filter-bar > .fx-select-wrap { flex-basis: calc(50% - var(--space-1)); }
}
/* ปุ่มตัวเลือกที่มีการตั้งค่าอยู่ (เช่น รวมเครื่องที่เลิกใช้) */
.fx-btn.fx-btn-active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
.fx-filter-clear { color: var(--danger); }
.fx-col-picker legend.fx-menu-head { border-top: 1px solid var(--line); }
.fx-col-picker fieldset:first-child legend.fx-menu-head { border-top: 0; }
.fx-filter-bar > .fx-filter-zone { flex: 0 1 160px; }

/* ================= ใบงานในรายการ: PEC เด่นก่อน + สีตามความสำคัญ ================= */
.fx-pec { font-family: var(--font-mono); font-weight: 600; color: var(--brand-strong); background: var(--brand-soft); padding: 1px 6px; border-radius: var(--radius-sm); white-space: nowrap; }
.fx-wo { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); white-space: nowrap; }
.fx-prio-high { --accent: var(--danger); --accent-soft: var(--danger-soft); }
.fx-prio-medium { --accent: var(--warning); --accent-soft: var(--warning-soft); }
.fx-prio-low { --accent: var(--success); --accent-soft: var(--success-soft); }
.fx-card[class*="fx-prio-"] { border-left: 5px solid var(--accent); }
.fx-kanban-card[class*="fx-prio-"] { border-left: 4px solid var(--accent); }
tr[class*="fx-prio-"] > td:first-child { box-shadow: inset 4px 0 0 var(--accent); }

/* เอกสาร 3 แบบในหน้าบันทึกงาน (กรอก + พิมพ์ PDF) */
.fx-doc-forms { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-md); }
.fx-doc-forms li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); padding: var(--space-3); }
.fx-doc-forms li + li { border-top: 1px solid var(--line); }
.fx-doc-forms-title { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
a.fx-pec { text-decoration: none; }
a.fx-pec:hover, a.fx-pec:focus-visible { background: var(--brand); color: var(--on-brand); text-decoration: none; }
a.fx-wo { text-decoration: none; }
a.fx-wo:hover { text-decoration: underline; }

/* ================= เครื่องมือวัด (assets_measuring): สีช่องวันหมดอายุตามสถานะใบรับรอง ================= */
.fx-cert-cell.is-ok { background: var(--success-soft); color: var(--success); }
.fx-cert-cell.is-expiring { background: var(--warning-soft); color: var(--warning); }
.fx-cert-cell.is-expired { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.fx-cert-cell.is-none { background: var(--neutral-soft); color: var(--ink-muted); }
.fx-cert-cell .fx-input { min-width: 140px; color: inherit; font-weight: inherit; }
/* แถบความหมายของสี เหนือตาราง แสดงตลอด (ไม่ต้องกดดู) */
.fx-cert-legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--line); font-size: 14px; }
.fx-cert-legend ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.fx-cert-legend li { display: inline-flex; align-items: center; gap: var(--space-1); }
.fx-cert-legend-title { font-weight: 500; }
.fx-cert-swatch { display: inline-block; width: 28px; height: 18px; border-radius: var(--radius-sm); border: 1px solid currentColor; }
.fx-cert-no { min-width: 130px; }
