:root {
    --primary-color: #0066cc;
    --secondary-color: #003183;
    --accent-color: #4ecdc4;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --light-bg: #f8f9fa;
    --card-bg: rgba(255, 255, 255, 0.95);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-accent: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --shadow-light: 0 2px 15px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.12);
    --shadow-heavy: 0 20px 40px rgba(0, 0, 0, 0.15);
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 400;
    line-height: 1.6;
}

/* Sfondo con particelle animate */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    z-index: -1;
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-20px) rotate(1deg); }
    66% { transform: translateY(10px) rotate(-1deg); }
}

.bg-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%) !important;
}

.card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    box-shadow: var(--shadow-light);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.card:hover::before {
    left: 100%;
}

.card:hover {
    transform: translateY(-5px) scale(1.01);
    box-shadow: var(--shadow-heavy);
    border-color: rgba(255, 255, 255, 0.5);
}

.card-header {
    background: rgba(248, 249, 250, 0.8) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 15px 15px 0 0 !important;
}

.form-select, .form-control {
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-weight: 500;
    padding: 12px 16px;
}

.form-select:focus, .form-control:focus {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 0 0 0.3rem rgba(78, 205, 196, 0.25), 
                0 8px 25px rgba(78, 205, 196, 0.15);
    transform: translateY(-2px);
}

.form-select:hover, .form-control:hover {
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.form-label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--gradient-accent);
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 25px rgba(79, 172, 254, 0.4);
}

.btn-outline-primary {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 12px;
    padding: 8px 16px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(10px);
}

.btn-outline-primary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 255, 255, 0.2);
}

.btn-outline-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#chartContainer canvas {
    border-radius: 10px;
}

.table {
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow-light);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.table thead th {
    background: var(--gradient-accent);
    color: white;
    border: none;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
    padding: 20px 15px;
    position: relative;
}

.table thead th::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
}

.table tbody td {
    padding: 15px;
    font-weight: 500;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.table tbody tr {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.table tbody tr:hover {
    background: linear-gradient(90deg, rgba(78, 205, 196, 0.1), rgba(79, 172, 254, 0.1));
    transform: scale(1.01);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border: 0.3em solid transparent;
    border-top: 0.3em solid;
    border-image: var(--gradient-accent) 1;
    animation: spin 1s linear infinite, pulse 2s ease-in-out infinite alternate;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { opacity: 0.8; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.1); }
}

/* Loading shimmer effect */
.loading-shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

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

/* Province select dropdown fix */
select[multiple] {
    min-height: 120px !important;
    padding: 8px 12px !important;
}

select[multiple] option {
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
}

select[multiple] option:hover {
    background: rgba(78, 205, 196, 0.2);
}

select[multiple] option:checked {
    background: var(--accent-color) !important;
    color: white !important;
    font-weight: 600;
}

#provinceSelect {
    min-height: 120px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) rgba(255, 255, 255, 0.1);
}

#provinceSelect::-webkit-scrollbar {
    width: 8px;
}

#provinceSelect::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#provinceSelect::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 4px;
}

#provinceSelect::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Alerts migliorati */
.alert {
    border-radius: 15px;
    border: none;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-light);
    animation: slideInDown 0.5s ease-out;
}

.alert-info {
    background: linear-gradient(135deg, rgba(79, 172, 254, 0.1), rgba(78, 205, 196, 0.1));
    border-left: 4px solid var(--accent-color);
}

.alert-success {
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.1), rgba(78, 205, 196, 0.1));
    border-left: 4px solid var(--success-color);
}

.alert-danger {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.1), rgba(245, 87, 108, 0.1));
    border-left: 4px solid #dc3545;
}

@keyframes slideInDown {
    from {
        transform: translate3d(0, -100%, 0);
        opacity: 0;
    }
    to {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .card {
        margin-bottom: 20px;
    }
    
    .row > .col-md-6 {
        margin-bottom: 15px;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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