:root {
    /* Dream App Color Palette */
    --primary-navy: #B48733;
    --primary-red: #d90429;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --text-dark: #1e293b;
    --text-muted: #6c757d;
    --border-light: #e9ecef;

    --success: #2b9348;
    --error: #d90429;
    --warning: #fb8500;
    --info: #0077b6;

    /* Shadows & Radius */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --radius-md: 16px;
    --radius-sm: 8px;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px !important;
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.5;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    padding-bottom: 80px;
    /* Space for bottom nav */
}

#app {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

h1,
h2,
h3,
.logo-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* Header - Deep Navy */
#main-header {
    background-color: var(--primary-navy);
    color: white;
    padding: var(--spacing-md) var(--spacing-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 900px;
    width: 100%;
    align-self: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-shield {
    width: 32px;
    height: 32px;
}

.logo-text {
    font-size: 1.3rem;
    letter-spacing: 3px;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

.icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    position: relative;
}

.badge-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background-color: var(--primary-red);
    border-radius: 50%;
    border: 2px solid var(--primary-navy);
}

/* Greeting Bar - Light bg but part of main flow */
.greeting-bar {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-white);
    margin-bottom: var(--spacing-sm);
}

.greeting-bar h1 {
    font-size: 1.5rem;
    color: var(--primary-navy);
}

.greeting-bar p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Common Layouts */
#view-container {
    max-width: 900px;
    padding: 0 var(--spacing-md);
    width: 100%;
    align-self: center;
    margin-top: 10px;
}

.card {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    margin-bottom: var(--spacing-md);
}

/* Buttons */
.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary:hover {
    filter: brightness(1.1);
}

.full-width {
    width: 100%;
}

/* Bottom Nav */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-white);
    display: flex;
    justify-content: space-around;
    padding: var(--spacing-sm) 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    width: 20%;
    position: relative;
}

.nav-item.active {
    color: var(--primary-navy);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    top: calc(-1 * var(--spacing-sm));
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 3px;
    background: var(--primary-red);
    border-radius: 0 0 4px 4px;
}

.nav-icon {
    font-size: 1.4rem;
}

/* Utility */
.mt-md {
    margin-top: var(--spacing-md);
}

.mt-lg {
    margin-top: var(--spacing-lg);
}

.hidden {
    display: none !important;
}

/* Forms & Inputs */
input,
select,
textarea {
    font-family: inherit;
    font-size: 1rem;
    padding: 10px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background-color: var(--bg-white);
    color: var(--text-dark);
    width: 100%;
    transition: 0.2s;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--info);
    box-shadow: 0 0 0 3px rgba(0, 119, 182, 0.1);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* --- RESPONSIVE DESKTOP SIDEBAR --- */
.sidebar-brand {
    display: none;
}

.sidebar-promo {
    display: none;
}

@media (min-width: 1024px) {
    body {
        padding-bottom: 0;
        padding-left: 240px;
        background-color: #f3f4f6;
    }

    #main-header .logo {
        display: none;
    }

    #main-header .header-content {
        justify-content: flex-end;
        max-width: 100%;
    }

    #bottom-nav {
        flex-direction: column;
        justify-content: flex-start;
        top: 0;
        bottom: 0;
        left: 0;
        width: 240px;
        height: 100vh;
        background-color: var(--primary-navy);
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
        padding: 0;
        border-top-right-radius: 0;
    }

    .sidebar-brand {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 30px 24px;
        color: white;
        font-family: 'Outfit', sans-serif;
        font-weight: 700;
        font-size: 1.2rem;
        letter-spacing: 2px;
    }

    .sidebar-brand img {
        width: 32px;
        height: 32px;
    }

    .nav-item {
        flex-direction: row;
        width: 100%;
        padding: 14px 24px;
        gap: 16px;
        border-left: 3px solid transparent;
        color: #94a3b8;
    }

    .nav-item .nav-icon {
        font-size: 1.4rem;
        margin-bottom: 0;
    }

    .nav-item .nav-label {
        font-size: 0.95rem;
        font-weight: 500;
        letter-spacing: 0.5px;
    }

    .nav-item:hover {
        color: white;
        background-color: rgba(255, 255, 255, 0.03);
    }

    .nav-item.active {
        color: white;
        background-color: rgba(255, 255, 255, 0.06);
        border-left: 3px solid var(--primary-red);
    }

    .nav-item.active::after {
        display: none;
    }

    .sidebar-promo {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-top: auto;
        margin-bottom: 24px;
        margin-left: 16px;
        margin-right: 16px;
        padding: 16px;
        background-color: rgba(255, 255, 255, 0.05);
        border-radius: var(--radius-sm);
        color: white;
    }

    .sidebar-promo i {
        font-size: 1.8rem;
        color: #94a3b8;
    }

    .sidebar-promo strong {
        display: block;
        font-size: 0.85rem;
        font-weight: 600;
    }

    .sidebar-promo p {
        font-size: 0.75rem;
        color: #94a3b8;
        margin-top: 4px;
        line-height: 1.3;
    }

    #view-container {
        max-width: 1000px;
        margin: 0 auto;
        padding: var(--spacing-sm) var(--spacing-xl);
        padding-top: 0;
    }

    /* Header Transparent a PC i Compactació */
    #main-header {
        background-color: transparent;
        position: absolute;
        top: 36px;
        right: 40px;
        padding: 0;
        width: auto;
    }

    /* Quan NO hi ha greeting-bar, afegim marge a view-container per evitar solapaments */
    .greeting-bar.hidden + #view-container {
        padding-top: 80px;
    }

    #main-header .icon-btn {
        color: var(--primary-navy);
    }

    /* Mostrar perfil només en PC */
    .user-profile-desktop {
        display: flex !important;
        align-items: center;
        gap: 12px;
        margin-left: 20px;
        cursor: pointer;
    }

    .avatar-circle {
        background-color: var(--primary-navy);
        color: white;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 700;
        font-size: 1.1rem;
    }

    .avatar-name {
        font-weight: 600;
        color: var(--primary-navy);
        display: flex;
        align-items: center;
        gap: 6px;
    }

    /* Separadors Menú Sidebar */
    .nav-separator {
        height: 1px;
        background-color: rgba(255, 255, 255, 0.08);
        margin: 12px 24px;
    }

    /* Compactar i reduir marges innecessaris per tenir-ho en una plana */
    .greeting-bar {
        max-width: none;
        margin: 0;
        background: transparent;
        padding-top: 35px;
        padding-bottom: 35px !important;
        padding-left: var(--spacing-xl);
        padding-right: var(--spacing-xl);
    }

    .greeting-bar h1 {
        font-size: 1.8rem;
    }

    .card {
        margin-bottom: var(--spacing-sm);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    }

    #view-container {
        max-width: none;
        margin: 0;
        padding: var(--spacing-sm) var(--spacing-xl);
        padding-top: 0;
    }

    /* Colors de les Targetes Mètriques Inicials (Només PC) */
    .metric-card {
        background-color: var(--primary-navy) !important;
        color: white !important;
        border: none !important;
    }

    .metric-card .metric-label,
    .metric-card .metric-footer {
        color: rgba(255, 255, 255, 0.7) !important;
    }

    .metric-card .metric-value,
    .metric-card .metric-value-small span {
        color: white !important;
    }

    .metric-card .progress-bar-bg {
        background-color: rgba(255, 255, 255, 0.2) !important;
    }

    .metric-card .metric-icon-wrap {
        background-color: rgba(255, 255, 255, 0.1) !important;
    }

    /* Targetes Evolució i Simulacre al 50% igualades */
    .evolution-sim-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 20px !important;
        align-items: stretch !important;
    }

    .evolution-sim-grid>.card {
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .chart-mini-placeholder {
        position: relative;
        height: 180px !important;
        width: 100%;
    }

    .metrics-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 16px;
    }

    /* Graella d'accés directe lineal de 3 items */
    .quick-access-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

.quick-access-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.quick-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 10px;
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-item:hover {
    background: var(--bg-white);
    border-color: var(--primary-navy);
    transform: translateY(-2px);
}

.quick-icon {
    font-size: 1.8rem;
    color: var(--primary-navy);
    margin-bottom: 6px;
}

.quick-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
}

/* Excepcions específiques Mobile */
@media (max-width: 1023px) {
    .hidden-mobile {
        display: none !important;
    }
}