/* =====================================================================
   SriCare — ระบบออกแบบหลัก (design system) ต่อจาก Bootstrap 5.3 · หน้าตาตามเทมเพลต ArchitectUI ธีม Blue Alternate
   (ArchitectUI © DashboardPack สัญญาอนุญาต MIT — ถอดแบบโครงหน้า/สี/เงา/ปุ่ม hamburger มาเป็น CSS ของระบบ ไม่ได้ใช้โค้ด Angular)
   โครงหน้า: แถบหัวคงที่มีเงา (.app-header) · เมนูด้านซ้ายแบบ vertical-nav (.app-sidebar — เลือกสีแถบเมนูได้ html[data-sb-theme])
            แถบหัวเรื่องโปร่งแสง + กล่องไอคอนไล่สีตามกลุ่มเมนู (.app-page-title) · การ์ดเงานุ่มหลายชั้น · ท้ายหน้า (.app-footer)
   โทนสี: พื้นหน้าเทาฟ้า #f1f4f6 · สีหลักกรมท่า #033C73 (ปุ่ม ลิงก์ ช่องเลือก โฟกัส) · ชี้/เลือกในเมนูเป็นฟ้าอ่อน #d1f3ff (--sc-hover)
          สีสถานะ (เขียว/เหลือง/แดง/ฟ้า) คงตาม Bootstrap ที่ปรับความต่างสีแล้ว — ใช้กับสถานะเท่านั้นและมีข้อความกำกับเสมอ
   ตัวอักษร Sarabun (ไฟล์ในเครื่อง assets/fonts — สัญญาอนุญาต assets/fonts/OFL.txt) · ข้อความไทยไม่ใช้ตัวพิมพ์ใหญ่/ระยะห่างตัวอักษร
          ข้อความไทยในกล่องที่ตัดล้น (overflow) ใช้ line-height ≥ 1.45 · ขนาดตัวอักษรเล็กสุด .75rem · ตัวเลขในตารางกว้างเท่ากัน (tabular-nums)
   โหมดมืด: [data-bs-theme="dark"] — ผู้ใช้เลือก สว่าง / มืด / ตามระบบ จากเมนูบนแถบด้านบน (คุกกี้ sricare_theme เฉพาะ path ของระบบ)
   ===================================================================== */
@font-face { font-family: 'Sarabun'; font-weight: 300; font-display: swap; src: url('../fonts/sarabun-thai-300.woff2') format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Sarabun'; font-weight: 300; font-display: swap; src: url('../fonts/sarabun-latin-300.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Sarabun'; font-weight: 400; font-display: swap; src: url('../fonts/sarabun-thai-400.woff2') format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Sarabun'; font-weight: 400; font-display: swap; src: url('../fonts/sarabun-latin-400.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Sarabun'; font-weight: 500; font-display: swap; src: url('../fonts/sarabun-thai-500.woff2') format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Sarabun'; font-weight: 500; font-display: swap; src: url('../fonts/sarabun-latin-500.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Sarabun'; font-weight: 600; font-display: swap; src: url('../fonts/sarabun-thai-600.woff2') format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Sarabun'; font-weight: 600; font-display: swap; src: url('../fonts/sarabun-latin-600.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Sarabun'; font-weight: 700; font-display: swap; src: url('../fonts/sarabun-thai-700.woff2') format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Sarabun'; font-weight: 700; font-display: swap; src: url('../fonts/sarabun-latin-700.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ================================================================ ตัวแปรสี/ขนาด (ArchitectUI Blue Alternate) */
:root, [data-bs-theme="light"] {
  --sc-sidebar-w: 280px;          /* $app-sidebar-width */
  --sc-sidebar-mini-w: 80px;      /* $app-sidebar-width-collapsed */
  --sc-topbar-h: 60px;            /* $app-header-height */
  --sc-gutter: 1.875rem;          /* $grid-gutter-width (30px) — ระยะขอบเนื้อหา/แถบหัวเรื่อง (จอเล็กลดลง ดูส่วนโครงหน้า) */
  --sc-navy: #022b52;
  --sc-navy-2: #033c73;
  --sc-accent: #2fa4e7;           /* $cyan ของธีม */
  --sc-brand: #033c73;            /* $brand ของธีม Blue Alternate */
  --sc-brand-rgb: 3, 60, 115;
  --sc-brand-hover: #022e59;
  --sc-brand-active: #02284d;
  --sc-brand-tint: #e6ebf1;
  --sc-brand-dark: #022b52;
  --sc-brand-text: #033c73;
  --sc-hover: #d1f3ff;            /* $dropdown-link-hover-bg — ชี้/เลือกในเมนู รายการ dropdown */
  --sc-hover-text: #033c73;
  --sc-page: #f1f4f6;             /* $app-container-bg */
  --sc-header-bg: #fafbfc;        /* $app-header-bg */
  --sc-surface: #fff;
  --sc-surface-2: #f8f9fa;
  --sc-border: #e3e7ec;
  --sc-border-row: #edf0f3;
  --sc-input-border: #c4cbd3;
  --sc-text: #3d4650;
  --sc-text-2: #5f6873;
  --sc-muted: #67707a;
  --sc-focus: #033c73;
  --sc-card-title: #2d3a4f;
  /* $box-shadow-default (เงานุ่ม 4 ชั้น) · เมนู/ป๊อปอัป · กล่องโต้ตอบ ($box-shadow-lg-default) */
  --sc-shadow-sm: 0 .46875rem 2.1875rem rgba(4, 9, 20, .03), 0 .9375rem 1.40625rem rgba(4, 9, 20, .03), 0 .25rem .53125rem rgba(4, 9, 20, .05), 0 .125rem .1875rem rgba(4, 9, 20, .03);
  --sc-shadow-md: 0 .46875rem 2.1875rem rgba(4, 9, 20, .07), 0 .9375rem 1.40625rem rgba(4, 9, 20, .06), 0 .25rem .53125rem rgba(4, 9, 20, .08), 0 .125rem .1875rem rgba(4, 9, 20, .05);
  --sc-shadow-lg: 0 .76875rem 2.4875rem rgba(52, 58, 64, .3), 0 1.3375rem 1.70625rem rgba(52, 58, 64, .3), 0 .55rem .53125rem rgba(0, 0, 0, .05), 0 .225rem .4375rem rgba(52, 58, 64, .3);
  --sc-radius: .375rem;
  --sc-purple: #6f42c1; --sc-teal: #0f766e; --sc-orange: #c2410c; --sc-pink: #c2255c;
  --sc-purple-text: #4b2a85; --sc-purple-bg: #ece4fa; --sc-purple-border: #d4c4f2;
  --sc-teal-text: #0b5d56; --sc-teal-bg: #d5f2ef; --sc-teal-border: #a6ded8;
  --sc-orange-text: #9a3b07; --sc-orange-bg: #ffe6d5; --sc-orange-border: #fdc9a6;
  --sc-pink-text: #8c1840; --sc-pink-bg: #fbdbe7; --sc-pink-border: #f3b3cb;
  /* กราฟ: ชุดสีหมวดหมู่ 8 สี (ผ่านการตรวจตาบอดสี/คอนทราสต์กับพื้นการ์ด — ใช้ตามลำดับ ห้ามวนซ้ำ) + สีกลาง/เส้นตาราง/แกน/กล่องข้อมูล
     assets/js/charts.js อ่านค่าเหล่านี้ให้กราฟ Chart.js ทุกกราฟ (สลับธีม/พิมพ์ = วาดใหม่ด้วยค่าของธีมนั้น) */
  --sc-chart-1: #2a78d6; --sc-chart-2: #eb6834; --sc-chart-3: #1baf7a; --sc-chart-4: #eda100;
  --sc-chart-5: #e87ba4; --sc-chart-6: #008300; --sc-chart-7: #4a3aa7; --sc-chart-8: #e34948;
  --sc-chart-muted: #8a94a3; --sc-chart-grid: #e8ecf2; --sc-chart-axis: #c3cbd6; --sc-chart-text: #5b6676;
  --sc-chart-tip-bg: #111a26; --sc-chart-tip-fg: #ffffff; --sc-chart-tip-border: transparent;

  --bs-font-sans-serif: 'Sarabun', 'Noto Sans Thai', 'Leelawadee UI', Tahoma, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-font-size: .9375rem;
  --bs-body-line-height: 1.6;
  --bs-body-color: #3d4650; --bs-body-color-rgb: 61, 70, 80;
  --bs-body-bg: #fff; --bs-body-bg-rgb: 255, 255, 255;
  --bs-emphasis-color: #1f252c; --bs-emphasis-color-rgb: 31, 37, 44;
  --bs-secondary-color: #5f6873; --bs-secondary-color-rgb: 95, 104, 115;
  --bs-tertiary-color: #67707a; --bs-tertiary-color-rgb: 103, 112, 122;
  --bs-secondary-bg: #e9ecef; --bs-secondary-bg-rgb: 233, 236, 239;
  --bs-tertiary-bg: #f8f9fa; --bs-tertiary-bg-rgb: 248, 249, 250;
  --bs-heading-color: #2b323a;
  --bs-border-color: #e3e7ec;
  --bs-border-color-translucent: rgba(26, 54, 126, .125);
  --bs-border-radius: .25rem; --bs-border-radius-sm: .2rem; --bs-border-radius-lg: .375rem; --bs-border-radius-xl: .5rem;
  --bs-blue: #033c73; --bs-teal: #0f766e; --bs-orange: #c2410c;
  --bs-primary: #033c73; --bs-primary-rgb: 3, 60, 115;
  --bs-primary-text-emphasis: #022b52; --bs-primary-bg-subtle: #e6ebf1; --bs-primary-border-subtle: #b3c4d5;
  --bs-secondary-text-emphasis: #3d4652; --bs-secondary-bg-subtle: #eceff3; --bs-secondary-border-subtle: #d5dbe3;
  --bs-link-color: #033c73; --bs-link-color-rgb: 3, 60, 115;
  --bs-link-hover-color: #0a5aa8; --bs-link-hover-color-rgb: 10, 90, 168;
  --bs-focus-ring-color: rgba(3, 60, 115, .25);
}
[data-bs-theme="dark"] {
  --sc-accent: #4fb6ef;
  --sc-brand: #2f6fb8;
  --sc-brand-rgb: 47, 111, 184;
  --sc-brand-hover: #3a7cc6;
  --sc-brand-active: #275f9f;
  --sc-brand-tint: #14263d;
  --sc-brand-dark: #9cc3f5;
  --sc-brand-text: #7ab3f0;
  --sc-hover: #17324f;
  --sc-hover-text: #d3e8ff;
  --sc-page: #0e1318;
  --sc-header-bg: #161c23;
  --sc-surface: #161c23;
  --sc-surface-2: #1c242e;
  --sc-border: #2a3442;
  --sc-border-row: #232c38;
  --sc-input-border: #3a4656;
  --sc-text: #e6ebf2;
  --sc-text-2: #a9b4c3;
  --sc-muted: #8f9bab;
  --sc-focus: #7ab3f0;
  --sc-card-title: #e2e8f0;
  --sc-shadow-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 .25rem .75rem rgba(0, 0, 0, .18);
  --sc-shadow-md: 0 10px 28px rgba(0, 0, 0, .5);
  --sc-shadow-lg: 0 18px 48px rgba(0, 0, 0, .6);
  --sc-purple-text: #c5b0f0; --sc-purple-bg: #2c2142; --sc-purple-border: #4b3873;
  --sc-teal-text: #8fe0d6; --sc-teal-bg: #12302d; --sc-teal-border: #1f5550;
  --sc-orange-text: #ffb889; --sc-orange-bg: #3a2416; --sc-orange-border: #6b3d1f;
  --sc-pink-text: #f3a6c2; --sc-pink-bg: #3b1a27; --sc-pink-border: #6a2c45;
  --sc-chart-1: #3987e5; --sc-chart-2: #d95926; --sc-chart-3: #199e70; --sc-chart-4: #c98500;
  --sc-chart-5: #d55181; --sc-chart-6: #008300; --sc-chart-7: #9085e9; --sc-chart-8: #e66767;
  --sc-chart-muted: #7d8899; --sc-chart-grid: #263040; --sc-chart-axis: #3a4656; --sc-chart-text: #a9b4c3;
  --sc-chart-tip-bg: #222b38; --sc-chart-tip-fg: #e6ebf2; --sc-chart-tip-border: #3a4656;

  --bs-body-color: #e6ebf2; --bs-body-color-rgb: 230, 235, 242;
  --bs-body-bg: #161c23; --bs-body-bg-rgb: 22, 28, 35;
  --bs-emphasis-color: #fff; --bs-emphasis-color-rgb: 255, 255, 255;
  --bs-secondary-color: #a9b4c3; --bs-secondary-color-rgb: 169, 180, 195;
  --bs-tertiary-color: #8f9bab; --bs-tertiary-color-rgb: 143, 155, 171;
  --bs-secondary-bg: #222b38; --bs-secondary-bg-rgb: 34, 43, 56;
  --bs-tertiary-bg: #1c242e; --bs-tertiary-bg-rgb: 28, 36, 46;
  --bs-heading-color: #f1f4f8;
  --bs-border-color: #2a3442;
  --bs-border-color-translucent: rgba(255, 255, 255, .1);
  --bs-primary: #2f6fb8; --bs-primary-rgb: 47, 111, 184;
  --bs-primary-text-emphasis: #9cc3f5; --bs-primary-bg-subtle: #14263d; --bs-primary-border-subtle: #24456f;
  --bs-secondary-text-emphasis: #c4cdd8; --bs-secondary-bg-subtle: #1f2733; --bs-secondary-border-subtle: #334052;
  --bs-link-color: #7ab3f0; --bs-link-color-rgb: 122, 179, 240;
  --bs-link-hover-color: #a3cbf6; --bs-link-hover-color-rgb: 163, 203, 246;
  --bs-focus-ring-color: rgba(122, 179, 240, .4);
}

/* ================================================================ พื้นฐาน/ตัวอักษร */
html { scroll-padding-top: calc(var(--sc-topbar-h) + .75rem); }
body { font-family: var(--bs-font-sans-serif); background-color: var(--sc-page); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { line-height: 1.35; }
::placeholder { color: var(--sc-muted) !important; opacity: 1; }
.min-w-0 { min-width: 0; }
.fs-7 { font-size: .8125rem; }
.cursor-pointer { cursor: pointer; }
.tabular, .text-end, .table td, .table th, .kpi-value, .font-monospace { font-variant-numeric: tabular-nums; }
.text-primary { color: var(--sc-brand-text) !important; }
/* โหมดมืด: สีข้อความสถานะใช้โทนสว่าง (สีเดิมของ Bootstrap มืดเกินบนพื้นมืด) */
[data-bs-theme="dark"] .text-success { color: var(--bs-success-text-emphasis) !important; }
[data-bs-theme="dark"] .text-danger { color: var(--bs-danger-text-emphasis) !important; }
[data-bs-theme="dark"] .text-warning { color: var(--bs-warning-text-emphasis) !important; }
[data-bs-theme="dark"] .text-info { color: var(--bs-info-text-emphasis) !important; }
[data-bs-theme="dark"] .text-secondary { color: var(--bs-secondary-color) !important; }
.link-primary { color: var(--sc-brand-text) !important; }
.link-primary:focus, .link-primary:hover { color: var(--bs-link-hover-color) !important; text-decoration-color: var(--bs-link-hover-color) !important; }
kbd { background: var(--bs-secondary-bg); color: var(--bs-body-color); border: 1px solid var(--sc-border); box-shadow: inset 0 -1px 0 var(--sc-border); font-size: .75rem; padding: .05rem .35rem; border-radius: .3rem; }
/* แถบเลื่อนบาง ๆ แบบ perfect-scrollbar ของเทมเพลต (ในกรอบที่เลื่อนได้ เช่น เมนู รายการแจ้งเตือน ตาราง) */
* { scrollbar-width: thin; scrollbar-color: rgba(var(--bs-body-color-rgb), .22) transparent; }
html { scrollbar-width: auto; } /* แถบเลื่อนของทั้งหน้าคงขนาดปกติ (จับง่าย) — แบบบางเฉพาะกรอบที่เลื่อนในหน้า */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(var(--bs-body-color-rgb), .2); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(var(--bs-body-color-rgb), .35); }
::-webkit-scrollbar-track { background: transparent; }

/* โฟกัสจากแป้นพิมพ์มองเห็นชัดทุกที่ (เส้น 2px สีหลัก) — เมาส์คลิกไม่แสดง (:focus-visible) */
:where(a, button, summary, [tabindex], [role="button"]):focus-visible { outline: 2px solid var(--sc-focus); outline-offset: 2px; }
.btn:focus-visible, .btn-check:focus-visible + .btn { outline: 2px solid var(--sc-focus); outline-offset: 2px; box-shadow: none; }
.nav-link:focus-visible { outline: 2px solid var(--sc-focus); outline-offset: -2px; box-shadow: none; }
.dropdown-item:focus-visible, .list-group-item-action:focus-visible { outline: 2px solid var(--sc-focus); outline-offset: -2px; }
.page-link:focus { box-shadow: none; }
.page-link:focus-visible { outline: 2px solid var(--sc-focus); outline-offset: 1px; z-index: 3; }
.skip-link { position: fixed; left: .75rem; top: .6rem; z-index: 2000; transform: translateY(-250%); background: var(--sc-brand); color: #fff; padding: .5rem 1rem;
  border-radius: .5rem; font-weight: 600; text-decoration: none; box-shadow: var(--sc-shadow-md); transition: transform .15s ease; }
.skip-link:focus, .skip-link:focus-visible { transform: none; color: #fff; outline: 2px solid #fff; outline-offset: 2px; }
main:focus { outline: 0; }

/* ================================================================ ปุ่ม/ฟอร์ม/คอมโพเนนต์ Bootstrap → สีหลักเดียว + เงาแบบ ArchitectUI */
.btn { --bs-btn-font-weight: 500; transition: color .15s, background-color .15s, border-color .15s, box-shadow .15s; }
.btn-primary { --bs-btn-bg: var(--sc-brand); --bs-btn-border-color: var(--sc-brand); --bs-btn-hover-bg: var(--sc-brand-hover); --bs-btn-hover-border-color: var(--sc-brand-hover);
  --bs-btn-focus-shadow-rgb: var(--sc-brand-rgb); --bs-btn-active-bg: var(--sc-brand-active); --bs-btn-active-border-color: var(--sc-brand-active);
  --bs-btn-disabled-bg: var(--sc-brand); --bs-btn-disabled-border-color: var(--sc-brand); }
.btn-outline-primary { --bs-btn-color: var(--sc-brand-text); --bs-btn-border-color: var(--sc-brand); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--sc-brand);
  --bs-btn-hover-border-color: var(--sc-brand); --bs-btn-focus-shadow-rgb: var(--sc-brand-rgb); --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--sc-brand-active);
  --bs-btn-active-border-color: var(--sc-brand-active); --bs-btn-disabled-color: var(--sc-brand-text); --bs-btn-disabled-border-color: var(--sc-brand); }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-border-color: #4b84c6; }
.btn-outline-secondary { --bs-btn-color: var(--sc-text-2); --bs-btn-border-color: var(--sc-input-border); --bs-btn-hover-color: var(--sc-text); --bs-btn-hover-bg: var(--bs-tertiary-bg);
  --bs-btn-hover-border-color: #9aa5b4; --bs-btn-focus-shadow-rgb: var(--sc-brand-rgb); --bs-btn-active-color: var(--sc-text); --bs-btn-active-bg: var(--bs-secondary-bg);
  --bs-btn-active-border-color: #9aa5b4; --bs-btn-disabled-color: var(--sc-muted); --bs-btn-disabled-border-color: var(--sc-border); }
[data-bs-theme="dark"] .btn-outline-secondary { --bs-btn-hover-border-color: #56657a; --bs-btn-active-border-color: #56657a; }
.btn-link { --bs-btn-color: var(--sc-brand-text); --bs-btn-focus-shadow-rgb: var(--sc-brand-rgb); }
/* สีเตือน (เหลือง #ffc107 = 1.6:1) และสีข้อมูล (ฟ้า #0dcaf0 = 1.9:1) ของ Bootstrap อ่านไม่ออกบนพื้นขาว — โหมดสว่างใช้โทนเข้ม
   (ข้อความ ≥ 4.5:1 · เส้นขอบ/ไอคอน ≥ 3:1) · โหมดมืดคงสีของ Bootstrap (สว่างบนพื้นมืด อ่านได้อยู่แล้ว) */
[data-bs-theme="light"] .btn-outline-warning { --bs-btn-color: #8f6a00; --bs-btn-border-color: #b98200; --bs-btn-hover-color: #1b2430; --bs-btn-hover-bg: #ffc107;
  --bs-btn-hover-border-color: #ffc107; --bs-btn-active-color: #1b2430; --bs-btn-active-bg: #f0b400; --bs-btn-active-border-color: #f0b400;
  --bs-btn-disabled-color: #8f6a00; --bs-btn-disabled-border-color: #b98200; }
[data-bs-theme="light"] .btn-outline-info { --bs-btn-color: #0b7285; --bs-btn-border-color: #1098ad; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #0b7285;
  --bs-btn-hover-border-color: #0b7285; --bs-btn-active-color: #fff; --bs-btn-active-bg: #095c6b; --bs-btn-active-border-color: #095c6b;
  --bs-btn-disabled-color: #0b7285; --bs-btn-disabled-border-color: #1098ad; }
[data-bs-theme="light"] .text-warning { color: #8f6a00 !important; }
[data-bs-theme="light"] .bi.text-warning { color: #b98200 !important; }
[data-bs-theme="light"] .text-info { color: #0b7285 !important; }
.btn-light { --bs-btn-bg: #eef1f5; --bs-btn-border-color: #dde2e8; --bs-btn-hover-bg: #e2e7ed; --bs-btn-hover-border-color: #cfd6de; --bs-btn-active-bg: #d9dfe6; }
[data-bs-theme="dark"] .btn-light { --bs-btn-color: var(--sc-text); --bs-btn-bg: #222b38; --bs-btn-border-color: #2a3442; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #2a3442;
  --bs-btn-hover-border-color: #3a4656; --bs-btn-active-color: #fff; --bs-btn-active-bg: #2a3442; --bs-btn-active-border-color: #3a4656;
  --bs-btn-disabled-color: var(--sc-muted); --bs-btn-disabled-bg: #222b38; --bs-btn-disabled-border-color: #2a3442; }
/* ปุ่มสีทึบมีเงาสีเดียวกับปุ่ม (.btn-shadow ของเทมเพลต) — ชี้แล้วเงาเข้มขึ้น · กดค้าง/ปิดใช้งาน/ปุ่มในกลุ่มเลือก ไม่มีเงา */
.btn-primary { --sc-btn-glow: var(--sc-brand-rgb); }
.btn-success { --sc-btn-glow: 25, 135, 84; } .btn-danger { --sc-btn-glow: 220, 53, 69; } .btn-warning { --sc-btn-glow: 255, 193, 7; }
.btn-info { --sc-btn-glow: 13, 202, 240; } .btn-dark { --sc-btn-glow: 33, 37, 41; } .btn-secondary { --sc-btn-glow: 108, 117, 125; }
:is(.btn-primary, .btn-success, .btn-danger, .btn-warning, .btn-info, .btn-dark, .btn-secondary):not(:disabled):not(.disabled):not(:active):not(.active) {
  box-shadow: 0 .125rem .625rem rgba(var(--sc-btn-glow), .38), 0 .0625rem .125rem rgba(var(--sc-btn-glow), .45); }
:is(.btn-primary, .btn-success, .btn-danger, .btn-warning, .btn-info, .btn-dark, .btn-secondary):not(:disabled):not(.disabled):not(:active):not(.active):hover {
  box-shadow: 0 .25rem .9rem rgba(var(--sc-btn-glow), .45), 0 .0625rem .1875rem rgba(var(--sc-btn-glow), .55); }
.btn-group > .btn, .btn-group-vertical > .btn, .input-group > .btn { box-shadow: none !important; }
:is(.btn-primary, .btn-success, .btn-danger, .btn-dark):active { box-shadow: inset 0 2px 4px rgba(0, 0, 0, .15); }
[data-bs-theme="dark"] :is(.btn-primary, .btn-success, .btn-danger, .btn-warning, .btn-info, .btn-dark, .btn-secondary):not(:disabled):not(:active) { box-shadow: 0 1px 2px rgba(0, 0, 0, .4) !important; }
.btn-pill { border-radius: 50rem !important; }
.btn-wide { padding-left: 1.5rem; padding-right: 1.5rem; }

.form-control, .form-select { border-color: var(--sc-input-border); }
.form-control:focus, .form-select:focus { border-color: #2a78c9; box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
[data-bs-theme="dark"] .form-control:focus, [data-bs-theme="dark"] .form-select:focus { border-color: var(--sc-focus); }
/* ช่องเลือกในคอลัมน์แคบ (col-md-2 เช่น คำนำหน้า หมู่เลือด) — ลด padding/ย้ายลูกศรชิดขวา ข้อความยาวอย่าง "นางสาว" "เด็กหญิง" ไม่ถูกตัด */
.form-select.form-select-compact { padding-left: .5rem; padding-right: 1.5rem; background-position: right .4rem center; }
.form-control[readonly]:not([type="search"]) { background-color: var(--sc-surface-2); }
.form-check-input { border-color: var(--sc-input-border); }
.form-check-input:focus { border-color: var(--sc-brand); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.form-check-input:checked, .form-check-input[type="checkbox"]:indeterminate { background-color: var(--sc-brand); border-color: var(--sc-brand); }
.form-switch .form-check-input:focus { --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%237f9db9'/%3e%3c/svg%3e"); }
.form-switch .form-check-input:checked { --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e"); }
.form-range::-webkit-slider-thumb { background-color: var(--sc-brand); }
.form-range::-moz-range-thumb { background-color: var(--sc-brand); }
.form-range:focus::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--bs-body-bg), 0 0 0 .2rem var(--bs-focus-ring-color); }
.form-range:focus::-moz-range-thumb { box-shadow: 0 0 0 1px var(--bs-body-bg), 0 0 0 .2rem var(--bs-focus-ring-color); }
.input-group-text { background-color: #eef6fb; border-color: var(--sc-input-border); color: var(--bs-secondary-color); } /* $input-group-addon-bg */
[data-bs-theme="dark"] .input-group-text { background-color: var(--sc-surface-2); }
.form-label { font-size: .875rem; font-weight: 500; margin-bottom: .3rem; }
.filter-form .form-label { font-size: .8125rem; color: var(--bs-secondary-color); }
.form-text { color: var(--bs-secondary-color); }

/* เมนูแบบหล่น: ไร้เส้นขอบ เงานุ่ม ชี้แล้วพื้นฟ้าอ่อน (โหมดมืดมีเส้นขอบ — เงาบนพื้นมืดมองไม่เห็น) */
.dropdown-menu { --bs-dropdown-min-width: 13rem; --bs-dropdown-padding-y: .5rem; --bs-dropdown-border-width: 0; --bs-dropdown-border-color: var(--sc-border);
  --bs-dropdown-box-shadow: var(--sc-shadow-md); --bs-dropdown-border-radius: .375rem; --bs-dropdown-inner-border-radius: .375rem;
  --bs-dropdown-link-hover-bg: var(--sc-hover); --bs-dropdown-link-hover-color: var(--sc-hover-text); --bs-dropdown-link-active-bg: var(--sc-brand);
  --bs-dropdown-font-size: .9375rem; --bs-dropdown-item-padding-y: .4rem; --bs-dropdown-item-padding-x: 1.1rem; --bs-dropdown-header-color: var(--sc-brand-text);
  box-shadow: var(--bs-dropdown-box-shadow); }
[data-bs-theme="dark"] .dropdown-menu { --bs-dropdown-border-width: 1px; }
.dropdown-header { font-size: .8125rem; font-weight: 700; }
.dropdown-item { border-radius: 0; transition: background-color .15s, color .15s; }
.dropdown-toggle::after { position: relative; top: 2px; opacity: .8; }
.nav-pills { --bs-nav-pills-link-active-bg: var(--sc-brand); --bs-nav-pills-border-radius: .25rem; }
.nav-pills .nav-link.active { box-shadow: 0 .125rem .625rem rgba(var(--sc-brand-rgb), .3); }
.pagination { --bs-pagination-color: var(--sc-brand-text); --bs-pagination-hover-color: var(--sc-hover-text); --bs-pagination-hover-bg: var(--sc-hover); --bs-pagination-focus-color: var(--bs-link-hover-color);
  --bs-pagination-border-color: var(--sc-border); --bs-pagination-active-bg: var(--sc-brand); --bs-pagination-active-border-color: var(--sc-brand);
  --bs-pagination-focus-box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); --bs-pagination-disabled-color: var(--sc-muted); }
.progress, .progress-stacked { --bs-progress-bar-bg: var(--sc-brand); --bs-progress-bg: var(--bs-secondary-bg); }
.list-group { --bs-list-group-active-bg: var(--sc-brand); --bs-list-group-active-border-color: var(--sc-brand); --bs-list-group-border-color: rgba(var(--sc-brand-rgb), .1);
  --bs-list-group-action-hover-bg: var(--sc-hover); --bs-list-group-action-hover-color: var(--sc-hover-text); }
[data-bs-theme="dark"] .list-group { --bs-list-group-border-color: var(--sc-border); }
.accordion { --bs-accordion-border-color: var(--sc-border); --bs-accordion-btn-focus-box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color);
  --bs-accordion-active-color: var(--bs-primary-text-emphasis); --bs-accordion-active-bg: var(--bs-primary-bg-subtle); }
.btn-close { --bs-btn-close-focus-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
/* กล่องโต้ตอบ: หัว/ท้ายพื้นเทาอ่อน เงาลึก (ไร้เส้นขอบ) */
.modal { --bs-modal-border-width: 0; --bs-modal-border-color: var(--sc-border); --bs-modal-border-radius: .5rem; --bs-modal-inner-border-radius: .5rem;
  --bs-modal-box-shadow: var(--sc-shadow-lg); --bs-modal-header-border-color: var(--sc-border); --bs-modal-footer-border-color: var(--sc-border); }
.modal-content { box-shadow: var(--bs-modal-box-shadow); }
.modal-header, .modal-footer { background: var(--sc-surface-2); }
[data-bs-theme="dark"] .modal { --bs-modal-border-width: 1px; }
.modal-title { font-size: 1.125rem; font-weight: 600; }
.modal-backdrop { --bs-backdrop-bg: #0b1626; --bs-backdrop-opacity: .45; }
.alert { --bs-alert-border-radius: .375rem; }
.toast { --bs-toast-border-radius: .375rem; --bs-toast-box-shadow: var(--sc-shadow-md); }
.popover { --bs-popover-border-color: rgba(26, 54, 126, .125); --bs-popover-box-shadow: var(--sc-shadow-md); }
.tooltip { --bs-tooltip-bg: #1f2a37; --bs-tooltip-border-radius: .3rem; }
.table-primary { --bs-table-color: var(--bs-body-color); --bs-table-bg: var(--bs-primary-bg-subtle); --bs-table-border-color: var(--bs-primary-border-subtle); }
[data-bs-theme="dark"] .table-light { --bs-table-color: var(--bs-body-color); --bs-table-bg: var(--sc-surface-2); --bs-table-border-color: var(--sc-border); }
[data-bs-theme="dark"] .table-secondary { --bs-table-color: var(--bs-body-color); --bs-table-bg: var(--bs-secondary-bg-subtle); --bs-table-border-color: var(--bs-secondary-border-subtle); }
[data-bs-theme="dark"] .table-success { --bs-table-color: var(--bs-body-color); --bs-table-bg: var(--bs-success-bg-subtle); --bs-table-border-color: var(--bs-success-border-subtle); }
[data-bs-theme="dark"] .table-danger { --bs-table-color: var(--bs-body-color); --bs-table-bg: var(--bs-danger-bg-subtle); --bs-table-border-color: var(--bs-danger-border-subtle); }
[data-bs-theme="dark"] .table-warning { --bs-table-color: var(--bs-body-color); --bs-table-bg: var(--bs-warning-bg-subtle); --bs-table-border-color: var(--bs-warning-border-subtle); }
[data-bs-theme="dark"] .table-info { --bs-table-color: var(--bs-body-color); --bs-table-bg: var(--bs-info-bg-subtle); --bs-table-border-color: var(--bs-info-border-subtle); }
[data-bs-theme="dark"] .text-bg-light { color: var(--sc-text) !important; background-color: #2a3442 !important; }

/* ================================================================ badge / สีเพิ่ม */
/* badge(): สถานะงานทั่วไปเป็นสีอ่อน (badge-soft) · คัดแยก/ผลวิกฤต/แพ้ยา/แยกโรค และสีแดง (danger) เป็นสีทึบเสมอ (app/labels.php) */
.badge { --bs-badge-font-size: max(.75rem, .78em); --bs-badge-font-weight: 600; --bs-badge-padding-y: .3em; --bs-badge-padding-x: .6em;
  --bs-badge-border-radius: .375rem; line-height: 1.25; letter-spacing: 0; }
.text-bg-purple { color: #fff !important; background-color: var(--sc-purple) !important; }
.text-bg-teal { color: #fff !important; background-color: var(--sc-teal) !important; }
.text-bg-orange { color: #fff !important; background-color: var(--sc-orange) !important; }
.text-bg-pink { color: #fff !important; background-color: var(--sc-pink) !important; }
.bg-purple-subtle { background-color: var(--sc-purple-bg) !important; } .text-purple-emphasis { color: var(--sc-purple-text) !important; }
.bg-teal-subtle { background-color: var(--sc-teal-bg) !important; } .text-teal-emphasis { color: var(--sc-teal-text) !important; }
.bg-orange-subtle { background-color: var(--sc-orange-bg) !important; } .text-orange-emphasis { color: var(--sc-orange-text) !important; }
.bg-pink-subtle { background-color: var(--sc-pink-bg) !important; } .text-pink-emphasis { color: var(--sc-pink-text) !important; }
.bg-purple { background-color: var(--sc-purple) !important; } .bg-teal { background-color: var(--sc-teal) !important; }
.bg-orange { background-color: var(--sc-orange) !important; } .bg-pink { background-color: var(--sc-pink) !important; }
.badge.badge-soft { box-shadow: inset 0 0 0 1px var(--sc-badge-line, transparent); }
.badge-soft.text-bg-primary { color: var(--bs-primary-text-emphasis) !important; background-color: var(--bs-primary-bg-subtle) !important; --sc-badge-line: var(--bs-primary-border-subtle); }
.badge-soft.text-bg-secondary { color: var(--bs-secondary-text-emphasis) !important; background-color: var(--bs-secondary-bg-subtle) !important; --sc-badge-line: var(--bs-secondary-border-subtle); }
.badge-soft.text-bg-success { color: var(--bs-success-text-emphasis) !important; background-color: var(--bs-success-bg-subtle) !important; --sc-badge-line: var(--bs-success-border-subtle); }
.badge-soft.text-bg-info { color: var(--bs-info-text-emphasis) !important; background-color: var(--bs-info-bg-subtle) !important; --sc-badge-line: var(--bs-info-border-subtle); }
.badge-soft.text-bg-warning { color: var(--bs-warning-text-emphasis) !important; background-color: var(--bs-warning-bg-subtle) !important; --sc-badge-line: var(--bs-warning-border-subtle); }
.badge-soft.text-bg-danger { color: var(--bs-danger-text-emphasis) !important; background-color: var(--bs-danger-bg-subtle) !important; --sc-badge-line: var(--bs-danger-border-subtle); }
.badge-soft.text-bg-dark { color: var(--bs-dark-text-emphasis) !important; background-color: var(--bs-dark-bg-subtle) !important; --sc-badge-line: var(--bs-dark-border-subtle); }
.badge-soft.text-bg-light { color: var(--bs-body-color) !important; background-color: var(--sc-surface-2) !important; --sc-badge-line: var(--sc-border); }
.badge-soft.text-bg-purple { color: var(--sc-purple-text) !important; background-color: var(--sc-purple-bg) !important; --sc-badge-line: var(--sc-purple-border); }
.badge-soft.text-bg-teal { color: var(--sc-teal-text) !important; background-color: var(--sc-teal-bg) !important; --sc-badge-line: var(--sc-teal-border); }
.badge-soft.text-bg-orange { color: var(--sc-orange-text) !important; background-color: var(--sc-orange-bg) !important; --sc-badge-line: var(--sc-orange-border); }
.badge-soft.text-bg-pink { color: var(--sc-pink-text) !important; background-color: var(--sc-pink-bg) !important; --sc-badge-line: var(--sc-pink-border); }
.badge.badge-zero { opacity: .55; }

/* ================================================================ สีประจำกลุ่มเมนู (body[data-mod] — app/layout.php layout_menu_match) */
/* แต่ละกลุ่มเมนูมีสีของตัวเอง + สีไล่ระดับแบบ ArchitectUI (--sc-mod-grad: ไอคอนในกล่องหัวเรื่อง ไอคอนหัวการ์ด): แท็บที่เลือก หัวตาราง สถานะว่าง ไอคอนกลุ่มในเมนูด้านซ้าย
   — ผู้ใช้รู้ว่าอยู่งานไหนจากสี · ปุ่มหลัก/ลิงก์/โฟกัสคงสีหลักเดียว (--sc-brand) ทุกกลุ่ม · ข้อความบนพื้นอ่อน ≥ 4.5:1 ทั้งโหมดสว่าง/มืด */
:root, [data-bs-theme="light"] {
  --sc-mod: var(--sc-brand); --sc-mod-text: var(--sc-brand-text); --sc-mod-bg: var(--sc-brand-tint); --sc-mod-border: var(--bs-primary-border-subtle);
  --sc-mod-a: #1e3c72; --sc-mod-b: #2a78c9;
  --sc-m-home: #1d5fa8;  --sc-m-home-t: #174f8c; --sc-m-home-b: #e8f0fa; --sc-m-home-l: #b9d0ec;
  --sc-m-g1: #2563eb;    --sc-m-g1-t: #1e40af;   --sc-m-g1-b: #e3ebff;   --sc-m-g1-l: #bccdfb;
  --sc-m-g2: #0f766e;    --sc-m-g2-t: #0b5d56;   --sc-m-g2-b: #d5f2ef;   --sc-m-g2-l: #a6ded8;
  --sc-m-ipd: #4f46e5;   --sc-m-ipd-t: #3730a3;  --sc-m-ipd-b: #e5e7ff;  --sc-m-ipd-l: #c3c6fb;
  --sc-m-g3: #7c3aed;    --sc-m-g3-t: #5b21b6;   --sc-m-g3-b: #efe6fd;   --sc-m-g3-l: #d6c3f8;
  --sc-m-g4: #c2410c;    --sc-m-g4-t: #9a3b07;   --sc-m-g4-b: #ffe9da;   --sc-m-g4-l: #fdc9a6;
  --sc-m-g5: #15803d;    --sc-m-g5-t: #166534;   --sc-m-g5-b: #dff5e6;   --sc-m-g5-l: #a8dcb9;
  --sc-m-g6: #be185d;    --sc-m-g6-t: #9d174d;   --sc-m-g6-b: #fce4ee;   --sc-m-g6-l: #f4b5cf;
  --sc-m-g7: #b45309;    --sc-m-g7-t: #8a4b0a;   --sc-m-g7-b: #fdf0d2;   --sc-m-g7-l: #f3d189;
  --sc-m-g8: #0e7490;    --sc-m-g8-t: #0b5563;   --sc-m-g8-b: #d9f2f7;   --sc-m-g8-l: #a5dbe6;
  --sc-m-sys: #475569;   --sc-m-sys-t: #334155;  --sc-m-sys-b: #e8ecf2;  --sc-m-sys-l: #cdd5df;
}
[data-bs-theme="dark"] {
  --sc-m-home: #5b9be6;  --sc-m-home-t: #9cc3f5; --sc-m-home-b: #14263d; --sc-m-home-l: #24456f;
  --sc-m-g1: #6d9bff;    --sc-m-g1-t: #a9c3ff;   --sc-m-g1-b: #16233f;   --sc-m-g1-l: #29416f;
  --sc-m-g2: #2bb3a5;    --sc-m-g2-t: #8fe0d6;   --sc-m-g2-b: #12302d;   --sc-m-g2-l: #1f5550;
  --sc-m-ipd: #8b85f5;   --sc-m-ipd-t: #c0bcfb;  --sc-m-ipd-b: #1f1f45;  --sc-m-ipd-l: #383a7a;
  --sc-m-g3: #a78bfa;    --sc-m-g3-t: #cbb8fc;   --sc-m-g3-b: #2a1f45;   --sc-m-g3-l: #4b3873;
  --sc-m-g4: #f08a4b;    --sc-m-g4-t: #ffb889;   --sc-m-g4-b: #3a2416;   --sc-m-g4-l: #6b3d1f;
  --sc-m-g5: #4ade80;    --sc-m-g5-t: #9be7b4;   --sc-m-g5-b: #13301d;   --sc-m-g5-l: #23573a;
  --sc-m-g6: #f472b6;    --sc-m-g6-t: #f6a8cd;   --sc-m-g6-b: #3b1a2a;   --sc-m-g6-l: #6a2c48;
  --sc-m-g7: #f0b44c;    --sc-m-g7-t: #f6cf85;   --sc-m-g7-b: #352610;   --sc-m-g7-l: #6b4d19;
  --sc-m-g8: #38bdd8;    --sc-m-g8-t: #91dcec;   --sc-m-g8-b: #0f2d35;   --sc-m-g8-l: #1d5462;
  --sc-m-sys: #94a3b8;   --sc-m-sys-t: #c4cdd8;  --sc-m-sys-b: #1f2733;  --sc-m-sys-l: #334052;
}
/* สีไล่ระดับต่อกลุ่ม (ปลายทั้งสองข้างเข้มพอบนพื้นขาว — ไอคอนตกแต่งข้างข้อความ) ใกล้เคียงชุด bg-* ของเทมเพลต:
   night-sky · happy-fisher · grow-early · plum-plate · mixed-hopes · sunny-morning · happy-green · ripe-malin · amber · arielle-smile · vicious-stance */
body[data-mod="home"] { --sc-mod: var(--sc-m-home); --sc-mod-text: var(--sc-m-home-t); --sc-mod-bg: var(--sc-m-home-b); --sc-mod-border: var(--sc-m-home-l); --sc-mod-a: #1e3c72; --sc-mod-b: #2a78c9; }
body[data-mod="g1"] { --sc-mod: var(--sc-m-g1); --sc-mod-text: var(--sc-m-g1-t); --sc-mod-bg: var(--sc-m-g1-b); --sc-mod-border: var(--sc-m-g1-l); --sc-mod-a: #1d4ed8; --sc-mod-b: #0891c9; }
body[data-mod="g2"] { --sc-mod: var(--sc-m-g2); --sc-mod-text: var(--sc-m-g2-t); --sc-mod-bg: var(--sc-m-g2-b); --sc-mod-border: var(--sc-m-g2-l); --sc-mod-a: #0b7a55; --sc-mod-b: #0e9488; }
body[data-mod="ipd"] { --sc-mod: var(--sc-m-ipd); --sc-mod-text: var(--sc-m-ipd-t); --sc-mod-bg: var(--sc-m-ipd-b); --sc-mod-border: var(--sc-m-ipd-l); --sc-mod-a: #5a67d8; --sc-mod-b: #764ba2; }
body[data-mod="g3"] { --sc-mod: var(--sc-m-g3); --sc-mod-text: var(--sc-m-g3-t); --sc-mod-bg: var(--sc-m-g3-b); --sc-mod-border: var(--sc-m-g3-l); --sc-mod-a: #7c3aed; --sc-mod-b: #c026d3; }
body[data-mod="g4"] { --sc-mod: var(--sc-m-g4); --sc-mod-text: var(--sc-m-g4-t); --sc-mod-bg: var(--sc-m-g4-b); --sc-mod-border: var(--sc-m-g4-l); --sc-mod-a: #c2410c; --sc-mod-b: #e8590c; }
body[data-mod="g5"] { --sc-mod: var(--sc-m-g5); --sc-mod-text: var(--sc-m-g5-t); --sc-mod-bg: var(--sc-m-g5-b); --sc-mod-border: var(--sc-m-g5-l); --sc-mod-a: #00806f; --sc-mod-b: #4d7c0f; }
body[data-mod="g6"], body[data-mod="hrm"], body[data-mod="sup"] { --sc-mod: var(--sc-m-g6); --sc-mod-text: var(--sc-m-g6-t); --sc-mod-bg: var(--sc-m-g6-b); --sc-mod-border: var(--sc-m-g6-l); --sc-mod-a: #be185d; --sc-mod-b: #e11d48; }
body[data-mod="g7"] { --sc-mod: var(--sc-m-g7); --sc-mod-text: var(--sc-m-g7-t); --sc-mod-bg: var(--sc-m-g7-b); --sc-mod-border: var(--sc-m-g7-l); --sc-mod-a: #b45309; --sc-mod-b: #d97706; }
body[data-mod="g8"] { --sc-mod: var(--sc-m-g8); --sc-mod-text: var(--sc-m-g8-t); --sc-mod-bg: var(--sc-m-g8-b); --sc-mod-border: var(--sc-m-g8-l); --sc-mod-a: #0e7490; --sc-mod-b: #2b8fd6; }
body[data-mod="adm"], body[data-mod="sys"], body[data-mod="it"], body[data-mod="hosm"], body[data-mod="erpm"] { --sc-mod: var(--sc-m-sys); --sc-mod-text: var(--sc-m-sys-t); --sc-mod-bg: var(--sc-m-sys-b); --sc-mod-border: var(--sc-m-sys-l); --sc-mod-a: #29323c; --sc-mod-b: #536476; }
/* โหมดมืด: ไล่จากสีอ่อนของกลุ่มไปสีหลักของกลุ่ม (ค่าโหมดมืดสว่างพอบนพื้นมืด) */
[data-bs-theme="dark"] body { --sc-mod-a: var(--sc-mod-text); --sc-mod-b: var(--sc-mod); }
:root { --sc-mod-grad: linear-gradient(135deg, var(--sc-mod-a) 0%, var(--sc-mod-b) 100%); }
body { --sc-mod-grad: linear-gradient(135deg, var(--sc-mod-a) 0%, var(--sc-mod-b) 100%); }
/* ไอคอนไล่สี (.icon-gradient ของเทมเพลต) — ข้อความ/ไอคอนที่ต้องเห็นชัดใช้สีทึบตามเดิม */
.icon-gradient { background-image: var(--sc-mod-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: var(--sc-mod-text); }
/* ใช้สีประจำกลุ่ม: แท็บที่เลือก · หัวตาราง · แถบตัวกรอง · หัวข้อย่อยในฟอร์ม */
.filter-form { box-shadow: inset 3px 0 0 var(--sc-mod), var(--sc-shadow-sm) !important; }
.card-body h3.h6.border-bottom, .card-body .form-section-title { color: var(--sc-mod-text); border-bottom: 2px solid var(--sc-mod-border) !important; padding-bottom: .35rem !important; }
legend { font-size: 1rem; font-weight: 600; color: var(--sc-mod-text); }
/* ช่องกรอก: เส้นขอบเข้มขึ้นเมื่อชี้ (รู้ว่ากรอกได้) · แถบปุ่มบันทึกด้านล่างโปร่งแสง */
.form-control, .form-select { transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease; }
.form-control:hover:not(:focus):not(:disabled):not([readonly]), .form-select:hover:not(:focus):not(:disabled) { border-color: #8f9bab; }
[data-bs-theme="dark"] .form-control:hover:not(:focus):not(:disabled):not([readonly]), [data-bs-theme="dark"] .form-select:hover:not(:focus):not(:disabled) { border-color: #56657a; }
.sticky-actions { background: color-mix(in srgb, var(--bs-body-bg) 92%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
@media (prefers-reduced-motion: reduce) { .form-control, .form-select { transition: none; } }

/* =====================================================================
   โครงหน้า (ArchitectUI): .app-shell > .app-header (คงที่ด้านบน) + .app-sidebar (คงที่ด้านซ้าย) + .app-main (เนื้อหา + .app-footer)
   จอ < 992px: เมนูด้านซ้ายเลื่อนออกจากขอบ (ปุ่ม hamburger ซ้ายบน) · จอกว้าง: ย่อเมนูเหลือไอคอนได้ (html.sb-mini — ชี้/โฟกัส = กางชั่วคราว)
   ===================================================================== */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
@media (max-width: 991.98px) { :root { --sc-gutter: 1.25rem; } }
@media (max-width: 575.98px) { :root { --sc-gutter: .875rem; } }

/* ---------------------------------------------------------------- แถบหัว */
.app-header { position: fixed; inset: 0 0 auto 0; z-index: 1040; height: var(--sc-topbar-h); display: flex; align-items: center;
  background: var(--sc-header-bg); box-shadow: var(--sc-shadow-sm); transition: box-shadow .2s; }
[data-bs-theme="dark"] .app-header { box-shadow: 0 1px 0 var(--sc-border); }
.app-header__logo { position: relative; flex: 0 0 auto; width: var(--sc-sidebar-w); height: 100%; display: flex; align-items: center; gap: .5rem; padding: 0 .9rem 0 1.5rem;
  transition: width .2s ease, padding .2s ease, background .2s; }
.app-brand { display: flex; align-items: center; gap: .65rem; min-width: 0; color: var(--bs-heading-color); text-decoration: none; border-radius: .375rem; }
.app-brand img { width: 34px; height: 34px; flex: 0 0 auto; filter: drop-shadow(0 2px 4px rgba(3, 60, 115, .25)); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; font-size: 1.2rem; line-height: 1.15; color: var(--sc-brand-text); }
.brand-sub { font-size: .75rem; color: var(--bs-secondary-color); line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-brand:hover .brand-name { color: var(--bs-link-hover-color); }
.header__pane { margin-left: auto; flex: 0 0 auto; }
.app-header__content { flex: 1 1 auto; min-width: 0; height: 100%; display: flex; align-items: center; gap: .5rem; padding: 0 1.5rem 0 1.25rem; }
.app-header-left { display: flex; align-items: center; min-width: 0; flex: 1 1 auto; max-width: 30rem; }
.app-header-right { margin-left: auto; display: flex; align-items: center; gap: .4rem; flex: 0 0 auto; }

/* ปุ่ม hamburger (jonsuh/hamburgers แบบ elastic — MIT · สีหลัก) · มือถือ: [aria-expanded="true"] (เมนูเปิด) = เครื่องหมาย ✕ · ปุ่มย่อเมนูบนจอกว้างคงเป็นขีดสามเส้น */
.hamburger { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 2.6rem; height: 2.6rem; padding: 0; margin: 0;
  border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; transition: background-color .15s ease, opacity .15s; }
.hamburger:hover { background: var(--sc-hover); }
.hamburger[aria-pressed="true"] { background: rgba(var(--sc-brand-rgb), .08); }
.hamburger-box { width: 24px; height: 14px; display: inline-block; position: relative; }
.hamburger-inner { display: block; top: 50%; margin-top: -1px; }
.hamburger-inner, .hamburger-inner::before, .hamburger-inner::after { width: 24px; height: 2px; background-color: var(--sc-brand-text); border-radius: 10px;
  position: absolute; transition-property: transform; transition-duration: .15s; transition-timing-function: ease; }
.hamburger-inner::before, .hamburger-inner::after { content: ""; display: block; }
.hamburger-inner::before { top: -6px; }
.hamburger-inner::after { bottom: -6px; }
.hamburger--elastic .hamburger-inner { top: 1px; transition-duration: .275s; transition-timing-function: cubic-bezier(.68, -.55, .265, 1.55); }
.hamburger--elastic .hamburger-inner::before { top: 6px; transition: opacity .125s .275s ease; }
.hamburger--elastic .hamburger-inner::after { top: 12px; bottom: auto; transition: transform .275s cubic-bezier(.68, -.55, .265, 1.55); }
.hamburger--elastic:is(.is-active, [aria-expanded="true"]) .hamburger-inner { transform: translate3d(0, 6px, 0) rotate(135deg); transition-delay: .075s; }
.hamburger--elastic:is(.is-active, [aria-expanded="true"]) .hamburger-inner::before { transition-delay: 0s; opacity: 0; }
.hamburger--elastic:is(.is-active, [aria-expanded="true"]) .hamburger-inner::after { transform: translate3d(0, -12px, 0) rotate(-270deg); transition-delay: .075s; }
.hamburger:focus-visible { outline: 2px solid var(--sc-focus); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { .hamburger-inner, .hamburger-inner::before, .hamburger-inner::after { transition: none !important; } }

/* ช่องค้นหาผู้ป่วย (search-wrapper ของเทมเพลต — แบบกางตลอด: พื้นโปร่ง มุมมน ปุ่มแว่นวงกลม) */
.top-search { flex: 1 1 auto; min-width: 0; max-width: 30rem; }
.top-search .search-holder { position: relative; display: flex; align-items: center; width: 100%; height: 2.65rem; border-radius: 50rem; background: rgba(var(--sc-brand-rgb), .05);
  transition: background-color .2s, box-shadow .2s; }
.top-search .search-holder:hover { background: rgba(var(--sc-brand-rgb), .08); }
.top-search .search-holder:focus-within { background: var(--sc-surface); box-shadow: 0 0 0 1px rgba(var(--sc-brand-rgb), .35), 0 .25rem .75rem rgba(var(--sc-brand-rgb), .12); }
.top-search .search-input { flex: 1; min-width: 0; height: 100%; padding: 0 1rem 0 1.25rem; border: 0; outline: 0; background: transparent; color: var(--bs-body-color); font-size: .9rem; }
.top-search .search-input::-webkit-search-cancel-button { cursor: pointer; }
.top-search .search-icon { flex: 0 0 auto; width: 2.65rem; height: 2.65rem; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 50%;
  background: rgba(var(--sc-brand-rgb), .08); color: var(--sc-brand-text); font-size: 1.05rem; transition: background-color .2s, color .2s; }
.top-search .search-icon:hover, .top-search .search-holder:focus-within .search-icon { background: var(--sc-brand); color: #fff; }
[data-bs-theme="dark"] .top-search .search-holder { background: rgba(255, 255, 255, .06); }
[data-bs-theme="dark"] .top-search .search-holder:focus-within { background: var(--sc-surface-2); box-shadow: 0 0 0 1px var(--sc-input-border); }
[data-bs-theme="dark"] .top-search .search-icon { background: rgba(255, 255, 255, .08); }

/* ปุ่มไอคอนบนแถบหัว (header-dots: วงกลมพื้นสีจางตามหน้าที่ของปุ่ม) */
.topbar-btn { --hd: var(--sc-brand-text); position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 2.75rem; height: 2.75rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--hd); font-size: 1.2rem; line-height: 1; text-decoration: none; }
.topbar-btn::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--hd); opacity: .1; transition: opacity .2s; }
.topbar-btn:hover, .topbar-btn[aria-expanded="true"] { color: var(--hd); }
.topbar-btn:hover::before, .topbar-btn[aria-expanded="true"]::before { opacity: .2; }
.topbar-btn.hd-ntf { --hd: #c92a2a; } .topbar-btn.hd-theme { --hd: #5f3dc4; } .topbar-btn.hd-search { --hd: var(--sc-brand-text); }
[data-bs-theme="dark"] .topbar-btn.hd-ntf { --hd: #ff8787; } [data-bs-theme="dark"] .topbar-btn.hd-theme { --hd: #b197fc; }
.topbar-btn .ntf-count { position: absolute; top: .05rem; right: -.25rem; font-size: .7rem; padding: .25em .45em; line-height: 1.15; box-shadow: 0 0 0 2px var(--sc-header-bg); pointer-events: none; }
.topbar-btn .ntf-dot { position: absolute; top: .55rem; right: .6rem; width: .5rem; height: .5rem; border-radius: 50%; background: #e03131; box-shadow: 0 0 0 2px var(--sc-header-bg); }

/* ปุ่มสถานที่ทำงาน */
.unit-switch { max-width: 240px; }
.unit-chip { display: inline-flex; align-items: center; gap: .4rem; height: 2.5rem; max-width: 17rem; padding: 0 .9rem 0 .75rem; border: 0; border-radius: 50rem;
  background: rgba(var(--sc-brand-rgb), .07); color: var(--bs-body-color); font-size: .875rem; font-weight: 500; line-height: 1.45; white-space: nowrap; transition: background-color .2s, box-shadow .2s; }
.unit-chip > .bi-geo-alt-fill { color: var(--sc-brand-text); font-size: 1rem; }
.unit-chip:hover, .unit-chip[aria-expanded="true"] { background: var(--sc-hover); color: var(--sc-hover-text); }
[data-bs-theme="dark"] .unit-chip { background: rgba(255, 255, 255, .07); }
.unit-chip .unit-chip-caret { font-size: .75rem; opacity: .65; }
.unit-chip.is-static { pointer-events: none; }
.unit-menu { width: min(25rem, 94vw); padding: 0; overflow: hidden; }
.unit-menu-head { padding: .85rem 1.1rem .6rem; font-size: .8125rem; color: rgba(255, 255, 255, .8); line-height: 1.5; background: linear-gradient(to right, #141e30, #243b55); }
.unit-menu-head b { display: block; color: #fff; font-size: .9375rem; }
.unit-menu-head .text-info-emphasis { color: #9be7ff !important; }
.unit-menu-search { padding: .6rem .75rem .5rem; }
.unit-menu-list { max-height: min(55vh, 26rem); overflow-y: auto; padding-bottom: .35rem; border-top: 1px solid var(--sc-border); }
.unit-menu-list .dropdown-header { position: sticky; top: 0; z-index: 1; background: var(--bs-body-bg); padding-top: .55rem; }
.unit-menu-list .dropdown-item { white-space: normal; line-height: 1.45; }
.unit-menu-list .dropdown-item small { color: var(--bs-secondary-color); }
.unit-menu-list .dropdown-item.active small { color: rgba(255, 255, 255, .8); }
.unit-menu-foot { border-top: 1px solid var(--sc-border); padding: .25rem 0; background: var(--sc-surface-2); }
.theme-menu .dropdown-menu { min-width: 16rem; }
.theme-menu .dropdown-item .theme-check { visibility: hidden; margin-left: auto; }
.theme-menu .dropdown-item[aria-pressed="true"] .theme-check { visibility: visible; }
.theme-menu .dropdown-item[aria-pressed="true"] { font-weight: 600; }
/* ตัวเลือกสีแถบเมนู (Theme Options ของเทมเพลต): จุดสีตัวอย่าง */
.sb-swatches { display: grid; grid-template-columns: repeat(4, 2.1rem); gap: .5rem; padding: .35rem 1.1rem .6rem; }
.sb-swatch { position: relative; width: 2.1rem; height: 2.1rem; padding: 0; border-radius: 50%; border: 2px solid var(--sc-surface); box-shadow: 0 0 0 1px var(--sc-border), 0 .125rem .375rem rgba(0, 0, 0, .12);
  background: var(--sw); cursor: pointer; transition: transform .15s; }
.sb-swatch:hover { transform: scale(1.08); }
.sb-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--sc-brand), 0 .125rem .375rem rgba(0, 0, 0, .15); }
.sb-swatch[aria-pressed="true"]::after { content: '\F633'; font-family: bootstrap-icons; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem; text-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.sb-swatch[data-sb-theme-set="white"][aria-pressed="true"]::after { color: var(--sc-brand-text); text-shadow: none; }
.sb-swatch:focus-visible { outline: 2px solid var(--sc-focus); outline-offset: 2px; }

/* ผู้ใช้ (header-btn-lg + widget-content: รูป · ชื่อ · บทบาท) — เส้นคั่นแนวตั้งด้านซ้าย */
.header-btn-lg { position: relative; display: flex; align-items: center; margin-left: .5rem; padding-left: .85rem; }
.header-btn-lg::before { content: ''; position: absolute; left: 0; top: 50%; width: 1px; height: 30px; margin-top: -15px; background: var(--sc-border); }
.topbar-user { display: inline-flex; align-items: center; gap: .65rem; padding: .2rem .35rem .2rem .2rem; border: 0; border-radius: 50rem; background: transparent; color: var(--bs-body-color); line-height: 1.4; }
.topbar-user:hover, .topbar-user[aria-expanded="true"] { background: rgba(var(--sc-brand-rgb), .06); }
.topbar-user .avatar { width: 2.6rem; height: 2.6rem; font-size: .95rem; box-shadow: 0 0 0 2px var(--sc-header-bg), 0 0 0 3px rgba(var(--sc-brand-rgb), .18); }
.header-user-info { display: flex; flex-direction: column; text-align: left; min-width: 0; }
.widget-heading { font-weight: 700; font-size: .875rem; color: var(--bs-heading-color); }
.widget-subheading { font-size: .75rem; color: var(--bs-secondary-color); }
.topbar-user-role { font-size: .75rem; color: var(--bs-secondary-color); }
.user-menu { width: 20rem; max-width: 94vw; padding-top: 0; overflow: hidden; }
.ntf-menu { width: 22.5rem; max-width: 94vw; padding: 0; overflow: hidden; }
/* หัวเมนูแบบรูปพื้นหลัง + สีไล่ระดับ (dropdown-menu-header ของเทมเพลต) */
.dropdown-menu-header { position: relative; overflow: hidden; color: #fff; margin-bottom: .4rem; }
.dropdown-menu-header-inner { position: relative; padding: 1.1rem 1.25rem; background: linear-gradient(-20deg, #2b5876 0%, #4e4376 100%); }
.dropdown-menu-header-inner.hdr-ntf { background: linear-gradient(to right, #141e30, #243b55); padding: .8rem 1.1rem; }
.menu-header-image { position: absolute; inset: 0; z-index: 0; background: url('../img/bg/abstract2.jpg') center / cover no-repeat; opacity: .28; mix-blend-mode: luminosity; }
.menu-header-content { position: relative; z-index: 1; display: flex; align-items: center; gap: .85rem; min-width: 0; }
.menu-header-content .avatar { width: 3.25rem; height: 3.25rem; font-size: 1.15rem; box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); }
.menu-header-title { font-weight: 700; font-size: 1rem; line-height: 1.35; overflow-wrap: anywhere; }
.menu-header-subtitle { font-size: .8125rem; opacity: .85; line-height: 1.45; overflow-wrap: anywhere; }
.menu-header-content a { color: #fff; }
.menu-header-content .btn-light-soft { --bs-btn-color: #fff; --bs-btn-bg: rgba(255, 255, 255, .14); --bs-btn-border-color: rgba(255, 255, 255, .25);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: rgba(255, 255, 255, .26); --bs-btn-hover-border-color: rgba(255, 255, 255, .4); --bs-btn-active-bg: rgba(255, 255, 255, .3); }
.user-menu .dropdown-item > .bi:first-child { width: 1.4rem; display: inline-block; color: var(--sc-brand-text); opacity: .75; }
.user-menu .dropdown-item:hover > .bi:first-child { opacity: 1; }
.user-menu .dropdown-item.text-danger > .bi:first-child { color: inherit; }
.demo-pill { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .7rem; border-radius: 50rem; font-size: .75rem; font-weight: 700; line-height: 1.45;
  color: #7a2e00; border: 1px solid #f5b26b; white-space: nowrap; background: repeating-linear-gradient(-45deg, #ffe8c7 0 8px, #ffd9a3 8px 16px); }
[data-bs-theme="dark"] .demo-pill { color: #ffd8a8; border-color: #8a4b12; background: repeating-linear-gradient(-45deg, #3a2410 0 8px, #4a2e12 8px 16px); }

/* ---------------------------------------------------------------- เมนูด้านซ้าย (v-sidebar-menu) */
.app-sidebar { --sb-text: #495057; --sb-text-2: #4f5965; --sb-hover-bg: var(--sc-hover); --sb-hover-text: var(--sc-hover-text); --sb-line: var(--sc-hover);
  --sb-header: var(--sc-brand-text); --sb-search-bg: rgba(var(--sc-brand-rgb), .05); --sb-search-text: var(--bs-body-color); --sb-search-ph: var(--sc-muted); --sb-icon-op: .62;
  position: fixed; top: var(--sc-topbar-h); bottom: 0; left: 0; z-index: 1035; width: var(--sc-sidebar-w); display: flex; flex-direction: column;
  background: var(--sc-surface); box-shadow: 7px 0 60px rgba(0, 0, 0, .05); transition: width .2s ease, transform .25s ease, box-shadow .2s ease; }
[data-bs-theme="dark"] .app-sidebar { --sb-text: #c4cdd8; --sb-text-2: #b3bdca; --sb-search-bg: rgba(255, 255, 255, .06); --sb-header: #8fb8e8; box-shadow: 1px 0 0 var(--sc-border); }
.app-sidebar-content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.sidebar-search { position: relative; flex: 0 0 auto; padding: 1rem 1.25rem .5rem; }
.sidebar-search .form-control { height: 2.4rem; padding: .25rem 2.1rem .25rem 2.4rem; font-size: .875rem; color: var(--sb-search-text); background-color: var(--sb-search-bg);
  border: 1px solid transparent; border-radius: 50rem; }
.sidebar-search .form-control::placeholder { color: var(--sb-search-ph) !important; }
.sidebar-search .form-control:focus { background-color: var(--sc-surface); border-color: rgba(var(--sc-brand-rgb), .45); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.sidebar-search .form-control::-webkit-search-cancel-button { display: none; -webkit-appearance: none; } /* ใช้ปุ่มล้างของระบบแทน (เห็นได้ทุกเบราว์เซอร์) */
/* ค่าที่เบราว์เซอร์เติมเอง: ไม่ให้เป็นพื้นเหลือง + เริ่ม animation ให้ app.js รู้แล้วล้างทิ้ง */
@keyframes scAutofillStart { from { opacity: 1; } to { opacity: 1; } }
.sidebar-search .form-control:-webkit-autofill { animation: scAutofillStart .01s; -webkit-text-fill-color: var(--sb-search-text); box-shadow: 0 0 0 100px var(--sc-surface) inset; }
.sidebar-search > .bi { position: absolute; left: 2.15rem; top: 2.2rem; transform: translateY(-50%); color: var(--sb-search-ph); font-size: .875rem; pointer-events: none; }
.menu-filter-clear { position: absolute; right: 1.6rem; top: 2.2rem; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem; padding: 0; border: 0; border-radius: 50%; background: rgba(var(--sc-brand-rgb), .1); color: var(--sc-brand-text); font-size: .75rem; cursor: pointer; }
.menu-filter-clear:hover, .menu-filter-clear:focus-visible { background: var(--sc-brand); color: #fff; outline: 2px solid var(--sc-focus); outline-offset: 1px; }
.sidebar-search kbd { position: absolute; right: 1.75rem; top: 2.2rem; transform: translateY(-50%); background: var(--sc-surface); pointer-events: none; }
.sidebar-search .form-control:focus ~ kbd, .sidebar-search .form-control:not(:placeholder-shown) ~ kbd { display: none; }
.sidebar-search .form-control:not(:placeholder-shown) ~ .menu-filter-clear ~ kbd { display: none; }
@media (hover: none) { .sidebar-search kbd { display: none; } }
.sidebar-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: .15rem 1.25rem 1.5rem; overscroll-behavior: contain; }
.vsm-header { margin: .9rem 0 .45rem; padding: 0 .4rem; font-size: .75rem; font-weight: 700; color: var(--sb-header); white-space: nowrap; line-height: 1.45; }
.nav-group { position: relative; padding: .1rem 0; }
/* หัวกลุ่ม = รายการระดับบน (vsm-link): ไอคอนกลุ่มสีประจำกลุ่ม · ลูกศร · เปิดอยู่ = ตัวหนา · กลุ่มที่มีหน้าปัจจุบัน = พื้นฟ้าอ่อน */
.nav-group-title { position: relative; display: flex; align-items: center; width: 100%; min-height: 2.5rem; padding: .35rem 2.1rem .35rem 2.85rem; border: 0; border-radius: .25rem;
  background: transparent; color: var(--sb-text); font-size: .9rem; font-weight: 400; line-height: 1.35; text-align: left; transition: background-color .2s, color .2s; }
.nav-group-title .vsm-icon { position: absolute; left: .3rem; top: 50%; width: 2.125rem; height: 2.125rem; margin-top: -1.0625rem; display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: var(--sc-dot, currentColor); opacity: var(--sb-icon-op); transition: opacity .3s, color .3s; }
.nav-group-title .vsm-title { min-width: 0; }
.nav-group-title .chev { position: absolute; right: .55rem; top: 50%; margin-top: -.5rem; font-size: .8rem; line-height: 1; opacity: .45; transform: rotate(180deg); transition: transform .3s, opacity .3s; }
.nav-group-title.collapsed .chev { transform: rotate(0deg); }
.nav-group-title:not(.collapsed) { font-weight: 600; color: var(--sb-hover-text); }
.nav-group-title:hover { background: var(--sb-hover-bg); color: var(--sb-hover-text); }
.nav-group-title:hover .vsm-icon, .nav-group-title:not(.collapsed) .vsm-icon, .nav-group.is-active > .nav-group-title .vsm-icon { opacity: 1; }
.nav-group.is-active > .nav-group-title { background: var(--sb-hover-bg); color: var(--sb-hover-text); font-weight: 600; }
/* รายการย่อย (vsm-dropdown): เส้นแนวตั้งด้านซ้าย · ไม่มีไอคอน (เหมือนเทมเพลต — ไอคอนของหน้าอยู่ที่กล่องหัวเรื่อง) */
.nav-group > ul { position: relative; margin: 0; padding: .35rem 0 .45rem 1.95rem; list-style: none; }
.nav-group > ul::before { content: ''; position: absolute; left: 1.25rem; top: .4rem; bottom: .5rem; width: 3px; border-radius: 15px; background: var(--sb-line); }
.app-sidebar .nav-link { position: relative; display: flex; align-items: center; gap: .5rem; min-height: 2rem; padding: .3rem .7rem; margin: 1px 0; border-radius: .25rem;
  color: var(--sb-text-2); font-size: .875rem; line-height: 1.4; text-decoration: none; transition: background-color .2s, color .2s; }
.app-sidebar .nav-link > .bi { display: none; }
.app-sidebar .nav-link:hover { background: var(--sb-hover-bg); color: var(--sb-hover-text); }
.app-sidebar .nav-link.active { background: var(--sb-hover-bg); color: var(--sb-hover-text); font-weight: 700; }
.app-sidebar .nav-link.active::before { content: ''; position: absolute; left: -.89rem; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%;
  background: var(--sc-dot, var(--sc-brand)); box-shadow: 0 0 0 2px var(--sc-surface); }
.app-sidebar .nav-link[target="_blank"]::after { content: '\F1C5'; font-family: bootstrap-icons; font-size: .7rem; opacity: .55; margin-left: auto; }
.app-sidebar .nav-link:focus-visible, .nav-group-title:focus-visible { outline: 2px solid var(--sc-focus); outline-offset: -2px; box-shadow: none; }
.sidebar-nav .is-filtering .collapse:not(.show) { display: block; }
.sidebar-nav .is-filtering .nav-group-title { pointer-events: none; }
.sidebar-nav .is-filtering .nav-group-title .chev { visibility: hidden; }
/* หัวข้อโซนเมนู (ระยะ 29 — งานบริการผู้ป่วย / งานบริหาร ERP / ข้อมูลพื้นฐานและการตั้งค่า): ซ่อนระหว่างกรองเมนู · โซนถัดไปมีเส้นคั่นบาง ๆ */
.sidebar-nav .is-filtering .vsm-zone { display: none; }
.vsm-zone { margin-top: 1.1rem; padding-top: .7rem; border-top: 1px solid var(--sb-line); }
.vsm-header + .vsm-zone, .vsm-list > .vsm-zone:first-child { margin-top: .9rem; padding-top: 0; border-top: 0; }
.nav-empty { color: var(--sb-text-2); font-size: .875rem; padding: .75rem; text-align: center; }
.nav-empty .nav-empty-clear { color: var(--sc-brand-text); padding: .25rem 0 0; font-size: .8125rem; text-decoration: underline; }
/* จุดสีของกลุ่ม (ไอคอนกลุ่ม + จุดหน้ารายการที่เลือก) */
.nav-group[data-group="home"] { --sc-dot: var(--sc-m-home); } .nav-group[data-group="g1"] { --sc-dot: var(--sc-m-g1); } .nav-group[data-group="g2"] { --sc-dot: var(--sc-m-g2); }
.nav-group[data-group="ipd"] { --sc-dot: var(--sc-m-ipd); } .nav-group[data-group="g3"] { --sc-dot: var(--sc-m-g3); } .nav-group[data-group="g4"] { --sc-dot: var(--sc-m-g4); }
.nav-group[data-group="g5"] { --sc-dot: var(--sc-m-g5); } .nav-group:is([data-group="g6"], [data-group="hrm"], [data-group="sup"]) { --sc-dot: var(--sc-m-g6); } .nav-group[data-group="g7"] { --sc-dot: var(--sc-m-g7); }
.nav-group[data-group="g8"] { --sc-dot: var(--sc-m-g8); } .nav-group:is([data-group="adm"], [data-group="sys"], [data-group="it"], [data-group="hosm"], [data-group="erpm"]) { --sc-dot: var(--sc-m-sys); }
.sidebar-backdrop { display: none; }

/* สีแถบเมนู (Theme Options ของเทมเพลต — html[data-sb-theme], คุกกี้ sricare_sb): พื้นไล่สีเข้ม + ตัวอักษรขาว (text-lighter) · โลโก้บนแถบหัวสีเดียวกัน (จอกว้าง) */
:root[data-sb-theme]:not([data-sb-theme="white"]) .app-sidebar { --sb-text: rgba(255, 255, 255, .82); --sb-text-2: rgba(255, 255, 255, .78); --sb-hover-bg: rgba(255, 255, 255, .12);
  --sb-hover-text: #fff; --sb-line: rgba(255, 255, 255, .14); --sb-header: rgba(255, 255, 255, .62); --sb-search-bg: rgba(255, 255, 255, .1); --sb-search-text: #fff;
  --sb-search-ph: rgba(255, 255, 255, .62); --sb-icon-op: .85; --sc-surface-sb: transparent; color-scheme: dark; box-shadow: 7px 0 60px rgba(0, 0, 0, .12); }
:root[data-sb-theme]:not([data-sb-theme="white"]) .app-sidebar .sidebar-search .form-control:focus { background-color: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .45);
  box-shadow: 0 0 0 .2rem rgba(255, 255, 255, .15); }
:root[data-sb-theme]:not([data-sb-theme="white"]) .app-sidebar .sidebar-search .form-control:-webkit-autofill { -webkit-text-fill-color: #fff; box-shadow: 0 0 0 100px #1d2b40 inset; }
:root[data-sb-theme]:not([data-sb-theme="white"]) .app-sidebar .sidebar-search kbd { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .2); box-shadow: none; }
:root[data-sb-theme]:not([data-sb-theme="white"]) .app-sidebar .menu-filter-clear { background: rgba(255, 255, 255, .16); color: #fff; }
:root[data-sb-theme]:not([data-sb-theme="white"]) .app-sidebar .nav-link.active::before { box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); }
:root[data-sb-theme]:not([data-sb-theme="white"]) .app-sidebar .nav-empty-clear { color: #fff; }
:root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group { --sc-dot: #fff; }
:root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group[data-group="home"] { --sc-dot: #8cc4ff; } :root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group[data-group="g1"] { --sc-dot: #9ab8ff; }
:root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group[data-group="g2"] { --sc-dot: #5fe0cf; } :root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group[data-group="ipd"] { --sc-dot: #b3aefc; }
:root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group[data-group="g3"] { --sc-dot: #cbb4ff; } :root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group[data-group="g4"] { --sc-dot: #ffb487; }
:root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group[data-group="g5"] { --sc-dot: #8ff0b0; } :root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group:is([data-group="g6"], [data-group="hrm"], [data-group="sup"]) { --sc-dot: #ffa3cf; }
:root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group[data-group="g7"] { --sc-dot: #ffd27a; } :root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group[data-group="g8"] { --sc-dot: #7fdcf0; }
:root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group:is([data-group="adm"], [data-group="sys"], [data-group="it"], [data-group="hosm"], [data-group="erpm"]) { --sc-dot: #c9d3df; }
:root[data-sb-theme="brand"] { --sc-sb-grad: linear-gradient(180deg, #033c73 0%, #022b52 100%); }
:root[data-sb-theme="royal"] { --sc-sb-grad: linear-gradient(to right, #141e30, #243b55); }
:root[data-sb-theme="nightsky"] { --sc-sb-grad: linear-gradient(to top, #1e3c72 0%, #1e3c72 1%, #2a5298 100%); }
:root[data-sb-theme="midnight"] { --sc-sb-grad: linear-gradient(-20deg, #2b5876 0%, #4e4376 100%); }
:root[data-sb-theme="asteroid"] { --sc-sb-grad: linear-gradient(to right, #0f2027, #203a43, #2c5364); }
:root[data-sb-theme="vicious"] { --sc-sb-grad: linear-gradient(60deg, #29323c 0%, #485563 100%); }
:root[data-sb-theme="carbon"] { --sc-sb-grad: linear-gradient(to bottom, #323232 0%, #3f3f3f 40%, #1c1c1c 150%); }
:root[data-sb-theme]:not([data-sb-theme="white"]) .app-sidebar { background: var(--sc-sb-grad, #243b55); }
@media (min-width: 992px) {
  :root[data-sb-theme]:not([data-sb-theme="white"]) .app-header__logo { background: var(--sc-sb-grad, #243b55); }
  :root[data-sb-theme]:not([data-sb-theme="white"]) .app-header__logo .brand-name { color: #fff; }
  :root[data-sb-theme]:not([data-sb-theme="white"]) .app-header__logo .brand-sub { color: rgba(255, 255, 255, .7); }
  :root[data-sb-theme]:not([data-sb-theme="white"]) .app-header__logo .app-brand img { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .35)); }
  :root[data-sb-theme]:not([data-sb-theme="white"]) .app-header__logo .hamburger-inner,
  :root[data-sb-theme]:not([data-sb-theme="white"]) .app-header__logo .hamburger-inner::before,
  :root[data-sb-theme]:not([data-sb-theme="white"]) .app-header__logo .hamburger-inner::after { background-color: rgba(255, 255, 255, .9); }
  :root[data-sb-theme]:not([data-sb-theme="white"]) .app-header__logo .hamburger:hover { background: rgba(255, 255, 255, .12); }
}

/* ---------------------------------------------------------------- เนื้อหา · ท้ายหน้า */
.app-main { flex: 1 1 auto; min-width: 0; min-height: 100vh; display: flex; flex-direction: column; padding: var(--sc-topbar-h) 0 0 var(--sc-sidebar-w); transition: padding-left .2s ease; }
.app-content { flex: 1 0 auto; width: 100%; padding: var(--sc-gutter) var(--sc-gutter) 1.5rem; }
.app-footer { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1.25rem; min-height: 3.5rem; padding: .6rem var(--sc-gutter); background: var(--sc-header-bg);
  color: var(--bs-secondary-color); font-size: .8125rem; line-height: 1.5;
  box-shadow: 0 -.46875rem 2.1875rem rgba(4, 9, 20, .03), 0 -.9375rem 1.40625rem rgba(4, 9, 20, .03), 0 -.25rem .53125rem rgba(4, 9, 20, .05), 0 -.125rem .1875rem rgba(4, 9, 20, .03); }
[data-bs-theme="dark"] .app-footer { box-shadow: 0 -1px 0 var(--sc-border); }
.app-footer-left, .app-footer-right { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem; min-width: 0; }
.app-footer-right { margin-left: auto; }
.app-footer a { color: var(--bs-secondary-color); text-decoration: none; }
.app-footer a:hover { color: var(--sc-brand-text); text-decoration: underline; }
.app-footer .footer-dot { display: inline-block; width: .45rem; height: .45rem; border-radius: 50%; background: #2f9e44; margin-right: .35rem; vertical-align: .08em; box-shadow: 0 0 0 3px rgba(47, 158, 68, .18); }
@media (max-width: 991.98px) {
  .app-header__logo { width: auto; padding: 0 .25rem 0 .6rem; gap: .25rem; }
  .app-header__content { padding: 0 .75rem 0 .25rem; }
  .app-sidebar { transform: translateX(-100%); box-shadow: none; }
  .app-sidebar.show { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: var(--sc-topbar-h) 0 0 0; z-index: 1034; background: rgba(11, 22, 38, .45); }
  .app-main { padding-left: 0; }
  .app-footer-right { margin-left: 0; }
}
@media (max-width: 575.98px) {
  .brand-sub { display: none; }
  .brand-name { font-size: 1.05rem; }
  .app-brand img { width: 30px; height: 30px; }
  .app-header__content { gap: .2rem; padding-right: .5rem; }
  .app-header-right { gap: .15rem; }
  .topbar-btn { width: 2.45rem; height: 2.45rem; font-size: 1.1rem; }
  .unit-chip { width: 2.45rem; height: 2.45rem; padding: 0; justify-content: center; border-radius: 50%; }
  .header-btn-lg { margin-left: .1rem; padding-left: .35rem; }
  .header-btn-lg::before { display: none; }
  .topbar-user .avatar { width: 2.3rem; height: 2.3rem; }
  .demo-pill .demo-text { display: none; }
}
@media (max-width: 575.98px) { .app-header__logo .brand-text { display: none; } }
/* เมนูแบบย่อ (ไอคอนกลุ่มอย่างเดียว — จอกว้าง ≥ 992px, จำค่าต่อผู้ใช้ใน localStorage) · ชี้เมาส์/โฟกัสที่เมนู = กางชั่วคราวทับเนื้อหา */
@media (min-width: 992px) {
  .sb-mini .app-main { padding-left: var(--sc-sidebar-mini-w); }
  .sb-mini .app-header__logo { width: var(--sc-sidebar-mini-w); padding: 0; justify-content: center; }
  .sb-mini .app-header__logo .app-brand { display: none; }
  .sb-mini .header__pane { margin: 0; }
  .sb-mini .app-sidebar { width: var(--sc-sidebar-mini-w); }
  .sb-mini .app-sidebar:hover, .sb-mini .app-sidebar:focus-within { width: var(--sc-sidebar-w); box-shadow: 7px 0 60px rgba(0, 0, 0, .18); }
  /* ช่องค้นหาเมนูซ่อนแบบยังรับโฟกัสได้ — กด / แล้วเมนูกางออกพร้อมช่องค้นหา */
  .sb-mini .app-sidebar:not(:hover):not(:focus-within) .sidebar-search { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .sb-mini .app-sidebar:not(:hover):not(:focus-within) .sidebar-nav { padding: .9rem .5rem 1.5rem; }
  .sb-mini .app-sidebar:not(:hover):not(:focus-within) .vsm-header { height: 1px; margin: .6rem .5rem; padding: 0; overflow: hidden; color: transparent; background: var(--sb-line); }
  .sb-mini .app-sidebar:not(:hover):not(:focus-within) .vsm-zone { border-top: 0; }
  .sb-mini .app-sidebar:not(:hover):not(:focus-within) .nav-group > ul { display: none; }
  .sb-mini .app-sidebar:not(:hover):not(:focus-within) .nav-group-title { justify-content: center; padding: .35rem 0; min-height: 2.75rem; }
  .sb-mini .app-sidebar:not(:hover):not(:focus-within) .nav-group-title .vsm-icon { left: 50%; margin-left: -1.0625rem; }
  .sb-mini .app-sidebar:not(:hover):not(:focus-within) .nav-group-title :is(.vsm-title, .chev) { display: none; }
}
@media (prefers-reduced-motion: reduce) { .app-sidebar, .app-main, .app-header__logo { transition: none; } }

/* ================================================================ แถบหัวเรื่อง (app-page-title): breadcrumb · ย้อนกลับ · กล่องไอคอน · ชื่อหน้า · ปุ่ม */
.app-page-title { position: relative; margin: calc(var(--sc-gutter) * -1) calc(var(--sc-gutter) * -1) var(--sc-gutter); padding: 1.35rem var(--sc-gutter);
  background: rgba(255, 255, 255, .55); box-shadow: inset 0 -1px 0 rgba(26, 54, 126, .06); }
[data-bs-theme="dark"] .app-page-title { background: rgba(255, 255, 255, .025); box-shadow: inset 0 -1px 0 var(--sc-border); }
.page-head { margin-bottom: 1.1rem; }
.page-head.app-page-title { margin-bottom: var(--sc-gutter); }
.page-crumbs .breadcrumb { --bs-breadcrumb-margin-bottom: .25rem; --bs-breadcrumb-font-size: .8125rem; --bs-breadcrumb-divider-color: var(--sc-muted);
  --bs-breadcrumb-item-active-color: var(--bs-secondary-color); --bs-breadcrumb-item-padding-x: .4rem; flex-wrap: wrap; line-height: 1.5; }
.page-crumbs .breadcrumb-item + .breadcrumb-item::before { content: '›'; font-weight: 600; }
.page-crumbs a { color: var(--bs-secondary-color); text-decoration: none; }
.page-crumbs a:hover { color: var(--sc-brand-text); text-decoration: underline; }
.page-crumbs .crumb-group { color: var(--bs-secondary-color); }
.page-head-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
/* กล่องไอคอน 60×60 พื้นขาวมีเงา + ไอคอนไล่สีของกลุ่มเมนู (page-title-icon + icon-gradient) */
.page-icon { width: 60px; height: 60px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; border-radius: .375rem;
  background: var(--sc-surface); box-shadow: var(--sc-shadow-sm); font-size: 1.9rem; line-height: 1; }
.page-icon > .bi { background-image: var(--sc-mod-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: var(--sc-mod-text); }
[data-bs-theme="dark"] .page-icon { background: var(--sc-surface-2); box-shadow: inset 0 0 0 1px var(--sc-border); }
.page-title-wrap { flex: 1 1 16rem; min-width: 0; margin-right: auto; }
.page-head h1, .page-title { font-size: 1.4rem; font-weight: 600; line-height: 1.35; margin: 0; color: var(--bs-heading-color); overflow-wrap: anywhere; }
.page-subtitle { color: var(--bs-secondary-color); font-size: .875rem; line-height: 1.5; margin-top: .15rem; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.page-actions > form { display: inline-flex; }
.page-back > .btn { display: inline-flex; align-items: center; }
.page-head .page-back > .btn { background: var(--sc-surface); }
@media (max-width: 767.98px) {
  .app-page-title { padding-top: 1rem; padding-bottom: 1rem; }
  .page-icon { width: 46px; height: 46px; font-size: 1.45rem; }
  .page-head h1, .page-title { font-size: 1.25rem; }
}
@media (max-width: 575.98px) {
  .page-head h1, .page-title { font-size: 1.15rem; }
  .page-title-wrap { flex-basis: 0; }
  .page-actions { width: 100%; }
  .page-actions > .btn, .page-actions > form, .page-actions > .dropdown, .page-actions > .btn-group, .page-actions > a { flex: 1 1 auto; }
  .page-actions > form > .btn, .page-actions > .dropdown > .btn { width: 100%; }
  .page-actions > .btn, .page-actions > a.btn { justify-content: center; }
}

/* ================================================================ แถบยืนยันตัวผู้ป่วย (ตรึงใต้แถบหัว — ไม่ตรึงบนมือถือ) */
.patient-banner { position: sticky; top: var(--sc-topbar-h); z-index: 1020; background: var(--sc-surface); box-shadow: var(--sc-shadow-sm); }
.patient-banner > .container-fluid { padding-left: var(--sc-gutter); padding-right: var(--sc-gutter); }
.patient-banner .avatar { box-shadow: 0 0 0 2px var(--sc-surface), 0 0 0 3px rgba(var(--sc-brand-rgb), .15); }
.patient-banner .pb-name { font-weight: 700; font-size: 1.0625rem; line-height: 1.4; text-decoration: none; color: var(--bs-heading-color); }
.patient-banner .pb-name:hover { color: var(--sc-brand-text); text-decoration: underline; }
.patient-banner .pb-item { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .65rem; border: 0; border-radius: 50rem; font-size: .8125rem;
  line-height: 1.6; background: rgba(var(--sc-brand-rgb), .06); }
[data-bs-theme="dark"] .patient-banner .pb-item { background: rgba(255, 255, 255, .06); }
.patient-banner .pb-conf { color: var(--bs-secondary-color); }
.allergy-bar { background: #c92a2a; color: #fff; font-weight: 500; padding: .4rem var(--sc-gutter); font-size: .9rem; line-height: 1.5; }
.allergy-bar.allergy-none { background: #e6f4ea; color: #1e6b34; }
.allergy-bar.allergy-unknown { background: #fff3cd; color: #6b4f00; }
[data-bs-theme="dark"] .allergy-bar.allergy-none { background: #163322; color: #8fd5a6; }
[data-bs-theme="dark"] .allergy-bar.allergy-unknown { background: #3a3012; color: #f1d27a; }
@media (max-width: 767.98px) {
  .patient-banner { position: static; }
  .patient-banner .pb-name { font-size: 1rem; }
}

.avatar { display: inline-flex; align-items: center; justify-content: center; width: 2.3rem; height: 2.3rem; border-radius: 50%; font-weight: 600; flex: 0 0 auto; font-size: 1rem; line-height: 1; }
.avatar-m { background: #dbe8fb; color: #1d5fa8; } .avatar-f { background: #fbe0ec; color: #b0275d; } .avatar-u { background: #e7ebf1; color: #46505d; }
.avatar-photo { object-fit: cover; padding: 0; background: var(--sc-surface-2, #f1f4f8); border: 1px solid var(--sc-border, #e2e7ef); }
.profile-photo-box { flex: 0 0 auto; }
.profile-photo { width: 7.5rem; height: 7.5rem; border-radius: 50%; object-fit: cover; border: 3px solid var(--sc-surface, #fff); box-shadow: 0 0 0 1px var(--sc-border, #e2e7ef), 0 2px 8px rgba(16,24,40,.08); background: var(--sc-surface-2, #f1f4f8); }
.profile-photo-empty { display: inline-flex; align-items: center; justify-content: center; font-size: 3rem; color: var(--sc-muted, #6b7585); }
.profile-photo-form { flex: 1 1 14rem; min-width: 0; } /* อยู่ข้างรูปเมื่อมีที่พอ (ไม่ตกบรรทัดเพราะข้อความยาว) */
[data-bs-theme="dark"] .avatar-m { background: #1d3150; color: #9cc3f5; } [data-bs-theme="dark"] .avatar-f { background: #3f1f2e; color: #f3a6c2; }
[data-bs-theme="dark"] .avatar-u { background: #2a3442; color: #c4cdd8; }

/* ================================================================ การ์ด (main-card ของเทมเพลต: เส้นขอบจางมาก + เงานุ่มหลายชั้น · หัวการ์ดตัวหนา + ไอคอนไล่สี) */
.card { --bs-card-border-color: rgba(26, 54, 126, .07); --bs-card-border-radius: var(--sc-radius); --bs-card-inner-border-radius: calc(var(--sc-radius) - 1px);
  --bs-card-cap-bg: transparent; --bs-card-cap-padding-y: .75rem; --bs-card-cap-padding-x: 1.25rem; --bs-card-spacer-x: 1.25rem; --bs-card-spacer-y: 1.1rem;
  box-shadow: var(--sc-shadow-sm); }
[data-bs-theme="dark"] .card { --bs-card-border-color: var(--sc-border); box-shadow: none; }
.card .card { box-shadow: none; --bs-card-border-color: var(--sc-border); } /* การ์ดซ้อนในการ์ด = เส้นขอบแทนเงา */
.card.shadow-none, .card.border-0.bg-transparent { box-shadow: none !important; }
.card > .card-header { min-height: 3.5rem; border-bottom: 1px solid var(--sc-border-row); padding: .65rem 1.25rem; }
.card > .card-header:first-child { border-radius: var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius) 0 0; }
.card > .card-header .h6, .card > .card-header h2.h6 { font-size: 1rem; font-weight: 700; line-height: 1.45; color: var(--sc-card-title); }
/* ไอคอนหัวการ์ด (header-icon + icon-gradient) */
.card > .card-header .h6 > .bi:first-child, .card > .card-header h2.h6 > .bi:first-child { display: inline-block; font-size: 1.3rem; line-height: 1; margin-right: .5rem !important; vertical-align: -.15em;
  background-image: var(--sc-mod-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: var(--sc-mod-text) !important; }
/* หัวข้อ/ไอคอนบนพื้นสีเข้ม (card-header bg-dark text-white, text-bg-*) ใช้สีตัวอักษรของพื้น — ไม่ใช่สีหัวข้อปกติ (มองไม่เห็นบนพื้นเข้ม) */
.text-white :is(h1, h2, h3, h4, h5, h6, .h6), [class*="text-bg-"] :is(h1, h2, h3, h4, h5, h6, .h6) { color: inherit; }
.card > .card-header:is(.text-white, [class*="text-bg-"], [class*="bg-dark"], [class*="bg-danger"], [class*="bg-success"], [class*="bg-primary"], [class*="bg-warning"], [class*="bg-info"]) .h6 > .bi:first-child,
.card > .card-header:is(.text-white, [class*="text-bg-"], [class*="bg-dark"], [class*="bg-danger"], [class*="bg-success"], [class*="bg-primary"], [class*="bg-warning"], [class*="bg-info"]) h2.h6 > .bi:first-child {
  background-image: none; -webkit-text-fill-color: currentColor; color: inherit !important; }
.card > .card-header:is([class*="bg-"]) .h6 { color: inherit; }
.card-footer { background-color: var(--sc-surface-2); border-top-color: var(--sc-border-row); }
.card-footer:last-child { border-radius: 0 0 var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius); }
.shadow-sm { box-shadow: var(--sc-shadow-sm) !important; }
.shadow { box-shadow: var(--sc-shadow-md) !important; }
.card-btm-border { border-bottom: 4px solid transparent !important; }
.divider { margin: 1rem 0; height: 1px; overflow: hidden; background: var(--sc-border); }

/* ================================================================ ตาราง (หัวตารางพื้นเทาอ่อนตัวหนา · ชี้แถว = ฟ้าอ่อน) */
.table { --bs-table-border-color: var(--sc-border-row); --bs-table-hover-bg: rgba(209, 243, 255, .45); --bs-table-striped-bg: rgba(16, 24, 40, .022);
  --bs-table-active-bg: rgba(var(--sc-brand-rgb), .08); }
[data-bs-theme="dark"] .table { --bs-table-hover-bg: rgba(122, 179, 240, .07); --bs-table-striped-bg: rgba(255, 255, 255, .025); }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table-sm > :not(caption) > * > * { padding: .35rem .5rem; }
.table-sm { font-size: .875rem; }
.table thead th { font-size: .8125rem; font-weight: 700; color: var(--bs-secondary-color); background: color-mix(in srgb, var(--sc-mod-bg) 30%, var(--sc-surface-2)); border-bottom: 2px solid var(--sc-border);
  white-space: nowrap; vertical-align: bottom; line-height: 1.45; }
.card .table { margin-bottom: 0; }
.card > .table-responsive:first-child > .table thead th:first-child, .card > .table:first-child thead th:first-child { border-top-left-radius: var(--bs-card-inner-border-radius); }
.card > .table-responsive:first-child > .table thead th:last-child, .card > .table:first-child thead th:last-child { border-top-right-radius: var(--bs-card-inner-border-radius); }
/* คอลัมน์ชื่อ/รหัส/เรื่อง ไม่ถูกบีบจนตัดทีละคำ (ตารางกว้างเกิน = เลื่อนแนวนอนในกรอบ) — คอลัมน์แรก (ยกเว้นช่องเลือก) และช่องที่ขึ้นต้นด้วยลิงก์ตัวหนา
   ไม่ใช้กับคอลัมน์แรกที่แคบโดยธรรมชาติ (ลำดับ/อันดับ/ตัวเลข/รหัสสั้น — เดิมถูกบังคับกว้าง 112px ทั้งระบบ): ช่องชิดขวา/กึ่งกลาง ช่องไม่ตัดบรรทัด คอลัมน์ตัวเลขของรายงาน (.num)
   และ .col-tight (ui_table ใส่ให้เองเมื่อทุกค่าในคอลัมน์แรกยาวไม่เกิน 6 ตัวอักษร — ตารางที่เขียนเองใส่ class="col-tight" ที่ td แรก) */
.table > tbody > tr > td:first-child:not(.col-tight, .text-end, .text-center, .text-nowrap, .num):not(:has(> input, > .form-check, > .form-check-input)) { min-width: 7rem; }
.table > tbody > tr > td:has(> a.fw-semibold:first-child) { min-width: 10rem; }
.table > tbody > tr > td:has(.avatar) { min-width: 11rem; } /* ชื่อผู้ป่วย/บุคลากรที่มีรูปย่อ — ไม่ถูกบีบจนตัดทีละพยางค์บนจอแคบ */
@media (max-width: 575.98px) { .table-stack > tbody > tr > td { min-width: 0 !important; } }
.card .table-responsive:last-child .table tbody tr:last-child td { border-bottom: 0; }
.table-empty-row > td { padding: 1.75rem 1rem !important; }
/* รายการบทบาท (adm/user_edit, adm/role_edit): เลื่อนในกรอบของตัวเองบนจอกว้าง — หน้าไม่ยาวตามจำนวนบทบาท */
@media (min-width: 1200px) { .role-list { max-height: 68vh; overflow-y: auto; } }
/* ui_table(['sticky' => true]) — หัวตารางค้างเมื่อเลื่อน (ตารางเลื่อนในกรอบสูงไม่เกิน --sc-sticky-h) */
.table-sticky { max-height: var(--sc-sticky-h, 70vh); overflow: auto; }
.table-sticky thead th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -2px 0 var(--sc-border); }
/* ตารางกว้างเกินกรอบ: ขอบด้านที่ยังเลื่อนได้จางลง (app.js ใส่คลาส sc-sx-l / sc-sx-r) */
.table-responsive.sc-sx-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), rgba(0, 0, 0, .15)); mask-image: linear-gradient(to right, #000 calc(100% - 2rem), rgba(0, 0, 0, .15)); }
.table-responsive.sc-sx-l { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 2rem), rgba(0, 0, 0, .15)); mask-image: linear-gradient(to left, #000 calc(100% - 2rem), rgba(0, 0, 0, .15)); }
.table-responsive.sc-sx-l.sc-sx-r { -webkit-mask-image: linear-gradient(to right, rgba(0, 0, 0, .15), #000 2rem, #000 calc(100% - 2rem), rgba(0, 0, 0, .15));
  mask-image: linear-gradient(to right, rgba(0, 0, 0, .15), #000 2rem, #000 calc(100% - 2rem), rgba(0, 0, 0, .15)); }
.table-responsive:has(.dropdown-menu.show) { -webkit-mask-image: none; mask-image: none; }
/* ui_table(['stack' => true]) — มือถือแสดงแต่ละแถวเป็นการ์ด พร้อมชื่อคอลัมน์ (data-label) */
@media (max-width: 575.98px) {
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table-stack, .table-stack > tbody, .table-stack > tbody > tr, .table-stack > tbody > tr > td, .table-stack > tfoot, .table-stack > tfoot > tr, .table-stack > tfoot > tr > td { display: block; width: 100%; }
  .table-stack > tbody > tr { width: auto; margin: .6rem .75rem; border: 1px solid var(--sc-border); border-radius: .5rem; background: var(--bs-body-bg); overflow: hidden; box-shadow: var(--sc-shadow-sm); }
  .table-stack > tbody > tr > td { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: .4rem .75rem !important; border: 0;
    border-bottom: 1px solid var(--sc-border-row); text-align: right !important; }
  .table-stack > tbody > tr > td:last-child { border-bottom: 0; }
  .table-stack > tbody > tr > td[data-label]::before { content: attr(data-label); flex: 0 0 40%; text-align: left; font-weight: 600; font-size: .8125rem; color: var(--bs-secondary-color); line-height: 1.6; }
  .table-stack > tbody > tr > td[data-label=""]::before { content: none; }
  .table-stack > tbody > tr > td[data-label=""] { justify-content: flex-end; }
  .table-stack > tbody > tr.table-empty-row > td { display: block; text-align: center !important; }
}
.dl-compact dt, .dl-compact dd { font-size: .9375rem; }
.dl-compact dt { color: var(--bs-secondary-color); }

/* แท็บ: เส้นใต้สีกลุ่ม 3px มุมมน (ไม่ใช้ margin ติดลบ — กล่องแท็บเลื่อนแนวนอนได้โดยไม่เกิดแถบเลื่อนแนวตั้ง) */
.nav-tabs { --bs-nav-tabs-border-color: var(--sc-border); gap: .15rem; }
.nav-tabs .nav-link { position: relative; border: 0; border-radius: .25rem .25rem 0 0; margin-bottom: 0; color: var(--bs-secondary-color); font-weight: 500; padding: .6rem .95rem; line-height: 1.5; transition: color .2s, background-color .2s; }
.nav-tabs .nav-link:hover { color: var(--sc-hover-text); background: rgba(209, 243, 255, .55); }
[data-bs-theme="dark"] .nav-tabs .nav-link:hover { background: var(--bs-secondary-bg); color: var(--bs-body-color); }
.nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link { color: var(--sc-mod-text); background: transparent; font-weight: 700; }
.nav-tabs .nav-link.active::after, .nav-tabs .nav-item.show .nav-link::after { content: ''; position: absolute; left: .45rem; right: .45rem; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--sc-mod-grad); }
.nav-tabs .nav-link .badge { margin-left: .15rem; }
.card-header-tabs { margin-bottom: -.65rem; }

/* ================================================================ KPI (widget-chart ของเทมเพลต: วงกลมไอคอนไล่สี · ตัวเลขหนา · เส้นสีด้านล่าง) · สถานะว่าง */
.kpi { --kpi-a: #1e3c72; --kpi-b: #2a78c9; --kpi-line: var(--sc-brand); border: 0; border-bottom: 3px solid var(--kpi-line) !important; color: inherit;
  transition: transform .2s ease, box-shadow .2s ease; }
.kpi-primary { --kpi-a: #1e3c72; --kpi-b: #2a78c9; --kpi-line: #2a5298; }
.kpi-success { --kpi-a: #0ba360; --kpi-b: #3cba92; --kpi-line: #2b9a6a; }
.kpi-danger { --kpi-a: #e8193c; --kpi-b: #ff6a5b; --kpi-line: #e03131; }
.kpi-warning { --kpi-a: #f39c12; --kpi-b: #f7b924; --kpi-line: #f0a500; }
.kpi-info { --kpi-a: #1fa2e0; --kpi-b: #30c7ec; --kpi-line: #1c94d2; }
.kpi-secondary { --kpi-a: #6c7a89; --kpi-b: #95a1ad; --kpi-line: #8a96a3; }
.kpi-dark { --kpi-a: #29323c; --kpi-b: #485563; --kpi-line: #3a4552; }
.kpi-purple { --kpi-a: #667eea; --kpi-b: #764ba2; --kpi-line: #6f42c1; }
.kpi-teal { --kpi-a: #0f766e; --kpi-b: #20c997; --kpi-line: #12a389; }
.kpi-orange { --kpi-a: #f76b1c; --kpi-b: #fba04b; --kpi-line: #f2711c; }
.kpi-pink { --kpi-a: #f5576c; --kpi-b: #f093fb; --kpi-line: #e64980; }
.kpi-light { --kpi-a: #a3b1c2; --kpi-b: #cfd9df; --kpi-line: #c3cbd6; }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--sc-shadow-md) !important; color: inherit; }
/* การ์ดแคบ (5–7 ใบต่อแถว ฯลฯ): วงกลมไอคอนเล็กลง ข้อความมีที่มากขึ้น — กฎ @container อยู่ท้ายหมวด KPI (ต้องมาหลังกฎพื้นฐานจึงมีผล) */
.kpi { container-type: inline-size; }
a.kpi:focus-visible { outline: 3px solid var(--sc-focus); outline-offset: 2px; }
.kpi .card-body { padding: 1rem 1.15rem; }
.kpi-icon { position: relative; width: 3.25rem; height: 3.25rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex: 0 0 auto; }
.kpi .kpi-icon { background: linear-gradient(135deg, var(--kpi-a) 0%, var(--kpi-b) 100%) !important; color: #fff !important; box-shadow: 0 .25rem .75rem color-mix(in srgb, var(--kpi-a) 35%, transparent); }
.kpi .kpi-icon > .bi { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .15)); }
.kpi-label { font-size: .8125rem; line-height: 1.45; color: var(--bs-secondary-color); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kpi-value { font-size: 1.75rem; font-weight: 700; line-height: 1.25; color: var(--bs-heading-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* บรรทัดเดียว — app.js SC.fitKpis ย่อให้พอดีกล่อง */
/* บรรทัดรอง: ไม่เกิน 2 บรรทัด (เดิมบรรทัดเดียวตัดด้วย … — ข้อความอย่าง "อัตราครองเตียง 65.0% · ว่าง 7 เตียง" อ่านไม่ครบเกือบทุกการ์ด) · ข้อความเต็มยังอยู่ใน title */
.kpi-sub { font-size: .8125rem; line-height: 1.45; color: var(--bs-secondary-color); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; }
/* หน่วยของตัวเลข (ui_kpi 'unit'): เล็กและจางกว่าตัวเลข เว้นระยะ ไม่ติดกับตัวเลข */
.kpi-value .kpi-unit { margin-left: .3em; font-size: .58em; font-weight: 600; color: var(--bs-secondary-color); letter-spacing: 0; }
/* การ์ดที่ค่าเป็นข้อความ/ลิงก์ยาว ไม่ใช่ตัวเลข (ui_kpi 'class' => 'kpi-text' — เช่น ลิงก์ "เปิดรายงานฉบับเต็ม" ในแถวตัวเลขสรุปของรายงาน): ตัวอักษรขนาดปกติ ตัดบรรทัดได้ ไม่ถูกตัดด้วย … */
.kpi-text .kpi-value { font-size: 1rem; line-height: 1.45; white-space: normal; overflow-wrap: break-word; }
/* การ์ดตัวเลขขนาดย่อ (ui_kpi 'class' => 'kpi-sm'): ตัวนับงานหลายใบในตารางกริด */
.kpi-sm .card-body { padding: .7rem .9rem; gap: .75rem !important; }
.kpi-sm .kpi-icon { width: 2.6rem; height: 2.6rem; font-size: 1.15rem; }
.kpi-sm .kpi-value { font-size: 1.5rem; }
.kpi-trend { display: inline-flex; align-items: center; gap: .15rem; margin-left: .35rem; padding: .05rem .45rem; border-radius: 2rem; font-size: .8125rem; font-weight: 600;
  line-height: 1.5; vertical-align: middle; }
.kpi-trend.is-good { color: var(--bs-success-text-emphasis); background: var(--bs-success-bg-subtle); }
.kpi-trend.is-bad { color: var(--bs-danger-text-emphasis); background: var(--bs-danger-bg-subtle); }
.kpi-trend.is-flat { color: var(--bs-secondary-text-emphasis); background: var(--bs-secondary-bg-subtle); }
@media (max-width: 575.98px) {
  .kpi .card-body { gap: .6rem !important; padding: .75rem .8rem; align-items: flex-start !important; }
  .kpi-icon { width: 2.3rem; height: 2.3rem; font-size: 1.05rem; }
  .kpi-value { font-size: 1.35rem; }
  .kpi-trend { margin-left: .25rem; }
  /* การ์ดของ ui_kpi(): ไอคอน + ชื่อตัวชี้วัดแถวบน ตัวเลขเต็มความกว้างการ์ดแถวล่าง (ตัวเลขยาว เช่น ยอดเงิน ไม่ถูกตัดกลางตัวเลข)
     การ์ด .kpi ที่หน้าเขียนเอง (โครงสร้างอื่น) คงแบบเดิม — เบราว์เซอร์ที่ไม่รองรับ :has() ก็คงแบบเดิม */
  .kpi .card-body:has(> .min-w-0 > .kpi-label) { display: grid !important; grid-template-columns: auto minmax(0, 1fr); column-gap: .55rem !important; row-gap: .2rem;
    align-items: center !important; align-content: start; } /* align-content: เนื้อหาชิดบน — การ์ดที่ถูกยืดให้สูงเท่ากันทั้งแถวไม่กระจายช่องว่างระหว่างชื่อ/ตัวเลข/บรรทัดรอง */
  .kpi .card-body:has(> .min-w-0 > .kpi-label) > .min-w-0 { display: contents; }
  .kpi .card-body:has(> .min-w-0 > .kpi-label) > .kpi-icon { grid-column: 1; grid-row: 1; }
  .kpi .card-body:has(> .min-w-0 > .kpi-label) .kpi-label { grid-column: 2; grid-row: 1; -webkit-line-clamp: 3; line-clamp: 3; } /* ชื่อตัวชี้วัดยาวได้ 3 บรรทัดบนการ์ดแคบ */
  .kpi .card-body:has(> .min-w-0 > .kpi-label) .kpi-value, .kpi .card-body:has(> .min-w-0 > .kpi-label) .kpi-sub { grid-column: 1 / -1; overflow-wrap: break-word; }
  .kpi-sm .kpi-icon { width: 2.3rem; height: 2.3rem; font-size: 1.05rem; }
  .kpi-sm .kpi-value { font-size: 1.35rem; }
}
@container (max-width: 215px) {
  .kpi .card-body { gap: .6rem !important; padding: .8rem .8rem; } .kpi-icon { width: 2.3rem; height: 2.3rem; font-size: 1.05rem; } .kpi-value { font-size: 1.4rem; }
  /* การ์ดของ ui_kpi() ที่แคบ (5–7 ใบต่อแถว): จัดแบบเดียวกับมือถือ — ไอคอน + ชื่อแถวบน ตัวเลขและบรรทัดรองเต็มความกว้างการ์ด (ตัวเลขไม่ถูกตัดเป็น "82.7…") */
  .kpi .card-body:has(> .min-w-0 > .kpi-label) { display: grid !important; grid-template-columns: auto minmax(0, 1fr); column-gap: .55rem !important; row-gap: .2rem; align-items: center !important; align-content: start; }
  .kpi .card-body:has(> .min-w-0 > .kpi-label) > .min-w-0 { display: contents; }
  .kpi .card-body:has(> .min-w-0 > .kpi-label) > .kpi-icon { grid-column: 1; grid-row: 1; }
  .kpi .card-body:has(> .min-w-0 > .kpi-label) .kpi-label { grid-column: 2; grid-row: 1; -webkit-line-clamp: 3; line-clamp: 3; }
  .kpi .card-body:has(> .min-w-0 > .kpi-label) .kpi-value, .kpi .card-body:has(> .min-w-0 > .kpi-label) .kpi-sub { grid-column: 1 / -1; }
}
.chart-box { position: relative; height: 260px; }
.sc-print-img { display: none; } /* ภาพกราฟสำหรับพิมพ์ (charts.js) — แสดงเฉพาะตอนพิมพ์ */
.chart-box.tall { height: 320px; }
.chart-box.short { height: 200px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; text-align: center; padding: 2.5rem 1rem; color: var(--bs-secondary-color); }
.empty-state.is-compact { padding: .75rem .5rem; gap: .25rem; }
.empty-icon { position: relative; width: 3.5rem; height: 3.5rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem;
  background: var(--sc-mod-bg); color: var(--sc-mod-text); margin-bottom: .3rem; box-shadow: 0 0 0 6px color-mix(in srgb, var(--sc-mod-bg) 45%, transparent); }
.empty-icon > .bi { background-image: var(--sc-mod-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.empty-state.is-compact .empty-icon { width: 2.25rem; height: 2.25rem; font-size: 1.05rem; margin-bottom: 0; box-shadow: none; }
.empty-title { font-weight: 600; color: var(--bs-body-color); line-height: 1.5; }
.empty-hint { font-size: .875rem; line-height: 1.5; max-width: 34rem; }
.empty-action { margin-top: .4rem; }

/* ------------------------------------------------------------- timeline (vertical-timeline ของเทมเพลต: เส้นหนามุมมน · จุดมีวงขาวรอบ) */
.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before { content: ''; position: absolute; left: .5rem; top: .35rem; bottom: .35rem; width: 4px; border-radius: 4px; background: var(--bs-secondary-bg); }
.timeline-item { position: relative; padding-bottom: .9rem; }
.timeline-dot { position: absolute; left: -1.38rem; top: .38rem; width: .8rem; height: .8rem; border-radius: 50%; box-shadow: 0 0 0 4px var(--bs-body-bg), 0 0 0 5px var(--sc-border); }

/* ------------------------------------------------------------- bed board */
.bed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .5rem; }
.bed-tile { border-radius: .6rem; padding: .45rem .55rem; border: 1px solid transparent; font-size: .8125rem; line-height: 1.45; min-height: 84px; position: relative; display: block; color: inherit; text-decoration: none; }
.bed-tile:focus-visible, a.bed-tile:focus-visible { outline: 3px solid var(--sc-focus); outline-offset: 2px; }
.bed-tile .bed-no { font-weight: 700; font-size: .95rem; }
.bed-tile.st-AVAILABLE { background: #e7f6ec; border-color: #9fd8b3; }
.bed-tile.st-OCCUPIED { background: #e5effb; border-color: #a9c7ee; }
.bed-tile.st-RESERVED { background: #fff4d6; border-color: #f2d37c; }
.bed-tile.st-CLEANING { background: #f0e8fb; border-color: #c9b2ef; }
.bed-tile.st-MAINTENANCE { background: #eceff2; border-color: #c6ccd3; color: #5b6676; }
.bed-tile .bed-flag { position: absolute; top: .3rem; right: .4rem; font-size: .75rem; }
[data-bs-theme="dark"] .bed-tile.st-AVAILABLE { background: #15301f; border-color: #285f3c; }
[data-bs-theme="dark"] .bed-tile.st-OCCUPIED { background: #142538; border-color: #2a4a72; }
[data-bs-theme="dark"] .bed-tile.st-RESERVED { background: #33290f; border-color: #6b5520; }
[data-bs-theme="dark"] .bed-tile.st-CLEANING { background: #251b36; border-color: #4f3a78; }
[data-bs-theme="dark"] .bed-tile.st-MAINTENANCE { background: #20252b; border-color: #3a424b; color: #a9b4c3; }
.legend-dot { display: inline-block; width: .8rem; height: .8rem; border-radius: .2rem; vertical-align: middle; margin-right: .25rem; }

/* ------------------------------------------------------------ queue board */
.queue-now { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.layout-display { background: #0b1a2e; color: #e8eef7; }
.display-main { min-height: 100vh; padding: 1.25rem 1.5rem; }
.qd-head { display: flex; align-items: center; gap: 1rem; border-bottom: 1px solid rgba(255, 255, 255, .15); padding-bottom: .75rem; margin-bottom: 1rem; }
.qd-card { background: #12294a; border-radius: 1rem; padding: 1rem 1.25rem; border: 1px solid rgba(255, 255, 255, .08); }
.qd-number { font-size: 4rem; font-weight: 700; line-height: 1; color: #ffd166; }
.qd-number.flash { animation: qdflash 1s ease-in-out 3; }
@keyframes qdflash { 50% { color: #fff; text-shadow: 0 0 18px #ffd166; } }
.qd-waiting span { display: inline-block; background: rgba(255, 255, 255, .08); border-radius: .5rem; padding: .25rem .6rem; margin: .2rem; font-size: 1.3rem; font-weight: 600; }

/* --------------------------------------------------------- autocomplete */
.ac-menu { position: absolute; z-index: 1060; left: 0; right: 0; top: 100%; max-height: 300px; overflow-y: auto; background: var(--bs-body-bg); border: 1px solid var(--sc-border);
  border-radius: .55rem; box-shadow: var(--sc-shadow-md); margin-top: 2px; }
.ac-item { padding: .45rem .7rem; cursor: pointer; font-size: .9rem; line-height: 1.45; border-bottom: 1px solid var(--sc-border-row); }
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.active { background: var(--bs-primary-bg-subtle); }
.ac-item small { color: var(--bs-secondary-color); display: block; }

/* ------------------------------------------------------------ notifications */
.ntf-menu { width: 360px; max-width: 92vw; overflow: hidden; }
.ntf-list { max-height: 420px; overflow-y: auto; }
.ntf-list a { display: block; padding: .55rem .8rem; border-bottom: 1px solid var(--sc-border-row); color: inherit; text-decoration: none; line-height: 1.5; }
.ntf-list a:hover { background: var(--bs-tertiary-bg); }
.ntf-list a.unread { background: var(--bs-primary-bg-subtle); }
.prio-CRITICAL { border-left: 3px solid #c92a2a; } .prio-HIGH { border-left: 3px solid #c2410c; }

/* ----------------------------------------------------------------- misc */
.stat-mini { font-size: .8125rem; color: var(--bs-secondary-color); }
.soap-label { font-weight: 600; color: var(--sc-brand-text); font-size: .875rem; }
.note-signed { border-left: 3px solid #2f9e44; }
.note-draft { border-left: 3px solid #f08c00; }
.note-body { white-space: pre-wrap; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bs-body-bg); border-top: 1px solid var(--sc-border); padding: .75rem 0; z-index: 5; box-shadow: 0 -6px 12px -8px rgba(16, 24, 40, .18); }
.error-page { max-width: 560px; margin: 0 auto; }
.error-code { font-size: 4.5rem; font-weight: 700; line-height: 1; color: var(--sc-border); font-variant-numeric: tabular-nums; }
[data-bs-theme="dark"] .error-code { color: #334052; }
.wristband { border: 2px dashed #999; border-radius: 1rem; padding: .6rem 1rem; display: inline-flex; gap: 1rem; align-items: center; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--sc-border); border: 1px solid var(--sc-border); border-radius: .5rem; overflow: hidden; }
.calendar-grid > div { background: var(--bs-body-bg); min-height: 92px; padding: .3rem .4rem; font-size: .8125rem; line-height: 1.45; }
.calendar-grid .cal-head { min-height: auto; font-weight: 600; text-align: center; background: var(--sc-surface-2); }
.calendar-grid .cal-other { opacity: .45; }
.calendar-grid .cal-today { box-shadow: inset 0 0 0 2px var(--sc-brand); }
.gantt { position: relative; }
.gantt-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--sc-border-row); min-height: 46px; }
.gantt-label { flex: 0 0 140px; padding: .5rem; font-weight: 600; font-size: .85rem; border-right: 1px solid var(--sc-border); }
.gantt-track { position: relative; flex: 1; background-image: linear-gradient(90deg, var(--bs-border-color-translucent) 1px, transparent 1px); }
.gantt-bar { position: absolute; top: 5px; bottom: 5px; border-radius: .4rem; padding: 2px 6px; font-size: .75rem; line-height: 1.45; color: #fff; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-decoration: none; }
.gantt-bar:hover { filter: brightness(1.1); color: #fff; }

/* ================================================================ หน้าเข้าสู่ระบบ/ล็อกจอ (layout blank) — แบบหน้า Login ของ ArchitectUI */
/* ฝั่งซ้าย: รูปพื้นหลัง (assets/img/bg/abstract5.jpg) + สีไล่ระดับทับ (slide-img-bg + bg-plum-plate/bg-premium-dark) · ฝั่งขวา: พื้นขาว ฟอร์มกลางจอ
   ล็อกจอ/ออกจากระบบ (.login-card): กล่องขาวกลางพื้นไล่สีเคลื่อนไหวช้า ๆ (Login Boxed: bg-plum-plate bg-animation) */
.blank-main { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: var(--sc-page); }
.blank-main:has(> .login-card) { background: linear-gradient(135deg, #1e3c72 0%, #2a5298 35%, #4e4376 100%); background-size: 180% 180%; animation: scBgPan 18s ease-in-out infinite alternate; }
@keyframes scBgPan { 0% { background-position: 0% 50%; } 100% { background-position: 100% 50%; } }
[data-bs-theme="dark"] .blank-main:has(> .login-card) { background: linear-gradient(135deg, #0f1c33 0%, #1a2c4f 45%, #2a2346 100%); }
.blank-main:has(> .login-card) .login-card > .text-center:first-child, .blank-main:has(> .login-card) .login-card > .text-center:first-child :is(h1, .h4, .h5, div) { color: #fff; }
.blank-main:has(> .login-card) .login-card > .text-center:first-child .text-body-secondary { color: rgba(255, 255, 255, .78) !important; }
.blank-main:has(> .login-card) .login-card > :is(.text-center, .small):last-child, .blank-main:has(> .login-card) .login-card > :is(.text-center, .small):last-child a { color: rgba(255, 255, 255, .85); }
.login-card { width: 100%; max-width: 440px; }
.login-brand { width: 64px; height: 64px; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .25)); }
.auth-card { border: 0; box-shadow: var(--sc-shadow-lg) !important; }
.blank-main.auth-split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: stretch; padding: 0; background: var(--sc-surface); animation: none; }
.auth-hero { position: relative; overflow: hidden; isolation: isolate; display: flex; flex-direction: column; justify-content: space-between; padding: 2.75rem 3rem; color: #e3e9f2;
  background: #141e30 url('../img/bg/abstract5.jpg') center / cover no-repeat; }
.auth-hero::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(135deg, rgba(3, 60, 115, .94) 0%, rgba(43, 88, 118, .9) 45%, rgba(78, 67, 118, .86) 100%); }
.auth-hero::after { content: ''; position: absolute; right: -6rem; bottom: -6rem; z-index: -1; width: 22rem; height: 22rem; border-radius: 50%;
  border: 2.5rem solid rgba(255, 255, 255, .05); pointer-events: none; }
.auth-brand { display: flex; align-items: center; gap: .85rem; }
.auth-brand img { width: 52px; height: 52px; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .3)); }
.auth-app { font-size: 1.75rem; font-weight: 700; color: #fff; line-height: 1.2; }
.auth-app-sub { font-size: .875rem; color: rgba(255, 255, 255, .72); line-height: 1.45; }
.auth-hero-body { position: relative; z-index: 1; max-width: 34rem; margin: 2.5rem 0; }
.auth-hospital { font-size: 1.85rem; font-weight: 600; line-height: 1.45; color: #fff; margin: 0 0 .75rem; text-shadow: 0 2px 12px rgba(0, 0, 0, .2); }
.auth-tagline { color: rgba(255, 255, 255, .82); font-size: 1rem; line-height: 1.65; margin-bottom: 1.5rem; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; }
.auth-points li { display: flex; gap: .75rem; align-items: flex-start; line-height: 1.55; color: rgba(255, 255, 255, .88); }
.auth-points .bi { flex: 0 0 auto; width: 2.2rem; height: 2.2rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 1.05rem; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); }
.auth-hero-foot { position: relative; z-index: 1; font-size: .8125rem; color: rgba(255, 255, 255, .62); }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 2rem 1.5rem; background: var(--sc-surface); }
.auth-box { width: 100%; max-width: 440px; }
.auth-mobile-brand { display: none; }
.auth-split .auth-card { box-shadow: none !important; background: transparent; }
.auth-split .auth-card .card-body { padding: 0; }
.auth-title { font-size: 1.6rem; font-weight: 600; margin: 0 0 .2rem; color: var(--bs-heading-color); }
.auth-lead { color: var(--bs-secondary-color); font-size: .9375rem; margin-bottom: 1.5rem; }
.auth-card .card-body { padding: 1.75rem; }
.auth-field { position: relative; }
.auth-field > .bi { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--sc-muted); pointer-events: none; z-index: 5; }
.auth-field > .form-control, .auth-field > .input-group > .form-control { padding-left: 2.5rem; }
.pw-toggle { border-color: var(--sc-input-border); color: var(--sc-text-2); background: var(--bs-body-bg); }
.pw-toggle:hover { color: var(--sc-text); background: var(--bs-tertiary-bg); }
.caps-warn { display: flex; align-items: center; gap: .35rem; margin-top: .35rem; font-size: .8125rem; font-weight: 500; color: var(--bs-warning-text-emphasis); }
.auth-divider { display: flex; align-items: center; gap: .75rem; color: var(--sc-muted); font-size: .8125rem; margin: 1.1rem 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--sc-border); }
.auth-notes { text-align: center; font-size: .8125rem; color: var(--bs-secondary-color); line-height: 1.6; margin-top: 1.25rem; }
.auth-notes a { font-weight: 500; }
.auth-wait { display: flex; align-items: center; gap: .5rem; margin-top: .35rem; font-weight: 600; }
.demo-card { margin-top: 1.25rem; border: 1px dashed #f0b468; background: #fffaf2; border-radius: var(--sc-radius); padding: .85rem 1rem; font-size: .875rem; line-height: 1.55; }
[data-bs-theme="dark"] .demo-card { background: #22190e; border-color: #7a4a17; }
.demo-card-title { display: flex; align-items: center; gap: .4rem; font-weight: 600; margin-bottom: .45rem; }
.demo-users { display: flex; flex-wrap: wrap; gap: .35rem; }
.demo-user { display: inline-flex; flex-direction: column; align-items: flex-start; padding: .25rem .55rem; border: 1px solid var(--sc-border); border-radius: .375rem;
  background: var(--bs-body-bg); color: var(--bs-body-color); font-size: .8125rem; line-height: 1.35; text-align: left; transition: border-color .15s, background-color .15s; }
.demo-user code { font-size: .8125rem; font-weight: 600; color: var(--sc-brand-text); }
.demo-user span { color: var(--bs-secondary-color); font-size: .75rem; }
.demo-user:hover { border-color: var(--sc-brand); background: var(--sc-hover); }
.demo-ribbon { position: fixed; top: 1.1rem; right: -2.6rem; z-index: 50; transform: rotate(45deg); width: 10rem; padding: .2rem 0; text-align: center;
  font-size: .75rem; font-weight: 700; color: #7a2e00; background: #ffd9a3; border-top: 1px solid #f5b26b; border-bottom: 1px solid #f5b26b; pointer-events: none; }
@media (max-width: 991.98px) {
  .blank-main.auth-split { display: block; background: var(--sc-page); }
  .auth-hero { display: none; }
  .auth-panel { min-height: 100vh; padding: 1.5rem 1rem 2rem; align-items: flex-start; background: transparent; }
  .auth-split .auth-card { background: var(--sc-surface); box-shadow: var(--sc-shadow-sm) !important; }
  .auth-split .auth-card .card-body { padding: 1.35rem; }
  .auth-mobile-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem; margin: .5rem 0 1.25rem; }
  .auth-mobile-brand img { width: 56px; height: 56px; }
  .auth-mobile-brand .auth-app { color: var(--sc-brand-text); font-size: 1.5rem; }
  .auth-mobile-brand .auth-app-sub { color: var(--bs-secondary-color); }
  .auth-card .card-body { padding: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { .blank-main:has(> .login-card) { animation: none; } }

/* --------------------------------------------------------------- print */
/* หน้าพิมพ์ (layout print) ใช้โหมดสว่างเสมอ · ขนาดกระดาษ: page_start(['paper' => 'A4' | 'A4-landscape' | 'A5' | 'none']) — app/layout.php ใส่ @page ให้
   (ค่าเริ่มต้น A4 ขอบ 15/15/18 มม. + เลขหน้า "หน้า X/Y") · ฉลาก/บัตรคิว/บัตรนัด (paper none) ไม่กำหนดขนาด ใช้ขนาดของเครื่องพิมพ์ฉลาก
   หน้าจอทั่วไป (layout app) = ขอบ + เลขหน้า ไม่บังคับขนาด/แนวกระดาษ (ตารางกว้างเลือกแนวนอนในหน้าต่างพิมพ์ได้)
   พิมพ์: ตัวอักษร 11pt ตาราง 10pt · แถวตารางไม่ถูกตัดข้ามหน้า · ซ่อนปุ่ม/breadcrumb/ตัวแบ่งหน้า/แท็บที่ไม่ได้เลือก */
.print-toolbar { position: fixed; top: .75rem; right: .75rem; z-index: 10; display: flex; gap: .4rem; }
.print-main { max-width: 960px; margin: 0 auto; padding: 1.5rem; background: #fff; color: #000; }
.layout-print { background: #e9ecef; }
.print-watermark { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; font-size: 2.2rem; color: rgba(0, 0, 0, .06); transform: rotate(-30deg); z-index: 0; white-space: nowrap; }
@media print {
  /* สำรองเมื่อสคริปต์ไม่ทำงาน (app.js สลับเป็นโหมดสว่างตอน beforeprint อยู่แล้ว): ตัวแปรสีกลับเป็นค่าโหมดสว่าง — กระดาษขาว ตัวอักษรดำ */
  [data-bs-theme="dark"] { color-scheme: light; --sc-page: #fff; --sc-surface: #fff; --sc-surface-2: #f4f4f4; --sc-border: #ccc; --sc-border-row: #ddd; --sc-input-border: #bbb;
    --sc-text: #000; --sc-text-2: #333; --sc-muted: #555; --sc-brand-text: #1d5fa8; --sc-brand-tint: #e8f0fa; --sc-shadow-sm: none; --sc-shadow-md: none;
    --bs-body-bg: #fff; --bs-body-bg-rgb: 255, 255, 255; --bs-body-color: #000; --bs-body-color-rgb: 0, 0, 0; --bs-heading-color: #000;
    --bs-secondary-color: #444; --bs-tertiary-color: #555; --bs-tertiary-bg: #f4f4f4; --bs-secondary-bg: #eee; --bs-border-color: #ccc; --bs-border-color-translucent: rgba(0, 0, 0, .15);
    --bs-emphasis-color: #000; --bs-link-color: #1d5fa8; --bs-link-color-rgb: 29, 95, 168;
    --bs-primary-text-emphasis: #123e70; --bs-secondary-text-emphasis: #3d4652; --bs-success-text-emphasis: #0a3622; --bs-info-text-emphasis: #055160;
    --bs-warning-text-emphasis: #664d03; --bs-danger-text-emphasis: #58151c; --bs-dark-text-emphasis: #495057;
    --bs-primary-bg-subtle: #e8f0fa; --bs-secondary-bg-subtle: #eceff3; --bs-success-bg-subtle: #d1e7dd; --bs-info-bg-subtle: #cff4fc; --bs-warning-bg-subtle: #fff3cd;
    --bs-danger-bg-subtle: #f8d7da; --bs-dark-bg-subtle: #ced4da; --bs-primary-border-subtle: #b9d0ec; --bs-secondary-border-subtle: #d5dbe3; --bs-success-border-subtle: #a3cfbb;
    --bs-info-border-subtle: #9eeaf9; --bs-warning-border-subtle: #ffe69c; --bs-danger-border-subtle: #f1aeb5;
    --sc-purple-text: #4b2a85; --sc-purple-bg: #ece4fa; --sc-teal-text: #0b5d56; --sc-teal-bg: #d5f2ef;
    --sc-orange-text: #9a3b07; --sc-orange-bg: #ffe6d5; --sc-pink-text: #8c1840; --sc-pink-bg: #fbdbe7;
    --sc-chart-1: #2a78d6; --sc-chart-2: #eb6834; --sc-chart-3: #1baf7a; --sc-chart-4: #eda100; --sc-chart-5: #e87ba4; --sc-chart-6: #008300; --sc-chart-7: #4a3aa7; --sc-chart-8: #e34948;
    --sc-chart-muted: #8a94a3; --sc-chart-grid: #e8ecf2; --sc-chart-axis: #c3cbd6; --sc-chart-text: #5b6676; }
  [data-bs-theme="dark"] .allergy-bar.allergy-none { background: #e6f4ea; color: #1e6b34; }
  [data-bs-theme="dark"] .allergy-bar.allergy-unknown { background: #fff3cd; color: #6b4f00; }
  [data-bs-theme="dark"] .text-bg-light { color: #000 !important; background-color: #f4f4f4 !important; }
  [data-bs-theme="dark"] .table-light, [data-bs-theme="dark"] .table-secondary { --bs-table-color: #000; --bs-table-bg: #f4f4f4; --bs-table-border-color: #ccc; }
  html, body { background: #fff !important; }
  body { font-size: 11pt; line-height: 1.5; }
  .table, .table-sm { font-size: 10pt; }
  .table > :not(caption) > * > * { padding: .25rem .45rem; }
  .table thead th { font-size: 9.5pt; color: #333; background: #f4f4f4; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  /* ไม่ตัดแถวตาราง/การ์ดตัวเลข/การ์ดกราฟข้ามหน้า (การ์ดกราฟย้ายไปหน้าถัดไปทั้งใบ — ไม่ตัดเฉพาะกราฟ ซึ่งทำให้หัวการ์ดแยกจากกราฟ) */
  tr, .kpi, .chart-box, .card:has(canvas), figure, img, svg { break-inside: avoid; page-break-inside: avoid; }
  h1, h2, h3, h4, h5, h6, .page-head { break-after: avoid; page-break-after: avoid; }
  .layout-print { background: #fff; }
  .print-main { padding: 0; max-width: none; }
  .paper-none .print-main { margin: 0; }
  .d-print-none, .app-header, .app-sidebar, .app-footer, .sidebar-backdrop, .page-icon, .print-toolbar, .skip-link, .page-back, .page-crumbs, .breadcrumb, .pagination, .demo-pill,
  .btn, .btn-group, .btn-toolbar, .dropdown-menu, .toast-container, .modal, .sticky-actions, .ac-menu { display: none !important; }
  .nav-tabs .nav-link:not(.active), .nav-pills .nav-link:not(.active) { display: none !important; }
  .nav-tabs .nav-link.active, .nav-pills .nav-link.active { box-shadow: none; padding-left: 0; background: transparent !important; color: #000 !important; font-weight: 600; }
  .app-main { padding: 0 !important; min-height: 0; }
  .app-page-title { margin: 0 0 .6rem !important; padding: 0 !important; background: none !important; box-shadow: none !important; }
  .nav-tabs .nav-link.active::after { display: none; }
  .kpi { border-bottom-width: 1px !important; }
  .kpi .kpi-icon { box-shadow: none; }
  .app-content { padding: 0 !important; }
  .page-head { margin-bottom: .6rem; }
  .page-head h1, .page-title { font-size: 16pt; }
  .page-subtitle { font-size: 10pt; color: #333; }
  .patient-banner { position: static; box-shadow: none; border: 1px solid #ccc; }
  .card { border: 1px solid #ccc !important; box-shadow: none !important; }
  .card > .card-header { background: #f7f7f7; }
  .table-responsive, .table-sticky { -webkit-mask-image: none !important; mask-image: none !important; overflow: visible !important; max-height: none !important; }
  .table-sticky thead th { position: static; }
  /* กราฟ: charts.js วางภาพกราฟ (สีโหมดสว่าง ความละเอียด 2 เท่า) แทน canvas ตอนพิมพ์ — ภาพย่อตามกระดาษโดยคงสัดส่วน
     สำรองเมื่อไม่มีภาพ: canvas ไม่กว้างเกินกระดาษ (คงสัดส่วน) */
  canvas { max-width: 100% !important; height: auto !important; }
  canvas.sc-print-canvas { display: none !important; }
  .sc-print-img { display: block !important; width: 100%; height: auto; margin: 0 auto; }
  .chart-box:has(.sc-print-img) { height: auto !important; }
  /* แถว grid ที่มีกราฟจัดเป็นบล็อกต่อกันตอนพิมพ์ (คอลัมน์เต็มความกว้างกระดาษอยู่แล้ว) — Chrome ตัดหน้า flex หลายบรรทัดแล้วการ์ดซ้อนทับกัน */
  .row:has(canvas) { display: block; }
  .row:has(canvas) > * { width: 100%; max-width: 100%; }
  a { text-decoration: none; color: #000; }
  .print-watermark { color: rgba(0, 0, 0, .08); }
  /* สีที่สื่อความปลอดภัย และพื้นสีทึบที่มีตัวอักษรสีขาว (ปิด "พิมพ์กราฟิกพื้นหลัง" แล้วตัวอักษรขาวบนกระดาษขาวจะหายไป) ต้องพิมพ์พื้นออกเสมอ */
  .allergy-bar, .badge, .legend-dot, .progress-bar, .bed-tile, .esi-badge, .kpi-icon, .list-group-item.active, [class*="text-bg-"],
  .bg-primary, .bg-secondary, .bg-success, .bg-danger, .bg-warning, .bg-info, .bg-dark, .bg-purple, .bg-teal, .bg-orange, .bg-pink, .gantt-bar, .table-active,
  .table-primary, .table-success, .table-danger, .table-warning, .table-info { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (prefers-reduced-motion: reduce) {
  .app-sidebar, .app-main, .kpi, .skip-link { transition: none; }
  a.kpi:hover { transform: none; }
}

/* ---------------------------------------------------------- Dashboard: แถบเลือกช่วงเวลา */
.dsh-toolbar { overflow-x: auto; scrollbar-width: none; }
.dsh-range { flex-wrap: nowrap; }
.dsh-range > .btn { white-space: nowrap; }
/* reg/visit_open: ห้องตรวจหลายสิบห้อง — ค้นหาได้ และเลื่อนในกรอบบนจอกว้าง (ปุ่มบันทึกไม่ถูกดันลงไปไกล) */
.unit-filter-hide { display: none !important; }
@media (min-width: 992px) { .vt-unit-grid { max-height: 52vh; overflow-y: auto; padding-right: .25rem; } }
.vt-clamp { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vt-card:has(input:checked) .vt-clamp { -webkit-line-clamp: 4; line-clamp: 4; } /* ประเภทที่เลือกแสดงรายละเอียดมากขึ้น */
/* reg/delete: รายการข้อมูลที่ผูกกับผู้ป่วย 2 คอลัมน์ (รายการยาวไม่ต้องเลื่อนมาก) */
.del-inv { column-count: 2; column-gap: 1.75rem; }
.del-inv li { break-inside: avoid; }
@media (max-width: 575.98px) { .del-inv { column-count: 1; } }

/* ---------------------------------------------------------- ปุ่มในช่องกรอก: ถ่ายรูปอ่านข้อความ (assets/js/ocr.js) · พิมพ์ด้วยเสียง (assets/js/dictation.js) */
/* ชุดเดียวทุกหน้า (เดิม CSS ไมค์อยู่ใน cds.css ที่โหลดเฉพาะหน้าที่มีแผงผู้ช่วยวิเคราะห์อาการ — หน้าอื่นปุ่มไมค์ไม่มีรูปแบบ)
   ปุ่มกลมมุมขวาของช่อง: textarea = มุมขวาบน · ช่องบรรทัดเดียว = กึ่งกลางแนวตั้ง · ไมค์ขวาสุด (สีแดง) กล้องซ้ายไมค์ (สีน้ำเงิน) · ช่อง -sm = ปุ่มเล็ก */
.ocr-wrap, .dict-wrap { position: relative; }
.ocr-wrap > textarea, .dict-wrap > textarea { padding-right: 2.85rem; }
.ocr-wrap > input, .dict-wrap > input { padding-right: 2.7rem; }
.ocr-wrap.dict-wrap > textarea { padding-right: 5.1rem; }
.ocr-wrap.dict-wrap > input { padding-right: 4.95rem; }
.ocr-cam, .dict-mic { position: absolute; top: .35rem; right: .4rem; width: 30px; height: 30px; border-radius: 50%; padding: 0; line-height: 1; z-index: 2; font-size: .95rem;
  display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease; }
.ocr-wrap > input ~ .ocr-cam, .dict-wrap > input ~ .ocr-cam, .dict-wrap > input ~ .dict-mic { top: 50%; transform: translateY(-50%); }
.dict-wrap .ocr-cam { right: 2.7rem; }
.dict-mic { color: #c92a2a; background: rgba(201, 42, 42, .07); border-color: rgba(201, 42, 42, .28); }
.ocr-cam { color: var(--sc-brand, #1d5fa8); background: rgba(29, 95, 168, .07); border-color: rgba(29, 95, 168, .28); }
.dict-mic:hover, .dict-mic:focus-visible { color: #fff; background: #c92a2a; border-color: #c92a2a; box-shadow: 0 0 0 .2rem rgba(201, 42, 42, .2); outline: 0; }
.ocr-cam:hover, .ocr-cam:focus-visible { color: #fff; background: var(--sc-brand, #1d5fa8); border-color: var(--sc-brand, #1d5fa8); box-shadow: 0 0 0 .2rem rgba(29, 95, 168, .2); outline: 0; }
.dict-mic.is-active { color: #fff; background: #e03131; border-color: #e03131; animation: dict-pulse 1.2s infinite; }
.dict-wrap > .form-control-sm ~ .dict-mic, .dict-wrap > .form-control-sm ~ .ocr-cam, .ocr-wrap > .form-control-sm ~ .ocr-cam { width: 24px; height: 24px; font-size: .78rem; right: .3rem; }
.dict-wrap > textarea.form-control-sm ~ .dict-mic, .dict-wrap > textarea.form-control-sm ~ .ocr-cam, .ocr-wrap > textarea.form-control-sm ~ .ocr-cam { top: .25rem; }
.dict-wrap > .form-control-sm ~ .ocr-cam { right: 2rem; }
.ocr-wrap > .form-control-sm, .dict-wrap > .form-control-sm { padding-right: 2.2rem; }
.ocr-wrap.dict-wrap > .form-control-sm { padding-right: 3.9rem; }
[data-bs-theme="dark"] .dict-mic { color: #ff8787; background: rgba(255, 135, 135, .1); border-color: rgba(255, 135, 135, .32); }
[data-bs-theme="dark"] .ocr-cam { color: #8fc1ff; background: rgba(143, 193, 255, .1); border-color: rgba(143, 193, 255, .32); }
/* แผงพิมพ์ด้วยเสียงแทรกในเนื้อหาใต้ส่วนของฟอร์ม (ไม่ลอย position:fixed — เคยทับเมนูด้านข้าง/แผงผู้ช่วย AI/แถบบน) */
.dict-panel { position: relative; width: 100%; max-width: 100%; margin: .6rem 0 .8rem; display: none; border-color: var(--bs-danger-border-subtle); box-shadow: var(--sc-shadow-sm, 0 1px 3px rgba(0,0,0,.08)) !important; }
.dict-panel.show { display: block; }
.dict-panel .card-header { line-height: 1.45; background: var(--bs-danger-bg-subtle); }
.dict-dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--bs-secondary-bg); border: 1px solid var(--bs-border-color); flex: 0 0 auto; }
.dict-panel.listening .dict-dot { background: #e03131; border-color: #e03131; animation: dict-pulse 1.2s infinite; }
@keyframes dict-pulse { 0% { box-shadow: 0 0 0 0 rgba(224, 49, 49, .6); } 70% { box-shadow: 0 0 0 .5rem rgba(224, 49, 49, 0); } 100% { box-shadow: 0 0 0 0 rgba(224, 49, 49, 0); } }
.dict-notice { line-height: 1.5; padding: .4rem .55rem; border-radius: .45rem; background: var(--bs-info-bg-subtle); color: var(--bs-info-text-emphasis); border: 1px solid var(--bs-info-border-subtle); }
.dict-notice.dict-acked { opacity: .8; }
.dict-text { font-size: .95rem; line-height: 1.55; }
.dict-interim { min-height: 1.4em; color: var(--bs-secondary-color); font-style: italic; line-height: 1.45; margin-top: .2rem; }
@media (max-width: 575.98px) { .dict-panel .card-body { padding: .5rem; } }
@media (prefers-reduced-motion: reduce) { .dict-mic.is-active, .dict-panel.listening .dict-dot { animation: none; } }
@media print { .dict-mic, .dict-panel { display: none !important; } }
.ocr-canvas-wrap { max-height: 55vh; overflow: auto; border: 1px solid var(--bs-border-color); border-radius: .5rem; background: var(--bs-tertiary-bg); text-align: center; }
.ocr-canvas { max-width: 100%; height: auto; touch-action: none; cursor: crosshair; display: inline-block; vertical-align: top; }
.ocr-video { width: 100%; max-height: 50vh; border-radius: .5rem; background: #000; }
.ocr-prog { height: .6rem; }
@media print { .ocr-cam { display: none !important; } }

/* =====================================================================
   เอกสารพิมพ์แบบทางการ (layout print — ทุกหน้าพิมพ์ของระบบ)
   หัวกระดาษโรงพยาบาล (print_letterhead_html) · ชื่อเอกสาร (print_doc_title) · ตาราง/ข้อความสีดำเส้นขอบชัด · ป้ายสถานะเป็นกรอบ (ไม่ใช่พื้นสี)
   ช่องลงนามมาตรฐาน (print_signatures) · ท้ายกระดาษ/เลขหน้าอยู่ใน @page (page_paper_css)
   ===================================================================== */
.doc-letterhead { display: flex; align-items: center; gap: 4mm; padding-bottom: 2.5mm; margin-bottom: 4mm; border-bottom: 2.4pt double #000; color: #000; }
.doc-letterhead .lh-logo { width: 19mm; height: 19mm; object-fit: contain; flex: 0 0 auto; }
.doc-letterhead .lh-text { min-width: 0; line-height: 1.3; }
.doc-letterhead .lh-name { font-size: 15pt; font-weight: 700; }
.doc-letterhead .lh-name-en { font-size: 10.5pt; font-weight: 600; letter-spacing: .15pt; }
.doc-letterhead .lh-addr { font-size: 9.5pt; color: #111; }
.layout-print .print-main { font-family: "Sarabun", "TH Sarabun New", "TH SarabunPSK", sans-serif; color: #000; line-height: 1.5; }
.layout-print .print-main h1, .layout-print .print-main h2, .layout-print .print-main h3, .layout-print .print-main h4, .layout-print .print-main h5, .layout-print .print-main h6 { color: #000; font-weight: 700; }
.doc-title-block { text-align: center; margin: 1mm 0 4mm; }
.doc-title { font-size: 16pt; font-weight: 700; margin: 0; letter-spacing: .2pt; }
.doc-subtitle { font-size: 11pt; margin-top: .5mm; }
.doc-meta { display: flex; justify-content: flex-end; gap: 6mm; font-size: 10.5pt; margin-top: 2mm; }
.layout-print .print-main .table:not(.table-borderless) { --bs-table-bg: transparent; --bs-table-striped-bg: transparent; --bs-table-hover-bg: transparent; border-collapse: collapse; }
.layout-print .print-main .table:not(.table-borderless) > :not(caption) > * > * { border: .6pt solid #000; color: #000; box-shadow: none; }
.layout-print .print-main .table:not(.table-borderless) > thead > tr > th,
.layout-print .print-main .table:not(.table-borderless) th[scope="row"] { background: #eee; font-weight: 700; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.layout-print .print-main .badge:not(.esi-badge):not(.shift-badge) { background: transparent !important; color: #000 !important; border: .6pt solid #000; border-radius: 1mm; font-weight: 600; }
.layout-print .print-main .card { border: .6pt solid #000 !important; border-radius: 0; box-shadow: none !important; }
.layout-print .print-main .card > .card-header { background: transparent !important; border-bottom: .6pt solid #000; font-weight: 700; color: #000; }
.layout-print .print-main .alert { border: .6pt solid #000; border-radius: 0; background: transparent; color: #000; }
.layout-print .print-main .text-body-secondary, .layout-print .print-main .text-muted { color: #222 !important; }
.layout-print .print-main a { color: #000; text-decoration: none; }
.layout-print .print-main .border-bottom { border-bottom-color: #000 !important; }
.sign-blocks { display: flex; flex-wrap: wrap; justify-content: space-around; gap: 8mm 10mm; margin-top: 10mm; break-inside: avoid; page-break-inside: avoid; color: #000; }
.sign-block { min-width: 64mm; text-align: center; line-height: 2; font-size: 11pt; }
.sign-block .sb-line { display: inline-block; min-width: 46mm; border-bottom: .8pt dotted #000; vertical-align: bottom; }
.sign-block .sb-line.sb-short { min-width: 40mm; }
.sign-block .sb-line.sb-date { min-width: 9mm; }
.sign-block .sb-esign { font-size: 8.5pt; line-height: 1.3; color: #222; }
.sign-cols-3 .sign-block { min-width: 52mm; }
.sign-blocks.sign-single { justify-content: flex-end; padding-right: 4mm; }
.sign-blocks.sign-single .sign-block { width: 50%; }
.sign-block .sb-heading { font-weight: 700; margin-bottom: 8mm; }
@media print {
  .layout-print .print-main { font-size: 11.5pt; }
  .layout-print .print-main .small, .layout-print .print-main small { font-size: 10pt; }
  .print-watermark { color: rgba(0, 0, 0, .05); }
}

/* ---------------------------------------------------------------- Refer ออนไลน์ (หน้าโรงพยาบาลเครือข่าย modules/rnet + การ์ดใน req/view) */
.rnet-body { background: var(--sc-page, #f3f5f9); min-height: 100vh; }
.rnet-wrap { max-width: 1140px; }
.rnet-main { padding-top: 1rem; padding-bottom: 1rem; }
.rnet-thread { display: flex; flex-direction: column; gap: .5rem; max-height: 28rem; overflow-y: auto; }
.rnet-msg { border-radius: .5rem; padding: .45rem .65rem; font-size: .9rem; max-width: 92%; border: 1px solid var(--bs-border-color); }
.rnet-msg.rnet-in { align-self: flex-start; background: var(--bs-body-bg); }
.rnet-msg.rnet-out { align-self: flex-end; background: var(--bs-primary-bg-subtle); border-color: var(--bs-primary-border-subtle); }
.rnet-meta { font-size: .75rem; color: var(--bs-secondary-color); margin-bottom: .15rem; }
.rnet-top .btn-light, .rnet-top .btn-light:hover { color: var(--sc-navy, #0b2545); }

/* ---------------------------------------------------------------- [geo] ช่องที่อยู่: จังหวัด → อำเภอ/เขต → ตำบล/แขวง (ระยะที่ 8)
   ui_thai_address() ใน app/ext/geo.php + assets/js/thaiaddr.js — combobox (input[role=combobox] + ul.ta-list[role=listbox]) · จบบล็อกที่ "[geo] จบ" */
.ta-combo { position: relative; }
.ta-combo.has-toggle > .form-control { padding-right: 2.25rem; }
.ta-toggle { position: absolute; top: 1px; right: 1px; bottom: 1px; width: 2.1rem; display: flex; align-items: center; justify-content: center; padding: 0; border: 0;
  border-radius: 0 var(--bs-border-radius) var(--bs-border-radius) 0; background: transparent; color: var(--bs-secondary-color); cursor: pointer; }
.ta-toggle:hover:not(:disabled) { color: var(--bs-body-color); background: var(--bs-tertiary-bg); }
.ta-toggle:disabled { opacity: .45; cursor: default; }
.ta-toggle[hidden], .ta-list[hidden] { display: none; }
.ta-list { position: absolute; z-index: 1060; left: 0; right: 0; top: 100%; max-height: min(45vh, 20rem); overflow-y: auto; overscroll-behavior: contain; margin: 2px 0 0; padding: 0;
  list-style: none; background: var(--bs-body-bg); border: 1px solid var(--sc-border); border-radius: .55rem; box-shadow: var(--sc-shadow-md); }
.ta-opt, .ta-empty { padding: .5rem .75rem; font-size: .95rem; line-height: 1.45; border-bottom: 1px solid var(--sc-border-row); }
.ta-opt { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .5rem; cursor: pointer; }
.ta-opt:last-child, .ta-empty:last-child { border-bottom: 0; }
.ta-opt:hover, .ta-opt.active { background: var(--bs-primary-bg-subtle); }
.ta-opt.active { box-shadow: inset 3px 0 0 var(--bs-primary); }
.ta-opt.is-current .ta-main { font-weight: 600; }
.ta-opt .ta-sub { color: var(--bs-secondary-color); font-size: .8125rem; }
.ta-empty { color: var(--bs-secondary-color); cursor: default; }
.ta-hint { color: var(--bs-warning-text-emphasis); }
@media (pointer: coarse) {
  .ta-opt, .ta-empty { padding: .7rem .85rem; }
  .ta-toggle { width: 2.6rem; }
  .ta-combo.has-toggle > .form-control { padding-right: 2.75rem; }
}
@media print { .ta-list, .ta-toggle, .ta-search-wrap { display: none !important; } }
/* [geo] จบ */

/* [acct] หลายบัญชีพร้อมกันในเบราว์เซอร์เดียว (ช่องบัญชี — app/layout.php render_account_slots_menu / ป้าย .acct-chip) */
/* สีประจำช่อง: ตัวอักษรขาวบนพื้นสีผ่านความต่างสี AA (>= 4.5:1) ทั้งโหมดสว่างและมืด */
.acct-slot-0 { --acct: #0b5ed7; } .acct-slot-1 { --acct: #b02a72; } .acct-slot-2 { --acct: #6f42c1; }
.acct-slot-3 { --acct: #b35400; } .acct-slot-4 { --acct: #0f7b6c; } .acct-slot-5 { --acct: #3d5a80; }
.acct-slot-6 { --acct: #8a5a00; } .acct-slot-7 { --acct: #0a6e8a; } .acct-slot-8 { --acct: #5c6b00; }
body.acct-multi .app-header { box-shadow: inset 0 3px 0 var(--acct), var(--sc-shadow-sm); }
.acct-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; background: var(--acct); color: #fff;
  font-size: .75rem; font-weight: 600; line-height: 1.2; white-space: nowrap; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.acct-chip-text { overflow: hidden; text-overflow: ellipsis; }
.acct-item { display: flex; gap: .5rem; align-items: flex-start; white-space: normal; }
.acct-dot { flex: 0 0 auto; width: .7rem; height: .7rem; margin-top: .3rem; border-radius: 50%; background: var(--acct); }
.acct-login-note { border-left: 4px solid var(--acct); }
@media (max-width: 575.98px) { .acct-chip { padding: .2rem .45rem; } }
@media print { .acct-chip { display: none !important; } body.acct-multi .app-header { box-shadow: none; } }
/* [acct] จบ */

/* [p19] ระยะที่ 19 — กลุ่มเมนู "ควบคุมการติดเชื้อ (IC)" (คีย์กลุ่ม ics) + แถบแท็บของ Dashboard 21 หมวด */
/* สีประจำกลุ่ม ics: เขียวมะกอก (ช่วงสีที่กลุ่มอื่นยังไม่ใช้ — ต่างจากเขียวของการเงิน g5 และส้มของประสานงาน g4) · ข้อความบนพื้นอ่อน ≥ 4.5:1 ทั้งโหมดสว่าง/มืด */
:root, [data-bs-theme="light"] { --sc-m-ics: #4d7c0f; --sc-m-ics-t: #3f6212; --sc-m-ics-b: #ecf6d6; --sc-m-ics-l: #c7e29a; }
[data-bs-theme="dark"] { --sc-m-ics: #a3d94a; --sc-m-ics-t: #c9ee8c; --sc-m-ics-b: #222e0f; --sc-m-ics-l: #40561c; }
body[data-mod="ics"] { --sc-mod: var(--sc-m-ics); --sc-mod-text: var(--sc-m-ics-t); --sc-mod-bg: var(--sc-m-ics-b); --sc-mod-border: var(--sc-m-ics-l); --sc-mod-a: #3f6212; --sc-mod-b: #5c940d; }
[data-bs-theme="dark"] body[data-mod="ics"] { --sc-mod-a: var(--sc-mod-text); --sc-mod-b: var(--sc-mod); }
.nav-group[data-group="ics"] { --sc-dot: var(--sc-m-ics); }
:root[data-sb-theme]:not([data-sb-theme="white"]) .nav-group[data-group="ics"] { --sc-dot: #c9ee7d; }
/* แถบแท็บของ Dashboard (dsh_tab_strip): แถบเลื่อนแนวนอน ไอคอน + ชื่อ หัวข้อกลุ่มคั่น · ปุ่มเลือกหมวดนำหน้าแสดงแท็บปัจจุบันเสมอ (เกิน 6 แท็บ) */
.dsh-tabbar { min-width: 0; border-bottom: 1px solid var(--sc-border); }
.dsh-tabs { min-width: 0; border-bottom: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scroll-behavior: smooth; overscroll-behavior-x: contain; align-items: flex-end; }
.dsh-tabs .nav-link { display: inline-flex; align-items: center; gap: .35rem; padding: .55rem .8rem; }
.dsh-tabs .nav-link .bi { font-size: 1rem; opacity: .85; }
.dsh-tabs .nav-link.active .bi { opacity: 1; }
/* แท็บที่เปิดอยู่ตรึงขอบแถบ (เลื่อนแถบไปทางใดก็ยังเห็น) — พื้นสีเดียวกับหน้า บังแท็บที่เลื่อนผ่านด้านหลัง */
.dsh-tabs .dsh-tab-on { position: sticky; left: 0; right: 0; z-index: 2; background: var(--sc-page); box-shadow: 0 0 .4rem .3rem var(--sc-page); }
.dsh-tab-group { display: flex; align-items: center; align-self: stretch; margin-left: .35rem; padding: 0 .45rem 0 .7rem; border-left: 1px solid var(--sc-border); }
.dsh-tab-group > span { font-size: .6875rem; font-weight: 600; letter-spacing: .01em; color: var(--bs-secondary-color); white-space: nowrap; }
.dsh-tab-group:first-child { margin-left: 0; padding-left: 0; border-left: 0; }
.dsh-tab-pick { margin-bottom: .3rem; }
.dsh-tab-pick > .btn { display: inline-flex; align-items: center; gap: .4rem; max-width: 46vw; font-weight: 600; color: var(--sc-mod-text); border-color: var(--sc-mod-border); background: var(--sc-mod-bg); }
.dsh-tab-pick > .btn:hover, .dsh-tab-pick > .btn:focus-visible, .dsh-tab-pick > .btn.show { color: var(--sc-mod-text); border-color: var(--sc-mod); background: var(--sc-mod-bg); }
.dsh-tab-pick-label { overflow: hidden; text-overflow: ellipsis; }
.dsh-tab-menu { max-height: min(70vh, 34rem); overflow-y: auto; min-width: 15rem; }
.dsh-tab-menu .dropdown-item { display: flex; align-items: center; gap: .5rem; }
.dsh-tab-menu .dropdown-header { padding-top: .6rem; }
.dsh-prefs-sec { border: 0; padding: 0; min-width: 0; }
.dsh-prefs-sec > legend { float: none; width: 100%; font-size: .95rem; padding-bottom: .3rem; border-bottom: 1px solid var(--sc-border); }
@media (min-width: 768px) { .dsh-tab-pick > .btn { max-width: 16rem; } }
@media (max-width: 575.98px) {
  .dsh-tabs .nav-link { padding: .5rem .6rem; }
  .dsh-tab-group { margin-left: .2rem; padding: 0 .3rem 0 .45rem; }
}
@media (pointer: coarse) { .dsh-tab-menu .dropdown-item { padding-top: .55rem; padding-bottom: .55rem; } }
@media (prefers-reduced-motion: reduce) { .dsh-tabs { scroll-behavior: auto; } }
@media print {
  .dsh-tabbar { border-bottom: 0; margin-bottom: .4rem !important; }
  .dsh-tabs { overflow: visible; }
  .dsh-tabs .dsh-tab-on { position: static; background: none; box-shadow: none; }
  .dsh-tab-group, .dsh-tab-pick { display: none !important; }
}
/* [p19] จบ */

/* =====================================================================
   [p19 u-core] ขนาดจอและรายการ: ตารางหลายคอลัมน์ · Dashboard (dsh/home dsh/unit dsh/my) · รายงาน (rpt/view rpt/index)
   คลาสใหม่ทั้งหมด — ไม่เปลี่ยนชื่อ/ความหมายของคลาสเดิม
   ===================================================================== */
/* ---- ตาราง: หัวคอลัมน์ตัดบรรทัดได้ (ui_table 'head_wrap' หรือ class="table-head-wrap" ที่ <table>) — คอลัมน์ตัวเลขไม่กว้างตามชื่อหัว */
.table-head-wrap > thead > tr > th { white-space: normal; }
.table-head-wrap > thead > tr > th:is(.text-end, .text-center, .num) { min-width: 3.75rem; }
/* ---- ตาราง: คอลัมน์แรกค้างด้านซ้ายเมื่อเลื่อนแนวนอน (ui_table 'pin' หรือ class="table-pin" / "table-pin-narrow" = เฉพาะจอ < 992px)
        พื้นของช่องมาจาก --bs-table-bg ของ Bootstrap (ทึบ) · เส้นคั่นวาดด้วย ::after (เส้นขอบของช่อง sticky ในตาราง border-collapse เลื่อนหาย) */
.table-pin > :is(thead, tbody, tfoot) > tr > :first-child { position: sticky; left: 0; z-index: 1; }
.table-pin > :is(thead, tbody, tfoot) > tr > :first-child::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 1px; background: var(--sc-border); pointer-events: none; }
.table-sticky .table-pin > thead > tr > th:first-child { z-index: 3; }
.table-responsive.sc-sx-l:has(> .table-pin) { -webkit-mask-image: none; mask-image: none; }
.table-responsive.sc-sx-l.sc-sx-r:has(> .table-pin) { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), rgba(0, 0, 0, .15)); mask-image: linear-gradient(to right, #000 calc(100% - 2rem), rgba(0, 0, 0, .15)); }
@media (max-width: 991.98px) {
  .table-pin-narrow > :is(thead, tbody, tfoot) > tr > :first-child { position: sticky; left: 0; z-index: 1; }
  .table-pin-narrow > :is(thead, tbody, tfoot) > tr > :first-child::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 1px; background: var(--sc-border); pointer-events: none; }
  .table-sticky .table-pin-narrow > thead > tr > th:first-child { z-index: 3; }
  .table-responsive.sc-sx-l:has(> .table-pin-narrow) { -webkit-mask-image: none; mask-image: none; }
  .table-responsive.sc-sx-l.sc-sx-r:has(> .table-pin-narrow) { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), rgba(0, 0, 0, .15)); mask-image: linear-gradient(to right, #000 calc(100% - 2rem), rgba(0, 0, 0, .15)); }
  /* คอลัมน์ที่ค้างไม่กินเกิน ~40% ของจอ (ชื่อยาวตัดบรรทัดแทน) */
  :is(.table-pin, .table-pin-narrow) > :is(thead, tbody, tfoot) > tr > :first-child { max-width: 42vw; white-space: normal; overflow-wrap: break-word; }
}
@media print {
  :is(.table-pin, .table-pin-narrow) > :is(thead, tbody, tfoot) > tr > :first-child { position: static; max-width: none; }
  :is(.table-pin, .table-pin-narrow) > :is(thead, tbody, tfoot) > tr > :first-child::after { content: none; }
}
/* ---- ข้อความยาวในรายการ: แสดงไม่เกิน 2/3 บรรทัด (ใส่ข้อความเต็มใน title เสมอ) · clamp-md-2 = ตัดเฉพาะจอ ≥ 768px (จอสัมผัสไม่มี tooltip — แสดงเต็ม) */
.clamp-2, .clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }
@media (min-width: 768px) { .clamp-md-2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; } }
@media print { .clamp-2, .clamp-3, .clamp-md-2 { display: block; -webkit-line-clamp: unset; line-clamp: unset; overflow: visible; } }
/* ---- หัวเรื่องการแจ้งเตือน (ntf/inbox): จอกว้างบรรทัดเดียวตัดด้วย … · มือถือแสดงได้ 2 บรรทัด (เดิมเห็นแค่ครึ่งหัวเรื่อง) — ข้อความเต็มอยู่ใน title */
.ntf-title { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: break-word; }
@media (min-width: 768px) { .ntf-title { display: block; white-space: nowrap; text-overflow: ellipsis; } }
/* ---- แถวล่างของการ์ดตัวกรอง (ui_filter_form 'below') */
.filter-form .filter-below { margin-top: .15rem; padding-top: .5rem; border-top: 1px dashed var(--sc-border); }

/* ---------------------------------------------------------------- Dashboard: แถวการ์ดกราฟ/ตาราง */
/* แถวที่ไม่ครบ 12 ช่อง (ซ่อนบางตัวชี้วัด/ความกว้างต่างชุดกัน) ขยายเต็มแถว — ไม่มีช่องโหว่ข้างการ์ด */
.dsh-cards > [class*="col"] { flex-grow: 1; min-width: 0; }
/* ตารางในการ์ดของ Dashboard: คอลัมน์ชื่อ (หอ/หน่วย/รายการ) กว้างพออ่านในบรรทัดเดียว-สองบรรทัด */
.dsh-cards .card > .table-responsive > .table > tbody > tr > td:first-child { min-width: 8.5rem; }
.dsh-cards .card > .table-responsive > .table > tbody > tr > td:first-child:is(.col-tight, .text-end, .text-center) { min-width: 0; }
/* หัวข้อของส่วน (dsh/my) */
.sc-sec { margin-bottom: 1.75rem; }
.sc-sec-head { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .75rem; margin-bottom: .85rem; padding-bottom: .5rem; border-bottom: 1px solid var(--sc-border); }
.sc-sec-head > h2 { font-size: 1.0625rem; font-weight: 700; line-height: 1.45; color: var(--sc-card-title, var(--bs-heading-color)); margin: 0 auto 0 0; }
.sc-sec-head > h2 > .bi:first-child { margin-right: .35rem; color: var(--sc-mod-text); }
.sc-sec-head .sc-sec-note { font-size: .8125rem; color: var(--bs-secondary-color); }
.sc-sub-head { display: flex; align-items: center; gap: .4rem; margin: 1rem 0 .5rem; font-size: .8125rem; font-weight: 600; color: var(--bs-secondary-color); }
.sc-sub-head::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--sc-border-row); }
.sc-chips { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.sc-chips > .badge { padding: .4em .7em; font-size: .8125rem; line-height: 1.4; max-width: 100%; white-space: normal; text-align: left; }
@media (max-width: 575.98px) {
  .sc-sec { margin-bottom: 1.35rem; }
  /* แถบแท็บ 21 หมวดบนมือถือ: ปุ่มเลือกหมวดเต็มความกว้าง (แสดงหมวดปัจจุบัน + รายการทุกหมวดตามกลุ่ม) แทนแถบเลื่อนที่ซ้ำชื่อเดียวกัน */
  .dsh-tabbar:has(> .dsh-tab-pick) { border-bottom: 0; }
  .dsh-tabbar:has(> .dsh-tab-pick) > .dsh-tabs { display: none; }
  .dsh-tabbar > .dsh-tab-pick { flex: 1 1 auto; margin-bottom: 0; }
  .dsh-tabbar > .dsh-tab-pick > .btn { width: 100%; max-width: none; justify-content: flex-start; }
  .dsh-tabbar > .dsh-tab-pick > .btn::after { margin-left: auto; }
  .dsh-tabbar > .dsh-tab-pick > .dsh-tab-menu { width: 100%; }
}

/* ---------------------------------------------------------------- รายงาน (rpt/view): หัวหน้า · ช่วงสำเร็จรูป · ตาราง (rpt_table_html) */
.rpt-desc { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.filter-form .rpt-presets { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.filter-form .rpt-presets .btn { margin: 0; }
.rpt-presets-label { margin-right: .25rem; white-space: nowrap; }
@media (max-width: 575.98px) {
  .filter-form .rpt-presets { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: .15rem; }
  .filter-form .rpt-presets .btn { white-space: nowrap; flex: 0 0 auto; }
}
/* ตารางรายงาน: เลื่อนในกรอบ (หัวตารางค้าง — .table-sticky) · หัวคอลัมน์ตัดบรรทัดได้ · ตัวเลขชิดขวาไม่ตัดบรรทัด · ข้อความยาวตัดบรรทัดในความกว้างที่กำหนด
   (ตัวเลือกของ .rpt-grid เจาะจงกว่า ".rpt-table td, .rpt-table th { white-space: nowrap }" ใน quality.css ซึ่งโหลดทีหลัง) */
.rpt-scroll { --sc-sticky-h: 72vh; }
.rpt-grid > thead > tr > th { white-space: normal; vertical-align: bottom; }
.rpt-grid > :is(thead, tbody, tfoot) > tr > .rpt-n { text-align: right; }
.rpt-grid > thead > tr > th.rpt-n { min-width: 4rem; }
.rpt-grid > :is(tbody, tfoot) > tr > td:is(.rpt-n, .rpt-d, .rpt-t-s) { white-space: nowrap; }
.rpt-grid > thead > tr > th.rpt-d { min-width: 5.5rem; }
.rpt-grid > :is(tbody, tfoot) > tr > td.rpt-t-m { white-space: normal; min-width: 12rem; max-width: 22rem; overflow-wrap: break-word; }
.rpt-grid > :is(tbody, tfoot) > tr > td.rpt-t-l { white-space: normal; min-width: 17rem; max-width: 30rem; overflow-wrap: break-word; }
.rpt-grid > tbody > tr > td { vertical-align: top; }
/* คอลัมน์แรก: ความกว้างตามชนิดของคอลัมน์เอง (ตัวเลือกเจาะจงเท่ากับกฎคอลัมน์แรกของ .table ในหมวดตาราง และมาทีหลัง) */
.table.rpt-grid.rpt-table > tbody > tr > td:first-child { min-width: 0; }
.table.rpt-grid.rpt-table > tbody > tr > td.rpt-t-m:first-child { min-width: 11rem; }
.table.rpt-grid.rpt-table > tbody > tr > td.rpt-t-l:first-child { min-width: 14rem; }
/* แถวรวม: ตัวหนา พื้นสีกลุ่ม เส้นคู่ด้านบน ค้างที่ขอบล่างของกรอบเมื่อเลื่อน */
.rpt-grid > tfoot > tr > td { position: sticky; bottom: 0; z-index: 1; font-weight: 700; color: var(--bs-heading-color); white-space: nowrap;
  background-color: color-mix(in srgb, var(--sc-mod-bg) 55%, var(--sc-surface-2)); box-shadow: inset 0 2px 0 var(--sc-border); border-bottom: 0; }
.rpt-grid.table-pin > tfoot > tr > td:first-child { z-index: 2; }
@media (max-width: 991.98px) {
  .rpt-grid.table-pin-narrow > tfoot > tr > td:first-child { z-index: 2; }
  .rpt-grid > :is(tbody, tfoot) > tr > td.rpt-t-m { min-width: 10rem; }
  .rpt-grid > :is(tbody, tfoot) > tr > td.rpt-t-l { min-width: 13rem; max-width: 22rem; }
}
@media (max-width: 575.98px) {
  .rpt-scroll { --sc-sticky-h: 78vh; }
  .table.rpt-grid.rpt-table > :is(tbody, tfoot) > tr > td:first-child:is(.rpt-t-m, .rpt-t-l) { min-width: 7rem; }
}
@media print {
  .rpt-grid > tfoot > tr > td { position: static; box-shadow: none; }
}

/* ---------------------------------------------------------------- แคตตาล็อกรายงาน (rpt/index): แถบค้นหา + ป้ายกลุ่ม · หัวกลุ่มมีจำนวน · การ์ดย่อ */
.rpt-jump { display: flex; flex-wrap: wrap; gap: .35rem; }
.rpt-jump > a { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .65rem; border: 1px solid var(--sc-border); border-radius: 2rem; background: var(--sc-surface);
  font-size: .8125rem; line-height: 1.5; color: var(--bs-body-color); text-decoration: none; white-space: nowrap; }
.rpt-jump > a:hover, .rpt-jump > a:focus-visible { border-color: var(--sc-mod); color: var(--sc-mod-text); background: var(--sc-mod-bg); }
.rpt-jump > a > .rpt-jump-n { font-weight: 600; color: var(--bs-secondary-color); font-variant-numeric: tabular-nums; }
.rpt-group { scroll-margin-top: 5rem; }
.rpt-group > .rpt-group-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; padding-bottom: .4rem; border-bottom: 1px solid var(--sc-border); }
.rpt-group > .rpt-group-head > h2 { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.45; color: var(--sc-card-title, var(--bs-heading-color)); }
.rpt-group > .rpt-group-head > .rpt-top { margin-left: auto; font-size: .8125rem; white-space: nowrap; }
.rpt-tile { display: flex; align-items: flex-start; gap: .7rem; height: 100%; padding: .6rem .8rem; border: 1px solid var(--bs-card-border-color, var(--sc-border)); border-radius: var(--sc-radius);
  background: var(--sc-surface); color: var(--bs-body-color); text-decoration: none; box-shadow: var(--sc-shadow-sm); transition: border-color .15s, transform .15s; }
[data-bs-theme="dark"] .rpt-tile { border-color: var(--sc-border); box-shadow: none; }
.rpt-tile:hover, .rpt-tile:focus-visible { border-color: var(--sc-mod); color: var(--bs-body-color); transform: translateY(-1px); }
.rpt-tile > .rpt-tile-icon { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; border-radius: .5rem; font-size: 1.15rem;
  background: var(--sc-mod-bg); color: var(--sc-mod-text); }
.rpt-tile > .rpt-tile-text { min-width: 0; }
.rpt-tile .rpt-tile-title { font-weight: 600; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rpt-tile .rpt-tile-desc { margin-top: .1rem; font-size: .8125rem; line-height: 1.45; color: var(--bs-secondary-color); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .rpt-tile { transition: none; } .rpt-tile:hover { transform: none; } }
@media print { .rpt-jump, .rpt-top { display: none !important; } .rpt-tile { box-shadow: none; break-inside: avoid; } }
/* [p19 u-core] จบ */
/* [p21] ปุ่มภาษา ไทย/English ที่แถบด้านบน (app/ext/i18n.php ui_lang_switch_html) + ลิงก์ภาษาที่หน้าเข้าสู่ระบบ + หน้าตรวจสอบระบบ */
.topbar-btn.hd-lang { --hd: #0b7285; }
[data-bs-theme="dark"] .topbar-btn.hd-lang { --hd: #66d9e8; }
.topbar-btn.hd-lang .lang-code { font-size: .76rem; font-weight: 700; letter-spacing: .04em; line-height: 1; }
.lang-menu .dropdown-menu { min-width: 12rem; }
.lang-menu .lang-code-sm { display: inline-block; min-width: 1.8rem; font-size: .72rem; font-weight: 700; color: var(--bs-secondary-color); }
.auth-lang a { text-decoration: none; }
.auth-lang .bi { margin-right: .25rem; color: var(--bs-secondary-color); }
.card.syscheck-fail { border-color: rgba(var(--bs-danger-rgb), .45); }
.card.syscheck-warn { border-color: rgba(var(--bs-warning-rgb), .55); }
@media (max-width: 767.98px) { .lang-menu { display: none; } } /* จอแคบ: เลือกภาษาจากเมนูผู้ใช้แทน (ui_lang_user_menu_html) */
/* [p21] จบ */

/* ---- ประวัติการทำงานของระบบ แท็บตามเวลาจริง (adm/activity&tab=live — assets/js/activity_live.js) ---- */
.act-live-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--bs-success); animation: act-pulse 1.6s infinite; }
.act-live-dot.is-paused { background: var(--bs-secondary); animation: none; }
.act-live-dot.is-offline { background: var(--bs-warning); animation: none; }
.act-live-dot.is-stopped { background: var(--bs-danger); animation: none; }
@keyframes act-pulse { 0% { box-shadow: 0 0 0 0 rgba(var(--bs-success-rgb), .5); } 70% { box-shadow: 0 0 0 .5rem rgba(var(--bs-success-rgb), 0); } 100% { box-shadow: 0 0 0 0 rgba(var(--bs-success-rgb), 0); } }
[data-act-live] tbody > tr > * { transition: box-shadow 1.5s ease-out; }
[data-act-live] tbody > tr.act-new > * { --bs-table-bg-state: rgba(var(--bs-primary-rgb), .16); }
.act-online .list-group-item { font-size: .875rem; }
@media (prefers-reduced-motion: reduce) { .act-live-dot { animation: none; } [data-act-live] tbody > tr > * { transition: none; } }

/* หน้าไม่รีโหลด (ระยะ 28 — app.js SC.soft): ปุ่มลอยกลางขอบล่างของจอ เมื่อมีข้อมูลใหม่แต่รอผู้ใช้กรอกค้างอยู่ */
.sc-soft-pill { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 1080; border-radius: 2rem; padding: .35rem 1rem; max-width: calc(100vw - 2rem); white-space: normal; }
@media (min-width: 992px) { body.layout-app .sc-soft-pill { left: calc(50% + var(--sc-sidebar-w, 0px) / 2); } }
/* ระยะ 28: เชื่อมต่อเซิร์ฟเวอร์ไม่ได้นาน — แถบเตือนด้านบน + เนื้อหาจางลง (ไม่ให้ข้อมูลเก่าดูเหมือนข้อมูลปัจจุบัน) */
.sc-stale { position: fixed; top: .75rem; left: 50%; transform: translateX(-50%); z-index: 1085; max-width: calc(100vw - 2rem); }
body.sc-stale-dim .app-main, body.sc-stale-dim > main#main { opacity: .55; }
