/* =====================================================================
 * assets/css/app.css — หน้าตาทั้งระบบ "ดินดี"
 * ---------------------------------------------------------------------
 * สารบัญ
 *   1. ตัวแปรสี/ฟอนต์ (Design tokens)       9.  ตาราง + DataTables + ตารางเป็นการ์ดบนมือถือ
 *   2. พื้นฐาน + ทับค่า Bootstrap            10. Modal (มือถือเป็น bottom sheet)
 *   3. Sidebar                              11. ฟอร์ม + Tom Select
 *   4. Topbar + เนื้อหา                     12. หน้ารายละเอียดตัวอย่าง (ไทม์ไลน์ แถบระดับ)
 *   5. Mobile bottom nav + ปุ่ม +           13. หน้าเข้าสู่ระบบ/สมัคร
 *   6. การ์ด + KPI                          14. SweetAlert2
 *   7. ป้ายสถานะ/ระดับ                      15. อนิเมชัน + skeleton
 *   8. ปุ่ม                                 16. ส่วนเล็ก ๆ อื่น ๆ + พิมพ์
 * จุดตัดจอ: < 576 มือถือ · < 768 แท็บเล็ตแนวตั้ง · < 992 ซ่อน sidebar
 * ===================================================================== */

/* 1. ตัวแปรสี/ฟอนต์ ---------------------------------------------------
 * สีอิงงานดินและพืช: เขียวเข้ม (เมนู) · เขียวใบไม้ (ปุ่มหลัก) · ทราย (พื้น)
 * ระดับผลตรวจใช้ 3 สีตามเอกสารลูกค้า: ต่ำ = ดินเผา · ปานกลาง = ทอง · สูง = เขียว */
:root {
  --forest: #2F3E2C;
  --forest-2: #1F2A1C;
  --leaf: #4F7A3A;
  --leaf-2: #6E9A4F;
  --leaf-soft: #E5EEDB;
  --sand: #F3ECDF;
  --cream: #FBF8F1;
  --gold: #B8862B;
  --gold-soft: #F6EBD3;
  --clay: #C0603F;
  --clay-soft: #F7E1D8;
  --sky: #3E7C93;
  --sky-soft: #DCEBF0;
  --green: #2E7D4F;
  --green-soft: #DCEFE3;
  --ink: #2B2A26;
  --muted: #6E6858;
  --line: #E4DACB;
  --white: #fff;

  --font-body: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Noto Serif Thai', 'IBM Plex Sans Thai', serif;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(47, 62, 44, .06), 0 8px 24px -12px rgba(47, 62, 44, .18);
  --shadow-lg: 0 24px 48px -20px rgba(31, 42, 28, .35);
  --sidebar-w: 268px;
  --topbar-h: 68px;
  --mnav-h: 66px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  /* ทับสีหลักของ Bootstrap ให้เป็นโทนเดียวกับระบบ */
  --bs-primary: var(--leaf);
  --bs-primary-rgb: 79, 122, 58;
  --bs-body-font-family: var(--font-body);
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--sand);
  --bs-border-color: var(--line);
  --bs-link-color: var(--leaf);
  --bs-link-color-rgb: 79, 122, 58;
  --bs-link-hover-color: var(--forest);
  --bs-secondary-color: var(--muted);
  --bs-border-radius: 10px;
  --bs-focus-ring-color: rgba(79, 122, 58, .25);
}

/* 2. พื้นฐาน ---------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); color: var(--ink); background: var(--sand); }
h1, h2, h3, h4, h5, .font-head { font-family: var(--font-head); font-weight: 600; letter-spacing: -.01em; }
a { text-decoration: none; }
.text-muted { color: var(--muted) !important; }
.text-leaf { color: var(--leaf) !important; }
.text-clay { color: var(--clay) !important; }
.text-gold { color: var(--gold) !important; }
.bg-cream { background: var(--cream) !important; }
.small-caps { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
::selection { background: var(--leaf-soft); }
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: var(--leaf-2);
  box-shadow: 0 0 0 .25rem rgba(79, 122, 58, .18);
}
.form-check-input:checked { background-color: var(--leaf); border-color: var(--leaf); }

/* 3. Sidebar ---------------------------------------------------------- */
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1045;
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(110, 154, 79, .25), transparent 60%),
    linear-gradient(180deg, var(--forest) 0%, var(--forest-2) 100%);
  color: #E9E4D6;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 22px 20px 14px; }
.brand-link { display: flex; align-items: center; gap: 12px; color: #fff; }
.brand-link strong { display: block; font-family: var(--font-head); font-size: 1.35rem; line-height: 1.1; }
.brand-link small { display: block; font-size: .74rem; color: #BFC8B2; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 14px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-group-title { font-size: .7rem; font-weight: 600; letter-spacing: .1em; color: #93A086; padding: 16px 12px 6px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin: 2px 0; border-radius: 12px;
  color: #DDE3D3; font-size: .95rem; transition: background .2s, color .2s, transform .2s var(--ease);
}
.nav-item i { font-size: 1.1rem; width: 22px; text-align: center; opacity: .9; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(2px); }
.nav-item.active { background: rgba(251, 248, 241, .12); color: #fff; font-weight: 500; }
.nav-item.active::before {
  content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--gold);
}
.nav-item.active i { color: #F2CF7F; }
.sidebar-user {
  display: flex; align-items: center; gap: 12px; margin: 10px 14px 16px; padding: 10px 12px;
  border-radius: 14px; background: rgba(0, 0, 0, .18); color: #fff;
}
.sidebar-user:hover { background: rgba(0, 0, 0, .28); color: #fff; }
.sidebar-user strong { display: block; font-size: .9rem; font-weight: 500; line-height: 1.2; }
.sidebar-user small { color: #BFC8B2; font-size: .75rem; }

.avatar { border-radius: 50%; object-fit: cover; flex: none; }
.avatar-text {
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, var(--leaf-2), var(--gold));
}

/* จอเล็ก: offcanvas-lg ของ Bootstrap ทำงาน — แต่งพื้นหลังให้เหมือนเดิม */
@media (max-width: 991.98px) {
  .app-sidebar.offcanvas-lg { width: min(86vw, 300px); border-right: 0; }
  .offcanvas-backdrop.show { opacity: .45; }
}

/* 4. Topbar + เนื้อหา ------------------------------------------------- */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar {
  position: sticky; top: 0; z-index: 1020; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: rgba(243, 236, 223, .82); backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid rgba(228, 218, 203, .7);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 1.3rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.role-chip { display: inline-flex;
  align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px;
  background: var(--leaf-soft); color: var(--forest); font-size: .8rem; font-weight: 500;
}
.btn-user { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 99px; border: 1px solid var(--line); background: var(--cream); }
.btn-user:hover, .btn-user[aria-expanded="true"] { background: #fff; border-color: #d6cab6; }
.btn-icon { width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; color: var(--forest); border: 0; }
.btn-icon:hover { background: rgba(47, 62, 44, .08); }
.dropdown-menu { border: 1px solid var(--line); border-radius: 14px; padding: 6px; background: var(--cream); }
.dropdown-item { border-radius: 10px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; }
.dropdown-item:active { background: var(--leaf); }
.app-content { flex: 1; padding: 26px 28px 32px; max-width: 1480px; width: 100%; }
.app-footer { padding: 16px 28px 24px; color: var(--muted); font-size: .8rem; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h2 { font-size: 1.5rem; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 991.98px) {
  .app-main { margin-left: 0; padding-bottom: calc(var(--mnav-h) + env(safe-area-inset-bottom)); }
  .app-topbar { padding: 0 12px; height: 60px; }
  .topbar-title h1 { font-size: 1.12rem; }
  .app-content { padding: 18px 14px 24px; }
  .app-footer { padding: 8px 16px 20px; text-align: center; }
}
@media (max-width: 575.98px) {
  .page-head h2 { font-size: 1.25rem; }
  .page-actions { width: 100%; }
  .page-actions > .btn { flex: 1; }
}

/* 5. Mobile bottom nav ------------------------------------------------ */
.mobile-nav { display: none; }
@media (max-width: 991.98px) {
  .mobile-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    display: flex; align-items: stretch; justify-content: space-around;
    height: calc(var(--mnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(251, 248, 241, .96); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); box-shadow: 0 -8px 24px -16px rgba(31, 42, 28, .35);
  }
  .mobile-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); font-size: .68rem; border: 0; background: none; padding: 6px 2px; position: relative;
    min-width: 0; white-space: nowrap;
  }
  .mobile-nav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .mobile-nav-item i { font-size: 1.3rem; transition: transform .25s var(--ease); }
  .mobile-nav-item.active { color: var(--leaf); font-weight: 600; }
  .mobile-nav-item.active i { transform: translateY(-2px); }
  .mobile-nav-item.active::after {
    content: ''; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--leaf);
  }
  .mobile-fab {
    flex: none; width: 58px; height: 58px; margin-top: -22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 1.6rem; color: #fff;
    background: linear-gradient(145deg, var(--leaf-2), var(--leaf) 55%, var(--forest));
    box-shadow: 0 10px 20px -6px rgba(79, 122, 58, .7), 0 0 0 5px var(--sand);
    transition: transform .2s var(--ease);
  }
  .mobile-fab:active { transform: scale(.92); }
}

/* 6. การ์ด + KPI ------------------------------------------------------ */
.card-soft {
  background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-soft > .card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 1.05rem; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-head h3 i { color: var(--leaf); }
.card-soft > .card-body { padding: 18px 20px; }
@media (max-width: 575.98px) {
  .card-soft > .card-head, .card-soft > .card-body { padding-left: 14px; padding-right: 14px; }
}

.kpi {
  position: relative; overflow: hidden; display: flex; gap: 14px; align-items: center;
  padding: 18px; height: 100%; color: var(--ink);
  transition: transform .25s var(--ease), box-shadow .25s;
}
a.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); color: var(--ink); }
.kpi-icon {
  flex: none; width: 52px; height: 52px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-size: 1.45rem; background: var(--tone-soft, var(--leaf-soft)); color: var(--tone, var(--leaf));
}
.kpi-value { font-family: var(--font-head); font-size: 1.85rem; font-weight: 700; line-height: 1; }
.kpi-label { color: var(--muted); font-size: .85rem; margin-top: 4px; }
@media (max-width: 575.98px) {
  .kpi { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
  .kpi-icon { width: 40px; height: 40px; border-radius: 12px; font-size: 1.15rem; }
  .kpi-value { font-size: 1.55rem; }
  .kpi-label { font-size: .78rem; }
}
.kpi::after {
  content: ''; position: absolute; right: -30px; bottom: -30px; width: 110px; height: 110px; border-radius: 50%;
  background: var(--tone-soft, var(--leaf-soft)); opacity: .55;
}
.tone-sand  { --tone: #8C6A3F; --tone-soft: #EFE3CC; }
.tone-sky   { --tone: var(--sky); --tone-soft: var(--sky-soft); }
.tone-leaf  { --tone: var(--leaf); --tone-soft: var(--leaf-soft); }
.tone-gold  { --tone: var(--gold); --tone-soft: var(--gold-soft); }
.tone-green { --tone: var(--green); --tone-soft: var(--green-soft); }
.tone-clay  { --tone: var(--clay); --tone-soft: var(--clay-soft); }
.tone-gray  { --tone: #6c6c66; --tone-soft: #ECEAE4; }

.hero-card {
  position: relative; overflow: hidden; border-radius: var(--radius); padding: 24px 26px; color: #fff;
  background:
    radial-gradient(80% 120% at 100% 0%, rgba(184, 134, 43, .45), transparent 55%),
    linear-gradient(135deg, var(--leaf) 0%, var(--forest) 70%);
  box-shadow: var(--shadow-lg);
}
.hero-card h2 { font-size: 1.5rem; margin-bottom: 6px; }
.hero-card p { color: #E3EBD8; margin: 0; }
.hero-card .hero-deco { position: absolute; right: 16px; bottom: -18px; font-size: 7rem; opacity: .14; }
.hero-card .btn-light { color: var(--forest); font-weight: 500; }

/* 7. ป้ายสถานะ/ระดับ -------------------------------------------------- */
.status {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 4px 10px; border-radius: 99px; font-size: .8rem; font-weight: 500; line-height: 1.4;
  background: var(--s-bg); color: var(--s-fg); border: 1px solid var(--s-bd, transparent);
}
.status-sand  { --s-bg: #F1E6D1; --s-fg: #7A5A2E; --s-bd: #E5D3B0; }
.status-sky   { --s-bg: var(--sky-soft); --s-fg: #2C6276; --s-bd: #C2DCE5; }
.status-leaf  { --s-bg: var(--leaf-soft); --s-fg: #3D6029; --s-bd: #CFE0BE; }
.status-gold  { --s-bg: var(--gold-soft); --s-fg: #8A6113; --s-bd: #EBD6A8; }
.status-green { --s-bg: var(--green-soft); --s-fg: #1F6440; --s-bd: #BDE0CB; }
.status-gray  { --s-bg: #ECEAE4; --s-fg: #5d5b55; --s-bd: #DEDBD2; }
.status-clay  { --s-bg: var(--clay-soft); --s-fg: #9A4428; --s-bd: #EDC6B7; }
.status.is-live i { animation: pulse-dot 1.6s ease-in-out infinite; }

.level { white-space: nowrap; flex: none;
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px;
  font-size: .8rem; font-weight: 600; color: #fff;
}
.level::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.85); }
.level-low { background: var(--clay); }
.level-medium { background: var(--gold); }
.level-high { background: var(--green); }

/* แถบระดับ 3 ช่อง + หมุดตำแหน่งค่า */
.level-bar { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; height: 10px; margin: 18px 0 6px; }
.level-bar span { border-radius: 99px; }
.level-bar span:nth-child(1) { background: var(--clay); opacity: .8; }
.level-bar span:nth-child(2) { background: var(--gold); opacity: .8; }
.level-bar span:nth-child(3) { background: var(--green); opacity: .8; }
.level-bar .pin {
  position: absolute; top: 50%; width: 18px; height: 18px; margin-left: -9px; transform: translateY(-50%) scale(0);
  border-radius: 50%; background: #fff; border: 4px solid var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.25);
  animation: pin-in .6s .3s var(--ease) forwards;
}
.level-bar-labels { display: grid; grid-template-columns: repeat(3, 1fr); font-size: .72rem; color: var(--muted); text-align: center; }

/* 8. ปุ่ม ------------------------------------------------------------- */
.btn { border-radius: 12px; font-weight: 500; transition: transform .15s var(--ease), box-shadow .2s, background .2s; }
.btn:active { transform: scale(.97); }
.btn-primary {
  --bs-btn-bg: var(--leaf); --bs-btn-border-color: var(--leaf);
  --bs-btn-hover-bg: #436932; --bs-btn-hover-border-color: #436932;
  --bs-btn-active-bg: var(--forest); --bs-btn-active-border-color: var(--forest);
  --bs-btn-disabled-bg: var(--leaf); --bs-btn-disabled-border-color: var(--leaf);
  box-shadow: 0 6px 14px -8px rgba(79, 122, 58, .8);
}
.btn-gold {
  --bs-btn-color: #fff; --bs-btn-bg: var(--gold); --bs-btn-border-color: var(--gold);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #9f7322; --bs-btn-hover-border-color: #9f7322;
  --bs-btn-active-color: #fff; --bs-btn-active-bg: #8a6419;
}
.btn-clay {
  --bs-btn-color: #fff; --bs-btn-bg: var(--clay); --bs-btn-border-color: var(--clay);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #a84f32; --bs-btn-hover-border-color: #a84f32;
}
.btn-soft {
  --bs-btn-color: var(--forest); --bs-btn-bg: var(--cream); --bs-btn-border-color: var(--line);
  --bs-btn-hover-color: var(--forest); --bs-btn-hover-bg: #fff; --bs-btn-hover-border-color: #d3c5ad;
  --bs-btn-active-bg: var(--leaf-soft);
}
.btn-ghost { --bs-btn-color: var(--muted); --bs-btn-hover-bg: rgba(47,62,44,.07); --bs-btn-hover-color: var(--ink); border: 0; }
.btn-xs { padding: 3px 8px; font-size: .78rem; border-radius: 8px; }
.btn-act {
  width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.btn-act:hover { color: var(--leaf); border-color: var(--leaf-2); background: var(--leaf-soft); }
.btn-act.danger:hover { color: var(--clay); border-color: var(--clay); background: var(--clay-soft); }
.btn.is-loading { pointer-events: none; opacity: .85; }
.btn.is-loading .btn-label::after { content: '…'; }

/* 9. ตาราง ------------------------------------------------------------ */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: rgba(79, 122, 58, .05); margin: 0; }
.table > thead th {
  font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: .02em;
  background: #F5EFE3; border-bottom: 1px solid var(--line); white-space: nowrap; padding: 12px 14px;
}
.table > tbody td { padding: 12px 14px; vertical-align: middle; border-color: #EEE6D8; }
.table > tbody tr { transition: background .15s; }
.cell-main { font-weight: 500; color: var(--ink); }
.nowrap { white-space: nowrap; }
.cell-sub { display: block; font-size: .8rem; color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* DataTables 2 */
div.dt-container { font-size: .92rem; }
div.dt-container div.dt-layout-row { margin: 0 !important; padding: 12px 16px; }
div.dt-container div.dt-layout-row.dt-layout-table { padding: 0; }
div.dt-container .dt-layout-table > div { overflow-x: auto; }       /* เลื่อนตารางแนวนอนได้ ไม่ดันหน้า */
div.dt-container .dt-search input { border-radius: 10px; min-width: 220px; margin-left: 8px; }
div.dt-container .dt-length select { border-radius: 10px; }
div.dt-container .dt-paging .page-link { border-radius: 10px !important; margin: 0 2px; border: 0; color: var(--forest); }
div.dt-container .dt-paging .page-item.active .page-link { background: var(--leaf); color: #fff; }
div.dt-container .dt-info { color: var(--muted); font-size: .85rem; }
div.dt-processing > div:last-child > div { background: var(--leaf) !important; }
table.dataTable > thead > tr > th.dt-orderable-asc:hover, table.dataTable > thead > tr > th.dt-orderable-desc:hover { outline: none; color: var(--leaf); }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filter-bar .form-control, .filter-bar .form-select { min-width: 140px; }
.filter-bar .ts-wrapper { min-width: 160px; }
.status-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 12px 16px 0; scrollbar-width: none; }
.status-tabs::-webkit-scrollbar { display: none; }
.status-tab {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px;
  border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: .85rem; cursor: pointer;
  transition: all .2s var(--ease);
}
.status-tab b { font-weight: 600; color: var(--ink); background: var(--sand); border-radius: 99px; padding: 0 7px; font-size: .75rem; }
.status-tab:hover { border-color: var(--leaf-2); color: var(--ink); }
.status-tab.active { background: var(--forest); border-color: var(--forest); color: #fff; }
.status-tab.active b { background: rgba(255,255,255,.18); color: #fff; }

/* ตารางกลายเป็นการ์ดบนมือถือ: ใส่ class table-cards + data-label ที่ td (App.dataTable ใส่ให้อัตโนมัติ) */
@media (max-width: 767.98px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tbody { padding: 10px; }
  .table-cards tr {
    position: relative; margin-bottom: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px;
    background: #fff; box-shadow: 0 2px 8px -6px rgba(31,42,28,.3);
  }
  /* ป้ายกำกับลอยซ้าย เนื้อหาชิดขวา (เนื้อหาหลายบรรทัดก็ยังเรียงสวย) */
  .table-cards td { border: 0 !important; padding: 4px 0 !important; text-align: right; overflow: hidden; }
  .table-cards td::before { content: attr(data-label); float: left; color: var(--muted); font-size: .78rem; text-align: left; max-width: 45%; margin-right: 12px; padding-top: 2px; }
  .table-cards td.td-actions { display: flex; gap: 6px; }
  .table-cards td.td-actions .row-actions { width: 100%; }
  .table-cards td.td-title { display: block; text-align: left; padding-right: 0 !important; margin-bottom: 4px; }
  .table-cards td.td-title::before { display: none; }
  .table-cards td.td-actions { justify-content: flex-end; border-top: 1px dashed var(--line) !important; margin-top: 8px; padding-top: 10px !important; }
  .table-cards td.td-actions::before { display: none; }
  .table-cards td.dt-empty { display: block; text-align: center; }
  .table-cards td.dt-empty::before { display: none; }
  .table-cards tr > td { box-shadow: none !important; background: transparent !important; }
  div.dt-container div.dt-layout-row { padding: 10px 12px; }
  div.dt-container .dt-length { display: none; }                 /* มือถือ: ซ่อน "แสดง x รายการ" ประหยัดที่ */
  div.dt-container div.dt-layout-row > div { width: 100%; margin: 0 !important; justify-content: stretch !important; }
  div.dt-container .dt-search { width: 100%; }
  div.dt-container .dt-search label { display: none; }
  div.dt-container .dt-search input { display: block; min-width: 0; width: 100% !important; margin: 0 !important; }
  div.dt-container .dt-paging { display: flex; justify-content: center; }
  .progress-steps li { min-width: 62px; font-size: .66rem; }
  div.dt-container .dt-layout-cell { width: 100%; }
}

/* 10. Modal ----------------------------------------------------------- */
.modal-content { border: 0; border-radius: 22px; background: var(--cream); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--line); padding: 18px 22px; }
.modal-title { font-family: var(--font-head); font-size: 1.2rem; display: flex; align-items: center; gap: 10px; }
.modal-title .mt-icon {
  width: 38px; height: 38px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--leaf-soft); color: var(--leaf); font-size: 1.1rem;
}
.modal-body { padding: 20px 22px; }
.modal-footer { border-top: 1px solid var(--line); padding: 14px 22px; gap: 8px; }
.modal-backdrop.show { opacity: .4; }
.modal.fade .modal-dialog { transform: translateY(24px) scale(.98); transition: transform .3s var(--ease); }
.modal.show .modal-dialog { transform: none; }
.form-section { font-size: .8rem; font-weight: 600; letter-spacing: .06em; color: var(--leaf); margin: 18px 0 10px; display: flex; align-items: center; gap: 8px; }
.form-section::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.form-section:first-child { margin-top: 0; }

/* มือถือ: modal เลื่อนขึ้นจากด้านล่างแบบ bottom sheet
 * หลักการ: จำกัดความสูงทั้งแผ่นไม่เกิน 92% ของจอ → หัว/ท้าย (ปุ่มบันทึก) อยู่กับที่ → เลื่อนเฉพาะส่วนเนื้อหา (.modal-body)
 * ต้องเขียนให้ specificity สูงกว่า .modal-dialog-scrollable .modal-content ของ Bootstrap (ไม่งั้น max-height ถูกทับ = เลื่อนไม่ได้)
 * dvh = ความสูงจอจริงบนมือถือ (ไม่รวมแถบที่อยู่ของเบราว์เซอร์) · บรรทัด vh ก่อนหน้าไว้สำหรับเบราว์เซอร์เก่า */
@media (max-width: 575.98px) {
  .modal .modal-dialog {
    margin: 0; position: fixed; left: 0; right: 0; bottom: 0; max-width: none; width: 100%;
    height: auto; min-height: 0; max-height: 92vh; max-height: 92dvh; display: flex; align-items: flex-end;
  }
  .modal .modal-dialog .modal-content {
    width: 100%; max-height: 92vh; max-height: 92dvh; overflow: hidden; border-radius: 22px 22px 0 0;
  }
  .modal .modal-dialog .modal-body {
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;   /* เลื่อนลื่นบน iOS และไม่ลากหน้าหลังไปด้วย */
  }
  .modal .modal-header, .modal .modal-footer { flex-shrink: 0; }
  .modal-content::before { content: ''; flex-shrink: 0; width: 44px; height: 5px; border-radius: 9px; background: #d5c9b5; margin: 8px auto 0; }
  .modal.fade .modal-dialog { transform: translateY(100%); }
  .modal.show .modal-dialog { transform: none; }
  .modal-footer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer > .btn { flex: 1 1 auto; white-space: nowrap; margin: 0; }   /* ปุ่มยาวไม่ตัดบรรทัด — ไม่พอที่จะขึ้นแถวใหม่เต็มความกว้าง */
}

/* 11. ฟอร์ม + Tom Select ---------------------------------------------- */
.form-label { font-size: .85rem; font-weight: 500; color: #4a463d; margin-bottom: 4px; }
.form-label .req { color: var(--clay); }
.form-control, .form-select { border-radius: 10px; border-color: #DCD0BC; background-color: #fff; }
.form-text { color: var(--muted); font-size: .78rem; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.check-tile {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; cursor: pointer; transition: all .2s;
}
.check-tile:hover { border-color: var(--leaf-2); }
.check-tile:has(input:checked) { border-color: var(--leaf); background: var(--leaf-soft); }
.check-tile .form-check-input { margin-top: 3px; flex: none; }
.check-tile small { display: block; color: var(--muted); font-size: .74rem; }
.choice-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.choice-pills input { position: absolute; opacity: 0; pointer-events: none; }
.choice-pills label {
  padding: 7px 14px; border-radius: 99px; border: 1px solid #DCD0BC; background: #fff; cursor: pointer; font-size: .9rem;
  transition: all .2s var(--ease);
}
.choice-pills input:checked + label { background: var(--forest); border-color: var(--forest); color: #fff; }
.choice-pills input:focus-visible + label { box-shadow: 0 0 0 .25rem rgba(79,122,58,.25); }
.ts-wrapper.form-select .ts-control, .ts-wrapper.form-control .ts-control { border-radius: 10px; border-color: #DCD0BC; }
.ts-wrapper.focus .ts-control { border-color: var(--leaf-2); box-shadow: 0 0 0 .25rem rgba(79,122,58,.18); }
.ts-dropdown { background: #fff; border-radius: 12px; border-color: var(--line); box-shadow: var(--shadow-lg); overflow: hidden; z-index: 1060; }
.ts-dropdown .active { background: var(--leaf-soft); color: var(--ink); }
.ts-dropdown .opt-sub { display: block; font-size: .78rem; color: var(--muted); }
.ts-dropdown .ts-dropdown-content { max-height: 320px; }
.ts-dropdown .optgroup-header {                           /* หัวกลุ่มลูกค้าใน dropdown แปลง — ติดอยู่ด้านบนขณะเลื่อน */
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 4px;
  padding: 7px 12px; background: #F5EFE3; color: var(--forest); font-weight: 600; font-size: .85rem; border-top: 1px solid var(--line);
}
.ts-dropdown .optgroup:first-child .optgroup-header { border-top: 0; }
.ts-dropdown .optgroup-header .opt-phone { margin-left: auto; font-weight: 400; color: var(--muted); font-size: .78rem; }
.ts-dropdown .option .opt-plot { padding-left: 14px; }
.ts-dropdown .opt-name { font-weight: 500; }
.drop-zone {
  border: 2px dashed #D6C8B0; border-radius: 14px; padding: 18px; text-align: center; color: var(--muted);
  background: rgba(255,255,255,.6); cursor: pointer; transition: all .2s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--leaf); background: var(--leaf-soft); color: var(--forest); }
.drop-zone i { font-size: 1.8rem; display: block; color: var(--leaf); }
.value-input { font-family: var(--font-head); font-size: 1.15rem; font-weight: 600; text-align: right; }

/* 12. รายละเอียดตัวอย่าง --------------------------------------------- */
.info-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 20px; margin: 0; }
.info-list dt { font-size: .76rem; font-weight: 500; color: var(--muted); margin-bottom: 2px; }
.info-list dd { margin: 0; font-weight: 500; word-break: break-word; }
.sample-hero {
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap; justify-content: space-between;
  padding: 20px 22px; border-radius: var(--radius); background: var(--cream); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.sample-no { font-family: var(--font-head); font-size: 1.6rem; font-weight: 700; margin: 0; }
.progress-steps { display: flex; gap: 0; margin: 4px 0 0; padding: 0; list-style: none; overflow-x: auto; }
.progress-steps li { flex: 1; min-width: 74px; text-align: center; position: relative; font-size: .72rem; color: var(--muted); }
.progress-steps li::before {
  content: ''; display: block; width: 14px; height: 14px; margin: 0 auto 6px; border-radius: 50%;
  background: #fff; border: 3px solid #D8CCB7; position: relative; z-index: 1;
}
.progress-steps li::after { content: ''; position: absolute; top: 6px; left: -50%; width: 100%; height: 3px; background: #E3D8C6; }
.progress-steps li:first-child::after { display: none; }
.progress-steps li.done { color: var(--forest); }
.progress-steps li.done::before { background: var(--leaf); border-color: var(--leaf); }
.progress-steps li.done::after { background: var(--leaf); }
.progress-steps li.current::before { border-color: var(--gold); background: #fff; box-shadow: 0 0 0 5px rgba(184,134,43,.2); animation: pulse-ring 1.8s infinite; }
.progress-steps li.current { color: var(--ink); font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 30px; }
.timeline li::before { content: ''; position: absolute; left: 8px; top: 20px; bottom: -2px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot {
  position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--tone-soft, var(--leaf-soft)); border: 2px solid var(--tone, var(--leaf));
}
.timeline time { display: block; font-size: .76rem; color: var(--muted); }

.result-card { padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: #fff; height: 100%; transition: transform .25s var(--ease), box-shadow .25s; }
.result-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.result-card .rc-name { font-size: .85rem; color: var(--muted); }
.result-card .rc-value { font-family: var(--font-head); font-size: 1.7rem; font-weight: 700; line-height: 1.15; }
.result-card .rc-unit { font-size: .85rem; color: var(--muted); margin-left: 4px; font-family: var(--font-body); font-weight: 400; }
.recommend-box {
  border-radius: 16px; padding: 16px 18px; background: linear-gradient(135deg, #FFF8E7, var(--gold-soft));
  border: 1px solid #EBD6A8;
}
.recommend-box ol { margin: 0; padding-left: 1.2rem; }
.recommend-box li { margin: 4px 0; }
.file-tile {
  position: relative; display: block; border-radius: 14px; overflow: hidden; border: 1px solid var(--line);
  background: #fff; aspect-ratio: 4 / 3;
}
.file-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s var(--ease); }
.file-tile:hover img { transform: scale(1.05); }
.file-tile .ft-pdf { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--clay); font-size: 2.2rem; }
.file-tile .ft-pdf small { font-size: .72rem; color: var(--muted); padding: 0 8px; text-align: center; word-break: break-all; }
.file-tile .ft-kind { position: absolute; left: 8px; top: 8px; font-size: .68rem; padding: 2px 8px; border-radius: 99px; background: rgba(31,42,28,.7); color: #fff; }
.file-tile .ft-del { position: absolute; right: 6px; top: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); color: var(--clay); opacity: 0; transition: opacity .2s; }
.file-tile:hover .ft-del, .file-tile:focus-within .ft-del { opacity: 1; }
@media (hover: none) { .file-tile .ft-del { opacity: 1; } }

/* หน้า Lab: ตารางกรอกค่า — มือถือเป็นแถวกะทัดรัด: ชื่อรายการ / ช่องค่า + ระดับ */
@media (max-width: 575.98px) {
  .values-table thead { display: none; }
  .values-table tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .values-table td { border: 0 !important; padding: 0 !important; }
  .values-table td:first-child { grid-column: 1 / -1; }
}

/* หน้า Lab: คิวงาน */
.queue-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; background: #fff; border: 1px solid var(--line); height: 100%; transition: transform .25s var(--ease), box-shadow .25s, border-color .2s; }
.queue-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #d4c6ae; }
.queue-card .q-no { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; }
.queue-card .q-meta { font-size: .82rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.queue-card .q-progress { height: 6px; border-radius: 99px; background: #EEE6D8; overflow: hidden; }
.queue-card .q-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--leaf-2), var(--leaf)); border-radius: 99px; transition: width .8s var(--ease); }

/* 13. หน้าเข้าสู่ระบบ/สมัคร ------------------------------------------ */
.auth-body { background: var(--sand); min-height: 100vh; }
.auth-shell { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; padding: 44px 52px; display: flex; flex-direction: column;
  background:
    radial-gradient(70% 60% at 85% 10%, rgba(184, 134, 43, .45), transparent 60%),
    radial-gradient(60% 50% at 0% 30%, rgba(110, 154, 79, .45), transparent 60%),
    linear-gradient(160deg, #3D5A2E 0%, var(--forest) 45%, var(--forest-2) 100%);
}
.hero-top { display: flex; align-items: center; gap: 14px; position: relative; z-index: 2; }
.hero-name { font-family: var(--font-head); font-size: 1.6rem; font-weight: 700; line-height: 1; }
.hero-tag { color: #CFD8C4; font-size: .9rem; }
.hero-copy { position: relative; z-index: 2; margin-top: auto; margin-bottom: 170px; max-width: 460px; }
.hero-copy h2 { font-size: clamp(2.2rem, 3.6vw, 3.3rem); line-height: 1.15; font-weight: 700; margin-bottom: 14px; animation: fade-up .8s var(--ease) both; }
.hero-copy p { color: #DCE4D2; font-size: 1.05rem; animation: fade-up .8s .1s var(--ease) both; }
.hero-steps { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.hero-steps li {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px; font-size: .85rem;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(4px);
  animation: fade-up .7s var(--ease) both;
}
.hero-steps li:nth-child(1) { animation-delay: .2s; } .hero-steps li:nth-child(2) { animation-delay: .28s; }
.hero-steps li:nth-child(3) { animation-delay: .36s; } .hero-steps li:nth-child(4) { animation-delay: .44s; }
.hero-soil { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 210px; }
.hero-soil .l1 { fill: #B8862B; animation: soil-wave 9s ease-in-out infinite alternate; transform-origin: center; }
.hero-soil .l2 { fill: #8A5A3B; }
.hero-soil .l3 { fill: #5B3A26; }
.hero-sprout {
  position: absolute; right: 16%; bottom: 150px; width: 74px; height: 84px; z-index: 1;
  animation: sprout 3.2s ease-in-out infinite; transform-origin: 50% 100%;
}
.auth-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card {
  width: 100%; max-width: 470px; padding: 34px 34px 28px; border-radius: 26px; background: var(--cream);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: card-in .7s var(--ease) both;
}
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head h1 { font-size: 1.75rem; margin: 10px 0 4px; }
.auth-head p { color: var(--muted); margin: 0; font-size: .92rem; }
.auth-badge {
  display: inline-flex; width: 58px; height: 58px; border-radius: 18px; align-items: center; justify-content: center;
  font-size: 1.6rem; color: #fff; background: linear-gradient(145deg, var(--leaf-2), var(--forest));
  box-shadow: 0 10px 22px -10px rgba(47, 62, 44, .8);
}
.auth-form .form-floating > .form-control { border-radius: 14px; height: 58px; }
.auth-form .form-floating > label { color: var(--muted); }
.btn-eye { position: absolute; right: 8px; top: 9px; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); z-index: 5; }
.btn-eye:hover { background: var(--sand); color: var(--ink); }
.auth-foot { color: var(--muted); font-size: .8rem; margin: 18px 0 0; }
.alert-clay { background: var(--clay-soft); color: #8b3c22; border: 1px solid #EDC6B7; border-radius: 14px; }
.demo-accounts { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); }
.demo-title { font-size: .8rem; color: var(--muted); text-align: center; margin-bottom: 10px; }
.demo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.demo-chip {
  display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; transition: all .2s var(--ease);
}
.demo-chip strong { font-size: .82rem; font-weight: 600; }
.demo-chip small { font-size: .7rem; color: var(--muted); }
.demo-chip:hover, .demo-chip.active { border-color: var(--leaf); background: var(--leaf-soft); transform: translateY(-2px); }
.pw-meter { display: flex; align-items: center; gap: 10px; }
.pw-meter .bars { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pw-meter .bars i { height: 5px; border-radius: 9px; background: #E6DCCB; transition: background .3s; }
.pw-meter small { color: var(--muted); font-size: .76rem; min-width: 76px; text-align: right; }
.pw-meter[data-score="1"] .bars i:nth-child(-n+1) { background: var(--clay); }
.pw-meter[data-score="2"] .bars i:nth-child(-n+2) { background: var(--gold); }
.pw-meter[data-score="3"] .bars i:nth-child(-n+3) { background: var(--leaf-2); }
.pw-meter[data-score="4"] .bars i { background: var(--green); }

@media (max-width: 991.98px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { padding: 22px 20px 70px; min-height: 230px; }
  .hero-copy { margin: 18px 0 0; }
  .hero-copy h2 { font-size: 1.9rem; margin-bottom: 6px; }
  .hero-copy p, .hero-steps { display: none; }
  .hero-soil { height: 90px; }
  .hero-sprout { display: none; }
  .auth-panel { margin-top: -56px; padding: 0 14px 28px; justify-content: flex-start; position: relative; z-index: 3; }
  .auth-card { padding: 26px 20px 22px; border-radius: 24px; }
}
@media (max-width: 400px) { .demo-grid { grid-template-columns: repeat(2, 1fr); } }

/* 14. SweetAlert2 ----------------------------------------------------- */
div:where(.swal2-container) { z-index: 2000; }
div:where(.swal2-container) div:where(.swal2-popup) { border-radius: 22px; background: var(--cream); font-family: var(--font-body); color: var(--ink); }
div:where(.swal2-container) h2:where(.swal2-title) { font-family: var(--font-head); color: var(--ink); font-size: 1.35rem; }
div:where(.swal2-container) div:where(.swal2-html-container) { color: var(--muted); font-size: .98rem; }
.swal2-actions { gap: 8px; }
.swal2-popup.swal2-toast { border-radius: 14px !important; box-shadow: var(--shadow-lg) !important; padding: 10px 14px !important; }
.swal2-popup.swal2-toast .swal2-title { font-size: .95rem !important; font-family: var(--font-body) !important; font-weight: 500; }
div:where(.swal2-icon).swal2-success { border-color: var(--leaf) !important; color: var(--leaf) !important; }
div:where(.swal2-icon).swal2-success [class^=swal2-success-line] { background-color: var(--leaf) !important; }
div:where(.swal2-icon).swal2-success .swal2-success-ring { border-color: rgba(79,122,58,.3) !important; }
.swal2-timer-progress-bar { background: var(--leaf-2) !important; }
.swal2-input, .swal2-textarea, .swal2-select { border-radius: 12px !important; font-family: var(--font-body); font-size: 1rem !important; }

/* 15. อนิเมชัน -------------------------------------------------------- */
/* .fade-up + style="--i:2" = ค่อย ๆ ลอยขึ้น เรียงลำดับตาม --i */
.fade-up { animation: fade-up .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes card-in { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pulse-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(184,134,43,.45); } 100% { box-shadow: 0 0 0 10px rgba(184,134,43,0); } }
@keyframes pin-in { to { transform: translateY(-50%) scale(1); } }
@keyframes sprout { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(5deg) translateY(-3px); } }
@keyframes soil-wave { from { transform: translateX(0); } to { transform: translateX(-14px); } }
@keyframes shimmer { from { background-position: -400px 0; } to { background-position: 400px 0; } }
.skeleton {
  border-radius: 10px; min-height: 14px;
  background: linear-gradient(90deg, #EEE6D8 0%, #F8F3EA 40%, #EEE6D8 80%); background-size: 800px 100%;
  animation: shimmer 1.3s linear infinite;
}
.skeleton-card { height: 150px; border-radius: 16px; }
.row-new { animation: row-flash 1.6s var(--ease); }
@keyframes row-flash { from { background: rgba(184, 134, 43, .22); } to { background: transparent; } }

/* ผู้ใช้ที่ตั้งค่า "ลดการเคลื่อนไหว" ในเครื่อง → ปิดอนิเมชันทั้งหมด */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* 16. อื่น ๆ ---------------------------------------------------------- */
.empty-state { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty-state i { font-size: 2.6rem; color: #CDBFA6; display: block; margin-bottom: 8px; }
.error-page { text-align: center; padding: 48px 12px; }
.error-icon { font-size: 3rem; color: var(--gold); }
.error-code { font-family: var(--font-head); font-size: 5rem; font-weight: 700; line-height: 1; color: var(--forest); opacity: .9; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.zone-map { height: 420px; border-radius: 0 0 var(--radius) var(--radius); z-index: 0; }
@media (max-width: 575.98px) { .zone-map { height: 300px; } }
.mini-bar { height: 8px; border-radius: 99px; background: #EEE6D8; overflow: hidden; min-width: 80px; }
.mini-bar span { display: block; height: 100%; border-radius: 99px; background: var(--leaf); }
.json-diff { font-size: .82rem; }
.json-diff td:first-child { color: var(--muted); white-space: nowrap; }
.json-diff .from { color: var(--clay); text-decoration: line-through; }
.json-diff .to { color: var(--green); font-weight: 500; }
.sig-preview { height: 90px; border: 1px dashed var(--line); border-radius: 12px; display: flex; align-items: center; justify-content: center; background: #fff; }
.sig-preview img { max-height: 80px; max-width: 100%; }
.profile-cover { height: 120px; border-radius: var(--radius) var(--radius) 0 0; background: linear-gradient(120deg, var(--leaf), var(--forest) 60%, #6b4a2e); }
.profile-avatar { margin-top: -48px; border: 5px solid var(--cream); border-radius: 50%; display: inline-block; }
.nav-pills-soft .nav-link { border-radius: 99px; color: var(--muted); padding: 8px 16px; }
.nav-pills-soft .nav-link.active { background: var(--forest); color: #fff; }
.badge-count { display: inline-flex; min-width: 22px; height: 22px; padding: 0 6px; align-items: center; justify-content: center; border-radius: 99px; background: var(--clay); color: #fff; font-size: .72rem; font-weight: 600; }

@media print {
  .app-sidebar, .app-topbar, .mobile-nav, .app-footer, .page-actions, .row-actions { display: none !important; }
  .app-main { margin: 0; }
  .card-soft { box-shadow: none; }
}

/* =====================================================================
 * ลายเซ็น — หน้า "ลายเซ็นของฉัน" + Modal วาด/อัปโหลด (component/signature)
 * ===================================================================== */
.sig-stage {
  position: relative; height: 200px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  background: #fff linear-gradient(transparent 0 0); border: 1px dashed var(--line); overflow: hidden;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.sig-stage.has { border-style: solid; box-shadow: inset 0 0 0 6px var(--cream); }
.sig-stage img { max-height: 150px; max-width: 86%; position: relative; z-index: 1; animation: sigIn .5s var(--ease); }
.sig-stage-line { position: absolute; left: 12%; right: 12%; bottom: 38px; border-bottom: 1.5px solid #D9CFBE; }
.sig-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; color: var(--muted); padding: 0 20px; position: relative; z-index: 1; }
.sig-empty i { font-size: 2rem; color: var(--gold); width: 58px; height: 58px; border-radius: 50%; background: var(--gold-soft); display: grid; place-items: center; margin-bottom: 4px; }
.sig-empty b { color: var(--ink); font-size: 1.05rem; }
.sig-empty span { font-size: .875rem; }
@keyframes sigIn { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
.sig-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 2px 0; font-size: .85rem; color: var(--muted); min-height: 1px; }
.sig-meta i { margin-right: 5px; color: var(--leaf); }
.sig-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* จำลองท้ายใบแจ้งผล */
.paper-mock { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px 16px 16px; box-shadow: 0 10px 24px -18px rgba(47,62,44,.4); font-family: 'Sarabun', var(--font-body); }
.pm-lines span { display: block; height: 7px; border-radius: 4px; background: #EFEAE0; margin-bottom: 7px; }
.pm-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; text-align: center; }
.pm-slot { border-radius: 10px; padding: 6px 4px 8px; }
.pm-slot.mine { background: var(--leaf-soft); box-shadow: inset 0 0 0 1px #CFE0BE; }
.pm-sig { height: 46px; display: flex; align-items: flex-end; justify-content: center; }
.pm-sig img { max-height: 44px; max-width: 92%; }
.pm-dots { font-size: .72rem; color: var(--muted); border-bottom: 1px dotted #b9ad97; padding: 0 6px 2px; }
.pm-name { font-size: .8rem; margin-top: 2px; }
.pm-role { font-size: .74rem; color: var(--muted); }

.sig-tips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.sig-tips > div { display: flex; gap: 12px; }
.sig-tips b { display: block; font-size: .92rem; }
.sig-tips span:not(.tip-icon) { font-size: .84rem; color: var(--muted); }
.tip-icon { flex: 0 0 38px; height: 38px; border-radius: 12px; background: var(--sand); display: grid; place-items: center; color: var(--leaf); font-size: 1.1rem; }
@media (max-width: 767.98px) { .sig-tips { grid-template-columns: 1fr; gap: 14px; } }

.sig-pending { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 12px 16px; border-radius: 14px; background: var(--gold-soft); color: #7a5512; }
.sig-pending > i { font-size: 1.2rem; }
.sig-pending .btn { white-space: nowrap; flex-shrink: 0; }

/* Modal */
.sig-note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 14px; border-radius: 12px; background: var(--gold-soft); color: #7a5512; font-size: .9rem; margin-bottom: 14px; }
.sig-tabs { display: inline-flex; padding: 4px; background: var(--sand); border-radius: 99px; margin-bottom: 14px; }
.sig-tab { border: 0; background: transparent; border-radius: 99px; padding: 7px 16px; color: var(--muted); font-weight: 500; display: inline-flex; gap: 6px; align-items: center; transition: background .2s, color .2s; }
.sig-tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(47,62,44,.15); }
.sig-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 10px; }
.sig-swatches, .sig-sizes { display: flex; gap: 6px; align-items: center; }
.sig-swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 0 0 1px var(--line); transition: transform .15s; }
.sig-swatch.active { box-shadow: 0 0 0 2px var(--leaf); transform: scale(1.08); }
.sig-size { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; }
.sig-size i { width: var(--s); height: var(--s); border-radius: 50%; background: var(--ink); }
.sig-size.active { border-color: var(--leaf); background: var(--leaf-soft); }
.sig-pad-wrap { position: relative; border-radius: 16px; background: #fff; border: 1px solid var(--line); overflow: hidden; }
.sig-pad { display: block; width: 100%; aspect-ratio: 5 / 2; touch-action: none; cursor: crosshair; position: relative; z-index: 2; }
.sig-guide { position: absolute; left: 7%; right: 7%; bottom: 26%; display: flex; align-items: flex-end; gap: 8px; pointer-events: none; z-index: 1; }
.sig-x { color: #C9BBA3; font-size: 1.1rem; line-height: 1; }
.sig-line { flex: 1; border-bottom: 1.5px dashed #D9CFBE; }
.sig-hint { position: absolute; inset: 0 0 auto 0; top: 28%; text-align: center; color: #B5AA97; font-size: .95rem; pointer-events: none; z-index: 1; transition: opacity .3s; }
.sig-hint i { margin-right: 6px; }
.sig-hint.hide { opacity: 0; }
.sig-drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; cursor: pointer;
  padding: 34px 18px; border: 2px dashed var(--line); border-radius: 16px; background: #fff; transition: border-color .2s, background .2s;
}
.sig-drop:hover, .sig-drop.over { border-color: var(--leaf-2); background: var(--leaf-soft); }
.sig-drop small { color: var(--muted); }
.sig-drop-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--leaf-soft); color: var(--leaf); display: grid; place-items: center; font-size: 1.6rem; margin-bottom: 6px; }
.sig-checker {
  border-radius: 14px; border: 1px solid var(--line); min-height: 160px; display: flex; align-items: center; justify-content: center; padding: 14px;
  background-color: #fff;
  background-image: linear-gradient(45deg, #F1ECE2 25%, transparent 25%), linear-gradient(-45deg, #F1ECE2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #F1ECE2 75%), linear-gradient(-45deg, transparent 75%, #F1ECE2 75%);
  background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.sig-checker canvas { max-width: 100%; max-height: 180px; }
.choice-pills-sm label { padding: 5px 12px; font-size: .85rem; }
@media (max-width: 575.98px) {
  .sig-pad { aspect-ratio: 3 / 2; }
  .sig-stage { height: 170px; }
  .sig-actions .btn { flex: 1 1 auto; }
}

/* ---------- ตั้งค่าระบบ: การ์ดระบบอีเมล + ประวัติการส่ง ---------- */
.mail-warn { background: var(--gold-soft); color: #7a5512; border-radius: 10px; padding: 9px 12px; margin-bottom: 12px; display: grid; gap: 4px; }
.mail-log { display: grid; }
.mail-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 2px; border-top: 1px solid var(--line); }
.mail-row:first-child { border-top: 0; }
.mail-row > .status { flex-shrink: 0; margin-top: 2px; }
.mail-main { flex: 1; min-width: 0; }
.mail-subject { font-weight: 500; overflow-wrap: anywhere; }
.mail-sub { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.mail-event { display: inline-block; background: var(--sand); border-radius: 99px; padding: 0 8px; margin-right: 4px; color: var(--ink); }
.mail-err { font-size: .8rem; color: #9A4428; background: var(--clay-soft); border-radius: 8px; padding: 4px 8px; margin-top: 4px; overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
  .mail-row { flex-wrap: wrap; }
  .mail-row > .btn { margin-left: auto; }
}
.logo-preview { height: 130px; border-radius: 14px; border: 1px solid var(--line); background: #fff; display: flex; align-items: center; justify-content: center; padding: 12px; }
.logo-preview img { max-height: 100%; max-width: 100%; }

/* ---------- โลโก้ระบบ (assets/img/logo.png พื้นขาว) วางบนแผ่นขาวมุมมน ใช้ได้ทั้งพื้นเข้มและพื้นสว่าง ---------- */
.brand-tile { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 14px; background: #fff; display: grid; place-items: center; padding: 4px; box-shadow: 0 4px 14px -6px rgba(0,0,0,.45); }
.brand-tile img { width: 100%; height: 100%; object-fit: contain; }
.brand-tile-lg { width: 76px; height: 76px; border-radius: 18px; padding: 6px; }
