/* ==================== TIM SANS FONT ==================== */
@font-face { font-family: 'TIM Sans'; src: url('../fonts/TIMSans-Thin.otf') format('opentype'); font-weight: 100; font-style: normal; font-display: swap; }
@font-face { font-family: 'TIM Sans'; src: url('../fonts/TIMSans-Light.otf') format('opentype'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'TIM Sans'; src: url('../fonts/TIMSans-Medium.otf') format('opentype'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'TIM Sans'; src: url('../fonts/TIMSans-Bold.otf') format('opentype'); font-weight: 700; font-style: normal; font-display: swap; }

/* ==================== RESET & BASE ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'TIM Sans', sans-serif; background: #F5F5F5; color: #1E1E1E; font-weight: 300; overflow-x: hidden; }
a { text-decoration: none; color: inherit; }

/* ==================== CSS VARIABLES ==================== */
:root {
    --blu-900: #000d7a;
    --blu-700: #0014ad;
    --blu-500: #1a3abf;
    --blu-300: #6680d9;
    --blu-100: #ccd5f2;
    --verde-900: #2A752F;
    --verde-700: #3CA434;
    --verde-500: #59C64D;
    --verde-300: #A4E89A;
    --verde-100: #E2F8DE;
    --grigio-900: #1E1E1E;
    --grigio-700: #4A4A4A;
    --grigio-500: #9B9B9B;
    --grigio-300: #D9D9D9;
    --grigio-100: #F5F5F5;
    --giallo: #FFCC00;
    --rosso: #ea0026;
    --azzurro: #0288D1;
    --sidebar-w: 260px;
    --header-h: 60px;
    --transition: all 0.3s ease;
}

/* ==================== LOGIN PAGE ==================== */
#loginPage {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--blu-900) 0%, var(--blu-700) 50%, var(--blu-500) 100%);
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999;
}
#loginPage.hidden { display: none; }

.login-box {
    background: #fff; border-radius: 16px; padding: 48px 40px; width: 420px; max-width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}
.login-logo { font-size: 32px; font-weight: 700; margin-bottom: 8px; color: var(--blu-700); }
.login-logo span { color: var(--rosso); }
.login-subtitle { color: var(--grigio-500); font-size: 14px; margin-bottom: 32px; }
.login-box .form-group { margin-bottom: 20px; text-align: left; }
.login-box label { display: block; font-weight: 500; font-size: 13px; color: var(--grigio-700); margin-bottom: 6px; }
.login-box input[type="email"], .login-box input[type="password"] {
    width: 100%; padding: 12px 16px; border: 2px solid var(--grigio-300); border-radius: 10px;
    font-family: 'TIM Sans', sans-serif; font-size: 15px; transition: var(--transition);
}
.login-box input:focus { outline: none; border-color: var(--blu-500); box-shadow: 0 0 0 3px rgba(46,109,168,0.15); }
.login-btn {
    width: 100%; padding: 14px; background: var(--blu-700); color: #fff; border: none;
    border-radius: 10px; font-family: 'TIM Sans', sans-serif; font-size: 16px; font-weight: 700;
    cursor: pointer; transition: var(--transition); margin-top: 8px;
}
.login-btn:hover { background: var(--blu-500); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(20,82,132,0.3); }
.login-error { color: var(--rosso); font-size: 13px; margin-top: 12px; display: none; }

/* ==================== HEADER ==================== */
.header {
    position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: var(--header-h);
    background: #fff; z-index: 100; display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: var(--transition);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.menu-toggle { display: none; background: none; border: none; font-size: 22px; color: var(--blu-700); cursor: pointer; }
.back-btn {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 8px; border: 2px solid var(--blu-300);
    background: #fff; color: var(--blu-700); font-size: 15px; cursor: pointer;
    transition: var(--transition);
}
.back-btn:hover { background: var(--blu-700); color: #fff; border-color: var(--blu-700); }
.header-title { font-size: 18px; font-weight: 700; color: var(--blu-700); }
.header-right { display: flex; align-items: center; gap: 16px; }
.header-user { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.header-user .avatar {
    width: 38px; height: 38px; border-radius: 50%; background: var(--blu-700); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.header-user .user-info { text-align: right; }
.header-user .user-name { font-weight: 500; font-size: 14px; color: var(--grigio-900); }
.header-user .user-role { font-size: 11px; color: var(--grigio-500); }

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh;
    background: linear-gradient(180deg, var(--blu-900) 0%, var(--blu-700) 100%);
    color: #fff; z-index: 200; overflow-y: auto; transition: var(--transition);
}
.sidebar-brand {
    padding: 22px 24px; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand-text { font-size: 24px; font-weight: 700; }
.sidebar-brand-text span { color: #ea0026; }
.sidebar-nav { padding: 14px 0; }
.nav-section { padding: 12px 24px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: rgba(255,255,255,0.45); font-weight: 500; }
.nav-item {
    display: flex; align-items: center; gap: 14px; padding: 13px 24px; cursor: pointer;
    transition: var(--transition); font-size: 16px; font-weight: 300; color: rgba(255,255,255,0.85); line-height: 1.3;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.15); color: #fff; font-weight: 500; border-left: 3px solid var(--verde-500); }
.nav-item i { width: 22px; text-align: center; font-size: 17px; }
.nav-item .badge {
    margin-left: auto; background: var(--verde-500); color: #fff; font-size: 12px;
    padding: 2px 9px; border-radius: 10px; font-weight: 700;
}
.nav-group-title { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.nav-group-title .arrow { font-size: 12px; transition: var(--transition); }
.nav-group-title .arrow.open { transform: rotate(90deg); }
.nav-sub { display: none; padding-left: 20px; }
.nav-sub.open { display: block; }
.nav-sub .nav-item { padding: 10px 24px; font-size: 15px; }
.nav-sub .nav-item i { font-size: 9px; }

/* ==================== MAIN CONTENT ==================== */
.main {
    margin-left: var(--sidebar-w); margin-top: var(--header-h); padding: 24px;
    min-height: calc(100vh - var(--header-h)); transition: var(--transition);
}
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ==================== BREADCRUMB ==================== */
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--grigio-500); margin-bottom: 20px; }
.breadcrumb a { color: var(--blu-500); }
.breadcrumb i { font-size: 10px; }

/* ==================== PAGE TITLE ==================== */
.page-title { font-size: 24px; font-weight: 700; color: var(--blu-900); margin-bottom: 24px; }

/* ==================== KPI CARDS TOP ==================== */
.kpi-top-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-top-card {
    background: #fff; border-radius: 12px; padding: 20px; display: flex; align-items: center; gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06); cursor: pointer; transition: var(--transition);
    border-left: 4px solid transparent;
}
.kpi-top-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.1); }
.kpi-top-card .kpi-icon {
    width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: #fff;
}
.kpi-top-card:nth-child(1) { border-left-color: var(--rosso); }
.kpi-top-card:nth-child(1) .kpi-icon { background: linear-gradient(135deg, #ea0026, #ff3350); }
.kpi-top-card:nth-child(2) { border-left-color: var(--verde-700); }
.kpi-top-card:nth-child(2) .kpi-icon { background: linear-gradient(135deg, var(--verde-700), var(--verde-500)); }
.kpi-top-card:nth-child(3) { border-left-color: var(--blu-700); }
.kpi-top-card:nth-child(3) .kpi-icon { background: linear-gradient(135deg, var(--blu-700), var(--blu-500)); }
.kpi-top-card:nth-child(4) { border-left-color: var(--giallo); }
.kpi-top-card:nth-child(4) .kpi-icon { background: linear-gradient(135deg, #F9A825, var(--giallo)); }
.kpi-info .kpi-label { font-size: 12px; color: var(--grigio-500); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-info .kpi-value { font-size: 28px; font-weight: 700; color: var(--grigio-900); }
.kpi-info .kpi-sub { font-size: 12px; color: var(--grigio-500); margin-top: 2px; }

/* ==================== QUARTER TABS ==================== */
.quarter-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.quarter-tabs .year-label { font-weight: 700; color: var(--blu-700); font-size: 15px; margin: 0 4px; user-select: none; }
.year-nav-btn {
    width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--blu-300);
    background: #fff; color: var(--blu-700); font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.year-nav-btn:hover { background: var(--blu-100); border-color: var(--blu-700); }
.q-tab {
    padding: 8px 20px; border-radius: 8px; font-weight: 700; font-size: 14px;
    cursor: pointer; transition: var(--transition); border: 2px solid var(--blu-300);
    color: var(--blu-700); background: #fff;
}
.q-tab:hover { background: var(--blu-100); }
.q-tab.active { background: var(--blu-700); color: #fff; border-color: var(--blu-700); }

/* ==================== STAT CARDS ==================== */
.stats-section { margin-bottom: 28px; }
.stats-section-title { font-size: 16px; font-weight: 700; color: var(--grigio-700); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--grigio-300); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
    background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border-top: 3px solid var(--blu-500); text-align: center;
}
.stat-card.netto { border-top-color: var(--verde-500); }
.stat-card .stat-label { font-size: 12px; color: var(--grigio-500); font-weight: 500; text-transform: uppercase; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 32px; font-weight: 700; color: var(--blu-700); }
.stat-card.netto .stat-value { color: var(--verde-700); }
.stat-card .chart-wrapper { position: relative; height: 100px; margin-top: 10px; }

/* ==================== PARTNER LOGOS ==================== */
.partners-section { margin-top: 32px; }
.partners-section h3 { font-size: 14px; color: var(--grigio-500); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }
.partners-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }
.partner-card {
    background: #fff; border-radius: 12px; padding: 24px 16px; text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06); transition: var(--transition); cursor: pointer;
}
.partner-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.1); }
.partner-card i { font-size: 32px; color: var(--blu-500); margin-bottom: 8px; }
.partner-card .partner-name { font-size: 12px; font-weight: 700; color: var(--grigio-700); }

/* ==================== DATA TABLE ==================== */
.table-container {
    background: #fff; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 24px;
}
.table-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--grigio-300); flex-wrap: wrap; gap: 12px;
}
.table-header h3 { font-size: 16px; font-weight: 700; color: var(--blu-900); }
.table-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-box {
    display: flex; align-items: center; gap: 8px; background: var(--grigio-100);
    border-radius: 8px; padding: 8px 14px; border: 1px solid var(--grigio-300);
}
.search-box input { border: none; background: transparent; font-family: 'TIM Sans', sans-serif; font-size: 14px; outline: none; width: 200px; }
.search-box i { color: var(--grigio-500); }
.btn {
    padding: 8px 16px; border-radius: 8px; font-family: 'TIM Sans', sans-serif;
    font-size: 13px; font-weight: 500; cursor: pointer; transition: var(--transition); border: none;
}
.btn-primary { background: var(--blu-700); color: #fff; }
.btn-primary:hover { background: var(--blu-500); }
.btn-success { background: var(--verde-700); color: #fff; }
.btn-success:hover { background: var(--verde-500); }
.btn-warning { background: var(--giallo); color: var(--grigio-900); }
.btn-danger { background: var(--rosso); color: #fff; }
.btn-outline { background: #fff; color: var(--blu-700); border: 2px solid var(--blu-700); }
.btn-outline:hover { background: var(--blu-700); color: #fff; }
.filter-select {
    padding: 8px 12px; border-radius: 8px; border: 2px solid var(--grigio-300);
    font-family: 'TIM Sans', sans-serif; font-size: 13px; font-weight: 500;
    color: var(--grigio-700); background: #fff; cursor: pointer;
    transition: var(--transition); min-width: 140px;
}
.filter-select:focus { outline: none; border-color: var(--blu-500); box-shadow: 0 0 0 3px rgba(0,20,173,0.1); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    background: var(--blu-900); color: #fff; padding: 12px 14px; text-align: left;
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
    position: sticky; top: 0; white-space: nowrap;
}
.data-table td { padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--grigio-100); }
.data-table tr:hover td { background: var(--blu-100); }
.data-table .link { color: var(--blu-500); cursor: pointer; font-weight: 500; }
.data-table .link:hover { text-decoration: underline; }
.table-scroll { overflow-x: auto; max-height: calc(100vh - 280px); min-height: 400px; overflow-y: auto; }

.status-badge {
    display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 700;
}
.status-emesso { background: var(--verde-100); color: var(--verde-900); }
.status-presentato { background: var(--blu-100); color: var(--blu-700); }
.status-inserito { background: #FFF3E0; color: #E65100; }
.status-attivato, .status-attivo { background: var(--verde-100); color: var(--verde-900); }
.status-approvato { background: #E8F5E9; color: #2E7D32; }
.status-ko, .status-rifiutato { background: #FFEBEE; color: var(--rosso); }
.status-lavorazione { background: var(--blu-100); color: var(--blu-700); }
.status-sospeso { background: #FFF8E1; color: #F57F17; }

/* ==================== CARDS VIEW (Utenti) ==================== */
.user-type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.user-type-card {
    border-radius: 12px; padding: 32px; text-align: center; color: #fff; cursor: pointer;
    transition: var(--transition); position: relative; overflow: hidden;
}
.user-type-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,0.2); }
.user-type-card h3 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.user-type-card .count { font-size: 36px; font-weight: 700; opacity: 0.9; }
.user-type-card i { font-size: 48px; opacity: 0.2; position: absolute; right: 20px; top: 20px; }
.utc-venditori { background: linear-gradient(135deg, #ea0026, #b8001e); }
.utc-coordinatori { background: linear-gradient(135deg, var(--verde-700), var(--verde-900)); }
.utc-utenti { background: linear-gradient(135deg, var(--azzurro), #0277BD); }
.utc-direzione { background: linear-gradient(135deg, #F9A825, #F57F17); }

/* ==================== FORM FIELDS ==================== */
.flabel { display:block; font-weight:500; font-size:13px; color:var(--grigio-700); margin-bottom:6px; }
.finput { width:100%; padding:10px 14px; border:2px solid var(--grigio-300); border-radius:8px; font-family:'TIM Sans',sans-serif; font-size:14px; background:#fff; transition:var(--transition); }
.finput:focus { outline:none; border-color:var(--blu-500); box-shadow:0 0 0 3px rgba(0,20,173,0.1); }
.anag-result-item { padding:10px 14px; cursor:pointer; border-bottom:1px solid var(--grigio-100); font-size:13px; transition:background 0.15s; }
.anag-result-item:hover { background:var(--blu-100); }
.anag-result-item .anag-name { font-weight:500; color:var(--grigio-900); }
.anag-result-item .anag-detail { font-size:12px; color:var(--grigio-500); margin-top:2px; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1200px) {
    .kpi-top-row, .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .partners-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ==================== MOBILE BO (CRM Back Office) ==================== */
@media (max-width: 768px) {
    /* --- Blocco overflow su tutta la pagina BO --- */
    html, body { overflow-x: hidden; width: 100%; max-width: 100vw; }

    /* --- Sidebar nascosta di default, slide-in --- */
    .sidebar { left: -260px; }
    .sidebar.open { left: 0; }

    /* --- Header full-width --- */
    .header { left: 0; padding: 0 12px; width: 100%; max-width: 100vw; box-sizing: border-box; }
    .header-user .user-info { display: none; }
    .header-user .avatar { width: 32px; height: 32px; font-size: 12px; }
    .header-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }

    /* --- Main content con blocco overflow --- */
    .main { margin-left: 0; padding: 12px; width: 100%; max-width: 100vw; box-sizing: border-box; overflow-x: hidden; }
    .menu-toggle { display: block; }
    .page { width: 100%; max-width: 100%; overflow-x: hidden; box-sizing: border-box; }

    /* --- KPI cards top: 2 per riga, adattive --- */
    .kpi-top-row {
        grid-template-columns: repeat(2, 1fr); gap: 8px;
        width: 100%; max-width: 100%; box-sizing: border-box;
    }
    .kpi-top-card {
        padding: 10px; gap: 10px;
        width: 100%; max-width: 100%; box-sizing: border-box;
        min-width: 0;
    }
    .kpi-top-card:hover { transform: none; }
    .kpi-top-card .kpi-icon { width: 36px; height: 36px; min-width: 36px; font-size: 16px; border-radius: 8px; }
    .kpi-top-card .kpi-value { font-size: 22px; }
    .kpi-top-card .kpi-label { font-size: 10px; }
    .kpi-top-card .kpi-sub { font-size: 10px; }
    .kpi-info { min-width: 0; overflow: hidden; }
    .kpi-info .kpi-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    /* --- Quarter tabs scrollabili --- */
    .quarter-tabs {
        overflow-x: auto; -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap; gap: 6px; padding-bottom: 4px;
        scrollbar-width: none; -ms-overflow-style: none;
    }
    .quarter-tabs::-webkit-scrollbar { display: none; }
    .q-tab { padding: 6px 14px; font-size: 13px; flex-shrink: 0; }

    /* --- Stats sections compatte --- */
    .stats-section { padding: 0; margin-bottom: 16px; }
    .stats-section-title { font-size: 13px; padding-bottom: 6px; }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr); gap: 8px;
        width: 100%; max-width: 100%; box-sizing: border-box;
    }
    .stats-section [style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important;
    }
    .stat-card {
        padding: 10px; width: 100%; max-width: 100%;
        box-sizing: border-box; min-width: 0;
    }
    .stat-card .stat-value { font-size: 20px; word-break: break-word; }
    .stat-card .stat-label { font-size: 10px; }
    .stat-card .chart-wrapper { height: 80px; overflow-x: auto; }

    /* --- Tabelle responsive con scroll orizzontale --- */
    .table-container {
        margin: 0 -12px; border-radius: 0;
        width: calc(100% + 24px); max-width: calc(100vw);
        overflow-x: hidden; overflow-y: visible;
    }
    .table-header { flex-direction: column; gap: 8px; padding: 12px; }
    .table-actions {
        width: 100%; display: flex; flex-wrap: wrap; gap: 6px;
    }
    .table-actions input[type="text"] { width: 100%; min-width: 0; }
    .search-box { width: 100%; }
    .search-box input { width: 100% !important; }
    .table-actions .btn { flex: 1; min-width: 0; font-size: 12px; padding: 8px 10px; text-align: center; }
    .table-actions .filter-select { width: 100%; min-width: 0; }
    .table-scroll {
        max-height: calc(100vh - 200px); min-height: 250px;
        overflow-x: auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
    }
    .data-table { min-width: 600px; }
    .data-table th { padding: 8px 6px; font-size: 10px; white-space: nowrap; }
    .data-table td { padding: 8px 6px; font-size: 11px; white-space: nowrap; }

    /* --- NON nascondere colonne: scroll orizzontale --- */
    /* Le colonne restano tutte visibili, l'utente scrolla */

    /* --- Link rapidi partner --- */
    .partners-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .partner-card { padding: 14px 8px; }
    .partner-card i { font-size: 22px; }
    .partner-card .partner-name { font-size: 10px; }

    /* --- Grids vari --- */
    .user-type-grid { grid-template-columns: repeat(2, 1fr); }

    /* --- Pannello edit full-screen --- */
    .edit-panel { width: 100%; right: -100%; }

    /* --- Pagina Impostazioni: tab compatti scrollabili --- */
    .sett-tabs {
        display: flex; flex-wrap: nowrap; gap: 4px;
        overflow-x: auto; -webkit-overflow-scrolling: touch;
        scrollbar-width: none; -ms-overflow-style: none;
        padding-bottom: 4px;
    }
    .sett-tabs::-webkit-scrollbar { display: none; }
    .sett-tab { font-size: 12px; padding: 8px 12px; flex-shrink: 0; white-space: nowrap; }

    /* --- Bulk import responsive --- */
    .mapping-grid { grid-template-columns: 1fr !important; }

    /* --- Paginazione compatta --- */
    .pagination { gap: 2px; padding: 10px; }
    .pagination button { width: 30px; height: 30px; font-size: 11px; }

    /* --- Form e grid inline responsive --- */
    .form-row, [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    div[style*="max-width:700px"] {
        max-width: 100% !important; padding: 16px !important;
        box-sizing: border-box;
    }

    /* --- Breadcrumb compatto --- */
    .breadcrumb { font-size: 11px; flex-wrap: wrap; gap: 4px; }

    /* --- Notifica bell --- */
    .notif-bell-btn { font-size: 18px; }
}

/* ==================== MOBILE PICCOLI (< 480px) BO ==================== */
@media (max-width: 480px) {
    .kpi-top-row { gap: 6px; }
    .stats-grid { gap: 6px; }
    .kpi-top-card .kpi-value { font-size: 18px; }
    .kpi-top-card .kpi-icon { width: 30px; height: 30px; min-width: 30px; font-size: 14px; }
    .stat-card .stat-value { font-size: 16px; }
    .header-title { font-size: 13px; max-width: 35vw; }
    .partners-grid { grid-template-columns: repeat(2, 1fr); }
    .main { padding: 8px; }
    .table-container { margin: 0 -8px; width: calc(100% + 16px); }
}
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 150; }
.overlay.active { display: block; }

/* ==================== PAGINATION ==================== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 16px; }
.pagination button {
    width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--grigio-300);
    background: #fff; cursor: pointer; font-family: 'TIM Sans', sans-serif; font-weight: 500;
    transition: var(--transition); font-size: 13px;
}
.pagination button:hover { background: var(--blu-100); }
.pagination button.active { background: var(--blu-700); color: #fff; border-color: var(--blu-700); }
.pagination .page-info { font-size: 13px; color: var(--grigio-500); margin: 0 12px; }

/* ==================== EMPTY STATE ==================== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--grigio-500); }
.empty-state i { font-size: 48px; margin-bottom: 16px; color: var(--grigio-300); }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--grigio-700); }

/* ==================== EDIT PANEL (Slide-in laterale) ==================== */
.edit-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 900; }
.edit-overlay.active { display: block; }
.edit-panel {
    position: fixed; top: 0; right: -540px; width: 520px; height: 100vh;
    background: #fff; z-index: 950; box-shadow: -8px 0 32px rgba(0,0,0,0.15);
    transition: right 0.3s ease; overflow-y: auto;
}
.edit-panel.active { right: 0; }
.edit-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; background: var(--blu-900); color: #fff;
    position: sticky; top: 0; z-index: 10;
}
.edit-panel-header h3 { font-size: 16px; font-weight: 700; }
.edit-panel-close { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; padding: 4px; }
.edit-panel-close:hover { opacity: 0.7; }
.edit-panel-body { padding: 24px; }
.edit-panel-body .edit-field { margin-bottom: 16px; }
.edit-panel-body .edit-field label { display: block; font-size: 12px; font-weight: 600; color: var(--grigio-500); text-transform: uppercase; margin-bottom: 4px; }
.edit-panel-body .edit-field .edit-value { font-size: 14px; color: var(--grigio-900); padding: 8px 0; border-bottom: 1px solid var(--grigio-100); }
.edit-panel-body .edit-field input,
.edit-panel-body .edit-field select,
.edit-panel-body .edit-field textarea {
    width: 100%; padding: 10px 12px; border: 2px solid var(--grigio-300); border-radius: 8px;
    font-family: 'TIM Sans', sans-serif; font-size: 14px; transition: var(--transition);
}
.edit-panel-body .edit-field input:focus,
.edit-panel-body .edit-field select:focus,
.edit-panel-body .edit-field textarea:focus { outline: none; border-color: var(--blu-500); }
.edit-section-label {
    font-size: 13px; font-weight: 700; color: var(--blu-700); text-transform: uppercase;
    letter-spacing: 0.5px; margin: 20px 0 10px; padding-bottom: 6px;
    border-bottom: 2px solid var(--blu-100); display: flex; align-items: center; gap: 8px;
}
.edit-section-label:first-child { margin-top: 0; }
.edit-section-label i { font-size: 14px; }
.edit-row { display: flex; gap: 12px; }
.edit-row .edit-field { flex: 1; }
.edit-panel-actions {
    display: flex; gap: 10px; padding: 16px 24px; border-top: 2px solid var(--grigio-100);
    position: sticky; bottom: 0; background: #fff;
}
@media (max-width: 768px) {
    .edit-panel { width: 100%; right: -100%; }
}
/* Pulsante Elimina Ordine */
.edit-panel-delete-zone { padding: 0 24px 20px; text-align: center; }
.btn-delete-order {
    width: 100%; padding: 12px; border: 2px solid #D32F2F; background: #fff;
    color: #D32F2F; border-radius: 8px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s ease; font-family: 'Titillium Web', sans-serif;
}
.btn-delete-order:hover { background: #D32F2F; color: #fff; }
.btn-delete-order i { margin-right: 6px; }
.delete-warning-text {
    font-size: 11px; color: #9B9B9B; margin-top: 8px; font-style: italic;
}

/* Catalogo servizi */
.catalogo-list {
    max-height: 280px; overflow-y: auto; border: 1px solid var(--grigio-300);
    border-radius: 8px; background: var(--grigio-100); padding: 4px;
}
.catalogo-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; background: #fff; border-radius: 6px; margin: 3px 0;
    font-size: 13px; color: var(--grigio-900); transition: background 0.15s;
}
.catalogo-item:hover { background: var(--blu-100); }
.catalogo-item-text { flex: 1; }
.catalogo-item-remove {
    background: none; border: none; color: var(--grigio-500); cursor: pointer;
    padding: 2px 6px; font-size: 12px; border-radius: 4px; transition: all 0.15s;
}
.catalogo-item-remove:hover { color: #D32F2F; background: rgba(211,47,47,0.1); }

/* ==================== AGENT VIEW STYLES (Modern Redesign) ==================== */

/* Agent Page Layout */
#page-agente-dashboard {
    display: flex !important;
    height: 100vh;
    overflow: hidden;
}

/* Left Sidebar */
.agent-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 200px; background: linear-gradient(180deg, var(--blu-900) 0%, var(--blu-700) 100%);
    color: #fff; z-index: 200; overflow-y: auto;
    display: flex; flex-direction: column;
    padding: 16px 12px;
    box-shadow: 2px 0 12px rgba(0,0,0,0.1);
}

.agent-sidebar-logo {
    font-size: 24px; font-weight: 700; text-align: center;
    padding: 16px 0; margin-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    letter-spacing: 0.5px;
}

.agent-sidebar-logo span {
    color: var(--rosso);
}

.agent-sidebar-profile {
    display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
    padding: 12px; border-radius: 10px; background: rgba(255,255,255,0.08);
}

.agent-avatar-circle {
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, var(--verde-500), var(--verde-700));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px; flex-shrink: 0;
}

.agent-profile-info {
    flex: 1; min-width: 0;
}

.agent-profile-name {
    font-size: 13px; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.agent-profile-role {
    font-size: 11px; color: rgba(255,255,255,0.7);
}

.agent-sidebar-nav {
    flex: 1; margin-bottom: 16px;
}

.agent-nav-section {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
    color: rgba(255,255,255,0.5); font-weight: 600; padding: 12px 8px 8px; margin-bottom: 8px;
}

.agent-nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px; border-radius: 8px; cursor: pointer;
    font-size: 13px; color: rgba(255,255,255,0.8);
    transition: var(--transition); position: relative;
}

.agent-nav-item:hover {
    background: rgba(255,255,255,0.12); color: #fff;
}

.agent-nav-item-active {
    background: rgba(255,255,255,0.15); color: #fff; font-weight: 500;
}

.agent-nav-item i:first-child {
    font-size: 14px; width: 18px; text-align: center;
}

.agent-nav-arrow {
    margin-left: auto !important; font-size: 11px;
}

.agent-nav-submenu {
    display: none; padding-left: 12px; margin: 4px 0;
}

.agent-nav-submenu.open {
    display: block;
}

.agent-nav-subitem {
    padding: 8px 12px; font-size: 12px; color: rgba(255,255,255,0.7);
    cursor: pointer; border-radius: 6px; border-left: 2px solid transparent;
    transition: var(--transition);
}

.agent-nav-subitem:hover {
    background: rgba(255,255,255,0.1); color: #fff; border-left-color: var(--verde-500);
}

.agent-sidebar-logout {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 11px 12px; border: none; border-radius: 8px;
    background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.8);
    font-size: 13px; cursor: pointer; transition: var(--transition);
    font-family: 'TIM Sans', sans-serif; font-weight: 500;
}

.agent-sidebar-logout:hover {
    background: rgba(255,255,255,0.15); color: #fff;
}

/* Main Content Wrapper */
.agent-main-wrapper {
    margin-left: 200px; display: flex; flex-direction: column; height: 100vh;
}

/* ==================== UNIFIED HERO HEADER ==================== */
.agent-hero-header {
    background:
        radial-gradient(ellipse 80% 60% at 70% 20%, rgba(255,255,255,0.18) 0%, transparent 60%),
        radial-gradient(ellipse 50% 80% at 10% 80%, rgba(255,255,255,0.08) 0%, transparent 50%),
        linear-gradient(160deg, var(--blu-900) 0%, var(--blu-700) 100%);
    flex-shrink: 0; padding: 20px 28px 14px; position: relative;
    box-shadow: 0 4px 24px rgba(0,13,122,0.35);
}
/* Top row */
.agent-hero-top {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.agent-menu-toggle { display: none; }
.agent-sidebar-overlay { display: none; }
.agent-hero-greeting { flex: 1; }
.agent-greeting-text {
    font-size: 22px; font-weight: 700; color: #fff; letter-spacing: -0.3px;
}
.agent-greeting-date {
    font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 2px; font-weight: 400;
}
.agent-hero-actions { display: flex; align-items: center; gap: 12px; }
.agent-hero-notif-btn {
    width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1); color: #fff; cursor: pointer;
    font-size: 15px; position: relative; transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.agent-hero-notif-btn:hover { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.4); }
.agent-notification-badge {
    position: absolute; top: -4px; right: -4px;
    background: var(--rosso); color: #fff; font-size: 10px; font-weight: 700;
    width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.agent-hero-avatar-wrap { display: flex; align-items: center; gap: 10px; }
.agent-header-avatar {
    width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,0.2); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
    border: 2px solid rgba(255,255,255,0.3); backdrop-filter: blur(4px);
}
.agent-hero-user-info { text-align: right; }
.agent-header-user-name { font-weight: 600; font-size: 13px; color: #fff; }
.agent-header-user-role { font-size: 11px; color: rgba(255,255,255,0.55); }

/* Motivational phrase */
.agent-hero-motivation {
    font-size: 16px; color: #fff; font-style: italic;
    margin-bottom: 18px; font-weight: 400; line-height: 1.5;
    padding: 10px 16px; min-height: 20px;
    background: rgba(255,255,255,0.08); border-radius: 10px;
    border-left: 3px solid rgba(255,255,255,0.4);
    text-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Period selector (year arrows + month pills inline) */
.agent-hero-period {
    display: flex; align-items: center; gap: 8px;
    background: rgba(0,0,0,0.18); border-radius: 16px;
    padding: 8px 12px; overflow-x: auto;
    scrollbar-width: none; -ms-overflow-style: none;
}
.agent-hero-period::-webkit-scrollbar { display: none; }
.agent-hero-year-btn {
    width: 32px; height: 32px; min-width: 32px; border-radius: 10px; border: none;
    background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.8); font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s ease;
}
.agent-hero-year-btn:hover { background: rgba(255,255,255,0.25); color: #fff; }
.agent-hero-year-label {
    font-size: 15px; font-weight: 700; color: #fff; user-select: none;
    min-width: 42px; text-align: center; letter-spacing: 0.5px;
}
.agent-month-timeline {
    display: flex; align-items: center; gap: 3px; flex: 1; justify-content: center;
}
.agent-month-pill {
    padding: 7px 13px; border-radius: 10px; font-size: 13px; font-weight: 500;
    color: rgba(255,255,255,0.55); background: transparent; cursor: pointer;
    transition: all 0.25s ease; white-space: nowrap; text-align: center;
    border: 1.5px solid transparent; letter-spacing: 0.3px;
}
.agent-month-pill:hover {
    color: #fff; background: rgba(255,255,255,0.12);
}
.agent-month-pill.active {
    font-size: 14px; font-weight: 700; color: #fff;
    background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.35);
    padding: 7px 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.agent-month-display {
    text-align: center;
}

.agent-month-current {
    font-size: 28px; font-weight: 700; color: #fff;
}

.agent-month-year {
    font-size: 14px; color: rgba(255,255,255,0.8);
}

/* Scrollable Content Area */
.agent-content-scroll {
    flex: 1; overflow-y: auto; padding: 24px; background: var(--grigio-100);
}

/* Fix for scroll overflow */
#page-agente-dashboard {
    overflow: hidden;
}

/* KPI Cards Grid */
.agent-kpi-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
    margin: 0 24px 24px 24px; padding: 0; align-items: stretch;
}

/* ==================== ANIMAZIONE BENVENUTO STAGGERED ==================== */
@keyframes heroGreetingIn {
    0% { opacity: 0; transform: translateX(-15px); }
    100% { opacity: 1; transform: translateX(0); }
}
@keyframes heroMotivationIn {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes heroPeriodIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}
@keyframes cardSlideUp {
    0% { opacity: 0; transform: translateY(30px) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes chartFadeIn {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes sectionSlideIn {
    0% { opacity: 0; transform: translateY(25px); }
    100% { opacity: 1; transform: translateY(0); }
}

.agent-hero-greeting {
    opacity: 0; animation: heroGreetingIn 0.5s ease-out 0.1s forwards;
}
.agent-hero-motivation {
    opacity: 0; animation: heroMotivationIn 0.5s ease-out 0.3s forwards;
}
.agent-hero-period {
    opacity: 0; animation: heroPeriodIn 0.4s ease-out 0.45s forwards;
}
.agent-all-goals-banner.visible {
    animation: bannerSlideIn 0.5s ease-out 0.5s both;
}

.agent-kpi-card {
    background: #fff; border-radius: 16px; padding: 20px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease; position: relative; overflow: hidden;
    display: flex; flex-direction: column; justify-content: space-between; min-height: 180px;
    animation: cardSlideUp 0.5s ease-out both;
}
.agent-kpi-card:nth-child(1) { animation-delay: 0.1s; }
.agent-kpi-card:nth-child(2) { animation-delay: 0.2s; }
.agent-kpi-card:nth-child(3) { animation-delay: 0.3s; }
.agent-kpi-card:nth-child(4) { animation-delay: 0.4s; }
.agent-kpi-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }

.agent-kpi-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, var(--grigio-300), transparent);
}

.agent-kpi-card-fisso::before { background: linear-gradient(90deg, var(--rosso), rgba(234,0,38,0.3)); }
.agent-kpi-card-mobile::before { background: linear-gradient(90deg, var(--verde-700), rgba(58,164,52,0.3)); }
.agent-kpi-card-valore::before { background: linear-gradient(90deg, var(--blu-700), rgba(0,20,173,0.3)); }
.agent-kpi-card-consumer::before { background: linear-gradient(90deg, #F9A825, rgba(249,168,37,0.3)); }

.agent-kpi-card:hover {
    transform: translateY(-6px); box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}

.agent-kpi-header {
    display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px;
}

.agent-kpi-icon {
    width: 44px; height: 44px; border-radius: 12px; display: flex;
    align-items: center; justify-content: center; font-size: 20px;
    flex-shrink: 0;
}

.agent-kpi-card-fisso .agent-kpi-icon { background: rgba(234,0,38,0.12); color: var(--rosso); }
.agent-kpi-card-mobile .agent-kpi-icon { background: rgba(58,164,52,0.12); color: var(--verde-700); }
.agent-kpi-card-valore .agent-kpi-icon { background: rgba(0,20,173,0.12); color: var(--blu-700); }
.agent-kpi-card-consumer .agent-kpi-icon { background: rgba(249,168,37,0.12); color: #F9A825; }

.agent-kpi-title {
    font-size: 12px; color: var(--grigio-500); font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px;
}

.agent-kpi-value {
    font-size: 32px; font-weight: 700; color: var(--grigio-900); margin-bottom: 12px;
}

.agent-kpi-progress-section {
    margin-bottom: 12px;
}

.agent-kpi-progress-bar {
    height: 6px; background: var(--grigio-100); border-radius: 3px; overflow: hidden;
    margin-bottom: 6px;
}

.agent-kpi-progress-fill {
    height: 100%; border-radius: 3px; transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
}

.agent-kpi-progress-fisso { background: linear-gradient(90deg, var(--rosso), #ff5a6d); }
.agent-kpi-progress-mobile { background: linear-gradient(90deg, var(--verde-700), var(--verde-500)); }
.agent-kpi-progress-valore { background: linear-gradient(90deg, var(--blu-700), var(--blu-500)); }
.agent-kpi-progress-consumer { background: linear-gradient(90deg, #F9A825, #FFB84D); }

.agent-kpi-progress-text {
    font-size: 11px; color: var(--grigio-500); text-align: center; font-weight: 500;
}

/* Celebrazione obiettivo raggiunto (100%) */
.agent-kpi-card.goal-reached {
    border: 2px solid var(--verde-700);
    box-shadow: 0 4px 20px rgba(60,164,52,0.25);
}
.agent-kpi-card.goal-reached .agent-kpi-progress-text {
    color: var(--verde-700); font-weight: 700;
}
/* Coccarda (elemento HTML iniettato da JS) */
.goal-rosette {
    position: absolute; top: -4px; right: -4px; z-index: 5;
    width: 56px; height: 56px;
    animation: rosetteBounce 0.6s ease-out 0.3s both;
    pointer-events: none;
}
.goal-rosette-outer {
    width: 56px; height: 56px; border-radius: 50%; position: relative;
    background: conic-gradient(
        from 0deg,
        #3CA434 0deg, #59C64D 15deg, #3CA434 30deg, #59C64D 45deg,
        #3CA434 60deg, #59C64D 75deg, #3CA434 90deg, #59C64D 105deg,
        #3CA434 120deg, #59C64D 135deg, #3CA434 150deg, #59C64D 165deg,
        #3CA434 180deg, #59C64D 195deg, #3CA434 210deg, #59C64D 225deg,
        #3CA434 240deg, #59C64D 255deg, #3CA434 270deg, #59C64D 285deg,
        #3CA434 300deg, #59C64D 315deg, #3CA434 330deg, #59C64D 345deg,
        #3CA434 360deg
    );
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center;
}
.goal-rosette-inner {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, #F9A825, #FFD54F);
    display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
}
.goal-rosette-inner i {
    font-size: 14px; color: #fff; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2));
}
/* Nastrini sotto la coccarda */
.goal-rosette-ribbon {
    position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 4px;
}
.goal-rosette-ribbon span {
    width: 10px; height: 16px; border-radius: 0 0 3px 3px;
}
.goal-rosette-ribbon span:first-child {
    background: #3CA434; transform: rotate(-12deg);
}
.goal-rosette-ribbon span:last-child {
    background: #2A752F; transform: rotate(12deg);
}
@keyframes goalPulse {
    0% { box-shadow: 0 4px 20px rgba(60,164,52,0.25); }
    50% { box-shadow: 0 4px 30px rgba(60,164,52,0.45); }
    100% { box-shadow: 0 4px 20px rgba(60,164,52,0.25); }
}
@keyframes rosetteBounce {
    0% { transform: scale(0) rotate(-30deg); opacity: 0; }
    60% { transform: scale(1.2) rotate(8deg); opacity: 1; }
    80% { transform: scale(0.95) rotate(-3deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Banner tutti gli obiettivi raggiunti */
.agent-all-goals-banner {
    background: linear-gradient(135deg, var(--verde-700), #59C64D);
    color: #fff; text-align: center; padding: 14px 20px;
    border-radius: 14px; margin: 0 24px 16px;
    font-size: 16px; font-weight: 700;
    box-shadow: 0 4px 16px rgba(60,164,52,0.3);
    animation: bannerSlideIn 0.5s ease-out both;
    display: none;
}
.agent-all-goals-banner.visible { display: block; }
.agent-all-goals-banner i { margin-right: 8px; }
@keyframes bannerSlideIn {
    0% { transform: translateY(-15px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.agent-kpi-comparison {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    font-size: 12px; color: var(--grigio-500);
}

.agent-kpi-arrow {
    font-size: 16px; font-weight: 700;
}

.agent-kpi-arrow-neutral { color: var(--grigio-500); }
.agent-kpi-arrow-up { color: var(--verde-700); }
.agent-kpi-arrow-down { color: var(--rosso); }

/* Main Card Style */
.agent-card {
    background: #fff; border-radius: 16px; padding: 24px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    margin: 0 24px 24px 24px;
}

.agent-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; padding-bottom: 16px; border-bottom: 2px solid var(--grigio-100);
}

.agent-card-title {
    font-size: 16px; font-weight: 700; color: var(--grigio-900); margin: 0;
}

/* Chart Card */
.agent-chart-card {
    background: #fff; border-radius: 16px; padding: 24px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    margin: 0 24px 24px 24px;
    height: 310px; display: flex; flex-direction: column;
    animation: chartFadeIn 0.6s ease-out 0.55s both;
}

.agent-chart-container {
    flex: 1; position: relative; min-height: 250px;
}

/* Two Column Layout */
.agent-two-column {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
    margin: 0 24px 24px 24px; align-items: start;
    animation: sectionSlideIn 0.6s ease-out 0.7s both;
}
.agent-two-column > .agent-card { margin: 0; }
.agent-two-column .agent-orders-section,
.agent-two-column .agent-clients-section { max-height: 500px; overflow-y: auto; }

/* Bottom Grid (Badge + Progresso + Provvigioni) */
.agent-bottom-grid {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px;
    margin: 0 24px 24px 24px; align-items: stretch;
    animation: sectionSlideIn 0.6s ease-out 0.85s both;
}
.agent-bottom-grid > .agent-card { min-height: 180px; display: flex; flex-direction: column; }

/* Orders Section */
.agent-orders-section {
    grid-column: 1;
}

.agent-orders-wrapper {
    overflow-x: auto;
}

.agent-orders-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}

.agent-orders-table th {
    background: var(--blu-900); color: #fff; padding: 12px 14px;
    text-align: left; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap;
}

.agent-orders-table td {
    padding: 12px 14px; border-bottom: 1px solid var(--grigio-100);
}

.agent-orders-table tbody tr {
    transition: background 0.2s ease;
}

.agent-orders-table tbody tr:hover td {
    background: var(--blu-100);
}

/* Clients Grid */
.agent-clients-section {
    grid-column: 2;
}

.agent-clients-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}

.agent-client-card {
    background: var(--grigio-100); border-radius: 12px; padding: 14px;
    cursor: pointer; transition: var(--transition);
}

.agent-client-card:hover {
    background: var(--blu-100); transform: translateY(-2px);
}

.agent-client-name {
    font-size: 13px; font-weight: 600; color: var(--grigio-900);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 6px;
}

.agent-client-city {
    font-size: 11px; color: var(--grigio-500); margin-bottom: 8px;
}

.agent-client-count {
    display: inline-block; background: var(--blu-700); color: #fff;
    font-size: 10px; font-weight: 700; padding: 4px 8px; border-radius: 4px;
}

/* Badges Grid */
.agent-badges-grid {
    display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 0;
}
.badge-empty {
    width: 100%; text-align: center; padding: 24px 16px;
    color: var(--grigio-500); font-size: 13px;
}

/* Single badge card */
.agent-badge-card {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: 14px;
    background: #fff; border: 1.5px solid var(--grigio-300);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    animation: badgePop 0.4s ease-out both;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-width: 170px; flex: 1 1 170px; max-width: 250px;
}
.agent-badge-card:hover {
    transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}
@keyframes badgePop {
    0% { opacity: 0; transform: scale(0.85); }
    60% { transform: scale(1.03); }
    100% { opacity: 1; transform: scale(1); }
}

/* Medal icon */
.badge-medal { position: relative; flex-shrink: 0; width: 44px; height: 52px; }
.badge-medal-ring {
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; color: #fff; position: relative; z-index: 2;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}
.badge-ribbon {
    position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 2px; z-index: 1;
}
.badge-ribbon span {
    width: 10px; height: 14px; border-radius: 0 0 3px 3px;
}
.badge-ribbon span:first-child { transform: rotate(-12deg); }
.badge-ribbon span:last-child { transform: rotate(12deg); }

/* Badge info */
.badge-info { flex: 1; min-width: 0; }
.badge-label { font-size: 13px; font-weight: 700; color: var(--grigio-900); line-height: 1.2; }
.badge-desc { font-size: 11px; color: var(--grigio-500); margin-top: 2px; line-height: 1.3; }

/* --- TIER COLORS --- */
/* Bronze */
.tier-bronze { border-color: #D4A574; background: linear-gradient(135deg, #FFF8F0, #FFF1E6); }
.tier-bronze .badge-medal-ring { background: linear-gradient(145deg, #CD7F32, #A0622E); }
.tier-bronze .badge-ribbon span { background: #CD7F32; }
.tier-bronze .badge-label { color: #8B5E3C; }

/* Silver */
.tier-silver { border-color: #C0C0C0; background: linear-gradient(135deg, #FAFAFA, #F0F0F0); }
.tier-silver .badge-medal-ring { background: linear-gradient(145deg, #C0C0C0, #8E8E8E); }
.tier-silver .badge-ribbon span { background: #A8A8A8; }
.tier-silver .badge-label { color: #555; }

/* Gold */
.tier-gold { border-color: #E8C547; background: linear-gradient(135deg, #FFFDF0, #FFF8DC); }
.tier-gold .badge-medal-ring { background: linear-gradient(145deg, #FFD700, #DAA520); }
.tier-gold .badge-ribbon span { background: #DAA520; }
.tier-gold .badge-label { color: #8B6914; }

/* Platinum */
.tier-platinum { border-color: #7BA7CE; background: linear-gradient(135deg, #F0F7FF, #E8F0FE); }
.tier-platinum .badge-medal-ring { background: linear-gradient(145deg, var(--blu-700), var(--blu-900)); box-shadow: 0 3px 14px rgba(0,20,173,0.3); }
.tier-platinum .badge-ribbon span { background: var(--blu-700); }
.tier-platinum .badge-label { color: var(--blu-900); }

/* Ruby (on fire) */
.tier-ruby { border-color: #F08080; background: linear-gradient(135deg, #FFF5F5, #FFE8E8); }
.tier-ruby .badge-medal-ring { background: linear-gradient(145deg, #E53935, #B71C1C); box-shadow: 0 3px 14px rgba(229,57,53,0.3); }
.tier-ruby .badge-ribbon span { background: #C62828; }
.tier-ruby .badge-label { color: #B71C1C; }

/* ==================== BIGLIETTO DA VISITA ==================== */
.bv-container {
    display: flex; gap: 32px; align-items: flex-start; max-width: 1100px; margin: 0 auto;
}
.bv-form-panel { flex: 1; min-width: 0; }
.bv-preview-panel { flex: 1; min-width: 0; position: sticky; top: 20px; }
.bv-form-title {
    font-size: 16px; font-weight: 700; color: var(--grigio-900);
    margin-bottom: 18px; display: flex; align-items: center;
}
.bv-form-group { margin-bottom: 14px; }
.bv-form-row { display: flex; gap: 12px; }
.bv-label {
    display: block; font-size: 12px; font-weight: 600; color: var(--grigio-700);
    margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.3px;
}
.bv-input {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--grigio-300);
    border-radius: 10px; font-size: 14px; font-family: 'TIM Sans', sans-serif;
    color: var(--grigio-900); background: #fff; transition: all 0.2s ease;
}
.bv-input:focus { border-color: #13599d; outline: none; box-shadow: 0 0 0 3px rgba(19,89,157,0.1); }
.bv-btn-pdf {
    width: 100%; padding: 14px; border: none; border-radius: 12px;
    background: linear-gradient(135deg, var(--rosso), #c20020); color: #fff;
    font-size: 15px; font-weight: 700; cursor: pointer; margin-top: 20px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    transition: all 0.2s ease; box-shadow: 0 4px 15px rgba(234,0,38,0.3);
    font-family: 'TIM Sans', sans-serif;
}
.bv-btn-pdf:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(234,0,38,0.4); }
.bv-btn-pdf:active { transform: translateY(0); }
.bv-hint { font-size: 11px; color: var(--grigio-500); text-align: center; margin-top: 10px; }

/* Card preview */
.bv-card-wrapper {
    display: flex; justify-content: center; padding: 20px;
    background: var(--grigio-100); border-radius: 16px;
}
.bv-card {
    width: 340px; height: 220px; background: #fff; border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.08);
    position: relative; overflow: hidden; padding: 0;
}
.bv-card-accent {
    position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: #13599d;
}
.bv-card-content { padding: 20px 20px 16px 22px; height: 100%; display: flex; flex-direction: column; }
.bv-card-logo { margin-bottom: 6px; }
.bv-logo-img { width: 180px; height: auto; display: block; }
.bv-card-divider { width: 100%; height: 1px; background: #e0e0e0; margin-bottom: 10px; }
.bv-card-name {
    font-size: 14px; font-weight: 700; color: #13599d; margin-bottom: 2px;
}
.bv-card-title {
    font-size: 10px; font-weight: 400; color: var(--grigio-700); margin-bottom: 6px; font-style: italic;
}
.bv-card-details { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; }
.bv-card-ragsoc { font-size: 11px; font-weight: 700; color: #13599d; margin-bottom: 2px; }
.bv-card-addr { font-size: 10px; color: var(--grigio-700); line-height: 1.4; }
.bv-card-phone { font-size: 10px; color: var(--grigio-700); margin-top: 1px; }
.bv-card-email { font-size: 10px; color: #13599d; margin-top: 1px; }
.bv-scale-note { font-size: 11px; color: var(--grigio-500); text-align: center; margin-top: 12px; }

@media (max-width: 768px) {
    .bv-container { flex-direction: column; }
    .bv-preview-panel { position: static; }
    .bv-card { width: 300px; height: 194px; }
    .bv-card-content { padding: 16px 16px 12px 18px; }
    .bv-tim-business { font-size: 15px; }
    .bv-card-subtitle { font-size: 12px; }
    .bv-card-name { font-size: 13px; }
}

/* ==================== WEEKLY / MONTHLY TABS ==================== */
.weekly-monthly-tabs {
    display: flex; gap: 4px; background: var(--grigio-100); border-radius: 8px; padding: 3px;
}
.wm-tab {
    font-family: 'Titillium Web', sans-serif; font-size: 12px; font-weight: 600;
    padding: 5px 14px; border: none; border-radius: 6px; cursor: pointer;
    background: transparent; color: var(--grigio-500); transition: all 0.2s;
}
.wm-tab:hover { color: var(--grigio-700); }
.wm-tab-active {
    background: #fff; color: var(--blu-700); box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* Sezioni settimanali */
.weekly-section {
    padding: 14px 0; border-bottom: 1px solid var(--grigio-100);
}
.weekly-section:last-child { border-bottom: none; }
.weekly-section-label {
    font-size: 12px; font-weight: 700; color: var(--grigio-700);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
}
.weekly-section-past { opacity: 0.85; }
.weekly-stats-row {
    display: flex; gap: 8px; justify-content: space-between;
}
.weekly-stat-box {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    background: var(--grigio-100); border-radius: 10px; padding: 10px 6px;
}
.weekly-stat-value {
    font-size: 22px; font-weight: 800; color: var(--blu-700); line-height: 1;
}
.weekly-stat-label {
    font-size: 10px; font-weight: 600; color: var(--grigio-500);
    text-transform: uppercase; margin-top: 4px; letter-spacing: 0.3px;
}
.weekly-motivation {
    margin-top: 12px; padding: 10px 14px; border-radius: 10px;
    background: linear-gradient(135deg, #FFF8E1 0%, #FFFDE7 100%);
    border-left: 3px solid var(--giallo);
    font-size: 13px; color: var(--grigio-700); line-height: 1.5;
    font-style: italic;
}
.weekly-motivation i { margin-right: 6px; color: var(--giallo); }
.weekly-comparison {
    margin-top: 10px; font-size: 12px; color: var(--grigio-500);
    text-align: center; padding: 6px 0;
}
.weekly-comparison .comparison-up { color: var(--verde-700); font-weight: 700; }
.weekly-comparison .comparison-down { color: var(--rosso); font-weight: 700; }
.weekly-comparison .comparison-same { color: var(--grigio-500); font-weight: 600; }

/* Progress Section */
.agent-progress-content {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 0;
}

.agent-progress-item {
    flex: 1; text-align: center;
}

.agent-progress-label {
    font-size: 12px; color: var(--grigio-500); font-weight: 500;
    text-transform: uppercase; margin-bottom: 6px; letter-spacing: 0.5px;
}

.agent-progress-value {
    font-size: 32px; font-weight: 700; color: var(--blu-700);
}

.agent-progress-comparison {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 16px;
}

.agent-progress-arrow {
    font-size: 28px; font-weight: 700; min-width: 32px; text-align: center;
}

.agent-progress-arrow-up { color: var(--verde-700); }
.agent-progress-arrow-down { color: var(--rosso); }
.agent-progress-arrow-neutral { color: var(--grigio-500); }

.agent-progress-change {
    font-size: 20px; font-weight: 700; color: var(--grigio-900);
}

/* Provvigioni Section */
.agent-provvisioni-content {
    padding: 20px 0;
}

.agent-provvisioni-placeholder {
    text-align: center; padding: 40px 20px; color: var(--grigio-500);
}

.agent-provvisioni-placeholder i {
    font-size: 36px; margin-bottom: 12px; opacity: 0.4;
}

.agent-provvisioni-placeholder p {
    font-size: 14px; margin: 0;
}

/* ==================== VISTE FULL-SCREEN AGENTE ==================== */
.agent-fullview {
    display: flex; flex-direction: column; height: calc(100vh - 80px);
    padding: 0 24px 24px; overflow: hidden;
}
.agent-fullview-header {
    display: flex; align-items: center; gap: 16px; padding: 20px 0 12px;
    border-bottom: 2px solid var(--grigio-100); flex-shrink: 0;
}
.agent-fullview-header h2 {
    font-size: 20px; font-weight: 700; color: var(--blu-900); margin: 0; flex: 1;
}
.agent-fullview-back {
    width: 36px; height: 36px; border-radius: 8px; border: none;
    background: var(--blu-100); color: var(--blu-700); font-size: 16px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.agent-fullview-back:hover { background: var(--blu-300); }
.agent-fullview-search {
    display: flex; align-items: center; gap: 8px; background: var(--grigio-100);
    border-radius: 8px; padding: 8px 14px; min-width: 220px;
}
.agent-fullview-search i { color: var(--grigio-500); font-size: 13px; }
.agent-fullview-search input {
    border: none; background: transparent; outline: none; font-size: 14px;
    font-family: 'Titillium Web', sans-serif; color: var(--grigio-900); width: 100%;
}
.agent-fullview-tabs {
    display: flex; gap: 6px; padding: 12px 0; flex-shrink: 0; overflow-x: auto;
}
.agent-tab {
    padding: 8px 18px; border-radius: 20px; border: 1px solid var(--grigio-300);
    background: #fff; color: var(--grigio-700); font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: 'Titillium Web', sans-serif; transition: all 0.2s;
    white-space: nowrap;
}
.agent-tab:hover { border-color: var(--blu-500); color: var(--blu-500); }
.agent-tab.active {
    background: var(--blu-700); color: #fff; border-color: var(--blu-700);
}
.agent-fullview-count {
    font-size: 13px; color: var(--grigio-500); padding: 8px 0; flex-shrink: 0;
}
.agent-fullview-body {
    flex: 1; overflow-y: auto; overflow-x: auto;
}

/* Responsive Design - Agent Page */
@media (max-width: 1200px) {
    .agent-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .agent-two-column { grid-template-columns: 1fr; }
    .agent-two-column .agent-orders-section,
    .agent-two-column .agent-clients-section { grid-column: 1; }
    .agent-bottom-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* ==================== MOBILE AGENT (Sales Dashboard) ==================== */
@media (max-width: 768px) {
    /* --- Blocco overflow su tutta la pagina agente --- */
    #page-agente-dashboard { width: 100vw; max-width: 100vw; overflow-x: hidden; }
    .agent-main-wrapper { margin-left: 0; width: 100%; max-width: 100vw; overflow-x: hidden; }
    #agentScrollArea { padding: 12px 0 !important; width: 100%; max-width: 100vw; overflow-x: hidden; }

    /* --- Sidebar nascosta, slide-in con hamburger --- */
    .agent-sidebar {
        width: 240px; transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 210;
    }
    .agent-sidebar.open { transform: translateX(0); }

    /* --- Overlay sidebar --- */
    .agent-sidebar-overlay {
        display: none; position: fixed; inset: 0;
        background: rgba(0,0,0,0.45); z-index: 205;
    }
    .agent-sidebar-overlay.active { display: block; }

    /* --- Hamburger button --- */
    .agent-menu-toggle {
        display: flex; align-items: center; justify-content: center;
        width: 36px; height: 36px; border-radius: 8px;
        background: rgba(255,255,255,0.12); border: 1.5px solid rgba(255,255,255,0.2);
        color: #fff; font-size: 18px; cursor: pointer; flex-shrink: 0;
        margin-right: 10px;
    }

    /* --- Hero header compatto mobile --- */
    .agent-hero-header { padding: 14px 14px 10px; }
    .agent-greeting-text { font-size: 17px; }
    .agent-greeting-date { font-size: 11px; }
    .agent-hero-user-info { display: none; }
    .agent-header-avatar { width: 34px; height: 34px; font-size: 12px; }
    .agent-hero-motivation { font-size: 13px; margin-bottom: 12px; padding: 8px 12px; }
    .agent-hero-period {
        padding: 5px 6px; gap: 4px; border-radius: 10px;
        overflow-x: auto; -webkit-overflow-scrolling: touch;
    }
    .agent-month-timeline {
        justify-content: flex-start; gap: 2px;
        flex-wrap: nowrap; width: max-content;
    }
    .agent-month-pill { padding: 6px 11px; font-size: 12px; min-width: 38px; flex-shrink: 0; }
    .agent-month-pill.active { font-size: 13px; padding: 6px 15px; }
    .agent-hero-year-label { font-size: 13px; min-width: 36px; }
    .agent-hero-year-btn { width: 26px; height: 26px; min-width: 26px; font-size: 12px; }

    /* --- Viste full-screen mobile --- */
    .agent-fullview { padding: 0 12px 12px; }
    .agent-fullview-header { flex-wrap: wrap; gap: 10px; padding: 14px 0 10px; }
    .agent-fullview-header h2 { font-size: 17px; }
    .agent-fullview-search { min-width: unset; flex: 1 1 100%; order: 3; }
    .agent-fullview-tabs { gap: 4px; }
    .agent-tab { padding: 6px 14px; font-size: 12px; }

    /* --- KPI cards: impilate, full-width, compatte --- */
    .agent-kpi-grid {
        display: flex; flex-direction: column;
        gap: 8px; margin: 0 12px 12px 12px;
        width: calc(100% - 24px); max-width: calc(100vw - 24px);
    }
    .agent-kpi-card {
        padding: 14px; min-height: auto;
        width: 100%; max-width: 100%; box-sizing: border-box;
    }
    .agent-kpi-card:hover { transform: none; }
    .agent-kpi-header { margin-bottom: 8px; }
    .agent-kpi-value { font-size: 24px; margin-bottom: 8px; }
    .agent-kpi-label { font-size: 10px; }
    .agent-kpi-icon { width: 32px; height: 32px; font-size: 14px; }
    .agent-kpi-comparison { font-size: 11px; }
    .agent-kpi-progress-section { margin-bottom: 8px; }

    /* --- Grafico compatto con scroll orizzontale --- */
    .agent-chart-card {
        margin: 0 12px 12px 12px; padding: 12px;
        width: calc(100% - 24px); max-width: calc(100vw - 24px);
        box-sizing: border-box; overflow-x: auto;
    }
    .agent-chart-container { height: 180px; min-width: 300px; }

    /* --- Sezioni card --- */
    .agent-card {
        margin: 0 12px 12px 12px; padding: 12px;
        width: calc(100% - 24px); max-width: calc(100vw - 24px);
        box-sizing: border-box;
    }

    /* --- Due colonne → una colonna --- */
    .agent-two-column { gap: 12px; grid-template-columns: 1fr; }

    /* --- Bottom grid compatto --- */
    .agent-bottom-grid {
        grid-template-columns: 1fr; gap: 8px;
        margin: 0 12px 12px 12px;
        width: calc(100% - 24px); max-width: calc(100vw - 24px);
    }

    /* --- Tabella ordini agente: scroll orizzontale --- */
    .agent-orders-wrapper { margin: 0 -12px; margin-top: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .agent-orders-table { min-width: 500px; }
    .agent-orders-table th { padding: 8px 6px; font-size: 10px; white-space: nowrap; }
    .agent-orders-table td { padding: 8px 6px; font-size: 11px; }

    /* --- Nascondi colonne meno importanti nelle tabelle agente --- */
    .agent-orders-table th:nth-child(n+5),
    .agent-orders-table td:nth-child(n+5) { display: none; }

    /* --- Lista clienti --- */
    .agent-clients-grid { grid-template-columns: 1fr; }

    /* --- Filtro ordini header --- */
    .agent-filtered-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .agent-filtered-header h3 { font-size: 14px; }

    /* --- Personal Stats compatte --- */
    #agentPersonalStats { padding: 12px; }
}

/* ==================== MOBILE PICCOLI (< 480px) AGENT ==================== */
@media (max-width: 480px) {
    .agent-kpi-grid { gap: 6px; margin: 0 8px 8px 8px; width: calc(100% - 16px); }
    .agent-kpi-card { padding: 10px; }
    .agent-kpi-value { font-size: 20px; }
    .agent-kpi-icon { width: 28px; height: 28px; font-size: 12px; }
    .agent-chart-card, .agent-card { margin: 0 8px 8px 8px; width: calc(100% - 16px); }
    .agent-bottom-grid { margin: 0 8px 8px 8px; width: calc(100% - 16px); }
    .agent-hero-header { padding: 10px 10px 8px; }
    .agent-greeting-text { font-size: 14px; }
    .agent-hero-motivation { font-size: 12px; margin-bottom: 8px; padding: 6px 10px; }
    .agent-month-pill { padding: 5px 9px; font-size: 11px; min-width: 32px; }
    .agent-month-pill.active { font-size: 12px; padding: 5px 13px; }
    .agent-chart-container { height: 160px; }
}

/* ==================== CLIENT DETAIL MODAL (Sales App) ==================== */
.client-detail-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); z-index: 2000;
    display: none; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.3s ease;
}

.client-detail-modal.active {
    display: flex; opacity: 1;
}

.client-detail-content {
    background: #fff; border-radius: 12px; width: 90%; max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.client-detail-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--grigio-300);
}

.client-detail-header h2 {
    margin: 0; font-size: 18px; font-weight: 700; color: var(--grigio-900);
}

.client-detail-close {
    background: none; border: none; font-size: 24px; color: var(--grigio-500);
    cursor: pointer; transition: color 0.2s;
}

.client-detail-close:hover {
    color: var(--grigio-900);
}

.client-detail-body {
    padding: 24px;
}

.client-detail-section {
    display: flex; flex-direction: column; gap: 12px;
}

.client-detail-row {
    display: flex; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--grigio-100);
}

.client-detail-row:last-child {
    border-bottom: none; padding-bottom: 0;
}

.client-detail-label {
    font-weight: 600; color: var(--grigio-700); min-width: 120px;
}

.client-detail-value {
    color: var(--grigio-900); flex: 1; word-break: break-word;
}

/* ==================== NOTIFICATION BELL (CRM BO) ==================== */
.notif-bell-btn {
    width: 40px; height: 40px; border-radius: 10px; border: none;
    background: var(--grigio-100); color: var(--blu-700); cursor: pointer;
    font-size: 16px; position: relative; transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.notif-bell-btn:hover { background: var(--blu-100); }
.notif-bell-badge {
    position: absolute; top: -4px; right: -4px;
    background: var(--rosso); color: #fff; font-size: 10px; font-weight: 700;
    width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}

/* ==================== NOTIFICATION DROPDOWN ==================== */
.notif-dropdown {
    position: fixed; z-index: 10000;
    width: 380px; max-width: calc(100vw - 24px);
    max-height: 480px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    overflow: hidden;
    display: flex; flex-direction: column;
    animation: notifDropdownIn 0.2s ease-out;
    font-family: 'Titillium Web', sans-serif;
}
@keyframes notifDropdownIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.notif-dropdown-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid var(--grigio-300);
    background: var(--blu-100);
}
.notif-dropdown-title {
    font-weight: 700; font-size: 0.95rem; color: var(--blu-900);
}
.notif-mark-all-btn {
    background: none; border: none; color: var(--blu-500);
    cursor: pointer; font-size: 14px; padding: 4px 8px;
    border-radius: 6px; transition: var(--transition);
}
.notif-mark-all-btn:hover { background: var(--blu-300); color: #fff; }

.notif-dropdown-list {
    overflow-y: auto; flex: 1;
    max-height: 400px;
}
.notif-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 20px; color: var(--grigio-500); font-size: 0.85rem;
}
.notif-loading {
    display: flex; align-items: center; justify-content: center;
    padding: 30px; color: var(--grigio-500); font-size: 0.85rem; gap: 8px;
}

.notif-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 16px; cursor: pointer;
    border-bottom: 1px solid var(--grigio-100);
    transition: background 0.15s;
}
.notif-item:hover { background: var(--grigio-100); }
.notif-item:last-child { border-bottom: none; }

.notif-item-unread {
    background: #EBF4FF;
}
.notif-item-unread:hover { background: #D8EBFF; }

.notif-item-read { opacity: 0.7; }

.notif-item-icon {
    width: 36px; height: 36px; min-width: 36px;
    border-radius: 10px; background: var(--grigio-100);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.notif-item-unread .notif-item-icon { background: var(--blu-100); }

.notif-item-content { flex: 1; min-width: 0; }
.notif-item-title {
    font-weight: 600; font-size: 0.85rem; color: var(--grigio-900);
    margin-bottom: 2px; line-height: 1.3;
}
.notif-item-message {
    font-size: 0.8rem; color: var(--grigio-700);
    line-height: 1.4; display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.notif-item-time {
    font-size: 0.7rem; color: var(--grigio-500); margin-top: 4px;
}

/* Pulsante dismiss (X) per rimuovere notifica */
.notif-item-dismiss {
    width: 28px; height: 28px; min-width: 28px; border-radius: 6px;
    border: none; background: transparent; color: var(--grigio-500);
    cursor: pointer; font-size: 12px; transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center;
    align-self: center; opacity: 0;
}
.notif-item:hover .notif-item-dismiss { opacity: 1; }
.notif-item-dismiss:hover {
    background: rgba(211,47,47,0.1); color: var(--rosso);
}

/* (Mobile responsive notif spostato in fondo al file) */

/* ==================== PANNELLO PROFILO UTENTE ==================== */
.profile-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); z-index: 9998;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.profile-overlay.active { opacity: 1; pointer-events: auto; }

.profile-panel {
    position: fixed; top: 0; right: -420px; width: 400px; max-width: 90vw; height: 100%;
    background: #fff; z-index: 9999; box-shadow: -4px 0 24px rgba(0,0,0,0.15);
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column; overflow-y: auto;
}
.profile-panel.active { right: 0; }

.profile-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; background: var(--blu-700); color: #fff;
}
.profile-panel-header h3 {
    font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px;
}
.profile-close-btn {
    background: rgba(255,255,255,0.15); border: none; color: #fff;
    width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
    font-size: 16px; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.profile-close-btn:hover { background: rgba(255,255,255,0.3); }

.profile-panel-body { padding: 24px; flex: 1; }

/* Avatar grande con overlay camera */
.profile-avatar-section {
    display: flex; flex-direction: column; align-items: center; margin-bottom: 28px;
}
.profile-avatar-large {
    width: 120px; height: 120px; border-radius: 50%; position: relative;
    background: linear-gradient(135deg, var(--blu-500), var(--blu-700));
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; cursor: pointer; box-shadow: 0 4px 16px rgba(20,82,132,0.25);
}
.profile-avatar-initials {
    font-size: 42px; font-weight: 700; color: #fff;
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
}
.profile-avatar-img {
    width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0;
}
.profile-avatar-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.55); color: #fff; padding: 8px 0;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 11px; font-weight: 500; opacity: 0; transition: opacity 0.2s;
}
.profile-avatar-overlay i { font-size: 16px; }
.profile-avatar-large:hover .profile-avatar-overlay { opacity: 1; }

.profile-upload-status {
    margin-top: 10px; font-size: 13px; min-height: 20px; text-align: center;
}

/* Info non modificabili */
.profile-info-row {
    display: flex; flex-direction: column; margin-bottom: 16px;
    padding-bottom: 16px; border-bottom: 1px solid var(--grigio-300);
}
.profile-info-row label {
    font-size: 12px; font-weight: 500; color: var(--grigio-500);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;
    display: flex; align-items: center; gap: 6px;
}
.profile-info-value {
    font-size: 15px; font-weight: 500; color: var(--grigio-900);
}

/* Campi modificabili */
.profile-edit-row {
    display: flex; flex-direction: column; margin-bottom: 18px;
}
.profile-edit-row label {
    font-size: 12px; font-weight: 500; color: var(--grigio-500);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
    display: flex; align-items: center; gap: 6px;
}
.profile-input {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--grigio-300);
    border-radius: 8px; font-family: inherit; font-size: 14px; color: var(--grigio-900);
    transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
.profile-input:focus {
    border-color: var(--blu-500); box-shadow: 0 0 0 3px rgba(46,109,168,0.12);
}
.profile-textarea { resize: vertical; min-height: 70px; }

/* Pulsante salva */
.profile-save-btn {
    width: 100%; padding: 12px; background: var(--blu-700); color: #fff;
    border: none; border-radius: 10px; font-family: inherit; font-size: 15px;
    font-weight: 600; cursor: pointer; display: flex; align-items: center;
    justify-content: center; gap: 8px; transition: background 0.2s, transform 0.1s;
    margin-top: 8px;
}
.profile-save-btn:hover { background: var(--blu-500); }
.profile-save-btn:active { transform: scale(0.98); }
.profile-save-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Responsive mobile profilo + notifiche */
@media (max-width: 768px) {
    .profile-panel { width: 100%; max-width: 100%; right: -100%; }
    .profile-panel.active { right: 0; }
    .notif-dropdown {
        width: calc(100vw - 16px);
        right: 8px !important;
        left: 8px;
    }
    .notif-item-dismiss { opacity: 1; }
}
@media (max-width: 480px) {
    .profile-avatar-large { width: 100px; height: 100px; }
    .profile-avatar-initials { font-size: 36px; }
}

/* ==================== GLOBALE: BLOCCO OVERFLOW MOBILE ==================== */
@media (max-width: 768px) {
    html { overflow-x: hidden; }
    body { overflow-x: hidden; min-height: 100vh; }
    * { -webkit-tap-highlight-color: transparent; }
    input, select, textarea { font-size: 16px !important; }
}
