/* Font caricati in locale (nessuna richiesta a Google Fonts: niente cookie/tracciamento di terze parti) */
@font-face {
    font-family: "Urbanist";
    src: url("fonts/Urbanist-Light.woff2") format("woff2");
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Urbanist";
    src: url("fonts/Urbanist-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Urbanist";
    src: url("fonts/Urbanist-Medium.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Urbanist";
    src: url("fonts/Urbanist-SemiBold.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Urbanist";
    src: url("fonts/Urbanist-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --blu: #234b8f;
    --blu-scuro: #0f2247;
    --blu-chiaro: #eaeff9;
    --verde: #1f9d73;
    --verde-chiaro: #e3f8ef;
    --rosso: #d1495b;
    --rosso-chiaro: #fbe7ea;
    --ambra: #c98a1a;
    --ambra-chiaro: #fdf2df;
    --grigio: #6b7280;
    --bordo: #e3e6ee;
    --ombra: 0 2px 10px rgba(15, 34, 71, .07), 0 1px 2px rgba(15, 34, 71, .04);
    --ombra-hover: 0 8px 24px rgba(15, 34, 71, .14), 0 2px 6px rgba(15, 34, 71, .06);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Urbanist", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: linear-gradient(160deg, #f4f6ff 0%, #fdf7f2 45%, #f0faf6 100%);
    background-attachment: fixed;
    color: #262b3d;
    font-weight: 400;
}
.container { max-width: 1300px; margin: 0 auto; padding: 24px 20px 60px; }

.topbar {
    position: relative;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    padding: 0 24px;
    flex-wrap: wrap;
    min-height: 64px;
}
.topbar-sfondo {
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, #0f2247 0%, #16305f 55%, #1e3f7a 100%);
    box-shadow: 0 2px 14px rgba(15, 34, 71, .25);
    clip-path: url(#topbar-curva);
    z-index: 0;
}
.topbar > *:not(.topbar-sfondo) { position: relative; z-index: 1; }
.topbar .logo { display: flex; align-items: center; padding: 10px 0; }
.logo-img { display: block; height: 32px; width: auto; }
.topbar nav { display: flex; align-items: stretch; flex-wrap: wrap; }
.topbar nav a {
    font-family: "Urbanist", sans-serif;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    padding: 0 9px;
    opacity: .88;
    font-size: .88em;
    letter-spacing: 0;
    white-space: nowrap;
    text-transform: uppercase;
    transition: opacity .15s, background-color .15s;
}
.topbar nav a:hover { opacity: 1; background-color: rgba(255, 255, 255, .16); }
.topbar nav a.active { opacity: 1; background-color: rgba(255, 255, 255, .22); font-weight: 600; }
.selettore-lingua { display: flex; align-items: center; gap: 2px; padding: 0 4px 0 12px; margin-left: 2px; border-left: 1px solid rgba(255,255,255,.18); }
.selettore-lingua a {
    font-family: "Urbanist", sans-serif;
    padding: 5px 8px !important;
    display: flex;
    align-items: center;
    font-size: .82em;
    font-weight: 600;
    letter-spacing: .3px;
    border-radius: 6px;
    opacity: .6;
    transition: opacity .15s, background-color .15s;
}
.selettore-lingua a:hover { opacity: .9; background-color: rgba(255, 255, 255, .12); }
.selettore-lingua a.active { opacity: 1; background-color: rgba(255, 255, 255, .22); }

/* Menu hamburger (mobile/tablet) */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
}
.hamburger span { display: block; width: 24px; height: 2px; background: #fff; border-radius: 2px; transition: transform .2s, opacity .2s; }
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 1310px) {
    .hamburger { display: flex; }
    .topbar nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        padding: 6px 0 12px;
    }
    .topbar nav.aperto { display: flex; }
    .topbar nav a { padding: 12px 6px; }
    .selettore-lingua { border-left: none; border-top: 1px solid rgba(255,255,255,.18); margin: 6px 0 0; padding: 10px 6px 0; justify-content: flex-start; }
    /* Sotto la soglia il menu diventa hamburger (a tendina, su più righe):
       la curva lascerebbe testo su sfondo chiaro poco leggibile, quindi l'header torna blu pieno. */
    .topbar-sfondo { clip-path: none; }
}

h1 { font-family: "Urbanist", sans-serif; font-size: 1.7em; margin: 0 0 16px; font-weight: 600; letter-spacing: .2px; color: #262b3d; }
h2 { font-family: "Urbanist", sans-serif; font-size: 1.25em; margin: 28px 0 12px; font-weight: 600; letter-spacing: .2px; color: #262b3d; }

.section-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }

.btn, button.btn {
    background: linear-gradient(135deg, #16305f 0%, #234b8f 100%);
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: 9px;
    text-decoration: none;
    cursor: pointer;
    font-size: .95em;
    display: inline-block;
    box-shadow: 0 3px 10px rgba(22, 48, 95, .28);
    transition: transform .12s, box-shadow .12s, opacity .12s;
}
.btn:hover { opacity: .95; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(22, 48, 95, .35); }
.btn-secondary {
    background: #fff;
    color: var(--blu);
    border: 1px solid var(--bordo);
    padding: 9px 18px;
    border-radius: 9px;
    text-decoration: none;
    cursor: pointer;
    font-size: .95em;
    display: inline-block;
    transition: box-shadow .12s, transform .12s, border-color .12s;
}
.btn-secondary:hover { box-shadow: var(--ombra); transform: translateY(-1px); border-color: #b9c5e0; }

.cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.card {
    background: linear-gradient(160deg, #ffffff 0%, #f7f8ff 100%);
    border: 1px solid var(--bordo);
    border-radius: 14px;
    padding: 16px 20px;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--ombra);
}
.card-label { color: var(--grigio); font-size: .85em; }
.card-value { font-size: 1.6em; font-weight: 700; color: var(--blu-scuro); }
.card-value.ok { color: var(--verde); }
.card-value.warn { color: var(--rosso); }

.tabella { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--bordo); border-radius: 12px; overflow: hidden; box-shadow: var(--ombra); }
.tabella th, .tabella td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--bordo); font-size: .93em; }
.tabella th { background: linear-gradient(135deg, #eaeff9 0%, #e3eaf6 100%); color: var(--blu-scuro); font-weight: 700; }
.tabella tr:last-child td { border-bottom: none; }
.tabella tr:hover td { background: #fafbff; }
.th-ordina { color: inherit; text-decoration: none; display: inline-block; white-space: nowrap; }
.th-ordina:hover { text-decoration: underline; }
.riga-totali td { background: var(--blu-chiaro); font-size: .93em; font-weight: 700; color: var(--blu-scuro); padding: 10px 12px; white-space: nowrap; }
.riga-totali:hover td { background: var(--blu-chiaro); }
.separatore-totali { margin: 0 10px; color: var(--grigio); }

.stato { padding: 4px 11px; border-radius: 20px; font-size: .8em; font-weight: 700; letter-spacing: .1px; }
.stato-bozza { background: linear-gradient(135deg, #eceef4, #e2e5f0); color: #5c6070; }
.stato-emessa { background: linear-gradient(135deg, var(--ambra-chiaro), #fdeccb); color: var(--ambra); }
.stato-pagata { background: linear-gradient(135deg, var(--verde-chiaro), #d3f3e6); color: var(--verde); }
.stato-scaduta { background: linear-gradient(135deg, var(--rosso-chiaro), #f9d9dd); color: var(--rosso); }
.stato-annullata { background: linear-gradient(135deg, #eceef4, #e2e5f0); color: #9096a6; text-decoration: line-through; }

.filtri { margin-bottom: 14px; }
.filtri a { margin-right: 14px; text-decoration: none; color: var(--grigio); padding-bottom: 4px; }
.filtri a.active { color: var(--blu); font-weight: 700; border-bottom: 2px solid var(--blu); }

.ricerca { margin-bottom: 14px; display: flex; gap: 8px; }
.ricerca input { padding: 8px 10px; border: 1px solid var(--bordo); border-radius: 8px; flex: 1; max-width: 320px; }
.azioni-export { display: flex; gap: 10px; }

.form-box { background: linear-gradient(160deg, #ffffff 0%, #f8f9ff 100%); border: 1px solid var(--bordo); border-radius: 14px; padding: 20px; max-width: 700px; box-shadow: var(--ombra); }
.form-box label { display: block; margin: 12px 0 4px; font-size: .88em; color: var(--grigio); }
.form-box input, .form-box select, .form-box textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--bordo); border-radius: 8px; font-size: .95em; font-family: inherit;
}
.form-box input:focus, .form-box select:focus, .form-box textarea:focus { outline: none; border-color: var(--blu); box-shadow: 0 0 0 3px rgba(35, 75, 143, .14); }
.form-box.form-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; max-width: none; }
.form-box.form-inline label { margin: 0 0 4px; }
.form-box.form-inline > div, .form-box.form-inline input { width: auto; }
.riga3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.link-piccolo { font-size: .85em; display: inline-block; margin-top: 6px; }
.mini-form { margin-top: 10px; padding: 12px; background: linear-gradient(135deg, var(--blu-chiaro), #dfe6f4); border-radius: 10px; }
.mini-form label { margin: 8px 0 3px; }
.mini-form button { margin-top: 10px; margin-right: 10px; }
.righe-table input, .righe-table select { width: 100%; }
.totale-anteprima { text-align: right; font-size: 1.1em; margin: 10px 0; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: linear-gradient(135deg, #0f2247 0%, #16305f 55%, #1e3f7a 100%); }
.login-box { background: #fff; padding: 32px; border-radius: 16px; width: 300px; box-shadow: 0 16px 40px rgba(10, 20, 50, .28); }
.login-box h1 { text-align: center; margin-bottom: 20px; }
.login-logo { display: block; margin: 0 auto 20px; max-width: 220px; height: auto; }
.login-box label { display: block; margin: 10px 0 4px; font-size: .88em; color: var(--grigio); }
.login-box input { width: 100%; padding: 9px 10px; border: 1px solid var(--bordo); border-radius: 8px; }
.login-box button { width: 100%; margin-top: 18px; padding: 10px; background: linear-gradient(135deg, #16305f, #234b8f); color: #fff; border: none; border-radius: 8px; cursor: pointer; font-weight: 700; }
.errore { color: var(--rosso); font-size: .9em; }
.msg-ok { color: var(--verde); font-weight: 600; }
.hint { color: var(--grigio); font-size: .85em; margin: -6px 0 10px; }
.logo-preview { margin: 8px 0; }
.logo-preview img { max-height: 70px; max-width: 220px; border: 1px solid var(--bordo); border-radius: 8px; padding: 6px; background: #fff; }

/* Foglio fattura */
.foglio-fattura { background: #fff; border: 1px solid var(--bordo); border-radius: 14px; padding: 32px; margin-bottom: 24px; box-shadow: var(--ombra); }
.fattura-head { display: flex; justify-content: space-between; margin-bottom: 20px; }
.fattura-logo { max-height: 60px; max-width: 200px; display: block; margin-bottom: 10px; }
.fattura-numero { text-align: right; }
.fattura-cliente { margin-bottom: 20px; padding: 12px; background: linear-gradient(135deg, var(--blu-chiaro), #dfe6f4); border-radius: 10px; }
.spaziatore-stampa { flex: 1; }
.fattura-totali { text-align: right; margin-top: 14px; }
.fattura-totali p { margin: 4px 0; }
.totale-finale { font-size: 1.3em; font-weight: 700; color: var(--blu-scuro); }
.fattura-note { margin-top: 16px; font-size: .9em; color: var(--grigio); }
.fattura-pagamenti { margin-top: 20px; }
.fattura-pagamenti h3 { font-size: 1em; margin: 0 0 8px; color: var(--blu-scuro); }
.fattura-pagamenti .tabella { font-size: .9em; }

/* Grafico statistiche */
.grafico-barre { display: flex; align-items: flex-end; gap: 8px; height: 210px; background: #fff; border: 1px solid var(--bordo); border-radius: 14px; padding: 16px; margin-bottom: 22px; box-shadow: var(--ombra); }
.barra-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.barra { width: 60%; background: var(--blu); border-radius: 5px 5px 0 0; min-height: 2px; }
.barra-fatturato { background: linear-gradient(180deg, #4fd9a0, #1f9d73); }
.barra-fornitori { background: linear-gradient(180deg, #ef8a95, #d1495b); }
.barra-spesa { background: linear-gradient(180deg, #f3c56b, #c98a1a); }
.barra-valore { font-size: .68em; color: var(--grigio); margin-bottom: 4px; white-space: nowrap; }
.barra-label { font-size: .75em; color: var(--grigio); margin-top: 6px; }
.grafico-singolo { justify-content: flex-start; }
.grafico-singolo .barra-col { flex: 0 0 140px; }

/* Grafico combinato dashboard */
.legenda-grafico { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 10px; font-size: .85em; color: var(--grigio); }
.legenda-grafico .punto { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.punto-fatturato { background: linear-gradient(180deg, #4fd9a0, #1f9d73); }
.punto-fornitori { background: linear-gradient(180deg, #ef8a95, #d1495b); }
.punto-spesa { background: linear-gradient(180deg, #f3c56b, #c98a1a); }
.grafico-multi { overflow-x: auto; height: 240px; }
.grafico-multi .barra-col { padding: 0 4px; flex: 0 0 auto; min-width: 76px; }
.barre-gruppo { display: flex; align-items: flex-end; gap: 5px; height: 100%; }
.grafico-multi .barra { width: 18px; }
.grafico-multi .barra-valore { font-size: .78em; font-weight: 700; color: var(--blu-scuro); }

.filtri-stat { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; background: #fff; border: 1px solid var(--bordo); padding: 14px 16px; border-radius: 14px; box-shadow: var(--ombra); }
.filtri-stat label { display: block; font-size: .82em; color: var(--grigio); margin-bottom: 4px; }
.filtri-stat select { padding: 7px 9px; border: 1px solid var(--bordo); border-radius: 8px; min-width: 160px; }

.filtri-periodo { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; background: #fff; border: 1px solid var(--bordo); padding: 12px 16px; border-radius: 14px; box-shadow: var(--ombra); }
.filtri-periodo label { display: block; font-size: .82em; color: var(--grigio); margin-bottom: 4px; }
.filtri-periodo select, .filtri-periodo input { padding: 7px 9px; border: 1px solid var(--bordo); border-radius: 8px; }

@page {
    size: A4;
    margin: 15mm;
}
@media print {
    .topbar, .no-print, .section-head, footer { display: none !important; }
    body { background: #fff; }
    .foglio-fattura { border: none; padding: 0; min-height: 267mm; box-sizing: border-box; display: flex; flex-direction: column; box-shadow: none; }
    .container { padding: 0; max-width: none; }
    .bulk-fattura:not(:last-child) { page-break-after: always; }
    .bulk-fattura { margin-bottom: 0; }
}
