:root{
    --brand:#1f4f86;
    --bg:#f4f6f9;
    --line:#dfe4ea;
    --text:#202938;
    --muted:#687385;
    font-family:Arial,Helvetica,sans-serif;
    color:var(--text);
    background:var(--bg);
}

*{box-sizing:border-box}

body{margin:0}

.topbar{
    background:#fff;
    border-bottom:1px solid var(--line);
    padding:15px 22px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:20px;
}

.brandwrap{
    display:flex;
    align-items:center;
    gap:14px;
}

.company-logo{
    max-height:54px;
    max-width:150px;
    object-fit:contain;
    flex:0 0 auto;
}

.brand,
.logo-title{
    font-size:1.35rem;
    font-weight:700;
}

.topbar small{
    color:var(--muted);
}

.userbox{
    font-size:.9rem;
}

.userbox a{
    color:var(--brand);
}

.nav{
    background:#263b59;
    padding:8px 18px;
    display:flex;
    gap:4px;
    align-items:center;
    flex-wrap:wrap;
}

.nav>a,
.dropbtn{
    color:#fff;
    text-decoration:none;
    padding:9px 11px;
    border-radius:5px;
    background:none;
    border:0;
    font:inherit;
    cursor:pointer;
}

.nav>a:hover,
.dropbtn:hover{
    background:#ffffff18;
}

.dropdown{
    position:relative;
}

.dropdown-content{
    display:none;
    position:absolute;
    z-index:10;
    background:white;
    min-width:235px;
    box-shadow:0 8px 25px #0003;
    border-radius:7px;
    padding:6px;
}

.dropdown-content a{
    display:block;
    padding:9px 11px;
    color:#263b59;
    text-decoration:none;
}

.dropdown-content a:hover{
    background:#eef3f8;
}

.dropdown:hover .dropdown-content{
    display:block;
}

.container{
    max-width:1280px;
    margin:24px auto;
    padding:0 18px;
}

footer{
    text-align:center;
    padding:35px;
    color:var(--muted);
}

.hero{
    background:white;
    border:1px solid var(--line);
    border-radius:12px;
    padding:24px;
    display:flex;
    justify-content:space-between;
    gap:20px;
    align-items:center;
}

.hero h1{
    margin:0 0 8px;
}

.hero-actions{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
}

.button,
button{
    display:inline-block;
    background:var(--button-primary,var(--brand));
    color:white;
    border:0;
    border-radius:7px;
    padding:10px 14px;
    text-decoration:none;
    font-weight:600;
    cursor:pointer;
}

.button.secondary,
button.secondary{
    background:var(--button-secondary,#5e6c7e);
}

.small{
    padding:6px 9px;
    font-size:.85rem;
}

.card{
    background:white;
    border:1px solid var(--line);
    border-radius:10px;
    padding:17px;
    margin-bottom:16px;
    box-shadow:0 2px 7px #00000009;
}

.stats{
    display:grid;
    grid-template-columns:repeat(4,1fr);
    gap:14px;
    margin:16px 0;
}

.stat b{
    font-size:2rem;
    display:block;
    color:var(--brand);
}

.stat span{
    color:var(--muted);
}

.two-cols{
    display:grid;
    grid-template-columns:minmax(0,1.7fr) minmax(300px,1fr);
    gap:18px;
}

.form-grid{
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
    gap:12px;
}

table{
    width:100%;
    border-collapse:collapse;
    background:white;
}

th,
td{
    padding:10px;
    border-bottom:1px solid var(--line);
    text-align:left;
    vertical-align:top;
}

th{
    background:#f7f9fb;
    font-size:.9rem;
}

label{
    display:block;
    font-weight:600;
    margin:10px 0;
}

input,
select,
textarea{
    width:100%;
    padding:9px 10px;
    border:1px solid #bcc6d1;
    border-radius:6px;
    margin-top:4px;
    font:inherit;
    background:white;
}

textarea{
    min-height:88px;
}

.filter{
    display:flex;
    gap:8px;
    align-items:end;
    margin-bottom:14px;
    flex-wrap:wrap;
}

.filter input,
.filter select{
    width:auto;
    min-width:200px;
}

.check-row{
    display:grid;
    grid-template-columns:2fr 260px 2fr;
    gap:12px;
    align-items:center;
    border-bottom:1px solid var(--line);
    padding:10px 0;
}

.check-buttons{
    display:flex;
    gap:10px;
}

.check-buttons label{
    display:flex;
    align-items:center;
    gap:4px;
    margin:0;
}

.check-buttons input{
    width:auto;
    margin:0;
}

.alert{
    padding:11px 13px;
    border-radius:7px;
    margin-bottom:13px;
}

.success{
    background:#e5f5eb;
    color:#18633a;
}

.danger{
    background:#fde8e8;
    color:#8b2020;
}

.muted{
    color:var(--muted);
    font-size:.9rem;
}

.news small{
    display:block;
    color:var(--muted);
    margin-top:3px;
}

.intervention-head{
    display:flex;
    justify-content:space-between;
    gap:20px;
}

.badge{
    background:#edf2f7;
    border-radius:999px;
    padding:6px 10px;
    height:max-content;
}

.auth{
    min-height:100vh;
    display:grid;
    place-items:center;
}

.authcard{
    width:min(430px,92vw);
}

#map{
    height:580px;
    border-radius:10px;
    border:1px solid var(--line);
}

/* LOGO SOCIETÀ */
.logo-preview{
    padding:12px;
    border:1px solid var(--line);
    background:#fff;
    border-radius:8px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    margin-bottom:10px;
    min-width:180px;
    min-height:90px;
}

.logo-preview img{
    max-height:100px;
    max-width:280px;
    object-fit:contain;
}

/* Miglioramento moduli upload CSV/logo */
input[type="file"]{
    padding:8px;
    background:#f8fafc;
}

/* Responsive */
@media(max-width:900px){
    .stats{
        grid-template-columns:repeat(2,1fr);
    }

    .two-cols{
        grid-template-columns:1fr;
    }

    .check-row{
        grid-template-columns:1fr;
    }

    .topbar{
        flex-direction:column;
        align-items:flex-start;
    }
}

@media(max-width:700px){
    .brandwrap{
        align-items:flex-start;
    }

    .company-logo{
        max-height:42px;
        max-width:110px;
    }
}

@media(max-width:520px){
    .stats{
        grid-template-columns:1fr;
    }

    .container{
        padding:0 10px;
    }

    .nav{
        padding:6px;
    }

    .hero{
        flex-direction:column;
        align-items:flex-start;
    }

    .hero-actions{
        width:100%;
    }

    .hero-actions .button{
        width:100%;
        text-align:center;
    }
}


/* =========================================================
   CHECKLIST GERARCHICA - MACROAREE v0.2.4
   ========================================================= */

.checklist-accordion{
    display:flex;
    flex-direction:column;
    gap:10px;
    margin-top:12px;
}

.macro-group{
    background:#fff;
    border:1px solid var(--line);
    border-radius:9px;
    overflow:hidden;
}

.macro-summary{
    display:grid;
    grid-template-columns:24px minmax(0,1fr) auto auto;
    gap:12px;
    align-items:center;
    min-height:58px;
    padding:10px 14px;
    cursor:pointer;
    list-style:none;
    background:#f8fafc;
    user-select:none;
}

.macro-summary::-webkit-details-marker{
    display:none;
}

.macro-summary:hover{
    background:#f2f5f8;
}

.macro-arrow{
    display:inline-block;
    transition:transform .15s ease;
    font-size:.85rem;
    color:var(--muted);
}

.macro-group[open] .macro-arrow{
    transform:rotate(90deg);
}

.macro-title{
    min-width:0;
    font-size:1.02rem;
    font-weight:700;
}

.macro-title small{
    display:block;
    margin-top:2px;
    font-size:.78rem;
    font-weight:400;
    color:var(--muted);
}

.macro-status{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:86px;
    min-height:30px;
    padding:5px 10px;
    border-radius:999px;
    font-size:.82rem;
    font-weight:700;
    white-space:nowrap;
}

.status-pending{
    background:#edf2f7;
    color:#566273;
}

.status-ok{
    background:#e5f5eb;
    color:#18633a;
}

.status-ko{
    background:#fde8e8;
    color:#8b2020;
}

.status-na{
    background:#eeeeee;
    color:#555;
}

.macro-ok-button{
    background:#1f6b42;
    padding:8px 12px;
    white-space:nowrap;
}

.macro-ok-button:hover{
    background:#185737;
}

.macro-children{
    padding:0 16px 8px 16px;
    border-top:1px solid var(--line);
}

.macro-children .check-row:last-child{
    border-bottom:0;
}

@media(max-width:760px){
    .macro-summary{
        grid-template-columns:20px minmax(0,1fr) auto;
    }

    .macro-ok-button{
        grid-column:2 / -1;
        width:100%;
    }

    .macro-status{
        min-width:64px;
    }
}


/* =========================================================
   MACROAREE - LAYOUT ORDINATO v0.2.5
   ========================================================= */

/* Elimina il triangolino nativo del browser: resta solo quello personalizzato */
.macro-summary{
    list-style:none !important;
    display:grid !important;
    grid-template-columns:24px minmax(0,1fr) 125px 125px !important;
    column-gap:14px !important;
    align-items:center !important;
    width:100% !important;
    min-height:62px !important;
    padding:10px 14px !important;
}

.macro-summary::-webkit-details-marker{
    display:none !important;
}

.macro-summary::marker{
    content:"" !important;
    display:none !important;
}

.macro-arrow{
    width:24px !important;
    text-align:center !important;
    justify-self:center !important;
}

.macro-title{
    display:flex !important;
    align-items:baseline !important;
    gap:8px !important;
    min-width:0 !important;
    overflow:hidden !important;
}

.macro-name{
    font-size:1rem !important;
    font-weight:700 !important;
    white-space:normal !important;
}

.macro-count{
    flex:0 0 auto !important;
    font-size:.78rem !important;
    font-weight:400 !important;
    color:var(--muted) !important;
    white-space:nowrap !important;
}
.immobili-map-legend{
    display:flex;
    flex-wrap:nowrap;
    align-items:center;
    gap:18px;
    white-space:nowrap;
}

.immobili-map-legend span{
    display:inline-flex;
    align-items:center;
    white-space:nowrap;
}

.macro-status{
    width:125px !important;
    min-width:125px !important;
    justify-self:stretch !important;
    text-align:center !important;
    display:flex !important;
    align-items:center !important;
    justify-content:center !important;
    min-height:34px !important;
    padding:5px 8px !important;
    border-radius:999px !important;
    font-size:.82rem !important;
    font-weight:700 !important;
    white-space:nowrap !important;
}

.macro-ok-button{
    width:125px !important;
    min-width:125px !important;
    justify-self:end !important;
    min-height:38px !important;
    padding:8px 10px !important;
    background:#1f6b42 !important;
    color:#fff !important;
    border-radius:7px !important;
    white-space:nowrap !important;
}

.macro-ok-button:hover{
    background:#185737 !important;
}

.status-pending{
    background:#edf2f7 !important;
    color:#566273 !important;
}

.status-ok{
    background:#e5f5eb !important;
    color:#18633a !important;
}

.status-ko{
    background:#fde8e8 !important;
    color:#8b2020 !important;
}

.status-na{
    background:#eeeeee !important;
    color:#555 !important;
}

@media(max-width:800px){
    .macro-summary{
        grid-template-columns:22px minmax(0,1fr) 95px !important;
    }

    .macro-status{
        width:95px !important;
        min-width:95px !important;
    }

    .macro-ok-button{
        grid-column:2 / -1 !important;
        width:100% !important;
        min-width:0 !important;
        justify-self:stretch !important;
    }

    .macro-title{
        flex-direction:column !important;
        align-items:flex-start !important;
        gap:1px !important;
    }
}


/* =========================================================
   ARCHIVIO - ELIMINAZIONE ISPEZIONE v0.2.9
   ========================================================= */
.archive-delete-col{
    width:72px;
    text-align:center;
}

.delete-inspection-form{
    margin:0;
    display:inline-block;
}

.trash-button{
    width:38px;
    min-width:38px;
    height:38px;
    padding:0;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    background:#fff;
    color:#a32626;
    border:1px solid #d9bcbc;
    border-radius:7px;
    font-size:1.05rem;
    cursor:pointer;
}

.trash-button:hover{
    background:#fde8e8;
    border-color:#c98787;
}

.trash-button:focus{
    outline:2px solid #a32626;
    outline-offset:2px;
}


/* =========================================================
   FOTO SU NON CONFORMITÀ v0.2.12
   ========================================================= */
.check-note-photo{
    display:flex;
    flex-direction:column;
    gap:7px;
    min-width:0;
}

.photo-upload-row{
    display:flex;
    align-items:center;
    gap:10px;
    flex-wrap:wrap;
}

.photo-upload-label{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:auto;
    min-height:36px;
    margin:0;
    padding:7px 11px;
    border:1px solid #bcc6d1;
    border-radius:6px;
    background:#f8fafc;
    color:#263b59;
    font-size:.86rem;
    font-weight:700;
    cursor:pointer;
}

.photo-upload-label:hover{
    background:#eef3f8;
}

.photo-upload-label input[type="file"]{
    position:absolute;
    width:1px;
    height:1px;
    overflow:hidden;
    clip:rect(0,0,0,0);
    white-space:nowrap;
    clip-path:inset(50%);
}

.photo-count{
    color:var(--muted);
    font-size:.82rem;
}

@media(max-width:760px){
    .photo-upload-label{
        min-height:44px;
        padding:10px 12px;
    }
}


/* =========================================================
   ARCHIVIO - FILTRI E ORDINAMENTO v0.2.17
   ========================================================= */

.archive-filter-banner{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:14px;
    flex-wrap:wrap;
    background:#eef4fb;
    border:1px solid #cddbec;
    border-radius:8px;
    padding:11px 13px;
    margin-bottom:14px;
}

.archive-clear-filter{
    margin-left:auto;
}

.archive-table-wrap{
    width:100%;
    overflow-x:auto;
}

.archive-table{
    min-width:850px;
}

.archive-sort-link{
    display:inline-flex;
    align-items:center;
    gap:6px;
    color:inherit;
    text-decoration:none;
    font-weight:700;
    white-space:nowrap;
}

.archive-sort-link:hover{
    color:var(--brand);
    text-decoration:underline;
}

.archive-sort-link span{
    color:var(--muted);
    font-size:.8rem;
}

.archive-address{
    display:block;
    margin-top:3px;
    color:var(--muted);
    font-weight:400;
}

.archive-nc-count{
    text-align:center;
    font-weight:700;
}

.archive-empty{
    text-align:center;
    color:var(--muted);
    padding:24px !important;
}

@media(max-width:700px){
    .archive-filter-banner{
        align-items:stretch;
    }

    .archive-clear-filter{
        width:100%;
        margin-left:0;
        text-align:center;
    }
}


/* =========================================================
   INTERVENTI - ELENCO SINTETICO E SCHEDA v0.2.18
   ========================================================= */

.interventi-list{
    display:flex;
    flex-direction:column;
    gap:0;
    border:1px solid var(--line);
    border-radius:10px;
    overflow:hidden;
    background:#fff;
}

.interventi-list-head,
.intervento-list-row{
    display:grid;
    grid-template-columns:minmax(280px,1.5fr) minmax(250px,1.4fr) 130px 130px;
    gap:16px;
    align-items:center;
    padding:12px 15px;
}

.interventi-list-head{
    background:#eef2f6;
    font-weight:700;
    font-size:.9rem;
}

.intervento-list-row{
    border-top:1px solid var(--line);
    min-height:68px;
}

.intervento-list-row:hover{
    background:#f8fafc;
}

.intervento-list-property{
    min-width:0;
}

.intervento-property-link{
    display:inline-block;
    color:var(--brand);
    font-size:1rem;
    font-weight:700;
    text-decoration:none;
}

.intervento-property-link:hover{
    text-decoration:underline;
}

.intervento-list-property small,
.intervento-control-preview{
    display:block;
    margin-top:3px;
    color:var(--muted);
    font-size:.82rem;
    font-weight:400;
}

.intervento-priority{
    font-weight:700;
}

.interventi-empty{
    margin:0;
    border:0;
    border-radius:0;
    box-shadow:none;
    color:var(--muted);
}

.intervento-detail-top{
    display:flex;
    align-items:flex-end;
    justify-content:space-between;
    gap:20px;
    margin-bottom:14px;
}

.intervento-detail-top h1{
    margin:7px 0 0;
}

.intervento-back{
    color:var(--brand);
    text-decoration:none;
    font-weight:600;
}

.intervento-back:hover{
    text-decoration:underline;
}

.intervento-property-title{
    font-size:1.35rem;
    font-weight:700;
}

.intervento-property-meta{
    color:var(--muted);
    margin-top:4px;
}

.intervento-detail-grid{
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:12px;
    margin:18px 0;
}

.intervento-detail-box{
    background:#f7f9fb;
    border:1px solid var(--line);
    border-radius:8px;
    padding:11px;
    min-width:0;
}

.intervento-detail-box strong,
.intervento-detail-box small{
    display:block;
}

.intervento-detail-label{
    display:block;
    color:var(--muted);
    font-size:.78rem;
    margin-bottom:5px;
}

.intervento-description{
    margin:18px 0;
    padding:14px;
    border-left:4px solid var(--brand);
    background:#f8fafc;
    border-radius:5px;
}

.intervento-description h3{
    margin-top:0;
}

.intervento-photo-section{
    margin:18px 0;
}

.intervento-photo-grid{
    display:grid;
    grid-template-columns:repeat(auto-fill,minmax(180px,1fr));
    gap:10px;
}

.intervento-photo{
    display:block;
    border:1px solid var(--line);
    border-radius:8px;
    padding:5px;
    background:#fff;
}

.intervento-photo img{
    display:block;
    width:100%;
    height:160px;
    object-fit:cover;
    border-radius:5px;
}

.intervento-readonly{
    border-top:1px solid var(--line);
    padding-top:12px;
}

@media(max-width:900px){
    .interventi-list-head{
        display:none;
    }

    .intervento-list-row{
        grid-template-columns:1fr 1fr;
    }

    .intervento-detail-grid{
        grid-template-columns:repeat(2,minmax(0,1fr));
    }
}

@media(max-width:560px){
    .intervento-list-row{
        grid-template-columns:1fr;
    }

    .intervento-detail-top{
        align-items:flex-start;
        flex-direction:column;
    }

    .intervento-detail-grid{
        grid-template-columns:1fr;
    }
}


/* =========================================================
   ARCHIVIO ISPEZIONI + MAPPA v0.2.19
   ========================================================= */
.archive-layout{
    display:grid;
    grid-template-columns:minmax(330px,.85fr) minmax(0,1.65fr);
    gap:18px;
    align-items:start;
}

.archive-map-panel{
    min-width:0;
    background:#fff;
    border:1px solid var(--line);
    border-radius:10px;
    padding:12px;
    position:sticky;
    top:14px;
}

.archive-map-title{
    font-size:1rem;
    font-weight:700;
    margin-bottom:8px;
}

.archive-map-legend{
    display:flex;
    gap:12px;
    flex-wrap:wrap;
    margin-bottom:9px;
    color:var(--muted);
    font-size:.8rem;
}

.archive-map-legend span{
    display:inline-flex;
    align-items:center;
    gap:6px;
}

.archive-pin-dot{
    width:12px;
    height:12px;
    border-radius:50%;
    display:inline-block;
}

.archive-pin-blue{background:#2563eb;}
.archive-pin-red{background:#dc2626;}

#archiveMap{
    width:100%;
    height:520px;
    border:1px solid var(--line);
    border-radius:8px;
}

.archive-map-empty{
    padding:22px 12px;
    background:#f7f9fb;
    border-radius:7px;
    color:var(--muted);
}

.archive-list-panel{
    min-width:0;
}

/* Puntatori Leaflet colorati */
.map-pin{
    position:relative;
    display:inline-block;
    width:20px;
    height:20px;
    border-radius:50% 50% 50% 0;
    transform:rotate(-45deg);
    border:2px solid #fff;
    box-shadow:0 1px 4px rgba(0,0,0,.35);
    box-sizing:border-box;
}

.map-pin::after{
    content:'';
    position:absolute;
    width:7px;
    height:7px;
    border-radius:50%;
    background:#fff;
    top:4px;
    left:4px;
}

.pin-blue{background:#2563eb;}
.pin-red{background:#dc2626;}
.leaflet-div-icon.custom-pin-icon{background:transparent;border:none;}

@media(max-width:1050px){
    .archive-layout{
        grid-template-columns:1fr;
    }

    .archive-map-panel{
        position:static;
    }

    #archiveMap{
        height:380px;
    }
}


/* =========================================================
   ARCHIVIO ISPEZIONI - LAYOUT AMPIO v0.2.20
   ========================================================= */

/* In Archivio sfrutta maggiormente la larghezza dello schermo */
.container:has(.archive-layout){
    max-width:1560px;
}

.archive-layout{
    grid-template-columns:minmax(470px,46%) minmax(0,54%) !important;
    gap:22px !important;
}

.archive-map-panel{
    padding:14px !important;
}

#archiveMap{
    height:620px !important;
}

/* La tabella deve stare tutta nel pannello, senza scrollbar orizzontale */
.archive-table-wrap{
    width:100% !important;
    overflow-x:visible !important;
}

.archive-table{
    width:100% !important;
    min-width:0 !important;
    table-layout:fixed !important;
    font-size:.88rem;
}

.archive-table th,
.archive-table td{
    white-space:normal !important;
    overflow-wrap:anywhere;
    word-break:normal;
    padding:9px 8px !important;
}

/* Larghezze studiate per mantenere visibili tutte le colonne */
.archive-table th:nth-child(1),
.archive-table td:nth-child(1){
    width:112px;
}

.archive-table th:nth-child(2),
.archive-table td:nth-child(2){
    width:140px;
}

.archive-table th:nth-child(3),
.archive-table td:nth-child(3){
    width:auto;
}

.archive-table th:nth-child(4),
.archive-table td:nth-child(4){
    width:115px;
}

.archive-table th:nth-child(5),
.archive-table td:nth-child(5){
    width:62px;
    text-align:center;
}

.archive-table th:nth-child(6),
.archive-table td:nth-child(6){
    width:92px;
}

.archive-table th:nth-child(7),
.archive-table td:nth-child(7){
    width:68px;
    text-align:center;
}

.archive-sort-link{
    white-space:normal !important;
}

.archive-address{
    line-height:1.25;
}

@media(max-width:1250px){
    .container:has(.archive-layout){
        max-width:100%;
    }

    .archive-layout{
        grid-template-columns:minmax(400px,44%) minmax(0,56%) !important;
        gap:16px !important;
    }

    #archiveMap{
        height:540px !important;
    }

    .archive-table{
        font-size:.82rem;
    }

    .archive-table th,
    .archive-table td{
        padding:8px 6px !important;
    }
}

@media(max-width:1050px){
    .archive-layout{
        grid-template-columns:1fr !important;
    }

    #archiveMap{
        height:440px !important;
    }

    .archive-table-wrap{
        overflow-x:auto !important;
    }

    .archive-table{
        min-width:760px !important;
        table-layout:auto !important;
    }
}


/* --- Home cards con icone --- */
.stat{
    min-height:112px;
}

.stat-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
}

.stat-icon{
    position:relative;
    width:54px;
    height:54px;
    flex:0 0 54px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:14px;
    background:#eef4fb;
    box-shadow:inset 0 0 0 1px #d5e2f1;
}

.stat-emoji{
    font-size:1.8rem;
    line-height:1;
}

.stat-icon.icon-home .stat-emoji,
.stat-icon.icon-tech .stat-emoji,
.stat-icon.icon-search .stat-emoji,
.stat-icon.icon-glasses .stat-emoji,
.stat-icon.icon-glasses-check .stat-emoji,
.stat-icon.icon-glasses-bell .stat-emoji{
    transform:translateY(1px);
}

.stat-overlay{
    position:absolute;
    right:-4px;
    bottom:-4px;
    min-width:22px;
    height:22px;
    padding:0 4px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:999px;
    font-size:.82rem;
    font-weight:800;
    color:#fff;
    box-shadow:0 2px 6px rgba(0,0,0,.16);
    border:2px solid #fff;
}

.stat-overlay-check{
    background:#1f8b4c;
}

.stat-overlay-bell{
    background:#c93333;
    font-size:.78rem;
    animation:bell-swing 1.8s ease-in-out infinite;
    transform-origin:top center;
}

@keyframes bell-swing{
    0%,100%{ transform:rotate(0deg); }
    20%{ transform:rotate(10deg); }
    40%{ transform:rotate(-10deg); }
    60%{ transform:rotate(7deg); }
    80%{ transform:rotate(-7deg); }
}

@media (max-width:700px){
    .stat{
        min-height:auto;
    }
    .stat-icon{
        width:48px;
        height:48px;
        flex-basis:48px;
    }
    .stat-emoji{
        font-size:1.55rem;
    }
}


/* =========================================================
   HOME - 6 SCHEDE DINAMICHE 3+3 v0.2.22
   ========================================================= */
.stats{
    grid-template-columns:repeat(3,minmax(0,1fr)) !important;
}

.stat-link{
    color:inherit;
    text-decoration:none;
    cursor:pointer;
    transition:transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}

.stat-link:visited{
    color:inherit;
}

.stat-link:hover{
    transform:translateY(-2px);
    border-color:#b9c9da;
    box-shadow:0 5px 14px rgba(31,79,134,.10);
}

.stat-link:focus-visible{
    outline:3px solid rgba(31,79,134,.28);
    outline-offset:2px;
}

@media(max-width:850px){
    .stats{
        grid-template-columns:repeat(2,minmax(0,1fr)) !important;
    }
}

@media(max-width:520px){
    .stats{
        grid-template-columns:1fr !important;
    }
}


/* =========================================================
   ANOMALIE / INTERVENTI - MAPPA + ELENCO v0.2.23
   ========================================================= */

.interventi-map-layout{
    display:grid;
    grid-template-columns:minmax(360px,42%) minmax(0,58%);
    gap:18px;
    align-items:start;
    margin-top:14px;
}

.interventi-map-card{
    margin:0;
    padding:12px;
}

.interventi-map-title{
    display:flex;
    align-items:baseline;
    justify-content:space-between;
    gap:10px;
    margin-bottom:9px;
}

.interventi-map-title small{
    color:var(--muted);
    white-space:nowrap;
}

#interventiMap{
    height:590px;
    width:100%;
    border:1px solid var(--line);
    border-radius:8px;
    overflow:hidden;
}

.interventi-list-panel{
    min-width:0;
}

.interventi-list-panel .interventi-list{
    width:100%;
}

.nc-map-div-icon{
    background:transparent !important;
    border:0 !important;
}

.nc-map-pin{
    position:relative;
    display:block;
    width:24px;
    height:24px;
    border-radius:50% 50% 50% 0;
    transform:rotate(-45deg);
    background:#dc2626;
    border:2px solid #fff;
    box-shadow:0 2px 6px rgba(0,0,0,.38);
}

.nc-map-pin::after{
    content:"";
    position:absolute;
    width:8px;
    height:8px;
    border-radius:50%;
    background:#fff;
    left:6px;
    top:6px;
}

.nc-map-popup{
    min-width:220px;
    max-width:310px;
}

.nc-popup-property{
    display:block;
    font-size:1rem;
    margin-bottom:3px;
}

.nc-popup-count{
    margin:7px 0;
    font-weight:700;
    color:#b42323;
}

.nc-popup-intervento{
    display:block;
    padding:7px 0;
    border-top:1px solid #e2e6eb;
    color:#1f4f86;
    text-decoration:none;
}

.nc-popup-intervento:hover{
    text-decoration:underline;
}

.nc-popup-intervento small,
.nc-popup-control{
    display:block;
    color:#687385;
    font-size:.78rem;
    margin-top:2px;
}

@media(max-width:980px){
    .interventi-map-layout{
        grid-template-columns:1fr;
    }

    #interventiMap{
        height:430px;
    }
}


/* =========================================================
   FORNITORI - FILTRO, MODIFICA, AREA INTERVENTO v0.2.24
   ========================================================= */

.supplier-toolbar{
    margin-bottom:14px;
}

.supplier-filter{
    align-items:end;
}

.supplier-filter label{
    min-width:260px;
}

.supplier-layout{
    grid-template-columns:minmax(0,1.75fr) minmax(360px,.9fr);
}

.supplier-table{
    width:100%;
}

.supplier-actions{
    width:95px;
    text-align:right;
}

.button.small{
    padding:6px 9px;
    font-size:.82rem;
}

.form-actions{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    margin-top:10px;
}

@media(max-width:950px){
    .supplier-layout{
        grid-template-columns:1fr;
    }
}


/* =========================================================
   COMUNICAZIONI - MODIFICA v0.2.25
   ========================================================= */

.communication-card-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
}

.communication-card-head small{
    display:block;
    margin-top:3px;
    color:var(--muted);
}

.communication-card .button.small{
    flex:0 0 auto;
}


/* =========================================================
   PROGRAMMAZIONE INTERVENTO + METEO v0.2.26
   ========================================================= */

.intervento-detail-grid{
    grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
}

.weather-planning-grid{
    display:grid;
    grid-template-columns:minmax(240px,.75fr) minmax(420px,1.5fr);
    gap:16px;
    align-items:start;
    margin:18px 0;
}

.weather-planning-grid > label{
    margin:0;
}

.weather-card{
    border:1px solid var(--line);
    border-radius:10px;
    background:#f8fafc;
    padding:13px 14px;
    min-height:126px;
}

.weather-card-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    margin-bottom:11px;
}

.weather-card-head small{
    display:block;
    color:var(--muted);
    margin-top:2px;
}

.weather-status{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:94px;
    min-height:30px;
    padding:5px 9px;
    border-radius:999px;
    font-size:.78rem;
    font-weight:700;
    white-space:nowrap;
}

.weather-neutral{
    background:#e9edf2;
    color:#586474;
}

.weather-good{
    background:#e3f4e9;
    color:#176238;
}

.weather-warning{
    background:#fff3cd;
    color:#795a00;
}

.weather-bad{
    background:#fde6e6;
    color:#972323;
}

.weather-content{
    color:#384454;
}

.weather-main{
    display:flex;
    align-items:center;
    gap:11px;
    margin-bottom:11px;
}

.weather-main strong,
.weather-main small{
    display:block;
}

.weather-main small{
    margin-top:3px;
    color:var(--muted);
}

.weather-icon{
    font-size:2rem;
    line-height:1;
}

.weather-values{
    display:grid;
    grid-template-columns:repeat(5,minmax(95px,1fr));
    gap:7px;
}

.weather-values > div{
    background:#fff;
    border:1px solid #e0e5eb;
    border-radius:7px;
    padding:7px 8px;
}

.weather-values span,
.weather-values strong{
    display:block;
}

.weather-values span{
    color:var(--muted);
    font-size:.72rem;
    margin-bottom:2px;
}

.weather-values strong{
    font-size:.88rem;
}

.weather-source{
    margin-top:9px;
    color:var(--muted);
    font-size:.72rem;
}

@media(max-width:950px){
    .weather-planning-grid{
        grid-template-columns:1fr;
    }

    .weather-values{
        grid-template-columns:repeat(2,minmax(110px,1fr));
    }
}

@media(max-width:520px){
    .weather-values{
        grid-template-columns:1fr;
    }

    .weather-card-head{
        flex-direction:column;
    }
}


/* =========================================================
   NUOVA ISPEZIONE PROGRAMMATA + METEO v0.2.27
   ========================================================= */

.field-help{
    display:block;
    margin-top:4px;
    color:var(--muted);
    font-size:.76rem;
}

.inspection-weather-card{
    margin:14px 0 18px;
    padding:14px 16px;
    border:1px solid var(--line);
    border-radius:10px;
    background:#f8fafc;
}

.inspection-weather-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    margin-bottom:10px;
}

.inspection-weather-head small{
    display:block;
    margin-top:3px;
    color:var(--muted);
}

.inspection-weather-content{
    color:#384454;
}

.inspection-weather-summary{
    display:flex;
    align-items:center;
    gap:10px;
    margin-bottom:10px;
}

.inspection-weather-summary strong,
.inspection-weather-summary small{
    display:block;
}

.inspection-weather-summary small{
    margin-top:2px;
    color:var(--muted);
}

.inspection-weather-values{
    display:grid;
    grid-template-columns:repeat(5,minmax(105px,1fr));
    gap:7px;
}

.inspection-weather-values > div{
    padding:7px 8px;
    background:#fff;
    border:1px solid #e0e5eb;
    border-radius:7px;
}

.inspection-weather-values span,
.inspection-weather-values strong{
    display:block;
}

.inspection-weather-values span{
    margin-bottom:2px;
    color:var(--muted);
    font-size:.72rem;
}

.inspection-weather-values strong{
    font-size:.88rem;
}

@media(max-width:850px){
    .inspection-weather-values{
        grid-template-columns:repeat(2,minmax(110px,1fr));
    }
}

@media(max-width:520px){
    .inspection-weather-head{
        flex-direction:column;
    }

    .inspection-weather-values{
        grid-template-columns:1fr;
    }
}


/* =========================================================
   ISPEZIONI PROGRAMMATE v0.2.28
   ========================================================= */

.page-title-actions{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:14px;
    margin-bottom:16px;
}

.page-title-actions h1{
    margin-bottom:3px;
}

.scheduled-inspections-table td small{
    display:block;
    margin-top:3px;
    color:var(--muted);
}

.scheduled-actions{
    display:flex;
    flex-wrap:wrap;
    gap:6px;
    align-items:center;
}

.scheduled-actions form{
    margin:0;
}

.scheduled-save-card{
    margin:14px 0 18px;
}

.scheduled-save-grid{
    display:grid;
    grid-template-columns:minmax(280px,1.4fr) minmax(220px,.6fr);
    gap:16px;
    align-items:end;
}

.scheduled-save-grid label{
    margin:0;
}

.scheduled-save-actions{
    display:flex;
    flex-direction:column;
    align-items:flex-start;
    gap:5px;
}

.scheduled-save-actions small{
    color:var(--muted);
    line-height:1.25;
}

@media(max-width:760px){
    .page-title-actions{
        flex-direction:column;
    }

    .scheduled-save-grid{
        grid-template-columns:1fr;
    }
}


/* =========================================================
   MACROAREA - COMANDO N/A v2.30
   ========================================================= */

.macro-summary{
    grid-template-columns:24px minmax(0,1fr) 125px 92px 125px !important;
}

.macro-na-button{
    width:92px !important;
    min-width:92px !important;
    justify-self:end !important;
    min-height:38px !important;
    padding:8px 10px !important;
    background:#697586 !important;
    color:#fff !important;
    border:0 !important;
    border-radius:7px !important;
    font-weight:700 !important;
    white-space:nowrap !important;
    cursor:pointer !important;
}

.macro-na-button:hover{
    background:#556171 !important;
}

@media(max-width:900px){
    .macro-summary{
        grid-template-columns:24px minmax(0,1fr) auto auto !important;
    }

    .macro-na-button,
    .macro-ok-button{
        width:auto !important;
        min-width:92px !important;
    }

    .macro-ok-button{
        grid-column:auto !important;
    }
}

@media(max-width:650px){
    .macro-summary{
        grid-template-columns:24px minmax(0,1fr) auto !important;
    }

    .macro-na-button{
        grid-column:2 / 3 !important;
        width:100% !important;
        min-width:0 !important;
    }

    .macro-ok-button{
        grid-column:3 / 4 !important;
        width:100% !important;
        min-width:0 !important;
    }
}


/* =========================================================
   MACROAREA - RESET v2.31
   ========================================================= */

.macro-summary{
    grid-template-columns:24px minmax(0,1fr) 125px 82px 82px 125px !important;
}

.macro-reset-button{
    width:82px !important;
    min-width:82px !important;
    justify-self:end !important;
    min-height:38px !important;
    padding:8px 10px !important;
    background:#eef1f4 !important;
    color:#334155 !important;
    border:1px solid #cbd5e1 !important;
    border-radius:7px !important;
    font-weight:700 !important;
    white-space:nowrap !important;
    cursor:pointer !important;
}

.macro-reset-button:hover{
    background:#e2e8f0 !important;
}

@media(max-width:1050px){
    .macro-summary{
        grid-template-columns:24px minmax(0,1fr) 115px auto auto auto !important;
    }

    .macro-reset-button,
    .macro-na-button,
    .macro-ok-button{
        width:auto !important;
        min-width:78px !important;
    }
}

@media(max-width:760px){
    .macro-summary{
        grid-template-columns:24px minmax(0,1fr) auto auto !important;
    }

    .macro-status{
        grid-column:3 / 5 !important;
    }

    .macro-reset-button{
        grid-column:2 / 3 !important;
        width:100% !important;
        min-width:0 !important;
    }

    .macro-na-button{
        grid-column:3 / 4 !important;
        width:100% !important;
        min-width:0 !important;
    }

    .macro-ok-button{
        grid-column:4 / 5 !important;
        width:100% !important;
        min-width:0 !important;
    }
}


/* =========================================================
   GESTIONE UTENTI - ELIMINAZIONE v2.33
   ========================================================= */

.user-actions{
    display:flex;
    flex-wrap:wrap;
    gap:6px;
    align-items:center;
}

.user-actions form{
    margin:0;
}

button.danger,
.button.danger{
    background:#b42318;
    color:#fff;
    border-color:#b42318;
}

button.danger:hover,
.button.danger:hover{
    background:#912018;
    border-color:#912018;
}


/* =========================================================
   TECNICI - ELIMINAZIONE v2.35
   ========================================================= */

.technician-actions{
    display:flex;
    align-items:center;
    gap:6px;
}

.technician-actions form{
    margin:0;
}


/* =========================================================
   RESTYLING GRAFICO v2.36
   Linea: tecnica · istituzionale · contemporanea
   ========================================================= */

:root{
    --brand:#1f3a5f;
    --brand-2:#2f5d8c;
    --brand-soft:#e9f0f7;
    --bg:#f3f6fa;
    --surface:#ffffff;
    --surface-soft:#f8fafc;
    --line:#dfe6ee;
    --text:#1f2937;
    --muted:#6b7280;
    --ok:#2e7d4f;
    --danger:#c0392b;
    --warning:#d89b1d;
    font-family:Inter,Arial,Helvetica,sans-serif;
}

html{
    background:#eef3f8;
}

body{
    min-height:100vh;
    color:var(--text);
    background:
        radial-gradient(circle at 8% 0%, rgba(47,93,140,.08), transparent 30rem),
        linear-gradient(180deg,#f8fafc 0%,#f2f6fa 48%,#edf3f8 100%);
    background-attachment:fixed;
}

/* HEADER */
.topbar{
    background:rgba(255,255,255,.97);
    border-bottom:1px solid #e2e8f0;
    padding:16px 24px;
    box-shadow:0 2px 10px rgba(31,58,95,.045);
}

.brand,
.logo-title{
    color:var(--brand);
    letter-spacing:-.015em;
}

.userbox{
    padding:8px 10px;
    border-radius:9px;
    background:#f6f8fb;
    border:1px solid #e7ebf0;
}

.nav{
    background:linear-gradient(90deg,#1f3a5f 0%,#294c75 100%);
    padding:8px 20px;
    gap:3px;
    box-shadow:0 4px 14px rgba(31,58,95,.13);
}

.nav>a,
.dropbtn{
    border-radius:7px;
    padding:9px 12px;
    transition:background .16s ease, transform .16s ease;
}

.nav>a:hover,
.dropbtn:hover{
    background:rgba(255,255,255,.13);
}

.dropdown-content{
    border:1px solid #e1e7ee;
    box-shadow:0 12px 34px rgba(31,58,95,.16);
    border-radius:10px;
    padding:7px;
}

.dropdown-content a{
    border-radius:7px;
}

.dropdown-content a:hover{
    background:#edf3f8;
    color:var(--brand);
}

/* LAYOUT */
.container{
    max-width:1320px;
    margin:26px auto 34px;
    padding:0 22px;
}

h1,h2,h3{
    color:#233c5d;
    letter-spacing:-.015em;
}

h1{
    font-size:1.75rem;
}

h2{
    font-size:1.22rem;
}

/* HERO */
.hero{
    position:relative;
    overflow:hidden;
    border:1px solid #dce5ef;
    border-radius:16px;
    padding:28px 30px;
    background:
        linear-gradient(120deg,rgba(255,255,255,.98),rgba(246,250,253,.96));
    box-shadow:0 8px 28px rgba(31,58,95,.07);
}

.hero::after{
    content:"";
    position:absolute;
    width:220px;
    height:220px;
    border-radius:50%;
    right:-90px;
    top:-120px;
    background:rgba(47,93,140,.08);
    pointer-events:none;
}

.hero h1{
    color:var(--brand);
    font-size:1.9rem;
}

.hero p{
    color:#64748b;
    max-width:720px;
}

/* BUTTONS */
.button,
button{
    background:linear-gradient(180deg,#315f91,#274f7b);
    border:1px solid #274f7b;
    border-radius:8px;
    padding:10px 14px;
    box-shadow:0 2px 5px rgba(31,58,95,.10);
    transition:transform .12s ease, box-shadow .12s ease, filter .12s ease;
}

.button:hover,
button:hover{
    transform:translateY(-1px);
    box-shadow:0 5px 12px rgba(31,58,95,.14);
    filter:brightness(1.03);
}

.button.secondary{
    background:#f5f7fa;
    color:#40546d;
    border:1px solid #cfd8e3;
    box-shadow:none;
}

.button.secondary:hover{
    background:#edf2f7;
}

button.danger,
.button.danger{
    background:#b9382e;
    border-color:#a93229;
    color:#fff;
}

/* CARDS */
.card{
    background:rgba(255,255,255,.98);
    border:1px solid #dfe6ee;
    border-radius:14px;
    padding:19px;
    margin-bottom:18px;
    box-shadow:0 5px 18px rgba(31,58,95,.055);
}

.card:hover{
    border-color:#d5dfe9;
}

/* HOME STATS */
.stats{
    grid-template-columns:repeat(3,1fr);
    gap:16px;
    margin:18px 0;
}

.stat{
    position:relative;
    min-height:118px;
    border-top:3px solid #d9e6f2;
}

.stat-link{
    text-decoration:none;
    color:inherit;
    transition:transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.stat-link:hover{
    transform:translateY(-3px);
    border-color:#8fb0cf;
    box-shadow:0 10px 24px rgba(31,58,95,.10);
}

.stat b{
    color:var(--brand);
    font-size:2.15rem;
}

.stat span{
    color:#64748b;
}

/* TABLES */
table{
    border:1px solid #e1e7ee;
    border-radius:10px;
    overflow:hidden;
    box-shadow:0 2px 8px rgba(31,58,95,.035);
}

th{
    background:#edf3f8;
    color:#314b68;
    font-size:.84rem;
    font-weight:700;
    text-transform:none;
}

th,td{
    padding:11px 12px;
    border-bottom:1px solid #e8edf2;
}

tbody tr:nth-child(even){
    background:#fbfcfd;
}

tbody tr:hover{
    background:#f2f7fb;
}

/* FORMS */
label{
    color:#334155;
}

input,
select,
textarea{
    border:1px solid #cbd5e1;
    border-radius:8px;
    background:#fff;
    transition:border-color .15s ease,box-shadow .15s ease;
}

input:focus,
select:focus,
textarea:focus{
    outline:none;
    border-color:#6f98be;
    box-shadow:0 0 0 3px rgba(47,93,140,.12);
}

input[type="file"]{
    background:#f8fafc;
}

/* ALERTS / BADGES */
.alert{
    border:1px solid transparent;
    border-radius:9px;
}

.success{
    background:#e8f5ee;
    color:#21643f;
    border-color:#cce8d7;
}

.danger{
    background:#fcebea;
    color:#8f2d25;
    border-color:#f3cfcb;
}

.badge{
    background:#edf3f8;
    color:#40566f;
    border:1px solid #dde6ef;
}

/* CHECKLIST */
.checklist-accordion{
    gap:12px;
}

.macro-group{
    border:1px solid #dce5ee;
    border-radius:12px;
    box-shadow:0 3px 12px rgba(31,58,95,.045);
}

.macro-summary{
    background:linear-gradient(180deg,#fbfcfd,#f4f7fa) !important;
    min-height:66px !important;
}

.macro-summary:hover{
    background:#eef4f8 !important;
}

.macro-group[open] .macro-summary{
    background:#edf3f8 !important;
    box-shadow:inset 4px 0 0 #6f98be;
}

.macro-title,
.macro-name{
    color:#293f5a;
}

.macro-children{
    background:#fff;
    padding:2px 18px 10px 18px;
}

.check-row{
    padding:13px 2px;
}

.status-pending{
    background:#edf1f5 !important;
    color:#5b6776 !important;
}

.status-ok{
    background:#e4f3e9 !important;
    color:#246b43 !important;
}

.status-ko{
    background:#fbe8e6 !important;
    color:#982f27 !important;
}

.status-na{
    background:#e8edf2 !important;
    color:#4f5d6b !important;
}

.macro-ok-button{
    background:#2e7d4f !important;
    border-color:#276b44 !important;
}

.macro-na-button{
    background:#64748b !important;
}

.macro-reset-button{
    background:#f3f5f7 !important;
    color:#405063 !important;
    border-color:#ccd5de !important;
}

/* WEATHER */
.weather-card,
.inspection-weather-card{
    background:linear-gradient(180deg,#f9fbfd,#f2f7fb);
    border:1px solid #dbe6ef;
    border-radius:13px;
    box-shadow:0 4px 14px rgba(31,58,95,.05);
}

.weather-good{
    background:#e4f3e9;
    color:#246b43;
}

.weather-warning{
    background:#fff3d6;
    color:#805e08;
}

.weather-bad{
    background:#fbe8e6;
    color:#982f27;
}

/* MAP */
#map,
.archive-map-wrap{
    border-radius:13px;
    border:1px solid #d7e1eb;
    box-shadow:0 5px 18px rgba(31,58,95,.07);
}

/* FOOTER */
footer{
    padding:36px 20px;
    color:#7a8796;
}

/* RESPONSIVE */
@media(max-width:1000px){
    .stats{
        grid-template-columns:repeat(2,1fr);
    }
}

@media(max-width:620px){
    .container{
        padding:0 12px;
        margin-top:16px;
    }

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

    .hero{
        padding:20px;
    }

    .topbar{
        padding:13px 15px;
    }
}


/* =========================================================
   TOOLTIP CONTESTUALI v2.37
   ========================================================= */

.tooltip-target{
    position:relative;
}

.tooltip-target::after{
    content:attr(data-tooltip);
    position:absolute;
    left:50%;
    bottom:calc(100% + 10px);
    transform:translate(-50%,6px);
    z-index:9999;
    width:max-content;
    max-width:290px;
    padding:8px 10px;
    border-radius:8px;
    background:#172b45;
    color:#fff;
    font-size:.78rem;
    line-height:1.35;
    font-weight:500;
    letter-spacing:0;
    text-align:left;
    white-space:normal;
    box-shadow:0 8px 22px rgba(17,35,58,.22);
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transition:opacity .14s ease, transform .14s ease, visibility .14s ease;
}

.tooltip-target::before{
    content:"";
    position:absolute;
    left:50%;
    bottom:calc(100% + 4px);
    transform:translateX(-50%);
    z-index:10000;
    border:6px solid transparent;
    border-top-color:#172b45;
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transition:opacity .14s ease, visibility .14s ease;
}

.tooltip-target:hover::after,
.tooltip-target:focus-visible::after{
    opacity:1;
    visibility:visible;
    transform:translate(-50%,0);
}

.tooltip-target:hover::before,
.tooltip-target:focus-visible::before{
    opacity:1;
    visibility:visible;
}

.nav .tooltip-target::after,
.topbar .tooltip-target::after{
    top:calc(100% + 10px);
    bottom:auto;
}

.nav .tooltip-target::before,
.topbar .tooltip-target::before{
    top:calc(100% + 4px);
    bottom:auto;
    border-top-color:transparent;
    border-bottom-color:#172b45;
}

@media(max-width:760px){
    .tooltip-target::after,
    .tooltip-target::before{
        display:none;
    }
}


/* =========================================================
   ARCHIVIO NOTIZIE E AVVISI v2.38
   ========================================================= */

.section-title-actions{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    margin-bottom:8px;
}

.section-title-actions h2{
    margin:0;
}

.page-title-actions-buttons{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
}

.notices-filter-card{
    margin-bottom:16px;
}

.notices-filter-form{
    display:grid;
    grid-template-columns:minmax(260px,1.5fr) minmax(180px,.6fr) auto;
    gap:12px;
    align-items:end;
}

.notices-filter-form label{
    margin:0;
}

.notices-filter-actions{
    display:flex;
    flex-wrap:wrap;
    gap:7px;
    align-items:center;
}

.notices-list{
    display:grid;
    gap:12px;
}

.notice-full{
    position:relative;
    border-left:5px solid #cbd5e1;
    padding:18px 20px;
}

.notice-full.notice-normal{
    border-left-color:#7b91a9;
}

.notice-full.notice-important{
    border-left-color:#d89b1d;
}

.notice-full.notice-urgent{
    border-left-color:#c0392b;
}

.notice-full-head{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:14px;
    margin-bottom:10px;
}

.notice-full-head h2{
    margin:0 0 3px;
    font-size:1.15rem;
}

.notice-full-head small{
    color:var(--muted);
}

.notice-priority{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:82px;
    padding:5px 9px;
    border-radius:999px;
    background:#eef2f6;
    color:#4b5e73;
    font-size:.76rem;
    font-weight:700;
}

.notice-important .notice-priority{
    background:#fff3d6;
    color:#805e08;
}

.notice-urgent .notice-priority{
    background:#fbe8e6;
    color:#982f27;
}

.notice-full-text{
    line-height:1.55;
    color:#3e4b5a;
}

.notice-full-actions{
    margin-top:14px;
    padding-top:12px;
    border-top:1px solid #e7edf2;
}

@media(max-width:820px){
    .notices-filter-form{
        grid-template-columns:1fr;
    }

    .section-title-actions{
        align-items:flex-start;
        flex-direction:column;
    }
}


/* =========================================================
   MODIFICA ISPEZIONE ARCHIVIATA v2.39
   ========================================================= */

.archive-edit-link{
    white-space:nowrap;
}

.inspection-edit-banner{
    padding:10px 12px;
    border-left:4px solid var(--warning,#d89b1d);
    background:#fff8e8;
    border-radius:8px;
    color:#6f5310;
}


/* =========================================================
   ARCHIVIO PDF v2.40
   ========================================================= */

.pdf-primary{
    background:linear-gradient(180deg,#2e7d4f,#256a42) !important;
    border-color:#256a42 !important;
    color:#fff !important;
    font-weight:700;
}

.pdf-primary:hover{
    background:linear-gradient(180deg,#348c59,#2a7449) !important;
}

.archive-pdf-cell{
    white-space:nowrap;
}

.pdf-archive-card{
    padding:0;
    overflow:hidden;
}

.pdf-archive-summary{
    display:flex;
    align-items:baseline;
    gap:8px;
    padding:15px 18px;
    border-bottom:1px solid #e4eaf0;
    background:#f7fafc;
}

.pdf-archive-summary strong{
    font-size:1.55rem;
    color:var(--brand);
}

.pdf-archive-summary span{
    color:var(--muted);
}

.pdf-archive-table{
    margin:0;
    border:0;
    box-shadow:none;
}

.pdf-filename{
    font-family:Consolas,"Courier New",monospace;
    font-size:.82rem;
    color:#40546d;
}

.pdf-row-actions{
    display:flex;
    flex-wrap:wrap;
    gap:6px;
}

.pdf-archive-filter{
    margin-bottom:16px;
}

@media(max-width:850px){
    .pdf-archive-table{
        min-width:900px;
    }
}


/* =========================================================
   ARCHIVIO PDF - ELIMINAZIONE AMMINISTRATORE v2.43
   ========================================================= */

.pdf-row-actions{
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:6px;
}

.pdf-delete-form{
    margin:0;
    padding:0;
    display:inline-flex;
}

.pdf-trash-button{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:34px;
    height:34px;
    min-width:34px;
    padding:0 !important;
    border:1px solid #efc8c4 !important;
    border-radius:7px !important;
    background:#fff5f4 !important;
    color:#a92f26 !important;
    box-shadow:none !important;
    font-size:16px;
    line-height:1;
    cursor:pointer;
}

.pdf-trash-button:hover{
    background:#fde8e6 !important;
    border-color:#e7aaa4 !important;
    transform:translateY(-1px);
}


/* =========================================================
   ANOMALIE RILEVATE - LINK ALLA SCHEDA GESTIONALE v3.1
   ========================================================= */

.intervento-anomaly-cell{
    min-width:0;
}

.intervento-anomaly-link{
    display:block;
    color:inherit;
    text-decoration:none;
    border-radius:7px;
    padding:5px 7px;
    margin:-5px -7px;
    transition:background .15s ease, color .15s ease;
}

.intervento-anomaly-link:hover{
    background:#eaf2f9;
    color:#1f4f86;
}

.intervento-anomaly-link strong{
    display:block;
}

.intervento-anomaly-link .intervento-control-preview{
    display:block;
    margin-top:3px;
    color:#5f6f81;
}

.intervento-anomaly-link:hover .intervento-control-preview{
    color:#415b78;
}


/* =========================================================
   ANOMALIE RILEVATE - RIGA COMPLETAMENTE CLICCABILE v3.2
   ========================================================= */

.intervento-row-link{
    cursor:pointer;
    transition:background .15s ease, box-shadow .15s ease;
}

.intervento-row-link:hover{
    background:#eaf2f9 !important;
}

.intervento-row-link:focus{
    outline:2px solid #5d8fbd;
    outline-offset:-2px;
    background:#eef5fb !important;
}

.intervento-row-link:hover .intervento-priority,
.intervento-row-link:hover .badge{
    filter:brightness(.98);
}


/* =========================================================
   ARCHIVIO PDF - TIPOLOGIA IMMOBILE v3.3
   ========================================================= */

.pdf-property-cell strong{
    display:block;
}

.pdf-property-cell small{
    display:block;
    margin-top:3px;
    color:#5f6f81;
    font-size:.78rem;
    line-height:1.25;
}


/* =========================================================
   ARCHIVIO PDF - AZIONI SEMPRE SULLA STESSA RIGA v3.4
   ========================================================= */

.pdf-archive-table th:last-child,
.pdf-archive-table td:last-child{
    width:190px !important;
    min-width:190px !important;
    white-space:nowrap !important;
}

.pdf-row-actions{
    display:flex !important;
    flex-direction:row !important;
    flex-wrap:nowrap !important;
    align-items:center !important;
    justify-content:flex-start !important;
    gap:6px !important;
    white-space:nowrap !important;
}

.pdf-row-actions > *{
    flex:0 0 auto !important;
}

.pdf-row-actions > a,
.pdf-row-actions > form{
    display:inline-flex !important;
    align-items:center !important;
    margin:0 !important;
}

.pdf-delete-form{
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    margin:0 !important;
    padding:0 !important;
}

.pdf-trash-button{
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    width:34px !important;
    height:34px !important;
    min-width:34px !important;
    min-height:34px !important;
    margin:0 !important;
    padding:0 !important;
    line-height:1 !important;
}

.pdf-row-actions .button.small{
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    min-height:34px !important;
    margin:0 !important;
}

/* Evita che il tooltip allarghi o sposti la colonna Azioni */
.pdf-row-actions .tooltip-target::after{
    white-space:normal !important;
    width:230px !important;
    max-width:230px !important;
}


/* =========================================================
   N.C. - AGGIUNTA RAPIDA FORNITORE v3.7
   ========================================================= */

.quick-supplier-modal{
    display:none;
    position:fixed;
    inset:0;
    z-index:12000;
    align-items:center;
    justify-content:center;
    padding:24px;
}

.quick-supplier-modal.is-open{
    display:flex;
}

.quick-supplier-backdrop{
    position:absolute;
    inset:0;
    background:rgba(21,34,50,.56);
    backdrop-filter:blur(2px);
}

.quick-supplier-dialog{
    position:relative;
    z-index:1;
    width:min(760px,100%);
    max-height:calc(100vh - 48px);
    overflow:auto;
    background:#fff;
    border:1px solid #d8e2ec;
    border-radius:14px;
    box-shadow:0 24px 60px rgba(24,46,71,.25);
}

.quick-supplier-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:18px;
    padding:20px 22px 15px;
    border-bottom:1px solid #e3e9ef;
    background:#f7f9fc;
}

.quick-supplier-head h2{
    margin:0 0 5px;
    color:#213d5e;
}

.quick-supplier-head p{
    margin:0;
    color:#667487;
    font-size:.88rem;
}

.quick-supplier-close{
    width:34px;
    height:34px;
    min-width:34px;
    padding:0 !important;
    display:flex;
    align-items:center;
    justify-content:center;
    background:#fff !important;
    color:#536274 !important;
    border:1px solid #d1dae4 !important;
    border-radius:8px !important;
    box-shadow:none !important;
    font-size:22px;
}

.quick-supplier-form{
    padding:20px 22px 22px;
}

.quick-supplier-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:12px 14px;
}

.quick-supplier-grid label{
    margin:0;
}

.quick-supplier-wide{
    grid-column:1 / -1;
}

.quick-supplier-actions{
    display:flex;
    justify-content:flex-end;
    gap:8px;
    margin-top:18px;
    padding-top:15px;
    border-top:1px solid #e5ebf0;
}

body.modal-open{
    overflow:hidden;
}

#interventoFornitoreSelect option[value="__new__"]{
    font-weight:700;
}

@media(max-width:650px){
    .quick-supplier-modal{
        padding:10px;
    }

    .quick-supplier-grid{
        grid-template-columns:1fr;
    }

    .quick-supplier-wide{
        grid-column:auto;
    }
}


/* =========================================================
   v3.9 - COLONNA STATO N.C.
   ========================================================= */

.interventi-list-head,
.intervento-list-row{
    display:grid !important;
    grid-template-columns:
        minmax(220px,1.15fr)
        minmax(300px,1.55fr)
        minmax(100px,.5fr)
        minmax(115px,.6fr) !important;
    align-items:center !important;
}

.interventi-list-head{
    font-weight:700;
}

.intervento-status-cell{
    display:flex;
    align-items:center;
    justify-content:flex-start;
}

.intervento-status-badge{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:82px;
    padding:5px 10px;
    border-radius:999px;
    font-size:.76rem;
    font-weight:700;
    white-space:nowrap;
    border:1px solid transparent;
}

.intervento-status-badge.status-open{
    background:#eaf2fb;
    color:#245b8e;
    border-color:#d4e2f0;
}

.intervento-status-badge.status-assigned{
    background:#f1ecfb;
    color:#64429a;
    border-color:#ddd2f0;
}

.intervento-status-badge.status-progress{
    background:#fff3d5;
    color:#84600d;
    border-color:#ead9a7;
}

.intervento-status-badge.status-suspended{
    background:#f0f2f4;
    color:#5c6570;
    border-color:#d8dde2;
}

.intervento-status-badge.status-closed{
    background:#e5f4ea;
    color:#246943;
    border-color:#cce5d4;
}

@media(max-width:900px){
    .interventi-list-head{
        display:none !important;
    }

    .intervento-list-row{
        grid-template-columns:1fr !important;
        gap:8px;
    }
}


/* =========================================================
   v3.10 - COLONNA STATO A LARGHEZZA AUTOMATICA
   ========================================================= */

.interventi-list-head,
.intervento-list-row{
    grid-template-columns:
        minmax(185px,1fr)
        minmax(250px,1.45fr)
        minmax(85px,max-content)
        max-content !important;
    column-gap:14px !important;
}

/* La colonna Stato prende esattamente lo spazio richiesto
   dal badge più largo, senza troncare il testo. */
.interventi-list-head > div:last-child,
.intervento-list-row > div:last-child{
    min-width:max-content !important;
    width:max-content !important;
    overflow:visible !important;
}

.intervento-status-cell{
    min-width:max-content !important;
    width:max-content !important;
    overflow:visible !important;
}

.intervento-status-badge{
    width:auto !important;
    min-width:max-content !important;
    max-width:none !important;
    white-space:nowrap !important;
    padding-left:12px !important;
    padding-right:12px !important;
}

/* Anche Priorità resta compatta, lasciando più spazio
   alla descrizione della macroarea. */
.intervento-list-head > div:nth-child(3),
.intervento-list-row > div:nth-child(3){
    min-width:max-content;
    white-space:nowrap;
}

@media(max-width:1050px){
    .interventi-list-head,
    .intervento-list-row{
        grid-template-columns:
            minmax(155px,.95fr)
            minmax(210px,1.25fr)
            max-content
            max-content !important;
        column-gap:10px !important;
    }
}

@media(max-width:900px){
    .interventi-list-head{
        display:none !important;
    }

    .intervento-list-row{
        grid-template-columns:1fr !important;
    }

    .intervento-list-row > div:last-child,
    .intervento-status-cell{
        width:auto !important;
    }
}


/* =========================================================
   v3.14 - PROTEZIONE DOPPIO SALVATAGGIO ISPEZIONE
   ========================================================= */

.inspection-save-row{
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:12px;
    margin-top:8px;
}

#inspectionSaveButton.is-saving,
#inspectionSaveButton:disabled{
    cursor:wait;
    opacity:.72;
}

.inspection-save-status{
    color:#607083;
    font-size:.82rem;
    line-height:1.35;
}

@media(max-width:650px){
    .inspection-save-row{
        align-items:flex-start;
        flex-direction:column;
    }
}


/* =========================================================
   v3.15 - HOME: ULTIME ISPEZIONI CLICCABILI
   ========================================================= */

.home-latest-inspections{
    width:100%;
}

.home-inspection-row{
    cursor:pointer;
    transition:background .15s ease;
}

.home-inspection-row:hover{
    background:#eef5fb;
}

.home-inspection-row:focus{
    outline:2px solid #5d8fbd;
    outline-offset:-2px;
    background:#eef5fb;
}

.home-inspection-cell-link{
    display:block;
    color:inherit;
    text-decoration:none;
    padding:2px 0;
}

.home-inspection-cell-link:hover{
    color:#1f4f86;
    text-decoration:underline;
}

.home-latest-inspections th:last-child,
.home-latest-inspections td:last-child{
    width:76px;
    white-space:nowrap;
}

@media(max-width:700px){
    .home-latest-inspections th:nth-child(3),
    .home-latest-inspections td:nth-child(3){
        display:none;
    }
}


/* =========================================================
   v3.16 - HOME: ULTIME ISPEZIONI PIÙ INFORMATIVE
   ========================================================= */

/* Più spazio alle Ultime ispezioni, meno al riquadro Notizie e avvisi. */
.home-lower-grid{
    grid-template-columns:minmax(280px,.82fr) minmax(560px,1.55fr) !important;
    align-items:start;
}

.home-news-card,
.home-inspections-card{
    min-width:0;
}

.home-latest-inspections{
    width:100%;
    table-layout:auto !important;
}

/* Le colonne si dimensionano sul contenuto reale. */
.home-latest-inspections th,
.home-latest-inspections td{
    width:auto !important;
}

.home-latest-inspections th:first-child,
.home-latest-inspections td:first-child{
    white-space:nowrap;
    width:1% !important;
}

.home-latest-inspections th:nth-child(3),
.home-latest-inspections td:nth-child(3){
    white-space:nowrap;
    width:1% !important;
}

.home-latest-inspections th:last-child,
.home-latest-inspections td:last-child{
    white-space:nowrap;
    width:1% !important;
}

.home-property-cell{
    min-width:260px;
}

.home-property-cell strong{
    display:block;
    color:#183d67;
}

.home-property-type{
    display:block;
    margin-top:2px;
    font-weight:600;
    color:#465b72;
    line-height:1.25;
}

.home-property-address{
    display:block;
    margin-top:2px;
    color:#68788a;
    line-height:1.3;
}

/* Su monitor meno larghi restituisce spazio in modo progressivo. */
@media(max-width:1100px){
    .home-lower-grid{
        grid-template-columns:minmax(250px,.72fr) minmax(500px,1.45fr) !important;
    }

    .home-property-cell{
        min-width:220px;
    }
}

@media(max-width:900px){
    .home-lower-grid{
        grid-template-columns:1fr !important;
    }

    .home-property-cell{
        min-width:200px;
    }
}

@media(max-width:700px){
    .home-latest-inspections th:nth-child(3),
    .home-latest-inspections td:nth-child(3){
        display:none;
    }

    .home-property-cell{
        min-width:170px;
    }
}


/* =========================================================
   v3.17 - GESTIONE IMMOBILI CON MAPPA
   ========================================================= */

.immobili-management-layout{
    display:grid;
    grid-template-columns:minmax(0,1.75fr) minmax(330px,.75fr);
    gap:18px;
    align-items:start;
}

.immobili-map-card{
    min-width:0;
    padding:16px;
}

.immobili-map-head{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    flex-wrap:wrap;
    gap:12px 20px;
    margin-bottom:12px;
}

.immobili-map-head h2{
    margin:0 0 3px;
}

.immobili-map-legend{
    justify-content:flex-end;
    margin:0;
}

#immobiliManagementMap{
    width:100%;
    height:650px;
    min-height:520px;
    border:1px solid #d6e0ea;
    border-radius:10px;
    overflow:hidden;
}

.immobili-map-empty{
    min-height:420px;
    display:flex;
    align-items:center;
    justify-content:center;
    color:#667689;
    border:1px dashed #ccd7e2;
    border-radius:10px;
    background:#f8fafc;
}

.immobili-management-sidebar{
    display:flex;
    flex-direction:column;
    gap:16px;
    min-width:0;
}

.immobili-form-actions{
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:8px;
}

.immobili-map-popup-actions{
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:10px;
    margin-top:10px;
    padding-top:8px;
    border-top:1px solid #dde3ea;
}

/* Stili della mappa replicati dalla Mappa generale. */
.immobili-map-card .map-legend{
    display:flex;
    gap:14px;
    flex-wrap:wrap;
    align-items:center;
    font-size:12px;
}

.immobili-map-card .map-legend span{
    display:inline-flex;
    align-items:center;
    gap:7px;
}

.immobili-map-card .map-pin{
    position:relative;
    display:inline-block;
    width:20px;
    height:20px;
    border-radius:50% 50% 50% 0;
    transform:rotate(-45deg);
    border:2px solid #fff;
    box-shadow:0 1px 4px rgba(0,0,0,.35);
    box-sizing:border-box;
}

.immobili-map-card .map-pin::after{
    content:'';
    position:absolute;
    width:7px;
    height:7px;
    border-radius:50%;
    background:#fff;
    top:4px;
    left:4px;
}

.immobili-map-card .legend-pin{
    transform:rotate(-45deg) scale(.85);
    margin-right:2px;
}

.immobili-map-card .pin-gray{background:#6b7280}
.immobili-map-card .pin-blue{background:#2563eb}
.immobili-map-card .pin-red{background:#dc2626}

.leaflet-div-icon.custom-pin-icon{
    background:transparent;
    border:none;
}

#immobiliManagementMap .leaflet-popup-content{
    min-width:280px;
    max-width:430px!important;
}

#immobiliManagementMap .map-popup-title{
    font-size:15px;
    margin-bottom:4px;
}

#immobiliManagementMap .map-nc-list{
    margin-top:10px;
    border-top:1px solid #ddd;
    padding-top:7px;
}

#immobiliManagementMap .map-nc-item{
    margin:7px 0;
    padding:8px;
    background:#fff5f5;
    border:1px solid #f0caca;
    border-radius:6px;
}

#immobiliManagementMap .map-nc-item summary{
    cursor:pointer;
    font-weight:700;
    color:#8b2020;
}

#immobiliManagementMap .map-nc-meta{
    font-size:12px;
    color:#66717f;
    margin:5px 0;
}

#immobiliManagementMap .map-nc-desc{
    margin:5px 0;
    white-space:normal;
}

#immobiliManagementMap .map-nc-photos{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:5px;
    margin-top:7px;
}

#immobiliManagementMap .map-nc-photos img{
    width:100%;
    height:110px;
    object-fit:cover;
    border-radius:4px;
    border:1px solid #d5dbe3;
}

@media(max-width:1100px){
    .immobili-management-layout{
        grid-template-columns:minmax(0,1.35fr) minmax(320px,.85fr);
    }

    #immobiliManagementMap{
        height:580px;
    }
}

@media(max-width:850px){
    .immobili-management-layout{
        grid-template-columns:1fr;
    }

    #immobiliManagementMap{
        height:520px;
        min-height:420px;
    }
}


/* =========================================================
   v3.18 - CORREZIONE VISIBILITÀ MAPPA IMMOBILI
   ========================================================= */

.immobili-management-layout{
    display:grid !important;
    grid-template-columns:minmax(0,1.75fr) minmax(340px,.75fr) !important;
    gap:20px !important;
    align-items:start !important;
}

.immobili-map-card{
    display:block !important;
    min-width:0 !important;
    min-height:620px !important;
}

#immobiliManagementMap{
    display:block !important;
    width:100% !important;
    height:650px !important;
    min-height:650px !important;
    background:#eef3f7;
    border:1px solid #d3dde7;
    border-radius:10px;
}

.immobili-map-load-error{
    min-height:620px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    text-align:center;
    color:#7a3030;
    background:#fff5f5;
    border-radius:10px;
    padding:24px;
}

@media(max-width:900px){
    .immobili-management-layout{
        grid-template-columns:1fr !important;
    }

    .immobili-map-card{
        min-height:500px !important;
    }

    #immobiliManagementMap{
        height:520px !important;
        min-height:520px !important;
    }
}


/* =========================================================
   v3.19 - PRIORITÀ VISIVA MARKER MAPPA
   ========================================================= */

/*
Ordine di priorità grafica:
1. Rosso = N.C. aperte
2. Blu = ispezionato senza N.C. aperte
3. Grigio = nessuna ispezione

Lo z-index reale viene gestito in JavaScript tramite zIndexOffset.
Queste regole mantengono inoltre i marker operativi visivamente più leggibili.
*/

.map-pin.pin-red{
    box-shadow:
        0 0 0 2px rgba(220,38,38,.20),
        0 2px 6px rgba(0,0,0,.38) !important;
}

.map-pin.pin-blue{
    box-shadow:
        0 0 0 1px rgba(37,99,235,.16),
        0 2px 5px rgba(0,0,0,.32) !important;
}

.map-pin.pin-gray{
    opacity:.82;
}


/* =========================================================
   v3.20 - CORREZIONE MAPPA ARCHIVIO ISPEZIONI
   ========================================================= */

.archive-map-load-error{
    min-height:360px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    text-align:center;
    color:#7a3030;
    background:#fff5f5;
    border-radius:8px;
    padding:24px;
}


/* =========================================================
   v3.21 - RIPRISTINO MAPPA ANOMALIE RILEVATE
   ========================================================= */

.interventi-map-load-error{
    min-height:360px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    text-align:center;
    color:#7a3030;
    background:#fff5f5;
    border-radius:8px;
    padding:24px;
}


/* =========================================================
   v3.22 - BACKUP E RIPRISTINO DATABASE
   ========================================================= */

.backup-status-grid{
    display:grid;
    grid-template-columns:minmax(0,1.55fr) minmax(280px,.65fr);
    gap:18px;
    align-items:start;
    margin-bottom:18px;
}

.backup-main-card,
.backup-guide-card,
.backup-list-card,
.backup-synology-card{
    min-width:0;
}

.backup-card-head{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:14px;
    flex-wrap:wrap;
}

.backup-card-head h2,
.backup-guide-card h2,
.backup-list-card h2,
.backup-synology-card h2{
    margin-top:0;
}

.backup-status-badge{
    display:inline-flex;
    align-items:center;
    min-height:30px;
    padding:5px 10px;
    border-radius:999px;
    font-size:.78rem;
    font-weight:700;
    white-space:nowrap;
}

.backup-status-badge.is-ok{
    color:#166534;
    background:#dcfce7;
    border:1px solid #bbf7d0;
}

.backup-status-badge.is-error{
    color:#991b1b;
    background:#fee2e2;
    border:1px solid #fecaca;
}

.backup-path{
    margin:14px 0;
    padding:10px 12px;
    background:#f5f8fb;
    border:1px solid #dce5ee;
    border-radius:8px;
    overflow-wrap:anywhere;
}

.backup-create-form{
    margin:14px 0;
}

.backup-note{
    margin:16px 0 0;
    padding:12px 14px;
    border-left:4px solid #2f6695;
    background:#f2f7fb;
    border-radius:5px;
}

.backup-guide-card ul{
    margin:8px 0 14px;
    padding-left:20px;
}

.backup-guide-card li{
    margin:5px 0;
}

.backup-table{
    width:100%;
    table-layout:auto;
}

.backup-table th,
.backup-table td{
    vertical-align:top;
}

.backup-table th:first-child,
.backup-table td:first-child,
.backup-table th:nth-child(3),
.backup-table td:nth-child(3),
.backup-table th:nth-child(4),
.backup-table td:nth-child(4),
.backup-table th:nth-child(6),
.backup-table td:nth-child(6){
    white-space:nowrap;
    width:1%;
}

.backup-table code{
    font-size:.82rem;
    overflow-wrap:anywhere;
}

.backup-restore-details{
    min-width:180px;
}

.backup-restore-details > summary{
    display:inline-flex;
    list-style:none;
    cursor:pointer;
}

.backup-restore-details > summary::-webkit-details-marker{
    display:none;
}

.button.warning,
summary.button.warning{
    background:#fff7ed;
    border:1px solid #fdba74;
    color:#9a3412;
}

.backup-restore-form{
    width:300px;
    max-width:70vw;
    margin-top:10px;
    padding:12px;
    border:1px solid #fdba74;
    border-radius:8px;
    background:#fffaf5;
}

.backup-restore-form p{
    margin-top:0;
    font-size:.85rem;
}

.backup-restore-form input{
    width:100%;
}

.backup-synology-card{
    margin-top:18px;
}

@media(max-width:900px){
    .backup-status-grid{
        grid-template-columns:1fr;
    }
}


/* v3.23 - SMTP / notifiche aggiornamenti */
.smtp-settings-card{scroll-margin-top:90px}
.smtp-settings-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap}
.smtp-settings-head h2{margin-top:0}
.smtp-status{display:inline-flex;align-items:center;min-height:29px;padding:4px 10px;border-radius:999px;font-size:.78rem;font-weight:700;white-space:nowrap}
.smtp-status.is-ok{background:#dcfce7;color:#166534;border:1px solid #bbf7d0}
.smtp-status.is-off{background:#f1f5f9;color:#475569;border:1px solid #d9e2ec}
.smtp-enabled-row{display:flex;align-items:center;gap:8px;margin:10px 0 14px;font-weight:700}
.smtp-enabled-row input{width:auto;margin:0}
.smtp-test-form{margin-top:12px}
.smtp-admin-recipients{margin-top:14px;padding:10px 12px;background:#f6f9fc;border:1px solid #dce5ee;border-radius:8px;overflow-wrap:anywhere}


/* =========================================================
   v3.24 - MANUALE E DOCUMENTAZIONE
   ========================================================= */

.manual-layout{
    display:grid;
    grid-template-columns:minmax(0,1.55fr) minmax(300px,.65fr);
    gap:18px;
    align-items:start;
}

.manual-main-card,
.manual-storage-card,
.manual-upload-card{
    min-width:0;
}

.manual-head{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:12px;
    flex-wrap:wrap;
}

.manual-head h2{
    margin-top:0;
}

.manual-status{
    display:inline-flex;
    align-items:center;
    min-height:30px;
    padding:5px 10px;
    border-radius:999px;
    font-size:.78rem;
    font-weight:700;
}

.manual-status.is-ok{
    color:#166534;
    background:#dcfce7;
    border:1px solid #bbf7d0;
}

.manual-status.is-missing{
    color:#991b1b;
    background:#fee2e2;
    border:1px solid #fecaca;
}

.manual-file-card{
    display:grid;
    grid-template-columns:auto minmax(0,1fr) auto;
    gap:14px;
    align-items:center;
    margin-top:16px;
    padding:14px;
    border:1px solid #d8e2eb;
    border-radius:10px;
    background:#f8fafc;
}

.manual-file-icon{
    display:flex;
    align-items:center;
    justify-content:center;
    width:58px;
    height:58px;
    border-radius:10px;
    background:#e6eef6;
    color:#214f7c;
    font-weight:800;
    font-size:.82rem;
}

.manual-file-info{
    min-width:0;
    overflow-wrap:anywhere;
}

.manual-file-actions{
    display:flex;
    align-items:center;
    gap:8px;
    flex-wrap:wrap;
}

.manual-note{
    margin-top:12px;
    padding:10px 12px;
    border-left:4px solid #c48a2c;
    background:#fff7e8;
    border-radius:5px;
}

.manual-empty{
    margin-top:14px;
    padding:18px;
    text-align:center;
    border:1px dashed #cbd6e1;
    border-radius:10px;
    background:#f8fafc;
}

.manual-usage-box{
    margin-top:18px;
    padding:14px;
    background:#f4f8fb;
    border:1px solid #dae5ee;
    border-radius:9px;
}

.manual-usage-box h3{
    margin-top:0;
}

.manual-usage-box ul{
    margin-bottom:0;
}

.manual-storage-card code{
    display:block;
    padding:10px 12px;
    background:#f5f7f9;
    border:1px solid #dce3ea;
    border-radius:7px;
    overflow-wrap:anywhere;
}

@media(max-width:900px){
    .manual-layout{
        grid-template-columns:1fr;
    }

    .manual-file-card{
        grid-template-columns:auto minmax(0,1fr);
    }

    .manual-file-actions{
        grid-column:1 / -1;
    }
}


/* v3.26 - Gestione utenti */
.user-actions{
    display:flex;
    gap:6px;
    align-items:center;
    flex-wrap:wrap;
}


/* =========================================================
   v3.26.1 - Correzione modifica utenti
   ========================================================= */

.users-table .user-row-editing{
    background:#eef6ff;
    box-shadow:inset 4px 0 0 #2f6da8;
}

.user-actions{
    display:flex;
    gap:6px;
    align-items:center;
    flex-wrap:wrap;
}

.user-actions form{
    margin:0;
}

.user-save-button{
    background:#277a49;
    border-color:#277a49;
}

.user-edit-buttons{
    display:flex;
    gap:8px;
    align-items:center;
    flex-wrap:wrap;
    margin-top:12px;
}


/* =========================================================
   v3.27 - Programmazione Ispezioni
   ========================================================= */

.scheduled-programming-layout{
    display:grid;
    grid-template-columns:minmax(0,1.35fr) minmax(280px,.65fr);
    gap:18px;
    align-items:start;
}

.scheduled-programming-layout .card{
    min-width:0;
}

.scheduled-programming-actions{
    display:flex;
    gap:8px;
    align-items:center;
    flex-wrap:wrap;
    margin-top:14px;
}

.scheduled-programming-help ol{
    padding-left:22px;
}

.scheduled-programming-help li{
    margin-bottom:8px;
}

@media(max-width:900px){
    .scheduled-programming-layout{
        grid-template-columns:1fr;
    }
}


/* =========================================================
   v3.28 - N.C. trasferite ad altro servizio / marker giallo
   ========================================================= */

.legend-dot.yellow,
.legend-marker.yellow,
.map-dot.yellow{
    background:#f2c94c;
    border-color:#b88700;
}

.nc-external-badge{
    display:inline-flex;
    align-items:center;
    gap:6px;
    padding:4px 9px;
    border-radius:999px;
    background:#fff6cf;
    color:#725600;
    border:1px solid #e2c45a;
    font-size:.78rem;
    font-weight:700;
}

.nc-external-note{
    margin-top:10px;
    padding:10px 12px;
    background:#fff9df;
    border-left:4px solid #d7a90d;
    border-radius:6px;
}

/* Priorità visiva prevista:
   rosso > giallo > blu > grigio */


/* v3.28.1 - marker giallo mappa generale */
.pin-yellow{
    background:#f2c94c;
}


/* =========================================================
   v4.0.1 - Marker giallo su tutte le mappe
   ========================================================= */

.archive-pin-yellow{
    background:#f2c94c;
    border-color:#b88700;
}

.interventi-map-title{
    gap:10px;
    flex-wrap:wrap;
}

.interventi-map-title > div:first-child{
    display:flex;
    flex-direction:column;
    gap:2px;
}

.interventi-map-legend{
    display:flex;
    gap:12px;
    flex-wrap:wrap;
    align-items:center;
    font-size:.78rem;
}

.interventi-map-legend span{
    display:inline-flex;
    gap:6px;
    align-items:center;
}

.nc-legend-dot{
    width:12px;
    height:12px;
    border-radius:50%;
    display:inline-block;
    border:2px solid rgba(255,255,255,.95);
    box-shadow:0 0 0 1px rgba(0,0,0,.22);
}

.nc-legend-red{
    background:#dc2626;
}

.nc-legend-yellow{
    background:#f2c94c;
}

.nc-map-pin-red{
    background:#dc2626;
}

.nc-map-pin-yellow{
    background:#f2c94c;
}

/* La priorità logica resta:
   rosso > giallo > blu > grigio */


/* =========================================================
   v4.2 - Stato reale sulla mappa Anomalie rilevate
   ========================================================= */

.nc-legend-blue{
    background:#2563eb;
}

.nc-map-pin-blue{
    background:#2563eb;
}

.nc-popup-count-blue{
    color:#1d4ed8;
}

.nc-popup-count-yellow{
    color:#8a6900;
}

.nc-popup-count-red{
    color:#b42323;
}


/* =========================================================
   v4.3 - Acquisizione fotografie multiple nelle N.C.
   ========================================================= */

.photo-upload-row{
    flex-wrap:wrap;
}

.photo-preview-gallery{
    width:100%;
    display:grid;
    grid-template-columns:repeat(auto-fill,minmax(120px,1fr));
    gap:9px;
    margin-top:8px;
}

.photo-preview-item{
    min-width:0;
    overflow:hidden;
    border:1px solid #d4dee7;
    border-radius:8px;
    background:#fff;
}

.photo-preview-item img{
    display:block;
    width:100%;
    aspect-ratio:4/3;
    object-fit:cover;
    background:#edf2f6;
}

.photo-preview-label{
    display:block;
    padding:5px 7px 2px;
    font-size:.76rem;
    font-weight:700;
    color:#40576b;
}

.photo-preview-remove{
    display:block;
    width:calc(100% - 12px);
    min-height:34px;
    margin:4px 6px 7px;
    padding:5px 8px;
    border:1px solid #d6a2a2;
    border-radius:6px;
    background:#fff5f5;
    color:#972525;
    font-size:.77rem;
    font-weight:700;
    cursor:pointer;
}

.photo-preview-remove:hover{
    background:#ffe9e9;
}

@media(max-width:600px){
    .photo-preview-gallery{
        grid-template-columns:repeat(2,minmax(0,1fr));
    }

    .photo-preview-remove{
        min-height:42px;
    }
}


/* =========================================================
   v4.4 - Aspetto e layout
   ========================================================= */

.settings-subnav{
    display:flex;
    gap:7px;
    flex-wrap:wrap;
    margin:0 0 18px;
    padding:7px;
    border:1px solid var(--line);
    border-radius:9px;
    background:var(--layout-card,#fff);
}

.settings-subnav a{
    display:inline-flex;
    align-items:center;
    min-height:36px;
    padding:7px 11px;
    border-radius:6px;
    color:var(--text);
    text-decoration:none;
    font-weight:600;
    font-size:.9rem;
}

.settings-subnav a:hover{
    background:#00000008;
}

.settings-subnav a.active{
    background:var(--brand);
    color:#fff;
}

.layout-settings-shortcut{
    display:flex;
    flex-direction:column;
    gap:4px;
    margin:12px 0;
    padding:11px 12px;
    border-left:4px solid var(--brand);
    border-radius:6px;
    background:#f5f8fb;
    font-size:.9rem;
}

.layout-settings-grid{
    display:grid;
    grid-template-columns:minmax(0,1.3fr) minmax(330px,.7fr);
    gap:18px;
    align-items:start;
}

.layout-settings-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    flex-wrap:wrap;
}

.layout-settings-head h2{
    margin-top:0;
}

.layout-admin-badge{
    display:inline-flex;
    align-items:center;
    padding:5px 9px;
    border-radius:999px;
    background:#eef3f8;
    color:#49637a;
    border:1px solid #d8e2ea;
    font-size:.75rem;
    font-weight:700;
}

.layout-color-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:12px;
    margin-bottom:22px;
}

.layout-color-control{
    display:block;
    padding:12px;
    border:1px solid var(--line);
    border-radius:8px;
    background:#fafbfd;
}

.layout-color-control > span{
    display:block;
    font-weight:700;
    margin-bottom:3px;
}

.layout-color-control small{
    display:block;
    min-height:34px;
    color:var(--muted);
}

.layout-color-row{
    display:flex;
    align-items:center;
    gap:10px;
    margin-top:8px;
}

.layout-color-row input[type="color"]{
    width:56px;
    height:38px;
    padding:2px;
    cursor:pointer;
}

.layout-color-row code{
    font-size:.84rem;
    color:#526274;
}

.layout-preset-section{
    margin-top:18px;
}

.layout-presets{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
}

.layout-form-actions{
    margin-top:20px;
}

.layout-reset-form{
    margin-top:8px;
}

.layout-preview-card{
    position:sticky;
    top:14px;
}

.layout-preview{
    overflow:hidden;
    border:1px solid var(--line);
    border-radius:12px;
    background:var(--bg);
    color:var(--text);
}

.layout-preview-topbar{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:8px;
    padding:13px;
    background:var(--layout-topbar);
    border-bottom:1px solid #00000010;
}

.layout-preview-nav{
    display:flex;
    gap:5px;
    flex-wrap:wrap;
    padding:7px;
    background:var(--layout-nav);
    color:#fff;
    font-size:.72rem;
}

.layout-preview-nav span{
    padding:5px 7px;
    border-radius:4px;
}

.layout-preview-body{
    display:grid;
    gap:9px;
    padding:12px;
    background:var(--bg);
}

.layout-preview-panel{
    padding:12px;
    border:1px solid #00000012;
    border-radius:var(--layout-radius,10px);
    background:var(--layout-card);
}

.layout-preview-panel p{
    margin:6px 0 10px;
}

.layout-preview-panel button{
    background:var(--brand);
}

.layout-note{
    margin-top:13px;
    padding:11px 12px;
    border-radius:7px;
    background:#fff8dc;
    border:1px solid #ead58c;
    color:#665418;
    font-size:.86rem;
}

@media(max-width:900px){
    .layout-settings-grid{
        grid-template-columns:1fr;
    }

    .layout-preview-card{
        position:static;
    }
}

@media(max-width:650px){
    .layout-color-grid{
        grid-template-columns:1fr;
    }

    .settings-subnav{
        display:grid;
        grid-template-columns:1fr 1fr;
    }
}


/* =========================================================
   v4.4.1 - Colore pulsante Programma ispezione
   ========================================================= */

.home-program-button{
    background:var(--layout-home-program-button,var(--brand));
}

.home-program-button:hover{
    filter:brightness(.94);
}

.layout-preview-program-button{
    background:var(--layout-home-program-button,var(--brand)) !important;
}


/* =========================================================
   v4.5 - Sistema centralizzato colori pulsanti
   ========================================================= */

/* Pulsanti principali */
.button:not(.secondary):not(.danger):not(.success):not(.program-action),
button:not(.secondary):not(.danger):not(.success):not(.program-action){
    background:var(--button-primary,var(--brand));
}

/* Pulsanti secondari */
.button.secondary,
button.secondary{
    background:var(--button-secondary,#5e6c7e) !important;
    color:#fff;
}

/* Salvataggio / conferma */
.button.success,
button.success,
.user-save-button,
.save-pdf-button,
.pdf-save-button{
    background:var(--button-success,#277a49) !important;
    color:#fff;
}

/* Eliminazione / pericolo */
.button.danger,
button.danger,
.danger{
    background:var(--button-danger,#b9332b) !important;
    color:#fff;
}

/* Programmazione ispezioni */
.button.program-action,
button.program-action,
.home-program-button{
    background:var(--button-program,var(--layout-home-program-button,var(--brand))) !important;
    color:#fff;
}

.button:hover,
button:hover{
    filter:brightness(.94);
}

/* Anteprima categorie */
.layout-preview-buttons{
    display:flex;
    gap:6px;
    flex-wrap:wrap;
}

.layout-preview-primary{
    background:var(--button-primary,var(--brand)) !important;
}
.layout-preview-secondary{
    background:var(--button-secondary,#5e6c7e) !important;
}
.layout-preview-success{
    background:var(--button-success,#277a49) !important;
}
.layout-preview-danger{
    background:var(--button-danger,#b9332b) !important;
}
.layout-preview-program-button{
    background:var(--button-program,var(--layout-home-program-button,var(--brand))) !important;
}


/* =========================================================
   v4.5.1 - Menu Manuale / Impostazioni allineato a destra
   ========================================================= */

.nav-right-group{
    margin-left:auto;
    display:flex;
    gap:4px;
    align-items:center;
}

.nav-right-group > a{
    color:#fff;
    text-decoration:none;
    padding:9px 11px;
    border-radius:5px;
    background:#ffffff10;
    font:inherit;
}

.nav-right-group > a:hover{
    background:#ffffff20;
}

@media(max-width:900px){
    .nav-right-group{
        width:100%;
        margin-left:0;
        padding-top:4px;
        border-top:1px solid #ffffff20;
    }
}
.immobili-map-card .immobili-map-legend{
    display:flex !important;
    flex-wrap:nowrap !important;
    align-items:center !important;
    justify-content:center !important;
    gap:10px !important;
    white-space:nowrap !important;
}

.immobili-map-card .immobili-map-legend span{
    display:inline-flex !important;
    align-items:center !important;
    white-space:nowrap !important;
    font-size:12px;
}
