:root {
    --bg-main: #0b1120; 
    --bg-card: #131c31; 
    --border-color: #1e293b;
    --text-main: #f1f5f9; 
    --text-muted: #94a3b8; 
    --accent: #38bdf8;
    --accent-hover: #0284c7; 
    --danger: #ef4444; 
    --success: #22c55e; 
    --warning: #f59e0b;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; 
}

body { 
    background-color: var(--bg-main); 
    color: var(--text-main); 
    display: flex; 
    height: 100vh; 
    overflow: hidden; 
}

/* MENÚ LATERAL (SIDEBAR) REFINAT */
aside { 
    width: 270px; 
    background-color: var(--bg-card); 
    border-right: 1px solid var(--border-color); 
    display: flex; 
    flex-direction: column; 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    z-index: 100; 
}

.sidebar-brand { 
    padding: 1.5rem; 
    font-size: 1.15rem; 
    font-weight: 800; 
    letter-spacing: 0.5px;
    color: var(--accent); 
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 0.75rem; 
}

.sidebar-close, .menu-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
    transition: color 0.2s;
}

.sidebar-close:hover, .menu-toggle:hover {
    color: var(--text-main);
}

.sidebar-menu { 
    list-style: none; 
    padding: 1rem 0; 
    flex: 1; 
    overflow-y: auto; 
}

.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}
.sidebar-menu::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.sidebar-menu li a { 
    display: flex; 
    align-items: center; 
    gap: 0.85rem; 
    padding: 0.85rem 1.5rem; 
    color: var(--text-muted); 
    text-decoration: none; 
    font-size: 0.9rem; 
    font-weight: 500;
    transition: all 0.2s ease; 
}

.sidebar-menu li a i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-menu li.active a, 
.sidebar-menu li a:hover { 
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.12) 0%, rgba(56, 189, 248, 0) 100%); 
    color: var(--accent); 
    border-left: 4px solid var(--accent); 
}

/* ÀREA PRINCIPAL I CAPÇALERA */
main { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    overflow-y: auto; 
    width: 100%; 
    min-width: 0; 
}

header { 
    background-color: var(--bg-card); 
    border-bottom: 1px solid var(--border-color); 
    padding: 1rem 2rem; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: 1rem; 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.dashboard-content { 
    padding: 2rem; 
    max-width: 1500px; 
    width: 100%; 
    margin: 0 auto; 
}

/* TARGETES I MÈTRIQUES MODERNES */
.card { 
    background-color: var(--bg-card); 
    border: 1px solid var(--border-color); 
    border-radius: 12px; 
    padding: 1.75rem; 
    margin-bottom: 1.5rem; 
    width: 100%; 
    overflow: hidden; 
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

.card h2 { 
    font-size: 1.15rem; 
    margin-bottom: 1.25rem; 
    border-bottom: 1px solid var(--border-color); 
    padding-bottom: 0.75rem; 
    color: var(--text-main); 
    display: flex; 
    align-items: center; 
    gap: 0.65rem; 
    font-weight: 600;
}

.card h2 i {
    color: var(--accent);
}

.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); 
    gap: 1.25rem; 
    margin-bottom: 1.75rem; 
}

.stat-card { 
    background-color: var(--bg-card); 
    border: 1px solid var(--border-color); 
    border-radius: 12px; 
    padding: 1.25rem 1.5rem; 
    display: flex; 
    align-items: center; 
    gap: 1.25rem; 
    min-width: 0; 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(56, 189, 248, 0.3);
}

.stat-icon { 
    font-size: 1.75rem; 
    color: var(--accent); 
    background: rgba(56, 189, 248, 0.1); 
    width: 55px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px; 
    flex-shrink: 0; 
}

.stat-info h3 { 
    font-size: 0.8rem; 
    color: var(--text-muted); 
    font-weight: 600; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-info p { 
    font-size: 1.4rem; 
    font-weight: 700; 
    color: var(--text-main); 
    margin-top: 0.2rem; 
}

.grid-dashboard { 
    display: grid; 
    grid-template-columns: 2fr 1fr; 
    gap: 1.5rem; 
}

.calendar-container { 
    width: 100%; 
    height: 460px; 
    border-radius: 10px; 
    overflow: hidden; 
    border: 1px solid var(--border-color); 
    background: #ffffff; 
}

.calendar-container iframe { 
    width: 100%; 
    height: 100%; 
    border: none; 
}

/* FORMULARIS I BOTONS */
form label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

form input, form select, form textarea { 
    width: 100%; 
    padding: 0.75rem 1rem; 
    margin-bottom: 1.2rem; 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    background: var(--bg-main); 
    color: var(--text-main); 
    font-size: 0.9rem; 
    transition: border-color 0.2s, box-shadow 0.2s;
}

form input:focus, form select:focus, form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.action-btn { 
    background: rgba(255, 255, 255, 0.03); 
    border: 1px solid var(--border-color); 
    color: var(--text-main); 
    padding: 0.85rem 1.25rem; 
    border-radius: 10px; 
    text-decoration: none; 
    font-size: 0.9rem; 
    font-weight: 600; 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    transition: all 0.2s ease; 
    width: 100%; 
    justify-content: flex-start; 
}

.action-btn:hover {
    background: rgba(56, 189, 248, 0.08);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateX(3px);
}

/* MENÚ DESPLEGABLE D'USUARI */
.user-dropdown-container { 
    position: relative; 
    display: inline-block; 
}

.user-meta-trigger { 
    display: flex; 
    align-items: center; 
    gap: 0.65rem; 
    background: rgba(255, 255, 255, 0.04); 
    padding: 0.5rem 1rem; 
    border-radius: 8px; 
    cursor: pointer; 
    color: var(--text-main); 
    border: 1px solid var(--border-color); 
    transition: background 0.2s;
}

.user-meta-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
}

.dropdown-menu-custom { 
    display: none; 
    position: absolute; 
    right: 0; 
    top: 100%; 
    margin-top: 10px; 
    background: var(--bg-card); 
    border: 1px solid var(--border-color); 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4); 
    border-radius: 10px; 
    width: 240px; 
    z-index: 1000; 
    overflow: hidden; 
    animation: dropdownFade 0.2s ease;
}

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

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

.dropdown-item-custom { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    padding: 0.8rem 1.2rem; 
    color: var(--text-main); 
    text-decoration: none; 
    font-size: 0.88rem; 
    border-bottom: 1px solid var(--border-color); 
    background: transparent; 
    width: 100%; 
    border: none; 
    text-align: left; 
    cursor: pointer; 
    transition: background 0.15s, color 0.15s;
}

.dropdown-item-custom:hover { 
    background: rgba(56, 189, 248, 0.1); 
    color: var(--accent); 
}

/* FINESTRES MODALS */
.modal-custom { 
    display: none; 
    position: fixed; 
    top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(11, 17, 32, 0.75); 
    backdrop-filter: blur(4px);
    z-index: 2000; 
    justify-content: center; 
    align-items: center; 
    padding: 1rem;
}

.modal-custom.show { 
    display: flex; 
}

.modal-content-custom { 
    background: var(--bg-card); 
    padding: 2rem; 
    border-radius: 14px; 
    width: 100%; 
    max-width: 440px; 
    border: 1px solid var(--border-color); 
    color: var(--text-main); 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); 
    animation: modalScale 0.25s ease;
}

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

.modal-content-custom h3 { 
    margin-top: 0; 
    margin-bottom: 1.25rem; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    font-size: 1.15rem;
    color: var(--text-main);
}

.modal-actions { 
    display: flex; 
    justify-content: flex-end; 
    gap: 0.75rem; 
    margin-top: 1.5rem; 
}

/* ALERTES */
.alert-success { 
    background: rgba(34, 197, 94, 0.12); 
    color: #4ade80; 
    border: 1px solid rgba(34, 197, 94, 0.25); 
    padding: 1rem 1.25rem; 
    border-radius: 10px; 
    margin-bottom: 1.5rem; 
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.alert-error { 
    background: rgba(239, 68, 68, 0.12); 
    color: #f87171; 
    border: 1px solid rgba(239, 68, 68, 0.25); 
    padding: 1rem 1.25rem; 
    border-radius: 10px; 
    margin-bottom: 1.5rem; 
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

/* BADGES I ETIQUETES */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-accent {
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

/* PÀGINA D'ACCÉS (LOGIN) */
.login-body { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    min-height: 100vh; 
    margin: 0; 
    background-color: var(--bg-main); 
}

.login-card { 
    background-color: var(--bg-card); 
    border: 1px solid var(--border-color); 
    padding: 2.5rem; 
    border-radius: 16px; 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4); 
    width: 100%; 
    max-width: 420px; 
}

.login-header { 
    text-align: center; 
    margin-bottom: 2rem; 
}

.login-header i { 
    font-size: 2.5rem; 
    color: var(--accent); 
    margin-bottom: 0.75rem; 
}

.login-header h2 { 
    color: var(--text-main); 
    font-size: 1.5rem; 
    font-weight: 700; 
}

.login-header p { 
    color: var(--text-muted); 
    font-size: 0.875rem; 
    margin-top: 0.25rem; 
}

.btn-primary { 
    width: 100%; 
    background: var(--accent); 
    color: #0b1120; 
    border: none; 
    padding: 0.8rem; 
    border-radius: 8px; 
    font-size: 0.95rem; 
    font-weight: 700; 
    cursor: pointer; 
    transition: background 0.2s, transform 0.1s; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 0.5rem; 
}

.btn-primary:hover { 
    background: var(--accent-hover); 
    color: white; 
}

.btn-primary:active {
    transform: scale(0.98);
}

/* ADAPTACIÓ MÒVIL RESPONSIVE */
@media (max-width: 1100px) { 
    .grid-dashboard { 
        grid-template-columns: 1fr; 
    } 
}

@media (max-width: 768px) {
    body { 
        position: relative; 
    }
    aside { 
        position: fixed; 
        top: 0; 
        left: 0; 
        height: 100%; 
        transform: translateX(-100%); 
    }
    aside.mobile-open { 
        transform: translateX(0); 
    }
    .sidebar-close, .menu-toggle { 
        display: block; 
    }
    header { 
        padding: 0.75rem 1rem; 
    }
    .dashboard-content { 
        padding: 1rem; 
    }
    .stats-grid { 
        grid-template-columns: 1fr 1fr; 
        gap: 0.75rem; 
    }
}

@media (max-width: 480px) { 
    .stats-grid { 
        grid-template-columns: 1fr; 
    } 
}