/* ================================================================
   Dashboard CSS — PPAOS & SRADSS
   ================================================================
    1. Base / Global
    2. Layout
    3. Top Navbar
   4. Top Navbar — Custom Breakpoint (1024px)
    5. Sidebar
    6. Sidebar Collapsed (≥1025px)
    7. Header Banner
    8. District Filter Bar
    9. Cards
   10. Small Boxes
   11. Stat Cards with Ring Icon
   12. Status Cards (Residence)
   13. D3 Map
   14. Chart Legend
   15. Dimension Grid & Tables
   16. Pie Timeline Player
   17. Province Comparison Table
   18. Export Excel Button
   19. Floating Action Buttons (FAB)
   20. Loading / Skeleton / Odometer
   21. Responsive
   22. Accessibility
   ================================================================ */

/* ─── Sidebar collapsed width token ─── */
:root {
    --sidebar-collapsed: 5.8rem;
    --top-nav-h: 59px;
}


/* ============ 1. Base / Global ============ */

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

/* บังคับ Kanit ทุก element รวม ECharts tooltip ที่ใช้ inline font style */
* {
    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;
}

.tooltip.year-tabs-tooltip {
    pointer-events: none;
    opacity: 0;
    transition: opacity .1s ease;
}
.tooltip.year-tabs-tooltip.show {
    opacity: 1 !important;
}
.tooltip.year-tabs-tooltip .tooltip-inner {
    background: linear-gradient(145deg, rgba(11, 18, 32, .94), rgba(15, 23, 42, .9));
    color: #e2e8f0;
    border: 1px solid rgba(96, 165, 250, .42);
    box-shadow: 0 14px 28px rgba(2, 6, 23, .28), inset 0 1px 0 rgba(255, 255, 255, .08);
    border-radius: 11px;
    padding: 8px 12px;
    font-size: .79rem;
    font-weight: 520;
    letter-spacing: .15px;
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
    max-width: 280px;
    text-align: center;
    line-height: 1.25;
}
.tooltip.year-tabs-tooltip .arrow {
    display: none !important;
}


/* ============ 2. Layout ============ */

.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. Top Navbar ============ */

.main-header {
    background: linear-gradient(135deg, #d8e0ec 0%, #c8d2e2 100%) !important;
    border-bottom: 1px solid #c4cedd;
    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: inset 0 -1px 0 rgba(255,255,255,.35);
}
.main-header .navbar-nav > .nav-item > .nav-link {
    font-size: 0.84rem;
    color: #0f172a;
    font-weight: 520;
    padding: 0.58rem 0.8rem;
    border-radius: 9px;
    transition: all .18s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    line-height: 1.15;
    gap: 6px;
    white-space: nowrap;
}
.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: rgba(37,99,235,0.1);
    color: #1d4ed8;
}
.main-header .navbar-nav > .nav-item > .nav-link.active {
    color: #1d4ed8;
    font-weight: 620;
    background: rgba(37,99,235,0.1);
}
.main-header .nav-link[data-widget="pushmenu"] {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.7);
    border: 1px solid rgba(148,163,184,.45);
}
.main-header .nav-link[data-widget="pushmenu"]:hover {
    background: #fff;
}
.main-header .auth-user-chip {
    border: 1px solid #c5d0e0;
    border-radius: 999px;
    background: rgba(255,255,255,.92);
    color: #0f172a !important;
    padding: 8px 12px !important;
    line-height: 1;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 184px;
}
.main-header .auth-user-chip:hover {
    background: #ffffff;
    border-color: #93c5fd;
    color: #1d4ed8 !important;
}
.main-header #authUserMenuText {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 122px;
}
.main-header .navbar-actions {
    display: flex;
    align-items: center;
    flex-direction: row;
    gap: 8px;
}
.main-header .navbar-nav .nav-link i {
    line-height: 1;
    width: 15px;
    min-width: 15px;
    text-align: center;
}
.main-header .navbar-nav .nav-link i.mr-1 {
    margin-right: 0 !important;
}
.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 !important;
}
.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,.18);
}
.main-header #reportDropdown .badge {
    background: linear-gradient(135deg, #14b8a6, #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(20,184,166,.25);
}
.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 {
    min-width: 260px;
    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;
}
.auth-user-dropdown .auth-user-meta {
    font-size: .78rem;
    color: #64748b;
    line-height: 1.4;
}
.auth-user-dropdown .dropdown-divider {
    margin: 6px 0;
}
.auth-user-dropdown .dropdown-item {
    border-radius: 8px;
}
.auth-login-modal .modal-content {
    border: none;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .24);
}
.auth-login-modal .modal-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: #fff;
    border-bottom: none;
}
/* หัวข้อที่ใช้รูปแบบตัวหนาและขนาดเดียวกัน */
.auth-login-modal .modal-title,
.age-gender-title {
    font-size: 1rem;
    font-weight: 700;
}
.auth-login-modal .close {
    color: #fff;
    opacity: .9;
    text-shadow: none;
}
.auth-login-modal .close:hover { opacity: 1; }
.auth-login-modal .modal-body { padding: 18px; }
.auth-login-modal .auth-help-text {
    font-size: .83rem;
    color: #64748b;
    margin-bottom: 12px;
}
.auth-login-modal .form-control {
    border-radius: 10px;
    height: 40px;
    border-color: #cbd5e1;
}
.auth-login-modal .form-control:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 .15rem rgba(59,130,246,.2);
}
.auth-login-modal .auth-error {
    display: none;
    font-size: .82rem;
    margin-top: 8px;
}

.auth-toast-container {
    position: fixed;
    top: 14px;
    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: 12px;
    padding: 7px;
    min-width: 200px;
    border: 1px solid #dbe4f0;
    box-shadow: 0 14px 30px rgba(15,23,42,.16);
}
.main-header .dropdown-item {
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-family: 'Kanit', sans-serif;
}
.main-header .dropdown-item:hover {
    background: rgba(59,130,246,0.08);
    color: #3b82f6;
}
.main-header .dropdown-item.active,
.main-header .dropdown-item.active:hover {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    font-weight: 600;
}

.main-header .navbar-toggler {
    color: #334155;
    font-size: 1.1rem;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(148,163,184,.45) !important;
    background: rgba(255,255,255,.78);
    transition: background 0.15s ease;
}
.main-header .navbar-toggler:hover {
    background: #ffffff;
    color: #3b82f6;
}

/* เมื่อมี modal เปิด ให้ modal ทับทุก overlay บน header เสมอ */
.modal-backdrop {
    z-index: 2000 !important;
}
.modal {
    z-index: 2010 !important;
}
body.modal-open .main-header .navbar-collapse.show {
    display: none !important;
}
body.modal-open #authUserMenu .dropdown-menu.show {
    display: none !important;
}


/* ============ 4. Top Navbar — Custom Breakpoint (1024px) ============ */

@media (min-width: 1025px) {
    .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;
    }
}

@media (max-width: 1024.98px) {
    .main-header {
        position: sticky;
        top: 0;
        z-index: 1060;
        padding: 8px 10px;
        padding-right: 198px;
        min-height: var(--top-nav-h);
        height: var(--top-nav-h);
    }
    .main-header .navbar-nav {
        flex-direction: row;
        align-items: center;
    }
    .main-header .nav-quick-toggle {
        margin-left: auto !important;
        margin-right: 0 !important;
    }
    .main-header .navbar-actions {
        position: absolute;
        right: 8px;
        top: 8px;
        margin-left: 0 !important;
        gap: 4px;
        z-index: 1062;
    }
    .main-header .navbar-actions .nav-link[data-widget="fullscreen"] { display: inline-flex; }
    .main-header .auth-user-chip {
        max-width: 120px;
        padding: 8px 10px !important;
    }
    .main-header #authUserMenuText {
        max-width: 64px;
    }
    .main-header .navbar-collapse {
        position: absolute;
        left: 8px;
        right: 8px;
        top: var(--top-nav-h);
        background: rgba(255,255,255,.98);
        border-radius: 14px;
        box-shadow: 0 16px 34px rgba(15,23,42,.18);
        padding: 10px;
        margin-top: 0;
        border: 1px solid #dbe4f0;
        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: rgba(59,130,246,0.08);
    }
    .main-header .navbar-collapse .nav-link.active {
        background: rgba(59,130,246,0.1);
        color: #2563eb;
        font-weight: 600;
    }
    .main-header .navbar-collapse .dropdown-menu {
        border: none;
        box-shadow: none;
        padding: 0 0 0 12px;
        min-width: 0;
        margin-top: 4px;
        background: transparent;
    }
    /* ให้เมนูผู้ใช้เปิดแบบเดียวกับปุ่ม 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: 1px solid #dbe4f0;
        background: rgba(255,255,255,.98);
        box-shadow: 0 16px 34px rgba(15,23,42,.18);
        padding: 10px;
        margin: 0 !important;
        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;
    }
}

/* Tablet compact: ใช้ quick menu แบบไม่เกิด scrollbar ภายใน */
@media (min-width: 768px) and (max-width: 1024.98px) {
    .main-header {
        /* กันพื้นที่ฝั่งขวาให้พอสำหรับ ... + ผู้ใช้ + fullscreen */
        padding-right: 272px;
    }
    .main-header .nav-quick-toggle {
        position: absolute;
        right: 228px;
        top: 8px;
        margin: 0 !important;
        z-index: 1062;
    }
    .main-header .navbar-actions .nav-link[data-widget="fullscreen"] { display: inline-flex; }
    .main-header .auth-user-chip {
        max-width: 154px;
    }
    .main-header #authUserMenuText {
        max-width: 88px;
    }
    .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 !important;
    }
    #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 !important;
        padding-right: 10px !important;
        justify-content: flex-start;
        gap: 8px;
    }
    .main-header .navbar-collapse > .navbar-nav > .nav-item > .nav-link i {
        margin-left: 0;
    }
}

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


/* ============ 5. Sidebar ============ */

.main-sidebar {
    font-size: 0.9rem;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%) !important;
}
.main-sidebar .sidebar {
    padding-bottom: 20px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(191, 219, 254, 0.55) transparent;
}
.main-sidebar .sidebar .nav-sidebar {
    padding-right: 8px;
}
@supports (overflow: overlay) {
    .main-sidebar .sidebar {
        overflow-y: overlay;
    }
}
.main-sidebar .sidebar::-webkit-scrollbar {
    width: 8px;
}
.main-sidebar .sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.main-sidebar .sidebar::-webkit-scrollbar-thumb {
    background: rgba(191, 219, 254, 0.48);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.main-sidebar .sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(219, 234, 254, 0.72);
    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: rgba(59,130,246,0.15);
}
.nav-sidebar .nav-link.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
    box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

.brand-link {
    padding: 14px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
    pointer-events: none;
}
.brand-text {
    letter-spacing: 0.5px;
}

.num-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 22px !important;
    height: 22px !important;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,0.5);
    font-size: 0.75rem !important;
    color: rgba(255,255,255,0.8);
    font-family: 'Kanit', sans-serif;
}
.nav-sidebar .nav-link.active .num-icon,
.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: linear-gradient(180deg, #10214a 0%, #1d4ed8 54%, #1e3a8a 100%) !important;
}
.ppaos-menu-brand {
    border-bottom: 1px solid rgba(191, 219, 254, 0.28) !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
}
.ppaos-side-nav .nav-header {
    color: rgba(219, 234, 254, 0.78);
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .35px;
    text-transform: uppercase;
    padding-left: 12px;
}
.ppaos-side-nav .ppaos-menu-link {
    border: 1px solid rgba(147, 197, 253, 0.22);
    background: linear-gradient(130deg, rgba(30, 64, 175, 0.28), rgba(30, 58, 138, 0.18));
    color: #e2e8f0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    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: rgba(191, 219, 254, 0.52);
    background: linear-gradient(130deg, rgba(59, 130, 246, 0.34), rgba(30, 64, 175, 0.26));
    color: #ffffff;
    transform: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 10px 16px rgba(15, 23, 42, 0.22);
}
.ppaos-side-nav .ppaos-menu-link:hover .nav-icon {
    transform: scale(1.14);
}
.ppaos-side-nav .ppaos-menu-link.active {
    border-color: rgba(147, 197, 253, 0.8);
    background: linear-gradient(135deg, #1a2a6d, #18398f) !important;
    box-shadow: 0 12px 20px rgba(15, 23, 42, 0.54), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.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 #94a3b8;
    font-size: 0.65rem !important;
    font-weight: 600;
    color: #475569;
    font-family: 'Kanit', sans-serif;
}
/* ============ 6. Sidebar Collapsed (≥1025px) ============ */

@media (min-width: 1025px) {

    /* Width — single source of truth */
    .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 inner reset */
    .sidebar-mini.sidebar-collapse .sidebar {
        padding: 0 0 20px 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        max-height: calc(100vh - 3.5rem) !important;
        transition: none !important;
    }
    .sidebar-mini.sidebar-collapse .sidebar .nav-sidebar {
        padding: 0 !important;
    }

    /* Scrollbar สำหรับ sidebar collapsed */
    .sidebar-mini.sidebar-collapse .sidebar::-webkit-scrollbar {
        width: 3px;
    }
    .sidebar-mini.sidebar-collapse .sidebar::-webkit-scrollbar-track {
        background: transparent;
    }
    .sidebar-mini.sidebar-collapse .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.2);
        border-radius: 3px;
    }
    .sidebar-mini.sidebar-collapse .sidebar::-webkit-scrollbar-thumb:hover {
        background: rgba(255,255,255,0.4);
    }
    .sidebar-mini.sidebar-collapse .sidebar {
        scrollbar-width: thin;
        scrollbar-color: rgba(255,255,255,0.2) transparent;
    }

    /* Nav items — icon on top, text below */
    .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;
        align-items: center !important;
        text-align: center !important;
        width: calc(100% - 8px) !important;
        padding: 10px 6px !important;
        margin: 2px auto !important;
        border-radius: 8px !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 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 > .badge.right {
        display: block !important;
        position: absolute;
        top: 2px;
        right: 8px;
        font-size: 0.7rem;
        padding: 2px 5px;
        border-radius: 10px;
        line-height: 1;
        z-index: 1;
    }

    /* Brand link */
    .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 !important;
        animation-name: none !important;
        animation-fill-mode: none !important;
        margin-left: 0 !important;
        display: block !important;
        font-size: 0.7rem !important;
        text-align: center;
        opacity: 1 !important;
    }
}

/* Badge style for sidebar (expanded) and navbar */
.nav-sidebar .nav-link p > .badge.right,
.navbar .badge {
    font-size: 0.7rem;
    padding: 2px 5px;
    border-radius: 10px;
    line-height: 1;
}

/* ============ 7. Header Banner ============ */

.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 !important;
    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 !important;
}
.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 !important;
    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 !important;
    font-weight: 400 !important;
    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;
    }
}

/* ============ 7b. Shared Report Styles ============ */

.rpt-year-bar {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #3b82f6 100%);
    padding: 12px 0;
}
/* ปุ่มปีของรายงาน: ใช้ได้ทั้งคลาสเดิมและคลาสกลาง */
.report-year-btn,
.rpt-year-bar .btn {
    border: 1.5px solid rgba(255,255,255,.45);
    color: #fff;
    background: transparent;
    font-size: .82rem;
    font-weight: 500;
    border-radius: 20px;
    padding: 4px 16px;
    margin: 3px 4px;
    transition: all .2s;
}
.report-year-btn:hover,
.rpt-year-bar .btn:hover { background: rgba(255,255,255,.18); }
.report-year-btn.is-active,
.rpt-year-bar .btn.active {
    background: #fff;
    color: #1e3a5f;
    font-weight: 700;
    border-color: #fff;
}
.dim-bar {
    padding: 10px 0;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
/* ปุ่มชิปของรายงาน: รองรับการใช้ซ้ำหลายหน้า */
.report-chip,
.dim-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 2px solid currentColor;
    background: transparent;
    font-size: .85rem;
    font-weight: 600;
    border-radius: 24px;
    padding: 6px 18px;
    margin: 3px 4px;
    cursor: pointer;
    transition: all .2s;
}
.report-chip:hover,
.dim-btn:hover { opacity: .85; }
.report-chip.is-active,
.dim-btn.active { color: #fff !important; }
.report-chip--human,
.dim-btn[data-dim="human"] { color: #dc2626; }
.report-chip--human.is-active,
.dim-btn[data-dim="human"].active { background: #dc2626; border-color: #dc2626; }
.report-chip--physical,
.dim-btn[data-dim="physical"] { color: #ea580c; }
.report-chip--physical.is-active,
.dim-btn[data-dim="physical"].active { background: #ea580c; border-color: #ea580c; }
.report-chip--financial,
.dim-btn[data-dim="financial"] { color: #ca8a04; }
.report-chip--financial.is-active,
.dim-btn[data-dim="financial"].active { background: #ca8a04; border-color: #ca8a04; }
.report-chip--natural,
.dim-btn[data-dim="natural"] { color: #16a34a; }
.report-chip--natural.is-active,
.dim-btn[data-dim="natural"].active { background: #16a34a; border-color: #16a34a; }
.report-chip--social,
.dim-btn[data-dim="social"] { color: #2563eb; }
.report-chip--social.is-active,
.dim-btn[data-dim="social"].active { background: #2563eb; border-color: #2563eb; }
.rpt-table-wrap {
    overflow-x: auto;
}
.rpt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.modal-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}
/* รวมโครงสร้างตารางที่ซ้ำกันของรายงานและโมดอล */
.rpt-table thead th,
.modal-detail-table thead th {
    background: #1e3a5f;
    color: #fff;
    font-weight: 600;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 2;
    white-space: nowrap;
}
.rpt-table thead th { padding: 10px 8px; }
.modal-detail-table thead th { padding: 8px 6px; }
.rpt-table tbody td,
.modal-detail-table tbody td {
    border-bottom: 1px solid #e2e8f0;
    text-align: center;
    vertical-align: middle;
}
.rpt-table tbody td { padding: 8px; }
.modal-detail-table tbody td { padding: 6px; }
.rpt-table tbody tr:hover,
.modal-detail-table tbody tr:hover { background: #f0f7ff; }
.rpt-table .col-name { text-align: left; }
.rpt-table .col-num { font-variant-numeric: tabular-nums; }
.rpt-table tfoot td {
    background: #f1f5f9;
    font-weight: 700;
    padding: 10px 8px;
    text-align: center;
    border-top: 2px solid #94a3b8;
}
.poverty-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: .78rem;
    font-weight: 600;
    color: #fff;
}
.poverty-badge.lv1 { background: #dc2626; }
.poverty-badge.lv2 { background: #ea580c; }
.poverty-badge.lv3 { background: #2563eb; }
.poverty-badge.lv4 { background: #16a34a; }
.btn-view-detail {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    color: #2563eb;
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: all .2s;
}
.btn-view-detail:hover {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37,99,235,.35);
}
.detail-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.detail-pagination .page-info {
    font-size: .8rem;
    color: #64748b;
    margin-right: 8px;
}
.detail-pagination .page-btn {
    min-width: 32px;
    height: 32px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    border-radius: 6px;
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
}
.detail-pagination .page-btn:hover { background: #f1f5f9; }
.detail-pagination .page-btn.active {
    background: #1e3a5f;
    color: #fff;
    border-color: #1e3a5f;
}
.detail-pagination .page-btn:disabled {
    opacity: .4;
    cursor: default;
}
.rpt-info-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}
.rpt-info-bar .rpt-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e3a5f;
}
.filter-condition-bar {
    background: #1e3a5f;
    border-radius: 10px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.filter-condition-bar .filter-label {
    font-size: .75rem;
    font-weight: 600;
    color: #fff;
    margin-right: 4px;
    white-space: nowrap;
}
/* แท็กเงื่อนไขตัวกรอง: รวมรูปแบบกลางและคงคลาสเดิม */
.report-filter-tag,
.filter-condition-bar .filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 20px;
    padding: 4px 14px;
    font-size: .78rem;
    font-weight: 600;
    border: 1.5px solid;
}
.report-filter-tag i,
.filter-condition-bar .filter-tag i { font-size: .7rem; }
.report-filter-tag--year,
.filter-tag.tag-year { border-color: #ca8a04; background: #fef9c3; color: #713f12; }
.report-filter-tag--prov,
.filter-tag.tag-prov { border-color: #7c3aed; background: #ede9fe; color: #5b21b6; }
.report-filter-tag--amp,
.filter-tag.tag-amp  { border-color: #0d9488; background: #ccfbf1; color: #115e59; }
.report-filter-tag--dim,
.filter-tag.tag-dim  { border-color: #fff; background: #1e3a5f; color: #fff; }
.report-filter-tag--tmb,
.filter-tag.tag-tmb  { border-color: #db2777; background: #fce7f3; color: #831843; }
.clickable-num {
    cursor: pointer;
    color: #2563eb;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all .15s;
}
.clickable-num:hover {
    background: #dbeafe;
    text-decoration: underline;
}


/* ============ 8. District Filter Bar ============ */

.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; }
}

/* ============ 8b. Sticky Filter Bar ============ */

.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.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s 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.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: 1025px) {
    .sidebar-mini.sidebar-collapse .sticky-filter-bar {
        margin-left: var(--sidebar-collapsed, 5.8rem);
    }
    .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. Cards ============ */

/* จัดกึ่งกลางแนวแกนสำหรับปุ่มและไอคอนที่ใช้ร่วมกัน */
.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);
}
/* รวม transition ของการ์ดที่ใช้จังหวะเดียวกัน */
.stat-card-ring,
.status-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
/* รวม pseudo วงกลมตกแต่งที่ใช้โครงสร้างเดียวกัน */
.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 !important;
    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 Boxes ============ */

.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 Cards with Ring Icon ============ */

.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 Cards (Province) ============ */
.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. Status Cards (Residence) ============ */

.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-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-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 Pyramid Gender Labels ============ */

.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. D3 Map ============ */

#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;
}

.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-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;
    bottom: 16px; left: 16px;
    background: linear-gradient(145deg, rgba(15,23,42,0.72) 0%, rgba(30,58,108,0.65) 100%);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-radius: 18px;
    padding: 16px 24px 14px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.12);
    z-index: 10;
    pointer-events: none;
    border: 1px solid rgba(255,255,255,0.15);
    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(99,179,237,0.15) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(129,140,248,0.10) 0%, transparent 40%);
    pointer-events: none;
}
.map-score-badge small {
    position: relative;
    display: block;
    font-size: 0.7rem;
    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: 2.2rem;
    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: 4px 16px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 6px;
}


/* ============ 14. Chart Legend ============ */

.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 & Tables ============ */

.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 Player ============ */

.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;
}

.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 Comparison Table ============ */

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


/* ============ 18. Export Excel Button ============ */

.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. Floating Action Buttons (FAB) ============ */

.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. Loading / Skeleton / Odometer ============ */

.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. Responsive ============ */

/* Compact desktop (1600–1800px) */
@media (min-width: 1600px) and (max-width: 1800px) {
    .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; }
}

/* Tablet (≤1024px) */
@media (max-width: 1024.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; }
}

/* Mobile (≤768px) */
@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; }

    #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; }
}

/* Small mobile (≤480px) */
@media (max-width: 480px) {
    .main-header {
        padding-right: 182px;
    }
    .main-header .auth-user-chip {
        max-width: 102px;
    }
    .main-header #authUserMenuText {
        max-width: 48px;
    }
    .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 Cards ============ */

.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;
    font-weight: 800;
    color: #1e293b;
}
.info-stat-card .isc-unit {
    font-weight: 500;
    font-size: 0.78rem;
    color: #64748b;
}
.info-stat-card .isc-sub {
    font-size: 1.1rem;
    font-weight: 800;
    color: #1e293b;
    margin-top: 3px;
}
.info-stat-card .isc-sub-icon {
    font-size: 0.75rem;
    margin-right: 4px;
    color: var(--isc-color, #333);
}
.info-stat-card .isc-sub-unit {
    font-weight: 500;
    font-size: 0.78rem;
    color: var(--isc-color, #333);
}

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

/* ============ 23. Continuous Poor Tab Buttons ============ */
.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;
}

/* ============ 24. Accessibility ============ */

@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;
    }
}
