:root{
    --blu:#004b7a;
    --blu2:#006fae;
    --bluScuro:#003b63;
    --azzurro:#eaf4ff;
    --sfondo:#f5f8fc;
    --testo:#203040;
    --bianco:#ffffff;
    --ombra:0 8px 24px rgba(0,0,0,0.08);
}

*{
    box-sizing:border-box;
}

body{
    margin:0;
    font-family:'Segoe UI', Arial, sans-serif;
    background:linear-gradient(
        180deg,
        #f8fbff 0%,
        #eef5fb 100%
    );
    color:var(--testo);
}

/* HEADER */

.page-header{
    background:linear-gradient(
        135deg,
        var(--bluScuro),
        var(--blu2)
    );
    color:white;
    padding:20px 35px;
    display:flex;
    align-items:center;
    gap:20px;
    box-shadow:0 4px 15px rgba(0,0,0,0.15);
}

.page-header h1{
    margin:0;
    font-size:30px;
}

.page-header p{
    margin:5px 0 0;
    opacity:0.9;
}

.page-logo{
    width:32px;
    height:32px;
    object-fit:contain;
}

/* CONTENUTO */

.container{
    max-width:1400px;
    margin:auto;
    padding:30px;
}

/* BOX */

.box{
    background:white;
    border-radius:16px;
    padding:25px;
    margin-bottom:25px;
    box-shadow:var(--ombra);
}

/* CARD */

.card{
    background:white;
    border-radius:16px;
    padding:25px;
    box-shadow:var(--ombra);
    transition:0.2s;
}

.card:hover{
    transform:translateY(-4px);
}

.cards{
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(250px,1fr));
    gap:20px;
}

/* BOTTONI */

.bottone,
button{
    display:inline-block;
    padding:12px 18px;
    border:none;
    border-radius:10px;
    background:linear-gradient(
        135deg,
        var(--bluScuro),
        var(--blu2)
    );
    color:white;
    text-decoration:none;
    cursor:pointer;
    font-weight:600;
    transition:0.2s;
}

.bottone:hover,
button:hover{
    opacity:0.9;
    transform:translateY(-1px);
}

/* FORM */

input,
select,
textarea{
    width:100%;
    padding:10px;
    border:1px solid #d6dde5;
    border-radius:8px;
    margin-top:5px;
}

textarea{
    min-height:100px;
}

/* TABELLE */

table{
    width:100%;
    border-collapse:collapse;
    background:white;
    border-radius:14px;
    overflow:hidden;
    box-shadow:var(--ombra);
}

th{
    background:linear-gradient(
        135deg,
        var(--bluScuro),
        var(--blu2)
    );
    color:white;
    padding:12px;
    font-size:14px;
}

td{
    padding:10px;
    border-bottom:1px solid #eef2f6;
}

tr:hover{
    background:#f8fbff;
}

.nome{
    font-weight:bold;
    text-align:left;
}

/* STATI CALENDARIO */

.presente{
    background:#d4edda !important;
}

.ferie{
    background:#cfe2ff !important;
}

.malattia{
    background:#f8d7da !important;
}

.permesso{
    background:#ffe5b4 !important;
}

.infortunio{
    background:#e2d5f8 !important;
}

.assenza{
    background:#dddddd !important;
}

.nonlavorativo{
    background:#ffd6d6 !important;
    color:#a00000;
    font-weight:bold;
}

/* WEEKEND */

.sabato{
    background:#f0f0f0 !important;
}

.domenica{
    background:#ffdcdc !important;
    color:#b00000;
    font-weight:bold;
}

/* LEGENDA */

.legenda span{
    display:inline-block;
    padding:8px 12px;
    margin-right:6px;
    border-radius:6px;
    border:1px solid #ddd;
}

/* FOOTER */

.footer{
    margin-top:40px;
    background:linear-gradient(
        135deg,
        var(--bluScuro),
        var(--blu2)
    );
    color:white;
    padding:18px 30px;
    display:flex;
    justify-content:space-between;
}

/* MOBILE */

@media(max-width:900px){

    .page-header{
        flex-direction:column;
        text-align:center;
    }

    .footer{
        flex-direction:column;
        text-align:center;
        gap:10px;
    }

    .container{
        padding:15px;
    }

    table{
        font-size:12px;
    }
}
/* CALENDARIO SCORREVOLE */

.table-container{
    width:100%;
    overflow-x:auto;
    overflow-y:auto;
    padding-bottom:10px;
}

.table-container table{
    min-width:1900px;
}

.table-container .nome{
    position:sticky;
    left:0;
    background:white !important;
    z-index:20;
    min-width:220px;
}

.table-container th{
    position:sticky;
    top:0;
    z-index:10;
}

.table-container th:first-child{
    left:0;
    z-index:30;
}

.table-container select{
    width:82px;
    font-size:11px;
    padding:5px;
}
.table-container{
    width:100%;
    max-width:100%;
    overflow-x:scroll;
    overflow-y:auto;
    background:white;
    border-radius:14px;
    box-shadow:0 8px 24px rgba(0,0,0,0.08);
}

.calendario-table{
    min-width:2200px;
    width:max-content;
    box-shadow:none;
}

.calendario-table th,
.calendario-table td{
    white-space:nowrap;
}

.calendario-table .nome{
    position:sticky;
    left:0;
    z-index:20;
    background:white !important;
    min-width:220px;
}
@media print {
    .page-header,
    .footer,
    .bottone,
    button {
        display:none !important;
    }

    body {
        background:white !important;
    }

    .container {
        padding:0;
    }

    .box {
        box-shadow:none;
        border:none;
    }
}
.page-logo{
    cursor:pointer;
}
.valido{
    background:#d4edda !important;
}

.inscadenza{
    background:#fff3cd !important;
}

.scaduto{
    background:#f8d7da !important;
}
/* SCADENZE */

.valido{
    background:#d4edda !important;
    color:#155724;
}

.inscadenza{
    background:#fff3cd !important;
    color:#856404;
    font-weight:bold;
}

.scaduto{
    background:#f8d7da !important;
    color:#721c24;
    font-weight:bold;
}
.box h2{
    display:flex;
    align-items:center;
    gap:10px;
}
.scadenze-box{
    border-left:5px solid #ff9800;
}
/* ORGANIGRAMMA */

.org-link{
    text-decoration:none;
    color:inherit;
    display:inline-block;
}

.org-link:hover .org-node{
    transform:translateY(-3px);
    transition:0.2s;
    box-shadow:0 10px 24px rgba(0,0,0,0.15);
}
/* V11 - Calendario presenze: scroll interno, intestazioni e nominativi fissi, mezze giornate */
html, body{
    max-width:100%;
    overflow-x:hidden;
}

.presenze-form{
    width:100%;
}

.toolbar-presenze{
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    gap:10px;
}

.legenda-presenze{
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    gap:8px;
}

.legenda-presenze strong{
    margin-right:8px;
}

.legenda-presenze span{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-height:28px;
    padding:5px 10px;
    border-radius:999px;
    font-size:12px;
    font-weight:800;
}

.presenze-scroll{
    width:100%;
    max-width:100%;
    max-height:72vh;
    overflow:auto;
    border-radius:16px;
    background:white;
    border:1px solid #dbe7f3;
    box-shadow:0 10px 28px rgba(0,55,95,0.12);
    position:relative;
}

.calendario-presenze-table{
    border-collapse:separate;
    border-spacing:0;
    min-width:max-content;
    width:max-content;
    margin:0;
    box-shadow:none !important;
}

.calendario-presenze-table th,
.calendario-presenze-table td{
    box-sizing:border-box;
    border-right:1px solid #dbe7f3;
    border-bottom:1px solid #dbe7f3;
    white-space:nowrap;
    background:white;
}

.calendario-presenze-table thead th{
    position:sticky;
    z-index:40;
    background:#073b63 !important;
    color:white;
    text-align:center;
    box-shadow:0 2px 0 rgba(0,0,0,.08);
}

.calendario-presenze-table thead tr:first-child th{
    top:0;
}

.calendario-presenze-table thead tr:nth-child(2) th{
    top:40px;
}

.calendario-presenze-table .dipendente-col{
    position:sticky;
    left:0;
    z-index:55;
    width:230px;
    min-width:230px;
    max-width:230px;
    text-align:left;
    background:#fff !important;
    color:#073b63;
    font-weight:800;
    box-shadow:4px 0 8px rgba(0,55,95,.08);
}

.calendario-presenze-table thead .dipendente-col{
    z-index:80;
    background:#052f4f !important;
    color:white !important;
}

.calendario-presenze-table .giorno-col,
.calendario-presenze-table .giorno-cell{
    width:76px;
    min-width:76px;
    max-width:76px;
    text-align:center;
}

.calendario-presenze-table .totale-col{
    width:72px;
    min-width:72px;
    max-width:72px;
    text-align:center;
    background:#f8fbff !important;
    font-weight:800;
}

.calendario-presenze-table thead .totale-col{
    background:#0a4b78 !important;
    color:white;
}

.calendario-presenze-table select{
    width:68px !important;
    max-width:68px;
    min-width:68px;
    height:34px;
    border-radius:9px;
    border:1px solid rgba(0,0,0,.13);
    font-size:11px;
    padding:3px 4px;
    font-weight:800;
    cursor:pointer;
}

.calendario-presenze-table .sabato,
.calendario-presenze-table td.sabato{
    background:#fff8e6 !important;
}

.calendario-presenze-table .domenica,
.calendario-presenze-table td.domenica{
    background:#ffecec !important;
}

.calendario-presenze-table thead .sabato{
    background:#9a6512 !important;
    color:#fff !important;
}

.calendario-presenze-table thead .domenica{
    background:#9f1239 !important;
    color:#fff !important;
}

.calendario-presenze-table select.mezza,
.legenda-presenze span.mezza{
    background-image:linear-gradient(135deg, rgba(255,255,255,.45) 0 25%, transparent 25% 50%, rgba(255,255,255,.45) 50% 75%, transparent 75% 100%) !important;
    background-size:14px 14px;
    border-style:dashed;
}

.calendar-save-bar{
    position:sticky;
    bottom:0;
    z-index:20;
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    gap:12px;
    margin-top:14px;
    padding:12px 14px;
    background:white;
    border:1px solid #dbe7f3;
    border-radius:14px;
    box-shadow:0 8px 24px rgba(0,55,95,.08);
}

.calendar-save-bar span{
    color:#63748a;
    font-size:13px;
    font-weight:700;
}

@media(max-width:760px){
    .presenze-scroll{
        max-height:68vh;
    }
    .calendario-presenze-table .dipendente-col{
        width:170px;
        min-width:170px;
        max-width:170px;
    }
    .calendario-presenze-table .giorno-col,
    .calendario-presenze-table .giorno-cell{
        width:70px;
        min-width:70px;
        max-width:70px;
    }
    .calendario-presenze-table select{
        width:62px !important;
        min-width:62px;
        max-width:62px;
        font-size:10px;
    }
}


/* V12 - Calendario con blocca riquadri reale tipo Excel */
body.calendario-page{
    height:100vh;
    height:100dvh;
    overflow:hidden !important;
    display:flex;
    flex-direction:column;
}

body.calendario-page .page-header{
    flex:0 0 auto;
    padding:14px 24px;
}

body.calendario-page .container.calendario-container{
    width:100%;
    max-width:none;
    flex:1 1 auto;
    min-height:0;
    display:flex;
    flex-direction:column;
    overflow:hidden !important;
    padding:14px 18px 0;
}

body.calendario-page .box{
    flex:0 0 auto;
    margin-bottom:10px;
    padding:12px 16px;
    border-radius:14px;
}

body.calendario-page .footer{
    display:none !important;
}

body.calendario-page .presenze-form{
    flex:1 1 auto;
    min-height:0;
    display:flex;
    flex-direction:column;
    overflow:hidden !important;
    margin:0;
}

body.calendario-page .calendario-freeze-pane,
body.calendario-page .presenze-scroll{
    flex:1 1 auto;
    min-height:260px;
    max-height:none !important;
    width:100% !important;
    max-width:100% !important;
    overflow:auto !important;
    overflow-x:auto !important;
    overflow-y:auto !important;
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
    border-radius:16px;
    border:1px solid #cbdceb;
    background:#fff;
    box-shadow:0 10px 28px rgba(0,55,95,0.13);
    position:relative;
}

body.calendario-page .calendario-presenze-table{
    border-collapse:separate !important;
    border-spacing:0 !important;
    table-layout:fixed;
    width:max-content !important;
    min-width:max-content !important;
    margin:0 !important;
    box-shadow:none !important;
}

body.calendario-page .calendario-presenze-table th,
body.calendario-page .calendario-presenze-table td{
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    border-right:1px solid #d7e3ef;
    border-bottom:1px solid #d7e3ef;
    padding:6px 7px;
}

/* Riga giorni e riga numeri bloccate in alto */
body.calendario-page .calendario-presenze-table thead th{
    position:sticky !important;
    background:#073b63 !important;
    color:#fff !important;
    z-index:60;
    text-align:center;
    height:38px;
    box-shadow:0 2px 0 rgba(0,0,0,.12);
}

body.calendario-page .calendario-presenze-table thead tr:first-child th{
    top:0 !important;
}

body.calendario-page .calendario-presenze-table thead tr:nth-child(2) th{
    top:38px !important;
}

/* Colonna nominativi bloccata a sinistra */
body.calendario-page .calendario-presenze-table .dipendente-col{
    position:sticky !important;
    left:0 !important;
    z-index:70;
    width:240px !important;
    min-width:240px !important;
    max-width:240px !important;
    background:#ffffff !important;
    color:#073b63 !important;
    text-align:left;
    font-weight:800;
    box-shadow:4px 0 10px rgba(0,55,95,.12);
}

/* Angolo alto sinistro bloccato sia in alto sia a sinistra */
body.calendario-page .calendario-presenze-table thead .dipendente-col{
    top:0 !important;
    z-index:120 !important;
    height:76px;
    background:#052f4f !important;
    color:#fff !important;
    vertical-align:middle;
}

body.calendario-page .calendario-presenze-table tbody .dipendente-col{
    z-index:50;
}

body.calendario-page .calendario-presenze-table .giorno-col,
body.calendario-page .calendario-presenze-table .giorno-cell{
    width:74px !important;
    min-width:74px !important;
    max-width:74px !important;
    text-align:center;
}

body.calendario-page .calendario-presenze-table .totale-col{
    width:72px !important;
    min-width:72px !important;
    max-width:72px !important;
    text-align:center;
    background:#f8fbff !important;
    font-weight:800;
}

body.calendario-page .calendario-presenze-table thead .totale-col{
    background:#0a4b78 !important;
    color:#fff !important;
}

body.calendario-page .calendario-presenze-table select{
    width:62px !important;
    min-width:62px !important;
    max-width:62px !important;
    height:31px;
    padding:2px 3px;
    margin:0;
    font-size:10px;
    line-height:1;
    border-radius:8px;
    font-weight:800;
}

body.calendario-page .calendario-presenze-table tbody tr:hover td:not(.dipendente-col){
    background:#f7fbff;
}

body.calendario-page .calendario-presenze-table td.sabato,
body.calendario-page .calendario-presenze-table .sabato{
    background:#fff8e6 !important;
}

body.calendario-page .calendario-presenze-table td.domenica,
body.calendario-page .calendario-presenze-table .domenica{
    background:#ffecec !important;
}

body.calendario-page .calendario-presenze-table thead .sabato{
    background:#9a6512 !important;
    color:#fff !important;
}

body.calendario-page .calendario-presenze-table thead .domenica{
    background:#9f1239 !important;
    color:#fff !important;
}

body.calendario-page .calendar-save-bar{
    flex:0 0 auto;
    position:relative !important;
    bottom:auto !important;
    margin:10px 0 0;
    padding:10px 12px;
}

@media(max-width:900px){
    body.calendario-page .page-header{
        padding:10px 12px;
        flex-direction:row;
        text-align:left;
    }
    body.calendario-page .page-header h1{
        font-size:20px;
    }
    body.calendario-page .container.calendario-container{
        padding:8px 8px 0;
    }
    body.calendario-page .box{
        padding:9px 10px;
        margin-bottom:8px;
    }
    body.calendario-page .legenda-presenze{
        max-height:92px;
        overflow:auto;
    }
    body.calendario-page .calendario-presenze-table .dipendente-col{
        width:170px !important;
        min-width:170px !important;
        max-width:170px !important;
    }
    body.calendario-page .calendario-presenze-table .giorno-col,
    body.calendario-page .calendario-presenze-table .giorno-cell{
        width:68px !important;
        min-width:68px !important;
        max-width:68px !important;
    }
}


/* V13 calendario: versione definitiva blocca riquadri tipo Excel */
html, body.calendario-page{width:100%!important;height:100%!important;min-height:100%!important;margin:0!important;overflow:hidden!important;overscroll-behavior:none!important;}
body.calendario-page{position:fixed!important;inset:0!important;display:grid!important;grid-template-rows:auto 1fr!important;background:#edf5fb!important;}
body.calendario-page .page-header{grid-row:1!important;flex:0 0 auto!important;margin:0!important;padding:12px 22px!important;min-height:72px!important;box-sizing:border-box!important;z-index:20!important;}
body.calendario-page .container.calendario-container{grid-row:2!important;width:100%!important;max-width:none!important;height:100%!important;min-height:0!important;margin:0!important;padding:10px 14px 12px!important;box-sizing:border-box!important;overflow:hidden!important;display:grid!important;grid-template-rows:auto auto auto minmax(0,1fr)!important;gap:8px!important;}
body.calendario-page .container.calendario-container>.box{margin:0!important;padding:9px 12px!important;border-radius:12px!important;box-sizing:border-box!important;}
body.calendario-page .legenda-presenze{max-height:76px!important;overflow:auto!important;}
body.calendario-page .presenze-form{min-height:0!important;height:100%!important;overflow:hidden!important;display:grid!important;grid-template-rows:minmax(0,1fr) auto!important;gap:8px!important;margin:0!important;}
body.calendario-page .table-container.presenze-scroll.calendario-freeze-pane{height:100%!important;min-height:0!important;max-height:none!important;width:100%!important;max-width:100%!important;overflow:auto!important;overscroll-behavior:contain!important;-webkit-overflow-scrolling:touch!important;position:relative!important;contain:layout paint!important;border:2px solid #c9dceb!important;border-radius:14px!important;background:#fff!important;box-shadow:0 10px 28px rgba(0,55,95,.16)!important;}
body.calendario-page .calendario-presenze-table{border-collapse:separate!important;border-spacing:0!important;table-layout:fixed!important;width:max-content!important;min-width:max-content!important;margin:0!important;box-shadow:none!important;}
body.calendario-page .calendario-presenze-table th,body.calendario-page .calendario-presenze-table td{box-sizing:border-box!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important;border-right:1px solid #d6e3ee!important;border-bottom:1px solid #d6e3ee!important;padding:5px 6px!important;}
body.calendario-page .calendario-presenze-table thead th{position:sticky!important;z-index:500!important;background:#073b63!important;color:#fff!important;text-align:center!important;height:36px!important;min-height:36px!important;max-height:36px!important;line-height:1.1!important;box-shadow:0 2px 0 rgba(0,0,0,.16)!important;}
body.calendario-page .calendario-presenze-table thead tr.giorni-settimana-row th{top:0!important;}
body.calendario-page .calendario-presenze-table thead tr.giorni-numero-row th{top:36px!important;}
body.calendario-page .calendario-presenze-table .dipendente-col{position:sticky!important;left:0!important;width:245px!important;min-width:245px!important;max-width:245px!important;background:#fff!important;color:#073b63!important;font-weight:900!important;text-align:left!important;z-index:450!important;box-shadow:4px 0 10px rgba(0,55,95,.18)!important;}
body.calendario-page .calendario-presenze-table thead .dipendente-col{top:0!important;left:0!important;height:72px!important;min-height:72px!important;max-height:72px!important;vertical-align:middle!important;background:#052f4f!important;color:#fff!important;z-index:900!important;}
body.calendario-page .calendario-presenze-table tbody .dipendente-col{z-index:430!important;}
body.calendario-page .calendario-presenze-table .giorno-col,body.calendario-page .calendario-presenze-table .giorno-cell{width:76px!important;min-width:76px!important;max-width:76px!important;text-align:center!important;}
body.calendario-page .calendario-presenze-table .totale-col{width:76px!important;min-width:76px!important;max-width:76px!important;text-align:center!important;background:#f7fbff!important;font-weight:900!important;}
body.calendario-page .calendario-presenze-table thead .totale-col{position:sticky!important;top:0!important;height:72px!important;background:#0a4b78!important;color:#fff!important;z-index:520!important;}
body.calendario-page .calendario-presenze-table select{width:64px!important;min-width:64px!important;max-width:64px!important;height:30px!important;padding:1px 2px!important;margin:0!important;font-size:10px!important;line-height:1!important;border-radius:8px!important;font-weight:800!important;}
body.calendario-page .calendar-save-bar{grid-row:2!important;position:relative!important;bottom:auto!important;margin:0!important;padding:9px 12px!important;border-radius:12px!important;flex:0 0 auto!important;box-sizing:border-box!important;}
body.calendario-page .footer{display:none!important;}


/* V18 - correzione scroll pagina/riepilogo e calendario con scroll interno solo quando il mouse è sulla griglia */
html{
    height:auto !important;
    min-height:100% !important;
    overflow-y:auto !important;
    overflow-x:hidden !important;
}
body:not(.calendario-page){
    height:auto !important;
    min-height:100vh !important;
    overflow-y:auto !important;
    overflow-x:hidden !important;
    position:static !important;
}
body.calendario-page{
    height:auto !important;
    min-height:100vh !important;
    overflow-y:auto !important;
    overflow-x:hidden !important;
    position:static !important;
    inset:auto !important;
    display:block !important;
}
body.calendario-page .container.calendario-container{
    height:auto !important;
    min-height:0 !important;
    overflow:visible !important;
    display:block !important;
}
body.calendario-page .presenze-form,
body.calendario-page .presenze-form-v17{
    height:auto !important;
    min-height:0 !important;
    overflow:visible !important;
    display:block !important;
}
body.calendario-page .excel-calendar-shell{
    height:68vh !important;
    min-height:360px !important;
    max-height:760px !important;
    overflow:hidden !important;
}
body.calendario-page .excel-body{
    overflow:auto !important;
    overscroll-behavior:contain !important;
}
body.calendario-page .footer{display:none !important;}


/* V19 - scroll mouse corretto calendario + allineamento colonne bloccate */
html.calendario-v19-html,
body.calendario-page{
    overflow-y:auto !important;
    overflow-x:hidden !important;
    position:static !important;
}
body.calendario-page .excel-calendar-shell{
    overflow:hidden !important;
    touch-action:auto !important;
}
body.calendario-page .excel-body{
    overflow:auto !important;
    overscroll-behavior:contain !important;
    scrollbar-gutter:stable !important;
}
body.calendario-page .excel-top .excel-head-table,
body.calendario-page .excel-left .excel-left-table{
    will-change:transform !important;
    transform-origin:left top !important;
}
body.calendario-page .excel-left-table tbody tr,
body.calendario-page .excel-body-table tbody tr{
    height:var(--row-h) !important;
    min-height:var(--row-h) !important;
    max-height:var(--row-h) !important;
}
body.calendario-page .excel-left-table .excel-name-cell,
body.calendario-page .excel-body-table .excel-day-cell,
body.calendario-page .excel-body-table .excel-total-cell{
    height:var(--row-h) !important;
    min-height:var(--row-h) !important;
    max-height:var(--row-h) !important;
    padding-top:0 !important;
    padding-bottom:0 !important;
    vertical-align:middle !important;
    line-height:var(--row-h) !important;
}
body.calendario-page .excel-left-table .excel-name-cell{
    padding-left:12px !important;
    padding-right:10px !important;
}
body.calendario-page .excel-body-table .excel-day-cell,
body.calendario-page .excel-body-table .excel-total-cell{
    padding-left:4px !important;
    padding-right:4px !important;
}
body.calendario-page .excel-body-table .excel-day-cell select{
    display:block !important;
    margin:0 auto !important;
}
