:root {
    --bg-color: #f4f6fa;
    --text-color: #2D3748;
    --card-bg: #ffffff;
    --sidebar-bg: #ffffff;
    --sidebar-text: #334155;
    --sidebar-hover-bg: rgba(0, 0, 0, 0.04);
    --sidebar-active-text: #ffffff;
    --sidebar-active-bg: #2563eb;
    --sidebar-header-text: #94a3b8;
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --border-color: #E2E8F0;
    --accent-color: #4FD1C5;
    
    /* Finance Specific Colors */
    --finance-inflow: #10B981;
    --finance-outflow: #F43F5E;
    --finance-warning: #DD6B20;
    --finance-highlight: #D69E2E;

    /* Stacking scale (Bootstrap 5 aligned)
       Navbar (--z-fixed) must sit ABOVE sidebar so header dropdowns are never clipped behind it.
       Report filters/toolbar/thead stay BELOW fixed navbar. */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-report-thead: 1024;
    --z-report-toolbar: 1026;
    --z-report-filters: 1028;
    --z-sidebar: 1030;
    --z-sidebar-backdrop: 1029;
    --z-fixed: 1040;
    --z-sidebar-elevated: 1042;
    --z-menu-overlay: 1048;
    --z-modal-backdrop: 1050;
    --z-modal: 1055;
    --z-popover: 1060;
    --z-toast: 1070;
    --z-tooltip: 1080;
}

/* Palette Variations */
:root {
    --primary-light: rgba(49, 130, 206, 0.08);
}

[data-palette="powerbi"] {
    --primary-color: #F2C811;
    --primary-hover: #D8B20F;
    --primary-light: rgba(242, 200, 17, 0.08);
    --sidebar-active-bg: #F2C811;
    --sidebar-active-text: #1A202C;
}

[data-palette="emerald"] {
    --primary-color: #10B981;
    --primary-hover: #059669;
    --primary-light: rgba(16, 185, 129, 0.08);
    --sidebar-active-bg: #10B981;
}

[data-palette="ruby"] {
    --primary-color: #EF4444;
    --primary-hover: #DC2626;
    --primary-light: rgba(239, 68, 68, 0.08);
    --sidebar-active-bg: #EF4444;
}

[data-palette="amethyst"] {
    --primary-color: #8B5CF6;
    --primary-hover: #7C3AED;
    --primary-light: rgba(139, 92, 246, 0.08);
    --sidebar-active-bg: #8B5CF6;
}

[data-palette="slate"] {
    --primary-color: #475569;
    --primary-hover: #334155;
    --primary-light: rgba(71, 85, 105, 0.08);
    --sidebar-active-bg: #475569;
    --sidebar-active-text: #ffffff;
}

[data-palette="cyan"] {
    --primary-color: #06B6D4;
    --primary-hover: #0891B2;
    --primary-light: rgba(6, 182, 212, 0.08);
    --sidebar-active-bg: #06B6D4;
    --sidebar-active-text: #ffffff;
}

[data-theme="dark"] {
    --bg-color: #0F172A;
    --text-color: #E2E8F0;
    --card-bg: #1E293B;
    --sidebar-bg: #0B0F19;
    --sidebar-text: #94A3B8;
    --sidebar-hover-bg: #1E293B;
    --sidebar-active-text: #ffffff;
    --sidebar-active-bg: #3B82F6;
    --primary-color: #3B82F6;
    --primary-hover: #2563EB;
    --primary-light: rgba(59, 130, 246, 0.08);
    --border-color: #334155;
    --accent-color: #38BDF8;
}

/* Override primary color in dark mode depending on selected palette */
[data-theme="dark"][data-palette="powerbi"] { 
    --primary-color: #F2C811; 
    --primary-light: rgba(242, 200, 17, 0.08);
    --sidebar-active-bg: #F2C811; 
}
[data-theme="dark"][data-palette="emerald"] { 
    --primary-color: #10B981; 
    --primary-light: rgba(16, 185, 129, 0.08);
    --sidebar-active-bg: #10B981; 
}
[data-theme="dark"][data-palette="ruby"] { 
    --primary-color: #EF4444; 
    --primary-light: rgba(239, 68, 68, 0.08);
    --sidebar-active-bg: #EF4444; 
}
[data-theme="dark"][data-palette="amethyst"] { 
    --primary-color: #8B5CF6; 
    --primary-light: rgba(139, 92, 246, 0.08);
    --sidebar-active-bg: #8B5CF6; 
}
[data-theme="dark"][data-palette="slate"] { 
    --primary-color: #64748B; 
    --primary-light: rgba(100, 116, 139, 0.08);
    --sidebar-active-bg: #64748B; 
    --sidebar-active-text: #ffffff;
}
[data-theme="dark"][data-palette="cyan"] { 
    --primary-color: #06B6D4; 
    --primary-light: rgba(6, 182, 212, 0.08);
    --sidebar-active-bg: #06B6D4; 
    --sidebar-active-text: #03060C;
}

/* Sidebar Style Variants (Classic, Theme, Light) */
[data-sidebar-style="theme"] {
    --sidebar-bg: var(--primary-color) !important;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.18) !important;
    --sidebar-text: rgba(255, 255, 255, 0.9) !important;
    --sidebar-active-text: #ffffff !important;
    --sidebar-active-bg: rgba(0, 0, 0, 0.25) !important;
}

[data-sidebar-style="theme"] #sidebar .sidebar-header,
[data-sidebar-style="theme"] #sidebar .sidebar-brand,
[data-sidebar-style="theme"] #sidebar .cat-title-text,
[data-sidebar-style="theme"] #sidebar .category-chevron {
    color: #ffffff !important;
}

/* Contrast adjustment for bright palette 'powerbi' (Amber Signal / Yellow) in Theme mode */
[data-sidebar-style="theme"][data-palette="powerbi"] {
    --sidebar-bg: #F2C811 !important;
    --sidebar-hover-bg: rgba(0, 0, 0, 0.08) !important;
    --sidebar-text: #1A202C !important;
    --sidebar-active-text: #000000 !important;
    --sidebar-active-bg: rgba(0, 0, 0, 0.15) !important;
}

[data-sidebar-style="theme"][data-palette="powerbi"] #sidebar .sidebar-header,
[data-sidebar-style="theme"][data-palette="powerbi"] #sidebar .sidebar-brand,
[data-sidebar-style="theme"][data-palette="powerbi"] #sidebar .cat-title-text,
[data-sidebar-style="theme"][data-palette="powerbi"] #sidebar .category-chevron {
    color: #1A202C !important;
}

/* Light Sidebar Variant */
[data-sidebar-style="light"] {
    --sidebar-bg: var(--card-bg) !important;
    --sidebar-hover-bg: var(--primary-light) !important;
    --sidebar-text: var(--text-color) !important;
    --sidebar-active-text: #ffffff !important;
    --sidebar-active-bg: var(--primary-color) !important;
}

[data-sidebar-style="light"] #sidebar .sidebar-header,
[data-sidebar-style="light"] #sidebar .sidebar-brand,
[data-sidebar-style="light"] #sidebar .cat-title-text,
[data-sidebar-style="light"] #sidebar .category-chevron {
    color: var(--text-color) !important;
}

[data-sidebar-style="light"] #sidebar {
    border-right: 1px solid var(--border-color) !important;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transition: background-color 0.3s, color 0.3s;
    margin: 0;
}

/* Layout Structure */
#wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    min-height: 100vh;
    /* Do not clip the fixed mobile offcanvas drawer */
    overflow-x: visible;
}

/* Sidebar Styling */
/* Sidebar Styling */
#sidebar {
    min-width: 260px;
    max-width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: var(--z-sidebar);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

#sidebar ul.components {
    flex: 1 1 auto;
}

#sidebar .sidebar-version-footer {
    flex: 0 0 auto;
    margin-top: 0;
    padding: 0.65rem 0.75rem;
    text-align: center;
    border-top: 1px solid rgba(160, 174, 192, 0.25);
}

#sidebar .sidebar-brand-footer {
    flex: 0 0 auto;
    margin-top: auto;
}

#sidebar .sidebar-customer-logo {
    padding: 0.75rem 0.85rem 0.35rem;
    text-align: center;
}

#sidebar .sidebar-customer-logo-img {
    max-width: 100%;
    max-height: 48px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.92);
    padding: 0.35rem 0.5rem;
}

#sidebar .sidebar-version-badge {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    background: var(--primary-color, #3182CE);
    color: #fff;
}

/* Collapsed sidebar: fully hidden on desktop (no 80px rail residue) */
@media (min-width: 769px) {
    #sidebar.active:not(.sidebar-hover-expanded) {
        min-width: 0 !important;
        max-width: 0 !important;
        width: 0 !important;
        margin-left: 0 !important;
        overflow: hidden !important;
        border-right: none !important;
        opacity: 0;
        pointer-events: none;
    }

    /* Thin left hit-area so hover can reopen flyout */
    #sidebar.active:not(.sidebar-hover-expanded)::before {
        content: '';
        position: fixed;
        top: 64px;
        left: 0;
        bottom: 0;
        width: 12px;
        z-index: calc(var(--z-sidebar, 1030) + 1);
        pointer-events: auto;
    }

    /* Hide text labels and section headers in collapsed mode */
    #sidebar.active:not(.sidebar-hover-expanded) .sidebar-brand span,
    #sidebar.active:not(.sidebar-hover-expanded) ul.components li a span,
    #sidebar.active:not(.sidebar-hover-expanded) .sidebar-section-header {
        display: none !important;
    }

    #sidebar.active:not(.sidebar-hover-expanded) .sidebar-version-footer,
    #sidebar.active:not(.sidebar-hover-expanded) .sidebar-customer-logo {
        display: none !important;
    }
    
    #sidebar.active:not(.sidebar-hover-expanded) ul.components li a {
        justify-content: center !important;
        padding: 12px 5px !important;
        gap: 0 !important;
        border-radius: 8px !important;
    }
    
    #sidebar.active:not(.sidebar-hover-expanded) #sidebarCollapseBtn {
        display: none !important;
    }
}

/* Mobile offcanvas is owned by layout-shell.css (show-mobile + transform). */
/* Legacy #sidebar.active { margin-left: -260px } at ≤768px removed — it fought the drawer. */

#sidebar .sidebar-header {
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#sidebar .sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

#sidebar ul.components {
    padding: 10px 0 24px 0;
    list-style: none;
}

#sidebar ul li {
    padding: 2px 8px;
}

#sidebar ul li a {
    padding: 8px 12px;
    font-size: 0.8125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.15s ease-in-out;
}

#sidebar ul li a i {
    width: 18px;
    text-align: center;
    font-size: 0.92rem;
    opacity: 0.8;
    transition: opacity 0.15s ease, color 0.15s ease;
}

#sidebar ul li a:hover {
    color: var(--primary-color);
    background: var(--sidebar-hover-bg);
}

#sidebar ul li a:hover i {
    opacity: 1;
    color: var(--primary-color);
}

#sidebar ul li.active a {
    color: var(--sidebar-active-text, #ffffff) !important;
    background: var(--sidebar-active-bg, var(--primary-color)) !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
    font-weight: 700;
}

#sidebar ul li.active a i {
    opacity: 1;
    color: var(--sidebar-active-text, #ffffff) !important;
}

/* React Aura Live Badge */
.live-pill-badge {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.18rem 0.5rem;
    border-radius: 9999px;
    background-color: rgba(16, 185, 129, 0.12);
    color: #10b981;
    letter-spacing: 0.02em;
    transition: all 0.15s ease;
}

#sidebar ul li.active .live-pill-badge {
    background-color: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

/* Main Content Area */
#content {
    width: 100%;
    min-width: 0;
    min-height: 100vh;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    padding-top: 72px !important;
    overflow-x: hidden;
}

#content > .content-main {
    flex: 1 1 auto;
    /* Aura AppFooter py-2.5 + text-xs clearance */
    padding-bottom: 3.25rem !important;
}

/* Fixed bottom bar — Aura AppFooter height parity (py-2.5 + text-xs) */
.app-footer.app-footer-fixed {
    position: fixed;
    bottom: 0;
    left: 260px;
    right: 0;
    z-index: var(--z-fixed);
    font-size: 0.75rem; /* Aura text-xs */
    line-height: 1.25;
    padding-top: 0.625rem !important; /* Aura py-2.5 */
    padding-bottom: 0.625rem !important;
    min-height: 2.75rem;
    color: var(--text-color);
    background-color: var(--card-bg);
    border-color: var(--border-color) !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.app-footer.app-footer-fixed .badge {
    font-size: 10px !important;
    padding: 0.125rem 0.5rem !important;
    line-height: 1.25 !important;
}

.app-footer .app-footer-link {
    color: var(--primary-color);
    font-size: 0.75rem !important;
}

@media (min-width: 992px) {
    #sidebar.active ~ #content .app-footer.app-footer-fixed {
        left: 0;
    }
}

@media (max-width: 991.98px) {
    .app-footer.app-footer-fixed {
        left: 0;
    }
}

/* ===================================================================
   AYZREPORT COCKPIT UNIFIED TOPBAR & BRAND (1:1 with React Aura)
   =================================================================== */
.brand-link-unified {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    user-select: none;
    flex-shrink: 0;
}
.brand-squircle-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary-color, #2563eb), #6366f1);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.15rem;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.brand-link-unified:hover .brand-squircle-icon {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.42);
}
.brand-title-line {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    line-height: 1.15;
}
.brand-title-text {
    font-size: 1.08rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text-color);
}
.brand-bi-pill {
    font-size: 0.62rem;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 5px;
    background-color: var(--primary-light, rgba(37, 99, 235, 0.12));
    color: var(--primary-color, #2563eb);
    border: 1px solid var(--border-color);
    letter-spacing: 0.04em;
    line-height: 1;
}
.brand-subtitle-text {
    font-size: 0.68rem;
    font-weight: 500;
    color: #94a3b8;
    line-height: 1.1;
    margin-top: 1px;
}

/* Hide legacy sidebar header box */
#sidebar .sidebar-header {
    display: none !important;
}

/* Fixed Full-Width Top Navbar Header */
.navbar-custom {
    background-color: var(--card-bg) !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 0 1.25rem !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 64px !important;
    min-height: 64px !important;
    z-index: var(--z-fixed) !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05) !important;
    transition: background-color 0.3s, border-color 0.3s;
}

[data-theme="dark"] .navbar-custom {
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5) !important;
}

.navbar-custom .navbar-inner {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    width: 100%;
    min-width: 0;
    height: 100%;
}

.navbar-custom .navbar-start {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 0 1 auto;
    max-width: 540px;
    overflow: hidden;
}

.navbar-custom .navbar-toggle-btn {
    flex: 0 0 auto;
}

/* All viewports: greeting on top, page title underneath (same criteria as mobile) */
.navbar-custom .navbar-titles {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.1rem;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

.nav-greeting {
    display: block;
    order: 1;
    flex: 0 1 auto;
    min-width: 0;
    max-width: clamp(6rem, 12vw, 10rem);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-color);
    opacity: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-custom #navReportTitle.navbar-brand {
    order: 2;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    margin-right: 0;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    opacity: 0.78;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-custom .navbar-end {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 auto;
    min-width: 0;
    max-width: none !important;
    gap: 0.35rem !important;
    /* NEVER overflow:auto here — it clips Bootstrap dropdown menus under the 64px bar */
    overflow: visible !important;
}

.navbar-custom,
.navbar-custom .navbar-inner,
.navbar-custom .dropdown {
    overflow: visible !important;
}

.navbar-custom .dropdown-menu {
    z-index: var(--z-popover) !important;
}

/* Desktop Collapsed Sidebar Navbar Adjustment */
@media (min-width: 992px) {
    #sidebar.active ~ #content .navbar-custom {
        left: 0 !important;
    }
}

/* Tablet */
@media (max-width: 991.98px) {
    .navbar-custom {
        left: 0 !important;
        padding: 0 10px !important;
    }
}

/* Phone / small: tighter widths; same stack order (greeting → title) */
@media (max-width: 767.98px) {
    .navbar-custom {
        padding: 0 8px !important;
        min-height: 64px;
    }

    .navbar-custom .navbar-inner {
        align-items: center;
        gap: 0.35rem;
    }

    .navbar-custom .navbar-start {
        align-items: center;
        padding-top: 0;
        flex: 1 1 0;
        min-width: 0;
    }

    .navbar-custom .navbar-titles {
        overflow: hidden;
        min-width: 0;
    }

    .nav-greeting {
        max-width: 100%;
        font-size: 1.05rem;
    }

    .navbar-custom #navReportTitle.navbar-brand {
        max-width: 100%;
        font-size: 0.78rem;
    }

    .navbar-custom .navbar-end {
        padding-top: 0;
        flex-wrap: nowrap;
        max-width: none;
        flex: 0 0 auto;
        gap: 0.2rem !important;
    }

    .navbar-custom #navReportTitle.navbar-brand,
    #navReportTitle {
        border-left-width: 3px;
        padding-left: 8px;
    }

    .navbar-user-btn.dropdown-toggle::after {
        margin-left: 0.25rem;
    }
}

@media (max-width: 575.98px) {
    .nav-greeting {
        font-size: 0.98rem;
    }

    .navbar-custom #navReportTitle.navbar-brand {
        font-size: 0.74rem;
    }
}

/* Dashboard KPI grid — 2 cols from the smallest phone; no empty slots when widgets hidden */
.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    align-items: stretch;
}

@media (min-width: 576px) {
    .dashboard-kpi-grid {
        gap: 1rem;
    }
}

@media (min-width: 992px) {
    .dashboard-kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .dashboard-kpi-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.dashboard-kpi-grid > .dashboard-widget {
    min-width: 0;
}

.dashboard-kpi-grid > .dashboard-widget.d-none {
    display: none !important;
}

.dashboard-kpi-grid .card-custom {
    margin-bottom: 0;
    height: 100%;
}

/* Card Styling */
.card-custom {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color); /* Premium theme accent indicator */
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    margin-bottom: 24px;
    transition: transform 0.2s, box-shadow 0.2s, border-left-color 0.3s;
}

.card-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
}

.kpi-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #718096;
    letter-spacing: 0.04em;
}

.kpi-value {
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 2px;
    margin-bottom: 2px;
}

.kpi-icon {
    font-size: 1.25rem;
    opacity: 0.85;
}

.kpi-card-themed.kpi-card-compact {
    min-height: 0;
}

.kpi-card-themed.kpi-card-compact .kpi-title {
    font-size: 0.75rem;
}

.kpi-card-themed.kpi-card-compact .kpi-value,
.kpi-card-themed.kpi-card-compact h5.kpi-value {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.kpi-card-themed.kpi-card-compact small.text-muted {
    font-size: 0.7rem;
}

/* Color Coding utilities */
.text-inflow { color: var(--finance-inflow) !important; }
.text-outflow { color: var(--finance-outflow) !important; }
.text-warning { color: var(--finance-warning) !important; }
.bg-inflow-light { background-color: rgba(72, 187, 120, 0.1) !important; }
.bg-outflow-light { background-color: rgba(229, 62, 62, 0.1) !important; }

/* Table Styling */
.table-custom {
    background-color: var(--card-bg);
}

.table-custom th {
    background-color: rgba(0, 0, 0, 0.02);
    color: var(--text-color);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

/* Floating AI Chat Assistant styling (Sağ Alt Konum + Hover Genişleyen Etiket) */
#ai-chat-widget {
    position: fixed;
    bottom: 88px;
    right: 25px;
    z-index: var(--z-toast);
    user-select: none;
    touch-action: none;
}

#ai-chat-bubble {
    height: 56px;
    min-width: 56px;
    padding: 0 16px;
    border-radius: 50px;
    background: linear-gradient(135deg, #3182CE 0%, #4FD1C5 100%);
    box-shadow: 0 6px 20px rgba(49, 130, 206, 0.45);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#ai-chat-bubble .ai-label {
    max-width: 0;
    opacity: 0;
    white-space: nowrap;
    transition: max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, margin 0.3s ease;
    display: inline-block;
}

#ai-chat-bubble:hover {
    padding: 0 22px;
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 10px 28px rgba(49, 130, 206, 0.6);
}

#ai-chat-bubble:hover .ai-label {
    max-width: 120px;
    opacity: 1;
    margin-left: 10px;
}

#ai-chat-bubble i {
    color: white;
}

#ai-chat-window {
    width: 380px;
    height: 500px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
    position: absolute;
    bottom: 70px;
    right: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

#ai-chat-window.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

@media (max-width: 768px) {
    #ai-chat-widget {
        right: 15px;
        bottom: 15px;
    }
    #ai-chat-window {
        width: calc(100vw - 30px);
        right: 0;
    }
}

.ai-chat-header {
    background: linear-gradient(135deg, #1A202C 0%, #2D3748 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-chat-footer {
    padding: 12px 15px;
    border-top: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.01);
}

/* Chat bubble entries */
.chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.chat-msg.user {
    background-color: var(--primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chat-msg.assistant {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-color);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

[data-theme="dark"] .chat-msg.assistant {
    background-color: rgba(255, 255, 255, 0.05);
}

.theme-toggle-btn {
    cursor: pointer;
    border: none;
    background: none;
    color: var(--text-color);
    font-size: 1.2rem;
    padding: 5px;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Premium CashFlow Calendar & Insights Visualizer Styles */
.cashflow-insights {
    margin-bottom: 24px;
    display: grid;
    gap: 20px;
    /* Above sticky report thead/toolbar so day popovers are never crushed */
    position: relative;
    z-index: var(--z-report-filters);
}
.cashflow-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    padding: 12px 16px;
}
.segmented {
    display: flex;
    gap: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    border-radius: 8px;
    padding: 4px;
}
.segmented button {
    border: 0;
    background: transparent;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-color);
    transition: all 0.2s;
}
.segmented button.active {
    background: var(--primary-color);
    color: #fff;
}
.flow-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.flow-summary button {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    background: linear-gradient(180deg, var(--card-bg), var(--bg-color));
    text-align: left;
    color: var(--text-color);
    transition: all 0.2s;
    width: 100%;
}
.flow-summary button:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}
.flow-summary span {
    display: block;
    color: var(--sidebar-text);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.flow-summary strong {
    display: block;
    margin-top: 6px;
    font-size: 1.2rem;
    font-weight: 700;
}
.flow-visual {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    padding: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}
.flow-bars {
    height: 132px;
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    gap: 8px;
    align-items: end;
    min-width: 580px;
}
.flow-bar {
    height: 112px;
    display: grid;
    grid-template-rows: 1fr 18px;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    align-items: end;
}
.flow-bar span {
    grid-column: 1/3;
    color: var(--sidebar-text);
    font-size: 0.7rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.flow-bar b, .flow-legend b {
    display: block;
    background: var(--finance-inflow, #0f766e);
    border-radius: 6px 6px 0 0;
}
.flow-bar i, .flow-legend i {
    display: block;
    background: var(--finance-outflow, #b91c1c);
    border-radius: 6px 6px 0 0;
}
.flow-legend {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    color: var(--sidebar-text);
    font-size: 0.8rem;
    margin-top: 8px;
}
.flow-legend span {
    display: flex;
    gap: 6px;
    align-items: center;
}
.flow-legend b, .flow-legend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}
.flow-calendar {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
    width: 100%;
}
.flow-calendar.week {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.flow-calendar.month {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.flow-day-wrap {
    position: relative;
    width: 100%;
    min-width: 0;
}
.flow-day {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: left;
    color: var(--text-color);
    min-height: 78px;
    transition: all 0.2s;
    width: 100%;
    box-sizing: border-box;
    z-index: 1;
    cursor: pointer;
}
.flow-day:hover,
.flow-day:focus-visible {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    outline: none;
}
.flow-day-view-icon {
    font-size: 0.72rem;
    opacity: 0.85;
}
.flow-day:hover .flow-day-view-icon,
.flow-day:focus-visible .flow-day-view-icon {
    opacity: 1;
}
.flow-day strong,
.flow-day .flow-day-label {
    font-size: 0.8rem;
    font-weight: 600;
}
.flow-day span {
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}
.flow-day .in {
    color: var(--finance-inflow, #0f766e);
}
.flow-day .out {
    color: var(--finance-outflow, #b91c1c);
}
.flow-day small {
    color: var(--sidebar-text);
    font-size: 0.7rem;
}
.flow-day-metrics .in,
.flow-day-metrics .out {
    font-size: 0.72rem;
    line-height: 1.25;
}
.flow-day-metrics small {
    font-size: 0.7rem;
    line-height: 1.25;
}

/* Legacy popover fully retired — details open in #flowDayDetailModal */
.flow-popover {
    display: none !important;
}

.flow-day-detail-list .flow-day-detail-ul,
#flowDayDetailBody .flow-day-detail-ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}
.flow-day-detail-list li,
#flowDayDetailBody li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 12px;
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    font-size: 0.82rem;
}
.flow-day-detail-list li:first-child,
#flowDayDetailBody li:first-child {
    border-top: 0;
    padding-top: 0;
}
.flow-day-detail-list li b,
#flowDayDetailBody li b {
    font-size: 0.82rem;
    color: var(--text-color);
}
.flow-day-detail-list li span,
#flowDayDetailBody li span {
    grid-column: 1/2;
    color: var(--sidebar-text);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.flow-day-detail-list li small,
#flowDayDetailBody li small {
    grid-column: 1/2;
    color: var(--text-color);
    font-size: 0.75rem;
}
.flow-day-detail-list li strong,
#flowDayDetailBody li strong {
    grid-row: 1/4;
    grid-column: 2/3;
    align-self: center;
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.flow-day-detail-list li strong.in,
#flowDayDetailBody li strong.in {
    color: var(--finance-inflow, #0f766e);
}
.flow-day-detail-list li strong.out,
#flowDayDetailBody li strong.out {
    color: var(--finance-outflow, #b91c1c);
}

@media(max-width: 768px) {
    .flow-calendar {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
        gap: 8px !important;
    }
    .flow-summary {
        grid-template-columns: 1fr !important;
    }
    .flow-day {
        min-height: 72px;
        padding: 7px 8px;
    }
}

@media(max-width: 480px) {
    .flow-calendar {
        grid-template-columns: 1fr !important;
    }
}

/* Premium Debt Aging (FIFO) Insights Styles */
.aging-insights .cashflow-toolbar {
    align-items: flex-start;
    flex-wrap: wrap;
}
.aging-insights .cashflow-toolbar > div:first-child span {
    display: block;
    color: var(--sidebar-text);
    font-size: 0.75rem;
    margin-top: 4px;
}
.aging-summary {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) repeat(5, minmax(150px, 1fr));
    gap: 10px;
}
.aging-total, .aging-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    padding: 14px;
    text-align: left;
    min-height: 104px;
    transition: all 0.2s;
}
.aging-total {
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary-color) 12%, var(--card-bg)), var(--card-bg));
}
.aging-total span, .aging-card span {
    display: block;
    color: var(--sidebar-text);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.aging-total strong, .aging-card strong {
    display: block;
    margin-top: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.aging-total small, .aging-card small {
    display: block;
    margin-top: 6px;
    color: var(--sidebar-text);
    font-size: 0.75rem;
}
.aging-card {
    cursor: pointer;
    border-top: 4px solid var(--aging);
}
.aging-card:hover {
    border-color: var(--aging);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.aging-card i {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4px;
    background: var(--aging);
    display: block;
}
.aging-visual .flow-bar b, .flow-bar.aging b {
    background: linear-gradient(180deg, #ef4444, #f59e0b);
}
.aging-day {
    border-left: 4px solid color-mix(in srgb, #ef4444 76%, var(--border-color)) !important;
}

@media(max-width: 1100px) {
    .aging-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}
@media(max-width: 640px) {
    .aging-summary {
        grid-template-columns: 1fr !important;
    }
}

/* Apply CSS Variables to Bootstrap Primary Classes */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #fff !important;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--primary-hover, var(--primary-color)) !important;
    border-color: var(--primary-hover, var(--primary-color)) !important;
}
.btn-outline-primary {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}
.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #fff !important;
}
.text-primary {
    color: var(--primary-color) !important;
}
.bg-primary {
    background-color: var(--primary-color) !important;
}
.border-primary {
    border-color: var(--primary-color) !important;
}
.spinner-border.text-primary {
    border-color: var(--primary-color) !important;
    border-right-color: transparent !important;
}.col-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 105;
}
.col-resize-handle:hover {
    background-color: var(--primary-color);
    opacity: 0.6;
}
.table-responsive {
    overflow-x: auto !important;
    overflow-y: visible !important;
}
.table-custom th {
    position: relative;
    user-select: none;
    padding-right: 36px !important;
}
/* Hide DataTables default overlapping sorting arrows */
.table-custom th.sorting:before,
.table-custom th.sorting:after,
.table-custom th.sorting_asc:before,
.table-custom th.sorting_asc:after,
.table-custom th.sorting_desc:before,
.table-custom th.sorting_desc:after {
    content: "" !important;
    display: none !important;
}
/* Always reserve sort-indicator width so click does not shift columns */
.table-custom th.sorting .column-title::after,
.table-custom th.sorting_asc .column-title::after,
.table-custom th.sorting_desc .column-title::after {
    content: " ▲";
    display: inline-block;
    min-width: 1.1em;
    margin-left: 4px;
    font-size: 0.65rem;
    line-height: 1;
    text-align: left;
    vertical-align: middle;
}
.table-custom th.sorting .column-title::after {
    opacity: 0.28;
    color: var(--text-muted, #718096);
}
.table-custom th.sorting_asc .column-title::after {
    content: " ▲";
    opacity: 1;
    color: var(--primary-color);
}
.table-custom th.sorting_desc .column-title::after {
    content: " ▼";
    opacity: 1;
    color: var(--primary-color);
}

/* ==========================================
   V4 EXTENDED COLOR PALETTE OVERRIDES
   ========================================== */

/* 1. Form Inputs Focus States */
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.25rem var(--primary-light) !important;
}

/* 2. Sidebar Hover & Active Glow Effects */
#sidebar ul li.active a {
    background: var(--sidebar-active-bg) !important;
    color: var(--sidebar-active-text) !important;
    box-shadow: 0 4px 15px var(--primary-light) !important;
}
#sidebar ul li a i {
    transition: color 0.2s ease-in-out;
}
#sidebar ul li a:hover i {
    color: var(--primary-color) !important;
}

/* 3. General Anchors Hover Transition */
a {
    color: var(--primary-color);
    text-decoration: none;
}
a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* 4. Scrollbars Hover Glows */
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color) !important;
    opacity: 0.8;
}

/* 5. Flatpickr Calendar Theming Adjustments */
.flatpickr-day.selected, 
.flatpickr-day.startRange, 
.flatpickr-day.endRange, 
.flatpickr-day.selected.inRange, 
.flatpickr-day.startRange.inRange, 
.flatpickr-day.endRange.inRange, 
.flatpickr-day.selected:focus, 
.flatpickr-day.startRange:focus, 
.flatpickr-day.endRange:focus, 
.flatpickr-day.selected:hover, 
.flatpickr-day.startRange:hover, 
.flatpickr-day.endRange:hover, 
.flatpickr-day.prevMonthDay.selected, 
.flatpickr-day.nextMonthDay.selected {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
}
.flatpickr-day.selected.startRange + .endRange:not(.startRange), 
.flatpickr-day.startRange.startRange + .endRange:not(.startRange), 
.flatpickr-day.endRange.startRange + .endRange:not(.startRange) {
    box-shadow: -5px 0 0 var(--primary-color) !important;
}
.flatpickr-day.week.selected {
    box-shadow: 0 12px 14px var(--primary-light) !important;
}
.flatpickr-months .flatpickr-month {
    color: var(--text-color) !important;
    background: var(--card-bg, #ffffff) !important;
    fill: var(--text-color) !important;
    font-weight: 700 !important;
}
.flatpickr-months {
    background: var(--card-bg, #ffffff) !important;
}
.flatpickr-current-month {
    color: var(--text-color) !important;
    font-weight: 700 !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months {
    font-weight: 700 !important;
    color: var(--text-color) !important;
    background: transparent !important;
}
.flatpickr-current-month input.cur-year {
    font-weight: 700 !important;
    color: var(--text-color) !important;
    background: transparent !important;
}
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    color: var(--text-color) !important;
    fill: var(--text-color) !important;
}
.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover,
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    color: var(--text-color) !important;
    fill: var(--text-color) !important;
}
.flatpickr-day.today {
    border-color: var(--primary-color) !important;
}
.flatpickr-day.today:hover {
    background: var(--primary-light, rgba(0, 0, 0, 0.06)) !important;
    color: var(--text-color) !important;
}

/* 6. Dynamic Header summary accent indicator */
#reportHeaderSummary {
    border-left: 3px solid var(--primary-color) !important;
    padding-left: 10px !important;
}

/* 7. KPI Icon and Hover Overrides */
.kpi-icon-wrapper {
    background-color: var(--primary-light) !important;
    color: var(--primary-color) !important;
}
.kpi-card-themed {
    transition: all 0.25s ease-in-out;
}
.kpi-card-themed:hover {
    border-left-color: var(--primary-hover) !important;
}
.kpi-card-themed small.text-muted {
    margin-bottom: 0 !important;
}
.card-custom > .card-header {
    padding-bottom: 0.35rem;
}
.card-custom > .card-header .h6,
.card-custom > .card-header h6 {
    margin-bottom: 0;
}

/* Drag & Drop Visuals and Accordion Header Styles */
.category-chevron {
    transition: transform 0.3s ease-in-out;
}
.sidebar-section-header.collapsed .category-chevron {
    transform: rotate(-90deg); /* points left/down when collapsed */
}
.draggable-menu-item {
    cursor: grab;
    user-select: none;
}
.draggable-menu-item.dragging {
    opacity: 0.4;
    cursor: grabbing;
}
.sidebar-category-list {
    min-height: 20px; /* gives an empty category a drop zone */
    transition: background-color 0.2s ease;
    display: none; /* accordion: closed until opened / active report group */
}
.sidebar-category-list.is-open {
    display: block;
}
.sidebar-category-list.drag-over {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-radius: 8px;
    outline: 2px dashed var(--primary-color);
}
[data-theme="dark"] .sidebar-category-list.drag-over {
    background-color: rgba(255, 255, 255, 0.02) !important;
}
/* Mini sidebar: keep accordion state — do not force every group open */
#sidebar.active .sidebar-category-list:not(.is-open) {
    display: none !important;
}
#sidebar.active .sidebar-category-list.is-open {
    display: block !important;
    height: auto !important;
}
#sidebar.active .category-chevron {
    display: none !important;
}

/* Category Header styling: subtle slate, bold, uppercase tracking matching React Aura */
.sidebar-section-header {
    font-size: 0.6875rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.06em !important;
    color: var(--sidebar-header-text, #94a3b8) !important;
    text-transform: uppercase;
    transition: color 0.2s ease;
    user-select: none;
    padding: 10px 14px 4px 14px;
}
.sidebar-section-header .category-chevron {
    color: var(--sidebar-header-text, #94a3b8) !important;
    font-size: 0.65rem;
    transition: transform 0.2s ease, color 0.2s ease;
}
.sidebar-section-header:hover .category-chevron {
    color: var(--primary-color) !important;
}

/* ==========================================
   EXTENDED PALETTE THEME COLOR ENHANCEMENTS
   ========================================== */

/* 1. Global Button Theme Overrides */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    transition: all 0.2s ease-in-out !important;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--primary-hover, var(--primary-color)) !important;
    border-color: var(--primary-hover, var(--primary-color)) !important;
    box-shadow: 0 0 0 0.25rem var(--primary-light) !important;
    color: #ffffff !important;
}
.btn-outline-primary {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    font-weight: 600 !important;
    transition: all 0.2s ease-in-out !important;
}
.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
}

/* 2. Top Navbar Border Accent Indicator */
.navbar-custom {
    border-bottom: 2px solid var(--primary-light) !important;
}

/* 3. Table Pagination Theme Overrides */
.page-item.active .page-link {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
}
.page-link {
    color: var(--primary-color) !important;
    transition: all 0.2s;
}
.page-link:hover {
    color: var(--primary-hover) !important;
    background-color: var(--primary-light) !important;
}

/* 4. Form Controls Focused/Checked State Theme Indicator */
.form-check-input:checked {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}
.form-check-input:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.25rem var(--primary-light) !important;
}

/* 5. DataTables Buttons (Excel, PDF, Copy, Print) Styling Integration */
.dt-buttons .btn {
    background-color: transparent !important;
    color: var(--primary-color) !important;
    border: 1px solid var(--primary-color) !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
}
.dt-buttons .btn:hover {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
    border-color: var(--primary-color) !important;
}

/* 6. Page Title Heading Left Border Accents (scoped — avoid leaking onto every h2.fw-bold card title) */
.page-title,
.content-header h2,
.main-title h2,
#navReportTitle {
    border-left: 4px solid var(--primary-color);
    padding-left: 12px;
    transition: border-left-color 0.3s ease;
}

h4.page-title {
    border-left: 4px solid var(--primary-color);
    padding-left: 12px;
}

/* ==== DARK MODE GLOBAL OVERRIDES FOR READABILITY ==== */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] .h1,
[data-theme="dark"] .h2,
[data-theme="dark"] .h3,
[data-theme="dark"] .h4,
[data-theme="dark"] .h5,
[data-theme="dark"] .h6 {
    color: var(--text-color) !important;
}

/* Ensure default KPI card value text color is readable */
[data-theme="dark"] .kpi-value {
    color: #ffffff !important;
}

/* Overriding text inflow and outflow to be brighter in dark mode for better contrast */
[data-theme="dark"] .text-inflow {
    color: #34D399 !important; /* Brighter Emerald Green */
}
[data-theme="dark"] .text-outflow {
    color: #FB7185 !important; /* Brighter Ruby Red */
}
[data-theme="dark"] .text-warning {
    color: #FBBF24 !important; /* Brighter Orange/Yellow */
}
[data-theme="dark"] .text-success {
    color: #34D399 !important;
}
[data-theme="dark"] .text-danger {
    color: #FB7185 !important;
}

/* Brighten KPI titles and secondary/muted text labels in dark mode */
[data-theme="dark"] .kpi-title {
    color: #94A3B8 !important; /* Slate Gray */
}
[data-theme="dark"] .text-muted,
[data-theme="dark"] small.text-muted,
[data-theme="dark"] .card-custom small {
    color: #94A3B8 !important; /* Ensure descriptive texts are fully readable */
}

/* Table styling for dark mode */
[data-theme="dark"] .table {
    --bs-table-color: var(--text-color) !important;
    --bs-table-bg: var(--card-bg) !important;
    --bs-table-border-color: var(--border-color) !important;
    color: var(--text-color) !important;
}
[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
    color: var(--text-color) !important;
    background-color: var(--card-bg) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(255, 255, 255, 0.02) !important;
    color: var(--text-color) !important;
}
[data-theme="dark"] .table-hover > tbody > tr:hover > * {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
}

/* Card custom container styling in dark mode */
[data-theme="dark"] .card-custom {
    background-color: var(--card-bg) !important;
    border-color: var(--border-color) !important;
}

/* Form inputs & controls in dark mode */
[data-theme="dark"] label,
[data-theme="dark"] .form-label,
[data-theme="dark"] .form-check-label {
    color: #CBD5E1 !important;
}

[data-theme="dark"] .form-text,
[data-theme="dark"] .text-muted,
[data-theme="dark"] small.text-muted {
    color: #94A3B8 !important;
}

[data-theme="dark"] .text-color {
    color: #F1F5F9 !important;
}

[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] .form-select::placeholder,
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #64748B !important;
    opacity: 0.8 !important;
}

[data-theme="dark"] .input-group-text {
    background-color: #1E293B !important;
    color: #94A3B8 !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .alert-info {
    background-color: rgba(56, 189, 248, 0.12) !important;
    color: #7DD3FC !important;
    border-color: rgba(56, 189, 248, 0.25) !important;
}

[data-theme="dark"] .alert-info a {
    color: #38BDF8 !important;
}

[data-theme="dark"] .alert-warning {
    background-color: rgba(251, 146, 60, 0.12) !important;
    color: #FDBA74 !important;
    border-color: rgba(251, 146, 60, 0.25) !important;
}

[data-theme="dark"] .alert-success {
    background-color: rgba(52, 211, 153, 0.12) !important;
    color: #6EE7B7 !important;
    border-color: rgba(52, 211, 153, 0.25) !important;
}

[data-theme="dark"] .alert-danger {
    background-color: rgba(248, 113, 113, 0.12) !important;
    color: #FCA5A5 !important;
    border-color: rgba(248, 113, 113, 0.25) !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .dataTables_filter input,
[data-theme="dark"] .dataTables_length select {
    background-color: #0F172A !important;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color) !important;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .dataTables_filter input:focus {
    background-color: #0F172A !important;
    color: #ffffff !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.25rem var(--primary-light) !important;
}

/* Dropdowns in dark mode */
[data-theme="dark"] .dropdown-menu {
    background-color: var(--card-bg) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color) !important;
}
[data-theme="dark"] .dropdown-item {
    color: var(--text-color) !important;
}
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background-color: var(--sidebar-hover-bg) !important;
    color: #ffffff !important;
}

/* DataTables pagination in dark mode */
[data-theme="dark"] .page-link {
    background-color: var(--card-bg) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .page-link:hover {
    background-color: var(--sidebar-hover-bg) !important;
}
[data-theme="dark"] .page-item.disabled .page-link {
    background-color: var(--card-bg) !important;
    color: #475569 !important;
    border-color: var(--border-color) !important;
}

/* Modals in dark mode */
[data-theme="dark"] .modal-content {
    background-color: var(--card-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: var(--border-color) !important;
}

/* Breadcrumbs / Info tags in dark mode */
[data-theme="dark"] .breadcrumb-item a {
    color: var(--primary-color) !important;
}
[data-theme="dark"] .breadcrumb-item.active {
    color: #94A3B8 !important;
}

/* Make web report table headers use the active palette's primary color by default */
#reportDataTable thead th,
.table-custom thead th {
    background-color: var(--primary-color) !important;
    color: var(--sidebar-active-text, #ffffff) !important;
}

/* Premium Report Header Summary Bar & Responsive Chips */
.report-header-summary,
#reportHeaderSummary {
    width: 100%;
    min-width: 0;
    align-self: stretch;
}

.report-summary-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
}

.summary-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.82rem;
    white-space: nowrap;
    transition: all 0.2s;
}

.summary-chip.record-count-chip {
    background: rgba(49, 130, 206, 0.08);
    border-color: rgba(49, 130, 206, 0.2);
    font-weight: 600;
}

.chip-label {
    font-size: 0.78rem;
}

.chip-value {
    font-size: 0.85rem;
    font-weight: 700;
}

/* Phone / small tablet: forced 2-column totals (avoid single-column crush) */
@media (max-width: 767.98px) {
    .report-page-header {
        width: 100%;
    }

    .report-header-summary,
    #reportHeaderSummary {
        width: 100% !important;
        max-width: 100%;
        flex: 1 1 100%;
    }

    .report-summary-bar {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 8px;
    }

    .summary-chip {
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        gap: 2px;
        padding: 8px 10px;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        white-space: normal;
    }

    .summary-chip.record-count-chip {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        text-align: center;
        white-space: nowrap;
    }

    .chip-label {
        font-size: 0.7rem;
        line-height: 1.25;
        word-break: break-word;
    }

    .chip-value {
        font-size: 0.82rem;
        line-height: 1.2;
        word-break: break-word;
    }
}

@media (max-width: 575.98px) {
    .summary-chip {
        padding: 7px 8px;
    }

    .chip-label {
        font-size: 0.68rem;
    }

    .chip-value {
        font-size: 0.78rem;
    }
}
