/* =====================================================================
   NMAPEO e-Office (ระบบสำนักงานอิเล็กทรอนิกส์) — ระบบดีไซน์กลาง
   ฟอนต์: IBM Plex Sans Thai (โฮสต์ในเครื่อง ไม่ต้องใช้อินเทอร์เน็ต)
   สี: หมึกน้ำเงินเข้ม (ตัวอักษร), โคบอลต์ (ปุ่มหลัก), ดาวเรือง (วันนี้/เวลาปัจจุบัน)
   ===================================================================== */

@font-face { font-family: "IBM Plex Sans Thai"; src: url("../fonts/ibm-plex-sans-thai/IBMPlexSansThai-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Thai"; src: url("../fonts/ibm-plex-sans-thai/IBMPlexSansThai-Medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Thai"; src: url("../fonts/ibm-plex-sans-thai/IBMPlexSansThai-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Thai"; src: url("../fonts/ibm-plex-sans-thai/IBMPlexSansThai-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --canvas: #F4F6FA;
  --surface: #FFFFFF;
  --surface-2: #F8F9FC;
  --ink: #18213A;
  --ink-2: #47516A;
  --muted: #5F6982;
  --line: #E2E6EE;
  --line-2: #EDF0F5;
  --primary: #2C54E0;
  --primary-ink: #1E3FB5;
  --primary-wash: #EDF1FF;
  --accent: #E9A21B;
  --accent-wash: #FFF5E1;
  --ok: #117A55;
  --ok-wash: #E4F4EC;
  --bad: #BE3A31;
  --bad-wash: #FCEBEA;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --sidebar-w: 272px;
  --side-bg: #F3F5F9;   /* 3.125.0 พื้นแถบเมนูด้านซ้าย */
  --topbar-h: 64px;

  --bs-body-font-family: "IBM Plex Sans Thai", "Leelawadee UI", Tahoma, system-ui, sans-serif;
  --bs-body-font-size: 1rem;
  --bs-body-line-height: 1.65;
  --bs-body-color: #18213A;
  --bs-body-bg: #F4F6FA;
  --bs-emphasis-color: #18213A;
  --bs-secondary-color: #5F6982;
  --bs-primary: #2C54E0;
  --bs-primary-rgb: 44, 84, 224;
  --bs-link-color: #2C54E0;
  --bs-link-color-rgb: 44, 84, 224;
  --bs-link-hover-color: #1E3FB5;
  --bs-link-hover-color-rgb: 30, 63, 181;
  --bs-border-color: #E2E6EE;
  --bs-border-radius: 10px;
  --bs-border-radius-sm: 8px;
  --bs-border-radius-lg: 12px;
  --bs-focus-ring-color: rgba(44, 84, 224, .25);
}

body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { text-underline-offset: .2em; }
h1, h2, h3, h4 { color: var(--ink); letter-spacing: -.005em; }
.tnum { font-variant-numeric: tabular-nums; }
::selection { background: rgba(44, 84, 224, .18); }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 2000; background: var(--ink); color: #fff; padding: .5rem .9rem; border-radius: var(--r-sm); }
.skip-link:focus { left: 8px; }

/* ---------- ปุ่มและฟอร์ม ---------- */
.btn { font-weight: 600; border-radius: 10px; padding: .5rem 1rem; display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; }   /* 3.89.0 ไอคอนอยู่หน้าข้อความบรรทัดเดียวกันเสมอ */
.btn-sm { border-radius: 8px; padding: .3rem .7rem; font-size: .9rem; }
.btn-lg { padding: .65rem 1.3rem; font-size: 1.02rem; border-radius: 12px; }
.btn i { margin-right: .3rem; flex: none; }
.btn.text-nowrap, .btn-sm { flex-wrap: nowrap; }
.btn-primary {
  --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary-ink); --bs-btn-hover-border-color: var(--primary-ink);
  --bs-btn-active-bg: #183294; --bs-btn-active-border-color: #183294;
  --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary);
  --bs-btn-focus-shadow-rgb: 44, 84, 224;
}
/* 3.89.0 ปุ่มรองไม่ใช้พื้นขาว: พื้นฟ้าอ่อน ตัวอักษรน้ำเงินเข้ม (คอนทราสต์ 7:1) แยกจากพื้นการ์ดสีขาวชัดเจน */
.btn-light {
  --bs-btn-bg: #EAF0FF; --bs-btn-border-color: #C9D6FB; --bs-btn-color: var(--primary-ink);
  --bs-btn-hover-bg: #DCE6FF; --bs-btn-hover-border-color: #AFC3F8; --bs-btn-hover-color: #172F8A;
  --bs-btn-active-bg: #CFDCFF; --bs-btn-active-border-color: #9DB5F5; --bs-btn-active-color: #172F8A;
  --bs-btn-disabled-bg: #F0F2F6; --bs-btn-disabled-border-color: var(--line); --bs-btn-disabled-color: var(--muted);
}
.btn-outline-primary { --bs-btn-bg: #F3F6FF; --bs-btn-color: var(--primary); --bs-btn-border-color: #A9BDF7; --bs-btn-hover-bg: var(--primary); --bs-btn-hover-border-color: var(--primary); }
.btn-outline-danger { --bs-btn-bg: var(--bad-wash); --bs-btn-border-color: #EBB3AE; --bs-btn-color: var(--bad); --bs-btn-hover-bg: var(--bad); --bs-btn-hover-border-color: var(--bad); }
.btn-outline-warning { --bs-btn-bg: var(--accent-wash); }

.form-label { font-weight: 600; color: var(--ink); margin-bottom: .35rem; font-size: .95rem; }
.form-control, .form-select { border-color: var(--line); border-radius: 10px; padding: .55rem .85rem; background-color: #fff; }
.form-control-lg { border-radius: 12px; padding: .7rem 1rem; font-size: 1.02rem; }
.form-control::placeholder { color: #9AA3B6; }
.form-control:focus, .form-select:focus { border-color: #8EA8F2; box-shadow: 0 0 0 .22rem rgba(44, 84, 224, .14); background-color: #fff; }
.form-text { color: var(--muted); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.input-group > .btn { border-color: var(--line); }
.req { color: var(--bad); }

.alert { border-radius: var(--r); border: 0; padding: .85rem 1.1rem; }
.alert-success { background: var(--ok-wash); color: #0C5C40; }
.alert-danger { background: var(--bad-wash); color: #8E241D; }
.alert-warning { background: var(--accent-wash); color: #7A4B00; }
.alert-info { background: var(--primary-wash); color: var(--primary-ink); }

.dropdown-menu { border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 32px rgba(24, 33, 58, .12); padding: .4rem; }
.dropdown-item { border-radius: 8px; padding: .5rem .75rem; display: flex; align-items: center; gap: .6rem; }
.dropdown-item i { color: var(--muted); }
.dropdown-item.text-danger i { color: inherit; }
.dropdown-head { padding: .45rem .75rem .55rem; display: flex; flex-direction: column; line-height: 1.35; }
.dropdown-head small { color: var(--muted); }

/* ---------- โครงหน้า: sidebar + topbar ---------- */
.shell { display: flex; min-height: 100vh; }
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

/* 3.125.0 พื้นแถบเมนูสีเทาอ่อน ให้การ์ดสีขาวของแต่ละหมวดเห็นชัด */
.sidebar { display: flex; flex-direction: column; background: var(--side-bg); }
@media (min-width: 992px) {
  .sidebar.offcanvas-lg {
    position: sticky; top: 0; height: 100vh; width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    border-right: 1px solid var(--line); background-color: var(--side-bg) !important;
  }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { background-color: var(--side-bg) !important; }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { --bs-offcanvas-width: min(300px, 86vw); }
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 1.1rem 1.1rem .9rem; }
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ink); min-width: 0; }
.brand:hover { color: var(--ink); }
.brand-logo { width: 40px; height: 40px; object-fit: contain; flex: none; }
.brand-mark {
  width: 40px; height: 40px; flex: none; border-radius: 11px; background: var(--primary);
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 9px;
}
.brand-mark i { display: block; border-radius: 3px; background: #fff; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { opacity: .7; }
.brand-mark i:nth-child(4) { background: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand-text strong { font-size: .98rem; font-weight: 700; }
.brand-text small { font-size: .8rem; color: var(--muted); }
.brand-text small.brand-org { font-size: .8rem; }   /* ชื่อระบบ 3 บรรทัด (3.105.0 ศธจ.นครราชสีมา) */
.brand-text strong, .brand-text small { overflow-wrap: anywhere; }

.sidebar-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: .25rem .75rem 1rem; }
.side-group { margin: 1.15rem .6rem .35rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.side-link {
  display: flex; align-items: center; gap: .7rem; padding: .5rem .65rem; margin: 1px 0; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .95rem; line-height: 1.4;
}
.side-link > i { font-size: 1.1rem; width: 26px; text-align: center; color: var(--muted); }
.side-link:hover { background: var(--surface-2); color: var(--ink); }
.side-link.active { background: var(--primary-wash); color: var(--primary-ink); font-weight: 600; }
.side-link.active > i { color: var(--primary); }
.module-link.is-current { color: var(--ink); font-weight: 600; }
.side-link.is-soon { color: #9AA3B6; cursor: default; }
.side-link.is-soon:hover { background: none; color: #9AA3B6; }
.side-link.is-soon .glyph { filter: grayscale(1); opacity: .45; }
.side-link em { margin-left: auto; font-style: normal; font-size: .75rem; font-weight: 600; color: var(--muted); background: var(--line-2); padding: .05rem .5rem; border-radius: 999px; white-space: nowrap; }
.side-sub { margin: .15rem 0 .5rem 1.45rem; padding-left: .75rem; border-left: 2px solid var(--line-2); display: flex; flex-direction: column; gap: 1px; }
.sub-link { display: block; padding: .38rem .7rem; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: .92rem; }
.sub-link:hover { background: var(--surface-2); color: var(--ink); }
.sub-link.active { background: var(--primary-wash); color: var(--primary-ink); font-weight: 600; }
.sub-link.has-badge { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.sub-badge { min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: #B42318; color: #fff; font-size: .75rem; font-weight: 700; line-height: 1.35rem; text-align: center; }

/* เมนูหลักที่มีเมนูย่อย: ยุบไว้ กดเพื่อคลี่ (assets/js/app.js) */
.side-toggle { width: 100%; border: 0; background: none; text-align: left; font-family: inherit; cursor: pointer; }
.side-toggle > span:not(.glyph) { flex: 1 1 auto; min-width: 0; }
.side-caret { margin-left: auto; font-size: .78rem; color: var(--muted); transition: transform .28s cubic-bezier(.2, .7, .2, 1); }
.side-module.is-open > .side-toggle { color: var(--ink); }
.side-module.is-open > .side-toggle .side-caret { transform: rotate(180deg); color: var(--ink-2); }
.side-collapse {
  display: grid; grid-template-rows: 0fr; opacity: 0; visibility: hidden;
  transition: grid-template-rows .3s cubic-bezier(.2, .7, .2, 1), opacity .22s ease, visibility 0s linear .3s;
}
.side-collapse-inner { min-height: 0; overflow: hidden; }
.side-module.is-open > .side-collapse {
  grid-template-rows: 1fr; opacity: 1; visibility: visible;
  transition: grid-template-rows .3s cubic-bezier(.2, .7, .2, 1), opacity .25s ease .05s, visibility 0s;
}
.side-collapse .side-sub { transform: translateY(-4px); transition: transform .3s cubic-bezier(.2, .7, .2, 1); }
.side-module.is-open > .side-collapse .side-sub { transform: none; }
.side-module.no-anim .side-collapse, .side-module.no-anim .side-sub, .side-module.no-anim .side-caret { transition: none !important; }
.sub-link.sub-module { display: flex; align-items: center; gap: .55rem; padding: .34rem .6rem; }
.sub-link.side-toggle { line-height: inherit; color: var(--ink-2); }
.sub-link.side-toggle:hover { color: var(--ink); }
.sub-link.side-toggle .side-caret { font-size: .75rem; margin-right: .1rem; }
.side-module-sub.is-open > .side-toggle { color: var(--ink); font-weight: 600; }
.sub-link.sub-module.is-current { color: var(--ink); font-weight: 600; }
.side-sub3 { margin: .1rem 0 .3rem 1.35rem; padding-left: .6rem; border-left: 2px solid var(--line-2); display: flex; flex-direction: column; gap: 1px; }
.side-sub3 .sub-link { font-size: .88rem; padding: .3rem .6rem; }
.sub-link .sub-icon { font-size: .95rem; color: var(--muted); }
@media (prefers-reduced-motion: reduce) {
  .side-collapse, .side-collapse .side-sub, .side-caret { transition: none !important; }
}

.sidebar-foot { display: flex; align-items: center; gap: .65rem; padding: .8rem 1rem; border-top: 1px solid var(--line); }
.sidebar-foot .me { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; flex: 1; }
.sidebar-foot .me strong { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .me small { font-size: .78rem; color: var(--muted); }
.sidebar-foot form { margin: 0; }

.glyph {
  --glyph: var(--primary);
  width: 44px; height: 44px; border-radius: 12px; flex: none; display: inline-grid; place-items: center;
  background: var(--glyph); color: #fff; font-size: 1.25rem;
}
.glyph-sm { width: 26px; height: 26px; border-radius: 8px; font-size: .85rem; }
.glyph-xs { width: 22px; height: 22px; border-radius: 6px; font-size: .75rem; }
.glyph-lg { width: 60px; height: 60px; border-radius: 17px; font-size: 1.65rem; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  background: var(--accent); color: var(--ink); font-weight: 700; line-height: 1; font-size: .95rem;
}
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border: 0; border-radius: 10px;
  background: transparent; color: var(--ink-2); font-size: 1.15rem;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.topbar {
  position: sticky; top: 0; z-index: 1020; height: var(--topbar-h); display: flex; align-items: center; gap: .75rem;
  padding: 0 2rem; background: rgba(244, 246, 250, .88); backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line-2);
}
.crumb { display: flex; align-items: center; gap: .5rem; min-width: 0; flex: 1; font-size: .95rem; }
.crumb-module { display: inline-flex; align-items: center; gap: .5rem; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.crumb-module:hover { color: var(--ink); }
.crumb-sep { color: #A7AFC0; font-size: .75rem; }
.crumb-page { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-solo { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; }
.crumb-solo > span { overflow: hidden; text-overflow: ellipsis; }
.user-btn { display: flex; align-items: center; gap: .55rem; border: 0; background: transparent; padding: .25rem .5rem .25rem .25rem; border-radius: 999px; color: var(--ink); }
.user-btn:hover, .user-btn[aria-expanded="true"] { background: #fff; box-shadow: 0 0 0 1px var(--line); }
.user-btn .user-name { font-weight: 500; font-size: .93rem; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-btn .bi-chevron-down { font-size: .75rem; color: var(--muted); }

.content { padding: 1.75rem 2rem 2.5rem; width: 100%; max-width: 1320px; flex: 1 0 auto; }
.app-foot { margin-top: 3rem; padding-top: 1.1rem; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }

@media (max-width: 991.98px) {
  .topbar { padding: 0 .75rem; }
  .content { padding: 1.25rem 1rem 2rem; }
}
@media (max-width: 575.98px) {
  .user-btn .user-name, .user-btn .bi-chevron-down, .crumb-module span, .crumb-sep { display: none; }
  .crumb-module { margin-right: .1rem; }
}

/* ---------- ส่วนประกอบทั่วไป ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.page-head h1 { font-size: 1.6rem; font-weight: 700; margin: 0; line-height: 1.3; }
.page-head p { margin: .25rem 0 0; color: var(--muted); }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line-2); }
.panel-head h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.panel-head p { margin: 0; color: var(--muted); font-size: .88rem; }
.panel-head a { font-size: .9rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
@media (max-width: 575.98px) { .panel-head { flex-wrap: wrap; } .panel-head > div:first-child { min-width: 0; flex: 1 1 12rem; } }   /* 3.87.0 จอแคบ: ปุ่มขึ้นบรรทัดใหม่แทนล้นจอ */
.panel-body { padding: 1.25rem; }
@media (max-width: 400px) { .panel-body { padding: 1rem .85rem; } }   /* 3.87.0 จอ 320–400 ได้พื้นที่เพิ่ม */
.panel-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.panel-actions { display: flex; flex-wrap: wrap; gap: .5rem; padding: 1rem 1.25rem; border-top: 1px solid var(--line-2); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--ink-2); }
.empty-state > i { font-size: 2.1rem; color: #A3ACBE; display: block; margin-bottom: .6rem; }
.empty-state h1, .empty-state h2 { font-size: 1.08rem; font-weight: 700; color: var(--ink); margin: 0 0 .3rem; }
.empty-state p { color: var(--muted); margin: 0; }
section.empty-state { max-width: 560px; margin: 3rem auto; }
.empty-mini { color: var(--muted); padding: 1rem 1.25rem 1.25rem; margin: 0; }

.chip {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; line-height: 1.5;
  padding: .1rem .6rem; border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.chip-primary { background: var(--primary-wash); color: var(--primary-ink); }
.chip-ok { background: var(--ok-wash); color: var(--ok); }
.chip-bad { background: var(--bad-wash); color: var(--bad); }
.chip-accent { background: var(--accent-wash); color: #7A4B00; }

.facts { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: .7rem 1.25rem; margin: 0; }
.facts dt { color: var(--muted); font-weight: 500; }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
  .facts { grid-template-columns: 1fr; gap: .1rem; }
  .facts dt { margin-top: .6rem; }
}

.table-clean { --bs-table-bg: transparent; margin: 0; }
.table-clean > :not(caption) > * > * { padding: .75rem 1.25rem; border-color: var(--line-2); }
.table-clean thead th { font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom-color: var(--line); background: var(--surface-2); }
.table-clean tbody tr:last-child > * { border-bottom: 0; }
.table-clean a.row-title { color: var(--ink); text-decoration: none; font-weight: 600; }
.table-clean a.row-title:hover { color: var(--primary); text-decoration: underline; }
.table-clean form { margin: 0; }
.table-clean tr.is-off { color: var(--muted); }

.filter-bar { padding: 1rem 1.25rem; margin-bottom: 1rem; }
.filter-bar .form-label { font-size: .85rem; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon > .form-control { padding-left: 2.4rem; }
[aria-busy="true"] { opacity: .55; transition: opacity .15s; }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; padding: .85rem 1.25rem; border-top: 1px solid var(--line-2); font-size: .9rem; color: var(--muted); }
.pager-pages { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; list-style: none; margin: 0 auto; padding: 0; }
.pager-btn {
  min-width: 34px; height: 34px; padding: 0 .55rem; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); text-decoration: none; font-variant-numeric: tabular-nums;
}
a.pager-btn:hover { border-color: #C5CCDA; color: var(--ink); background: var(--surface-2); }
.pager-btn.is-current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pager-btn.is-disabled { opacity: .4; }
.pager-gap { padding: 0 .2rem; color: var(--muted); }
.pager-per { display: inline-flex; align-items: center; gap: .45rem; margin: 0; white-space: nowrap; }
.pager-per .form-select { width: auto; min-width: 4.8rem; padding-top: .2rem; padding-bottom: .2rem; }
.pager.is-card { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); margin-top: 1rem; }
@media (max-width: 575.98px) {
  .pager { justify-content: center; }
  .pager-info { width: 100%; text-align: center; }
}

/* ---------- หน้าหลัก ---------- */
.hello { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.5rem; }
.hello h1 { font-size: 1.75rem; font-weight: 700; margin: 0; line-height: 1.3; }
.hello p { margin: .2rem 0 0; color: var(--muted); }
.hello .last-login { font-size: .85rem; color: var(--muted); }

.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; padding: .75rem; }
@media (max-width: 575.98px) { .apps { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: .5rem; } .app { padding: .9rem .4rem; } }
.app {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .55rem;
  padding: 1.1rem .75rem 1rem; border-radius: 14px; text-decoration: none; color: var(--ink); position: relative;
}
a.app:hover { background: var(--surface-2); color: var(--ink); }
a.app:hover .glyph { transform: translateY(-2px); }
.app .glyph { transition: transform .15s ease; box-shadow: 0 6px 16px -6px var(--glyph); }
.app strong { font-weight: 600; font-size: 1rem; line-height: 1.35; }
.app small { color: var(--muted); font-size: .84rem; line-height: 1.45; max-width: 22ch; }
.app.is-soon { color: var(--muted); }
.app.is-soon .glyph { filter: grayscale(1); opacity: .4; box-shadow: none; }
.app.is-soon .chip { position: absolute; top: .6rem; right: .6rem; font-size: .75rem; }

/* ---------- หน้าบัญชี ---------- */
.profile-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.profile-head .avatar { width: 64px; height: 64px; font-size: 1.6rem; }
.profile-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0; }
.profile-head .roles { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .3rem; }
/* ข้อมูลของฉัน: อายุและอายุราชการ (3.24.0) */
.svc-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
@media (max-width: 1199.98px) { .svc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .svc-grid { grid-template-columns: 1fr; } }
.svc-tile { display: flex; flex-direction: column; gap: .2rem; padding: .9rem 1rem; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface-2); }
.svc-label { display: flex; align-items: center; gap: .4rem; color: var(--ink-2); font-size: .88rem; font-weight: 600; }
.svc-label i { color: var(--primary); }
.svc-val { font-size: 1.25rem; font-weight: 700; line-height: 1.35; color: var(--ink); font-variant-numeric: tabular-nums; }
.svc-na { font-size: .95rem; font-weight: 500; color: var(--muted); }
.svc-sub { color: var(--muted); font-size: .84rem; }
.svc-bar { margin-top: 1rem; }
.svc-bar-track { height: 10px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.svc-bar-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #5B7CF0); }
.svc-bar-labels { display: flex; justify-content: space-between; gap: .5rem; margin-top: .35rem; font-size: .82rem; color: var(--muted); }
.svc-bar-labels .tnum { color: var(--ink-2); font-weight: 600; }

.narrow { max-width: 560px; }
.rules { list-style: none; margin: .25rem 0 0; padding: 0; display: grid; gap: .3rem; font-size: .9rem; color: var(--muted); }
.rules li { display: flex; align-items: center; gap: .5rem; }
.rules li.is-ok { color: var(--ok); }
.note { display: flex; gap: .7rem; padding: .85rem 1rem; border-radius: var(--r); background: var(--primary-wash); color: var(--primary-ink); font-size: .92rem; }
.note i { font-size: 1.1rem; }
.note > div, .note > span { min-width: 0; overflow-wrap: anywhere; }   /* 3.87.0 จอ 320 ไม่ล้น */
.note.note-warn { background: var(--accent-wash); color: #6B4200; }
.note.note-bad { background: var(--bad-wash); color: var(--bad); }
.note.note-bad a { color: inherit; font-weight: 600; }

/* ---------- หน้าเข้าสู่ระบบ ---------- */
body.is-bare { background: var(--surface); }
.auth {
  --top: max(6vh, calc(50vh - 320px));
  --band: calc(var(--top) + 236px);
  position: relative; min-height: 100vh; background: var(--canvas); isolation: isolate;
}
.auth::before {
  content: ""; position: absolute; inset: 0 0 auto; height: var(--band); z-index: -1;
  background-color: var(--ink);
  background-image:
    radial-gradient(ellipse 60% 90% at 50% 0%, rgba(44, 84, 224, .38), transparent 70%),
    radial-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px);
  background-size: 100% 100%, 22px 22px;
}
.auth-wrap {
  width: 100%; max-width: 456px; margin: 0 auto; padding: var(--top) 20px 28px;
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
}
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 1.75rem; }
.auth-brand .brand-mark {
  width: 56px; height: 56px; border-radius: 16px; padding: 13px; gap: 5px; margin-bottom: 1rem;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .06), 0 10px 24px rgba(0, 0, 0, .25);
}
.auth-logo { width: 64px; height: 64px; object-fit: contain; margin-bottom: 1rem; }
.auth-app { color: #fff; font-size: 1.4rem; font-weight: 700; line-height: 1.35; margin: 0; }
.auth-sub { color: #DCE3F0; font-size: 1.05rem; font-weight: 600; margin: .1rem 0 0; }   /* 3.104.0 */
.auth-org { color: #AEB8CC; font-size: .95rem; margin: .15rem 0 0; }
.auth-card {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 2rem 2rem 1.5rem;
  box-shadow: 0 1px 2px rgba(24, 33, 58, .04), 0 24px 48px -16px rgba(24, 33, 58, .28);
}
.auth-form h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.auth-hint { color: var(--muted); font-size: .92rem; margin: .2rem 0 1.5rem; }
.auth-foot {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  color: var(--muted); font-size: .88rem; margin: 1.5rem 0 0; padding-top: 1.1rem; border-top: 1px solid var(--line-2);
}
.auth-legal { margin-top: auto; padding-top: 2rem; color: var(--muted); font-size: .8rem; text-align: center; }

@media (max-width: 575.98px) {
  .auth { --top: max(5vh, calc(50vh - 330px)); --band: calc(var(--top) + 214px); }
  .auth-wrap { padding: var(--top) 16px 20px; }
  .auth-brand { margin-bottom: 1.35rem; }
  .auth-brand .brand-mark { width: 48px; height: 48px; border-radius: 14px; padding: 11px; margin-bottom: .8rem; }
  .auth-app { font-size: 1.2rem; }
  .auth-sub { font-size: .98rem; }
  .auth-org { font-size: .88rem; }
  .auth-card { padding: 1.5rem 1.25rem 1.25rem; }
}

/* ---------- หน้าสาธารณะ (เช่น ลิงก์สั้นที่เปิดไม่ได้) ---------- */
.public-note {
  max-width: 460px; margin: 14vh auto 0; padding: 2.25rem 1.5rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: .6rem;
}
.public-note .brand-mark { width: 52px; height: 52px; border-radius: 15px; padding: 12px; gap: 5px; margin-bottom: .5rem; }
.public-note h1 { font-size: 1.45rem; font-weight: 700; margin: 0; }
.public-note .su-url { font-size: .85rem; color: var(--muted); word-break: break-all; max-width: 36rem; }
.public-note p { color: var(--ink-2); margin: 0; }
.public-note small { color: var(--muted); margin-top: 1.25rem; }

/* ---------- การเข้าถึงและการพิมพ์ ---------- */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible { outline: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .sidebar, .topbar, .app-foot, .panel-actions { display: none !important; }
  body, .content { background: #fff; padding: 0; }
}

/* ตารางเลื่อนแนวนอน: เก็บป้ายซ่อน (visually-hidden) ไว้ในกรอบ ไม่ให้หน้าเลื่อนแนวนอนบนมือถือ (3.40.0) */
.table-responsive { position: relative; }

/* ---------- รายการแบบแถว + กล่องวันที่ (ใช้ร่วมกันหลายระบบย่อย) ---------- */
.blist { list-style: none; margin: 0; padding: 0; }
.brow {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 1.1rem; align-items: center;
  padding: 1rem 1.25rem; border-top: 1px solid var(--line-2);
}
.brow:first-child { border-top: 0; }
.brow-compact { grid-template-columns: auto minmax(0, 1fr); padding: .85rem 1.25rem; gap: 1rem; }
.brow-top { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; font-size: .9rem; }
.brow-title { display: inline-block; font-weight: 600; font-size: 1.04rem; color: var(--ink); text-decoration: none; margin: .1rem 0; overflow-wrap: anywhere; line-height: 1.45; }
.brow-title:hover { color: var(--primary); text-decoration: underline; }
.brow-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem 1.1rem; color: var(--ink-2); font-size: .9rem; }
.brow-meta i { color: var(--muted); margin-right: .35rem; }
.brow-actions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
@media (max-width: 575.98px) {
  .brow { grid-template-columns: auto minmax(0, 1fr); padding: 1rem; }
  .brow-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

.dateblock {
  display: block; width: 62px; text-align: center; border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; background: #fff; line-height: 1.2; flex: none;
}
.dateblock .m { display: block; background: var(--ink); color: #fff; font-size: .75rem; font-weight: 600; padding: .18rem 0; }
.dateblock .d { display: block; font-size: 1.45rem; font-weight: 700; padding-top: .2rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.dateblock .w { display: block; font-size: .75rem; color: var(--muted); padding-bottom: .3rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; scrollbar-width: thin; }
.tabs a { padding: .6rem .9rem; color: var(--ink-2); text-decoration: none; font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--primary); }
.tabs .count { display: inline-block; min-width: 1.5rem; margin-left: .4rem; padding: 0 .4rem; border-radius: 999px; background: #E6EAF1; color: var(--ink-2); font-size: .76rem; text-align: center; }
.tabs a.active .count { background: var(--primary); color: #fff; }
/* หน้าหลัก: หมวดระบบงานตามสิทธิ์ และแท็บข้อมูลของแต่ละระบบ (3.22.0) */
.dash-note { color: var(--muted); font-size: .85rem; }
.dash-widgets { margin-top: .5rem; }
.dash-tabs { position: sticky; top: var(--topbar-h); z-index: 5; background: var(--canvas); margin-bottom: 1rem; }
.dash-tabs button { display: inline-flex; align-items: center; gap: .5rem; padding: .7rem 1rem; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px;
  background: none; color: var(--ink-2); font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; }
.dash-tabs button:hover { color: var(--ink); }
.dash-tabs button.active { color: var(--ink); border-bottom-color: var(--primary); }
.dash-tabs button:not(.active) .glyph { filter: saturate(.35); opacity: .75; }
.dash-tabs button:focus-visible { outline: 3px solid rgba(44, 84, 224, .35); outline-offset: -3px; border-radius: 6px; }

.live { color: var(--ok); font-weight: 600; white-space: nowrap; font-size: .9rem; }
.live::before { content: ""; display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--ok); margin-right: .35rem; vertical-align: .1em; box-shadow: 0 0 0 3px rgba(17, 122, 85, .18); }

.people { list-style: none; display: flex; flex-wrap: wrap; gap: .45rem; margin: .85rem 0 0; padding: 0; }
.person { display: inline-flex; align-items: center; gap: .5rem; border: 1px solid var(--line); border-radius: 999px; padding: .2rem .8rem .2rem .25rem; font-size: .92rem; background: #fff; }
.person .avatar, .table-clean .avatar { width: 28px; height: 28px; font-size: .8rem; background: #E9EDF4; color: var(--ink-2); }
.person.is-me { border-color: #A9BDF7; background: var(--primary-wash); }
.person.is-me .avatar { background: var(--accent); color: var(--ink); }

/* ---------- 3.47.0 เมนูผู้ดูแล (โล่สีอำพัน) และปุ่มคู่มือ ---------- */
:root { --admin: #B45309; --admin-ink: #92400E; --admin-wash: #FFF7EA; --admin-line: #F3DDB6; }
.sub-link .sub-label { flex: 1 1 auto; min-width: 0; }
.sub-link.is-admin { color: var(--admin-ink); }
.sub-link.is-admin:hover { background: var(--admin-wash); color: var(--admin-ink); }
.sub-link.is-admin.active { background: var(--admin-wash); color: var(--admin-ink); box-shadow: inset 3px 0 0 var(--admin); }
.sub-admin-mark { color: var(--admin); font-size: .78rem; flex: none; }
.sub-link.sub-manual { display: flex; align-items: center; gap: .5rem; margin-top: .3rem; padding-top: .45rem; border-top: 1px dashed var(--line); border-radius: 0 0 8px 8px; }
.sub-link.sub-manual > .bi { color: var(--muted); font-size: .92rem; }
.sub-link.sub-manual.active > .bi { color: var(--primary); }
/* 3.125.0 การ์ดสีขาวของแต่ละหมวดในเมนูด้านซ้าย (งานบุคลากร … บัญชีของฉัน) ขนาดและมุมเดียวกับกรอบ ผู้ดูแลระบบ */
.side-card { margin: .7rem .1rem .25rem; padding: .1rem .3rem .45rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(24, 33, 58, .04); }
.side-card .side-group { margin: .65rem .45rem .35rem; }
.sidebar-nav > .side-link:hover { background: var(--surface); }
/* 3.126.0 ตั้งค่าแจ้งเตือนอีเมล: ปิดทุกระบบอยู่ = รายการรายระบบจางลง */
.pref-dim .mod-list { opacity: .6; }
.pref-dim .mod-list:focus-within, .pref-dim .mod-list:hover { opacity: 1; }   /* หน้าหลัก อยู่นอกการ์ด บนพื้นสีเทา */
.side-card + .side-admin { margin-top: .7rem; }
.side-admin { margin: 1rem .1rem .25rem; padding: .1rem .3rem .45rem; border-radius: 14px; background: var(--admin-wash); border: 1px solid var(--admin-line); }
.side-admin .side-group-admin { display: flex; align-items: center; gap: .4rem; margin: .65rem .45rem .35rem; color: var(--admin-ink); font-weight: 700; }
.side-admin .side-group-admin .bi { color: var(--admin); font-size: .85rem; }
.side-admin .side-link > i { color: var(--admin); }
.side-admin .side-link:hover, .side-admin .sub-link:hover { background: rgba(255, 255, 255, .75); }
.side-admin .side-link.active, .side-admin .sub-link.active { background: #fff; color: var(--admin-ink); box-shadow: 0 0 0 1px var(--admin-line); }
.side-admin .side-link.active > i { color: var(--admin); }
.side-admin .side-sub, .side-admin .side-sub3 { border-left-color: var(--admin-line); }
.crumb-admin { display: inline-flex; align-items: center; gap: .3rem; flex: none; margin-left: .25rem; padding: .1rem .55rem; border-radius: 999px; background: var(--admin-wash); color: var(--admin-ink); border: 1px solid var(--admin-line); font-size: .78rem; font-weight: 600; white-space: nowrap; }
.crumb-admin .bi { color: var(--admin); font-size: .75rem; }
.help-btn { display: inline-flex; align-items: center; gap: .35rem; flex: none; height: 36px; padding: 0 .8rem; border-radius: 999px; border: 1px solid #C9D6FB; background: #EAF0FF; color: var(--primary-ink); text-decoration: none; font-size: .9rem; font-weight: 600; }
.help-btn:hover { color: var(--primary-ink); border-color: #C9D3F5; background: var(--primary-wash); }
.help-btn .bi { font-size: 1rem; color: var(--primary); }
.dash-sec.is-admin { background: linear-gradient(180deg, var(--admin-wash), #fff 140px); border-color: var(--admin-line); }
.dash-sec.is-admin h2 { display: flex; align-items: center; gap: .45rem; color: var(--admin-ink); }
.dash-admin-mark { color: var(--admin); font-size: 1rem; }
@media (max-width: 575.98px) {
  .crumb-admin span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .help-btn { padding: 0 .6rem; }
  .help-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
@media print { .help-btn, .crumb-admin { display: none !important; } }

/* ---------- 3.48.0 กลุ่มเมนูผู้ดูแล และคู่มือของบัญชีของฉัน ---------- */
.side-link.side-manual { font-size: .9rem; color: var(--ink-2); }
.side-link.side-manual > i { font-size: 1rem; }
.side-admin .side-toggle > i { font-size: 1.1rem; width: 26px; text-align: center; color: var(--admin); }
.admin-hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: .5rem; padding: 1rem; }
.admin-hub-card { display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; border-radius: 14px; border: 1px solid var(--admin-line); background: #fff; color: var(--ink); text-decoration: none; }
.admin-hub-card:hover { background: var(--admin-wash); color: var(--ink); border-color: #E9C78D; }
.admin-hub-icon { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--admin-wash); color: var(--admin); font-size: 1.2rem; border: 1px solid var(--admin-line); }
.admin-hub-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.45; }
.admin-hub-text small { color: var(--ink-2); font-size: .86rem; }
.admin-hub-card > .bi-chevron-right { color: var(--muted); }

/* ---------- 3.51.0 หน้าหลัก: การ์ดของแต่ละระบบเรียงลงมา ---------- */
.dash-sys { margin: 0 0 1.75rem; scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.dash-sys-head { display: flex; align-items: center; gap: .85rem; margin: 0 0 .75rem; }
.dash-sys-head > div { flex: 1 1 auto; min-width: 0; }
.dash-sys-head h2 { font-size: 1.2rem; font-weight: 700; margin: 0; }
.dash-sys-head p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.dash-sys-links { display: flex; align-items: center; gap: .4rem; flex: none; }
.dash-sys-links a { display: inline-flex; align-items: center; gap: .3rem; padding: .35rem .75rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); text-decoration: none; font-size: .88rem; font-weight: 500; white-space: nowrap; }
.dash-sys-links a:hover { color: var(--primary-ink); border-color: #C9D3F5; background: var(--primary-wash); }
.dash-sys-links a.dash-open { color: var(--primary-ink); border-color: #C9D3F5; }
.dash-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: .25rem; padding: .6rem; }
.dash-tool { display: flex; align-items: center; gap: .8rem; padding: .7rem .8rem; border-radius: 12px; color: var(--ink); text-decoration: none; }
.dash-tool:hover { background: var(--surface-2); color: var(--ink); }
.dash-tool > span { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.dash-tool small { color: var(--ink-2); font-size: .84rem; }
.dash-alert { display: flex; gap: .55rem; align-items: flex-start; margin: .75rem 1.25rem 0; padding: .6rem .85rem; border-radius: 10px; background: var(--accent-wash); color: #7A4A06; font-size: .92rem; }
.wl-dash-items { margin: .6rem 1.25rem 1rem; padding-left: 1.4rem; font-size: .94rem; } /* 3.53.0 ภาระงานของฉัน */
.wl-dash-items li { margin: .2rem 0; }
.dash-stats { display: flex; flex-wrap: wrap; gap: .5rem; padding: .85rem 1.25rem .25rem; }
.dash-stat { display: flex; flex-direction: column; min-width: 110px; padding: .5rem .85rem; border-radius: 12px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); line-height: 1.3; }
.dash-stat span { font-size: 1.3rem; font-weight: 700; }
.dash-stat small { color: var(--ink-2); font-size: .82rem; }
.dash-stat:hover { border-color: #C9D3F5; background: var(--primary-wash); color: var(--ink); }
.dash-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.25rem; border-top: 1px solid var(--line-2); }
.dash-row:first-child { border-top: 0; }
.dash-row > div:first-child { min-width: 0; }
.dash-row-end { display: flex; align-items: center; gap: .5rem; flex: none; }
@media (max-width: 575.98px) {
  .dash-sys-head { flex-wrap: wrap; }
  .dash-sys-head > div { flex-basis: calc(100% - 60px); }
  .dash-sys-links { width: 100%; }
  .dash-row { flex-direction: column; align-items: flex-start; gap: .4rem; }
}

/* ---------- 3.56.0 แถบแท็บของหน้าที่รวมกันเป็นกลุ่ม (อยู่บนสุดของเนื้อหา เหนือหัวเรื่อง) ---------- */
.page-tabs { gap: .15rem; margin: -.35rem 0 1.15rem; padding: 0 .1rem; border-bottom: 1px solid var(--line); }
.page-tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .85rem .6rem; font-size: .94rem; border-radius: 10px 10px 0 0; }
.page-tabs a .bi { font-size: 1rem; color: var(--muted); }
.page-tabs a:hover { background: var(--surface-2, #F4F6FA); }
.page-tabs a.active { background: var(--surface, #fff); color: var(--primary); border-bottom-color: var(--primary); }
.page-tabs a.active .bi { color: var(--primary); }
@media (min-width: 768px) { .page-tabs { flex-wrap: wrap; overflow: visible; } }
.page-tabs a .sub-admin-mark { margin-left: .1rem; font-size: .75rem; color: var(--admin); }
@media (max-width: 575.98px) {
  .page-tabs { margin-top: -.15rem; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .page-tabs a { padding: .5rem .7rem; font-size: .9rem; }
}
@media print { .page-tabs { display: none; } }

/* ---------- 3.56.0 หน้ารวมเครื่องมือ (group.php) ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 1rem; }
.tool-card { display: flex; flex-direction: column; border-top: 4px solid var(--tool, var(--primary)); margin: 0; }
.tool-main { display: flex; align-items: flex-start; gap: .9rem; padding: 1.1rem 1.15rem .9rem; color: inherit; text-decoration: none; flex: 1 1 auto; }
.tool-main:hover strong { color: var(--primary); text-decoration: underline; }
.tool-text { flex: 1 1 auto; min-width: 0; }
.tool-text strong { display: block; font-size: 1.08rem; }
.tool-text small { display: block; color: var(--muted); margin-top: .15rem; line-height: 1.5; }
.tool-go { color: var(--muted); font-size: 1.1rem; padding-top: .3rem; }
.tool-links { display: flex; flex-wrap: wrap; gap: .4rem; padding: .7rem 1.15rem .95rem; border-top: 1px dashed var(--line); }
.tool-links a { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border-radius: 999px; background: var(--surface-2, #F4F6FA); border: 1px solid var(--line); color: var(--ink-2); font-size: .86rem; font-weight: 600; text-decoration: none; }
.tool-links a:hover { border-color: var(--tool, var(--primary)); color: var(--ink); }
.tool-links a .bi { color: var(--tool, var(--primary)); }
.tool-links a .sub-admin-mark { font-size: .75rem; color: var(--admin); }

/* 3.87.0 แท็บเล็ต (768–1024) และจอสัมผัสทุกขนาด: ช่องติ๊ก 24 px เหมือนมือถือ (เดิม 13–18 px ในตาราง) */
@media (max-width: 1024px), (pointer: coarse) {
  .form-check-input[type=checkbox]:not([role=switch]), .form-check-input[type=radio] { width: 1.5rem; height: 1.5rem; }
}
/* ---------- 3.60.0 จอสัมผัส/มือถือ: พื้นที่แตะอย่างน้อย 24–40 px ---------- */
@media (max-width: 767.98px) {
  .crumb-module { min-width: 34px; min-height: 34px; justify-content: center; border-radius: 10px; }
  .form-check-input[type=checkbox]:not([role=switch]), .form-check-input[type=radio] { width: 1.5rem; height: 1.5rem; }
  .form-check { min-height: 1.75rem; }
  .form-check .form-check-input { margin-top: .05rem; }
  details > summary { min-height: 2rem; padding-block: .2rem; }
  .back-link { display: inline-flex; align-items: center; min-height: 2rem; }
}

tr[hidden] { display: none !important; }   /* 3.93.0 แถวที่ซ่อนด้วยตัวกรอง (ตารางแบบการ์ดบนจอแคบตั้ง display ไว้) */

/* ---------- 3.60.0 ตารางแบบการ์ดบนจอแคบ: <table class="table-stack"> (ป้ายของแต่ละช่องมาจากหัวตาราง ใส่ให้โดย app.js) ---------- */
@media (max-width: 575.98px) {
  .table-stack, .table-stack > tbody, .table-stack > tbody > tr, .table-stack > tbody > tr > td, .table-stack > tbody > tr > th { display: block; width: 100%; }
  .table-stack > thead { display: block; }
  .table-stack > thead > tr { display: flex; flex-wrap: wrap; border: 0; }
  .table-stack > thead > tr > th { display: none; }
  .table-stack > thead > tr > th.stack-keep { display: flex; align-items: center; gap: .6rem; border: 0; padding: .25rem .25rem .6rem; font-weight: 600; color: var(--ink-2); }
  .table-stack > thead > tr > th.stack-keep::after { content: attr(data-stack-keep); }
  .table-stack > tbody > tr { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; margin-bottom: .7rem; padding: .55rem .8rem; background: var(--surface, #fff); }
  .table-stack > tbody > tr > th, .table-stack > tbody > tr > td.stack-title { order: -1; }
  .table-stack > tbody > tr > th, .table-stack > tbody > tr > td { border: 0; padding: .3rem 0; white-space: normal; min-width: 0; }
  .table-stack > tbody > tr > th { font-size: 1rem; padding-bottom: .4rem; }
  .table-stack > tbody > tr > td { display: flex; align-items: center; justify-content: space-between; gap: .75rem; text-align: right; border-top: 1px dashed var(--line-2); }
  .table-stack > tbody > tr > td::before { content: attr(data-label); flex: 0 1 45%; text-align: left; font-size: .85rem; font-weight: 600; color: var(--muted); }
  .table-stack > tbody > tr > td[data-label=""]::before, .table-stack > tbody > tr > td.stack-title::before { display: none; }
  .table-stack > tbody > tr > td.stack-title { display: block; text-align: left; border-top: 0; font-size: 1rem; padding-bottom: .4rem; }
  .table-stack > tbody > tr > td.stack-check { position: absolute; top: .45rem; right: .6rem; width: auto; border: 0; padding: 0; }
  .table-stack > tbody > tr > td.stack-check::before { display: none; }
  .table-stack > tbody > tr > td.stack-check .form-check-input, .table-stack > thead th.stack-keep .form-check-input { width: 1.5rem; height: 1.5rem; }
  .table-stack > tbody > tr:has(> td.stack-check) > .stack-title, .table-stack > tbody > tr:has(> td.stack-check) > th { padding-right: 2.5rem; }
  .table-stack > tbody > tr > td.d-none { display: none !important; }
  .table-stack > tbody > tr > td .form-control { width: 7rem; max-width: 55%; }
  .table-stack > tbody > tr > td.text-end, .table-stack > tbody > tr > td.text-center { justify-content: space-between; }
  .table-stack > tbody > tr > td[colspan] { display: block; text-align: left; }
  .table-stack > tbody > tr > td[colspan]::before { display: none; }
  .table-responsive:has(> .table-stack) { overflow: visible; }
}
.th-date-hint { margin-top: .2rem; font-size: .8rem; }

/* 3.67.0 หน้าเปิดใช้บัญชี/ตั้งรหัสผ่านใหม่จากลิงก์ในอีเมล (activate.php) */
.auth-steps { margin: 0 0 1.25rem; padding-left: 1.2rem; color: var(--ink-2); font-size: .92rem; line-height: 1.6; }
.auth-steps li + li { margin-top: .35rem; }
/* 3.68.0 ลิงก์ ลืมรหัสผ่าน? ข้างป้ายรหัสผ่าน · กล่องส่งอีเมลแล้ว */
.auth-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.auth-forgot { font-size: .88rem; font-weight: 600; text-decoration: none; padding: .25rem 0; }
.auth-forgot:hover { text-decoration: underline; }
.auth-sent { display: flex; gap: .75rem; align-items: flex-start; background: var(--primary-wash); border-radius: 12px; padding: .9rem 1rem; margin: .9rem 0 1rem; line-height: 1.6; }
.auth-sent > i { font-size: 1.5rem; color: var(--primary); line-height: 1; margin-top: .15rem; }
.auth-sent p { margin: 0; font-size: .94rem; }
.btn-outline-secondary { --bs-btn-bg: #F1F3F7; --bs-btn-color: #545d68; --bs-btn-border-color: #8a939e; }   /* 3.87.0 คอนทราสต์ 4.5:1 บนพื้นเทาอ่อน */
@media (max-width: 400px) { .table td.text-nowrap { white-space: normal !important; } }   /* 3.87.0 จอ 320: วันที่/เวลาในตารางตัดบรรทัดได้ ไม่ล้นจอ */
/* 3.99.0 ตัวเลขแจ้งเตือนท้ายชื่อระบบในเมนูด้านซ้าย (เช่น ปฏิทินของฉัน) */
.side-link.has-side-badge > span:not(.side-badge):not(.glyph) { flex: 1 1 auto; min-width: 0; }
.side-badge { flex: none; min-width: 1.35rem; height: 1.35rem; margin-left: auto; padding: 0 .38rem; border-radius: 999px; background: #DC2626; color: #fff; font-size: .75rem; font-weight: 700; line-height: 1.35rem; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.side-toggle > span.side-badge { flex: none; margin-left: .35rem; }
.side-toggle.has-side-badge > .side-caret { margin-left: .35rem; }
#main td .chip { white-space: normal; text-align: left; }   /* 3.104.0 ป้ายยาวในตารางบนจอแคบ (ผู้ใช้และสิทธิ์) */
#main code { color: #A3195B; }   /* 3.104.0 สีโค้ดผ่านเกณฑ์ความคมชัดบนพื้นอ่อน */
.text-secondary { color: var(--muted) !important; }   /* 3.104.0 สีรองของ Bootstrap (#6C757D) ไม่ผ่านเกณฑ์บนพื้นเทาอ่อน */
.chip-wait { background: #EDE9FE; color: #5B21B6; }
.chip-closed { background: var(--line-2); color: var(--ink-2); }   /* 3.115.0 ใช้ร่วมหลายระบบ (วิดเจ็ตหน้าหลัก) */

/* ---------- 3.126.0 คู่มือแบบหน้าต่าง: ปุ่ม คู่มือ เปิดหน้าต่างทับหน้าเดิม (iframe หน้าคู่มือ ?embed=1) ---------- */
.help-modal .modal-dialog { max-width: min(1180px, 96vw); }
.help-modal .modal-content { height: calc(100vh - 3.5rem); overflow: hidden; }
.help-modal .modal-header { gap: .5rem; padding: .7rem 1rem; }
.help-modal .modal-title { display: flex; align-items: center; gap: .45rem; margin: 0; min-width: 0; }
.help-modal .modal-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.help-modal .modal-body { padding: 0; background: var(--canvas); }
.help-modal iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--canvas); }
@media (max-width: 767.98px) {
  .help-modal .modal-content { height: 100%; }
  .help-modal .help-full-text { display: none; }
}
body.is-embed { background: var(--canvas); }
main.embed { display: block; padding: 1rem 1.25rem 1.5rem; }
body.is-embed .man-side-inner { top: 1rem; }
body.is-embed .man-sec { scroll-margin-top: 1rem; }

/* ---------- 3.127.0 ระบบที่ใช้บ่อย (การ์ดบนสุดของเมนูด้านซ้าย) ---------- */
.side-fav { border-color: #C9D6FB; background: linear-gradient(180deg, #F6F8FF, var(--surface) 70%); }
.side-fav-head { display: flex; align-items: center; justify-content: space-between; gap: .25rem; }
.side-fav .side-group { display: flex; align-items: center; gap: .4rem; color: var(--primary-ink); font-weight: 700; }
.side-fav .side-group .bi { color: #E9A21B; font-size: .8rem; }
.side-fav-edit { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin: .35rem .2rem 0 0; border-radius: 8px; color: var(--muted); text-decoration: none; }
.side-fav-edit:hover, .side-fav-edit:focus-visible { background: var(--primary-wash); color: var(--primary-ink); }
.side-fav-add { color: var(--primary-ink); font-size: .9rem; }
.side-fav-add > i { color: var(--primary); }
