/* =========================================
   1. STRICT DESIGN SYSTEM (Expert UI/UX)
   ========================================= */
:root {
    /* --- COLOR PALETTE (Centralized Source of Truth) --- */
    --brand-primary-900: #0f172a;
    /* Slate 900 - Deepest */
    --brand-primary-800: #1e293b;
    /* Slate 800 - Deep */
    --brand-primary-700: #334155;
    /* Slate 700 - Body */
    --brand-primary-600: #475569;
    /* Slate 600 - Muted */
    --brand-primary-500: #64748b;
    /* Slate 500 - Border */
    --brand-primary-300: #cbd5e1;
    /* Slate 300 - Border */
    --brand-primary-100: #f1f5f9;
    /* Slate 100 - Background */
    --brand-primary-50: #f8fafc;
    /* Slate 50  - Surface */

    --action-primary: #0f172a;
    /* Main Action Color (Navy) */
    --action-hover: #334155;
    --action-secondary: #ffffff;
    --action-accent: #06b6d4;
    /* Cyan 500 - Accent ONLY */
    --action-accent-dark: #043C48;
    /* Darker Cyan for headers */

    --state-success: #10b981;
    /* Emerald 500 */
    --state-warning: #f59e0b;
    /* Amber 500 */
    --state-danger: #ef4444;
    /* Red 500 */
    --state-info: #06b6d4;
    /* Cyan 500 (Replaces Blue) */

    /* --- BOOTSTRAP OVERRIDES (Deep Clean) --- */
    --bs-blue: var(--state-info);
    --bs-primary: var(--action-primary);
    --bs-primary-rgb: 15, 23, 42;
    /* Navy RGB */
    --bs-link-color: var(--action-accent);
    --bs-link-hover-color: var(--brand-primary-800);
    --bs-info: var(--state-info);
    --bs-info-rgb: 6, 182, 212;
    /* Cyan RGB */
    --bs-body-color: var(--brand-primary-800);
    --bs-body-bg: var(--brand-primary-100);

    /* --- TYPOGRAPHY (Outfit) --- */
    --font-sans: 'Outfit', system-ui, -apple-system, sans-serif;
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-bold: 600;
    --font-weight-h: 700;

    /* --- SPACING & SIZING --- */
    --sidebar-width: 220px;
    --navbar-height: 56px;
    --border-radius-sm: 6px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    --bot-width: 380px;

    /* --- SHADOWS & DEPTH --- */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition-fast: 0.15s ease-in-out;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap');

/* =========================================
   2. GLOBAL RESET & BASE
   ========================================= */
body {
    background-color: var(--brand-primary-100);
    color: var(--brand-primary-800);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: var(--action-accent);
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--brand-primary-700);
}

.dropdown-menu {
    z-index: 1050 !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--brand-primary-200);
    border-radius: var(--border-radius-md);
}

.navbar-custom .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
}

.navbar-custom .nav-link:hover,
.navbar-custom .nav-link.active {
    color: #ffffff !important;
}

/* =========================================
   3. COMPONENTS (Atomic Design)
   ========================================= */

/* --- Buttons --- */
.btn {
    font-weight: var(--font-weight-medium);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    border: 1px solid var(--brand-primary-300);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background-color: var(--action-primary);
    border-color: var(--brand-primary-600);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: var(--action-hover);
    border-color: var(--brand-primary-500);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: white;
    border-color: var(--brand-primary-300);
    color: var(--brand-primary-700);
}

.btn-secondary:hover {
    background-color: var(--brand-primary-50);
    border-color: var(--brand-primary-500);
    color: var(--brand-primary-900);
}

/* Explicit Override for Bootstrap Outline Primary (Nuke #0d6efd) */
.btn-outline-primary {
    --bs-btn-color: var(--action-primary) !important;
    --bs-btn-border-color: var(--action-primary) !important;
    --bs-btn-hover-color: #fff !important;
    --bs-btn-hover-bg: var(--action-primary) !important;
    --bs-btn-hover-border-color: var(--action-primary) !important;
    --bs-btn-focus-shadow-rgb: 15, 23, 42 !important;
    --bs-btn-active-color: #fff !important;
    --bs-btn-active-bg: var(--action-primary) !important;
    --bs-btn-active-border-color: var(--action-primary) !important;
    --bs-btn-disabled-color: var(--action-primary) !important;
    --bs-btn-disabled-border-color: var(--action-primary) !important;
    color: var(--action-primary) !important;
    border-color: var(--action-primary) !important;
}

.btn-outline-primary:hover {
    background-color: var(--action-primary) !important;
    color: white !important;
}

.btn-info {
    background-color: var(--action-accent);
    border-color: var(--action-accent);
    color: white;
}

.btn-info:hover {
    background-color: #0891b2;
    border-color: #0891b2;
    color: white;
}

.btn-link {
    border-color: transparent;
    color: var(--brand-primary-600);
}

.btn-link:hover {
    color: var(--action-accent);
    background: var(--brand-primary-50);
    border-color: var(--brand-primary-200);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* --- Forms --- */
.form-control,
.form-select,
.form-control:focus,
.form-select:focus {
    background-color: #ffffff;
}

/* Adjust button height to match form inputs */
.btn-match-input-height {
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}



/* Forms Customization (Override Bootstrap Defaults) */

/* Checkboxes & Radios */
.form-check-input:checked {
    background-color: var(--action-primary);
    border-color: var(--action-primary);
}

.form-check-input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
}

.form-check-input[type="radio"]:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e");
}

.form-check-input:focus {
    border-color: var(--action-primary);
    /* Use system primary color for border focus */
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
    /* Use system primary RGB for shadow */
}

/* Select2 elements custom styling for active/hover states */
.select2-container--bootstrap-5 .select2-results__option--highlighted.select2-results__option--selectable {
    background-color: var(--action-primary) !important;
    color: #fff !important;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
    background-color: var(--action-primary);
    border-color: var(--action-primary);
    color: #fff;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--action-primary) !important;
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25) !important;
}

/* General select focus, if not handled by Select2 */
select:focus {
    border-color: var(--action-primary);
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

/* --- Alerts --- */
.alert {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}

.swal2-popup.custom-swal {
    max-width: 500px;
    width: 90%;
}

.swal2-popup.custom-swal .swal2-icon {
    border: 0 !important;
    transform: scale(1.4);
    margin: 1.5em auto 1em;
}

/* --- Modals --- */
.modal-header {
    background-color: var(--action-accent-dark);
    color: white;
}

.modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    /* Makes it white */
}

/* --- Cards --- */
.card {
    background: white;
    border: 1px solid var(--brand-primary-200, #e2e8f0);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-xs);
    /* overflow: hidden; Removed to allow dropdowns to spill over */
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--brand-primary-200, #e2e8f0);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
}

.card-title,
.card-header {
    font-weight: var(--font-weight-bold);
    color: var(--brand-primary-900);
    margin: 0;
    font-size: 1rem;
}

.card-header i {
    color: var(--brand-primary-500);
    font-size: 1.1em;
}

.card-header .btn,
.card-header .dropdown,
.card-header .ms-auto {
    margin-left: auto;
}

.card-header .btn {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}

/* --- KPI Cards --- */
.kpi-card {
    background: white;
    border: 1px solid var(--brand-primary-200, #e2e8f0);
    border-radius: var(--border-radius-md);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-card>.card-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kpi-icon-container i {
    font-size: 2.5rem;
    color: var(--brand-primary-300);
}


.kpi-info .kpi-label {
    font-size: 0.75rem;
    color: var(--brand-primary-600);
    letter-spacing: 0.05em;
    font-weight: var(--font-weight-bold);
    margin-bottom: 0.25rem;
}

.kpi-info .kpi-value {
    font-size: 1.75rem;
    font-weight: var(--font-weight-h);
    color: var(--brand-primary-900);
    line-height: 1.2;
}

.kpi-primary {
    border-left: 4px solid var(--action-primary);
}

.kpi-success {
    border-left: 4px solid var(--state-success);
}

.kpi-warning {
    border-left: 4px solid var(--state-warning);
}

.kpi-danger {
    border-left: 4px solid var(--state-danger);
}

/* --- Navbar --- */
.navbar-custom {
    background-color: var(--action-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
    height: auto;
    min-height: var(--navbar-height);
}

.navbar-brand img {
    height: 32px;
    width: auto;
}

.navbar-brand span {
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.01em;
    font-size: 1.1rem;
    color: white;
}

.nav-link {
    font-weight: var(--font-weight-medium);
    font-size: 0.9rem;
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 0.75rem !important;
    transition: all var(--transition-fast);
}

.navbar-custom .nav-link:focus,
.navbar-custom .nav-link.active,
.navbar-custom .nav-link.show {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 0 -1px var(--action-accent);
    /* Cyan underline */
}

/* --- Module Navigation (Secondary) --- */
.module-secondary-nav {
    background: white;
    border-bottom: 1px solid var(--brand-primary-200);
    padding: 0;
}

.module-secondary-nav .nav-link {
    color: var(--brand-primary-600) !important;
    padding: .75rem 1rem !important;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    font-size: 0.80rem;
}

.module-secondary-nav .nav-link:hover {
    color: var(--action-primary) !important;
    background: transparent;
}

.module-secondary-nav .nav-link.active,
.module-secondary-nav .nav-link:focus {
    color: var(--action-primary) !important;
    border-bottom-color: var(--action-accent);
    /* Cyan Line */
    font-weight: var(--font-weight-bold);
    background: rgba(6, 182, 212, 0.05);
}

/* --- Search Bar --- */
.navbar-search-control {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 20px;
    padding-left: 1rem;
    padding-right: 2.5rem;
    transition: all var(--transition-fast);
}

.navbar-search-control:focus {
    background-color: white;
    color: var(--brand-primary-900);
    border-color: white;
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.navbar-search-control::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.navbar-search-control:focus::placeholder {
    color: var(--brand-primary-500);
}

/* --- Tables --- */
.table {
    margin: 0;
    font-size: 0.875rem;
    background-color: white !important;
    /* Default table background: lightest shade */
}

.table th {
    background-color: var(--action-primary);
    color: white;
    font-weight: var(--font-weight-bold);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--brand-primary-800);
}

.table td {
    padding: 0.875rem 1rem;
    color: var(--brand-primary-800);
    border-bottom: 1px solid var(--brand-primary-200);
    /* Darker border for better separation */
    vertical-align: middle;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--brand-primary-100);
    /* Odd rows: current body background color */
}

.table-hover tbody tr:hover {
    background-color: var(--brand-primary-200);
    /* Hover rows: next darker shade */
}

/* --- DataTables --- */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.25rem 0.75rem !important;
    border-radius: var(--border-radius-sm) !important;
    border: 1px solid var(--brand-primary-200) !important;
    background: white !important;
    color: var(--brand-primary-700) !important;
    margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--brand-primary-50) !important;
    color: var(--brand-primary-900) !important;
    border-color: var(--brand-primary-500) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--action-accent) !important;
    /* Cyan */
    color: white !important;
    border-color: var(--action-accent) !important;
}

.dataTables_filter input {
    border: 1px solid var(--brand-primary-300);
    border-radius: var(--border-radius-sm);
    padding: 0.35rem 0.75rem;
}

.dataTables_filter input:focus {
    border-color: var(--action-accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

/* --- Utilities --- */
.transition-hover {
    transition: all var(--transition-smooth);
}

.transition-hover:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

/* --- Module Cards (Hybrid Approach) --- */
.module-card {
    transition: all var(--transition-smooth);
    border: 1px solid var(--brand-primary-200, #e2e8f0);
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 1.5rem;
    gap: 1.25rem;
    background: white;
    border-radius: var(--border-radius-lg);
}

.module-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--action-accent);
    /* Cyan border on hover */
    background-color: #f0f9ff;
    /* Very light cyan tint */
}

/* Animate icon color on hover */
.module-card:hover .module-card-icon-pane {
    color: var(--action-accent);
    background-color: rgba(6, 182, 212, 0.15);
    transform: scale(1.1);
    /* Subtle pop */
    transition: all var(--transition-fast);
}

.module-card-icon-pane {
    font-size: 1.75rem;
    color: var(--action-primary);
    /* Navy Base (Serious) */
    background-color: #e0f2fe;
    /* Light Blue Base */
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all var(--transition-smooth);
}

.module-card-text-pane {
    flex-grow: 1;
}

.module-card .card-title {
    font-size: 1.1rem;
    font-weight: var(--font-weight-bold);
    color: var(--brand-primary-900);
    margin-bottom: 0.25rem;
}

.module-card p.text-muted {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--brand-primary-600) !important;
    margin: 0;
}

.module-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
}

/* --- Floating AI Bot --- */
.ai-widget-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: var(--action-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 1060;
    transition: transform var(--transition-smooth);
}

.ai-widget-btn:hover {
    transform: scale(1.1);
    background: var(--action-hover);
}

.ai-chat-window {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: var(--bot-width);
    height: 500px;
    max-height: 80vh;
    background: white;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 1060;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all var(--transition-smooth);
    border: 1px solid var(--brand-primary-200);
}

.ai-chat-window.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.ai-chat-header {
    background: var(--action-primary);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: var(--font-weight-bold);
}

.ai-chat-messages {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
    background: var(--brand-primary-50);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-md);
    font-size: 0.9rem;
    line-height: 1.5;
}

.ai-message.bot {
    align-self: flex-start;
    background: white;
    border: 1px solid var(--brand-primary-200);
    color: var(--brand-primary-800);
    border-bottom-left-radius: 0;
}

.ai-message.user {
    align-self: flex-end;
    background: var(--action-accent);
    /* Cyan */
    color: white;
    border-bottom-right-radius: 0;
}

.ai-chat-input-area {
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--brand-primary-200);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* --- Footer --- */
.footer {
    background-color: white !important;
    border-top: 1px solid var(--brand-primary-200) !important;
    padding: 1.5rem 0;
    color: var(--brand-primary-500);
}

.footer small {
    font-size: 0.8rem;
    font-weight: var(--font-weight-medium);
}

.footer strong {
    color: var(--action-primary);
}

/* --- FINAL PAGINATION FIX: FORCE NAVY/CYAN --- */
/* --- FINAL PAGINATION FIX: JOINED STYLE --- */
/* --- FINAL PAGINATION FIX: JOINED STYLE --- */
.dataTables_wrapper .dataTables_paginate .pagination {
    margin: 0 !important;
    padding: 0 !important;
    justify-content: flex-end !important;
    display: flex !important;
    gap: 0 !important;
}

.dataTables_wrapper .dataTables_paginate .page-item {
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    border: none !important;
}

.dataTables_wrapper .dataTables_paginate .page-item .page-link {
    border-radius: 0 !important;
    margin: 0 !important;
    margin-left: -1px !important;
    border: 1px solid var(--brand-primary-300) !important;
    color: var(--brand-primary-700) !important;
    padding: 0.375rem 0.75rem !important;
    position: relative;
    float: none !important;
    display: block !important;
}

.dataTables_wrapper .dataTables_paginate .page-item:first-child .page-link {
    border-top-left-radius: var(--border-radius-sm) !important;
    border-bottom-left-radius: var(--border-radius-sm) !important;
    margin-left: 0 !important;
}

.dataTables_wrapper .dataTables_paginate .page-item:last-child .page-link {
    border-top-right-radius: var(--border-radius-sm) !important;
    border-bottom-right-radius: var(--border-radius-sm) !important;
}

.dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
    background-color: var(--action-primary) !important;
    border-color: var(--action-primary) !important;
    color: white !important;
    z-index: 3;
}

.dataTables_wrapper .dataTables_paginate .page-item:not(.active) .page-link:hover {
    background-color: var(--brand-primary-50) !important;
    border-color: var(--brand-primary-300) !important;
    color: var(--brand-primary-900) !important;
    z-index: 2;
}

.dataTables_wrapper .dataTables_paginate .page-item.disabled .page-link {
    background-color: white !important;
    color: var(--brand-primary-300) !important;
    cursor: default !important;
}

/* Fix for .btn-white visibility on white background */
.btn-white {
    background-color: white;
    border: 1px solid var(--brand-primary-200);
    color: var(--brand-primary-700);
    box-shadow: var(--shadow-sm);
}

.btn-white:hover {
    background-color: var(--brand-primary-50);
    border-color: var(--brand-primary-300);
    color: var(--brand-primary-900);
}

/* Absolute Centering for Navbar Search */
@media (min-width: 992px) {
    .navbar-search-centered {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        max-width: 450px;
        margin: 0 !important;
    }
}

/* =========================================
   4. SYSTEM ENHANCEMENTS (LTS Standard)
   ========================================= */

/* --- Global Loader --- */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

/* HTMX Indicator Class */
.htmx-indicator.htmx-request .global-loader,
.global-loader.active {
    display: flex;
}

/* --- Mobile Card View (Responsive DataTables) --- */
@media (max-width: 767.98px) {
    .mobile-card-view thead {
        display: none;
    }

    .mobile-card-view tbody,
    .mobile-card-view tr,
    .mobile-card-view td {
        display: block;
        width: 100%;
    }

    .mobile-card-view tr {
        margin-bottom: 1rem;
        background: white;
        border: 1px solid var(--brand-primary-200);
        border-radius: var(--border-radius-md);
        box-shadow: var(--shadow-sm);
        padding: 1rem;
    }

    .mobile-card-view td {
        display: flex !important;
        /* Use Flexbox for layout */
        justify-content: space-between !important;
        /* Label left, content right */
        align-items: center !important;
        /* Vertically align */
        width: 100% !important;
        text-align: right !important;
        padding: 0.75rem 1rem !important;
        border-bottom: 1px solid var(--brand-primary-50);
        min-height: 3rem;
        /* Ensure height for empty fields */
    }

    .mobile-card-view td:last-child {
        border-bottom: 0;
        justify-content: center !important;
        /* Center actions */
    }

    .mobile-card-view td::before {
        content: attr(data-label);
        font-weight: var(--font-weight-bold);
        color: var(--brand-primary-600);
        font-size: 0.85rem;
        text-align: left;
        margin-right: 1rem;
        flex-shrink: 0;
        /* Prevent label from shrinking */
        width: auto;
        /* Let it grow as needed, or set fixed if alignment needed */
        max-width: 50%;
        /* Prevent label from taking too much space */
        position: static;
        /* Reset absolute positioning */
        display: block;
    }

    .mobile-card-view td:last-child::before {
        display: none;
    }

    /* --- Datatables Mobile Fixes --- */
    .dataTables_wrapper .d-flex {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem;
    }

    .dataTables_wrapper .dataTables_filter {
        text-align: left !important;
        margin-top: 0.5rem;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        /* Full width search box */
        margin-left: 0 !important;
    }

    .dataTables_wrapper .dataTables_length {
        text-align: left !important;
    }
}

/* --- Menu Scrolling --- */
.nav-scroller-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #fff;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    color: #004aad;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.9;
    transition: all 0.2s ease;
}

.nav-arrow:hover {
    background-color: #f8f9fa;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    opacity: 1;
}

.nav-arrow.hidden {
    display: none !important;
}

.nav-arrow-left {
    left: -12px;
}

.nav-arrow-right {
    right: -12px;
}

.mobile-scroll-container {
    overflow-x: auto !important;
    white-space: nowrap;
    display: flex;
    align-items: center;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding-bottom: 400px;
    margin-bottom: -400px;
    pointer-events: none;
    scroll-behavior: smooth;
}

.mobile-scroll-container::-webkit-scrollbar {
    display: none;
}

.mobile-scroll-container .nav {
    pointer-events: auto;
}

@media (min-width: 992px) {
    .mobile-scroll-container {
        justify-content: flex-start;
    }
}

.select2-container--default .select2-search--inline .select2-search__field {
    font-size: 85% !important;
    margin-top: 9px !important;
}

/* ============ TABLE ============ */
.table-card {
    background: var(--card-bg, #fff);
    padding: 0;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-light, #e2e8f0);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    border-bottom: 1px solid var(--brand-primary-200, #e2e8f0);
    padding: .7rem 1.25rem;
    font-weight: var(--font-weight-bold);
    color: var(--brand-primary-900);
    font-size: 1rem;
}

.table-header h3 {
    margin: 0 !important;
    font-size: 1rem;
    font-weight: var(--font-weight-bold);
    color: var(--brand-primary-900);
    display: flex;
    align-items: center;
}

#table-wrapper,
.table-wrapper {
    flex-grow: 1;
    padding: 1.25rem;
}

.download-button {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    border: none;
    background: linear-gradient(135deg, var(--secondary-color, #6c757d), var(--secondary-light, #adb5bd));
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.download-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.35);
}

.download-button:active {
    transform: translateY(0);
}

#table-wrapper,
.table-wrapper {
    flex-grow: 1;
}

/* DataTables Enhanced */
.dataTables_wrapper {
    width: 100%;
    font-size: 0.8rem;
    color: var(--text-color, #1e293b);
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: var(--border-radius-sm);
    padding: 8px 12px;
    outline: none;
    transition: all var(--transition-fast);
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary-light, #3b82f6);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: var(--border-radius-sm);
    padding: 6px 10px;
    outline: none;
}

table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0 4px;
    background: transparent;
}

table.dataTable thead th {
    background: linear-gradient(180deg, #f8fafc, #f1f5f9);
    color: var(--text-color, #1e293b);
    font-weight: 600;
    text-align: left;
    padding: 12px 14px;
    border-bottom: 2px solid var(--primary-light, #3b82f6);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

table.dataTable tbody tr {
    background: var(--card-bg, #fff) !important;
    transition: all var(--transition-fast);
}

table.dataTable tbody tr td {
    padding: 12px 14px;
    border-top: none !important;
    border-bottom: 1px solid var(--border-light, #e2e8f0) !important;
    vertical-align: middle;
}

table.dataTable tbody tr:hover {
    background: #f0f9ff !important;
}

.dataTables_wrapper .dataTables_processing {
    background: var(--card-bg, #fff);
    padding: 12px 24px;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow);
    color: var(--primary-color, #0f172a);
    font-weight: 600;
}

@media (max-width: 768px) {
    :root {
        --gap: 0.75rem;
        --border-radius: 10px;
        --border-radius-sm: 6px;
    }

    /* DataTable Mobile */
    .dataTables_wrapper {
        font-size: 0.75rem;
    }

    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        float: none !important;
        text-align: left !important;
        margin-bottom: 0.5rem;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        margin-left: 0 !important;
        margin-top: 0.25rem;
    }

    table.dataTable thead th {
        padding: 8px 6px;
        font-size: 0.65rem;
    }

    table.dataTable tbody tr td {
        padding: 8px 6px;
        font-size: 0.7rem;
    }

    /* Horizontal scroll for tables */
    #table-wrapper,
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table.dataTable {
        min-width: 600px;
    }
}