/* ================================================================
   ไฟล์สไตล์แดชบอร์ด — PPAOS & SRA-DSS
   ================================================================
    1. พื้นฐาน / ส่วนกลาง
    2. โครงหน้า (Layout)
    3. แถบเมนูบน (Top Navbar)
    4. แถบเมนูบน — จุดตัดจอ 1024px
    5. เมนูด้านข้าง (Sidebar)
    6. เมนูด้านข้างตอนย่อ (≥1025px)
    7. แบนเนอร์ส่วนหัว
    8. แถบตัวกรองเขตพื้นที่
    9. การ์ดข้อมูล
   10. กล่องข้อมูลขนาดเล็ก
   11. การ์ดสถิติแบบวงแหวน
   12. การ์ดสถานะ (ที่อยู่อาศัย)
   13. แผนที่ D3
   14. คำอธิบายกราฟ
   15. กริดมิติและตาราง
   16. ตัวเล่นไทม์ไลน์กราฟวงกลม
   17. ตารางเปรียบเทียบรายจังหวัด
   18. ปุ่มส่งออก Excel
   19. ปุ่มลอยการทำงาน (FAB)
   20. โหลดข้อมูล / โครงร่าง / ตัวเลขนับ
   21. การแสดงผลตามขนาดหน้าจอ
   22. การเข้าถึง (Accessibility)
   ================================================================ */

/* ─── Skeleton Chart Loading Animation ─── */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}
.chart-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, #cbd5e1 0%, #94a3b8 50%, #cbd5e1 100%);
    background-size: 2000px 100%;
    animation: shimmer 2s infinite;
    opacity: 0.85;
    pointer-events: none;
    z-index: 1;
    border-radius: 8px;
}
.chart-skeleton-fade {
    animation: shimmer 2s infinite, fadeOut 0.4s ease-out forwards;
}
@keyframes fadeOut {
    to { opacity: 0; }
}
.chart-container {
    position: relative;
}
.chart-container.loading .chart-skeleton {
    opacity: 0.85;
    display: block;
}
.chart-container:not(.loading) .chart-skeleton {
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

/* ─── ตัวแปรความกว้างตอนย่อของเมนูด้านข้าง ─── */
:root {
    --sidebar-collapsed: calc(5.8rem + 40px);
    --top-nav-h: 59px;
    --top-nav-bg: radial-gradient(1200px 120px at 18% -48%, rgba(255,255,255,.64), rgba(255,255,255,0)),
                  linear-gradient(135deg, #d2dced 0%, #c1cee0 55%, #b7c6da 100%);
    --top-nav-border: rgba(96, 165, 250, 0.4);
    --top-nav-shadow: inset 0 1px 0 rgba(255,255,255,.48),
                      inset 0 -1px 0 rgba(255,255,255,.26),
                      0 9px 22px rgba(15, 23, 42, 0.12);
    --top-nav-link-color: #041126;
    --top-nav-link-border: 1px solid rgba(255,255,255,.14);
    --top-nav-link-hover-bg: linear-gradient(180deg, rgba(242,248,255,.82), rgba(229,239,254,.76));
    --top-nav-link-hover-border: rgba(30, 64, 175, 0.3);
    --top-nav-link-hover-color: #132e68;
    --top-nav-link-hover-shadow: 0 9px 16px rgba(30, 64, 175, 0.11);
    --top-nav-link-active-color: #0f2859;
    --top-nav-link-active-bg: linear-gradient(180deg, rgba(238,246,255,.86), rgba(223,235,254,.8));
    --top-nav-link-active-border: rgba(30, 64, 175, 0.38);
    --top-nav-link-active-shadow: inset 0 1px 0 rgba(255,255,255,.68),
                                  0 11px 20px rgba(29, 78, 216, 0.15);
    --top-nav-active-indicator-bg: linear-gradient(90deg, rgba(30, 64, 175, .96), rgba(59, 130, 246, .92));
    --top-nav-active-indicator-shadow: 0 2px 8px rgba(30, 64, 175, 0.26);
    --top-nav-push-bg: linear-gradient(180deg, rgba(247,251,255,.92), rgba(233,241,252,.84));
    --top-nav-push-border: 1px solid rgba(111, 138, 184, .5);
    --top-nav-push-shadow: 0 6px 16px rgba(15, 23, 42, .11);
    --top-nav-push-bg-hover: linear-gradient(180deg, rgba(255,255,255,.95), rgba(245,248,255,.88));
    --top-nav-auth-chip-border: 1px solid rgba(110, 138, 186, .5);
    --top-nav-auth-chip-bg: linear-gradient(180deg, rgba(246,250,255,.95), rgba(233,241,252,.9));
    --top-nav-auth-chip-bg-hover: linear-gradient(180deg, rgba(246,250,255,.98), rgba(233,242,254,.93));
    --top-nav-auth-chip-border-hover: #6ea4f4;
    --top-nav-auth-chip-shadow-hover: 0 9px 18px rgba(29, 78, 216, 0.11);
    --top-nav-dropdown-bg: linear-gradient(180deg, rgba(247,251,255,.98), rgba(236,244,254,.97));
    --top-nav-dropdown-border: 1px solid rgba(145, 168, 207, .62);
    --top-nav-dropdown-shadow: 0 18px 36px rgba(15,23,42,.22);
    --top-nav-dropdown-item-color: #0c1426;
    --top-nav-dropdown-item-hover-bg: linear-gradient(180deg, rgba(224,237,255,.98), rgba(212,228,252,.94));
    --top-nav-dropdown-item-hover-color: #132e68;
    --top-nav-dropdown-item-hover-border: rgba(30, 64, 175, .2);
    --top-nav-dropdown-item-active-bg: linear-gradient(135deg, #3b82f6, #2563eb);
    --top-nav-dropdown-item-active-color: #fff;
    --top-nav-toggler-border: 1px solid rgba(148,163,184,.45);
    --top-nav-toggler-bg: rgba(255,255,255,.78);
    --top-nav-toggler-bg-hover: #ffffff;
    --top-nav-toggler-color: #334155;
    --top-nav-toggler-color-hover: #3b82f6;
    --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    --sidebar-scrollbar-thumb: rgba(148, 163, 184, 0.42);
    --sidebar-scrollbar-thumb-hover: rgba(148, 163, 184, 0.68);
    --sidebar-generic-link-hover-bg: rgba(59,130,246,0.15);
    --sidebar-generic-link-active-bg: linear-gradient(135deg, #3b82f6, #2563eb);
    --sidebar-generic-link-active-shadow: 0 2px 8px rgba(59,130,246,0.3);
    --sidebar-num-icon-idle-border: rgba(255, 255, 255, 0.86);
    --sidebar-num-icon-idle-color: rgba(255, 255, 255, 0.92);
    --sidebar-shell-bg: linear-gradient(180deg, #10214a 0%, #1d4ed8 54%, #1e3a8a 100%);
    --sidebar-brand-border: 2px solid rgba(96, 165, 250, 0.4);
    --sidebar-brand-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
    --sidebar-brand-logo-shadow: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.26));
    --sidebar-brand-mini-shadow: drop-shadow(0 4px 10px rgba(15, 23, 42, 0.24));
    --sidebar-nav-header-color: rgba(219, 234, 254, 0.78);
    --sidebar-link-border: 1px solid rgba(147, 197, 253, 0.22);
    --sidebar-link-bg: linear-gradient(130deg, rgba(30, 64, 175, 0.28), rgba(30, 58, 138, 0.18));
    --sidebar-link-color: #e2e8f0;
    --sidebar-link-inset-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    --sidebar-link-hover-border: rgba(191, 219, 254, 0.52);
    --sidebar-link-hover-bg: linear-gradient(130deg, rgba(59, 130, 246, 0.34), rgba(30, 64, 175, 0.26));
    --sidebar-link-hover-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 10px 16px rgba(15, 23, 42, 0.22);
    --sidebar-link-active-border: 1px solid rgba(147, 197, 253, 0.22);
    --sidebar-link-active-bg: linear-gradient(135deg, #1a2a6d, #18398f);
    --sidebar-link-active-shadow: 0 12px 20px rgba(15, 23, 42, 0.54), inset 0 1px 0 rgba(255, 255, 255, 0.14);
    --sidebar-sub-link-border: 1px solid rgba(148, 163, 184, 0.3);
    --sidebar-sub-link-bg: linear-gradient(140deg, rgb(21 47 120), rgb(17 64 143));
    --sidebar-sub-link-color: #cbd5e1;
    --sidebar-sub-link-hover-border: rgba(125, 211, 252, 0.58);
    --sidebar-sub-link-hover-bg: linear-gradient(140deg, rgb(25 43 112), rgb(17 64 143));
    --sidebar-sub-link-hover-color: #eff6ff;
    --sidebar-sub-link-active-border: rgba(96, 165, 250, 0.82);
    --sidebar-sub-link-active-bg: linear-gradient(140deg, rgb(28 68 184), rgb(29 75 203));
    --sidebar-sub-link-active-color: #ffffff;
    --sidebar-sub-link-active-shadow: 0 8px 14px rgba(2, 6, 23, 0.28), inset 3px 0 0 rgba(96, 165, 250, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.14);
    --top-mobile-panel-bg: linear-gradient(180deg, rgba(245, 250, 255, 0.98), rgba(232, 241, 252, 0.96));
    --top-mobile-panel-border: 1px solid rgba(154, 176, 212, 0.58);
    --top-mobile-panel-shadow: 0 18px 36px rgba(15,23,42,.2);
    --top-mobile-panel-hover: linear-gradient(180deg, rgba(230, 241, 255, 0.95), rgba(218, 232, 251, 0.92));
    --top-mobile-panel-active: linear-gradient(180deg, rgba(239,246,255,.95), rgba(231,240,255,.9));
    --footer-logo-max: min(30vw, 320px);
    --footer-modern-padding: 18px 16px 14px;
    --footer-wrap-padding: 18px 20px 14px;
    --footer-wrap-radius: 16px;
    --footer-logos-gap: 26px;
    --footer-title-mt: 14px;
    --footer-title-size: 18px;
    --footer-stats-cols: repeat(3, minmax(180px, 1fr));
    --footer-stats-gap: 12px;
    --footer-stats-mt: 16px;
    --footer-stat-padding: 12px 14px;
    --footer-stat-label-size: 0.74rem;
    --footer-stat-value-size: 0.96rem;
    --footer-meta-size: 1rem;
    --auth-login-content-border: 1px solid rgba(148, 163, 184, 0.34);
    --auth-login-content-radius: 20px;
    --auth-login-content-bg: linear-gradient(165deg, rgba(255, 255, 255, 0.97), rgba(243, 248, 255, 0.98));
    --auth-login-content-shadow: 0 26px 58px rgba(15, 23, 42, 0.2);
    --auth-login-header-bg: radial-gradient(560px 170px at 88% -18%, rgba(59,130,246,.25), rgba(59,130,246,0)),
                            linear-gradient(135deg, #2f5fb4 0%, #2753a4 55%, #1f4387 100%);
    --auth-login-orb-color: #eff6ff;
    --auth-login-orb-border: 1px solid rgba(191, 219, 254, 0.72);
    --auth-login-orb-bg: linear-gradient(160deg, rgba(37,99,235,.9), rgba(29,78,216,.68));
    --auth-login-orb-shadow: 0 8px 16px rgba(30, 64, 175, .28), inset 0 1px 0 rgba(255,255,255,.3);
    --auth-login-subtitle-color: #bfdbfe;
    --auth-login-close-bg: rgba(255, 255, 255, .18);
    --auth-login-close-border: 1px solid rgba(191, 219, 254, .5);
    --auth-login-close-bg-hover: rgba(255, 255, 255, .3);
    --auth-login-close-border-hover: rgba(224, 242, 254, .92);
    --auth-login-body-bg: linear-gradient(180deg, rgba(247, 250, 255, .95), rgba(238, 245, 255, .96));
    --auth-login-help-color: #1e3a8a;
    --auth-login-help-border: 1px solid rgba(96, 165, 250, .34);
    --auth-login-help-accent: rgba(59, 130, 246, .86);
    --auth-login-help-bg: linear-gradient(180deg, rgba(219, 234, 254, .74), rgba(219, 234, 254, .48));
    --auth-login-input-icon-color: #3b82f6;
    --auth-login-label-color: #1e293b;
    --auth-login-input-border: 1px solid rgba(148, 163, 184, .44);
    --auth-login-input-bg: linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(241, 245, 249, .95));
    --auth-login-input-color: #0f172a;
    --auth-login-input-placeholder: #64748b;
    --auth-login-input-focus-border: rgba(59, 130, 246, .9);
    --auth-login-input-focus-shadow: 0 0 0 .16rem rgba(59,130,246,.18), 0 8px 18px rgba(37, 99, 235, .18);
    --auth-login-input-focus-bg: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(239, 246, 255, .97));
    --auth-login-input-focus-color: #1e3a8a;
    --auth-login-submit-border: 1px solid rgba(37, 99, 235, .88);
    --auth-login-submit-bg: linear-gradient(135deg, #2b61d8, #1d4ed8);
    --auth-login-submit-bg-hover: linear-gradient(135deg, #3b82f6, #2563eb);
    --auth-login-submit-shadow: 0 12px 24px rgba(37, 99, 235, .3);
    --auth-login-error-bg: rgba(254, 226, 226, .88);
    --auth-login-error-border: 1px solid rgba(248, 113, 113, .45);
    --auth-login-error-color: #991b1b;
    --auth-login-backdrop-bg: radial-gradient(1100px 500px at 80% -10%, rgba(59,130,246,.24), rgba(15,23,42,.42) 45%, rgba(2,6,23,.56) 100%);
    --auth-login-backdrop-opacity: .72;
}

body.theme-darker {
    --top-nav-bg: linear-gradient(180deg, #0f1d3a 0%, #0f1d3a 100%);
    --top-nav-border: rgba(96, 165, 250, 0.4);
    --top-nav-shadow: inset 0 1px 0 rgba(148, 163, 184, .16),
                      inset 0 -1px 0 rgba(15, 23, 42, .78),
                      0 12px 26px rgba(2, 6, 23, .45);
    --top-nav-link-color: #dbeafe;
    --top-nav-link-border: 1px solid rgba(148, 163, 184, .22);
    --top-nav-link-hover-bg: linear-gradient(180deg, rgba(30, 58, 114, .62), rgba(30, 64, 175, .5));
    --top-nav-link-hover-border: rgba(96, 165, 250, 0.54);
    --top-nav-link-hover-color: #eff6ff;
    --top-nav-link-hover-shadow: 0 10px 18px rgba(2, 6, 23, 0.38);
    --top-nav-link-active-color: #ffffff;
    --top-nav-link-active-bg: var(--top-nav-link-hover-bg);
    --top-nav-link-active-border: var(--top-nav-link-hover-border);
    --top-nav-link-active-shadow: var(--top-nav-link-hover-shadow);
    --top-nav-active-indicator-bg: linear-gradient(90deg, #7aa2df, #5f8fda);
    --top-nav-active-indicator-shadow: 0 2px 8px rgba(96, 165, 250, 0.28);
    --top-nav-push-bg: linear-gradient(180deg, rgba(21, 34, 63, .94), rgba(16, 29, 55, .88));
    --top-nav-push-border: 1px solid rgba(148, 163, 184, .28);
    --top-nav-push-shadow: 0 8px 16px rgba(2, 6, 23, .35);
    --top-nav-push-bg-hover: linear-gradient(180deg, rgba(30, 58, 114, .82), rgba(30, 64, 175, .68));
    --top-nav-auth-chip-border: 1px solid rgba(148, 163, 184, .3);
    --top-nav-auth-chip-bg: linear-gradient(180deg, rgba(21, 34, 63, .94), rgba(16, 29, 55, .88));
    --top-nav-auth-chip-bg-hover: linear-gradient(180deg, rgba(30, 58, 114, .82), rgba(30, 64, 175, .68));
    --top-nav-auth-chip-border-hover: #93c5fd;
    --top-nav-auth-chip-shadow-hover: 0 10px 20px rgba(2, 6, 23, .38);
    --top-nav-dropdown-bg: linear-gradient(180deg, rgba(12, 24, 50, .96), rgba(15, 29, 58, .94));
    --top-nav-dropdown-border: 1px solid rgba(71, 85, 105, .72);
    --top-nav-dropdown-shadow: 0 20px 38px rgba(2, 6, 23, .56);
    --top-nav-dropdown-item-color: #e2e8f0;
    --top-nav-dropdown-item-hover-bg: linear-gradient(180deg, rgba(30, 58, 114, .72), rgba(30, 64, 175, .58));
    --top-nav-dropdown-item-hover-color: #ffffff;
    --top-nav-dropdown-item-hover-border: rgba(96, 165, 250, .5);
    --top-nav-dropdown-item-active-bg: var(--top-nav-dropdown-item-hover-bg);
    --top-nav-dropdown-item-active-color: #ffffff;
    --top-nav-toggler-border: 1px solid rgba(148,163,184,.32);
    --top-nav-toggler-bg: rgba(15, 23, 42, .7);
    --top-nav-toggler-bg-hover: rgba(30, 58, 114, .78);
    --top-nav-toggler-color: #dbeafe;
    --top-nav-toggler-color-hover: #ffffff;
    --top-mobile-panel-bg: linear-gradient(180deg, rgba(12, 24, 50, .98), rgba(15, 29, 58, .96));
    --top-mobile-panel-border: 1px solid rgba(71, 85, 105, .74);
    --top-mobile-panel-shadow: 0 18px 36px rgba(2, 6, 23, .62);
    --top-mobile-panel-hover: linear-gradient(180deg, rgba(30, 58, 114, .72), rgba(30, 64, 175, .58));
    --top-mobile-panel-active: linear-gradient(180deg, rgba(37, 99, 235, .78), rgba(29, 78, 216, .66));
    --sidebar-bg: linear-gradient(180deg, #0f1d3a 0%, #0f1d3a 100%);
    --sidebar-shell-bg: linear-gradient(180deg, #0f1d3a 0%, #0f1d3a 100%);
    --sidebar-brand-bg: linear-gradient(180deg, #0f1d3a 0%, #0f1d3a 100%);
    --sidebar-brand-border: 2px solid rgba(96, 165, 250, 0.4);
    --sidebar-link-bg: linear-gradient(130deg, rgba(21, 44, 118, 0.44), rgba(16, 35, 92, 0.34));
    --sidebar-link-hover-bg: linear-gradient(130deg, rgba(59, 130, 246, 0.56), rgba(30, 64, 175, 0.44));
    --sidebar-link-active-bg: linear-gradient(135deg, #1e3a8a, #1d4ed8);
    --sidebar-link-active-shadow: 0 14px 24px rgba(2, 6, 23, 0.68), inset 0 1px 0 rgba(191, 219, 254, 0.22);
    --sidebar-sub-link-border: 1px solid rgba(148, 163, 184, 0.34);
    --sidebar-sub-link-bg: linear-gradient(140deg, rgba(32, 45, 74, 0.88), rgba(14, 22, 40, 0.84));
    --sidebar-sub-link-color: #cbd5e1;
    --sidebar-sub-link-hover-border: rgba(125, 211, 252, 0.62);
    --sidebar-sub-link-hover-bg: linear-gradient(140deg, rgba(24, 33, 57, 0.98), rgba(11, 17, 32, 0.96));
    --sidebar-sub-link-hover-color: #f8fafc;
    --sidebar-sub-link-active-border: rgba(125, 211, 252, 0.84);
    --sidebar-sub-link-active-bg: linear-gradient(140deg, rgba(18, 25, 43, 0.96), rgba(8, 12, 22, 0.93));
    --sidebar-sub-link-active-color: #ffffff;
    --sidebar-sub-link-active-shadow: 0 9px 16px rgba(2, 6, 23, 0.34), inset 3px 0 0 rgba(96, 165, 250, 0.92), inset 0 1px 0 rgba(191, 219, 254, 0.16);
    --auth-login-content-border: 1px solid rgba(148, 163, 184, 0.28);
    --auth-login-content-bg: linear-gradient(165deg, rgba(22, 35, 64, 0.94), rgba(15, 28, 55, 0.95));
    --auth-login-content-shadow: 0 28px 64px rgba(2, 6, 23, 0.42);
    --auth-login-header-bg: radial-gradient(560px 170px at 88% -18%, rgba(59,130,246,.34), rgba(59,130,246,0)),
                            linear-gradient(135deg, #274375 0%, #1c3362 55%, #162c56 100%);
    --auth-login-orb-color: #dbeafe;
    --auth-login-orb-border: 1px solid rgba(147, 197, 253, 0.5);
    --auth-login-orb-bg: linear-gradient(160deg, rgba(30,64,175,.7), rgba(29,78,216,.45));
    --auth-login-orb-shadow: 0 8px 16px rgba(15, 23, 42, .3), inset 0 1px 0 rgba(255,255,255,.25);
    --auth-login-subtitle-color: #93c5fd;
    --auth-login-close-bg: rgba(22, 35, 64, .54);
    --auth-login-close-border: 1px solid rgba(148, 163, 184, .35);
    --auth-login-close-bg-hover: rgba(30, 41, 59, .62);
    --auth-login-close-border-hover: rgba(147, 197, 253, .66);
    --auth-login-body-bg: linear-gradient(180deg, rgba(17, 33, 65, .75), rgba(13, 26, 52, .82));
    --auth-login-help-color: #dbeafe;
    --auth-login-help-border: 1px solid rgba(96, 165, 250, .28);
    --auth-login-help-accent: rgba(96, 165, 250, .8);
    --auth-login-help-bg: linear-gradient(180deg, rgba(30, 58, 114, .34), rgba(30, 58, 114, .2));
    --auth-login-input-icon-color: #93c5fd;
    --auth-login-label-color: #dbeafe;
    --auth-login-input-border: 1px solid rgba(148, 163, 184, .46);
    --auth-login-input-bg: linear-gradient(180deg, rgba(22, 35, 64, .62), rgba(34, 51, 86, .52));
    --auth-login-input-color: #f8fafc;
    --auth-login-input-placeholder: #94a3b8;
    --auth-login-input-focus-border: rgba(96, 165, 250, .92);
    --auth-login-input-focus-shadow: 0 0 0 .16rem rgba(37,99,235,.22), 0 8px 18px rgba(15, 23, 42, .26);
    --auth-login-input-focus-bg: linear-gradient(180deg, rgba(29, 45, 78, .74), rgba(42, 62, 102, .62));
    --auth-login-input-focus-color: #f8fafc;
    --auth-login-submit-border: 1px solid rgba(96, 165, 250, .85);
    --auth-login-submit-bg: linear-gradient(135deg, #2563eb, #1d4ed8);
    --auth-login-submit-bg-hover: linear-gradient(135deg, #3b82f6, #2563eb);
    --auth-login-submit-shadow: 0 12px 24px rgba(29, 78, 216, .32);
    --auth-login-error-bg: rgba(127, 29, 29, .3);
    --auth-login-error-border: 1px solid rgba(248, 113, 113, .35);
    --auth-login-error-color: #fecaca;
    --auth-login-backdrop-bg: radial-gradient(1100px 500px at 80% -10%, rgba(59,130,246,.32), rgba(11,18,37,.86) 45%, rgba(5,9,16,.94) 100%);
    --auth-login-backdrop-opacity: .92;
}

body.theme-darker .content-wrapper {
    background: linear-gradient(180deg, #101b33 0%, #101b33 100%) !important;
}
body.theme-darker .main-header .num-icon-top {
    border-color: rgba(147, 197, 253, 0.75);
    color: #dbeafe;
    background: rgba(15, 23, 42, 0.36);
}
body.theme-darker .main-header .theme-preset-btn,
body.theme-darker .main-header .navbar-actions .nav-link[data-widget="fullscreen"] {
    color: #dbeafe;
}
body.theme-darker .main-header .theme-preset-btn:hover,
body.theme-darker .main-header .navbar-actions .nav-link[data-widget="fullscreen"]:hover {
    color: #ffffff;
}
body.theme-darker .main-header .navbar-nav > .nav-item > .nav-link,
body.theme-darker .main-header .dropdown-item {
    text-shadow: none;
    font-weight: 500;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: geometricPrecision;
}
body.theme-darker .main-header .navbar-nav > .nav-item > .nav-link.active,
body.theme-darker .main-header .dropdown-item.active,
body.theme-darker .main-header .dropdown-item.active:hover {
    font-weight: 500;
}
body.theme-darker .main-header .auth-user-chip {
    color: #e2e8f0;
}
body.theme-darker .main-header .auth-user-chip:hover {
    color: #ffffff;
}
body.theme-darker #authUserMenu .auth-user-dropdown .auth-user-name {
    color: #fde68a;
}
body.theme-darker #authUserMenu .auth-user-dropdown .auth-user-meta,
body.theme-darker #authUserMenu .auth-user-dropdown .text-muted,
body.theme-darker #authUserMenu .auth-user-dropdown .dropdown-item:not(.text-danger),
body.theme-darker #authUserMenu .auth-user-dropdown .dropdown-item:not(.text-danger) i,
body.theme-darker #authUserMenu .auth-user-dropdown .dropdown-item:not(.text-danger) .small,
body.theme-darker #authUserMenu .auth-user-dropdown .dropdown-item:not(.text-danger) .text-muted {
    color: #ffffff;
}
body.theme-darker #authUserMenu .auth-user-dropdown .dropdown-divider {
    border-top-color: rgba(148, 163, 184, 0.5);
}
.residence-status-title {
    color: #1e293b;
}
body.theme-darker .residence-status-title {
    color: #ffffff;
}
body.theme-darker .brand-link,
body.theme-darker .ppaos-menu-brand {
    border-bottom-width: 2px !important;
    border-bottom-color: rgba(96, 165, 250, 0.4) !important;
}
body.theme-darker .footer-modern {
    background: linear-gradient(180deg, #0f1d3a 0%, #0f1d3a 100%) !important;
    border-top: 1px solid rgba(71, 85, 105, 0.6) !important;
}
body.theme-darker .footer-brand-wrap {
    background: linear-gradient(180deg, #0f1d3a 0%, #0f1d3a 100%);
    border-color: rgba(71, 85, 105, 0.7);
}
body.theme-darker .footer-brand-title {
    color: #dbeafe;
}
body.theme-darker .footer-system-stat-item {
    background: linear-gradient(180deg, rgba(19, 35, 66, 0.96), rgba(17, 30, 56, 0.94));
    box-shadow:
        0 14px 28px rgba(2, 6, 23, 0.42),
        0 2px 6px rgba(30, 64, 175, 0.2);
}
body.theme-darker .footer-system-stat-item:hover {
    box-shadow:
        0 18px 32px rgba(2, 6, 23, 0.52),
        0 4px 10px rgba(30, 64, 175, 0.28);
}
body.theme-darker .footer-system-stat-label {
    color: #a5b4fc;
}
body.theme-darker .footer-system-stat-value {
    color: #eff6ff;
}
body.theme-darker .footer-meta {
    color: #cbd5e1;
}


/* ============ 1. พื้นฐาน / ส่วนกลาง ============ */

body,
.content-wrapper,
.main-sidebar,
.main-header,
.main-footer {
    font-family: 'Kanit', sans-serif;
}

/* บังคับฟอนต์คานิททุกองค์ประกอบ รวมทูลทิปของอีชาร์ตส์ที่กำหนดฟอนต์แบบอินไลน์ */
* {
    font-family: 'Kanit', sans-serif !important;
}
.fas, .far, .fa, .fal, .fad {
    font-family: "Font Awesome 5 Free" !important;
}
.fab {
    font-family: "Font Awesome 5 Brands" !important;
}

/* ============ 2. โครงหน้า ============ */

.content-wrapper {
    background: #f1f5f9 !important;
    overflow-x: hidden;
}

.row-stretch {
    display: flex;
    flex-wrap: wrap;
}
.row-stretch > [class*="col-"] {
    display: flex;
}
.row-stretch .card {
    flex: 1;
}


/* ============ 3. แถบเมนูบน ============ */

.main-header {
    position: relative;
    isolation: isolate;
    overflow: visible;
    background: var(--top-nav-bg) !important;
    border-bottom: 2px solid rgba(96, 165, 250, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    min-height: var(--top-nav-h);
    height: var(--top-nav-h);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    box-shadow: var(--top-nav-shadow);
}
.main-header::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 38%;
    background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,0));
    pointer-events: none;
    z-index: 0;
}
.main-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, rgba(30, 64, 175, 0), rgba(30, 64, 175, 0.34), rgba(30, 64, 175, 0));
    z-index: 1;
    pointer-events: none;
}
.main-header .navbar-nav,
.main-header .navbar-actions {
    align-items: center;
}
.main-header .navbar-nav > .nav-item > .nav-link {
    font-size: 0.84rem;
    color: var(--top-nav-link-color);
    font-weight: 570;
    padding: 0.58rem 0.8rem;
    border-radius: 10px;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    line-height: 1;
    gap: 6px;
    white-space: nowrap;
    position: relative;
    border: var(--top-nav-link-border);
    text-shadow: 0 1px 0 rgba(255,255,255,.25);
}
.main-header .navbar-nav > .nav-item {
    margin-right: 6px;
}
.main-header .navbar-nav > .nav-item:last-child {
    margin-right: 0;
}
.main-header .navbar-nav > .nav-item > .nav-link:hover {
    background: var(--top-nav-link-hover-bg);
    border-color: var(--top-nav-link-hover-border);
    color: var(--top-nav-link-hover-color);
    box-shadow: var(--top-nav-link-hover-shadow);
}
.main-header .navbar-nav > .nav-item > .nav-link.active {
    color: var(--top-nav-link-active-color);
    font-weight: 620;
    background: var(--top-nav-link-active-bg);
    border-color: var(--top-nav-link-active-border);
    box-shadow: var(--top-nav-link-active-shadow);
}
.main-header .nav-link[data-widget="pushmenu"] {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--top-nav-push-bg);
    border: var(--top-nav-push-border);
    box-shadow: var(--top-nav-push-shadow);
}
.main-header .nav-link[data-widget="pushmenu"]:hover {
    background: var(--top-nav-push-bg-hover);
}
.main-header .auth-user-chip {
    border: var(--top-nav-auth-chip-border);
    border-radius: 999px;
    background: var(--top-nav-auth-chip-bg);
    color: #0f172a;
    padding: 6px 10px;
    line-height: 1;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 154px;
}
.main-header .auth-user-chip:hover {
    background: var(--top-nav-auth-chip-bg-hover);
    border-color: var(--top-nav-auth-chip-border-hover);
    color: #1d4ed8;
    box-shadow: var(--top-nav-auth-chip-shadow-hover);
}
.main-header #authUserMenuText {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 96px;
}
.main-header .navbar-actions {
    display: flex;
    align-items: center;
    flex-direction: row;
    gap: 6px;
}
.main-header .theme-preset-btn,
.main-header .navbar-actions .nav-link[data-widget="fullscreen"] {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--top-nav-push-bg);
    box-shadow: var(--top-nav-push-shadow);
    color: #0f172a;
}
.main-header .theme-preset-btn:hover,
.main-header .navbar-actions .nav-link[data-widget="fullscreen"]:hover {
    background: var(--top-nav-push-bg-hover);
    color: #1d4ed8;
}
.theme-preset-dropdown {
    min-width: 190px;
}
.theme-preset-dropdown .theme-preset-item {
    font-size: .84rem;
}
.theme-preset-dropdown .theme-preset-item.active,
.theme-preset-dropdown .theme-preset-item.active:hover {
    background: var(--top-nav-dropdown-item-active-bg);
    color: var(--top-nav-dropdown-item-active-color);
    font-weight: 700;
}
.main-header .navbar-nav .nav-link i {
    line-height: 1;
    width: 15px;
    min-width: 15px;
    text-align: center;
    transform: translateY(-0.5px);
}
.main-header .navbar-nav .nav-link i.mr-1 {
    margin-right: 0;
}
.main-header .navbar-collapse > .navbar-nav {
    align-items: center;
    gap: 4px;
}
.main-header .navbar-collapse {
    margin-left: 14px;
    min-width: 0;
    will-change: height, opacity, transform;
}
.main-header .navbar-collapse.collapsing {
    transition: height .14s ease;
}
.main-header .navbar-collapse > .navbar-nav > .nav-item > .nav-link {
    border: 1px solid transparent;
}
.main-header .navbar-collapse > .navbar-nav > .nav-item > .nav-link:hover,
.main-header .navbar-collapse > .navbar-nav > .nav-item > .nav-link:focus {
    border-color: rgba(37,99,235,.22);
}
.main-header #reportDropdown .badge {
    background: linear-gradient(135deg, #0ea5a4, #22d3ee);
    color: #fff;
    border-radius: 999px;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    font-size: .68rem;
    font-weight: 700;
    padding: 0 6px;
    box-shadow: 0 6px 14px rgba(14,165,164,.34), 0 0 0 1px rgba(255,255,255,.45) inset;
}
.main-header .dropdown-menu .dropdown-item .num-icon-top {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .68rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
}
.main-header .navbar-collapse > .navbar-nav > .nav-item.dropdown > .nav-link {
    padding-right: 0.92rem;
}
.main-header .dropdown-toggle::after {
    margin-left: .36rem;
    vertical-align: middle;
}
.auth-user-dropdown {
    width: max-content;
    min-width: 240px;
    max-width: min(460px, calc(100vw - 16px));
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 8px;
}
.auth-user-dropdown .auth-user-header {
    padding: 10px 12px 8px;
}
.auth-user-dropdown .auth-user-name {
    font-size: .92rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
}
.auth-user-dropdown .auth-user-meta {
    font-size: .78rem;
    color: #404040;
    line-height: 1.4;
}
.auth-user-dropdown .dropdown-divider {
    margin: 6px 0;
}
.auth-user-dropdown .dropdown-item {
    border-radius: 8px;
}
/* Recessed divider for dropdown menu */
.dropdown-divider-recessed {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
    height: 0;
    overflow: visible;
}
body.theme-darker .dropdown-divider-recessed {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.3);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}
.main-header .dropdown-menu .dropdown-divider-recessed {
    margin: 6px 8px;
}
.auth-login-modal.fade .modal-dialog {
    transform: translateY(16px) scale(0.96);
    opacity: 0;
    transition: transform .34s cubic-bezier(.22,.61,.36,1), opacity .28s ease;
}
.auth-login-modal.show .modal-dialog {
    transform: translateY(0) scale(1);
    opacity: 1;
}
.auth-login-modal .modal-content {
    border: var(--auth-login-content-border);
    border-radius: var(--auth-login-content-radius);
    overflow: hidden;
    background: var(--auth-login-content-bg);
    box-shadow: var(--auth-login-content-shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.auth-login-modal .modal-header {
    background: var(--auth-login-header-bg);
    color: #fff;
    border-bottom: none;
    padding: 14px 16px 12px;
    position: relative;
}
.auth-login-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 48px;
}
.auth-login-orb {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--auth-login-orb-color);
    border: var(--auth-login-orb-border);
    background: var(--auth-login-orb-bg);
    box-shadow: var(--auth-login-orb-shadow);
}
.auth-login-subtitle {
    font-size: .72rem;
    color: var(--auth-login-subtitle-color);
    letter-spacing: .2px;
}
.auth-login-modal .modal-title,
.age-gender-title {
    font-size: 1rem;
    margin: 0;
}
.auth-login-modal .close {
    color: #fff;
    opacity: .9;
    text-shadow: none;
    background: var(--auth-login-close-bg);
    border: var(--auth-login-close-border);
    border-radius: 10px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 10px;
    top: 9px;
    margin: 0;
}
.auth-login-modal .close:hover {
    opacity: 1;
    border-color: var(--auth-login-close-border-hover);
    background: var(--auth-login-close-bg-hover);
}
.auth-login-modal .modal-body {
    padding: 18px;
    background: var(--auth-login-body-bg);
}
.auth-login-modal .auth-help-text {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    color: var(--auth-login-help-color);
    margin-bottom: 14px;
    padding: 8px 11px;
    border-radius: 10px;
    border: var(--auth-login-help-border);
    border-left: 3px solid var(--auth-login-help-accent);
    background: var(--auth-login-help-bg);
}
.auth-login-modal .auth-help-text i {
    color: var(--auth-login-input-icon-color);
    font-size: .82rem;
}
.auth-login-modal .auth-field-group > label {
    color: var(--auth-login-label-color);
    font-size: .82rem;
    font-weight: 600;
}
.auth-login-modal .auth-input-wrap {
    position: relative;
}
.auth-login-modal .auth-input-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--auth-login-input-icon-color);
    font-size: .82rem;
    pointer-events: none;
}
.auth-login-modal .auth-password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(59, 130, 246, 0.32);
    color: var(--auth-login-input-icon-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.auth-login-modal .auth-password-toggle:hover {
    background: rgba(37, 99, 235, 0.32);
    border-color: rgba(37, 99, 235, 0.46);
}
.auth-login-modal .form-control,
.auth-login-modal .auth-input {
    border-radius: 11px;
    height: 42px;
    padding-left: 34px;
    padding-right: 42px;
    border: var(--auth-login-input-border);
    background: var(--auth-login-input-bg);
    color: var(--auth-login-input-color);
}
.auth-login-modal .form-control::placeholder,
.auth-login-modal .auth-input::placeholder {
    color: var(--auth-login-input-placeholder);
}
.auth-login-modal .form-control:focus,
.auth-login-modal .auth-input:focus {
    border-color: var(--auth-login-input-focus-border);
    box-shadow: var(--auth-login-input-focus-shadow);
    background: var(--auth-login-input-focus-bg);
    color: var(--auth-login-input-focus-color);
}
.auth-login-modal .auth-login-submit {
    margin-top: 14px;
    height: 44px;
    border: var(--auth-login-submit-border);
    border-radius: 11px;
    background: var(--auth-login-submit-bg);
    box-shadow: var(--auth-login-submit-shadow);
    font-weight: 700;
    letter-spacing: .2px;
}
.auth-login-modal .auth-login-submit:hover {
    background: var(--auth-login-submit-bg-hover);
    transform: translateY(-1px);
}
.auth-login-modal .auth-login-submit:disabled {
    opacity: .82;
    transform: none;
}
.auth-login-modal .auth-error {
    display: none;
    font-size: .82rem;
    margin-top: 8px;
    border-radius: 10px;
    background: var(--auth-login-error-bg);
    border: var(--auth-login-error-border);
    color: var(--auth-login-error-color);
}
body.auth-login-open .modal-backdrop.show {
    background: var(--auth-login-backdrop-bg);
    opacity: var(--auth-login-backdrop-opacity);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.auth-toast-container {
    position: fixed;
    top: calc(var(--top-nav-h) + 10px);
    right: 14px;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.auth-toast {
    min-width: 260px;
    max-width: 360px;
    border-radius: 14px;
    padding: 11px 14px;
    color: #fff;
    border: 1px solid rgba(255,255,255,.22);
    box-shadow: 0 14px 34px rgba(15, 23, 42, .24);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .88rem;
    font-weight: 500;
    letter-spacing: .1px;
    transform: translateY(-8px);
    opacity: 0;
    transition: transform .2s ease, opacity .2s ease;
    pointer-events: auto;
}
.auth-toast.show {
    transform: translateY(0);
    opacity: 1;
}
.auth-toast i {
    font-size: .95rem;
}
.auth-toast.success {
    background: linear-gradient(135deg, rgba(22,163,74,.88), rgba(34,197,94,.82));
}
.auth-toast.error {
    background: linear-gradient(135deg, rgba(220,38,38,.9), rgba(239,68,68,.84));
}
.auth-toast.info {
    background: linear-gradient(135deg, rgba(29,78,216,.88), rgba(37,99,235,.82));
}
.main-header .dropdown-menu {
    border-radius: 14px;
    padding: 8px;
    min-width: 200px;
    border: var(--top-nav-dropdown-border);
    box-shadow: var(--top-nav-dropdown-shadow);
    background: var(--top-nav-dropdown-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1095;
}
.main-header .navbar-nav > .nav-item.dropdown {
    position: relative;
    z-index: 1086;
}
.main-header .navbar-nav > .nav-item.dropdown.show {
    z-index: 1096;
}
.main-header .dropdown-menu[aria-labelledby="reportDropdown"],
.main-header .dropdown-menu[aria-labelledby="systemDataDropdown"] {
    width: max-content;
    min-width: 100%;
    max-width: min(420px, calc(100vw - 16px));
}
.main-header .dropdown-menu > li {
    margin: 0;
}
.main-header .dropdown-menu > li + li {
    margin-top: 2px;
}
.main-header .dropdown-menu > .dropdown-item + .dropdown-item {
    margin-top: 2px;
}
.main-header .dropdown-item {
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-family: 'Kanit', sans-serif;
    white-space: normal;
    color: var(--top-nav-dropdown-item-color);
    border: 1px solid transparent;
}
.main-header .dropdown-item:hover {
    background: var(--top-nav-dropdown-item-hover-bg);
    color: var(--top-nav-dropdown-item-hover-color);
    border-color: var(--top-nav-dropdown-item-hover-border);
}
.main-header .dropdown-item.active,
.main-header .dropdown-item.active:hover {
    background: var(--top-nav-dropdown-item-active-bg);
    color: var(--top-nav-dropdown-item-active-color);
    font-weight: 600;
}
body:has(.main-header .dropdown-menu.show) .main-header::after {
    opacity: 0;
}

.main-header .navbar-toggler {
    color: var(--top-nav-toggler-color);
    font-size: 1.1rem;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--top-nav-toggler-bg);
    transition: background 0.15s ease;
}
.main-header .navbar-toggler:hover {
    background: var(--top-nav-toggler-bg-hover);
    color: var(--top-nav-toggler-color-hover);
}
.main-header .nav-quick-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    height: 38px;
    min-height: 38px;
    padding: 0 10px !important;
    border-radius: 10px;
    background: var(--top-nav-push-bg);
    box-shadow: var(--top-nav-push-shadow);
    color: #0f172a;
}
.main-header .nav-quick-toggle:hover {
    background: var(--top-nav-push-bg-hover);
    color: #0f172a;
}
.main-header .nav-quick-toggle .nav-quick-label {
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
    color: inherit;
}
body.theme-darker .main-header .nav-quick-toggle {
    color: #ffffff;
}
body.theme-darker .main-header .nav-quick-toggle:hover {
    color: #ffffff;
}

/* เมื่อมีหน้าต่างโมดอลเปิด ให้โมดอลอยู่เหนือชั้นซ้อนทุกตัวบนส่วนหัวเสมอ */
.modal-backdrop {
    z-index: 2000 !important;
}
.modal {
    z-index: 2010 !important;
}
html.modal-open,
body.modal-open {
    overflow: hidden !important;
}
body.modal-open .main-header .navbar-collapse.show {
    display: none !important;
}
body.modal-open #authUserMenu .dropdown-menu.show {
    display: none !important;
}


/* ============ 4. แถบเมนูบน — จุดตัดจอแบบกำหนดเอง (1024 พิกเซล) ============ */

@media (min-width: 1366px) {
    .main-header .navbar-nav > .nav-item > .nav-link {
        font-weight: 580;
        padding: 0.54rem 0.6rem;
        gap: 4px;
    }
    .main-header .navbar-nav > .nav-item {
        margin-right: 3px;
    }
    .main-header .navbar-actions {
        gap: 3px;
    }
    .main-header #authUserMenuText {
        max-width: 76px;
    }
    .navbar-expand-custom {
        flex-flow: row nowrap;
        justify-content: flex-start;
    }
    .navbar-expand-custom .navbar-toggler {
        display: none;
    }
    .navbar-expand-custom .navbar-collapse {
        display: flex !important;
        flex-basis: auto;
    }
    .navbar-expand-custom .navbar-nav {
        flex-direction: row;
        flex-wrap: nowrap;
    }
    .navbar-expand-custom .navbar-nav .nav-link {
        padding-right: 0.75rem;
        padding-left: 0.75rem;
    }
    .navbar-expand-custom .navbar-nav .dropdown-menu {
        position: absolute;
    }
    .main-header .navbar-nav > .nav-item > .nav-link.active::before {
        content: "";
        position: absolute;
        left: 10px;
        right: 10px;
        bottom: 3px;
        height: 2.5px;
        border-radius: 999px;
        background: var(--top-nav-active-indicator-bg);
        box-shadow: var(--top-nav-active-indicator-shadow);
    }
}

@media (max-width: 1023.98px) {
    :root {
        --footer-logo-max: min(42vw, 260px);
    }
    .main-header {
        position: sticky;
        top: 0;
        z-index: 1060;
        padding: 8px 10px;
        padding-right: 176px;
        min-height: var(--top-nav-h);
        height: var(--top-nav-h);
    }
    /* ซ่อนเมนูด้านข้างเป็นค่าเริ่มต้นสำหรับแท็บเล็ต/มือถือ */
    .main-sidebar,
    .main-sidebar::before {
        transform: translateX(-250px);
    }
    .sidebar-open .main-sidebar,
    .sidebar-open .main-sidebar::before,
    body:not(.sidebar-collapse) .main-sidebar,
    body:not(.sidebar-collapse) .main-sidebar::before {
        transform: translateX(0);
    }
    .content-wrapper,
    .main-footer,
    .main-header {
        margin-left: 0 !important;
    }
    /* มือถือและแท็บเล็ต: ให้ข้อความล่างสุดอยู่ตามลำดับปกติ ไม่ลอยทับเมนู */
    .main-sidebar .sidebar {
        padding-bottom: 20px;
    }
    .ppaos-sidebar-bottom-copy {
        position: static;
        left: auto;
        right: auto;
        bottom: auto;
        margin: 8px 0 0;
        padding: 8px 6px 0;
        font-size: 0.78rem;
    }
    .main-header .nav-quick-toggle {
        display: inline-flex !important;
    }
    .main-header .navbar-nav {
        flex-direction: row;
        align-items: center;
    }
    .main-header .nav-quick-toggle {
        position: absolute;
        right: 166px;
        top: 50%;
        transform: translateY(-50%);
        margin: 0;
        z-index: 1062;
        height: 40px;
        min-height: 40px;
    }
    .main-header .navbar-actions {
        position: absolute;
        right: 8px;
        top: 8px;
        margin-left: 0;
        gap: 6px;
        z-index: 1062;
    }
    .main-header .navbar-actions .nav-link[data-widget="fullscreen"] { display: inline-flex; }
    .main-header .theme-preset-btn {
        min-width: 38px;
        min-height: 38px;
    }
    .main-header .auth-user-chip {
        max-width: 86px;
        padding: 7px 8px;
        min-height: 38px;
    }
    .main-header #authUserMenuText {
        max-width: 34px;
    }
    #themePresetMenu {
        position: relative;
    }
    #themePresetMenu .dropdown-menu {
        position: absolute !important;
        left: auto !important;
        right: 0 !important;
        top: calc(100% + 6px) !important;
        min-width: 220px;
        transform: none !important;
        margin: 0;
        border-radius: 12px;
        border: var(--top-mobile-panel-border);
        background: var(--top-mobile-panel-bg);
        box-shadow: var(--top-mobile-panel-shadow);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        z-index: 1064;
    }
    .main-header .navbar-collapse {
        position: absolute;
        left: 8px;
        right: 8px;
        top: var(--top-nav-h);
        background: var(--top-mobile-panel-bg);
        border-radius: 14px;
        box-shadow: var(--top-mobile-panel-shadow);
        padding: 10px;
        margin-top: 0;
        border: var(--top-mobile-panel-border);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        max-height: calc(100vh - var(--top-nav-h) - 16px);
        overflow-y: auto;
        margin-left: 0;
        z-index: 1061;
    }
    .main-header .navbar-collapse .navbar-nav {
        flex-direction: column !important;
        align-items: stretch;
        padding: 4px 0;
        gap: 4px;
    }
    .main-header .navbar-collapse .navbar-nav > .nav-item {
        width: 100%;
    }
    .main-header .navbar-collapse > .navbar-nav > .nav-item > .nav-link {
        padding: 10px 12px !important;
        border-radius: 10px;
        font-size: 0.88rem;
        min-height: 42px;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        text-align: left;
    }
    .main-header .navbar-collapse .nav-link:hover {
        background: var(--top-mobile-panel-hover);
    }
    .main-header .navbar-collapse .nav-link.active {
        background: var(--top-mobile-panel-active);
        color: #1d4ed8;
        font-weight: 600;
        border-left: 2px solid #2563eb;
    }
    .main-header .navbar-collapse .dropdown-menu {
        position: static !important;
        float: none;
        display: flex;
        flex-direction: column;
        gap: 0;
        width: 100%;
        min-width: 100%;
        max-width: none;
        border: none;
        box-shadow: none;
        padding: 0;
        margin-top: 0;
        background: transparent;
        max-height: 0;
        opacity: 0;
        transform: translateY(-4px);
        overflow: hidden;
        pointer-events: none;
        transition: max-height .28s ease, opacity .22s ease, transform .22s ease, margin-top .22s ease;
    }
    .main-header .navbar-collapse .dropdown-menu.show {
        display: flex;
        max-height: 420px;
        opacity: 1;
        transform: translateY(0);
        margin-top: 4px;
        pointer-events: auto;
    }
    .main-header .navbar-collapse .dropdown-menu .dropdown-item {
        width: 100%;
        display: flex;
        align-items: center;
        margin-bottom: 14px;
    }
    .main-header .navbar-collapse .dropdown-menu .dropdown-item:last-child {
        margin-bottom: 0;
    }
    /* ให้เมนูผู้ใช้เปิดแบบเดียวกับปุ่ม 3 จุด */
    #authUserMenu .dropdown-menu {
        position: fixed !important;
        left: 8px !important;
        right: 8px !important;
        top: var(--top-nav-h) !important;
        width: auto !important;
        transform: none !important;
        min-width: 0 !important;
        border-radius: 14px;
        border: var(--top-mobile-panel-border);
        background: var(--top-mobile-panel-bg);
        box-shadow: var(--top-mobile-panel-shadow);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        padding: 10px;
        margin: 0;
        max-height: calc(100vh - var(--top-nav-h) - 16px);
        overflow-y: auto;
        z-index: 1063;
    }
    #authUserMenu .auth-user-header {
        padding: 2px 4px 8px;
    }
    #authUserMenu .auth-user-name {
        font-size: .94rem;
    }
    #authUserMenu .auth-user-meta {
        font-size: .82rem;
    }
    #authUserMenu .dropdown-item {
        min-height: 42px;
        display: flex;
        align-items: center;
        border-radius: 10px;
        padding: 10px 12px;
        font-size: .88rem;
    }
    .main-header #reportDropdown .badge {
        min-width: 18px;
        height: 18px;
        line-height: 18px;
        font-size: .62rem;
    }
    .main-header .navbar-nav > .nav-item {
        margin-right: 0;
    }
}

/* แท็บเล็ตแบบกะทัดรัด: ใช้เมนูด่วนโดยไม่ให้เกิดแถบเลื่อนภายใน */
@media (min-width: 768px) and (max-width: 1023.98px) {
    .main-header {
        padding-right: 272px;
    }
    .main-header .nav-quick-toggle {
        position: absolute;
        right: 214px;
        top: 50%;
        transform: translateY(-50%);
        margin: 0;
        z-index: 1062;
        height: 40px;
        min-height: 40px;
    }
    .main-header .navbar-actions .nav-link[data-widget="fullscreen"] { display: inline-flex; }
    .main-header .auth-user-chip {
        max-width: 136px;
    }
    .main-header #authUserMenuText {
        max-width: 72px;
    }
    .main-header .navbar-actions .nav-link {
        min-height: 38px;
        min-width: 38px;
        justify-content: center;
    }
    .main-header .navbar-collapse {
        left: auto;
        right: 8px;
        width: min(520px, calc(100vw - 16px));
        top: calc(var(--top-nav-h) + 6px);
        max-height: none;
        overflow-y: visible;
        border-top-left-radius: 12px;
        border-top-right-radius: 12px;
    }
    .main-header .navbar-collapse.collapsing {
        transition: none;
    }
    #authUserMenu .dropdown-menu {
        left: auto !important;
        right: 8px !important;
        width: min(360px, calc(100vw - 16px)) !important;
        min-width: 300px !important;
        top: calc(var(--top-nav-h) + 6px) !important;
        max-height: none;
        overflow-y: visible;
        border-top-left-radius: 12px;
        border-top-right-radius: 12px;
    }

    .main-header .navbar-collapse > .navbar-nav > .nav-item > .nav-link {
        text-align: left;
        padding-left: 8px;
        padding-right: 10px;
        justify-content: flex-start;
        gap: 8px;
    }
    .main-header .navbar-collapse > .navbar-nav > .nav-item > .nav-link i {
        margin-left: 0;
    }
}

/* จอช่วงกลาง (ใหญ่กว่า 480 แต่เล็กกว่า 768): ใช้โครงเดียวกับแท็บเล็ต */
@media (min-width: 481px) and (max-width: 767.98px) {
    .main-header {
        padding-right: 265px;
    }
    .main-header .nav-quick-toggle {
        right: 190px;
        top: 50%;
        transform: translateY(-50%);
        margin: 0;
        z-index: 1062;
        height: 40px;
        min-height: 40px;
        min-width: 78px;
        padding-left: 10px;
        padding-right: 10px;
    }
    .main-header .nav-quick-toggle .nav-quick-label {
        display: inline;
        font-size: 0.74rem;
        margin-left: 3px;
    }
    .main-header .navbar-actions .nav-link[data-widget="fullscreen"] { display: inline-flex; }
    .main-header .auth-user-chip {
        max-width: 106px;
    }
    .main-header #authUserMenuText {
        max-width: 42px;
    }
    .main-header .navbar-actions .nav-link {
        min-height: 38px;
        min-width: 38px;
        justify-content: center;
    }
    .main-header .navbar-collapse {
        left: auto;
        right: 8px;
        width: min(520px, calc(100vw - 16px));
        top: calc(var(--top-nav-h) + 6px);
        max-height: none;
        overflow-y: visible;
        border-top-left-radius: 12px;
        border-top-right-radius: 12px;
    }
    .main-header .navbar-collapse.collapsing {
        transition: none;
    }
    #authUserMenu .dropdown-menu {
        left: auto !important;
        right: 8px !important;
        width: min(340px, calc(100vw - 16px)) !important;
        min-width: 280px !important;
        top: calc(var(--top-nav-h) + 6px) !important;
        max-height: none;
        overflow-y: visible;
        border-top-left-radius: 12px;
        border-top-right-radius: 12px;
    }
}

/* จูนจังหวะระยะด้านบนคอนเทนต์ให้กระชับขึ้น */
.content.pt-3 {
    padding-top: 0.65rem !important;
}


/* ============ 5. เมนูด้านข้าง ============ */

.main-sidebar {
    font-size: 0.85rem;
    background: var(--sidebar-bg) !important;
}
.main-sidebar .sidebar {
    position: relative;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-scrollbar-thumb) transparent;
}
.main-sidebar .sidebar .nav-sidebar {
    padding-right: 8px;
}
.ppaos-sidebar-bottom-copy {
    position: static;
    z-index: 2;
    margin-top: auto;
    padding: 10px 10px 8px;
    padding-bottom: 30px;
    text-align: center;
    font-size: 0.9rem;
    color: rgba(191, 219, 254, 0.92);
}
.ppaos-sidebar-bottom-copy strong {
    color: #ffffff;
}

@supports (overflow: overlay) {
    .main-sidebar .sidebar {
        overflow-y: overlay;
    }
}
.main-sidebar .sidebar::-webkit-scrollbar {
    width: 2px;
}
.main-sidebar .sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.main-sidebar .sidebar::-webkit-scrollbar-thumb {
    background: var(--sidebar-scrollbar-thumb);
    border-radius: 999px;
    border: 0;
    background-clip: padding-box;
}
.main-sidebar .sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--sidebar-scrollbar-thumb-hover);
    background-clip: padding-box;
}

.nav-sidebar .nav-item {
    width: 100%;
}
.nav-sidebar .nav-link {
    display: flex;
    align-items: center;
    width: calc(100% - 16px);
    border-radius: 8px;
    padding: 10px 14px;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-sidebar .nav-link:hover {
    background: var(--sidebar-generic-link-hover-bg);
}
.nav-sidebar .nav-link.active {
    background: var(--sidebar-generic-link-active-bg) !important;
    box-shadow: var(--sidebar-generic-link-active-shadow);
}

.brand-link {
    height: var(--top-nav-h);
    min-height: var(--top-nav-h);
    padding: 6px 10px;
    border-bottom: 2px solid rgba(96, 165, 250, 0.4) !important;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.brand-text {
    letter-spacing: 0.5px;
}

.nav-sidebar .nav-link .num-icon-top {
    margin-right: 0.45rem;
}
.nav-sidebar .nav-link:not(.active) .num-icon-top {
    border-color: var(--sidebar-num-icon-idle-border);
    color: var(--sidebar-num-icon-idle-color);
}
.nav-sidebar .nav-link .nav-icon.num-icon-top {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    line-height: 18px !important;
    padding: 0 !important;
    margin-left: 0 !important;
    border-radius: 999px !important;
    font-size: 0.65rem !important;
    flex: 0 0 18px;
}
.nav-sidebar .nav-link.active .num-icon-top,
.dropdown-item.active .num-icon-top,
.dropdown-item:active .num-icon-top {
    color: #fff;
    border-color: #fff;
}
.nav-sidebar .nav-link.active,
.nav-sidebar .nav-link.active p,
.nav-sidebar .nav-link.active i {
    color: #fff !important;
}
.ppaos-menu-shell {
    background: var(--sidebar-shell-bg) !important;
}
.ppaos-menu-brand {
    border-bottom: var(--sidebar-brand-border) !important;
    background: var(--sidebar-brand-bg);
}
.ppaos-menu-brand .brand-logo-svg {
    display: block;
    width: min(100%, 200px);
    height: auto;
    margin: 0 auto;
    filter: var(--sidebar-brand-logo-shadow);
}
.ppaos-menu-brand .brand-logo-mini {
    display: none;
    width: 126px;
    height: auto;
    max-width: 100%;
    margin: 0 auto;
    filter: var(--sidebar-brand-mini-shadow);
}
.ppaos-side-nav .nav-header {
    color: var(--sidebar-nav-header-color);
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .35px;
    text-transform: uppercase;
    padding-left: 12px;
}
.ppaos-side-nav .ppaos-menu-link {
    border: var(--sidebar-link-border);
    background: var(--sidebar-link-bg);
    color: var(--sidebar-link-color);
    box-shadow: var(--sidebar-link-inset-shadow);
    transition: transform .34s cubic-bezier(.22,.61,.36,1), background .34s cubic-bezier(.22,.61,.36,1), border-color .34s cubic-bezier(.22,.61,.36,1), box-shadow .34s cubic-bezier(.22,.61,.36,1), color .3s ease, opacity .3s ease;
    will-change: transform, background, border-color, box-shadow;
}
.ppaos-side-nav .ppaos-menu-link .nav-icon {
    transition: transform .3s cubic-bezier(.22,.61,.36,1), color .3s ease, opacity .3s ease;
    transform-origin: center center;
}
.ppaos-side-nav .ppaos-menu-link p {
    transition: color .3s ease, opacity .3s ease;
}
.ppaos-side-nav .ppaos-menu-link:hover {
    border-color: var(--sidebar-link-hover-border);
    background: var(--sidebar-link-hover-bg);
    color: #ffffff;
    transform: none;
    box-shadow: var(--sidebar-link-hover-shadow);
}
.ppaos-side-nav .ppaos-menu-link:hover .nav-icon {
    transform: scale(1.14);
}
.ppaos-side-nav .ppaos-menu-link.active {
    border-color: var(--sidebar-link-active-border);
    background: var(--sidebar-link-active-bg) !important;
    box-shadow: var(--sidebar-link-active-shadow);
}
.ppaos-side-nav .nav-treeview .ppaos-menu-link {
    border: var(--sidebar-sub-link-border);
    background: var(--sidebar-sub-link-bg);
    color: var(--sidebar-sub-link-color);
    box-sizing: border-box;
    overflow: visible;
    box-shadow: 0 4px 10px rgba(2, 6, 23, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: transform .26s cubic-bezier(.22,.61,.36,1), background .26s cubic-bezier(.22,.61,.36,1), border-color .26s cubic-bezier(.22,.61,.36,1), box-shadow .26s cubic-bezier(.22,.61,.36,1), color .26s ease;
}
.ppaos-side-nav .nav-treeview .ppaos-menu-link:hover {
    border-color: var(--sidebar-sub-link-hover-border);
    background: var(--sidebar-sub-link-hover-bg);
    color: var(--sidebar-sub-link-hover-color);
    transform: translateX(4px);
    box-shadow: 0 10px 18px rgba(2, 6, 23, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.ppaos-side-nav .nav-treeview .ppaos-menu-link.active {
    border-color: var(--sidebar-sub-link-active-border);
    background: var(--sidebar-sub-link-active-bg) !important;
    color: var(--sidebar-sub-link-active-color) !important;
    box-shadow: var(--sidebar-sub-link-active-shadow);
    transform: none;
}
.ppaos-side-nav .nav-treeview .ppaos-menu-link .nav-icon,
.ppaos-side-nav .nav-treeview .ppaos-menu-link p {
    color: inherit;
}
.ppaos-side-nav .ppaos-menu-link .nav-icon,
.ppaos-side-nav .ppaos-menu-link p {
    color: inherit;
}
.num-icon-top {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid #0f2859;
    font-weight: 600;
    color: #475569;
    font-family: 'Kanit', sans-serif;
}
/* ============ 6. เมนูด้านข้างตอนย่อ (ตั้งแต่ 1024 พิกเซลขึ้นไป) ============ */

@media (min-width: 1366px) {
    /* ที่ความกว้างตั้งแต่ 1024 ขึ้นไป ใช้โหมดย่อเมนู ไม่ใช้โหมดซ่อน */
    .sidebar-mini .main-sidebar,
    .sidebar-mini .main-sidebar::before {
        transform: none !important;
    }
    .sidebar-mini:not(.sidebar-collapse) .main-sidebar,
    .sidebar-mini:not(.sidebar-collapse) .main-sidebar::before {
        width: 250px !important;
        min-width: 250px !important;
        max-width: 250px !important;
    }
    .sidebar-mini:not(.sidebar-collapse) .content-wrapper,
    .sidebar-mini:not(.sidebar-collapse) .main-footer,
    .sidebar-mini:not(.sidebar-collapse) .main-header {
        margin-left: 250px !important;
    }
    .main-header {
        padding-top: 0;
        padding-bottom: 0;
    }
    .main-header .navbar-collapse {
        height: 100%;
        display: flex !important;
        align-items: center;
    }
    .main-header .navbar-collapse > .navbar-nav {
        height: 100%;
        display: flex;
        align-items: center;
    }

    /* ความกว้างหลัก — ใช้ค่าจากจุดเดียว */
    .sidebar-mini.sidebar-collapse .main-sidebar,
    .sidebar-mini.sidebar-collapse .main-sidebar::before,
    .sidebar-mini.sidebar-collapse .main-sidebar:hover,
    .sidebar-mini.sidebar-collapse .main-sidebar:focus-within,
    .sidebar-mini.sidebar-collapse .brand-link,
    .sidebar-mini.sidebar-collapse .brand-link:hover,
    .sidebar-mini.sidebar-collapse .main-sidebar:hover .brand-link,
    .sidebar-mini.sidebar-collapse.layout-fixed .brand-link {
        width: var(--sidebar-collapsed) !important;
        min-width: var(--sidebar-collapsed) !important;
        max-width: var(--sidebar-collapsed) !important;
        overflow-x: hidden !important;
        transition: none !important;
    }

    .sidebar-mini.sidebar-collapse .content-wrapper,
    .sidebar-mini.sidebar-collapse .main-footer,
    .sidebar-mini.sidebar-collapse .main-header,
    .sidebar-mini.sidebar-collapse .main-sidebar:hover ~ .content-wrapper,
    .sidebar-mini.sidebar-collapse .main-sidebar:hover ~ .main-footer,
    .sidebar-mini.sidebar-collapse .main-sidebar:hover ~ .main-header {
        margin-left: var(--sidebar-collapsed) !important;
        transition: none !important;
    }

    /* รีเซ็ตโครงสร้างด้านในของเมนูด้านข้าง */
    .sidebar-mini.sidebar-collapse .sidebar {
        padding: 0 0 20px 2px !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain !important;
        max-height: calc(100vh - 3.5rem) !important;
        transition: none !important;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar {
        padding: 0 !important;
    }
    .sidebar-mini.sidebar-collapse .ppaos-sidebar-bottom-copy {
        display: block !important;
        position: static !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        margin: 8px 0 0;
        padding: 8px 6px 0;
        font-size: 0.7rem;
    }

    /* แถบเลื่อนสำหรับเมนูด้านข้างตอนย่อ */
    .sidebar-mini.sidebar-collapse .sidebar::-webkit-scrollbar {
        width: 2px;
    }
    .sidebar-mini.sidebar-collapse .sidebar::-webkit-scrollbar-track {
        background: transparent;
    }
    .sidebar-mini.sidebar-collapse .sidebar::-webkit-scrollbar-thumb {
        background: var(--sidebar-scrollbar-thumb);
        border-radius: 999px;
    }
    .sidebar-mini.sidebar-collapse .sidebar::-webkit-scrollbar-thumb:hover {
        background: var(--sidebar-scrollbar-thumb-hover);
    }
    .sidebar-mini.sidebar-collapse .sidebar {
        scrollbar-width: thin;
        scrollbar-color: var(--sidebar-scrollbar-thumb) transparent;
    }

    /* รายการเมนู — ไอคอนอยู่บน ข้อความอยู่ล่าง */
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-item {
        width: 100% !important;
        margin: 0 !important;
        /* padding: 0 2px !important; */
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
        width: calc(100% - 6px) !important;
        min-height: 85px !important;
        padding: 12px 6px !important;
        margin-left: 2px !important;
        border-radius: 10px !important;
        white-space: normal !important;
        position: relative !important;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link .nav-icon {
        margin-right: 0 !important;
        font-size: 1.1rem;
        margin-bottom: 3px;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link .nav-icon.num-icon-top {
        width: 18px !important;
        height: 18px !important;
        min-width: 18px !important;
        line-height: 18px !important;
        font-size: 0.65rem !important;
        margin-bottom: 4px;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link p {
        width: auto !important;
        visibility: visible !important;
        animation-name: none !important;
        animation-fill-mode: none !important;
        margin-left: 0 !important;
        display: block !important;
        font-size: 0.78rem !important;
        line-height: 1.35;
        white-space: normal !important;
        opacity: 0.85 !important;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link:hover p {
        opacity: 1 !important;
    }
    .sidebar-mini.sidebar-collapse .main-sidebar:hover .nav-sidebar .nav-link p {
        display: block !important;
        width: auto !important;
        margin-left: 0 !important;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link p > i.right {
        position: static !important;
        display: block !important;
        margin: 4px auto 0 !important;
        line-height: 1 !important;
        font-size: 0.72rem !important;
        opacity: 0.9;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link p > .num-icon-top.right {
        display: block !important;
        position: absolute;
        top: 4px;
        right: 5px;
        width: 18px;
        height: 18px;
        margin-right: 0;
        z-index: 1;
    }

    /* ลิงก์แบรนด์ */
    .sidebar-mini.sidebar-collapse .brand-link {
        text-align: center !important;
        padding: 0 4px !important;
        height: 59px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    .sidebar-mini.sidebar-collapse .brand-text {
        visibility: visible;
        animation-name: none;
        animation-fill-mode: none;
        margin-left: 0;
        display: block;
        font-size: 0.7rem;
        text-align: center;
        opacity: 1;
    }
    .sidebar-mini.sidebar-collapse .ppaos-menu-brand .brand-logo-svg {
        display: none;
    }
    .sidebar-mini.sidebar-collapse .ppaos-menu-brand .brand-logo-mini {
        display: block;
        width: 126px;
        height: auto;
        max-width: 126px;
    }
}

/* สไตล์ไอคอนตัวเลขของเมนูด้านข้างและเมนูบน */
.nav-sidebar .nav-link p > .num-icon-top.right,
.navbar .num-icon-top {
    vertical-align: middle;
}

/* โหมดเมนูด้านข้างแบบขยาย: แยกตำแหน่งป้ายตัวเลขและลูกศรไม่ให้ทับกัน */
body:not(.sidebar-collapse) .ppaos-side-nav .nav-item.has-treeview > .nav-link {
    position: relative;
}
body:not(.sidebar-collapse) .ppaos-side-nav .ppaos-menu-link {
    align-items: flex-start;
}
body:not(.sidebar-collapse) .ppaos-side-nav .ppaos-menu-link .nav-icon {
    margin-top: 2px;
    margin-right: 8px;
}
body:not(.sidebar-collapse) .ppaos-side-nav .nav-item.has-treeview > .nav-link p {
    position: relative;
    width: 100%;
    display: block;
    padding-right: 44px;
}
body:not(.sidebar-collapse) .ppaos-side-nav .nav-item.has-treeview > .nav-link p > .num-icon-top.right {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
}
body:not(.sidebar-collapse) .ppaos-side-nav .nav-item.has-treeview > .nav-link p > i.right {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform .08s linear;
    margin: 0;
}
body:not(.sidebar-collapse) .ppaos-side-nav .nav-item.has-treeview.menu-open > .nav-link p > i.right,
body:not(.sidebar-collapse) .ppaos-side-nav .nav-item.has-treeview.menu-is-opening > .nav-link p > i.right {
    transform: translateY(-50%) rotate(-90deg);
}
/* เมนูรายงาน (ไม่ใช่ treeview) ใช้ตำแหน่งป้าย/ลูกศรเดียวกับ treeview เพื่อกันเลขทับไอคอน */
body:not(.sidebar-collapse) .ppaos-side-nav .js-right-report-toggle p {
    position: relative;
    width: 100%;
    display: block;
    margin: 0;
    padding-right: 44px;
}
body:not(.sidebar-collapse) .ppaos-side-nav .js-right-report-toggle p > .num-icon-top.right {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
}
body:not(.sidebar-collapse) .ppaos-side-nav .js-right-report-toggle p > i.right {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%) rotate(180deg);
    transition: transform .08s linear;
    margin: 0;
}
body.has-right-report-sidebar-open:not(.sidebar-collapse) .ppaos-side-nav .js-right-report-toggle p > i.right {
    transform: translateY(-50%) rotate(0deg);
}

/* โหมดเมนูด้านข้างแบบย่อ: ลูกศรพื้นหลังขาวและตัวลูกศรสีน้ำเงิน */
.sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link p > i.right {
    background: #ffffff;
    color: #1d4ed8 !important;
    border-radius: 999px;
    width: 20px;
    height: 20px;
    line-height: 20px !important;
    text-align: center;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem !important;
    font-weight: 900;
}
.sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .js-right-report-toggle p > i.right {
    transform: rotate(180deg) !important;
}
body.has-right-report-sidebar-open.sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .js-right-report-toggle p > i.right {
    transform: rotate(0deg) !important;
}

/* ============ 7. แบนเนอร์ส่วนหัว ============ */

.dashboard-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 40%, #2563eb 100%);
    color: #fff;
    padding: 20px 0;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}
.content-wrapper .container-fluid,
.dashboard-header .container-fluid,
.sticky-filter-bar .container-fluid {
    padding-left: 20px;
    padding-right: 20px;
}
.dashboard-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.04) 75%, transparent 100%);
    animation: header-sweep 4s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}
.dashboard-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #60a5fa, #a78bfa, #60a5fa, transparent);
    background-size: 200% 100%;
    animation: border-glow 3s linear infinite;
    pointer-events: none;
    z-index: 1;
}
@keyframes header-sweep {
    0%   { left: -100%; opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { left: 150%; opacity: 0; }
}
@keyframes border-glow {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.stat-highlight {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.stat-highlight .stat-number {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.stat-highlight .stat-label {
    font-size: 0.85rem;
    opacity: 0.75;
    letter-spacing: 0.3px;
}

.year-select {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.year-select:focus {
    background-color: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.3);
    color: #fff;
}
.year-select option {
    color: #1e293b;
    background: #fff;
}

.dashboard-header.hero-banner {
    background:
        radial-gradient(circle at 12% 18%, rgba(129, 140, 248, 0.26), transparent 44%),
        radial-gradient(circle at 88% 78%, rgba(56, 189, 248, 0.25), transparent 40%),
        linear-gradient(135deg, #0f1d3c 0%, #1e40af 45%, #2563eb 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.24);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 18px 34px rgba(15, 23, 42, 0.25);
}
.dashboard-header.hero-banner .hero-year-wrap {
    position: relative;
}
/* รวมรูปแบบไอคอนวงกลมในแบนเนอร์ให้ใช้ร่วมกัน */
.dashboard-header.hero-banner .hero-year-arrow,
.dashboard-header.hero-banner .hero-datetime-icon {
    border-radius: 50%;
    background: #ffffff;
    color: #1d4ed8;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.25);
}
.dashboard-header.hero-banner .year-select.hero-year-select {
    border: 1px solid rgba(191, 219, 254, 0.82);
    background: linear-gradient(130deg, rgba(30, 64, 175, 0.92), rgba(37, 99, 235, 0.88));
    border-radius: 14px;
    color: #ffffff;
    font-size: .8rem;
    height: 43px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 12px 26px rgba(2, 6, 23, 0.22);
    padding-left: 12px;
    padding-right: 54px;
    transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
}
.dashboard-header.hero-banner .hero-year-arrow {
    position: absolute;
    top: 50%;
    right: 8px;
    width: 30px;
    height: 30px;
    transform: translateY(-50%);
    pointer-events: none;
}
.dashboard-header.hero-banner .hero-year-arrow i {
    font-size: .85rem;
    line-height: 1;
}
.dashboard-header.hero-banner .year-select.hero-year-select:hover {
    transform: translateY(-1px) scale(1.005);
    border-color: rgba(255, 255, 255, 0.95);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 16px 30px rgba(15, 23, 42, 0.3);
}
.dashboard-header.hero-banner .year-select.hero-year-select:focus {
    border-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.4), 0 16px 30px rgba(15, 23, 42, 0.3);
}
.dashboard-header.hero-banner .year-select.hero-year-select option {
    color: #0f172a;
    background: #f8fafc;
}
.dashboard-header.hero-banner .stat-highlight.hero-datetime {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 232px;
    padding: 8px 14px 8px 42px;
    border: 1px solid rgba(191, 219, 254, 0.8);
    border-radius: 15px;
    background:
        linear-gradient(140deg, rgba(30, 64, 175, 0.96), rgba(29, 78, 216, 0.9)),
        radial-gradient(circle at 10% 20%, rgba(191, 219, 254, 0.22), transparent 45%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 14px 26px rgba(15, 23, 42, 0.26);
}
.dashboard-header.hero-banner .hero-datetime-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    font-size: .72rem;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.24);
}
.dashboard-header.hero-banner .hero-datetime-content {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}
.dashboard-header.hero-banner .stat-highlight.hero-datetime .stat-label {
    font-size: .58rem;
    font-weight: 400;
    letter-spacing: .35px;
    color: rgba(224, 242, 254, 0.92);
    text-transform: uppercase;
}
.dashboard-header.hero-banner .stat-highlight.hero-datetime .stat-number {
    font-size: .8rem;
    font-weight: 400;
    color: #ffffff;
    line-height: 1.2;
    text-shadow: 0 1px 8px rgba(2, 6, 23, 0.36);
}
@media (max-width: 991.98px) {
    .dashboard-header.hero-banner .year-select.hero-year-select {
        height: 37px;
        font-size: .74rem;
        border-radius: 12px;
        padding-right: 48px;
    }
    .dashboard-header.hero-banner .hero-year-arrow {
        width: 26px;
        height: 26px;
        right: 7px;
    }
    .dashboard-header.hero-banner .hero-year-arrow i {
        font-size: .78rem;
    }
    .dashboard-header.hero-banner .stat-highlight.hero-datetime {
        min-width: 100%;
        align-items: flex-start;
        padding-left: 42px;
    }
    .dashboard-header.hero-banner .hero-datetime-content {
        align-items: flex-start;
    }
}

/* ============ 7.2 โหมดเข้ม (ส่วนหัวและแถบรายงาน) ============ */
body.theme-darker .dashboard-header.hero-banner {
    background:
        radial-gradient(circle at 12% 18%, rgba(59, 130, 246, 0.14), transparent 46%),
        radial-gradient(circle at 88% 78%, rgba(37, 99, 235, 0.14), transparent 42%),
        linear-gradient(180deg, #0f1a31 0%, #10203d 100%);
    border-bottom: 1px solid rgba(8, 15, 30, 0.92);
    box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.08), 0 16px 30px rgba(2, 6, 23, 0.34);
}
/* ============ 8. แถบตัวกรองเขตพื้นที่ ============ */

.district-filter-bar {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    padding: 8px 0;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    animation: slideDown 0.3s ease;
}
.district-filter-bar i.fa-map-marker-alt {
    font-size: 14px;
}
.district-filter-bar .btn-outline-light {
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 20px;
}
@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

/* ============ 8.1 แถบตัวกรองแบบติดด้านบน ============ */

.sticky-filter-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1065;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #1d4ed8 100%);
    padding: 0;
    height: var(--top-nav-h);
    display: flex;
    align-items: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
    transform: translateY(-110%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.45s ease, margin-left 0.3s ease;
    pointer-events: none;
    border-bottom: 2px solid rgba(96, 165, 250, 0.4);
    margin-left: 0;
}
.sticky-filter-bar .container-fluid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.sticky-filter-bar .sfb-left,
.sticky-filter-bar .sfb-right {
    display: flex;
    align-items: center;
}
.sticky-filter-bar.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}
.sfb-icon {
    color: #60a5fa;
    font-size: 0.85rem;
}
.sfb-prov-name {
    color: #fff;
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}
.sfb-right {
    gap: 6px;
}
.sfb-field {
    display: flex;
    align-items: center;
    gap: 4px;
}
.sfb-label {
    color: rgba(255,255,255,0.65);
    font-size: 0.72rem;
    margin: 0;
    white-space: nowrap;
    display: none;
}
.sfb-select {
    background-color: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 8px;
    padding: 4px 28px 4px 10px;
    font-size: 0.78rem;
    font-family: 'Kanit', sans-serif;
    height: 30px;
    min-width: 100px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(255,255,255,0.7)'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.sfb-select:hover,
.sfb-select:focus {
    background-color: rgba(255,255,255,0.2);
    border-color: rgba(96,165,250,0.6);
    outline: none;
}
.sfb-select option {
    background: #1e293b;
    color: #fff;
}
@media (min-width: 768px) {
    .sfb-label { display: block; }
    .sfb-select { min-width: 140px; }
}
@media (min-width: 1024px) {
    .sidebar-mini.sidebar-collapse .sticky-filter-bar {
        margin-left: var(--sidebar-collapsed, calc(5.8rem + 40px));
    }
    .sidebar-mini:not(.sidebar-collapse) .sticky-filter-bar {
        margin-left: 250px;
    }
    .sfb-prov-name { max-width: 260px; }
}
@media (max-width: 767.98px) {
    .sfb-prov-name { max-width: 100px; font-size: 0.8rem; }
    .sfb-select { min-width: 80px; font-size: 0.75rem; padding: 3px 24px 3px 8px; height: 28px; }
}

/* ============ 9. การ์ดข้อมูล ============ */

/* จัดกึ่งกลางแนวแกนสำหรับปุ่มและไอคอนที่ใช้ร่วมกัน */
.fab-btn,
.ring-icon,
.detail-stat-icon,
.residence-section .section-icon,
.status-card .status-icon,
.status-card .status-label {
    display: flex;
    align-items: center;
    justify-content: center;
}
/* รวมแอนิเมชันพื้นฐานของการ์ดที่ใช้รูปแบบเดียวกัน */
.card,
.small-box,
.detail-stat-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
/* รวมการยกตัวของการ์ดเวลาชี้เมาส์ */
.small-box:hover,
.stat-card-ring:hover,
.detail-stat-card:hover {
    transform: translateY(-3px);
}
/* รวมเอฟเฟ็กต์เปลี่ยนผ่านของการ์ดที่ใช้จังหวะเดียวกัน */
.stat-card-ring,
.status-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
/* รวมองค์ประกอบหลอกแบบวงกลมที่ใช้โครงสร้างเดียวกัน */
.stat-card-ring::before,
.detail-stat-card::before {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    pointer-events: none;
}

.card {
    border-radius: 14px;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 8px 30px rgba(0,0,0,0.06);
}
.card-header {
    border-radius: 14px 14px 0 0;
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.card-outline.card-primary .card-header {
    border-top: 3px solid #3b82f6;
}
.card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
}
.card-body {
    position: relative;
}


/* ============ 10. กล่องข้อมูลขนาดเล็ก ============ */

.small-box {
    border-radius: 14px;
    border: none;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
.small-box:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}
.small-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    pointer-events: none;
}
.small-box h3 {
    font-size: 1.9rem;
    font-weight: 700;
    text-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.small-box p         { font-size: 0.85rem; opacity: 0.9; }
.small-box .icon > i { font-size: 60px; opacity: 0.2; }

.small-box.bg-info    { background: linear-gradient(135deg, #06b6d4, #0284c7) !important; }
.small-box.bg-success { background: linear-gradient(135deg, #10b981, #059669) !important; }
.small-box.bg-warning { background: linear-gradient(135deg, #f59e0b, #d97706) !important; }
.small-box.bg-danger  { background: linear-gradient(135deg, #ef4444, #dc2626) !important; }


/* ============ 11. การ์ดสถิติพร้อมไอคอนวงแหวน ============ */

.stat-card-ring {
    display: flex;
    align-items: center;
    border-radius: 16px;
    padding: 18px 16px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
    border: none;
}
.stat-card-ring::before {
    top: -40%; right: -30%;
    width: 120px; height: 120px;
}
.stat-card-ring::after {
    content: '';
    position: absolute;
    bottom: -30%; left: -20%;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    pointer-events: none;
}
.stat-teal  { background: linear-gradient(135deg, #0891b2 0%, #06b6d4 50%, #22d3ee 100%); box-shadow: 0 4px 16px rgba(8,145,178,0.3); }
.stat-green { background: linear-gradient(135deg, #059669 0%, #10b981 50%, #34d399 100%); box-shadow: 0 4px 16px rgba(5,150,105,0.3); }
.stat-amber { background: linear-gradient(135deg, #d97706 0%, #f59e0b 50%, #fbbf24 100%); box-shadow: 0 4px 16px rgba(217,119,6,0.3); }
.stat-rose  { background: linear-gradient(135deg, #e11d48 0%, #f43f5e 50%, #fb7185 100%); box-shadow: 0 4px 16px rgba(225,29,72,0.3); }

.stat-teal:hover  { box-shadow: 0 8px 28px rgba(8,145,178,0.4); }
.stat-green:hover { box-shadow: 0 8px 28px rgba(5,150,105,0.4); }
.stat-amber:hover { box-shadow: 0 8px 28px rgba(217,119,6,0.4); }
.stat-rose:hover  { box-shadow: 0 8px 28px rgba(225,29,72,0.4); }

.ring-icon {
    width: 64px; height: 64px; min-width: 64px;
    margin-right: 14px;
    position: relative;
}
.ring-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    transform: rotate(-90deg);
    transition: transform 0.6s cubic-bezier(0.34,1.56,0.64,1);
}
.ring-bg {
    fill: none;
    stroke: rgba(255,255,255,0.3);
    stroke-width: 2.5;
    transition: opacity 0.3s ease;
}
.ring-progress {
    fill: none;
    stroke: rgba(255,255,255,0.85);
    stroke-width: 5;
    stroke-linecap: round;
    transition: stroke-width 0.3s ease;
}
.ring-icon i {
    position: relative;
    z-index: 1;
    font-size: 1.25rem;
    color: #fff;
    transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

.stat-card-ring:hover .ring-svg      { transform: rotate(270deg); }
.stat-card-ring:hover .ring-bg       { opacity: 0.6; }
.stat-card-ring:hover .ring-progress { stroke-width: 6; }
.stat-card-ring:hover .ring-icon i   { transform: scale(1.2) rotate(8deg); }

.ring-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
}
.ring-info p {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.8);
    margin: 0;
}


/* ============ การ์ดสถิติรายละเอียด (รายจังหวัด) ============ */
.detail-stat-card {
    flex: 1;
    position: relative;
    background: linear-gradient(135deg, var(--ds-from), var(--ds-to));
    border-radius: 12px;
    padding: 14px 8px 12px;
    text-align: center;
    color: #fff;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.detail-stat-card::before {
    top: -18px; right: -18px;
    width: 56px; height: 56px;
}
.detail-stat-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.detail-stat-icon {
    width: 34px; height: 34px;
    margin: 0 auto 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.22);
    font-size: 0.85rem;
    backdrop-filter: blur(4px);
}
.detail-stat-val {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.detail-stat-label {
    font-size: 0.72rem;
    opacity: 0.85;
    margin-top: 2px;
    font-weight: 500;
}

/* ============ 12. การ์ดสถานะ (ที่อยู่อาศัย) ============ */

.residence-section .section-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    font-size: 14px;
    flex-shrink: 0;
}

.status-card {
    border-radius: 16px;
    padding: 20px 14px 16px;
    text-align: center;
    color: #1e293b;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-top: 4px solid var(--status-color, #64748b);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.status-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 100%;
    background: linear-gradient(180deg, var(--status-bg, rgba(0,0,0,0.02)) 0%, transparent 50%);
    pointer-events: none;
}
.status-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}
.status-card .status-icon {
    width: 50px; height: 50px;
    border-radius: 14px;
    background: var(--status-bg, #f1f5f9);
    margin: 0 auto 10px;
    font-size: 20px;
    color: var(--status-color, #64748b);
    position: relative;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.status-card:hover .status-icon {
    transform: scale(1.1) rotate(5deg);
}
.status-card .status-label {
    font-size: 12.5px;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 6px;
    line-height: 1.3;
    min-height: 32px;
    position: relative;
}
.status-card .status-value {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--status-color, #1e293b);
    position: relative;
}

.status-card.bg-success,
.status-card.bg-warning,
.status-card.bg-purple,
.status-card.bg-primary,
.status-card.bg-brown,
.status-card.bg-danger,
.status-card.bg-dark {
    background: #fff !important;
}
.status-card.bg-success { --status-color: #059669; --status-bg: rgba(5,150,105,0.1); }
.status-card.bg-warning { --status-color: #d97706; --status-bg: rgba(217,119,6,0.1); }
.status-card.bg-purple  { --status-color: #7c3aed; --status-bg: rgba(124,58,237,0.12); }
.status-card.bg-primary { --status-color: #2563eb; --status-bg: rgba(37,99,235,0.1); }
.status-card.bg-brown   { --status-color: #b45309; --status-bg: rgba(180,83,9,0.1); }
.status-card.bg-danger  { --status-color: #dc2626; --status-bg: rgba(220,38,38,0.1); }
.status-card.bg-dark    { --status-color: #475569; --status-bg: rgba(71,85,105,0.1); }


/* ============ 12.1 ป้ายเพศในกราฟพีระมิดอายุ ============ */

.age-gender-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px 4px;
}
.age-gender-male,
.age-gender-female {
    display: flex;
    align-items: center;
    gap: 10px;
}
/* รวมขนาดไอคอนชาย/หญิงให้ใช้ค่าร่วมกัน */
.age-gender-male > i,
.age-gender-female > i {
    font-size: 2.5rem;
}
.age-gender-male > i {
    color: #2563eb;
}
.age-gender-female > i {
    color: #ec4899;
}
.age-gender-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}
.age-gender-male .age-gender-title {
    color: #2563eb;
}
.age-gender-female .age-gender-title {
    color: #ec4899;
}
.age-gender-count {
    font-size: 0.85rem;
    color: #64748b;
}
.age-gender-count strong {
    font-weight: 700;
}

@media (max-width: 575px) {
    .age-gender-labels { padding: 8px 12px 2px; }
    .age-gender-male > i,
    .age-gender-female > i { font-size: 1.8rem; }
    .age-gender-title { font-size: 0.85rem; }
    .age-gender-count { font-size: 0.75rem; }
}


/* ============ 13. แผนที่ดีสาม ============ */

#mapContainer {
    position: relative;
    overflow: hidden;
    border-radius: 0 0 14px 14px;
}
#mapContainer svg {
    display: block;
    border-radius: 0 0 14px 14px;
}
#mapContainer .map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
    font-size: 0.95rem;
}
.chart-loading.chart-loading--map {
    z-index: 35;
    background: rgba(255,255,255,0.62);
}
.chart-loading.chart-loading--map .chart-loading-map-content {
    text-align: center;
    color: #334155;
    font-family: 'Kanit', sans-serif;
}
.chart-loading.chart-loading--map .chart-loading-map-shadow {
    font-size: 72px;
    line-height: 1;
    color: rgba(30, 58, 95, 0.16);
    filter: drop-shadow(0 4px 10px rgba(30, 58, 95, 0.12));
    margin-bottom: 12px;
}
.chart-loading.chart-loading--map .spinner {
    width: 42px;
    height: 42px;
    margin: 0 auto 10px;
    border: 3px solid rgba(203, 218, 246, 0.28);
    border-top-color: #9bc3ff;
    animation: spin .85s linear infinite;
}
.chart-loading.chart-loading--map .spinner-text {
    margin-top: 0;
    font-size: .88rem;
    letter-spacing: .15px;
    color: #475569;
    text-shadow: none;
}

.map-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.95);
    color: #f1f5f9;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-family: 'Kanit', sans-serif;
    line-height: 1.5;
    z-index: 200;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    white-space: normal;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    max-width: 280px;
    min-width: 160px;
    backdrop-filter: blur(6px);
    transition: opacity 0.15s ease;
}

.map-btn-group {
    position: absolute;
    top: 40px; left: 12px;
    z-index: 50;
    display: flex;
    gap: 6px;
}
.map-btn-group .btn {
    font-size: 0.78rem;
    border-radius: 8px;
    padding: 8px 14px;
    font-family: 'Kanit', sans-serif;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.map-btn-group .btn-warning       { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.map-btn-group .btn-warning:hover { background: #d97706; border-color: #d97706; color: #fff; }

.map-back-btn {
    position: absolute;
    top: 40px; left: 12px;
    z-index: 50;
    font-size: 0.75rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    backdrop-filter: blur(4px);
}

.map-zoom-controls {
    position: absolute;
    top: 12px; right: 12px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.map-zoom-btn {
    width: 32px; height: 32px;
    border: none;
    border-radius: 6px;
    background: rgba(255,255,255,0.92);
    color: #1e3a5f;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.15s ease;
}
.map-zoom-btn:hover {
    background: #1e3a5f;
    color: #fff;
}

.map-active-info-card {
    position: absolute;
    top: 12px;
    right: 56px;
    left: auto;
    z-index: 150;
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
    min-width: 186px;
    max-width: 268px;
    padding: 5px 10px;
    font-size: 0.76rem;
    line-height: 1.24;
    background: linear-gradient(145deg, rgba(11, 31, 84, 0.86) 0%, rgba(20, 54, 132, 0.78) 55%, rgba(33, 84, 182, 0.66) 100%);
    border: 1px solid rgba(191, 219, 254, 0.26);
    box-shadow: 0 8px 20px rgba(9, 22, 58, 0.34), inset 0 1px 0 rgba(255,255,255,0.16);
    backdrop-filter: blur(12px) saturate(1.18);
    -webkit-backdrop-filter: blur(12px) saturate(1.18);
}
.map-active-info-card i {
    font-size: 0.78rem;
    margin-right: 6px !important;
}
.map-active-info-card > div {
    min-width: 0 !important;
}
.map-active-info-card > div > div:first-child {
    margin-bottom: 2px !important;
    gap: 4px !important;
}
.map-active-info-card > div > div:first-child span {
    font-size: 13px !important;
    line-height: 1.2 !important;
    max-width: 204px;
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}
.map-active-info-card > div > div[style*="grid-template-columns"] {
    font-size: 11.5px !important;
    gap: 1px 8px !important;
}
.map-active-info-card > div > div[style*="grid-template-columns"] > span {
    line-height: 1.2 !important;
}
.map-active-info-card > div > div[style*="grid-template-columns"] > span:nth-child(even) {
    font-size: 12.5px !important;
}
.map-active-info-card .province-tip-avg-value {
    font-size: 15px !important;
}
.map-active-info-card.is-hidden {
    opacity: 0;
    transform: translateY(-4px);
}

.map-ctx-menu {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 6px 0;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    font-family: 'Kanit', sans-serif;
}
.map-ctx-item {
    padding: 8px 16px;
    font-size: 0.82rem;
    color: #e2e8f0;
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
}
.map-ctx-item:hover {
    background: rgba(59, 130, 246, 0.25);
    color: #fff;
}
.map-ctx-item i {
    width: 18px;
    text-align: center;
    margin-right: 8px;
    color: #60a5fa;
}

.map-score-badge {
    position: absolute;
    right: 16px;
    bottom: 16px;
    background: linear-gradient(145deg, rgba(11, 31, 84, 0.86) 0%, rgba(20, 54, 132, 0.78) 55%, rgba(33, 84, 182, 0.66) 100%);
    backdrop-filter: blur(12px) saturate(1.18);
    -webkit-backdrop-filter: blur(12px) saturate(1.18);
    border-radius: 14px;
    padding: 12px 18px 10px;
    text-align: center;
    box-shadow: 0 8px 20px rgba(9, 22, 58, 0.34), inset 0 1px 0 rgba(255,255,255,0.16);
    z-index: 10;
    pointer-events: none;
    border: 1px solid rgba(191, 219, 254, 0.26);
    overflow: hidden;
}
.map-score-badge::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle at 30% 20%, rgba(96,165,250,0.12) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(59,130,246,0.10) 0%, transparent 40%);
    pointer-events: none;
}
.map-score-badge small {
    position: relative;
    display: block;
    font-size: 0.64rem;
    color: rgba(203,213,225,0.9);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.map-score-badge .score-value {
    position: relative;
    font-size: 1.62rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.1;
    background: linear-gradient(180deg, #fff 30%, #93c5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.map-score-badge .score-level {
    position: relative;
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.66rem;
    font-weight: 600;
    margin-top: 4px;
}


/* ============ 14. คำอธิบายกราฟ ============ */

.chart-legend {
    padding: 10px 6px 0;
}
.chart-legend .legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.8rem;
    color: #475569;
}
.chart-legend .legend-dot {
    width: 10px; height: 10px;
    border-radius: 3px;
    display: inline-block;
    margin-right: 8px;
    flex-shrink: 0;
}
.chart-legend .legend-label { flex: 1; }
.chart-legend .legend-value { font-weight: 600; color: #1e293b; }


/* ============ 15. กริดมิติและตาราง ============ */

.dimension-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
}
.dimension-item {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-radius: 10px;
    padding: 12px 10px;
    text-align: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.dimension-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.dimension-item .dim-label {
    font-size: 0.7rem;
    color: #64748b;
    display: block;
    margin-bottom: 2px;
}
.dimension-item .dim-value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.2;
}
.dimension-item.dimension-avg {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-width: 3px;
}
.dimension-item .dim-level {
    font-size: 0.65rem;
    padding: 2px 10px;
    border-radius: 20px;
    display: inline-block;
    font-weight: 500;
    margin-top: 2px;
}

.level-danger  { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #991b1b; }
.level-warning { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.level-info    { background: linear-gradient(135deg, #cffafe, #a5f3fc); color: #155e75; }
.level-success { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46; }

#dimensionSummaryTable .table,
#dimStatsTable .table {
    font-family: 'Kanit', sans-serif;
    border-collapse: separate;
    border-spacing: 0;
}
#dimensionSummaryTable .table th,
#dimStatsTable .table th {
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}
#dimensionSummaryTable .table td,
#dimStatsTable .table td {
    vertical-align: middle;
    padding: 10px 12px;
}


/* ============ 16. ตัวเล่นไทม์ไลน์กราฟวงกลม ============ */

.pie-timeline {
    padding: 0 12px 4px;
    margin-top: -20px;
    position: relative;
    z-index: 5;
}
.pie-timeline .btn-sm {
    width: 30px; height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 12px;
}

/* ============ SVG วงกลมครัวเรือน/ความยากจน ============ */
.poverty-circle-wrap {
    position: relative;
    width: 100%;
    min-height: 0;
    border-radius: 0;
    background: transparent;
    border: 0;
    overflow: hidden;
}
.poverty-dim-svg {
    display: block;
    width: 100%;
    height: clamp(430px, 40vw, 560px);
    font-family: 'Kanit', sans-serif;
}
.poverty-circle-svg {
    display: block;
    width: 100%;
    height: clamp(430px, 40vw, 560px);
    font-family: 'Kanit', sans-serif;
}
.poverty-circle-svg .pulse-circle,
.poverty-dim-svg .pulse-circle {
    transform-box: fill-box;
    transform-origin: center;
    animation: bubblePulseLoop 4.6s ease-in-out infinite;
}
.poverty-circle-svg .pulse-circle--poverty,
.poverty-dim-svg .pulse-circle--livelihood {
    will-change: opacity, filter, transform;
}
@keyframes bubblePulseLoop {
    0% {
        opacity: 0.38;
        filter: brightness(0.76) saturate(0.92);
        transform: scale(0.95);
    }
    50% {
        opacity: 0.98;
        filter: brightness(1.34) saturate(1.14);
        transform: scale(1.06);
    }
    100% {
        opacity: 0.38;
        filter: brightness(0.76) saturate(0.92);
        transform: scale(0.95);
    }
}
.poverty-circle-caption {
    font-size: 0.8rem;
    color: #64748b;
    text-align: center;
    padding: 8px 10px 12px;
}
@media (max-width: 768px) {
    .poverty-circle-wrap {
        min-height: 0;
    }
    .poverty-dim-svg {
        height: 480px;
    }
    .poverty-circle-svg {
        height: 480px;
    }
}

.timeline-dots {
    position: relative;
    height: 40px;
    margin: 0 auto;
    max-width: 90%;
}
.tl-track {
    position: relative;
    height: 100%;
}
.tl-track::before {
    display: none;
}

.tl-point {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    cursor: pointer;
    text-align: center;
    z-index: 2;
}
.tl-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    margin: 6px auto 4px;
    transition: all 0.3s ease;
}
.tl-label {
    font-size: 9px;
    color: #94a3b8;
    white-space: nowrap;
    transition: all 0.3s ease;
    font-family: 'Kanit', sans-serif;
    display: none;
    pointer-events: none;
}
.tl-point:hover .tl-label {
    display: block;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.9);
    color: #fff;
    font-weight: 500;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 6px;
    margin-bottom: 4px;
    z-index: 10;
}
.tl-point.active .tl-dot {
    width: 12px; height: 12px;
    margin-top: 4px;
    background: #2196f3;
    box-shadow: 0 0 0 3px rgba(33,150,243,0.2);
}
.tl-point.active .tl-label {
    display: block;
    color: #2196f3;
    font-weight: 600;
    font-size: 11px;
}

/* ============ 17. ตารางเปรียบเทียบรายจังหวัด ============ */

.province-compare-row:hover {
    background-color: rgba(59, 130, 246, 0.08);
    transition: background-color 0.15s ease;
}
.province-compare-row:hover td {
    color: #1e40af;
}


/* ============ 18. ปุ่มส่งออกไฟล์ตาราง ============ */

.export-xls-btn {
    font-family: 'Kanit', sans-serif;
    font-size: 0.75rem;
    border-radius: 8px;
    padding: 4px 12px;
}
.export-xls-btn:hover {
    background: #059669;
    color: #fff;
    border-color: #059669;
}


/* ============ 19. ปุ่มลอยการทำงาน ============ */

.fab-container {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.fab-btn {
    width: 44px; height: 44px;
    border: none;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    transition: all 0.25s ease;
    opacity: 0.35;
}
.fab-btn:hover {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.fab-top {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}
.fab-top.show {
    opacity: 0.35;
    pointer-events: auto;
    transform: translateY(0);
}
.fab-top.show:hover { opacity: 1; }
.fab-top:hover      { background: linear-gradient(135deg, #3b82f6, #2563eb); }


/* ============ 20. โหลดข้อมูล / โครงร่าง / ตัวเลขนับ ============ */

.app-boot-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(1100px 560px at 50% 18%, rgba(37, 99, 235, 0.18), rgba(9, 16, 32, 0.46) 52%, rgba(2, 6, 23, 0.58) 100%);
    opacity: 1;
    visibility: visible;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: opacity .36s ease, visibility .36s ease;
}
.app-boot-overlay.is-hiding {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.app-boot-overlay__panel {
    width: clamp(290px, 56vw, 430px);
    height: clamp(290px, 56vw, 430px);
    border-radius: 50%;
    padding: 36px 30px 30px;
    border: 1px solid rgba(96, 165, 250, 0.4);
    background: radial-gradient(140% 130% at 18% 12%, rgba(59, 130, 246, 0.36), rgba(59, 130, 246, 0) 34%),
                radial-gradient(120% 120% at 86% 90%, rgba(14, 165, 233, 0.18), rgba(14, 165, 233, 0) 44%),
                conic-gradient(from 220deg at 50% 50%, rgba(30, 64, 175, 0.18), rgba(14, 165, 233, 0.08), rgba(2, 132, 199, 0.2), rgba(30, 64, 175, 0.14), rgba(30, 64, 175, 0.18)),
                linear-gradient(152deg, rgba(3, 12, 30, 0.92), rgba(6, 22, 52, 0.88) 56%, rgba(2, 10, 26, 0.9) 100%);
    box-shadow: 0 30px 70px rgba(2, 6, 23, 0.58), inset 0 1px 0 rgba(191, 219, 254, 0.24), inset 0 -34px 46px rgba(2, 6, 23, 0.36), inset 0 0 42px rgba(14, 165, 233, 0.08);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.app-boot-overlay__panel::before {
    content: "";
    position: absolute;
    inset: 7.5%;
    border-radius: 50%;
    border: 1px solid rgba(147, 197, 253, 0.3);
    pointer-events: none;
}
.app-boot-overlay__panel::after {
    content: "";
    position: absolute;
    width: 86%;
    height: 52%;
    border-radius: 50%;
    top: -14%;
    left: 7%;
    background: radial-gradient(70% 90% at 50% 85%, rgba(191, 219, 254, 0.3), rgba(191, 219, 254, 0.06) 52%, rgba(191, 219, 254, 0));
    filter: blur(10px);
    pointer-events: none;
    animation: none;
}
.app-boot-overlay__orb {
    width: clamp(200px, 50%, 220px);
    margin: 0 auto 30px;
    border-radius: 0;
    display: block;
    color: inherit;
    border: 0;
    background: transparent;
    box-shadow: none;
    animation: appBootPulse 1.1s ease-in-out infinite;
    transform: translateY(-12px);
}
.app-boot-overlay__logo {
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(15, 23, 42, .28));
}
.app-boot-overlay__title {
    font-family: 'Kanit', sans-serif;
    font-size: clamp(1.05rem, 2.8vw, 1.3rem);
    font-weight: 700;
    color: #f0f7ff;
    text-shadow: 0 2px 14px rgba(56, 189, 248, .2);
    margin-bottom: 4px;
}
.app-boot-overlay__title-break { display: inline; }
.app-boot-overlay__subtitle {
    font-family: 'Kanit', sans-serif;
    font-size: clamp(.82rem, 2.2vw, .93rem);
    line-height: 1.5;
    color: rgba(219, 234, 254, .92);
    margin-bottom: 16px;
    max-width: 74%;
}
.app-boot-overlay__bar {
    width: 64%;
    height: 9px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(148, 163, 184, .34);
}
.app-boot-overlay__bar > span {
    display: block;
    width: 44%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(59, 130, 246, .98), rgba(14, 165, 233, .95), rgba(59, 130, 246, .98));
    animation: appBootBar 1.35s ease-in-out infinite;
}
.app-boot-overlay__percent {
    margin-top: 8px;
    font-family: 'Kanit', sans-serif;
    font-size: clamp(.82rem, 2.1vw, .95rem);
    font-weight: 700;
    letter-spacing: .02em;
    color: rgba(191, 219, 254, .96);
    text-shadow: 0 1px 8px rgba(30, 64, 175, .35);
}
@keyframes appBootPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}
@keyframes appBootBar {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(270%); }
}
@keyframes appBootHalo {
    0% { transform: rotate(0deg); opacity: .65; }
    50% { opacity: .95; }
    100% { transform: rotate(360deg); opacity: .65; }
}
@media (max-width: 576px) {
    .app-boot-overlay__panel {
        width: clamp(260px, 82vw, 340px);
        height: clamp(260px, 82vw, 340px);
        padding: 22px 16px 18px;
    }
    .app-boot-overlay__title { font-size: clamp(.96rem, 4.4vw, 1.12rem); line-height: 1.35; max-width: 78%; }
    .app-boot-overlay__title-break { display: none; }
    .app-boot-overlay__subtitle { font-size: clamp(.76rem, 3.3vw, .9rem); line-height: 1.35; max-width: 78%; margin-bottom: 12px; }
    .app-boot-overlay__orb { width: clamp(126px, 44%, 168px); margin-bottom: 20px; transform: translateY(-8px); }
    .app-boot-overlay__bar { width: 70%; }
}

.chart-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.85);
    z-index: 10;
    border-radius: 0 0 14px 14px;
    transition: opacity 0.3s ease;
}
.chart-loading.hide {
    opacity: 0;
    pointer-events: none;
}
.chart-loading .spinner {
    width: 36px; height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.chart-loading .spinner-text {
    margin-top: 8px;
    font-size: 0.75rem;
    color: #64748b;
    font-family: 'Kanit', sans-serif;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.stat-skeleton {
    display: inline-block;
    width: 80px; height: 28px;
    background: linear-gradient(90deg, rgba(255,255,255,0.15) 25%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0.15) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.odometer-num {
    display: inline-flex;
    overflow: hidden;
    line-height: 1;
}
.odometer-num .odo-digit {
    display: inline-block;
    position: relative;
    overflow: hidden;
}
.odometer-num .odo-digit .odo-ribbon {
    display: flex;
    flex-direction: column;
    transition: transform 0.8s cubic-bezier(0.19, 1, 0.22, 1);
}
.odometer-num .odo-digit .odo-ribbon span {
    display: block;
    text-align: center;
}
.odometer-num .odo-comma {
    display: inline-block;
}


/* ============ 21. การแสดงผลตามขนาดหน้าจอ ============ */

/* แท็บเล็ต (ไม่เกิน 1024 พิกเซล) */
@media (max-width: 1023.98px) {
    .dashboard-header h4         { font-size: 1.1rem; }
    .stat-highlight .stat-number { font-size: 1.6rem; }
    #mapContainer                { height: 420px !important; }
    #chartPolarDimension,
    #chartDimStats               { height: 380px !important; }
}

/* มือถือ (ไม่เกิน 768 พิกเซล) */
@media (max-width: 768px) {
    .dashboard-header       { padding: 14px 0; }
    .dashboard-header h4    { font-size: 1rem; }
    .dashboard-header small { font-size: 0.72rem; }

    .stat-highlight              { align-items: center; margin-top: 8px; }
    .stat-highlight .stat-number { font-size: 1.5rem; }
    .stat-highlight .stat-label  { font-size: 0.75rem; }
    .year-select                 { font-size: 0.8rem; margin-top: 8px; }

    .small-box h3        { font-size: 1.3rem; }
    .small-box p         { font-size: 0.75rem; }
    .small-box .icon > i { font-size: 40px; }

    .card-title  { font-size: 0.78rem; }
    .card-header { padding: 0.5rem 0.75rem; }

    .stat-card-ring { padding: 12px 10px; }
    .ring-icon      { width: 48px; height: 48px; min-width: 48px; margin-right: 10px; }
    .ring-icon i    { font-size: 1rem; }
    .ring-info h3   { font-size: 1.15rem; }
    .ring-info p    { font-size: 0.7rem; }

    .detail-stat-card { padding: 10px 6px 8px; border-radius: 10px; }
    .detail-stat-icon { width: 28px; height: 28px; font-size: 0.7rem; }
    .detail-stat-val  { font-size: 1.05rem; }
    .detail-stat-label { font-size: 0.65rem; }

    .status-card              { padding: 14px 8px 12px; border-radius: 12px; }
    .status-card .status-icon { width: 40px; height: 40px; font-size: 16px; border-radius: 10px; margin-bottom: 8px; }
    .status-card .status-label { font-size: 11px; min-height: 26px; }
    .status-card .status-value { font-size: 1.25rem; }

    #mapContainer        { height: 520px !important; }
    .map-score-badge     { display: none; }
    .map-active-info-card { display: none !important; }

    #chartRadar          { height: 380px !important; }
    #chartPolarDimension { height: 340px !important; }
    #chartDimStats       { height: 300px !important; }

    #chartDistrictHousehold,
    #chartDistrictMember   { height: 520px !important; }
    #chartAge              { height: 480px !important; }
    #chartYearlyStats      { height: 380px !important; }
    #chartDistrictOverview { height: 420px !important; }

    .dimension-grid            { grid-template-columns: 1fr; gap: 6px; padding: 6px; }
    .dimension-item            { padding: 8px; }
    .dimension-item .dim-value { font-size: 1.1rem; }
    .dimension-item .dim-label { font-size: 0.65rem; }

    .row-stretch { flex-direction: column; }

    #dimensionSummaryTable .table,
    #dimStatsTable .table    { font-size: 11px; }
    #dimensionSummaryTable .table td,
    #dimStatsTable .table td { padding: 6px 8px; }
    #dimensionSummaryTable .table th,
    #dimStatsTable .table th { font-size: 10px; padding: 6px 8px; }

    .content.pt-3    { padding-top: 0.75rem !important; }
    .container-fluid { padding-left: 10px; padding-right: 10px; }
    .main-footer     { font-size: 0.72rem; padding: 8px; }

    .fab-container { display: none; }
}

/* มือถือขนาดเล็ก (ไม่เกิน 480 พิกเซล) */
@media (max-width: 480px) {
    .main-header {
        padding-right: 166px;
    }
    .main-header .nav-quick-toggle {
        right: 172px;
        padding-left: 9px;
        padding-right: 9px;
    }
    .main-header .nav-quick-toggle .nav-quick-label {
        font-size: 0.72rem;
    }
    .main-header .auth-user-chip {
        max-width: 80px;
    }
    .main-header #authUserMenuText {
        max-width: 30px;
    }
    .dashboard-header h4         { font-size: 0.9rem; }
    .stat-highlight .stat-number { font-size: 1.25rem; }

    .small-box h3        { font-size: 1.1rem; }
    .small-box .inner    { padding: 8px 10px; }
    .small-box .icon > i { font-size: 30px; }

    #mapContainer        { height: 480px !important; }
    #chartRadar          { height: 340px !important; }
    #chartPolarDimension { height: 300px !important; }
    #chartDimStats       { height: 260px !important; }

    #chartDistrictHousehold,
    #chartDistrictMember { height: 500px !important; }
    #chartAge            { height: 460px !important; }

    .card        { border-radius: 10px; }
    .card-header { border-radius: 10px 10px 0 0 !important; }
    .card-outline.card-primary .card-header { border-top-width: 2px; }
    .card-title  { font-size: 0.72rem; }

    .dimension-grid            { padding: 4px; gap: 4px; }
    .dimension-item .dim-value { font-size: 1rem; }

    .chart-legend              { padding: 6px 4px 0; }
    .chart-legend .legend-item { font-size: 0.7rem; }

    #dimStatsTable h5 { font-size: 0.85rem !important; }
}


/* ============ 22. การ์ดข้อมูลสถิติ ============ */

.info-stat-card {
    border-left: 4px solid var(--isc-color, #333);
    background: var(--isc-bg, rgba(0,0,0,0.04));
    border-radius: 8px;
    padding: 10px 14px;
}
.info-stat-card .isc-label {
    font-weight: 600;
    color: var(--isc-color, #333);
    font-size: 0.8rem;
    margin-bottom: 4px;
}
.info-stat-card .isc-value {
    font-size: 1.25rem;
}
.info-stat-card .isc-value,
.info-stat-card .isc-sub {
    font-weight: 800;
    color: #1e293b;
}
.info-stat-card .isc-unit,
.info-stat-card .isc-sub-unit {
    font-weight: 500;
    font-size: 0.78rem;
}
.info-stat-card .isc-sub {
    font-size: 1.1rem;
    margin-top: 3px;
}
.info-stat-card .isc-unit {
    color: #64748b;
}
.info-stat-card .isc-sub-icon {
    font-size: 0.75rem;
    margin-right: 4px;
    color: var(--isc-color, #333);
}
.info-stat-card .isc-sub-unit {
    color: var(--isc-color, #333);
}

.info-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ============ 23. ปุ่มแท็บกลุ่มยากจนต่อเนื่อง ============ */
.cp-mode-btn {
    background: #fff;
    color: #0055BF;
    border: 1.5px solid #0055BF;
    font-weight: 500;
    transition: all .2s ease;
}
.cp-mode-btn:hover {
    background: rgba(0,85,191,0.08);
    color: #0055BF;
}
.cp-mode-btn.active {
    background: #0055BF;
    color: #fff;
    border-color: #0055BF;
    font-weight: 600;
}

.footer-modern {
    background: linear-gradient(180deg, #eff3fb 0%, #e2e8f5 100%) !important;
    border-top: 1px solid #c7d2e8 !important;
    padding: var(--footer-modern-padding) !important;
}
.footer-brand-wrap {
    width: 100%;
    max-width: min(1440px, calc(100vw - 32px));
    margin: 0 auto;
}
.footer-brand-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--footer-logos-gap);
}
.footer-brand-logo {
    height: 80px;
    width: auto;
    border-radius: 10px;
    max-width: var(--footer-logo-max);
    object-fit: contain;
    filter: drop-shadow(0 8px 18px rgba(30, 41, 59, 0.16));
}
.footer-brand-title {
    margin-top: var(--footer-title-mt);
    font-size: var(--footer-title-size);
    font-weight: 700;
    color: #0f2f6d;
    letter-spacing: 0.1px;
    line-height: 1.38;
}
.footer-system-stats {
    margin-top: var(--footer-stats-mt);
    display: grid;
    grid-template-columns: var(--footer-stats-cols);
    gap: var(--footer-stats-gap);
}
.footer-system-stat-item {
    padding: var(--footer-stat-padding);
    border-radius: 10px;
    border: none;
    background: linear-gradient(180deg, #fafdff 0%, #edf4ff 100%);
    box-shadow:
        0 14px 28px rgba(15, 23, 42, 0.14),
        0 2px 6px rgba(37, 99, 235, 0.08);
    text-align: left;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.footer-system-stat-item:hover {
    border-color: transparent;
    box-shadow:
        0 18px 32px rgba(15, 23, 42, 0.18),
        0 4px 10px rgba(37, 99, 235, 0.1);
    transform: translateY(-2px);
}
.footer-system-stat-label,
.footer-system-stat-value {
    display: block;
}
.footer-system-stat-label {
    color: #334155;
    font-size: var(--footer-stat-label-size);
    margin-bottom: 6px;
    letter-spacing: 0.2px;
    text-transform: uppercase;
}
.footer-system-stat-value {
    color: #0f2f6d;
    font-size: var(--footer-stat-value-size);
    line-height: 1.45;
}
.footer-meta {
    margin-top: 12px;
    font-size: var(--footer-meta-size);
    color: #334155;
}

@media (max-width: 767.98px) {
    :root {
        --footer-logo-max: min(72vw, 220px);
        --footer-modern-padding: 14px 10px 12px;
        --footer-wrap-padding: 14px 12px 12px;
        --footer-wrap-radius: 14px;
        --footer-logos-gap: 14px;
        --footer-title-mt: 10px;
        --footer-title-size: 0.98rem;
        --footer-stats-cols: 1fr;
        --footer-stats-gap: 9px;
        --footer-stats-mt: 10px;
        --footer-stat-padding: 10px 11px;
        --footer-stat-label-size: 0.7rem;
        --footer-stat-value-size: 0.88rem;
        --footer-meta-size: 0.8rem;
    }
}

/* ============ บล็อกกลางจอ (แก้ทับซ้อนรอบสุดท้าย) ============ */
@media (min-width: 1024px) and (max-width: 1365.98px) {
    .sidebar-mini {
        --sidebar-collapsed-width: var(--sidebar-collapsed, calc(5.8rem + 40px));
        --sidebar-expanded-width: 250px;
        --top-compact-actions-right: 8px;
        --top-compact-actions-top: 8px;
        --top-compact-toggle-right: 260px;
        --top-compact-layer-actions: 1062;
        --top-compact-layer-panel: 1061;
        --top-compact-panel-offset-top: 6px;
        --top-compact-panel-padding: 10px;
        --top-compact-panel-radius: 14px;
    }
    .sidebar-mini.sidebar-collapse .ppaos-menu-brand .brand-logo-svg {
        display: none;
    }
    .sidebar-mini.sidebar-collapse .ppaos-menu-brand .brand-logo-mini {
        display: block;
        width: 126px;
        height: auto;
        max-width: 126px;
    }
    .main-header {
        padding-right: 272px;
    }
    .navbar-expand-custom .navbar-toggler,
    .main-header .nav-quick-toggle {
        display: inline-flex !important;
    }
    .main-header .nav-quick-toggle {
        position: absolute;
        right: var(--top-compact-toggle-right);
        top: 50%;
        transform: translateY(-50%);
        margin: 0;
        z-index: var(--top-compact-layer-actions);
        height: 40px;
        min-height: 40px;
    }
    .main-header .navbar-actions {
        position: absolute;
        right: var(--top-compact-actions-right);
        top: var(--top-compact-actions-top);
        margin-left: 0;
        gap: 6px;
        z-index: var(--top-compact-layer-actions);
    }

    /* ให้ปุ่มเมนูเปิดเป็นแผงเดียว ไม่ยืดเต็มหน้าจอ */
    .navbar-expand-custom .navbar-collapse {
        display: none !important;
        position: absolute;
        left: auto !important;
        right: var(--top-compact-actions-right) !important;
        top: calc(var(--top-nav-h) + var(--top-compact-panel-offset-top));
        width: min(520px, calc(100vw - var(--sidebar-collapsed-width) - 16px));
        max-height: calc(100vh - var(--top-nav-h) - 20px);
        overflow-y: auto;
        border-radius: var(--top-compact-panel-radius);
        background: var(--top-mobile-panel-bg);
        border: var(--top-mobile-panel-border);
        box-shadow: var(--top-mobile-panel-shadow);
        padding: var(--top-compact-panel-padding);
        margin: 0;
        z-index: var(--top-compact-layer-panel);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
    .navbar-expand-custom .navbar-collapse.show,
    .navbar-expand-custom .navbar-collapse.collapsing {
        display: block !important;
    }
    .main-header .navbar-collapse > .navbar-nav,
    .main-header .navbar-collapse .navbar-nav {
        display: flex;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 4px;
        padding: 4px 0;
        height: auto;
        min-width: 0;
    }
    .main-header .navbar-collapse .navbar-nav > .nav-item {
        width: 100%;
        margin-right: 0;
    }
    .main-header .navbar-collapse > .navbar-nav > .nav-item > .nav-link {
        width: 100%;
        min-height: 42px;
        display: flex;
        justify-content: flex-start;
        text-align: left;
        gap: 8px;
        padding: 10px 12px !important;
    }
    .main-header .navbar-collapse .dropdown-menu {
        position: static !important;
        float: none;
        display: flex;
        flex-direction: column;
        width: 100%;
        min-width: 100%;
        max-width: none;
        border: none;
        box-shadow: none;
        padding: 0;
        margin-top: 0;
        background: transparent;
        max-height: 0;
        opacity: 0;
        transform: translateY(-4px);
        overflow: hidden;
        pointer-events: none;
        transition: max-height .28s ease, opacity .22s ease, transform .22s ease, margin-top .22s ease;
    }
    .main-header .navbar-collapse .dropdown-menu.show {
        max-height: 420px;
        opacity: 1;
        transform: translateY(0);
        margin-top: 4px;
        pointer-events: auto;
    }
    .main-header .navbar-collapse .dropdown-menu .dropdown-item {
        width: 100%;
        display: flex;
        align-items: center;
        margin-bottom: 14px;
    }
    .main-header .navbar-collapse .dropdown-menu .dropdown-item:last-child {
        margin-bottom: 0;
    }

    /* เมนูธีมและเมนูผู้ใช้ยึดกับปุ่ม ไม่ลอยผิดตำแหน่ง */
    #themePresetMenu,
    #authUserMenu {
        position: relative;
    }
    #themePresetMenu .dropdown-menu,
    #authUserMenu .dropdown-menu {
        position: absolute !important;
        left: auto !important;
        right: 0 !important;
        top: calc(100% + var(--top-compact-panel-offset-top)) !important;
        transform: none !important;
        margin: 0 !important;
    }
    #themePresetMenu .dropdown-menu {
        width: 240px;
        min-width: 220px;
        border-radius: 12px;
        border: var(--top-mobile-panel-border);
        background: var(--top-mobile-panel-bg);
        box-shadow: var(--top-mobile-panel-shadow);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        z-index: 1064;
    }
    #authUserMenu .dropdown-menu {
        width: min(360px, calc(100vw - 16px)) !important;
        min-width: 300px !important;
    }

    /* ย่อเมนูซ้ายให้รูปแบบเหมือนช่วงจอใหญ่ */
    .sidebar-mini.sidebar-collapse .main-sidebar,
    .sidebar-mini.sidebar-collapse .main-sidebar::before,
    .sidebar-mini.sidebar-collapse .brand-link,
    .sidebar-mini.sidebar-collapse.layout-fixed .brand-link {
        width: var(--sidebar-collapsed-width) !important;
        min-width: var(--sidebar-collapsed-width) !important;
        max-width: var(--sidebar-collapsed-width) !important;
    }
    .sidebar-mini.sidebar-collapse .content-wrapper,
    .sidebar-mini.sidebar-collapse .main-footer,
    .sidebar-mini.sidebar-collapse .main-header {
        margin-left: var(--sidebar-collapsed-width) !important;
        width: calc(100% - var(--sidebar-collapsed-width)) !important;
        max-width: calc(100% - var(--sidebar-collapsed-width)) !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar {
        padding: 0 !important;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-item {
        width: 100% !important;
        margin: 0;
        padding: 0 !important;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link {
        width: 100% !important;
        border-radius: 10px !important;
        padding: 10px 6px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        gap: 2px;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link .nav-icon {
        margin-right: 0 !important;
        font-size: 1.04rem;
        margin-bottom: 2px;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link .nav-icon.num-icon-top {
        width: 18px !important;
        height: 18px !important;
        min-width: 18px !important;
        line-height: 18px !important;
        font-size: 0.65rem !important;
        margin-bottom: 4px;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link p {
        display: -webkit-box !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: calc(var(--sidebar-collapsed-width) - 10px);
        line-height: 1.2;
        font-size: 0.76rem;
        visibility: visible;
        animation-name: none;
        animation-fill-mode: none;
        white-space: normal;
        opacity: 0.85;
        min-height: 2.44em;
        line-clamp: 2;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link:hover p {
        opacity: 1;
    }
    .sidebar-mini.sidebar-collapse .main-sidebar:hover .nav-sidebar .nav-link p {
        display: block !important;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link p > i.right {
        position: static !important;
        display: block !important;
        margin: 2px auto 0 !important;
        width: 20px;
        height: 20px;
        line-height: 20px !important;
        font-size: 0.82rem !important;
        font-weight: 900;
        opacity: 0.9;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link p > .num-icon-top.right {
        display: block !important;
        position: absolute;
        top: 3px;
        right: 4px;
        width: 18px;
        height: 18px;
        margin-right: 0;
        z-index: 1;
    }
    .sidebar-mini:not(.sidebar-collapse) .main-sidebar,
    .sidebar-mini:not(.sidebar-collapse) .main-sidebar::before,
    .sidebar-mini:not(.sidebar-collapse) .brand-link,
    .sidebar-mini:not(.sidebar-collapse).layout-fixed .brand-link {
        width: var(--sidebar-expanded-width) !important;
        min-width: var(--sidebar-expanded-width) !important;
        max-width: var(--sidebar-expanded-width) !important;
    }
    .sidebar-mini:not(.sidebar-collapse) .content-wrapper,
    .sidebar-mini:not(.sidebar-collapse) .main-footer,
    .sidebar-mini:not(.sidebar-collapse) .main-header {
        margin-left: var(--sidebar-expanded-width) !important;
        width: calc(100% - var(--sidebar-expanded-width)) !important;
        max-width: calc(100% - var(--sidebar-expanded-width)) !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-item.has-treeview > .nav-link p,
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-treeview .nav-link p {
        display: block !important;
        width: auto !important;
        max-width: calc(var(--sidebar-collapsed-width) - 10px);
        margin-left: 0 !important;
        visibility: visible !important;
        opacity: 1;
        -webkit-line-clamp: unset;
        line-clamp: unset;
        min-height: 0;
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
    }
    .dashboard-header.hero-banner,
    .dashboard-header.hero-banner .container-fluid {
        max-width: 100%;
    }
    .dashboard-header.hero-banner .row {
        margin-left: 0;
        margin-right: 0;
    }
    .content-wrapper .container-fluid {
        max-width: 100%;
        overflow-x: clip;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-item.menu-open > .nav-treeview .nav-link p {
        display: block !important;
        visibility: visible !important;
        opacity: 1;
        white-space: normal;
    }
    .content-wrapper,
    .content-wrapper .content,
    .content-wrapper .container-fluid {
        overflow-x: hidden !important;
    }

    .dashboard-header.hero-banner .stat-highlight.hero-datetime {
        min-width: 0;
        width: 100%;
        padding-left: 36px;
        padding-right: 10px;
    }
    .dashboard-header.hero-banner .hero-datetime-content {
        width: 100%;
    }
    .dashboard-header.hero-banner .stat-highlight.hero-datetime .stat-number {
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link p,
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-treeview .nav-link p {
        display: block !important;
        width: calc(100% - 4px) !important;
        max-width: 100% !important;
        margin: 2px 0 0 !important;
        min-height: 0 !important;
        visibility: visible !important;
        opacity: 1 !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        -webkit-line-clamp: unset !important;
        line-clamp: unset !important;
        color: inherit !important;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link p > i.right,
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link p > .num-icon-top.right {
        position: static !important;
        display: inline-flex !important;
        margin: 0 0 0 4px !important;
        top: auto !important;
        right: auto !important;
    }
}

/* กันเลเยอร์ทับด้านขวาในจอเดสก์ท็อปกะทัดรัด */
@media (min-width: 1366px) and (max-width: 1800px) {
    .sidebar-mini.sidebar-collapse .content-wrapper,
    .sidebar-mini.sidebar-collapse .main-footer,
    .sidebar-mini.sidebar-collapse .main-header {
        width: calc(100% - var(--sidebar-collapsed, calc(5.8rem + 40px))) !important;
        max-width: calc(100% - var(--sidebar-collapsed, calc(5.8rem + 40px))) !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }
    .sidebar-mini:not(.sidebar-collapse) .content-wrapper,
    .sidebar-mini:not(.sidebar-collapse) .main-footer,
    .sidebar-mini:not(.sidebar-collapse) .main-header {
        width: calc(100% - 250px) !important;
        max-width: calc(100% - 250px) !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }
    .main-header {
        overflow: visible;
        --top-desktop-collapse-margin: 0 10px 0 12px;
        --top-desktop-collapse-max-width: calc(100% - 220px);
        --top-desktop-actions-layer: 1064;
    }
    .main-header .navbar-nav > .nav-item {
        margin-right: 4px;
    }
    .main-header .navbar-nav > .nav-item > .nav-link {
        font-size: 0.78rem;
        padding: 0.45rem 0.5rem;
    }
    .stat-highlight .stat-label  { font-size: 0.75rem; }
    .stat-highlight .stat-number { font-size: 1rem; }
    .main-header .navbar-collapse {
        position: static !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        width: auto !important;
        max-height: none !important;
        overflow: visible !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: var(--top-desktop-collapse-margin) !important;
        flex: 1 1 auto;
        min-width: 0;
        max-width: var(--top-desktop-collapse-max-width);
        z-index: auto;
    }
    .main-header .navbar-collapse > .navbar-nav {
        width: 100%;
        min-width: 0;
        flex-wrap: nowrap;
        overflow: visible;
    }
    .main-header .navbar-actions {
        position: relative;
        z-index: var(--top-desktop-actions-layer);
        flex: 0 0 auto;
        margin-left: auto !important;
    }
}

/* ============ ทำให้ย่อ/ขยายเมนูลื่นขึ้น ============ */
@media (min-width: 1024px) {
    .sidebar-mini {
        --sidebar-width-transition: width 0.28s cubic-bezier(0.22, 0.61, 0.36, 1), min-width 0.28s cubic-bezier(0.22, 0.61, 0.36, 1), max-width 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
        --sidebar-margin-transition: margin-left 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
        --sidebar-link-transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.24s ease, opacity 0.2s ease;
        --sidebar-inner-transition: opacity 0.22s ease, transform 0.22s ease, color 0.22s ease;
    }
    .sidebar-mini .main-sidebar,
    .sidebar-mini .main-sidebar::before,
    .sidebar-mini .brand-link {
        transition: var(--sidebar-width-transition) !important;
    }
    .sidebar-mini .content-wrapper,
    .sidebar-mini .main-footer,
    .sidebar-mini .main-header {
        transition: var(--sidebar-margin-transition) !important;
    }
    .sidebar-mini .sidebar .nav-sidebar .nav-link {
        transition: var(--sidebar-link-transition) !important;
    }
    .sidebar-mini .sidebar .nav-sidebar .nav-link .nav-icon,
    .sidebar-mini .sidebar .nav-sidebar .nav-link p {
        transition: var(--sidebar-inner-transition) !important;
    }
}

/* ============ 22. การเข้าถึง ============ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============ Chart Drilldown Panel ============ */
.chart-drill-card {
    min-height: 100%;
}
.chart-drill-empty {
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    text-align: center;
    color: #64748b;
    font-size: 0.9rem;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 12px;
    background: #f8fafc;
}
.chart-drill-empty i {
    font-size: 1rem;
    color: #3b82f6;
}
.chart-drill-loading {
    color: #334155;
    padding: 12px 10px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.chart-drill-error {
    color: #991b1b;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #fecaca;
    background: #fff1f2;
    font-size: 0.9rem;
}
.chart-drill-context {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.chart-drill-chip {
    display: inline-block;
    font-size: 0.76rem;
    color: #17345c;
    background: linear-gradient(180deg, #eef5ff 0%, #e7f0ff 100%);
    border: 1px solid #c9daf8;
    border-radius: 999px;
    padding: 4px 11px;
    line-height: 1.4;
    font-weight: 600;
}
.chart-drill-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.chart-drill-kpi {
    border: 1px solid #d2e2ff;
    border-radius: 10px;
    background: linear-gradient(180deg, #f8fbff 0%, #f0f6ff 100%);
    padding: 10px 12px;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.08);
}
.chart-drill-kpi__label {
    color: #5b6b84;
    font-size: 0.76rem;
}
.chart-drill-kpi__value {
    color: #0d2445;
    font-size: 1.72rem;
    line-height: 1.1;
    font-weight: 700;
    margin-top: 4px;
}
.chart-drill-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #1e3a5f;
    color: #fff;
    font-size: 0.8rem;
    white-space: nowrap;
    border: 1px solid #355a8a;
}
.chart-drill-table tbody tr:nth-child(odd) {
    background: #f4f8ff;
}
.chart-drill-table tbody tr:nth-child(even) {
    background: #eaf2ff;
}
.chart-drill-table tbody td {
    border: 1px solid #d8e6ff;
}
.chart-drill-table td {
    font-size: 0.84rem;
    vertical-align: middle;
}
.chart-drill-table th,
.chart-drill-table td {
    padding: 0.62rem 0.95rem !important;
}
.chart-drill-table tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: #dbeafe;
    color: #0f2d57;
    border: 1px solid #93c5fd;
    border-top-width: 2px;
    font-weight: 700;
}
#chartDrillModal .chart-drill-modal-dialog {
    max-width: min(1080px, 94vw);
    width: 100%;
}
#chartDrillModal .modal-content {
    border: 0;
    border-radius: 14px;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.26);
}
#chartDrillModal .chart-drill-card {
    margin: 0;
    border-radius: 14px;
    box-shadow: none;
}
#chartDrillModal #chartDrillPanelBody {
    max-height: calc(86vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
}
#chartDrillModal #chartDrillTableWrap {
    max-height: 46vh;
    padding: 0 8px 8px;
}
@media (max-width: 991.98px) {
    .chart-drill-summary {
        grid-template-columns: 1fr;
    }
    .chart-drill-kpi__value {
        font-size: 1.45rem;
    }
}
@media (max-width: 767.98px) {
    #chartDrillModal .chart-drill-modal-dialog {
        max-width: 96vw;
        margin: 0.5rem auto;
    }
    #chartDrillModal #chartDrillPanelBody {
        max-height: calc(90vh - 56px);
    }
}
.info-stat-card.js-help-summary-card {
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease;
}
.info-stat-card.js-help-summary-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}
