:root {
    --primary-red: #e11d48;
    --primary-yellow: #facc15;
    --bg-dark: #0f172a;
    --bg-card: rgba(15, 23, 42, 0.35);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --accent: #38bdf8;
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.08);
    --success: #22c55e;
    --warning: #f59e0b;
}

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

body {
    background-color: #0f172a; /* Fallback */
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(225, 29, 72, 0.25), transparent 35%),
        radial-gradient(circle at 85% 30%, rgba(56, 189, 248, 0.25), transparent 35%),
        radial-gradient(circle at 50% 90%, rgba(250, 204, 21, 0.2), transparent 40%),
        radial-gradient(circle at 50% 10%, rgba(34, 197, 94, 0.15), transparent 40%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    background-attachment: fixed;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
aside {
    width: 260px;
    min-width: 260px;
    flex-shrink: 0;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 10001;
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.logo-container img {
    width: 180px;
    height: 180px;
    max-width: 100%;
    object-fit: cover;
    border-radius: 50%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    border: 2px solid var(--glass-border);
}

.logo-container h1 {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--primary-yellow);
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-dim);
    text-decoration: none;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(225, 29, 72, 0.15) 0%, transparent 100%);
    border-left: 3px solid var(--primary-red);
    color: var(--text-main);
}

/* Main Content */
main {
    flex: 1;
    width: 100%;
    padding: 3rem;
    max-width: 1400px;
    margin: 0 auto;
    min-width: 0;
    overflow-x: auto;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 3rem;
}

.header-row h2 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-row p {
    color: var(--text-dim);
    margin-top: 0.5rem;
    font-size: 1.05rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.stat-card .label {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.stat-card .value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-main);
}

.stat-card.highlight {
    border-color: rgba(250, 204, 21, 0.3);
    background: linear-gradient(135deg, rgba(250, 204, 21, 0.05) 0%, rgba(30, 41, 59, 0.7) 100%);
}

/* Section Cards */
.section-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
    margin-bottom: 2.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.section-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.02);
}

.section-body {
    padding: 2rem;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px; /* Adds space between rows */
}

th {
    text-align: left;
    padding: 1rem 1.2rem;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr {
    background: rgba(255,255,255,0.02);
    transition: all 0.2s ease;
}
tbody tr:hover {
    background: rgba(255,255,255,0.06);
    transform: scale(1.01);
}

td {
    padding: 1.2rem;
    font-size: 0.95rem;
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
}
td:first-child {
    border-left: 1px solid var(--glass-border);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}
td:last-child {
    border-right: 1px solid var(--glass-border);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.role-tag {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-pt { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56,189,248,0.3); }
.role-df { background: rgba(34, 197, 94, 0.15); color: #22c55e; border: 1px solid rgba(34,197,94,0.3); }
.role-cc { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.role-att { background: rgba(225, 29, 72, 0.15); color: #e11d48; border: 1px solid rgba(225,29,72,0.3); }

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-red), #9f1239);
    color: white;
    box-shadow: 0 4px 15px rgba(225, 29, 72, 0.4);
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(225, 29, 72, 0.6);
    filter: brightness(1.1);
}


.btn-outline {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.btn-outline:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

/* Form Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    z-index: 1000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 3rem 1rem;
    box-sizing: border-box;
}

.modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 2.5rem;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.85rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-size: 1.05rem;
    font-weight: 500;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--primary-yellow);
    background: rgba(255,255,255,0.05);
    box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.2);
}

.bonus-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Custom Multi Select */
.custom-multi-select {
    position: relative;
    width: 100%;
}

.select-box {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-main);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.select-box:hover {
    border-color: var(--primary-yellow);
    background: rgba(255,255,255,0.05);
}

.options-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-top: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    padding: 0.5rem 0;
}

.options-container.show {
    display: block;
    animation: fadeIn 0.2s ease-out forwards;
}

.optgroup-label {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-yellow);
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.03);
    margin-top: 0.5rem;
}
.optgroup-label:first-child {
    margin-top: 0;
}

.option-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem 0.6rem 2rem;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    color: var(--text-main);
}

.option-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.option-item input {
    margin-right: 0.8rem;
    accent-color: var(--primary-red);
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.role-generic {
    background: rgba(255, 215, 0, 0.15);
    color: var(--primary-yellow);
    border: 1px solid rgba(255, 215, 0, 0.3);
    margin: 2px 0;
}

/* =========================================================
   MOBILE — TUTTI I TELEFONI (≤ 768px)
   ========================================================= */
.mobile-topbar { display: none; }
.mobile-menu-overlay { display: none; }

@media screen and (max-width: 768px) {

    /* Layout base */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        -webkit-overflow-scrolling: touch;
    }

    aside { display: none !important; }

    .app-container { flex-direction: column; }

    main {
        padding: 0.5rem !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        width: 100% !important;
    }

    /* Topbar hamburger */
    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.6rem 1rem;
        background: var(--bg-card);
        border-bottom: 1px solid var(--glass-border);
        position: sticky;
        top: 0;
        z-index: 100;
        backdrop-filter: blur(10px);
    }
    .mobile-topbar .club-name {
        font-size: 0.85rem;
        font-weight: 800;
        color: var(--primary-yellow);
        letter-spacing: 0.5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 55vw;
    }
    .hamburger-btn {
        background: transparent;
        border: none;
        color: white;
        cursor: pointer;
        padding: 0.5rem;
        display: flex;
        flex-direction: column;
        gap: 5px;
        flex-shrink: 0;
    }
    .hamburger-btn span {
        display: block;
        width: 24px;
        height: 2px;
        background: white;
        border-radius: 2px;
        transition: all 0.3s;
    }

    /* Menu overlay */
    .mobile-menu-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: var(--bg-dark);
        z-index: 9000;
        flex-direction: column;
        overflow-y: auto;
        padding: 1.25rem;
    }
    .mobile-menu-overlay.open { display: flex; }
    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1.5rem;
    }
    .mobile-menu-close {
        background: transparent;
        border: none;
        color: white;
        font-size: 2rem;
        cursor: pointer;
        line-height: 1;
    }
    .mobile-nav-item {
        display: flex;
        align-items: center;
        gap: 0.85rem;
        padding: 0.85rem 1rem;
        border-radius: 10px;
        color: var(--text-dim);
        cursor: pointer;
        text-decoration: none;
        font-size: 0.95rem;
        font-weight: 600;
        margin-bottom: 0.2rem;
        border: 1px solid transparent;
        transition: all 0.2s;
    }
    .mobile-nav-item:hover, .mobile-nav-item.active {
        background: rgba(255,255,255,0.07);
        color: white;
        border-color: var(--glass-border);
    }
    .mobile-nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
    .mobile-nav-section-label {
        font-size: 0.68rem;
        font-weight: 800;
        color: var(--text-dim);
        letter-spacing: 2px;
        text-transform: uppercase;
        padding: 0.85rem 1rem 0.25rem 1rem;
    }

    /* Titoli e header */
    .header-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
        margin-bottom: 1rem !important;
    }
    .header-row > div { flex-wrap: wrap !important; gap: 0.5rem !important; width: 100% !important; }
    .header-row h2 { font-size: 1.25rem !important; }

    /* Griglia stats: 2 colonne su phone medio/grande, 1 su piccolo */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
        margin-bottom: 1rem !important;
    }
    .stat-card { padding: 0.85rem !important; border-radius: 10px !important; }
    .stat-card .value { font-size: 1.4rem !important; }
    .stat-card .label { font-size: 0.7rem !important; }

    /* Qualsiasi griglia inline → colonna singola */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr 1fr"],
    [style*="repeat(3, 1fr)"],
    [style*="repeat(4, 1fr)"],
    [style*="repeat(5, 1fr)"] {
        grid-template-columns: 1fr !important;
    }

    /* Grids a 2 colonne nei modali e sezioni */
    .modal-content [style*="grid-template-columns"],
    .section-body [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    .bonus-grid,
    #p-salary-block > div { grid-template-columns: 1fr !important; }

    /* Flex orizzontali → verticali */
    [style*="display: flex"][style*="gap: 2rem"],
    [style*="display: flex"][style*="gap: 1.5rem"],
    [style*="display: flex"][style*="gap: 2.5rem"] {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    /* Section cards */
    .section-card {
        border-radius: 12px !important;
        overflow: hidden !important;
        max-width: 100% !important;
        margin-bottom: 1rem !important;
    }
    .section-header { flex-wrap: wrap !important; gap: 0.5rem !important; padding: 0.75rem 0.85rem !important; }
    .section-body { padding: 0.5rem !important; overflow-x: auto !important; }

    /* Tabelle */
    table { font-size: 0.8rem !important; width: 100%; min-width: max-content; }
    th, td { padding: 0.6rem 0.5rem !important; font-size: 0.8rem !important; word-wrap: normal !important; white-space: nowrap; }

    /* Bottoni — tap target minimo 44px */
    .btn { padding: 0.6rem 0.9rem !important; font-size: 0.85rem !important; min-height: 44px; }

    /* Modal — sale dal basso come sheet */
    .modal {
        padding: 0.5rem !important;
        align-items: flex-end !important;
    }
    .modal-content {
        padding: 1.25rem !important;
        border-radius: 20px 20px 0 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        max-height: 92vh !important;
        overflow-y: auto !important;
    }

    /* Layout Chat su mobile */
    #section-chat { overflow: hidden !important; max-width: 100vw !important; }
    #section-chat .header-row { overflow: hidden !important; }
    #wzp-layout {
        overflow: hidden !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 70vh !important;
    }
    #wzp-sidebar {
        width: 100% !important;
        min-width: 100% !important;
        border-right: none !important;
        flex-shrink: 0 !important;
    }
    #wzp-main {
        width: 100% !important;
        min-width: 100% !important;
        flex-shrink: 0 !important;
    }

    /* Atletica: tab bar scorrevole */
    #section-atletica > div > div[style*="display: flex"][style*="gap: 0.5rem"] {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        padding-bottom: 4px;
    }
    #section-atletica [id^="tab-atl-"] {
        min-width: 100px !important;
        flex-shrink: 0 !important;
        font-size: 0.75rem !important;
        padding: 0.4rem 0.6rem !important;
    }
    #section-atletica div[style*="grid-template-columns: 2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Rosa / Budget: scroll tabelle */
    .section-body { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }

    /* Staff: nascondi tabella, mostra cards */
    #staff-section-table { display: none !important; }
    #staff-mobile-cards { display: flex !important; }

    /* Calendario */
    #section-calendario .calendar-grid { font-size: 0.7rem !important; }

    /* Testo: no overflow */
    h1, h2, h3, h4, p, span, button, label {
        word-wrap: break-word;
        max-width: 100%;
    }
}

/* ---- Telefoni piccoli ≤ 390px (iPhone SE, Galaxy A, ecc.) ---- */
@media screen and (max-width: 390px) {
    main { padding: 0.5rem !important; }

    .stats-grid { grid-template-columns: 1fr !important; }

    .header-row h2 { font-size: 1.1rem !important; }

    .mobile-topbar .club-name { font-size: 0.78rem; max-width: 50vw; }

    .btn { font-size: 0.8rem !important; padding: 0.5rem 0.7rem !important; }

    table { font-size: 0.72rem !important; }
    th, td { padding: 0.4rem 0.3rem !important; font-size: 0.72rem !important; }

    .section-header { padding: 0.7rem 0.75rem !important; }
    .section-body { padding: 0.5rem !important; }

    /* Stats giocatore (presenze/gol/assist/gialli/rossi) */
    [style*="repeat(5, 1fr)"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}


/* Sidebar Macro Categorie & Sotto-Menu */
.nav-category {
    margin-bottom: 0.4rem;
    border-radius: 8px;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.nav-category-header {
    padding: 0.65rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-dim);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
    transition: all 0.25s ease;
    border-radius: 8px;
}

.nav-category-header span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.nav-category-header:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.nav-category-header svg:first-child {
    width: 18px;
    height: 18px;
    opacity: 0.8;
    flex-shrink: 0;
}

.nav-category-header .chevron-icon {
    margin-left: auto;
    width: 14px;
    height: 14px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.6;
    flex-shrink: 0;
}

/* Stato attivo quando un figlio è selezionato */
.nav-category.active-parent .nav-category-header {
    color: var(--primary-yellow);
    background: rgba(255, 215, 0, 0.05);
}

.nav-category.open .chevron-icon {
    transform: rotate(180deg);
    opacity: 1;
}

/* Sottomenu comprimibile con transizione fluida ed allineamento millimetrico */
.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding-left: 0.8rem;
    margin-top: 0.2rem;
    margin-bottom: 0.4rem;
    border-left: 1.5px solid rgba(255, 255, 255, 0.05);
    margin-left: 1.2rem;
}

.nav-category.open .nav-submenu {
    max-height: 350px;
}

.nav-submenu .nav-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.86rem;
    border-radius: 6px;
    background: transparent;
    gap: 0.6rem;
}

.nav-submenu .nav-item svg {
    width: 15px;
    height: 15px;
    opacity: 0.6;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.nav-submenu .nav-item:hover svg, 
.nav-submenu .nav-item.active svg {
    opacity: 1;
}

.nav-submenu .nav-item.active {
    border-left: 2px solid var(--primary-red);
    background: rgba(196, 30, 58, 0.08);
    color: var(--text-main);
}


/* =========================================================
   TABLET — QUALSIASI TABLET (600px – 1280px)
   Copre: iPad mini, iPad Air, iPad Pro, Android tablet,
          Surface, Galaxy Tab, Kindle Fire, ecc.
   ========================================================= */

/* ---- Tablet medio (769px – 1100px) ---- */
@media screen and (min-width: 769px) and (max-width: 1100px) {

    aside {
        width: 190px;
        min-width: 190px;
        padding: 1rem 0.85rem;
        gap: 0.75rem;
    }

    .logo-container img {
        width: 80px;
        height: 80px;
    }
    .logo-container h1 {
        font-size: 0.8rem;
        letter-spacing: 0.5px;
    }

    .nav-category-header {
        font-size: 0.7rem;
        padding: 0.45rem 0.55rem;
    }
    .nav-submenu .nav-item {
        font-size: 0.76rem;
        padding: 0.38rem 0.55rem;
    }

    main {
        padding: 1rem 1.2rem;
        max-width: 100%;
    }

    .header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }
    .header-row h2 { font-size: 1.3rem; }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.8rem;
        margin-bottom: 1.25rem;
    }

    /* Forza single-column su griglie 2-colonne inline */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Griglie 3+ colonne → 2 colonne */
    [style*="grid-template-columns: 1fr 1fr 1fr"],
    [style*="repeat(3"],
    [style*="repeat(4"],
    [style*="repeat(5"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .bonus-grid,
    #p-salary-block > div {
        grid-template-columns: 1fr !important;
    }

    table { font-size: 0.8rem; }
    th, td { padding: 0.6rem 0.5rem; }

    .modal-content {
        max-width: 95vw;
        padding: 1.25rem;
    }

    .btn {
        padding: 0.45rem 0.85rem;
        font-size: 0.82rem;
    }

    /* Tab barre → scroll orizzontale */
    [style*="overflow-x: auto"],
    .atl-tab-nav,
    [id^="tab-atl-"] {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
    }

    /* Section cards */
    .section-card { border-radius: 12px; }
    .section-body { padding: 1rem; }

    /* Chat layout su tablet */
    #section-chat { overflow: hidden !important; }
    #wzp-layout {
        max-width: 100% !important;
        overflow: hidden !important;
    }
    #wzp-sidebar {
        width: 260px !important;
        min-width: 260px !important;
        flex-shrink: 0 !important;
    }
    #wzp-main {
        flex: 1 !important;
        min-width: 0 !important;
    }
}

/* ---- Tablet grande (1101px – 1280px) ---- */
@media screen and (min-width: 1101px) and (max-width: 1280px) {

    aside {
        width: 220px;
        min-width: 220px;
        padding: 1.5rem 1.1rem;
    }
    .logo-container img { width: 110px; height: 110px; }
    .logo-container h1 { font-size: 0.9rem; }

    main {
        padding: 1.5rem 2rem;
        max-width: 100%;
    }

    .header-row h2 { font-size: 1.6rem; }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem;
    }

    .modal-content { max-width: 90vw; }

    /* Chat layout su tablet grande */
    #section-chat { overflow: hidden !important; }
    #wzp-layout {
        max-width: 100% !important;
        overflow: hidden !important;
    }
}

/* ---- Fix iPad Portrait esatto (768px) ---- */
@media screen and (max-width: 768px) {
    main {
        padding: 1rem;
        max-width: 100%;
        width: 100%;
    }
}


/* Hide PWA install link when running inside standalone PWA */
@media (display-mode: standalone) {
    #nav-install-app, #mobile-nav-install-app, #mobile-topbar-download-btn {
        display: none !important;
    }
}

/* =========================================
   IOS SPRINGBOARD REDESIGN — PREMIUM v2
   ========================================= */

/* Nascondi la vecchia navigazione */
aside, .mobile-topbar, .mobile-menu-overlay, .hamburger-btn {
    display: none !important;
}

/* Il main prende tutto lo schermo */
main {
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    min-height: 100vh;
    overflow-x: hidden;
    background: transparent;
}

/* ── Sfondo animato Home Screen ── */
#section-home {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    background: #060c1a;
    padding: 0 !important;
}

/* Glow orbs animati in background */
#section-home::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.18) 0%, transparent 70%);
    top: -150px; left: -150px;
    animation: orbFloat 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}
#section-home::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.14) 0%, transparent 70%);
    bottom: -100px; right: -100px;
    animation: orbFloat 10s ease-in-out infinite reverse;
    pointer-events: none;
    z-index: 0;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.97); }
}

/* Orb terzo */
.ios-orb3 {
    position: absolute;
    width: 300px; height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.12) 0%, transparent 70%);
    top: 40%; left: 50%; transform: translate(-50%, -50%);
    animation: orbFloat 12s ease-in-out infinite 2s;
    pointer-events: none;
    z-index: 0;
}

/* ── Header della Home ── */
.ios-home-header {
    position: relative;
    z-index: 1;
    padding: 50px 20px 20px;
    text-align: center;
}

.ios-home-time {
    font-size: 4.5rem;
    font-weight: 100;
    color: #fff;
    letter-spacing: -2px;
    line-height: 1;
    margin-bottom: 4px;
    text-shadow: 0 0 40px rgba(255,255,255,0.15);
}

.ios-home-date {
    font-size: 1rem;
    color: rgba(255,255,255,0.6);
    font-weight: 400;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.ios-home-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 30px;
    padding: 6px 14px;
    margin-top: 10px;
}

.ios-home-avatar {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--primary-yellow, #facc15);
    color: #000;
    font-weight: 900;
    font-size: 0.65rem;
    display: flex; align-items: center; justify-content: center;
}

.ios-home-user-name {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.85);
    font-weight: 600;
}

/* ── Griglia Icone Premium ── */
.ios-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 22px 10px;
    padding: 30px 20px 40px;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

@media (max-width: 400px) {
    .ios-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px 8px;
        padding: 20px 14px 40px;
    }
    .ios-icon {
        width: 62px !important;
        height: 62px !important;
    }
    .ios-home-time { font-size: 3.5rem !important; }
}

/* Animazione ingresso icone a cascata */
.ios-app {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    opacity: 0;
    transform: scale(0.7) translateY(20px);
    animation: iconAppear 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.ios-app:nth-child(1)  { animation-delay: 0.05s; }
.ios-app:nth-child(2)  { animation-delay: 0.10s; }
.ios-app:nth-child(3)  { animation-delay: 0.15s; }
.ios-app:nth-child(4)  { animation-delay: 0.20s; }
.ios-app:nth-child(5)  { animation-delay: 0.25s; }
.ios-app:nth-child(6)  { animation-delay: 0.30s; }
.ios-app:nth-child(7)  { animation-delay: 0.35s; }
.ios-app:nth-child(8)  { animation-delay: 0.40s; }
.ios-app:nth-child(9)  { animation-delay: 0.45s; }
.ios-app:nth-child(10) { animation-delay: 0.50s; }
.ios-app:nth-child(11) { animation-delay: 0.55s; }
.ios-app:nth-child(12) { animation-delay: 0.60s; }

@keyframes iconAppear {
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.ios-app:active .ios-icon {
    transform: scale(0.88);
    filter: brightness(1.1);
}

/* ── Icona App ── */
.ios-icon {
    width: 68px;
    height: 68px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-bottom: 6px;
    position: relative;
    /* Inner shine overlay */
    overflow: hidden;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                box-shadow 0.3s ease,
                filter 0.15s ease;
}

/* Shine overlay su ogni icona */
.ios-icon::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.25), transparent);
    border-radius: 20px 20px 0 0;
    z-index: 1;
    pointer-events: none;
}

/* Glow colorato al hover */
.ios-app:hover .ios-icon {
    transform: scale(1.08) translateY(-3px);
}

.ios-icon i {
    width: 30px;
    height: 30px;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
}

/* ── Label ── */
.ios-label {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.85);
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}

/* ── Top Nav Premium ── */
#ios-top-nav {
    background: rgba(6, 12, 26, 0.75) !important;
    backdrop-filter: saturate(180%) blur(20px) !important;
    -webkit-backdrop-filter: saturate(180%) blur(20px) !important;
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
    padding: 14px 16px !important;
}

#ios-top-nav button {
    font-family: 'Inter', sans-serif;
    font-size: 1rem !important;
    font-weight: 600 !important;
    letter-spacing: -0.2px;
}

#ios-top-nav-title {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.3px;
}

/* ── Contenuto sezioni (dopo il nav) ── */
main > section:not(#section-home) {
    padding: 16px 16px 80px;
    max-width: 960px;
    margin: 0 auto;
}

/* ── Animazioni slide pagina ── */
.ios-slide-in {
    animation: iOSSlideIn 0.32s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes iOSSlideIn {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}


