* {
    scrollbar-width: thin;
    scrollbar-color: #4b5563 transparent;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 3px;
    transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

*:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

.animate-fade-in-up {
    animation: fadeInUp 0.4s ease-out both;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out both;
}

.animate-slide-down {
    animation: slideDown 0.3s ease-out both;
}

.animate-scale-in {
    animation: scaleIn 0.25s ease-out both;
}

#data-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

#data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

#data-table th {
    background: #1e293b;
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #334155;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

#data-table th:hover {
    background: #334155;
    color: #e2e8f0;
}

#data-table th.sorted-asc::after {
    content: ' ↑';
    font-size: 0.7em;
    opacity: 0.8;
}

#data-table th.sorted-desc::after {
    content: ' ↓';
    font-size: 0.7em;
    opacity: 0.8;
}

#data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #1e293b;
    color: #cbd5e1;
    font-size: 0.875rem;
    transition: background 0.15s;
}

#data-table tbody tr {
    transition: background 0.15s;
}

#data-table tbody tr:nth-child(even) {
    background: rgba(30, 41, 59, 0.3);
}

#data-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.08);
}

#data-table tbody tr:last-child td {
    border-bottom: none;
}

.kpi-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid #334155;
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #3b82f6);
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: #475569;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.kpi-card.global-count {
    background: linear-gradient(135deg, #1e3a5f 0%, #172554 100%);
    border-color: #1d4ed8;
}

.kpi-card.global-count::before {
    background: linear-gradient(90deg, #60a5fa, #3b82f6, #60a5fa);
    background-size: 200% 100%;
}

.kpi-card.global-count:hover {
    border-color: #3b82f6;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.15), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.kpi-card select {
    background: #1e293b;
    border: 1px solid #475569;
    color: #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.kpi-card select:hover {
    border-color: #3b82f6;
}

.kpi-card select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    outline: none;
}

.filter-widget {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.75rem;
    padding: 1rem;
    transition: border-color 0.2s;
}

.filter-widget:hover {
    border-color: #475569;
}

.filter-widget label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 0.625rem;
    letter-spacing: 0.01em;
}

.range-slider-container {
    position: relative;
    height: 40px;
    display: flex;
    align-items: center;
}

.range-slider-container input[type="range"] {
    position: absolute;
    left: 0;
    right: 0;
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    pointer-events: none;
}

.range-slider-container input[type="range"]:focus {
    z-index: 2;
}

.range-slider-container .range-max {
    z-index: 1;
}

.range-slider-container input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: #334155;
    border-radius: 3px;
}

.range-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: -7px;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.range-slider-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.range-slider-container input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(0.95);
}

.range-slider-container input[type="range"]::-moz-range-track {
    height: 6px;
    background: #334155;
    border-radius: 3px;
}

.range-slider-container input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.range-slider-values {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #94a3b8;
}

.range-slider-values input {
    width: 72px;
    padding: 0.375rem 0.5rem;
    border: 1px solid #475569;
    border-radius: 0.375rem;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.75rem;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.range-slider-values input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    outline: none;
}

.range-slider-values input:hover {
    border-color: #64748b;
}

.checkbox-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    padding: 0.375rem;
    background: #0f172a;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background 0.15s;
}

.checkbox-item:hover {
    background: rgba(59, 130, 246, 0.1);
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #3b82f6;
    cursor: pointer;
    border-radius: 3px;
    transition: transform 0.15s;
}

.checkbox-item input[type="checkbox"]:checked {
    transform: scale(1.1);
}

.checkbox-item label {
    margin: 0;
    font-size: 0.8125rem;
    color: #cbd5e1;
    cursor: pointer;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 400;
}

.checkbox-search {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #475569;
    border-radius: 0.5rem;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.8125rem;
    margin-bottom: 0.5rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.checkbox-search::placeholder {
    color: #64748b;
}

.checkbox-search:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    outline: none;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem 0.25rem 0.75rem;
    background: linear-gradient(135deg, #1e3a5f, #1e40af);
    color: #93c5fd;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
    animation: scaleIn 0.2s ease-out;
}

.filter-tag:hover {
    background: linear-gradient(135deg, #1e40af, #2563eb);
    color: #bfdbfe;
}

.filter-tag button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    line-height: 1;
    color: #93c5fd;
    opacity: 0.7;
    transition: opacity 0.15s, transform 0.15s;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    border-radius: 50%;
}

.filter-tag button:hover {
    opacity: 1;
    transform: scale(1.2);
    background: rgba(255, 255, 255, 0.1);
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.625rem;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #cbd5e1;
    background: #1e293b;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.pagination-btn:hover:not(:disabled) {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
    transform: translateY(-1px);
}

.pagination-btn:active:not(:disabled) {
    transform: translateY(0);
}

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

.pagination-btn.active:hover {
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #0f172a;
    border-color: #1e293b;
}

#main-chart {
    max-height: 100%;
    width: 100% !important;
    height: 100% !important;
}

#drop-zone {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

#drop-zone::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6, #3b82f6);
    background-size: 200% 200%;
    opacity: 0;
    transition: opacity 0.4s;
    border-radius: inherit;
    z-index: -1;
    filter: blur(4px);
}

#drop-zone:hover::before,
#drop-zone.drag-active::before {
    opacity: 0.3;
}

#drop-zone.drag-active {
    border-color: transparent;
    background: rgba(59, 130, 246, 0.05);
    transform: scale(1.01);
}

#drop-zone svg {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#drop-zone:hover svg {
    transform: translateY(-4px);
}

#loading-indicator {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease-out;
}

#loading-indicator > div {
    animation: scaleIn 0.3s ease-out;
}

.animate-spin {
    animation: spin 0.8s linear infinite;
}

.chartjs-tooltip {
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(59, 130, 246, 0.2) !important;
    border-radius: 0.75rem !important;
    padding: 0.75rem 1rem !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3) !important;
}

#column-visibility-modal {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

#column-visibility-modal > div {
    animation: scaleIn 0.25s ease-out;
}

#column-visibility-list label {
    transition: color 0.15s;
}

#column-visibility-list input[type="checkbox"] {
    accent-color: #3b82f6;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    cursor: pointer;
}

#data-summary {
    transition: all 0.3s ease;
}

#summary-details {
    animation: slideDown 0.3s ease-out;
}

#summary-body td {
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
}

#active-filters-summary {
    animation: slideDown 0.3s ease-out;
}

@media (max-width: 640px) {
    #chart-section .flex-wrap {
        flex-direction: column;
        align-items: stretch;
    }

    #chart-section select {
        width: 100%;
    }

    .kpi-card {
        padding: 1.125rem;
    }

    .kpi-card select {
        font-size: 0.75rem;
    }

    .filter-widget {
        padding: 0.75rem;
    }
}
