:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;

    --body-bg: #f3f4f6;
    --text-color: #1e293b;
    --text-muted: #64748b;

    --navbar-height: 60px;
    --navbar-bg: #ffffff;
    --navbar-border: #e2e8f0;

    --card-bg: #ffffff;
    --card-radius: 12px;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

    --transition-speed: 0.3s;
}

/* Base Styles */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-color);
    overflow-x: hidden;
    margin: 0;
    padding-top: var(--navbar-height);
    /* Account for fixed navbar */
}

a {
    text-decoration: none;
}

/* Modern Navbar */
.modern-navbar {
    background-color: var(--navbar-bg);
    border-bottom: 1px solid var(--navbar-border);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    height: var(--navbar-height);
    padding: 0;
    transition: background-color 0.3s, border-color 0.3s;
}

.brand-icon-wrapper {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-color);
    letter-spacing: -0.5px;
}

/* Navigation Links */
.main-nav-links .nav-link {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.4rem 0.85rem !important;
    border-radius: 0.5rem;
    transition: all 0.2s;
    margin-right: 0.15rem;
    position: relative;
}

.main-nav-links .nav-link:hover {
    color: var(--primary-color);
    background-color: #f8fafc;
}

.main-nav-links .nav-link.active {
    color: var(--primary-color);
    background-color: #eff6ff;
    font-weight: 600;
}

/* Dropdowns */
.dropdown-menu {
    border: none;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-radius: 0.75rem;
    padding: 0.5rem;
    margin-top: 0.5rem;
    min-width: 200px;
}

.dropdown-item {
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.9rem;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: #f1f5f9;
    color: var(--primary-color);
}

/* Multi-level Dropdown */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu>.dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -0.5rem;
    margin-left: 0.5rem;
    display: none;
}

.dropdown-submenu:hover>.dropdown-menu {
    display: block;
}

/* User & System Menu */
.icon-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f5f9;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.nav-link:hover .icon-circle {
    background-color: #e0e7ff;
}

.user-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
    background: linear-gradient(135deg, #4f46e5 0%, #818cf8 100%);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

/* Hamburger Icon */
.hamburger-icon {
    width: 24px;
    height: 20px;
    position: relative;
    transform: rotate(0deg);
    transition: .5s ease-in-out;
    cursor: pointer;
    display: block;
}

.hamburger-icon span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: var(--text-color);
    border-radius: 2px;
    opacity: 1;
    left: 0;
    transform: rotate(0deg);
    transition: .25s ease-in-out;
}

.hamburger-icon span:nth-child(1) {
    top: 0px;
}

.hamburger-icon span:nth-child(2) {
    top: 9px;
}

.hamburger-icon span:nth-child(3) {
    top: 18px;
}

.navbar-toggler[aria-expanded="true"] .hamburger-icon span:nth-child(1) {
    top: 9px;
    transform: rotate(135deg);
}

.navbar-toggler[aria-expanded="true"] .hamburger-icon span:nth-child(2) {
    opacity: 0;
    left: -60px;
}

.navbar-toggler[aria-expanded="true"] .hamburger-icon span:nth-child(3) {
    top: 9px;
    transform: rotate(-135deg);
}

/* Mobile Responsive */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background-color: var(--navbar-bg);
        position: absolute;
        top: var(--navbar-height);
        left: 0;
        right: 0;
        padding: 1rem;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        max-height: calc(100vh - var(--navbar-height));
        overflow-y: auto;
        border-bottom: 1px solid var(--navbar-border);
    }

    .main-nav-links .nav-link {
        padding: 0.65rem 1rem !important;
        margin: 0.2rem 0;
    }

    .right-nav-links {
        align-items: flex-start !important;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--navbar-border);
    }

    .right-nav-links > .nav-item {
        width: 100%;
        position: relative;
    }

    .right-nav-links .nav-link {
        padding: 0.65rem 1rem !important;
        justify-content: flex-start !important;
    }

    /* Mobile Dropdown – accordion style for main nav submenus */
    .main-nav-links .dropdown-menu {
        border: none;
        box-shadow: none;
        padding-left: 1.5rem;
        margin-top: 0;
        background-color: transparent;
    }

    /* Right-nav dropdowns: in-flow accordion style – not clipped by scroll container */
    .right-nav-links .dropdown-menu {
        position: static;
        background-color: var(--card-bg);
        border: 1px solid var(--navbar-border);
        border-radius: 0.75rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        padding: 0.5rem;
        margin: 0.25rem 0 0.5rem 1rem;
        min-width: 160px;
    }

    .dropdown-submenu>.dropdown-menu {
        position: static;
        margin-left: 0;
        display: none;
    }

    .dropdown-submenu>.dropdown-menu.show {
        display: block;
    }
}

/* Card Styling for Dashboard & Grids */
.card {
    background-color: var(--card-bg);
    border-radius: var(--card-radius);
    border: none;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
}

.card-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 16px;
    background-color: var(--primary-color);
    border-radius: 2px;
    margin-right: 0.75rem;
}

/* DevExtreme Overrides for Modern Look */
.dx-datagrid,
.dx-widget {
    font-family: 'Inter', sans-serif !important;
}

.dx-datagrid-headers {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid #e2e8f0;
}

.dx-datagrid-rowsview .dx-row {
    border-bottom: 1px solid #f1f5f9;
}

.dx-datagrid-rowsview .dx-row.dx-row-alt {
    background-color: #f8fafc;
}

.dx-datagrid-rowsview .dx-row:hover {
    background-color: #f1f5f9;
}

.dx-header-row>td {
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.dx-data-row>td {
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    vertical-align: middle;
}

/* Chat Specifics (Adapting old chat styles) */
.chat-container {
    height: 100%;
    background-color: transparent;
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: row;
    position: relative;
}

/* Chat Sidebar (Enterprise Light Theme) */
.chat-sidebar {
    width: 320px;
    background-color: #f8fafc;
    /* Slate 50 */
    border-right: 1px solid #e2e8f0;
    /* Slate 200 */
    color: #334155;
    /* Slate 700 */
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.3s ease, margin-left 0.3s ease;
    z-index: 10;
    flex-shrink: 0;
    border-radius: var(--card-radius) 0 0 var(--card-radius);
}

.chat-sidebar .sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-sidebar .sidebar-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    /* Slate 800 */
}

.sidebar-header-buttons {
    display: flex;
    gap: 0.5rem;
}

.sidebar-search {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-search input {
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    /* Slate 300 */
    color: #1e293b;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
}

.sidebar-search input::placeholder {
    color: #94a3b8;
    /* Slate 400 */
}

.sidebar-search input:focus {
    background-color: #ffffff;
    border-color: #3b82f6;
    /* Blue 500 */
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-history-item {
    padding: 0.75rem 1rem;
    margin: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: transparent;
    border: 1px solid transparent;
    color: #334155;
}

.chat-history-item:hover {
    background-color: #f1f5f9;
    /* Slate 100 */
    transform: translateX(4px);
}

.chat-history-item.active {
    background-color: #eff6ff;
    /* Blue 50 */
    border-color: #bfdbfe;
    /* Blue 200 */
    color: #1e40af;
    /* Blue 800 */
}

/* .chat-history-item-header removed - using Bootstrap flex utilities */

.chat-history-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: inherit;
    /* truncation handled by text-truncate class */
}

.chat-history-item-time {
    font-size: 0.75rem;
    color: #94a3b8;
    /* Slate 400 */
}

/* Custom overrides for the delete button to make it cleaner */
.chat-delete-btn {
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.chat-history-item:hover .chat-delete-btn {
    opacity: 1;
}



/* Chat Main Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    height: 100%;
    min-width: 0;
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
    display: none;
}

.sidebar-toggle:hover {
    background-color: #f1f5f9;
    color: var(--primary-color);
}

.chat-header .chat-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.chat-content {
    flex: 1;
    overflow: hidden;
    background-color: #f8fafc;
}

.dx-chat-message-box {
    background-color: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 1rem;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.sidebar-close {
    display: none;
}

/* Mobile Responsive */
@media (max-width: 1280px) {
    .chat-sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        border-radius: var(--card-radius) 0 0 var(--card-radius);
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    }

    .chat-sidebar.active {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .sidebar-close {
        display: inline-block;
    }

    .chat-main {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .chat-sidebar {
        width: 280px;
    }

    .chat-header {
        padding: 1rem;
    }

    .chat-history-item {
        padding: 0.75rem;
    }
}

/* Dark Theme Variables Override */
body.dark-theme {
    --body-bg: #0f172a;
    /* Slate 900 */
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;

    --navbar-bg: #1e293b;
    --navbar-border: #334155;

    --card-bg: #1e293b;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

body.dark-theme .modern-navbar {
    background-color: var(--navbar-bg);
    border-bottom-color: var(--navbar-border);
}

body.dark-theme .brand-text {
    color: #fff;
}

body.dark-theme .main-nav-links .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

body.dark-theme .main-nav-links .nav-link.active {
    background-color: rgba(79, 70, 229, 0.15);
}

body.dark-theme .hamburger-icon span {
    background: #fff;
}

body.dark-theme .card-title {
    color: #fff;
}

body.dark-theme .icon-circle {
    background-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .nav-link:hover .icon-circle {
    background-color: rgba(255, 255, 255, 0.2);
}

body.dark-theme .dropdown-menu {
    background-color: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Keep main-nav mobile accordions transparent in dark theme (higher specificity than above) */
@media (max-width: 991.98px) {
    body.dark-theme .main-nav-links .dropdown-menu {
        background-color: transparent;
        border: none;
        box-shadow: none;
    }

    body.dark-theme .right-nav-links .dropdown-menu {
        background-color: #1e293b;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
}

body.dark-theme .dropdown-item {
    color: #e2e8f0;
}

body.dark-theme .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

body.dark-theme .dx-datagrid {
    background-color: transparent !important;
    color: #e2e8f0 !important;
}

body.dark-theme .dx-datagrid-headers {
    background-color: #0f172a;
    border-bottom-color: #334155;
    color: #cbd5e1;
}

body.dark-theme .dx-datagrid-rowsview .dx-row {
    background-color: #1e293b;
    border-bottom-color: #334155;
    color: #e2e8f0;
}

body.dark-theme .dx-datagrid-rowsview .dx-row.dx-row-alt {
    background-color: #0f172a;
}

body.dark-theme .dx-datagrid-rowsview .dx-row:hover {
    background-color: #334155;
}

body.dark-theme .chat-main {
    background-color: #1e293b;
}

body.dark-theme .chat-header {
    background-color: #0f172a;
    border-bottom-color: #334155;
}

body.dark-theme .chat-header .chat-title {
    color: #e2e8f0;
}

body.dark-theme .chat-content {
    background-color: #0f172a;
}

body.dark-theme .dx-chat-message-box {
    background-color: #1e293b;
    border-top-color: #334155;
}

body.dark-theme .sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

body.dark-theme ::-webkit-scrollbar-thumb {
    background: #475569;
}

body.dark-theme ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Bootstrap Button Overrides */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* Dark Theme Overrides for Chat Sidebar */
body.dark-theme .chat-sidebar {
    background-color: #1e293b;
    /* Slate 800 */
    border-right-color: #334155;
    color: #f8fafc;
}

body.dark-theme .chat-sidebar .sidebar-header {
    border-bottom-color: #334155;
}

body.dark-theme .chat-sidebar .sidebar-header h3 {
    color: #f8fafc;
}

body.dark-theme .sidebar-search {
    border-bottom-color: #334155;
}

body.dark-theme .sidebar-search input {
    background-color: #0f172a;
    /* Slate 900 */
    border-color: #334155;
    color: #f8fafc;
}

body.dark-theme .sidebar-search input::placeholder {
    color: #64748b;
}

body.dark-theme .sidebar-search input:focus {
    background-color: #0f172a;
    border-color: #60a5fa;
    /* Blue 400 */
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

body.dark-theme .chat-history-item {
    color: #cbd5e1;
    /* Slate 300 */
}

body.dark-theme .chat-history-item:hover {
    background-color: #334155;
    /* Slate 700 */
}

body.dark-theme .chat-history-item.active {
    background-color: #1e3a8a;
    /* Blue 900 */
    border-color: #3b82f6;
    /* Blue 500 */
    color: #bfdbfe;
    /* Blue 200 */
}

body.dark-theme .chat-history-item .chat-preview {
    color: #94a3b8;
    /* Slate 400 */
}

body.dark-theme .chat-history-item .chat-date {
    color: #64748b;
    /* Slate 500 */
}

/* ============================================
   Result Popup - DevExtreme Tab Caption Fix
   Fluent theme hides .dx-tab-text-span on
   inactive tabs via visibility:hidden
   ============================================ */

/* Force tab text span to always be visible */
#resultTabPanel .dx-tab .dx-tab-text .dx-tab-text-span {
    visibility: visible !important;
    opacity: 1 !important;
    color: inherit !important;
}

/* Force tab text container to always be visible */
#resultTabPanel .dx-tab .dx-tab-text {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    max-width: none !important;
    overflow: visible !important;
    width: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: static !important;
}

/* Ensure all tabs (including inactive) have visible text color */
#resultTabPanel .dx-tab {
    color: var(--text-muted) !important;
    opacity: 1 !important;
}

/* Selected tab: primary color, bold */
#resultTabPanel .dx-tab.dx-tab-selected {
    color: var(--primary-color) !important;
    font-weight: 600 !important;
    opacity: 1 !important;
}

/* Hover state for unselected tabs */
#resultTabPanel .dx-tab:not(.dx-tab-selected):hover {
    color: var(--text-color) !important;
    background-color: #f1f5f9 !important;
}

/* Tab icons should match the text color */
#resultTabPanel .dx-tab .dx-icon {
    color: inherit !important;
    opacity: 1 !important;
}

/* Ensure the tab bar container has proper contrast */
#resultTabPanel .dx-tabs {
    background-color: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

/* Dark Theme tab overrides */
body.dark-theme #resultTabPanel .dx-tab {
    color: #94a3b8 !important;
}

body.dark-theme #resultTabPanel .dx-tab.dx-tab-selected {
    color: #818cf8 !important;
}

body.dark-theme #resultTabPanel .dx-tab:not(.dx-tab-selected):hover {
    color: #e2e8f0 !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

body.dark-theme #resultTabPanel .dx-tabs {
    background-color: #1e293b !important;
    border-bottom-color: #334155 !important;
}

/* Hide tab text on mobile, show only icons */
@media (max-width: 768px) {
    #resultTabPanel .dx-tab .dx-tab-text .dx-tab-text-span {
        display: none !important;
    }
}

/* ============================================
   Dashboard - Page Header
   ============================================ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0 0 0.2rem;
    letter-spacing: -0.025em;
}

.page-header-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

.page-header-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.page-header-badge .pulse-dot {
    width: 6px;
    height: 6px;
    background: rgba(255,255,255,0.85);
    border-radius: 50%;
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(1.4); }
}

/* ============================================
   Dashboard - KPI Stat Cards
   ============================================ */
.kpi-card {
    background-color: var(--card-bg);
    border-radius: var(--card-radius);
    border: none;
    box-shadow: var(--card-shadow);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.12);
}

.kpi-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.kpi-icon.kpi-indigo  { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; }
.kpi-icon.kpi-emerald { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.kpi-icon.kpi-amber   { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.kpi-icon.kpi-blue    { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; }

.kpi-content {
    flex: 1;
    min-width: 0;
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1;
    margin-bottom: 0.35rem;
    letter-spacing: -0.03em;
}

.kpi-change {
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.kpi-change.positive { color: var(--success-color); }
.kpi-change.negative { color: var(--danger-color); }

@media (max-width: 575.98px) {
    .kpi-card {
        padding: 0.75rem;
        gap: 0.6rem;
    }
    .kpi-icon {
        width: 38px;
        height: 38px;
        font-size: 1rem;
        border-radius: 9px;
        flex-shrink: 0;
    }
    .kpi-label {
        font-size: 0.65rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .kpi-value {
        font-size: 1.2rem;
    }
    .kpi-change {
        font-size: 0.65rem;
    }
}

/* Dark theme overrides for dashboard */
body.dark-theme .page-header-title { color: #f1f5f9; }
body.dark-theme .kpi-card          { background-color: var(--card-bg); }
body.dark-theme .kpi-value         { color: #f1f5f9; }

/* ============================================
   Dashboard - Chart Cards
   ============================================ */
.chart-card {
    background-color: var(--card-bg);
    border-radius: var(--card-radius);
    border: none;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    height: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chart-card:hover {
    box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.1);
}

.chart-card-header {
    padding: 1rem 1.25rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid #f1f5f9;
}

.chart-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.chart-card-icon.ci-indigo  { background: #ede9fe; color: #4f46e5; }
.chart-card-icon.ci-purple  { background: #f3e8ff; color: #9333ea; }
.chart-card-icon.ci-emerald { background: #d1fae5; color: #059669; }
.chart-card-icon.ci-amber   { background: #fef3c7; color: #d97706; }
.chart-card-icon.ci-blue    { background: #dbeafe; color: #2563eb; }

.chart-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.chart-card-body {
    padding: 1rem 1.25rem 1.25rem;
}

.chart-card-body .dx-widget,
.chart-card-body > div {
    min-height: 220px;
}

body.dark-theme .chart-card-header { border-bottom-color: #334155; }
body.dark-theme .chart-card-title  { color: #f1f5f9; }
body.dark-theme .chart-card-icon.ci-indigo  { background: rgba(79,70,229,.2);  color: #818cf8; }
body.dark-theme .chart-card-icon.ci-purple  { background: rgba(147,51,234,.2); color: #c084fc; }
body.dark-theme .chart-card-icon.ci-emerald { background: rgba(5,150,105,.2);  color: #34d399; }
body.dark-theme .chart-card-icon.ci-amber   { background: rgba(217,119,6,.2);  color: #fbbf24; }
body.dark-theme .chart-card-icon.ci-blue    { background: rgba(37,99,235,.2);  color: #60a5fa; }