:root {
    /* Palette Colori Moderna */
    --primary: #4F46E5;
    --primary-light: #EEF2FF;
    --secondary: #64748B;
    --bg-body: #F8FAFC;
    --bg-card: #FFFFFF;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --border: #E2E8F0;
    
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;

    /* Spaziature */
    --radius: 16px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    
    /* Dimensioni Navbar Mobile */
    --bottom-nav-height: 70px; 
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent; /* Rimuove il flash blu su mobile */
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 16px; /* Base font size leggibile su mobile */
}

/* Layout Principale */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* --- SIDEBAR (Desktop Style) --- */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    padding: 24px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: all 0.3s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 40px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-links li.active a, 
.nav-links a:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.nav-links i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    margin-left: 260px; /* Lascia spazio alla sidebar desktop */
    padding: 32px;
    width: calc(100% - 260px);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.user-profile img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* KPI CARDS */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.net-worth { background: #EEF2FF; color: var(--primary); }
.cash-flow { background: #DCFCE7; color: var(--success); }
.safety { background: #FEF3C7; color: var(--warning); }

.kpi-info h3 { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-info .amount { font-size: 1.5rem; font-weight: 700; margin: 4px 0; color: var(--text-main); }

.amount.positive { color: var(--success); }
.amount.negative { color: var(--danger); }
.amount.warning { color: var(--warning); }

/* CHARTS SECTION */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.chart-container {
    min-height: 300px;
}

.canvas-wrapper {
    position: relative;
    height: 250px;
    width: 100%;
}

/* RECENT TRANSACTIONS & TABLES */
.table-responsive {
    width: 100%;
    overflow-x: auto; /* Permette lo scroll orizzontale su mobile */
    -webkit-overflow-scrolling: touch; /* Scroll fluido su iOS */
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px; /* Forza la larghezza minima per attivare lo scroll se necessario */
}

th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    text-transform: uppercase;
}

td {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.transaction-icon {
    display: inline-flex;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 0.9rem;
}

.transaction-icon.shop { background: #FEE2E2; color: var(--danger); }
.transaction-icon.salary { background: #DCFCE7; color: var(--success); }
.transaction-icon.transfer { background: #F1F5F9; color: var(--text-muted); }

/* FLOATING ACTION BUTTON (FAB) */
.fab {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 1.6rem;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    z-index: 900;
}

.fab:hover { transform: scale(1.05); }

/* --- MODAL --- */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 24px;
    border-radius: 20px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-height: 90vh;
    overflow-y: auto;
}

/* --- MOBILE OPTIMIZATION (BREAKPOINT 768px) --- */
@media (max-width: 768px) {
    
    /* Sidebar diventa Bottom Navigation */
    .sidebar {
        width: 100%;
        height: var(--bottom-nav-height);
        bottom: 0;
        top: auto;
        left: 0;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        padding: 0;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
    }

    .logo { display: none; } /* Nascondi logo su mobile */
    
    .nav-links {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        height: 100%;
        gap: 0;
    }

    .nav-links li {
        flex: 1;
        display: flex;
        justify-content: center;
        height: 100%;
    }
    
    .nav-links a {
        flex-direction: column;
        justify-content: center;
        padding: 0;
        width: 100%;
        border-radius: 0;
        gap: 4px;
        background-color: transparent !important; /* Rimuovi sfondo hover */
    }
    
    .nav-links i {
        font-size: 1.4rem;
        margin-bottom: 2px;
    }
    
    .link-text {
        font-size: 0.7rem;
        font-weight: 500;
    }
    
    /* Nascondi testo dei link non attivi su schermi molto piccoli */
    .nav-links li:not(.active) .link-text {
        color: var(--text-muted);
    }
    
    .nav-links li.active a {
        color: var(--primary);
    }
    
    .nav-links li.active .link-text {
        font-weight: 700;
    }

    /* Main Content Adjustments */
    .main-content {
        margin-left: 0;
        padding: 20px;
        width: 100%;
        /* Aggiungi padding in basso per non finire dietro la navbar */
        padding-bottom: calc(var(--bottom-nav-height) + 40px); 
    }

    .top-bar {
        flex-direction: row; /* Mantieni row */
        margin-bottom: 24px;
    }

    .welcome-text h1 { font-size: 1.5rem; }
    .welcome-text p { font-size: 0.9rem; }

    /* Grid layout mobile */
    .kpi-grid {
        grid-template-columns: 1fr; /* Una colonna per le card */
        gap: 16px;
    }

    .charts-grid {
        grid-template-columns: 1fr; /* Una colonna per i grafici */
    }
    
    .card {
        padding: 20px;
    }

    /* Floating Action Button mobile */
    .fab {
        bottom: calc(var(--bottom-nav-height) + 20px); /* Sopra la navbar */
        right: 20px;
        width: 56px;
        height: 56px;
    }
    
    /* Modal mobile */
    .modal-content {
        width: 95%;
        padding: 20px;
        margin-bottom: 50px; /* Per non coprire con la tastiera virtuale */
    }
}

/* --- HEADER PAGINA --- */
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-header-row h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.subtitle strong {
    color: var(--text-main);
    font-weight: 700;
}

.btn-add {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    transition: transform 0.2s;
}
.btn-add:active { transform: scale(0.95); }

/* --- GRID PER LE CARTE BANCARIE --- */
.section-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 20px;
    font-weight: 600;
}

.cards-grid {
    display: grid;
    /* Minimo 300px per carta, altrimenti va a capo */
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/* STILE BANK CARD (Tipo Carta di Credito) */
.bank-card {
    border-radius: 20px;
    padding: 24px;
    color: white;
    position: relative;
    overflow: hidden;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 10px 20px -5px rgba(0,0,0,0.2);
    transition: transform 0.3s;
}

.bank-card:hover { transform: translateY(-5px); }

/* Varianti Colore */
.card-primary {
    background: linear-gradient(135deg, #4F46E5, #312E81); /* Blu Profondo */
}
.card-warning {
    background: linear-gradient(135deg, #F59E0B, #B45309); /* Arancio */
}
.card-dark {
    background: linear-gradient(135deg, #334155, #0F172A); /* Grigio Scuro */
}

/* Elementi interni alla carta */
.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-chip { font-size: 1.8rem; opacity: 0.8; }
.card-icon { font-size: 1.5rem; opacity: 0.8; }

.card-actions button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.bank-name {
    display: block;
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 5px;
}

.card-balance {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 15px;
    letter-spacing: 0.5px;
}

.card-footer-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    opacity: 0.7;
    font-family: monospace;
}

/* --- LISTA INVESTIMENTI (Stile Pulito) --- */
.investments-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.invest-item {
    background: white;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px solid var(--border);
    transition: background 0.2s;
}

.invest-item:hover { background: #F8FAFC; }

.invest-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #EEF2FF;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.invest-icon.crypto { background: #FEF3C7; color: #D97706; }

.invest-info { flex: 1; }

.invest-info h4 { font-size: 1rem; margin-bottom: 2px; }
.invest-info .sub-text { font-size: 0.85rem; color: var(--text-muted); }

.invest-balance {
    text-align: right;
    font-weight: 600;
    font-size: 1.1rem;
}

.invest-balance .gain {
    display: block;
    font-size: 0.75rem;
    margin-top: 4px;
}
.invest-balance.positive .gain { color: var(--success); }
.invest-balance.negative .gain { color: var(--danger); }

.btn-icon-gray {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
}

/* --- MOBILE TWEAKS (Fondamentale!) --- */
@media (max-width: 768px) {
    
    .page-header-row {
        flex-direction: row;
        align-items: center;
    }

    .page-header-row h1 { font-size: 1.4rem; }
    .subtitle { display: none; } /* Risparmiamo spazio su mobile */

    .btn-text { display: none; } /* Mostra solo icona + su mobile */
    .btn-add { padding: 10px; border-radius: 50%; width: 40px; height: 40px; justify-content: center; }

    /* Le carte occupano tutta la larghezza su mobile */
    .cards-grid {
        grid-template-columns: 1fr; 
    }
    
    .bank-card {
        min-height: 160px; /* Un po' più compatte su mobile */
    }

    .invest-item {
        padding: 15px;
    }
    
    .invest-balance { font-size: 1rem; }
}

/* --- HEADER BUDGET --- */
.budget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.month-selector {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 8px 15px;
    border-radius: 30px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.current-month {
    font-weight: 600;
    min-width: 120px;
    text-align: center;
}

.btn-nav {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
}

/* --- SUMMARY BANNER (Disponibile) --- */
.summary-banner {
    background: linear-gradient(135deg, #6366f1, #4338ca); /* Indaco sfumato */
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border: none;
}

.summary-left .label {
    font-size: 0.9rem;
    opacity: 0.9;
    display: block;
    margin-bottom: 5px;
}

.summary-left .amount {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.sub-info {
    font-size: 0.8rem;
    opacity: 0.7;
}

.summary-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-left: 1px solid rgba(255,255,255,0.2);
    padding-left: 20px;
}

.mini-stat span { display: block; font-size: 0.75rem; opacity: 0.8; }
.mini-stat strong { display: block; font-size: 1rem; }

/* --- GRID LAYOUT (2 Colonne Desktop, 1 Mobile) --- */
.budget-grid-layout {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Due colonne uguali */
    gap: 30px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header h3 { font-size: 1.1rem; color: var(--text-muted); font-weight: 600; }
.btn-text-only { background: none; border: none; color: var(--primary); font-weight: 600; cursor: pointer; }

/* --- LISTA SPESE FISSE --- */
.fixed-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fixed-item {
    background: white;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid var(--border);
}

/* Stato: Pagato */
.fixed-item.paid { opacity: 0.6; background: #f8fafc; }
.fixed-item.paid .fixed-details h4 { text-decoration: line-through; }
.icon-box.check { background: #DCFCE7; color: var(--success); }

/* Stato: In Attesa */
.icon-box {
    width: 40px; 
    height: 40px; 
    border-radius: 10px; 
    background: #EEF2FF; 
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
}
.icon-box.warning { background: #FEF3C7; color: var(--warning); }

.fixed-details { flex: 1; }
.fixed-details h4 { font-size: 0.95rem; margin-bottom: 2px; }
.fixed-details .date { font-size: 0.8rem; color: var(--text-muted); }
.warning-text { color: var(--warning); font-weight: 600; }

.fixed-amount { font-weight: 700; }

/* --- BUDGET CARDS --- */
.budget-cards-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.budget-card {
    background: white;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.budget-top {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.cat-icon {
    width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.cat-icon.food { background: #E0E7FF; color: var(--primary); }
.cat-icon.fun { background: #FEF3C7; color: #D97706; }
.cat-icon.transport { background: #FEE2E2; color: var(--danger); }

.cat-info { flex: 1; }
.cat-info h4 { font-size: 0.95rem; font-weight: 600; }
.status-text { font-size: 0.75rem; color: var(--text-muted); }
.status-text.warning { color: #D97706; font-weight: 600; }
.status-text.danger { color: var(--danger); font-weight: 600; }

.cat-amount { font-weight: 700; font-size: 0.9rem; }
.cat-amount.danger { color: var(--danger); }

/* PROGRESS BARS CUSTOM */
.progress-bg {
    width: 100%;
    height: 8px;
    background: #f1f5f9;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 768px) {
    .budget-header h1 { font-size: 1.5rem; }
    
    /* Il banner diventa verticale su mobile */
    .summary-banner {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
    }
    .summary-right {
        width: 100%;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.2);
        padding-left: 0;
        padding-top: 15px;
        margin-top: 15px;
        flex-direction: row;
        justify-content: space-between;
    }
    
    /* Le colonne diventano una sotto l'altra */
    .budget-grid-layout {
        grid-template-columns: 1fr;
        gap: 40px;
    }
}

/* --- REPORT HEADER --- */
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.filter-group {
    display: flex;
    gap: 10px;
}

.date-select {
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-main);
}

.btn-download {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.btn-download:hover { background: #f1f5f9; color: var(--primary); }

/* --- STATS OVERVIEW (Cards Piccole) --- */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 colonne uguali */
    gap: 20px;
    margin-bottom: 30px;
}

.stat-box {
    background: white;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}

/* Colori specifici per le stat */
.stat-box.income .stat-icon { background: #DCFCE7; color: var(--success); }
.stat-box.expense .stat-icon { background: #FEE2E2; color: var(--danger); }
.stat-box.savings .stat-icon { background: #EEF2FF; color: var(--primary); }

.stat-text span { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.stat-text h3 { font-size: 1.25rem; font-weight: 700; }

/* --- CHART SECTIONS --- */
.chart-section {
    background: white;
    padding: 25px;
    border-radius: 20px;
    border: 1px solid var(--border);
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.chart-container-large {
    position: relative;
    height: 300px;
    width: 100%;
}

/* --- BREAKDOWN GRID (Ciambella + Lista) --- */
.breakdown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.chart-card, .category-list-card {
    background: white;
    padding: 25px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.chart-card h3, .category-list-card h3 {
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: var(--text-main);
}

.chart-wrapper-doughnut {
    position: relative;
    height: 250px;
    display: flex;
    justify-content: center;
}

/* Custom List Styles */
.cat-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}
.cat-item:last-child { border-bottom: none; }

.cat-color {
    width: 12px; height: 12px; border-radius: 4px;
    margin-right: 10px;
}

.cat-name { flex: 1; font-size: 0.9rem; color: var(--text-muted); }
.cat-val { font-weight: 600; font-size: 0.95rem; }
.cat-val small { font-weight: 400; color: var(--text-muted); font-size: 0.8rem; margin-left: 5px; }


/* --- MOBILE RESPONSIVE --- */
@media (max-width: 768px) {
    .stats-overview {
        grid-template-columns: 1fr; /* Una colonna per le stat */
        gap: 15px;
    }

    .stat-box {
        padding: 15px; /* Meno padding */
    }

    .breakdown-grid {
        grid-template-columns: 1fr; /* Stack verticale per grafici */
    }
    
    .chart-container-large {
        height: 250px; /* Grafico un po' più basso su mobile */
    }
}

/* --- STILE MODALE (Nuovo Movimento) --- */

/* Sfondo scuro che copre tutto lo schermo */
.modal {
    display: none; /* Nascosto di default, gestito da JS */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Sfondo scuro semitrasparente */
    backdrop-filter: blur(5px); /* Effetto sfocato sullo sfondo */
    align-items: center; /* Centra verticalmente */
    justify-content: center; /* Centra orizzontalmente */
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Quando la modale è attiva (aggiungeremo questa classe via JS se serve, o useremo display flex) */
.modal[style*="display: flex"] {
    opacity: 1;
}

/* Il box bianco della modale */
.modal-content {
    background-color: #ffffff;
    padding: 24px;
    border-radius: 24px; /* Angoli molto arrotondati */
    width: 90%;
    max-width: 450px; /* Larghezza massima su desktop */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Header della modale */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.close {
    font-size: 28px;
    font-weight: 400;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}
.close:hover { color: var(--danger); }

/* --- TABS (Switcher Spesa/Trasferimento) --- */
.modal-tabs {
    display: flex;
    background-color: #F1F5F9; /* Grigio chiaro */
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1; /* I bottoni occupano lo stesso spazio */
    padding: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

/* Stile del tab attivo */
.tab-btn.active {
    background-color: white;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* --- FORM ELEMENTS --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Layout a righe (es. Categoria + Conto vicini) */
.form-row {
    display: flex;
    gap: 16px;
}
.form-row .form-group {
    flex: 1; /* Divide lo spazio equamente */
}

/* Stile Input e Select Standard */
input[type="text"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none; /* Rimuove stile default browser */
}

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Wrapper per icona Euro dentro l'input */
.input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-wrapper i {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-size: 1rem;
    z-index: 10;
}

.input-icon-wrapper input {
    padding-left: 40px; /* Lascia spazio all'icona */
    font-weight: 600;     /* Rende l'importo più visibile */
    font-size: 1.1rem;
}

/* --- RADIO BUTTONS (Priorità) --- */
.radio-group {
    display: flex;
    gap: 12px;
}

.radio-label {
    flex: 1;
    position: relative;
    cursor: pointer;
}

.radio-label input {
    position: absolute;
    opacity: 0; /* Nascondiamo il pallino standard */
    cursor: pointer;
}

.radio-label span {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background-color: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s;
}

/* Quando il radio è selezionato */
.radio-label input:checked + span {
    border-color: var(--primary);
    background-color: #EEF2FF; /* Sfondo blu chiarissimo */
    color: var(--primary);
    font-weight: 600;
}

/* --- SUBMIT BUTTON --- */
.btn-save {
    width: 100%;
    margin-top: 10px;
    padding: 14px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-save:hover {
    background-color: #4338ca; /* Primary Dark */
}

.btn-save:active {
    transform: scale(0.98);
}

/* --- HEADER TRANSACTIONS --- */
.transactions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn-filter {
    width: 40px; height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    cursor: pointer;
}

.btn-add-circle {
    width: 40px; height: 40px;
    border-radius: 50%; /* Cerchio */
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
    font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
}

/* --- SEARCH BAR --- */
.search-section { margin-bottom: 15px; }

.search-bar {
    position: relative;
    width: 100%;
}

.search-bar i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    padding: 12px 15px 12px 45px; /* Spazio per icona */
    border-radius: 25px; /* Pillola */
    border: 1px solid var(--border);
    background: white;
    font-size: 0.95rem;
}

/* --- FILTER CHIPS (Scroll orizzontale) --- */
.filter-chips {
    display: flex;
    gap: 10px;
    overflow-x: auto; /* Scroll orizzontale se non ci stanno */
    padding-bottom: 5px; /* Spazio per scrollbar invisibile */
    margin-bottom: 25px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Nascondi scrollbar Firefox */
}
.filter-chips::-webkit-scrollbar { display: none; } /* Nascondi scrollbar Chrome */

.chip {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap; /* Non andare a capo */
    cursor: pointer;
    transition: all 0.2s;
}

.chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.chip:hover:not(.active) {
    background: #f1f5f9;
}

/* --- TIMELINE LIST --- */
.transactions-timeline {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.timeline-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    padding-left: 5px;
}

.trans-item {
    display: flex;
    align-items: center;
    background: white;
    padding: 15px;
    border-radius: 16px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.2s;
}

.trans-item:active { transform: scale(0.98); }
.trans-item:hover { border-color: var(--border); }

.trans-icon {
    width: 45px; height: 45px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    margin-right: 15px;
    flex-shrink: 0;
}

/* Colori Icone Categoria */
.category-food { background: #FEF3C7; color: #D97706; } /* Arancio */
.category-shop { background: #FEE2E2; color: #EF4444; } /* Rosso */
.category-income { background: #DCFCE7; color: #166534; } /* Verde */
.category-transfer { background: #F1F5F9; color: var(--text-muted); } /* Grigio */

.trans-info { flex: 1; }

.trans-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 3px;
    color: var(--text-main);
}

.trans-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.trans-amount {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
}

.trans-amount.negative { color: var(--text-main); } /* O nero, o rosso */
.trans-amount.positive { color: var(--success); }
.trans-amount.neutral { color: var(--text-muted); }

/* --- COLOR SELECTOR (Per la modale conti) --- */
.color-selector {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    justify-content: flex-start; /* Allinea a sinistra */
}

.color-option {
    cursor: pointer;
    position: relative;
}

.color-option input {
    display: none; /* Nasconde il radio button vero */
}

.color-circle {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent; /* Bordo invisibile di base */
}

/* Effetto Hover */
.color-option:hover .color-circle {
    transform: scale(1.1);
}

/* Quando selezionato: Bordo colorato e ingrandimento */
.color-option input:checked + .color-circle {
    transform: scale(1.15);
    border-color: #fff; /* Bordo bianco interno */
    box-shadow: 0 0 0 3px var(--primary); /* Anello esterno color primario */
}

/* --- NUOVO STILE ULTIMI MOVIMENTI (List View) --- */

.transactions-list {
    display: flex;
    flex-direction: column;
}

.trans-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.2s;
}

/* Rimuovi bordo all'ultimo elemento */
.trans-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Parte Sinistra (Icona + Testi) */
.trans-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1; /* Occupa tutto lo spazio disponibile */
    min-width: 0; /* Fondamentale per far funzionare il truncate del testo su mobile */
}

/* Icone */
.trans-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0; /* L'icona non si schiaccia mai */
}

.icon-shop { background: #FEE2E2; color: #EF4444; } /* Rosso chiaro */
.icon-salary { background: #DCFCE7; color: #10B981; } /* Verde chiaro */
.icon-transfer { background: #F1F5F9; color: #64748B; } /* Grigio */
.icon-fun { background: #FEF3C7; color: #D97706; } /* Arancio */

/* Testi Centrali */
.trans-details {
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Per gestire testi lunghi */
}

.trans-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Se il testo è lungo mette "..." */
}

.trans-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Parte Destra (Importo + Conto) */
.trans-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-left: 10px;
}

.trans-amount {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
}

.trans-amount.negative { color: var(--text-main); }
.trans-amount.positive { color: var(--success); }
.trans-amount.neutral { color: var(--text-muted); }

.trans-account {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: #F8FAFC;
    padding: 2px 6px;
    border-radius: 6px;
    margin-top: 4px;
    border: 1px solid #E2E8F0;
    display: inline-block;
}

/* --- MOBILE TWEAKS --- */
@media (max-width: 480px) {
    .trans-title {
        font-size: 0.9rem; /* Leggermente più piccolo su schermi minuscoli */
    }
    .trans-icon {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }
}

/* --- HEADER INVESTIMENTI --- */
.investments-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    margin-bottom: 20px;
}
.investments-header-row h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- SUMMARY CARD (Il riepilogo in alto) --- */
.invest-summary-card {
    background: linear-gradient(135deg, #1E293B, #0F172A); /* Sfondo scuro professionale */
    border-radius: 16px;
    padding: 20px;
    color: white;
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.3);
}

.summary-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.summary-col .lbl { font-size: 0.8rem; opacity: 0.7; }
.summary-col .val { font-size: 1.2rem; font-weight: 600; }
.summary-col.highlight .val { font-size: 1.4rem; font-weight: 700; }
.summary-col small { font-size: 0.8rem; font-weight: 400; opacity: 0.9; margin-left: 5px; }

/* --- GRID INVESTIMENTI --- */
.invest-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* --- INVEST CARD (Singolo Asset) --- */
.invest-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s;
}

.invest-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    border-color: #cbd5e1;
}

/* Header Card */
.inv-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.inv-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}
.inv-icon.etf { background: #E0E7FF; color: var(--primary); }
.inv-icon.crypto { background: #FFF7ED; color: #EA580C; }
.inv-icon.stock { background: #F1F5F9; color: #475569; }

.inv-name { flex: 1; }
.inv-name h4 { font-size: 1rem; font-weight: 600; margin-bottom: 2px; }
.inv-name .provider { font-size: 0.75rem; color: var(--text-muted); display: block; }

.btn-dots { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.1rem; }

/* Body Card */
.inv-body { margin-bottom: 20px; }

.inv-main-val {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pnl-badge {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    display: flex; align-items: center; gap: 4px;
}
.pnl-badge.positive { background: #DCFCE7; color: #166534; }
.pnl-badge.negative { background: #FEE2E2; color: #991B1B; }

.inv-details {
    background: #F8FAFC;
    border-radius: 10px;
    padding: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 6px;
}
.detail-row:last-child { margin-bottom: 0; }
.detail-row span { color: var(--text-muted); }

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* Footer Card (Azioni) */
.inv-footer {
    display: flex;
    gap: 10px;
    margin-top: auto; /* Spinge in basso se la card si allunga */
}

.btn-inv-action {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-inv-action:hover { background: #f1f5f9; }

.btn-inv-action.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-inv-action.primary:hover { background: #4338ca; }

/* Mobile Adjustments */
@media (max-width: 600px) {
    .invest-summary-card {
        flex-direction: column; /* Stack verticale su mobile */
        gap: 15px;
        align-items: flex-start;
    }
    .summary-col { 
        flex-direction: row; 
        justify-content: space-between; 
        width: 100%; 
        border-bottom: 1px solid rgba(255,255,255,0.1);
        padding-bottom: 10px;
    }
    .summary-col:last-child { border-bottom: none; padding-bottom: 0; }
}