.loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    border: 4px solid #e5e7eb; /* Light gray */
    border-top: 4px solid #3b82f6; /* Blue */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    display: inline-block;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-left: 6px;
    animation: spin 0.8s linear infinite;
}

/* Disabled button visual state */
.apply-filters-btn[disabled],
#clear-filters-btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    filter: saturate(0.7);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none !important;
}


#data-table thead th {
    background-color: #c9cbce;
    color: rgb(0, 0, 0);
    font-weight: 600;
    font-size: 14px;
    padding: 12px 10px;
    border-bottom: 1px solid #ddd;
    vertical-align: middle;
    text-align: left;
    white-space: nowrap;
}

#data-table thead th.sorting,
#data-table thead th.sorting_asc,
#data-table thead th.sorting_desc {
    cursor: pointer;
    position: relative;
}

#data-table thead th:hover {
    background-color: #e9ecef;
}

#data-table tbody td {
    padding: 10px;
    font-size: 13.5px;
    color: #221f1f;
    vertical-align: top;
}

/* Optional: rounded top corners on first and last header */
#data-table thead th:first-child {
    border-top-left-radius: 8px;
}

#data-table thead th:last-child {
    border-top-right-radius: 8px;
}


.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
    gap: 3px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

#sortDropdown,
#customSearchInput {
    padding: 6px 10px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    min-width: 160px;
}



.sort-container select {
    padding: 6px 10px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
}


.dt-button.buttons-colvis,
#analyticsBtn {
    display: none !important;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 40px; /* Increased padding */
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 999;
    font-size: 1.25rem; /* Increased base font size (optional) */
}

.header-left {
    display: flex;
    align-items: center;
    gap: 32px; /* Increased gap */
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 24px; /* Increased gap */
    flex-grow: 1;
}


/* Ensure proper spacing between elements */
.header-left > *,
.header-right > * {
    margin: 0;
}

/* Count card styling */
.count-card {
    display: flex;
    gap: 24px;
    background: transparent;
    /* Remove background */
    padding: 0;
    box-shadow: none;
    /* Remove shadow */
    align-items: center;
}

.count-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.count-label {
    font-size: 16px;
    color: #6e6e73;
    font-weight: 500;
}

.count-value {
    font-size: 18px;
    font-weight: 600;
    color: #1d1d1f;
}

/* Header center alignment */
.header-center {
    display: flex;
    align-items: center;
    gap: 24px;
}

/* Update the user info container */
.user-info-container {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

/* Ellipsis button styling */
.ellipsis-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #1d1d1f;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.ellipsis-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Dropdown content styling */
.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    min-width: 200px;
    padding: 8px 0;
    margin-top: 8px;
}

/* Dropdown items */
.dropdown-content button,
.dropdown-content a {
    display: block;
    width: 100%;
    padding: 8px 16px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    color: #1d1d1f;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.dropdown-content button:hover {
    background-color: #f5f5f7;
}

/* User email styling */
.user-email {
    font-size: 14px;
    color: #6e6e73;
    padding: 8px 16px;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 4px;
}


.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    color: #007aff;
    font-size: 18px;
}

.icon-button:hover {
    color: #005ecb;
}
























.icon-button {
    background: none;
    border: none;
    font-size: 18px;
    color: #007aff;
    cursor: pointer;
}

.icon-button:hover {
    color: #005ecb;
}





.count-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
}






.icon-button {
    background: none;
    border: none;
    color: #007aff;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    margin-left: 8px;
}

.icon-button:hover {
    color: #005ecb;
}

/* ✅ IMPROVED: Select2 Modern Styling */
.select2-container--default .select2-selection--multiple {
    min-height: 42px !important;
    font-size: 14px;
    border: 2px solid #e0e0e0 !important;
    border-radius: 6px !important;
    transition: all 0.2s ease;
}

.select2-container--default .select2-selection--multiple:hover {
    border-color: #007aff !important;
}

.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #007aff !important;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1) !important;
}

/* ✅ Dropdown opens smoothly without blocking scroll */
.select2-container--default .select2-dropdown {
    border: 2px solid #007aff !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    z-index: 9999 !important; /* Ensure dropdown appears above other elements */
}

/* ✅ CRITICAL: Allow scrolling even when Select2 dropdown is open */
.select2-container--open {
    z-index: 9999 !important;
}

/* ✅ Prevent Select2 from blocking pointer events on the sidebar */
.select2-container--open + .select2-container--open {
    pointer-events: none !important;
}

/* ✅ But allow pointer events on the dropdown itself */
.select2-dropdown {
    pointer-events: auto !important;
    max-height: 300px !important;
}

/* ✅ CRITICAL: Remove the invisible overlay that blocks scrolling */
body.select2-container--open {
    overflow: auto !important;
}

/* ✅ Ensure sidebar remains scrollable */
.sidebar {
    pointer-events: auto !important;
    touch-action: auto !important;
}

/* ✅ Hide the "Please enter X or more characters" message */
.select2-container--default .select2-results__message {
    display: none !important;
}

/* ✅ Search box in dropdown */
.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 2px solid #e0e0e0 !important;
    border-radius: 4px !important;
    padding: 8px !important;
    font-size: 14px !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: #007aff !important;
    outline: none !important;
}

#analyticsDrilldownChart {
    height: 500px !important;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}


.pagination-container {
    position: relative;
}


.access-popup {
    display: none;
    position: absolute;
    background-color: #ffe0e0;
    color: #d8000c;
    padding: 6px 12px;
    font-size: 13px;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    z-index: 999;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    transition: opacity 0.3s ease;
}



.pagination-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.pagination-btn {
    background-color: #007aff;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.pagination-btn:hover {
    background-color: #005ecb;
}

#gotoPageInput {
    width: 90px;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
}


.priority-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.priority-field-select,
.priority-values-input {
    padding: 6px 10px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    flex: 1;
}

.remove-priority-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.remove-priority-btn:hover {
    background-color: #c0392b;
}




#analyticsLoader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Popup box in the center */
.analytics-loader-popup {
    background: white;
    padding: 24px 32px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    text-align: center;
    font-family: 'Segoe UI', sans-serif;
    width: 250px;
}

/* Spinner */
.analytics-spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto 12px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007aff;
    /* Theme color */
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* Animation */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}




/* Analytics View */
body.analytics-view .sidebar,
body.analytics-view .table-container,
body.analytics-view .count-box,
body.analytics-view #exportLeadsBtn,
body.analytics-view #exportCompaniesBtn,
body.analytics-view .sort-container,
body.analytics-view .pagination-container,
body.analytics-view .main-content,
body.analytics-view .footer {
    display: none !important;
}

body.analytics-view .header-center {
    justify-content: center;
}

/* Analytics Container */
#analyticsContainer {
    padding: 20px;
    background-color: #f8f9fa;
    min-height: calc(100vh - 120px);
    position: relative;
    padding-bottom: 80px;
    /* Space for footer */
}

.back-to-dashboard {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 16px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.3s;
}

.back-to-dashboard:hover {
    background-color: #2980b9;
}

.analytics-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    text-align: center;
    background-color: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}


.analytics-btn {
    padding: 8px 12px;
    background-color: #007BFF;
    color: white;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.analytics-btn:hover {
    background-color: #0056b3;
}

.analytics-btn.dashboard-btn {
    padding: 8px 12px;
    background-color: #007BFF;
    color: white;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.analytics-btn.dashboard-btn:hover {
    background-color: #0056b3;
}




#analyticsToggleBtn {
    padding: 8px 12px;
    background-color: #007BFF;
    color: white;
    border: none;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    margin-left: 10px;
    transition: background-color 0.2s ease;
}

#analyticsToggleBtn:hover {
    background-color: #0056b3;
}

#analyticsToggleBtn.dashboard-btn {
    background-color: #28a745;
}

#analyticsToggleBtn.dashboard-btn:hover {
    background-color: #1e7e34;
}







/* Analytics View */
body.analytics-view .sidebar,
body.analytics-view .table-container,
body.analytics-view .count-box,
body.analytics-view #exportLeadsBtn,
body.analytics-view #exportCompaniesBtn {
    display: none !important;
}

body.analytics-view .header-center {
    justify-content: center;
}

.analytics-container {
    padding: 20px;
    background-color: #f8f9fa;
    min-height: calc(100vh - 120px);
}

.analytics-title {
    text-align: center;
    margin-bottom: 20px;
    color: #2c3e50;
}

.analytics-filters {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.analytics-filters select,
.analytics-filters input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 200px;
}

.analytics-filters button {
    padding: 8px 16px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.analytics-filters button:hover {
    background-color: #2980b9;
}

.analytics-main {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.chart-container {
    flex: 2;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: 500px;
}

.metrics-container {
    flex: 1;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 80px;
}

.metric-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #3498db;
}

.metric-card h3 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 16px;
}

.metric-value {
    font-size: 24px;
    font-weight: bold;
    color: #3498db;
    margin: 10px 0;
}

.metric-label {
    font-size: 14px;
    color: #7f8c8d;
}

.chart-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.chart-controls select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .analytics-main {
        flex-direction: column;
    }

    .chart-container,
    .metrics-container {
        width: 100%;
    }
}

.delete-list-btn {
    margin-left: 6px;
    font-size: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #d00;
}

.delete-list-btn:hover {
    color: red;
}




/* Import CSV Modal Styles */
#importCsvModal .modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

/* Saved Lists Dropdown */
#savedListsDropdown {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#clearListBtn {
    background: #f5f5f5;
    border: 1px solid #ddd;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}

#clearListBtn:hover {
    background: #e5e5e5;
}

/* Mapping table styles */
.mapping-select {
    width: 100%;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: white;
}

#mappingTableContainer .export-btn,
#mappingTableContainer .apply-filters-btn {
    padding: 8px 16px;
    font-size: 14px;
    display: inline-block;
    margin: 10px 5px 0 0;
    width: auto;
    min-width: 150px;
    border-radius: 6px;
    background-color: #007bff;
    color: white;
    border: none;
    cursor: pointer;
}

#mappingTableContainer .export-btn:hover,
#mappingTableContainer .apply-filters-btn:hover {
    background-color: #0056b3;
}

.priority-row select,
.priority-row input {
    flex: 1;
    padding: 6px 10px;
    font-size: 14px;
}

.priority-row .remove-priority-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.priority-row .remove-priority-btn:hover {
    background-color: #c0392b;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    /* Semi-transparent overlay */
}

.modal-content {
    background-color: #fff;
    /* White content box */
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1001;
}

.modal-content .close-btn-inside {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

/* Table container styles */
#mappingTableContainer {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Button styles */
.button-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.apply-filters-btn {
    background-color: #4CAF50;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.apply-filters-btn:hover {
    background-color: #45a049;
}

/* Close button */
.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: black;
}

/* ✅ IMPROVED: Filter Labels - Bold, Large, Easy to Find */
.sidebar label {
    display: block;
    margin-top: 18px;
    margin-bottom: 8px;
    font-weight: 700 !important; /* Extra bold */
    font-size: 15px !important; /* Larger text */
    color: #1a1a1a !important; /* Darker color */
    text-transform: capitalize;
    letter-spacing: 0.3px;
}

/* Saved Lists Dropdown */
.filter-group {
    margin-bottom: 15px;
}

.filter-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 700 !important;
    font-size: 15px !important;
    color: #1a1a1a !important;
}

.filter-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.list-actions {
    display: flex;
    gap: 5px;
    margin-top: 5px;
}

.list-actions button {
    flex: 1;
    padding: 5px;
    font-size: 12px;
}

/* Match CSV Modal Updates */
.modal-content .form-group {
    margin-bottom: 15px;
}

.modal-content .button-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.modal-content .button-group button {
    flex: 1;
}

/* Match CSV Modal */





#mappingTableContainer table {
    width: 100%;
    border-collapse: collapse;
}

#mappingTableContainer th,
#mappingTableContainer td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

#mappingTableContainer th {
    background-color: #f2f2f2;
    position: sticky;
    top: 0;
}

#mappingTableContainer select {
    width: 100%;
    padding: 5px;
}

#matchStatus {
    margin-top: 10px;
    font-weight: bold;
}


/* GENERAL STYLING */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f7;
    color: #1d1d1f;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}




.content-wrapper {
    display: flex;
    flex: 1;
    margin-top: 70px;
    /* Header height */
}





#sortDropdown {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #d2d2d7;
    font-size: 14px;
    margin-bottom: 15px;
    background-color: white;
    width: auto;
    display: block;
    margin: 15px 0;
}




.logo {
    height: 50px;  /* Bigger logo */
    width: auto;
}

.header-left h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: #1d1d1f;
}



.count-container {
    display: flex;
    gap: 20px;
}







.export-btn {
    background-color: #007aff;
    color: white;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.export-btn:hover {
    background-color: #0063cc;
}









.upload-btn {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    background-color: #007aff;
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.upload-btn:hover {
    background-color: #0063cc;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    top: 80px;
    left: 10px;
    background-color: #007aff;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 1001;
    display: none;
}

/* Sidebar */
.sidebar {
    width: 270px;
    background-color: #ffffff;
    padding: 20px;
    height: calc(100vh - 80px);
    padding-bottom: 10px;
    position: fixed;
    top: 102px;
    left: 0;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    z-index: 999;
}

.sidebar h2 {
    font-size: 18px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 15px;
}

.sidebar label {
    font-size: 14px;
    font-weight: 500;
    color: #6e6e73;
    display: block;
    margin-top: 10px;
}

.sidebar input {
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #d2d2d7;
    font-size: 14px;
    width: 100%;
    margin-bottom: 10px;
}

.sidebar input[type="checkbox"] {
    width: auto;
    margin-right: 5px;
}

/* Additional Filters Checkbox Container */
.additional-filters {
    width: 100%;
    margin-top: 20px; /* ✅ Add space between Tag 3 and toggle filters */
}

.checkbox-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    /* Space between filter groups */
}




/* Remove the separate label styling for checkboxes */
.additional-filters label {
    margin-top: 0;
    /* Remove the top margin that was causing misalignment */
}





/* Main Content */
.main-content {
    flex: 1;
    margin-left: 270px;
    margin-top: -2px;
    transition: margin-left 0.3s ease;
    padding: 20px 20px 60px;
    /* Added bottom padding for footer space */
    height: calc(100vh - 160px);
    /* Match sidebar height */
}

/* Table Container */
.table-container {
    width: 100%;
    min-height: 590px;
    height: auto;
    overflow-x: auto;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background-color: white;
    margin-top: 5px;
    padding: 5px;
    white-space: nowrap;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
    border-radius: 12px;
    font-size: 10px; /* ⬇️ Smaller text */
    overflow: hidden;
}

/* Table Header */
thead {
    background-color: #f5f5f7;
}

th {
    font-size: 14px;
    font-weight: 600;
    color: #1d1d1f;
    padding: 12px;
    text-align: left;
}

/* Table Body */
tr:nth-child(even) {
    background: #fafafa;
}

tr:hover {
    background: #f0f0f0;
}

td {
    padding: 10px;
    font-size: 10px;
    color: #1d1d1f;
    border-bottom: 1px solid #e0e0e0;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 15px;
    border-radius: 12px;
    margin-top: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.pagination button {
    width: 80px;
    height: 40px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.3s;
}

.pagination button:hover {
    background-color: #f5f5f7;
}

#page-number {
    font-size: 16px;
    font-weight: 600;
    color: #1d1d1f;
    padding: 10px 20px;
    border-radius: 8px;
}

/* Footer */
.footer {
    background-color: #ffffff;
    color: #6e6e73;
    padding: 15px 0;
    text-align: center;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    margin-top: auto;
    /* Pushes footer to bottom */
}

/* Modal and Popup */
.modal,
.popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1001;
}

.modal-content,
.popup-content {
    text-align: center;
}

.modal-content h2,
.popup-content h2 {
    font-size: 18px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 15px;
}

.modal-content input,
.popup-content select {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #d2d2d7;
    font-size: 14px;
    margin-bottom: 15px;
}

.modal-content button,
.popup-content button {
    background: #007aff;
    color: white;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.modal-content button:hover,
.popup-content button:hover {
    background: #0063cc;
}

.close,
.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    cursor: pointer;
    font-size: 20px;
    color: #ff3b30;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar-toggle {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

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



/* Clear Filters Button */
#clear-filters-btn {
    background-color: #007aff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
    margin-bottom: 20px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#clear-filters-btn:hover {
    background-color: #0063cc;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

#clear-filters-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#clear-filters-btn svg {
    width: 14px;
    height: 14px;
}


/* Modern Login Section CSS */
:root {
    --primary-color: #4361ee;
    --primary-dark: #3a56d4;
    --text-color: #2b2d42;
    --light-gray: #f8f9fa;
    --medium-gray: #e9ecef;
    --dark-gray: #6c757d;
    --white: #ffffff;
    --error-color: #ef233c;
    --success-color: #4cc9f0;
}

/* Base Styles */
body {
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background-color: var(--light-gray);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* Login Container */
#loginSection {
    width: 100%;
    max-width: 450px;
    /* Controls box width */
    margin: 0 auto;
    /* Additional horizontal centering */
}

#loginForm {
    background: var(--white);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    transition: all 0.3s ease;
}

#loginForm:hover {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

/* Form Elements */
#loginForm h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1.8rem;
}

.input-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.input-group input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--medium-gray);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: var(--light-gray);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

.input-group input::placeholder {
    color: var(--dark-gray);
    opacity: 0.7;
}

/* Button Styles */
#loginForm button[type="submit"] {
    width: 100%;
    padding: 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#loginForm button[type="submit"]:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

#loginForm button[type="submit"]:active {
    transform: translateY(0);
}

/* Logout button styling */
.logout-btn {
    padding: 8px 16px;
    background: none;
    border: none;
    color: #ff3b30;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    width: 100%;
    transition: background-color 0.2s ease;
}

.logout-btn:hover {
    background-color: rgba(255, 59, 48, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    #loginForm {
        padding: 2rem;
        margin: 0 1rem;
    }

    #loginForm h2 {
        font-size: 1.5rem;
    }
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#loginForm {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Additional Modern Touches */
.input-group:after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.input-group input:focus+.input-group:after {
    width: 100%;
}

/* Status Messages (for potential error/success messages) */
.status-message {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 500;
}

.error-message {
    background-color: rgba(239, 35, 60, 0.1);
    color: var(--error-color);
}

.success-message {
    background-color: rgba(76, 201, 240, 0.1);
    color: var(--success-color);
}

/* Modern Login Section CSS */
:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --text: #2b2d42;
    --text-light: #6c757d;
    --light: #f8f9fa;
    --white: #ffffff;
    --border: #e9ecef;
    --error: #ef233c;
    --success: #4cc9f0;
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #f5f7fa;
    color: var(--text);
    line-height: 1.6;
}

/* Login Container */
#loginSection {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
    background: linear-gradient(135deg, #f5f7fa 0%, #e2e8f0 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.12);
}

/* Header */
.login-header {
    padding: 2.5rem 2rem 1.5rem;
    text-align: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.login-header .logo {
    width: 50px;
    height: 50px;
    margin-bottom: 1rem;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-header p {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 400;
}

/* Form */
.login-form {
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background-color: var(--light);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.forgot-password {
    display: block;
    margin-top: 0.5rem;
    text-align: right;
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.forgot-password:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Button */
.login-button {
    width: 100%;
    padding: 1rem;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.login-button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

.login-button:active {
    transform: translateY(0);
}

.login-button svg {
    transition: transform 0.3s ease;
}

.login-button:hover svg {
    transform: translateX(3px);
}

/* Footer */
.login-footer {
    padding: 1.5rem 2rem;
    text-align: center;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-light);
}

.login-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.login-footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 480px) {
    #loginSection {
        padding: 1rem;
    }

    .login-card {
        border-radius: 12px;
    }

    .login-header {
        padding: 1.5rem 1rem 1rem;
    }

    .login-form {
        padding: 1.5rem;
    }
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-card {
    animation: fadeIn 0.6s ease-out forwards;
}


/* ✅ HORIZONTAL: Toggle Filter Groups - Label and Buttons in One Line */
.filter-toggle-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    padding: 8px 10px;
    background: #f9f9f9;
    border-radius: 6px;
}

.filter-toggle-group label {
    display: block;
    margin: 0 !important;
    padding: 0 !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    color: #1a1a1a !important;
    min-width: 95px;
    max-width: 95px;
    flex-shrink: 0;
}

.toggle-options {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.toggle-btn {
    flex: 1;
    padding: 6px 7px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-align: center;
    min-width: 32px;
    max-width: 45px;
}

.toggle-btn:hover {
    background: #f0f0f0;
    border-color: #bbb;
    transform: translateY(-1px);
}

.toggle-btn.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

.toggle-btn.active[data-value="no"] {
    background: #f44336;
    border-color: #f44336;
    box-shadow: 0 2px 4px rgba(244, 67, 54, 0.3);
}

.toggle-btn.active[data-value="all"] {
    background: #2196F3;
    border-color: #2196F3;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
}

/* Add this to your CSS */
.filter-action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    padding: 10px 0;
}

.apply-filters-btn,
#clear-filters-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    border: none;
}

.apply-filters-btn {
    background-color: #007aff;
    color: white;
}

.apply-filters-btn:hover {
    background-color: #0063cc;
}

#clear-filters-btn {
    background-color: #007aff;
    color: white;
}

#clear-filters-btn:hover {
    background-color: #0063cc;
}

.filter-action-buttons svg {
    width: 16px;
    height: 16px;
}

/* Freeze header and columns */
.dataTables_scrollHead {
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
}

/* Frozen columns styling */
.DTFC_LeftBodyWrapper {
    border-right: 2px solid #ddd;
    background: white;
}

/* Button to toggle columns */
.btn-column-toggle {
    background: #007aff !important;
    color: white !important;
    border: none;
    padding: 8px 12px;
    margin-bottom: 10px;
}

/* Highlight selected columns */
table.dataTable tbody td {
    cursor: cell;
    /* Google Sheets-like cursor */
}

/* Hover effect */
table.dataTable tbody tr:hover {
    background: #f5f5f5 !important;
}

/* ========== OLD DATATABLES STYLES - COMMENTED OUT ========== */
/*
.dataTables_scrollHead {
    display: block !important;
}

.dataTables_scrollBody thead {
    display: none !important;
}
*/

/* ========== AG GRID CUSTOM STYLES ========== */
/* Modern AG Grid styling */
.ag-theme-alpine {
    --ag-header-height: 40px;
    --ag-header-foreground-color: #333;
    --ag-header-background-color: #f8f9fa;
    --ag-odd-row-background-color: #ffffff;
    --ag-row-hover-color: #f5f5f5;
    --ag-selected-row-background-color: #e3f2fd;
    --ag-border-color: #ddd;
    --ag-font-size: 14px;
    --ag-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Sticky header - fixed for horizontal scrolling */
.ag-theme-alpine .ag-header {
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ✅ Hide the arrow in top-left corner */
.ag-theme-alpine .ag-header-select-all {
    display: none !important;
}

/* ✅ Column resize handle - MUCH more visible */
.ag-theme-alpine .ag-header-cell-resize {
    width: 8px !important;
    background-color: #d0d0d0 !important;
    cursor: col-resize !important;
    opacity: 1 !important;
    right: -4px !important;
    z-index: 10 !important;
}

.ag-theme-alpine .ag-header-cell-resize:hover {
    background-color: #007aff !important;
    width: 10px !important;
    right: -5px !important;
}

/* ✅ Add a visible line on the resize handle */
.ag-theme-alpine .ag-header-cell-resize::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    background-color: #999;
}

.ag-theme-alpine .ag-header-cell-resize:hover::before {
    background-color: white;
    width: 3px;
}

/* Header cells - merged with border styling above */
.ag-theme-alpine .ag-header-cell {
    font-weight: 600;
    padding: 0 12px;
    border-right: 1px solid #d8d8d8 !important; /* ✅ Slimmer and lighter */
}

/* Cell styling - merged with border styling above */
.ag-theme-alpine .ag-cell {
    padding: 0 12px;
    line-height: 35px;
    border-right: 1px solid #e8e8e8 !important;
}

/* Pinned column styling */
.ag-theme-alpine .ag-pinned-left-header,
.ag-theme-alpine .ag-pinned-left-cols-container {
    border-right: 2px solid #007aff;
}

/* Filter icon */
.ag-theme-alpine .ag-icon-filter {
    color: #007aff;
}

/* Sort icon */
.ag-theme-alpine .ag-icon-asc,
.ag-theme-alpine .ag-icon-desc {
    color: #007aff;
}

/* ✅ IMPROVED: Column Resizer (Google Sheets-like) - ALWAYS VISIBLE */
.column-resizer {
    position: absolute !important;
    top: 0 !important;
    right: -2px !important; /* Position on border */
    width: 4px !important; /* Visible line */
    height: 100% !important;
    cursor: col-resize !important;
    background-color: #d0d0d0 !important; /* Gray - always visible */
    z-index: 99999 !important;
    transition: all 0.2s ease !important;
    pointer-events: auto !important;
    display: block !important;
    border-right: 1px solid #bbb !important; /* Make it stand out */
}

.column-resizer:hover {
    background-color: #007aff !important; /* Blue on hover */
    width: 6px !important;
    right: -3px !important;
}

/* Active resizing state */
.column-resizer.resizing {
    background-color: #007aff !important;
    width: 6px !important;
    right: -3px !important;
}

/* Ensure table headers have proper positioning */
table.dataTable thead th {
    position: relative !important;
    user-select: none;
    overflow: visible !important; /* Allow resizer to overflow */
}

/* Prevent DataTables from interfering with resizer */
table.dataTable thead th > * {
    pointer-events: none;
}

table.dataTable thead th .column-resizer {
    pointer-events: auto !important;
}

table.dataTable td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    cursor: pointer;
    position: relative;
}

table.dataTable td:hover {
    background-color: #f5f5f5;
}

/* Ensure headers have relative positioning */
table.dataTable thead th {
    position: relative;
}

/* Prevent text selection during resize */
table.dataTable thead th {
    user-select: none;
    -webkit-user-select: none;
}

.cell-popup {
    background: white;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    max-height: 300px;
    overflow: auto;
    padding: 15px;
    word-wrap: break-word;
    white-space: normal !important;
}

.cell-popup-content {
    white-space: normal;
}

/* ========================================
   Analytics 2.0 Styles
   ======================================== */

#analyticsV2Container {
    width: 100%;
    background-color: transparent;
}

#analyticsView {
    width: 100%;
    padding: 0;
    margin: 0;
}

.analytics-v2-wrapper {
    width: 100%;
    padding: 20px;
    margin: 0;
    margin-bottom: 40px;
    min-height: calc(100vh - 200px);
    background-color: #f8f9fa;
}

/* Header */
.analytics-v2-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.analytics-v2-title {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.analytics-v2-actions {
    display: flex;
    gap: 12px;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.add-field-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-field-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.apply-filter-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.apply-filter-btn:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.reset-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.reset-btn i {
    transition: transform 0.3s ease;
}

.reset-btn:hover i {
    transform: rotate(-180deg);
}

/* Stats Panel */
.stats-panel {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e5e7eb;
}

.stats-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.total-count {
    font-size: 18px;
    font-weight: 700;
    color: #3b82f6;
}

.total-count span {
    font-size: 24px;
}

.analytics-v2-stats,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    width: 100%;
}

.stat-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    min-width: 0;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #3b82f6;
}

.stat-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 18px;
    flex-shrink: 0;
    color: white;
}

/* Icon color variations */
.stat-icon.direct-dial {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.stat-icon.work-email {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.stat-icon.personal-email {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.stat-icon.facebook {
    background: linear-gradient(135deg, #1877f2 0%, #0c63d4 100%);
}

.stat-icon.linkedin {
    background: linear-gradient(135deg, #0a66c2 0%, #004182 100%);
}

.stat-icon.website {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.stat-icon.ecommerce {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
}

.stat-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.stat-label {
    font-size: 10px;
    color: #6b7280;
    font-weight: 600;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-values {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stat-primary {
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex-wrap: wrap;
}

.stat-count {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
}

.stat-percent {
    font-size: 12px;
    font-weight: 600;
    color: #3b82f6;
    white-space: nowrap;
}

.stat-secondary {
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
    margin-top: 2px;
    line-height: 1.3;
    word-break: break-word;
}

.stat-secondary span {
    font-weight: 700;
    color: #3b82f6;
    font-size: 12px;
    white-space: nowrap;
}

/* Percentage color coding */
.stat-value.high {
    color: #10b981;
}

.stat-value.medium {
    color: #f59e0b;
}

.stat-value.low {
    color: #ef4444;
}

/* Applied Filters Section */
.applied-filters-section {
    background: white;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.applied-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    transition: background 0.2s;
}

.applied-filters-header:hover {
    background: linear-gradient(135deg, #f1f5f9 0%, #ffffff 100%);
}

.filters-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}

.filters-title i {
    color: #3b82f6;
    font-size: 16px;
}

.filters-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    background: #3b82f6;
    color: white;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

.filters-toggle-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    transition: all 0.2s;
}

.filters-toggle-btn:hover {
    color: #3b82f6;
    transform: scale(1.1);
}

.filters-toggle-btn i {
    transition: transform 0.3s;
}

.applied-filters-section.collapsed .filters-toggle-btn i {
    transform: rotate(-90deg);
}

.applied-filters-content {
    max-height: 300px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.applied-filters-section.collapsed .applied-filters-content {
    max-height: 0;
}

.filters-scroll-container {
    padding: 15px 20px;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.filters-scroll-container::-webkit-scrollbar {
    width: 6px;
}

.filters-scroll-container::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.filters-scroll-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.applied-filters-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-category {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-category-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #1e40af;
    border: 1px solid #bfdbfe;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-chip:hover {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.filter-chip.toggle-filter {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border-color: #6ee7b7;
}

.filter-chip.toggle-filter:hover {
    background: linear-gradient(135deg, #a7f3d0 0%, #6ee7b7 100%);
}

.filter-chip.toggle-filter-no {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border-color: #fca5a5;
}

.filter-chip.toggle-filter-no:hover {
    background: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%);
}

.filter-chip i {
    font-size: 10px;
}

.filter-chip-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
}

/* Analytics Filters Breadcrumb */
.analytics-filters-breadcrumb {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fbbf24;
    border-radius: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.breadcrumb-label {
    font-size: 13px;
    font-weight: 600;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 6px;
}

.breadcrumb-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: white;
    color: #92400e;
    border: 1px solid #fbbf24;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.breadcrumb-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}

.breadcrumb-item .remove-filter {
    cursor: pointer;
    font-weight: bold;
    margin-left: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.breadcrumb-item .remove-filter:hover {
    opacity: 1;
}

.clear-analytics-filters-btn {
    padding: 6px 12px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.clear-analytics-filters-btn:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

/* View Tabs */
.view-tabs {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.tab-btn {
    padding: 10px 24px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    background: #f9fafb;
    border-color: #3b82f6;
    color: #3b82f6;
}

.tab-btn.active {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-color: #3b82f6;
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.tab-btn i {
    font-size: 16px;
}

/* View Content */
.view-content {
    display: none;
    position: relative;
    min-height: 500px;
}

.view-content.active {
    display: block;
}

/* Loading Overlay */
.analytics-v2-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 500px;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: flex-start; /* Changed from center to flex-start */
    justify-content: center;
    padding-top: 40px; /* Add padding from top */
    z-index: 100;
    border-radius: 12px;
}

/* Loading Spinner Card */
.analytics-v2-loading .loading-spinner {
    background: white;
    padding: 40px 60px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
    border: 1px solid #e5e7eb;
}

.spinner-circle {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 5px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    font-size: 16px;
    font-weight: 600;
    color: #3b82f6;
}

/* Legends Section Header */
.legends-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.legends-section-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.legends-section-title i {
    color: #3b82f6;
    font-size: 20px;
}

/* Unhide Fields Button */
.unhide-fields-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.unhide-fields-btn:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.unhide-badge {
    background: rgba(255, 255, 255, 0.3);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

/* Legends Horizontal Scroll Wrapper */
.legends-scroll-wrapper {
    position: relative;
    margin-bottom: 30px;
}

.legends-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
    padding: 10px 0;
    margin: 0 60px;
}

.legends-scroll-container::-webkit-scrollbar {
    height: 8px;
}

.legends-scroll-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.legends-scroll-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.legends-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Legends Grid - Horizontal Layout */
.legends-grid {
    display: flex;
    gap: 15px;
    min-width: min-content;
}

.legends-grid.has-extra-fields {
    display: flex;
}

/* Scroll Buttons */
.scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.scroll-btn:hover {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.scroll-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.scroll-btn-left {
    left: 0;
}

.scroll-btn-right {
    right: 0;
}

.scroll-btn i {
    font-size: 18px;
}

.scroll-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.legend-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    min-width: 280px;
    max-width: 280px;
    flex-shrink: 0;
    overflow: hidden;
    will-change: transform;
}

.legend-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* Empty Legend State */
.empty-legend {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.no-data-message {
    text-align: center;
    padding: 30px 20px;
    color: #6b7280;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.no-data-message i {
    font-size: 24px;
    color: #9ca3af;
}

/* Add Field Card */
.add-field-card {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px dashed #3b82f6;
    min-height: 200px;
}

.add-field-card:hover {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: #2563eb;
    transform: translateY(-3px) scale(1.02);
}

.add-field-content {
    text-align: center;
}

.add-field-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 12px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.add-field-card:hover .add-field-icon {
    transform: rotate(90deg);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.add-field-icon i {
    font-size: 28px;
    color: white;
}

.add-field-text {
    font-size: 16px;
    font-weight: 600;
    color: #1e40af;
}

.legend-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
    position: relative;
}

.legend-card-title {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    text-transform: capitalize;
    flex: 1;
}

/* Legend Search Bar */
.legend-search-container {
    position: relative;
    margin-bottom: 12px;
}

.legend-search-input {
    width: 100%;
    padding: 8px 35px 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    color: #1f2937;
    background: #f9fafb;
    transition: all 0.2s ease;
}

.legend-search-input:focus {
    outline: none;
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.legend-search-input::placeholder {
    color: #9ca3af;
}

.legend-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 13px;
    pointer-events: none;
}

.no-search-results {
    padding: 20px;
    text-align: center;
    color: #6b7280;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.search-more-results {
    padding: 12px;
    text-align: center;
    color: #3b82f6;
    font-size: 12px;
    background: #eff6ff;
    border-radius: 6px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.legend-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-menu-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    position: relative;
}

.legend-menu-btn:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.legend-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    z-index: 100;
    display: none;
}

.legend-menu-dropdown.show {
    display: block;
}

.legend-menu-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    color: #1f2937;
    transition: background 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-menu-item:hover {
    background: #f3f4f6;
}

.legend-menu-item:first-child {
    border-radius: 8px 8px 0 0;
}

.legend-menu-item:last-child {
    border-radius: 0 0 8px 8px;
}

.legend-card.hidden {
    display: none;
}

.legend-remove-btn {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s ease;
}

.legend-remove-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.legend-items {
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
    scroll-behavior: smooth;
}

.legend-items::-webkit-scrollbar {
    width: 6px;
}

.legend-items::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.legend-items::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

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

.legend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f9fafb;
    min-width: 0;
}

.legend-item:hover {
    background: #e5e7eb;
    transform: translateX(2px);
}

.legend-item.selected {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.legend-item-label {
    font-size: 13px;
    font-weight: 500;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    padding-right: 8px;
    position: relative;
    cursor: pointer;
}

/* Tooltip on hover for truncated text */
.legend-item-label:hover::after {
    content: attr(data-full-text);
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 4px;
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: normal;
    word-wrap: break-word;
    max-width: 300px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

/* Arrow for tooltip */
.legend-item-label:hover::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 100%;
    border: 6px solid transparent;
    border-bottom-color: #1f2937;
    z-index: 1001;
    pointer-events: none;
}

.legend-item-count {
    font-size: 12px;
    font-weight: 700;
    color: #3b82f6;
    flex-shrink: 0;
}

.legend-item.selected .legend-item-count {
    color: white;
}

.legend-load-more {
    text-align: center;
    padding: 8px;
    color: #3b82f6;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.legend-load-more:hover {
    color: #2563eb;
    background: #f0f9ff;
    border-radius: 6px;
}

.legend-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 8px;
    color: #3b82f6;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.legend-loading i.fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.legend-chart-container {
    display: none !important;
}

.legend-chart-container canvas {
    display: none !important;
}

/* Fix alignment for legends with few items */
.legend-items.few-items + .legend-chart-container {
    display: none !important;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #e5e7eb;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.modal-body {
    padding: 25px;
    max-height: calc(80vh - 100px);
    overflow-y: auto;
}

.field-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.field-option {
    padding: 12px 16px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.field-option:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.field-option.added {
    background: #10b981;
    color: white;
    border-color: #10b981;
    cursor: not-allowed;
}

.field-option.added:hover {
    transform: none;
    box-shadow: none;
}

/* Loading State */
.legend-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

.legend-card.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Responsive Design */
@media (max-width: 1600px) {
    .legends-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 1200px) {
    .legends-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .legends-grid.has-extra-fields {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 900px) {
    .legends-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .analytics-v2-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .analytics-v2-title {
        font-size: 22px;
        text-align: center;
    }

    .analytics-v2-actions {
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .legends-grid {
        grid-template-columns: 1fr;
    }

    .breadcrumb-container {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Large Desktop (>1600px) - Larger minimum for better fit */
@media (min-width: 1600px) {
    .analytics-v2-stats,
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    }
}

/* Desktop (1200px-1599px) */
@media (max-width: 1599px) and (min-width: 1200px) {
    .analytics-v2-stats,
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
        gap: 10px;
    }
}

/* Medium Desktop (992px-1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
    .analytics-v2-stats,
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
    }
}

/* Tablet (768px-991px) */
@media (max-width: 991px) and (min-width: 768px) {
    .analytics-v2-stats,
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .filter-chip {
        max-width: 200px;
        font-size: 11px;
    }
}

/* Small Tablet (576px-767px) */
@media (max-width: 767px) and (min-width: 576px) {
    .analytics-v2-stats,
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .filter-chip {
        max-width: 200px;
        font-size: 11px;
    }
}

/* Mobile (<576px) */
@media (max-width: 575px) {
    .analytics-v2-wrapper {
        padding: 12px;
    }

    .analytics-v2-header {
        padding: 15px;
    }
    
    .analytics-v2-stats,
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .filter-chip {
        max-width: 150px;
    }

    .stats-panel {
        padding: 15px;
    }

    .legend-card {
        padding: 15px;
    }
}
