/* ================= VARIABLES ================= */
:root {
    --bg-primary: #f3f6f9;
    --bg-secondary: #fff;
    --text-primary: #172754;
    --text-secondary: #374151;
    --border-color: #d5dbe7;
    --hover-bg: #EFF3FE;
    --accent-blue: #172754;
    --accent-blue-dark: #3b82f6;
    --header-gradient-start: #3A404C;
    --header-gradient-end: #2D343F;
    --title-blue: #172754;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
    --hover-bg: #334155;
    --accent-blue: #172754;
    --accent-blue-dark: #93c5fd;
    --header-gradient-start: #1e293b;
    --header-gradient-end: #0f172a;
    --title-blue: #93c5fd;
}

/* ================= LOGIN PAGE ================= */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 20px;
    padding: 48px;
    max-width: 450px;
    width: 100%;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.login-logo {
    width: 50%;     
    height: 10%;
    padding: 25px;   
    margin: 0 auto 24px;
    background: #172754;
    border-radius: 3%;
    border: 3px solid white;        
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}
.login-title {
    font-size: 32px;
    font-weight: 700;
    color: #172754;
    margin-bottom: 12px;
}

.login-subtitle {
    font-size: 16px;
    color: #6b7280;
    margin-bottom: 32px;
}

.login-btn {
    width: 100%;
    padding: 16px 24px;
    background: #172754;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s;
}

.login-btn:hover {
    background: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
}

.login-btn:active {
    transform: translateY(0);
}

.login-error {
    margin-top: 20px;
    padding: 12px;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 8px;
    font-size: 14px;
    display: none;
}

.login-loading {
    display: none;
    margin-top: 20px;
    color: #6b7280;
    font-size: 14px;
}

/* ================= USER INFO BAR ================= */
.user-info-bar {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 999;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    border-bottom-left-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

[data-theme="dark"] .user-info-bar {
    background: rgba(30, 41, 59, 0.95);
}

.user-info-name {
    font-weight: 600;
    color: var(--text-primary);
}

.user-info-role {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.user-info-role.admin {
    background: #dbeafe;
    color: #1e3a8a;
}

.user-info-role.user {
    background: #f3e8ff;
    color: #6b21a8;
}

.logout-btn {
    padding: 6px 12px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* ================= RESPONSIVE - MOBILE FIRST ================= */
@media (max-width: 768px) {

    /* ── Body ── */
    body {
        padding: 8px 8px calc(120px + env(safe-area-inset-bottom, 0px));
        /* 120px = barra 64px + margine 56px; env() aggiunge la safe area iPhone */
    }

    /* ── Login ── */
    .login-box {
        padding: 28px 20px;
    }
    .login-logo {
        width: 80px;
        height: auto;
    }
    .login-title {
        font-size: 22px;
    }

    /* ── User info bar ── */
    .user-info-bar {
        padding: 8px 12px;
        font-size: 12px;
    }
    .user-info-name {
        display: none;
    }

    /* ── Logo header: più compatto ── */
    .logo-box {
        padding: 10px 0;
        margin-bottom: 4px;
        border-radius: 8px;
    }
    .logo-img {
        height: 44px;
    }

    /* ── Titolo h1: ridotto ── */
    h1 {
        font-size: 17px;
        margin: 8px 0 6px;
    }

    /* ── Navigazione ANNO: icone sole, niente testo ── */
    .year-nav-bar {
        gap: 8px;
        margin-bottom: 8px;
    }
    .year-nav-bar .nav-btn {
        padding: 8px 14px;
        font-size: 13px;
        width: auto;
    }
    .year-nav-label {
        display: none; /* nasconde "Anno Prec." / "Anno Succ." su mobile */
    }

    /* ── Navigazione MESE: compatta ── */
    .calendar-header {
        gap: 8px;
        margin-bottom: 10px;
    }
    .calendar-header .nav-btn {
        padding: 8px 14px;
        width: auto;
    }
    .month-label {
        font-size: 17px;
        min-width: 130px;
    }

    /* ── View mode bar: scroll orizzontale per contenere tutti i bottoni ── */
    .view-mode-bar {
        gap: 6px;
        padding: 0 0 10px;
        justify-content: center;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .view-btn {
        flex: 0 0 auto;
        padding: 8px 14px;
        font-size: 13px;
        white-space: nowrap;
    }
    /* Nessun bottone nascosto: tutti visibili con scroll orizzontale */

    /* ── Hint SHIFT+Click: inutile su touch ── */
    .shift-hint {
        display: none;
    }

    /* ── Bottone Inserisci Ferie: nascosto dalla posizione desktop,
          appare nella bottom bar mobile (vedi sotto) ── */
    .insert-holidays-btn {
        display: none;
    }

    /* ── Stats cards: scroll orizzontale con snap ── */
    .stats-row {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 10px;
        padding-bottom: 8px;
        width: 100%;
    }
    .stats-row::-webkit-scrollbar { display: none; }
    .stat-card {
        flex: 0 0 68vw;
        scroll-snap-align: start;
        min-width: 200px;
    }
    .stat-value {
        font-size: 26px;
    }
    .stat-label {
        font-size: 11px;
    }

    /* ── Dashboard: stacked, chart collassato di default (via JS) ── */
    .dashboard-row {
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }
    .dashboard-box,
    .chart-box {
        width: 100%;
        padding: 14px;
        box-sizing: border-box;
    }
    .chart-box canvas {
        height: 220px !important;
    }

    /* ── Planner: scroll orizzontale con indicatore ── */
    .planner-box {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
    .planner {
        min-width: 620px;
        font-size: 10px;
    }
    .planner th,
    .planner td {
        padding: 5px 2px;
        min-width: 22px;
        height: 34px;
    }
    .member-name {
        position: sticky !important;
        left: 0 !important;
        z-index: 10 !important;  /* Sopra tutte le celle che scorrono */
        background: var(--bg-secondary) !important;
        min-width: 76px !important;
        font-size: 11px;
        box-shadow: 2px 0 4px rgba(0,0,0,0.08); /* Ombra lato destro per indicare il freeze */
    }
    /* Header member-name ancora più in alto dello z-index per stare sopra i td */
    th.member-name {
        z-index: 15 !important;
        background: var(--bg-secondary) !important;
    }
    /* ── Titolo mese sticky su mobile: rimane visibile mentre si scrolla ── */
    .planner-month-title {
        position: sticky;
        top: 0;
        z-index: 20;
        font-size: 16px;
        padding: 7px 0;
        margin-bottom: 0;
        border-radius: 0;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    }

    /* Indicatore "scorri" sul planner */
    .planner-scroll-hint {
        display: block;
        text-align: center;
        font-size: 11px;
        color: var(--text-secondary);
        padding: 4px 0 2px;
        opacity: 0.7;
    }

    /* ── MOBILE GOOGLE CALENDAR VIEW ── */
    .mob-cal-user-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 12px 8px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
    }
    .mob-cal-user-name {
        font-weight: 700;
        font-size: 15px;
        color: var(--text-primary);
        flex: 1;
        text-align: center;
    }
    .mob-cal-own-badge {
        display: inline-block;
        font-size: 9px;
        font-weight: 700;
        background: #172754;
        color: white;
        border-radius: 4px;
        padding: 1px 5px;
        margin-left: 6px;
        vertical-align: middle;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    .mob-cal-nav-btn {
        background: none;
        border: none;
        color: var(--text-secondary);
        font-size: 20px;
        cursor: pointer;
        padding: 4px 8px;
        border-radius: 8px;
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .mob-cal-nav-btn:active { background: var(--hover-bg); }
    .mob-cal-nav-btn:disabled { opacity: 0.25; cursor: default; }
    .mob-gcal-wrapper {
        background: var(--bg-secondary);
        border-radius: 12px;
        overflow: hidden;
        border: 1px solid var(--border-color);
        margin-bottom: 14px;
    }
    .mob-gcal-month-title {
        font-size: 14px;
        font-weight: 700;
        color: var(--text-primary);
        padding: 10px 14px 6px;
    }
    .mob-gcal-grid {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        border-top: 1px solid var(--border-color);
    }
    .mob-gcal-header-cell {
        text-align: center;
        font-size: 10px;
        font-weight: 700;
        color: var(--text-secondary);
        padding: 5px 2px;
        text-transform: uppercase;
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border-color);
        border-right: 1px solid var(--border-color);
    }
    .mob-gcal-header-cell:last-child { border-right: none; }
    .mob-gcal-day {
        min-height: 54px;
        border-right: 1px solid var(--border-color);
        border-bottom: 1px solid var(--border-color);
        padding: 4px 3px 3px;
        background: var(--bg-secondary);
        box-sizing: border-box;
    }
    .mob-gcal-day:nth-child(7n) { border-right: none; }
    .mob-gcal-day.mob-gcal-empty { background: var(--bg-primary); }
    .mob-gcal-day.mob-gcal-editable { cursor: pointer; }
    .mob-gcal-day.mob-gcal-editable:active { background: var(--hover-bg); }
    .mob-gcal-today .mob-gcal-num-inner {
        background: #172754;
        color: white !important;
        border-radius: 50%;
        width: 22px;
        height: 22px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .mob-gcal-num {
        font-size: 12px;
        font-weight: 600;
        text-align: center;
        color: var(--text-primary);
        margin-bottom: 2px;
    }
    .mob-gcal-day.mob-gcal-sunday .mob-gcal-num,
    .mob-gcal-day.mob-gcal-holiday .mob-gcal-num { color: #ef4444; }
    .mob-gcal-chip {
        font-size: 9px;
        font-weight: 700;
        text-align: center;
        border-radius: 4px;
        padding: 1px 3px;
        margin-top: 1px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.5;
        display: block;
    }
    .mob-gcal-chip.ferie-full  { background: #ef4444; color: white; }
    .mob-gcal-chip.ferie-morn  { background: #3b82f6; color: white; }
    .mob-gcal-chip.ferie-aftn  { background: #8b5cf6; color: white; }
    .mob-gcal-chip.ferie-other { background: #6b7280; color: white; }
    .mob-gcal-chip.holiday-lbl { color: #ef4444; font-size: 8px; background: transparent; padding: 0; }
    .mob-gcal-range-lbl {
        font-size: 8px;
        color: var(--text-secondary);
        text-align: center;
        display: block;
        margin-top: 1px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ── Modal ferie: touch-friendly ── */
    .modal-panel {
        width: 96vw;
        max-width: 96vw;
        padding: 16px 14px;
        border-radius: 16px;
    }
    .modal-title {
        font-size: 17px;
    }
    /* Tap target minimo 44px (Apple HIG) */
    .hour-btn {
        padding: 0;
        min-height: 44px;
        min-width: 60px;
        font-size: 13px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .btn-full-day {
        min-height: 48px;
        font-size: 15px;
    }
    .cancel-btn {
        min-height: 40px;
        padding: 8px 18px;
    }

    /* ── Modal analisi ── */
    .user-analysis-modal {
        padding: 8px;
    }
    .user-analysis-header {
        padding: 14px 16px;
    }
    .user-analysis-title h2 {
        font-size: 18px;
    }
    .user-analysis-body {
        padding: 14px;
    }
    .analysis-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .analysis-stat-value {
        font-size: 22px;
    }
    .analysis-chart-container {
        height: 180px;
    }
    .month-selector {
        gap: 6px;
    }
    .month-chip {
        padding: 6px 10px;
        font-size: 11px;
    }

    /* ── Version badge: ridotto ── */
    .version-badge {
        font-size: 9px;
        padding: 3px 7px;
        bottom: 68px; /* sopra la bottom bar */
        right: 8px;
    }
}

/* ── BOTTOM ACTION BAR - solo mobile ── */
.mobile-bottom-bar {
    display: none; /* Sempre nascosta di default; viene mostrata da syncMobileUI() solo dopo il login */
}
@media (max-width: 768px) {
    .mobile-bottom-bar {
        /* display gestito via JS - non impostare flex qui */
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 990;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 16px rgba(0,0,0,0.10);
        padding: 8px 12px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); /* iPhone home bar */
        gap: 8px;
        align-items: center;
        justify-content: space-between;
    }
    .mob-nav-btn {
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-radius: 10px;
        color: var(--text-primary);
        font-size: 20px;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        transition: background 0.15s;
    }
    .mob-nav-btn:active {
        background: var(--hover-bg);
    }
    .mob-insert-btn {
        flex: 1;
        height: 44px;
        background: #172754;
        color: white;
        border: none;
        border-radius: 10px;
        font-size: 13px;
        font-weight: 700;
        letter-spacing: 1px;
        cursor: pointer;
        transition: background 0.15s;
    }
    .mob-insert-btn:active {
        background: #3b82f6;
    }
    .mob-extras-btn {
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-radius: 10px;
        color: var(--text-secondary);
        font-size: 18px;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
    }
    /* Drawer "Altro" (PDF, Excel, Semestre, Anno) */
    .mob-extras-drawer {
        display: none;
        position: fixed;
        bottom: 64px;
        right: 12px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 14px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.18);
        z-index: 991;
        overflow: hidden;
        min-width: 180px;
    }
    .mob-extras-drawer.open {
        display: block;
    }
    .mob-drawer-item {
        display: block;
        width: 100%;
        padding: 14px 18px;
        text-align: left;
        background: none;
        border: none;
        border-bottom: 1px solid var(--border-color);
        color: var(--text-primary);
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
    }
    .mob-drawer-item:last-child {
        border-bottom: none;
    }
    .mob-drawer-item:active {
        background: var(--hover-bg);
    }
}

/* ================= RESPONSIVE - TABLET ================= */
@media (min-width: 769px) and (max-width: 1024px) {
    .stats-row {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .dashboard-row {
        grid-template-columns: 1fr 1fr;
    }
    
    .planner-box {
        margin-bottom: 20px;
    }
    
    .analysis-stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .planner-scroll-hint {
        display: block;
        text-align: center;
        font-size: 11px;
        color: var(--text-secondary);
        padding: 4px 0 2px;
        opacity: 0.7;
    }
}

/* ================= STICKY NAV HEADER ================= */
.sticky-nav {
    position: sticky;
    top: 0;
    z-index: 200;
    /* Estende oltre il padding del body per coprire tutta la larghezza del viewport */
    margin-left: -20px;
    margin-right: -20px;
    padding: 10px 20px 6px;
    background: var(--bg-primary);
    /* Ombra visibile solo dopo scroll */
    box-shadow: 0 0 0 transparent;
    transition: box-shadow 0.25s ease;
}
.sticky-nav.scrolled {
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}
[data-theme="dark"] .sticky-nav.scrolled {
    box-shadow: 0 4px 20px rgba(0,0,0,0.40);
}
/* Compatta h1 dentro lo sticky */
.sticky-nav h1 {
    margin: 0 0 8px;
    font-size: 22px;
}
.sticky-nav .year-nav-bar {
    margin-bottom: 8px !important;
}
.sticky-nav .calendar-header {
    margin-bottom: 8px;
}
.sticky-nav .view-mode-bar {
    margin: 0 0 4px;
}
/* Su mobile lo sticky è disabilitato: la bottom bar gestisce già nav mese */
@media (max-width: 768px) {
    .sticky-nav {
        /* Sticky abilitato anche su mobile */
        margin-left: -8px;  /* compensa il padding body mobile (8px) */
        margin-right: -8px;
        padding: 6px 8px 4px;
        /* Ombra sempre visibile su mobile per separare il nav dal contenuto */
        box-shadow: none;
    }
    .sticky-nav.scrolled {
        box-shadow: 0 3px 12px rgba(0,0,0,0.12);
    }
    /* Compatta ulteriormente i margini interni su mobile */
    .sticky-nav h1 {
        font-size: 17px;
        margin: 0 0 4px;
    }
    .sticky-nav .year-nav-bar {
        margin-bottom: 4px !important;
    }
    .sticky-nav .calendar-header {
        margin-bottom: 6px;
    }
    .sticky-nav .view-mode-bar {
        margin: 0 0 2px;
    }
}

/* ================= BASE ================= */
body{
    font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text",
               "Segoe UI",Roboto,system-ui,sans-serif;
    background:var(--bg-primary);
    margin:0;
    padding:20px;
    color:var(--text-primary);
    transition:background 0.3s ease, color 0.3s ease;
}

/* ── Zoom per schermi ~24" a 1920x1080: riduce tutto del 20% ── */
@media screen and (max-width: 1920px) and (max-height: 1084px) {
    #appContainer {
        zoom: 0.80;
    }
}

/* ── Zoom per notebook/MacBook 13-15": riduce tutto del 30% ── */
@media screen and (max-width: 1440px) and (max-height: 900px) {
    #appContainer {
        zoom: 0.70;
    }
}

/* ── Sticky-nav più compatto per schermi 24" a 1920x1080 (zoom 0.80) ──
   Lo zoom 0.70 dei notebook compatta già abbastanza; qui interveniamo
   solo sulla fascia 1440-1920 dove lo zoom è solo 0.80               ── */
@media screen and (min-width: 1441px) and (max-width: 1920px) and (max-height: 1084px) {
    .sticky-nav {
        padding: 7px 20px 4px;
    }
    .sticky-nav h1 {
        font-size: 19px;
        margin: 0 0 6px;
    }
    .sticky-nav .year-nav-bar {
        margin-bottom: 6px !important;
    }
    .sticky-nav .calendar-header {
        margin-bottom: 6px;
        gap: 14px;
    }
    .sticky-nav .view-mode-bar {
        margin: 0 0 3px;
        gap: 7px;
    }
    .nav-btn {
        padding: 9px 13px;
        font-size: 14px;
    }
    .month-label {
        font-size: 19px;
        min-width: 155px;
    }
    .view-btn {
        padding: 8px 16px;
        font-size: 14px;
    }
}

/* ================= LOGO HEADER ================= */
.logo-box{
    width:100%;
    margin-bottom:8px;
    padding:20px 0;
    text-align:center;
    background:linear-gradient(180deg, var(--header-gradient-start), var(--header-gradient-end));
    border-radius:12px;
}
.logo-img{
    height:70px;
    width:auto;
    filter:drop-shadow(0 2px 4px rgba(0,0,0,.5));
}

/* Dark Mode Toggle */
.dark-mode-toggle{
    display:flex;
    justify-content:center;
    margin:10px 0 16px;
}
.theme-switch{
    background:var(--bg-secondary);
    border:1px solid var(--border-color);
    border-radius:999px;
    padding:6px 14px;
    cursor:pointer;
    color:var(--text-secondary);
    font-size:13px;
    display:flex;
    align-items:center;
    gap:8px;
    transition:all 0.3s ease;
}
.theme-switch:hover{
    background:var(--hover-bg);
    border-color:var(--accent-blue);
}
.theme-icon{
    width:16px;
    height:16px;
    display:flex;
    align-items:center;
    justify-content:center;
}

@media(max-width:768px){
    .logo-img{height:48px}
}

/* ================= TITOLI ================= */
h1, h2, h3{
    color:var(--title-blue);
}
h1{
    text-align:center;
    margin:10px 0 14px;
}

/* ================= HEADER NAV ================= */
.calendar-header{
    display:flex;
    justify-content:center;
    align-items:center;
    gap:20px;
    margin-bottom:20px;
}
.nav-btn{
    padding:12px 16px;
    border-radius:999px;
    border:1px solid var(--border-color);
    background:var(--bg-secondary);
    color:var(--text-primary);
    cursor:pointer;
    transition:all 0.2s ease;
    font-weight:600;
    font-size:15px;
    display:flex;
    align-items:center;
    justify-content:center;
}
.nav-btn svg{
    display:block;
}
.nav-btn:hover{
    background:var(--accent-blue);
    color:#FDFCF0;
    border-color:var(--accent-blue);
    transform:translateY(-1px);
    box-shadow:0 4px 8px rgba(0,0,0,.1);
}
.nav-btn:hover svg{
    stroke:#FDFCF0;
}
.month-label{
    font-weight:700;
    color:var(--title-blue);
    font-size:22px;
    min-width:180px;
    text-align:center;
}

/* ================= VIEW ================= */
.view-mode-bar{
    display:flex;
    justify-content:center;
    gap:10px;
    margin:0 0 30px;
    flex-wrap:wrap;
}
.view-btn{
    padding:10px 20px;
    border-radius:999px;
    border:1px solid var(--border-color);
    background:var(--bg-secondary);
    color:var(--text-primary);
    cursor:pointer;
    transition:all 0.2s ease;
    font-size:15px;
    font-weight:500;
}
.view-btn:hover{
    background:var(--hover-bg);
    transform:translateY(-1px);
    box-shadow:0 2px 4px rgba(0,0,0,.08);
}
.view-btn.active{
    background:var(--accent-blue);
    color:#ffffff;
    border-color:var(--accent-blue);
    font-weight:600;
    box-shadow:0 4px 8px rgba(96,165,250,.3);
}

/* ================= PAGE LAYOUT ================= */
.page-wrapper{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:28px;
}

/* ================= STATISTICHE CARD ================= */
.stats-row{
    width:70%;
    display:grid;
    grid-template-columns:repeat(auto-fit, minmax(180px, 1fr));
    gap:12px;
    margin-bottom:16px;
}
.stat-card{
    background:var(--bg-secondary);
    padding:14px 16px;
    border-radius:10px;
    box-shadow:0 2px 8px rgba(0,0,0,.06);
    border-left:3px solid var(--accent-blue);
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.stat-card.accent-orange { border-left-color: #f97316; }
.stat-card.accent-green  { border-left-color: #22c55e; }
.stat-card.accent-red    { border-left-color: #ef4444; }
.stat-card.accent-green .stat-value { color: #16a34a; }
.stat-card.accent-red .stat-value   { color: #dc2626; }
[data-theme="dark"] .stat-card.accent-green .stat-value { color: #4ade80; }
[data-theme="dark"] .stat-card.accent-red .stat-value   { color: #f87171; }
.saldo-pos { color: #16a34a; font-weight: 700; }
.saldo-neg { color: #dc2626; font-weight: 700; }
[data-theme="dark"] .saldo-pos { color: #4ade80; }
[data-theme="dark"] .saldo-neg { color: #f87171; }

/* ── Colonne ordinabili dashboard ── */
#dashboardTable th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
#dashboardTable th.sortable:hover {
    background: var(--hover-bg);
}
#dashboardTable th.sort-active {
    color: var(--accent-blue-dark);
}
#dashboardTable th .sort-icon {
    display: inline-block;
    margin-left: 4px;
    font-size: 10px;
    opacity: 0.6;
}
#dashboardTable th.sort-active .sort-icon {
    opacity: 1;
}

.stat-label{
    font-size:10px;
    color:var(--text-secondary);
    text-transform:uppercase;
    letter-spacing:0.6px;
    margin-bottom:6px;
    font-weight:600;
}
.stat-value{
    font-size:24px;
    font-weight:700;
    color:var(--title-blue);
}
.stat-subvalue{
    font-size:12px;
    color:var(--text-secondary);
    margin-top:3px;
}

/* ================= DASHBOARD ================= */
.dashboard-row{
    width:70%;
    display:flex;
    gap:3%;
}
.dashboard-box{
    width:32%;
    background:var(--bg-secondary);
    padding:18px;
    border-radius:12px;
    box-shadow:0 2px 8px rgba(0,0,0,.06);
}
.dashboard-box h3{
    margin:0 0 14px 0;
    color:var(--title-blue);
    font-size:17px;
}
.chart-box{
    width:68%;
    background:var(--bg-secondary);
    padding:18px;
    border-radius:12px;
    box-shadow:0 2px 8px rgba(0,0,0,.06);
}

.chart-box h3{
    margin:0 0 14px 0;
    color:var(--title-blue);
    font-size:17px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color 0.2s ease;
}

.chart-box h3:hover {
    color: #3b82f6;
}

/* Icona freccia toggle */
.chart-toggle-icon {
    font-size: 14px;
    transition: transform 0.3s ease;
    color: var(--text-secondary);
}

.chart-toggle-icon.expanded {
    transform: rotate(180deg);
}

/* Contenuto grafico collassabile */
.chart-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 1000px;
    opacity: 1;
}

.chart-content.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Filtri Utenti */
.chart-filters{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    margin-bottom:14px;
    padding-bottom:10px;
    border-bottom:1px solid var(--border-color);
}
.filter-chip{
    padding:6px 12px;
    border-radius:999px;
    border:1px solid var(--border-color);
    background:var(--bg-secondary);
    color:var(--text-primary);
    cursor:pointer;
    font-size:12px;
    transition:all 0.2s ease;
    display:flex;
    align-items:center;
    gap:6px;
}
.filter-chip:hover{
    background:var(--hover-bg);
    transform:translateY(-1px);
}
.filter-chip.active{
    background:var(--accent-blue);
    color:#ffffff;
    border-color:var(--accent-blue);
}
.filter-chip-color{
    width:10px;
    height:10px;
    border-radius:50%;
}

.chart-box canvas{
    height:320px!important;
    max-height:320px;
}

/* ================= TOTALI TABLE ================= */
#dashboardTable{
    width:100%;
    border-collapse:collapse;
    font-size:15px;
}
#dashboardTable th{
    background:#EFF3FE;
    color:var(--title-blue);
    border:1px solid #c7d2fe;
    padding:12px 10px;
    font-weight:700;
    text-align:center;
    font-size:14px;
}
#dashboardTable td{
    border:1px solid var(--border-color);
    padding:12px 10px;
    text-align:center;
    background:var(--bg-secondary);
    color:var(--text-primary);
    transition:all 0.2s ease;
}
#dashboardTable td:first-child,
.dashboard-username {
    text-align:left;
    font-weight:700;
    font-size:15px;
}

/* Colore nome utente - Light Mode */
#dashboardTable td:first-child,
.dashboard-username {
    color:#172754;  /* Blu scuro leggibile */
}

/* Colore nome utente - Dark Mode */
[data-theme="dark"] #dashboardTable td:first-child,
[data-theme="dark"] .dashboard-username {
    color:#93c5fd;  /* Blu chiaro leggibile */
}

#dashboardTable tbody tr{
    cursor:pointer;
}

/* ================= DASHBOARD TABLE HOVER - DARK ================= */
[data-theme="dark"] #dashboardTable tbody tr:hover{
    background:#173B54;          /* scuro ma distinto */
    transform:scale(1.01);
}

[data-theme="dark"] #dashboardTable tbody tr:hover td{
    background:#173B54;
}
[data-theme="dark"] #dashboardTable tbody tr:hover td{
    color:#93c5fd;
}

/* ================= DASHBOARD TABLE ROW HOVER - LIGHT ================= */
#dashboardTable tbody tr:hover td{
    background:#EFF3FE;          /* oppure var(--hover-bg) */
    color:#172754;
}


#dashboardTable tbody tr:hover td{
    color:#173B54;
}





#dashboardTable td:nth-child(2),
#dashboardTable td:nth-child(3){
    font-weight:700;
    color:var(--accent-blue-dark);
    font-size:15px;
}

/* ================= PLANNER ================= */
/* Hint di scorrimento: visibile solo su mobile/tablet (max-width:1024px) */
.planner-scroll-hint {
    display: none;
}
.planner-container{width:70%}
#plannersContainer{
    display:flex;
    flex-direction:column;
    gap:28px;
}

.planner-month-title{
    font-size:20px;
    font-weight:700;
    color:var(--title-blue);
    margin-bottom:4px;
    padding:8px 0;
    text-align:center;
    background:var(--bg-secondary);
    border-radius:8px 8px 0 0;
    border-bottom:2px solid var(--accent-blue);
}

.planner-box{
    border-radius:14px;
    overflow-x:auto;
    overflow-y:hidden;
    background:var(--bg-secondary);
    box-shadow:0 4px 14px rgba(0,0,0,.08);
    -webkit-overflow-scrolling: touch;
}

table.planner{
    width:max-content;
    min-width:100%;
    border-collapse:collapse;
}

th,td{
    border:1px solid var(--border-color);
    padding:6px;
    height:38px;
    text-align:center;
    font-size:14px;
    color:var(--text-primary);
}

th.member-name,td.member-name{
    position:sticky;
    left:0;
    z-index:5;
    background:var(--bg-secondary);
    font-weight:700;
    text-align:left;
    padding-left:10px;
    white-space:nowrap;
    font-size:14px;
    text-transform: uppercase;
}

.weekday-row th{
    background:#EFF3FE;
    color:var(--title-blue);
    font-weight:600;
    font-size:14px;
}

/* ── Ghost header fisso per il planner — DISABILITATO ──
#plannerGhostHeader {
    position: fixed;
    z-index: 180;
    overflow: hidden;
    pointer-events: none;
    display: none;
    background: var(--bg-secondary);
    box-shadow: 0 3px 8px rgba(0,0,0,0.10);
}
#plannerGhostHeader table {
    border-collapse: collapse;
    table-layout: fixed;
}
#plannerGhostHeader th {
    border: 1px solid var(--border-color);
    padding: 2px 4px;
    height: 26px;
    white-space: nowrap;
    font-size: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 500;
}
#plannerGhostHeader .weekday-row th {
    background: #EFF3FE;
    color: var(--title-blue);
    font-weight: 600;
}
[data-theme="dark"] #plannerGhostHeader .weekday-row th {
    background: #1e3a5f;
}
#plannerGhostHeader th.member-name {
    background: var(--bg-secondary);
    font-weight: 700;
    color: var(--text-secondary);
}
── */
.holiday-col{
    background:#fde6b3;
    cursor:not-allowed;
}
[data-theme="dark"] .holiday-col{
    background:#173B54;
}
td.editable{cursor:pointer}
td.editable:hover{background:var(--hover-bg)}
td.full-day{background:#ffd6d6;color:#b30000;font-weight:600}
td.morning-partial{background:#d6ecff;color:#0b5ed7;font-weight:600}
td.afternoon-partial{background:#F79169;color:#7c2d12;font-weight:600}

/* Cella con permessi multipli */
td.multi-permit {
    background: linear-gradient(135deg, #d6ecff 50%, #e6dbff 50%);
    font-size: 9px !important;
    font-weight: 700;
    line-height: 1.2;
    padding: 1px !important;
    vertical-align: middle;
}
td.multi-permit .mp-line {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
}
td.multi-permit .mp-line.mp-M { color: #0b5ed7; }
td.multi-permit .mp-line.mp-P { color: #7c2d12; }

/* Santo Patrono Marnate */
td.santo-patrono {
    background: #fdf3e3;
    color: #92400e;
    font-weight: 700;
    cursor: pointer;
}
td.santo-patrono:hover { background: #fde8c8; }

[data-theme="dark"] td.full-day{background:#7f1d1d;color:#fca5a5}
[data-theme="dark"] td.morning-partial{background:#1e3a8a;color:#93c5fd}
[data-theme="dark"] td.afternoon-partial{background:#7c2d12;color:#ffedd5}
[data-theme="dark"] td.multi-permit{background:linear-gradient(135deg,#1e3a8a 50%,#4c1d95 50%)}
[data-theme="dark"] td.multi-permit .mp-line.mp-M{color:#93c5fd}
[data-theme="dark"] td.multi-permit .mp-line.mp-P{color:#ffedd5}
[data-theme="dark"] td.santo-patrono{background:#3b2a14;color:#fbbf24}
[data-theme="dark"] td.santo-patrono:hover{background:#4a3520}

/* ── Segnaposto cella ── */
td.segnaposto-cell {
    background: linear-gradient(135deg, #ede9fe 60%, #ddd6fe) !important;
    color: #3F2278 !important;
    font-weight: 700 !important;
    font-size: 11px !important;
    cursor: pointer;
}
td.segnaposto-cell:hover { background: linear-gradient(135deg, #ddd6fe 60%, #c4b5fd) !important; }
[data-theme="dark"] td.segnaposto-cell {
    background: linear-gradient(135deg, #2e1065 60%, #3b0764) !important;
    color: #c4b5fd !important;
}
[data-theme="dark"] td.segnaposto-cell:hover { background: linear-gradient(135deg, #3b0764 60%, #4c1d95) !important; }

/* ── Bottone Inserisci Evento (stesso stile di insert-holidays-btn, colori viola #3F2278) ── */
.btn-segnaposto {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 11rem;
    height: 3rem;
    overflow: hidden;
    background-size: 300% 300%;
    cursor: pointer;
    backdrop-filter: blur(1rem);
    border-radius: 5rem;
    transition: 0.5s;
    animation: gradient_segnaposto 5s ease infinite;
    border: double 4px transparent;
    background-image: linear-gradient(#3F2278, #3F2278),
        linear-gradient(137.48deg, #c4b5fd 10%, #a78bfa 45%, #7c3aed 67%, #3F2278 87%);
    background-origin: border-box;
    background-clip: content-box, border-box;
    position: relative;
    flex-shrink: 0;
}
.btn-segnaposto:hover { transform: scale(1.1); }
.btn-segnaposto:active {
    border: double 4px #a78bfa;
    background-origin: border-box;
    background-clip: content-box, border-box;
    animation: none;
}
.btn-segnaposto .sg-stars-container {
    position: absolute;
    z-index: -1;
    width: 100%; height: 100%;
    overflow: hidden;
    transition: 0.5s;
    backdrop-filter: blur(1rem);
    border-radius: 5rem;
}
.btn-segnaposto:hover .sg-stars-container {
    z-index: 1;
    background-color: #3F2278;
}
.btn-segnaposto .sg-glow {
    position: absolute;
    display: flex;
    width: 10rem;
}
.btn-segnaposto .sg-glow-circle {
    width: 100%; height: 30px;
    filter: blur(2rem);
    animation: pulse_glow_sg 4s infinite;
    z-index: -1;
}
.btn-segnaposto .sg-glow-circle:nth-of-type(1) { background: rgba(167,139,250,0.6); }
.btn-segnaposto .sg-glow-circle:nth-of-type(2) { background: rgba(124,58,237,0.7); }
.btn-segnaposto:active .sg-glow-circle { background: #a78bfa; }
.btn-segnaposto .sg-label {
    z-index: 2;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #ffffff;
    text-shadow: 0 0 4px white;
    position: relative;
}
@keyframes gradient_segnaposto {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes pulse_glow_sg {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}
@media (max-width: 768px) { .btn-segnaposto { display: none !important; } }

/* ================= MODALE ================= */
.modal-overlay{
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.35);
    backdrop-filter:blur(6px);
    display:none;
    align-items:center;
    justify-content:center;
    z-index:1000;
    overflow-y:auto;
    padding:20px;
}
.modal-panel{
    background:var(--bg-secondary);
    border-radius:18px;
    padding:20px 22px;
    width:420px;
    max-width:90vw;
    max-height:90vh;
    overflow-y:auto;
}
.modal-title{
    font-weight:700;
    font-size:18px;
    color:var(--text-primary);
}
.modal-subtitle{
    font-size:13px;
    color:var(--text-secondary);
    margin-bottom:12px;
}
.btn-full-day{
    width:100%;
    padding:10px;
    border-radius:999px;
    border:1px solid #fca5a5;
    background:#fee2e2;
    color:#b30000;
    font-weight:600;
    cursor:pointer;
    margin-bottom:14px;
}
[data-theme="dark"] .btn-full-day{
    background:#7f1d1d;
    border-color:#991b1b;
    color:#fca5a5;
}
.modal-section{margin-bottom:12px}
.modal-section-title{
    font-size:13px;
    font-weight:600;
    margin-bottom:6px;
    color:var(--text-primary);
}
.modal-hours{
    display:flex;
    gap:6px;
    flex-wrap:wrap;
}
.hour-btn{
    padding:6px 12px;
    border-radius:999px;
    border:1px solid var(--border-color);
    background:var(--bg-secondary);
    color:var(--text-primary);
    cursor:pointer;
    font-size:13px;
}
.hour-btn:hover{
    background:var(--hover-bg);
}
.modal-footer{
    display:flex;
    justify-content:space-between;
    margin-top:10px;
}
.remove-link{color:#dc2626;font-size:13px;cursor:pointer}
[data-theme="dark"] .remove-link{color:#f87171}
.cancel-btn{
    padding:6px 14px;
    border-radius:999px;
    border:none;
    background:var(--hover-bg);
    color:var(--text-primary);
    cursor:pointer;
}

/* ================= LOADING INDICATOR ================= */
.loading-overlay{
    position:fixed;
    inset:0;
    background:rgba(255,255,255,0.9);
    display:flex;
    align-items:center;
    justify-content:center;
    z-index:9999;
}
[data-theme="dark"] .loading-overlay{
    background:rgba(15,23,42,0.9);
}
.loading-spinner{
    width:50px;
    height:50px;
    border:4px solid var(--border-color);
    border-top:4px solid var(--accent-blue);
    border-radius:50%;
    animation:spin 1s linear infinite;
}
@keyframes spin{
    0%{transform:rotate(0deg)}
    100%{transform:rotate(360deg)}
}

/* ================= RESPONSIVE ================= */
@media(max-width:1200px){
    .planner-container,.dashboard-row,.stats-row{width:100%}
}
@media(max-width:900px){
    .dashboard-row{
        flex-direction:column;
        gap:16px;
    }
    .dashboard-box,.chart-box{width:100%}
    .chart-box canvas{height:300px!important}
}
@media(max-width:768px){
    th,td{font-size:12px;height:32px}
    .chart-box canvas{height:280px!important}
    .stat-value{font-size:20px}
    .month-label{font-size:18px}
    .nav-btn{padding:10px 18px;font-size:14px}
    .view-btn{padding:8px 16px;font-size:14px}
    #dashboardTable{font-size:13px}
    #dashboardTable th{font-size:12px;padding:10px 8px}
    #dashboardTable td{padding:10px 8px}
}

/* ================= PDF SPECIFIC STYLES ================= */
.pdf-export-mode .stats-row{
    width:100%;
    grid-template-columns:repeat(4, 1fr);
    gap:6px;
    margin-bottom:8px;
}
.pdf-export-mode .stat-card{
    padding:6px 8px;
    border-left-width:2px;
}
.pdf-export-mode .stat-label{
    font-size:8px;
    margin-bottom:3px;
}
.pdf-export-mode .stat-value{
    font-size:14px;
}
.pdf-export-mode .stat-subvalue{
    font-size:9px;
    margin-top:2px;
}

.pdf-export-mode .dashboard-row{
    width:100%;
    gap:2%;
    margin-bottom:10px;
}
.pdf-export-mode .dashboard-box{
    width:30%;
    padding:8px;
}
.pdf-export-mode .dashboard-box h3{
    font-size:12px;
    margin-bottom:6px;
}
.pdf-export-mode #dashboardTable{
    font-size:9px;
}
.pdf-export-mode #dashboardTable th,
.pdf-export-mode #dashboardTable td{
    padding:4px 3px;
}

.pdf-export-mode .chart-box{
    width:70%;
    padding:8px;
}
.pdf-export-mode .chart-box h3{
    font-size:12px;
    margin-bottom:6px;
}
.pdf-export-mode .chart-box canvas{
    height:140px!important;
    max-height:140px;
}
.pdf-export-mode .chart-filters{
    display:none;
}

.pdf-export-mode .planner-container{
    width:100%;
}
.pdf-export-mode .planner-month-title{
    font-size:13px;
    padding:4px 0;
    margin-bottom:4px;
    page-break-before:auto;
    page-break-after:avoid;
}
.pdf-export-mode .planner-box{
    page-break-inside:avoid;
    margin-bottom:6px;
    font-size:10px;
}
.pdf-export-mode .planner-box table.planner{
    font-size:9px;
}
.pdf-export-mode .planner-box th,
.pdf-export-mode .planner-box td{
    padding:3px 2px;
    height:auto;
    font-size:9px;
}
.pdf-export-mode .planner-box th.member-name,
.pdf-export-mode .planner-box td.member-name{
    font-size:9px;
    padding-left:6px;
}

.pdf-export-mode h1{
    font-size:18px;
    margin:6px 0;
}
.pdf-export-mode .logo-img{
    height:40px;
}
.pdf-export-mode .logo-box{
    padding:10px 0;
    margin-bottom:8px;
}

/* Gestione pagine per calendari */
.pdf-export-mode #plannersContainer > div:nth-child(3n+1){
    page-break-before:auto;
}
.pdf-export-mode #plannersContainer > div:nth-child(3n){
    page-break-after:auto;
}
.pdf-export-mode #plannersContainer > div:nth-child(3n+3){
    page-break-after:always;
}

/* ================= DARK MODE TH ================= */
[data-theme="dark"] th{
    background:#173B54;
    color:#f1f5f9;
    border-color:#334155;
}

[data-theme="dark"] #dashboardTable th{
    background:#173B54;
    color:#f1f5f9;
}

/* ================= INSERISCI FERIE BUTTON ================= */
.insert-holidays-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 11rem;
    height: 3rem;
    overflow: hidden;
    background-size: 300% 300%;
    cursor: pointer;
    backdrop-filter: blur(1rem);
    border-radius: 5rem;
    transition: 0.5s;
    animation: gradient_holidays 5s ease infinite;
    border: double 4px transparent;
    background-image: linear-gradient(#172754, #172754),
        linear-gradient(137.48deg, #60a5fa 10%, #3b82f6 45%, #2563eb 67%, #172754 87%);
    background-origin: border-box;
    background-clip: content-box, border-box;
    position: relative;
    flex-shrink: 0;
}

.insert-holidays-btn:hover {
    transform: scale(1.1);
}

.insert-holidays-btn:active {
    border: double 4px #3b82f6;
    background-origin: border-box;
    background-clip: content-box, border-box;
    animation: none;
}

.btn-stars-container {
    position: absolute;
    z-index: -1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    transition: 0.5s;
    backdrop-filter: blur(1rem);
    border-radius: 5rem;
}

.insert-holidays-btn:hover .btn-stars-container {
    z-index: 1;
    background-color: #172754;
}

.btn-text {
    z-index: 2;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #ffffff;
    text-shadow: 0 0 4px white;
}

.btn-glow {
    position: absolute;
    display: flex;
    width: 10rem;
}

.glow-circle {
    width: 100%;
    height: 30px;
    filter: blur(2rem);
    animation: pulse_glow 4s infinite;
    z-index: -1;
}

.glow-circle:nth-of-type(1) {
    background: rgba(59, 130, 246, 0.6);
}

.glow-circle:nth-of-type(2) {
    background: rgba(37, 99, 235, 0.7);
}

.insert-holidays-btn:active .glow-circle {
    background: #3b82f6;
}

.btn-stars {
    position: relative;
    background: transparent;
    width: 200rem;
    height: 200rem;
}

.btn-stars::after {
    content: "";
    position: absolute;
    top: -10rem;
    left: -100rem;
    width: 100%;
    height: 100%;
    animation: animStarRotate 90s linear infinite;
    background-image: radial-gradient(#ffffff 1px, transparent 1%);
    background-size: 50px 50px;
}

.btn-stars::before {
    content: "";
    position: absolute;
    top: 0;
    left: -50%;
    width: 170%;
    height: 500%;
    animation: animStar 60s linear infinite;
    background-image: radial-gradient(#ffffff 1px, transparent 1%);
    background-size: 50px 50px;
    opacity: 0.5;
}

@keyframes animStar {
    from { transform: translateY(0); }
    to { transform: translateY(-135rem); }
}

@keyframes animStarRotate {
    from { transform: rotate(360deg); }
    to { transform: rotate(0); }
}

@keyframes gradient_holidays {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes pulse_glow {
    0% {
        transform: scale(0.75);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
    100% {
        transform: scale(0.75);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

/* ── Bottone Release Allianz — colore #225778 ── */
.insert-allianz-btn {
    background-image: linear-gradient(#0c2d3f, #0c2d3f),
        linear-gradient(137.48deg, #7dd3fc 10%, #38bdf8 45%, #0284c7 67%, #225778 87%);
    animation: gradient_allianz 5s ease infinite;
}
.insert-allianz-btn:active {
    border: double 4px #38bdf8;
    animation: none;
}
.insert-allianz-btn:hover .btn-stars-container {
    background-color: #0c2d3f;
}
.insert-allianz-btn .glow-circle:nth-of-type(1) { background: rgba(56,189,248,0.6); }
.insert-allianz-btn .glow-circle:nth-of-type(2) { background: rgba(2,132,199,0.7); }
@keyframes gradient_allianz {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ================= PRESIDIO SABATO ================= */

.presidio-cell {
    background: #1e3a8a !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 11px !important;
}
[data-theme="dark"] .presidio-cell {
    background: #1d4ed8 !important;
    color: #ffffff !important;
}

/* Pre-Produzione: stessi colori del presidio */
td.preprod-cell {
    background: #1e3a8a !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 11px !important;
    cursor: pointer;
}
[data-theme="dark"] td.preprod-cell {
    background: #1d4ed8 !important;
    color: #ffffff !important;
}


/* ================= SELEZIONE MULTIPLA ================= */
.cell-selected {
    outline: 3px solid #3b82f6!important;
    outline-offset: -3px;
    background: rgba(59, 130, 246, 0.1) !important;
}

/* ================= CORONA ICON ================= */
.crown-icon {
    display: inline-block;
    margin-left: 6px;
    font-size: 30px;
    color: #fbbf24;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
    animation: crown-shine 2s ease-in-out infinite;
}

@keyframes crown-shine {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

kbd {
    background: #e5e7eb;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-family: monospace;
    border: 1px solid #d1d5db;
}

[data-theme="dark"] kbd {
    background: #334155;  /* Grigio più chiaro per contrasto */
    color: #93C5FD;       /* Blu chiaro */
    border: 1px solid #475569;
}

/* ================= MODAL ANALISI UTENTE FULLSCREEN ================= */
.user-analysis-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    overflow-y: auto;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}


.user-analysis-content {
    max-width: 600px;
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    animation: slideInUp 0.4s ease;
}

.user-analysis-header {
    background: linear-gradient(135deg, #172754, #3b82f6);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.user-analysis-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-analysis-title h2 {
    color: white;
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.user-analysis-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.user-analysis-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.user-analysis-body {
    padding: 16px;
}

.analysis-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.analysis-stat-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    text-align: center;
    transition: all 0.2s;
}

.analysis-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.analysis-stat-icon {
    font-size: 18px;
    margin-bottom: 4px;
}

.analysis-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--title-blue);
    margin: 4px 0;
}

.analysis-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.analysis-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

.analysis-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--title-blue);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.analysis-chart-container {
    height: 150px;
    position: relative;
}

.month-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.month-chip {
    padding: 4px 8px;
    border-radius: 20px;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s;
}

.month-chip:hover {
    border-color: var(--accent-blue);
    background: var(--hover-bg);
}

.month-chip.active {
    border-color: var(--accent-blue);
    background: var(--accent-blue);
    color: white;
}

.holidays-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.holiday-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

.holiday-item.full-day {
    border-left-color: #ef4444;
}

.holiday-item.morning {
    border-left-color: #3b82f6;
}

.holiday-item.afternoon {
    border-left-color: #a855f7;
}

.holiday-icon {
    font-size: 14px;
}

.holiday-date {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 80px;
    font-size: 12px;
}

.holiday-type {
    color: var(--text-secondary);
    font-size: 11px;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@media (max-width: 768px) {
    .user-analysis-body {
        padding: 10px;
    }
    
    .analysis-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
}



/* ================= USER MODE (permesso user) ================= */
body.user-mode #dashboardTable td,
body.user-mode #dashboardTable th{
    padding-top: 16px;
    padding-bottom: 16px;
}

/* ================= VERSION BADGE ================= */
.version-badge {
    position: fixed;
    bottom: 12px;
    right: 12px;
    z-index: 998;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .version-badge {
    background: rgba(30, 41, 59, 0.9);
    color: #94a3b8;
    border-color: #334155;
}

@media (max-width: 768px) {
    .version-badge {
        font-size: 9px;
        padding: 3px 8px;
        bottom: 8px;
        right: 8px;
    }
}

/* ================= USER ROW HIGHLIGHT ================= */
/* ================= USER ROW HIGHLIGHT - SOLUZIONE UX ELEGANTE ================= */

/* Effetto glow morbido che fa risaltare la riga senza coprire i colori */
.user-own-row {
    position: relative;
    box-shadow: 
        0 0 0 1px rgba(59, 130, 246, 0.2),
        0 0 20px rgba(59, 130, 246, 0.15),
        inset 0 0 0 1px rgba(59, 130, 246, 0.1);
    background: linear-gradient(
        90deg, 
        rgba(59, 130, 246, 0.03) 0%, 
        rgba(59, 130, 246, 0.02) 100%
    );
}

[data-theme="dark"] .user-own-row {
    box-shadow: 
        0 0 0 1px rgba(96, 165, 250, 0.3),
        0 0 25px rgba(96, 165, 250, 0.2),
        inset 0 0 0 1px rgba(96, 165, 250, 0.15);
    background: linear-gradient(
        90deg, 
        rgba(59, 130, 246, 0.06) 0%, 
        rgba(59, 130, 246, 0.04) 100%
    );
}

/* Hover effect - intensifica leggermente il glow */
.user-own-row:hover {
    box-shadow: 
        0 0 0 1px rgba(59, 130, 246, 0.3),
        0 0 30px rgba(59, 130, 246, 0.25),
        inset 0 0 0 1px rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .user-own-row:hover {
    box-shadow: 
        0 0 0 1px rgba(96, 165, 250, 0.4),
        0 0 35px rgba(96, 165, 250, 0.3),
        inset 0 0 0 1px rgba(96, 165, 250, 0.2);
}

/* Evidenziazione cella nome utente - glow laterale */
.user-own-cell {
    position: relative;
    box-shadow: inset 3px 0 0 rgba(59, 130, 246, 0.4);
    font-weight: 700;
}

[data-theme="dark"] .user-own-cell {
    box-shadow: inset 3px 0 0 rgba(96, 165, 250, 0.5);
}

/* Mantieni colori originali delle celle */
.user-own-row td {
    position: relative;
}

/* Le celle weekend mantengono i loro colori originali */
.user-own-row td.holiday-col {
    background: #fde6b3; /* Colore originale preservato */
}

[data-theme="dark"] .user-own-row td.holiday-col {
    background: #1e3a5a; /* Blu scuro coerente con palette (invece di marrone) */
    color: #93c5fd; /* Testo blu chiaro per contrasto */
}

/* Ferie giornata intera nella riga utente - dark mode con colori più morbidi */
[data-theme="dark"] .user-own-row td.full-day {
    background: #881337; /* Rose-900 più morbido del rosso scuro standard */
    color: #fda4af; /* Rose-300 per testo leggibile */
}

/* ── Colonna giorno corrente ── */
.today-col {
    background-color: rgba(59,130,246,0.07);
}
thead .today-col {
    background-color: rgba(59,130,246,0.14);
    color: var(--accent-blue-dark);
    font-weight: 700;
}
[data-theme="dark"] .today-col {
    background-color: rgba(99,160,255,0.10);
}
[data-theme="dark"] thead .today-col {
    background-color: rgba(99,160,255,0.20);
}

/*[PRESIDIO ]*/
  
.user-own-row td.presidio-cell {
    background: #172754;
    color: white;
}


/* Cursore not-allowed su celle altri utenti per USER */
.user-not-editable-cell {
    cursor: not-allowed !important;
}

/* ================= DASHBOARD GIF ================= */
.dashboard-gif-container {
    margin-top: 20px;
    text-align: center;
    padding: 15px;
}

.dashboard-gif {
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 240px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0.92;
    transition: opacity 0.3s, transform 0.3s;
}

.dashboard-gif:hover {
    opacity: 1;
    transform: scale(1.02);
}

@media (max-width: 768px) {
    .dashboard-gif {
        max-height: 180px;
    }
}

@media (max-width: 480px) {
    .dashboard-gif {
        max-height: 120px;
    }
}

/* ================= USER MODE ADJUSTMENTS ================= */
/* Nascondi dashboard-box per USER */
.user-mode .dashboard-box {
    display: none;
}

/* Chart-box occupa tutto lo spazio per USER */
.user-mode .chart-box {
    width: 100%;
}

/* ================= DASHBOARD TABLE SCROLL ================= */
.dashboard-table-wrapper {
    max-height: 480px; /* ~10-12 righe, poi scroll */
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 8px;
}

/* Scrollbar personalizzata */
.dashboard-table-wrapper::-webkit-scrollbar {
    width: 8px;
}

.dashboard-table-wrapper::-webkit-scrollbar-track {
    background: var(--bg-main);
    border-radius: 4px;
}

.dashboard-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--accent-blue);
    border-radius: 4px;
}

.dashboard-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #2563eb;
}

/* Header dashboard con toggle */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.dashboard-header h3 {
    margin: 0;
}

/* Bottone ordinamento dashboard */
.dashboard-sort-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
}

.dashboard-sort-btn:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.dashboard-sort-icon {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.dashboard-sort-btn.descending .dashboard-sort-icon {
    transform: rotate(180deg);
}

/* Badge contatore */
.user-count-badge {
    background: var(--accent-blue);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    margin-left: 6px;
}

/* ================= FLOATING GIF GATTA (EASTER EGG) ================= */
.floating-gatta {
    position: fixed;
    bottom: 50px;
    left: 20px;
    z-index: 997;
    width: 140px;
    height: 140px;
    opacity: 0.7;
    transition: all 0.3s ease;
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    /* Neutralizza zoom CSS del parent container */
    zoom: 1;
}

/* Badge immagine utente — in alto a destra */
.floating-badge {
    position: fixed;
    top: 60px;
    right: 16px;
    z-index: 996;
    width: 110px;
    height: 110px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    opacity: 0.92;
    transition: all 0.3s ease;
    cursor: default;
    zoom: 1;
}
.floating-badge:hover {
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0,0,0,0.28);
}
[data-theme="dark"] .floating-badge {
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
@media screen and (max-width: 1100px), screen and (max-height: 700px) {
    .floating-badge { display: none !important; }
}
@media (max-width: 768px) {
    .floating-badge { display: none !important; }
}

/* Nasconde la mascotte quando la finestra è ridotta (zoom browser alto o schermo piccolo) */
@media screen and (max-width: 1100px), screen and (max-height: 700px) {
    .floating-gatta {
        display: none !important;
    }
}

.floating-gatta:hover {
    opacity: 1;
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .floating-gatta {
    opacity: 0.6;
}

[data-theme="dark"] .floating-gatta:hover {
    opacity: 0.95;
}

@media (max-width: 768px) {
    .floating-gatta {
        display: none !important;
    }
}

/* ================= DESKTOP FULLSCREEN - PIÙ COMPATTO E CENTRATO ================= */
@media (min-width: 1400px) {
    .page-wrapper {
        gap: 20px;
        max-width: 1750px; /* Aumentato del ~9% da 1600px */
        margin: 0 auto;    /* CENTRATO */
        width: 100%;
        padding: 0 20px;
    }
    
    /* Mantieni sezione top compatta */
    h1 {
        margin: 8px 0 12px; /* Leggermente ridotto */
        font-size: 28px;    /* Mantieni dimensione originale */
    }
    
    .calendar-header {
        margin-bottom: 16px; /* Ridotto se necessario */
    }
    
    .view-btn {
        padding: 10px 18px; /* Mantieni dimensioni compatte */
    }
    
    .stats-row {
        width: 75%; /* Uniformato - più largo di prima */
        gap: 10px;
        margin-bottom: 12px;
        margin-left: auto;
        margin-right: auto;
    }
    
    .stat-card {
        padding: 12px 14px;
    }
    
    .stat-value {
        font-size: 22px;
    }
    
    .dashboard-row {
        width: 75%; /* Uniformato - uguale a stats-row */
        gap: 2%;
        margin-left: auto;
        margin-right: auto;
    }
    
    .dashboard-box,
    .chart-box {
        padding: 16px;
    }
    
    .planner-container {
        width: 75%; /* Uniformato - uguale alle altre sezioni */
        margin-left: auto;
        margin-right: auto;
    }
    
    .planner table {
        font-size: 12px;
    }
    
    .planner th,
    .planner td {
        padding: 6px 4px;
    }
    
    .planner-box {
        padding: 14px;
    }
}

