:root{--navy:#15274a;--navy2:#20365f;--blue:#476bf0;--light:#eef2fc;--paper:#fff;--bg:#f5f7fb;--ink:#1d2940;--muted:#6b778e;--line:#e2e7f1;--success:#16765b;--warn:#bd6f13;--red:#b8454f;--shadow:0 7px 28px rgba(27,42,73,.06)}
*{box-sizing:border-box}html{font-size:15px}body{margin:0;background:var(--bg);font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:var(--ink)}button,input,select,textarea{font:inherit}button{cursor:pointer}button:disabled{opacity:.55;cursor:wait}input,select,textarea{min-width:0;width:100%;background:#fff;border:1px solid #ced6e5;border-radius:10px;padding:11px 12px;color:var(--ink)}input:focus,select:focus,textarea:focus{outline:2px solid #b6c5ff;border-color:#7e97f7}textarea{resize:vertical;min-height:76px}a{color:var(--blue)}.hidden{display:none!important}
.loading-page{min-height:100dvh;display:flex;align-items:center;justify-content:center;flex-direction:column;color:var(--muted)}.spinner{width:34px;height:34px;border:3px solid #d9e3fa;border-top-color:var(--blue);border-radius:50%;animation:spin .75s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}
.login-layout{min-height:100dvh;display:grid;grid-template-columns:1.03fr 1fr}.hero{background:linear-gradient(142deg,#101e3b 5%,#2d498e 100%);padding:clamp(30px,6vw,90px);color:#fff;display:flex;flex-direction:column;justify-content:center;gap:20px}.brand-mark{width:62px;height:62px;background:linear-gradient(135deg,#febb84,#f08daa);border-radius:20px;display:grid;place-items:center;font-size:26px;font-weight:850;color:#fff;letter-spacing:-3px}.hero h1{font-size:clamp(36px,5vw,68px);line-height:1.05;letter-spacing:-2px;margin:0}.hero p{color:#e4e9f8;font-size:18px;max-width:440px;line-height:1.6}.hero .pill{align-self:flex-start;border:1px solid #ffffff56;padding:9px 14px;border-radius:40px;font-size:13px}.login-pane{display:flex;align-items:center;justify-content:center;padding:26px}.login-card{width:min(100%,420px);background:#fff;border:1px solid var(--line);border-radius:20px;box-shadow:var(--shadow);padding:34px}.login-card h2{margin:0 0 8px;font-size:27px}.login-card p{color:var(--muted);line-height:1.5}.form-stack{display:grid;gap:15px;margin-top:26px}.field{display:grid;gap:6px}.field label{font-size:13px;font-weight:700;color:#43516c}.small{font-size:12px;color:var(--muted)}.notice{padding:14px;border-radius:12px;background:#f0f4ff;color:#435272;font-size:13px;line-height:1.55}.warning{background:#fff4e2;color:#7f5416}.error{background:#fff0f1;color:var(--red)}
.btn{display:inline-flex;justify-content:center;align-items:center;gap:8px;border:1px solid transparent;background:var(--navy);color:#fff;border-radius:10px;padding:11px 15px;font-weight:700;text-decoration:none;white-space:nowrap;line-height:1.2}.btn:hover{filter:brightness(1.08)}.btn.primary{background:var(--blue)}.btn.secondary{color:var(--navy);background:#f1f3fa;border:1px solid var(--line)}.btn.danger{background:#fff0f1;color:var(--red)}.btn.small-btn{font-size:12px;padding:8px 11px}.btn.outline{background:#fff;color:var(--navy);border-color:var(--line)}
.shell{display:grid;grid-template-columns:245px minmax(0,1fr);min-height:100dvh}.sidebar{background:var(--navy);color:#fff;display:flex;flex-direction:column;padding:24px 15px;position:sticky;top:0;height:100dvh}.identity{display:flex;align-items:center;gap:12px;padding:3px 10px 23px}.identity .brand-mark{width:41px;height:41px;font-size:19px;border-radius:13px}.identity strong{font-size:18px}.identity span{font-size:11px;color:#bac7e5;display:block}.nav{display:grid;gap:4px}.nav button{display:flex;gap:12px;align-items:center;text-align:left;width:100%;padding:12px 13px;border:none;border-radius:10px;background:transparent;color:#c9d5ed;font-weight:600}.nav button:hover,.nav button.active{color:#fff;background:#344a72}.nav button .navico{display:inline-grid;place-items:center;width:23px;font-size:18px}.side-bottom{margin-top:auto;padding:15px 9px 6px;border-top:1px solid #ffffff24}.side-bottom .btn{width:100%;background:#ffffff15;border-color:#ffffff36;margin-top:10px}.side-bottom small{color:#b5c4e4;overflow-wrap:anywhere}
.main-area{min-width:0}.topbar{height:75px;background:#fff;border-bottom:1px solid var(--line);padding:0 clamp(18px,3.2vw,48px);display:flex;align-items:center;justify-content:space-between;gap:10px}.topbar .kicker{font-size:12px;color:var(--muted);font-weight:650;letter-spacing:.07em;text-transform:uppercase}.topbar h2{font-size:19px;letter-spacing:-.45px;margin:4px 0 0}.topbar .right{display:flex;align-items:center;gap:8px}.topbar .chip{font-size:12px;background:#edf3ff;color:#405c93;border-radius:100px;padding:8px 11px;font-weight:700}.content{padding:clamp(16px,3vw,42px);max-width:1480px;margin:auto}.section-head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:22px}.section-head h1{font-size:28px;letter-spacing:-.7px;margin:0 0 5px}.section-head p{color:var(--muted);margin:0}.actions{display:flex;flex-wrap:wrap;gap:8px}.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:15px;margin-bottom:21px}.stat-card,.panel{background:#fff;border:1px solid var(--line);border-radius:16px;box-shadow:var(--shadow)}.stat-card{padding:21px}.stat-card .label{font-size:12px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}.stat-card .value{font-size:29px;font-weight:800;letter-spacing:-1px;margin-top:11px}.stat-card .foot{margin-top:7px;color:var(--muted);font-size:12px}.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:18px}.panel{padding:22px;min-width:0}.panel h3{margin:0 0 17px;font-size:17px}.panel-head{display:flex;justify-content:space-between;align-items:center;gap:10px}.muted{color:var(--muted)}.empty{padding:32px 15px;text-align:center;color:var(--muted);background:#f7f9fe;border:1px dashed #d6dfed;border-radius:12px}.table-wrap{overflow-x:auto}.data-table{border-collapse:collapse;width:100%;min-width:670px}.data-table th{text-align:left;font-size:11px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);padding:13px 11px;border-bottom:1px solid var(--line)}.data-table td{padding:14px 11px;border-bottom:1px solid #e9edf5;font-size:13px;vertical-align:middle}.data-table tbody tr:hover{background:#fbfcff}.data-table tr:last-child td{border-bottom:0}.status{display:inline-flex;align-items:center;padding:5px 9px;background:#ebf5f0;color:#16765b;font-size:11px;font-weight:750;border-radius:100px}.status.muted-status{background:#eef0f4;color:#5c677a}.status.warn-status{background:#fff5e5;color:#ab6819}.text-button{border:0;background:none;color:#385eae;font-weight:750;padding:6px;cursor:pointer}.filters{display:flex;gap:10px;margin-bottom:15px;align-items:center}.filters input{max-width:360px}.money{font-variant-numeric:tabular-nums;font-weight:700}.bars{display:grid;gap:13px}.bar-row{display:grid;grid-template-columns:92px 1fr 105px;gap:10px;align-items:center;font-size:12px}.track{background:#eef1f8;border-radius:40px;height:12px;overflow:hidden}.fill{height:100%;background:linear-gradient(90deg,#7082ec,#485dd4);border-radius:40px}.timeline{display:grid;gap:12px}.timeline-item{display:flex;align-items:center;justify-content:space-between;gap:12px;border-bottom:1px solid var(--line);padding-bottom:12px}.timeline-item:last-child{border:0}.timeline .title{font-weight:700;font-size:13px}.timeline .sub{font-size:12px;color:var(--muted);margin-top:5px}
.modal-overlay{position:fixed;inset:0;background:#0f1d37a1;z-index:20;display:flex;align-items:center;justify-content:center;padding:20px;overflow-y:auto}.modal{background:#fff;width:min(700px,100%);border-radius:19px;padding:27px;max-height:min(92dvh,1000px);overflow-y:auto;box-shadow:0 18px 80px #09132e60}.modal h2{margin:0;font-size:23px}.modal-top{display:flex;justify-content:space-between;gap:10px;align-items:flex-start;margin-bottom:17px}.modal-close{background:#eef2f8;color:#3f5070;border:0;border-radius:50%;width:33px;height:33px;font-size:19px}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.span2{grid-column:span 2}.modal-footer{display:flex;justify-content:flex-end;gap:9px;margin-top:24px}.field-hint{font-size:11px;color:var(--muted)}.signature{height:135px;width:100%;border:1px dashed #bcc7dd;border-radius:12px;background:#fcfdff;touch-action:none}.qr-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:15px}.qr-card{border:1px solid var(--line);border-radius:15px;padding:18px;text-align:center;display:grid;place-items:center;gap:8px;background:#fff}.qr-canvas{background:#fff;padding:4px;border-radius:8px}.qr-card strong{font-size:18px}.qr-card small{overflow-wrap:anywhere;font-size:10px;color:var(--muted)}.qr-card .btn{font-size:12px}.toast{position:fixed;bottom:22px;right:22px;z-index:40;background:#182c50;color:#fff;padding:13px 19px;border-radius:11px;box-shadow:var(--shadow);opacity:0;transform:translateY(10px);transition:.2s;pointer-events:none;max-width:min(90vw,420px)}.toast.visible{opacity:1;transform:translateY(0)}.detail-head{display:flex;justify-content:space-between;align-items:center;gap:12px}.info-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}.info-cell{background:#f5f7fb;border-radius:10px;padding:13px}.info-cell small{display:block;color:var(--muted);margin-bottom:6px}.info-cell strong{font-size:14px}.alert-band{background:#fff5e5;border:1px solid #f4dbb0;color:#79551c;padding:12px 15px;border-radius:11px;margin-bottom:20px}.badge-demo{background:#fff3c9;color:#8b6200;border-radius:8px;padding:6px 11px;font-size:12px;font-weight:800}
@media(max-width:1000px){.stats{grid-template-columns:repeat(2,1fr)}.shell{grid-template-columns:76px minmax(0,1fr)}.sidebar{padding:16px 8px}.identity{padding:8px 10px 26px}.identity strong,.identity span,.nav .label-nav,.side-bottom small{display:none}.identity .brand-mark{margin:auto}.nav button{justify-content:center}.side-bottom .btn{font-size:0}.side-bottom .btn:after{content:'↪';font-size:19px}.nav button .navico{font-size:22px}}
@media(max-width:670px){.login-layout{grid-template-columns:1fr}.hero{padding:32px 25px 25px;gap:10px}.hero h1{font-size:37px}.hero p{font-size:14px;margin:0}.hero .pill{display:none}.login-pane{padding:18px 15px 40px}.login-card{padding:23px}.shell{display:block;padding-bottom:73px}.sidebar{position:fixed;bottom:0;top:auto;width:100%;height:67px;z-index:12;padding:5px 7px;background:var(--navy)}.identity,.side-bottom{display:none}.nav{display:flex;justify-content:space-around;gap:0;height:100%}.nav button{flex:1;flex-direction:column;gap:1px;font-size:10px;padding:4px 0}.nav button .label-nav{display:block;font-size:10px}.nav button .navico{font-size:20px}.topbar{height:70px;padding:0 18px}.topbar h2{font-size:17px}.topbar .right .btn{padding:8px 9px;font-size:12px}.topbar .chip{display:none}.content{padding:18px 13px}.section-head{align-items:flex-start}.section-head h1{font-size:23px}.section-head p{font-size:12px}.grid-2{grid-template-columns:1fr}.stats{gap:9px}.stat-card{padding:14px}.stat-card .value{font-size:22px}.stat-card .label{font-size:10px}.panel{padding:14px}.form-grid{grid-template-columns:1fr}.span2{grid-column:span 1}.modal{padding:20px}.modal-overlay{padding:10px}.bar-row{grid-template-columns:64px 1fr 75px}.info-grid{grid-template-columns:1fr 1fr}.filters input{max-width:none}}
@media print{body{background:white}.sidebar,.topbar,.section-head,.qr-card .btn,.toast,.alert-band{display:none!important}.shell{display:block}.content{padding:0}.qr-grid{grid-template-columns:repeat(3,1fr)}.qr-card{break-inside:avoid;box-shadow:none}.qr-canvas{width:4cm!important;height:4cm!important}.qr-canvas canvas{width:4cm!important;height:4cm!important}}

@media print{body:has(#modal) .shell{display:none!important}#modal{display:block;position:static;background:#fff;padding:0;overflow:visible}#modal .modal{max-height:none;overflow:visible;box-shadow:none;width:100%;padding:0}#modal .modal-close,#modal .btn{display:none!important}}

/* v1.1: valori mensili negativi e nota sui margini */
.fill.loss{background:linear-gradient(90deg,#ee9a80,#c45657)}
.chart-note{margin:14px 0 0;line-height:1.5;color:var(--muted)}

/* v1.3: sette schede nella navigazione mobile, scorrimento orizzontale */
@media(max-width:670px){.nav{overflow-x:auto;justify-content:flex-start;scrollbar-width:thin}.nav button{flex:0 0 68px;min-width:68px}.nav button .label-nav{font-size:9px}}

/* v1.5: more modules in mobile nav */
@media(max-width:670px){.nav button{flex:0 0 76px;min-width:76px}}

/* v1.7 - protezione compilazione e stato bozze */
.draft-notice{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;margin:0 0 18px;border:1px solid #cee0f6;background:#f0f7ff;color:#27486d;border-radius:10px;font-size:12px;line-height:1.5}.draft-notice .text-button{flex-shrink:0;color:#8b3147;font-size:12px}.modal-overlay .modal{overscroll-behavior:contain}@media(max-width:520px){.draft-notice{align-items:flex-start;flex-direction:column;gap:5px}}

/* v1.9: indirizzi coincidenti */
.same-address{display:flex;align-items:center;gap:10px;font-size:13px;color:#354662;line-height:1.45;cursor:pointer;background:#f5f8fe;border:1px solid #d7e4f8;border-radius:9px;padding:10px 12px}.same-address input{width:17px;height:17px;flex-shrink:0}.field input[readonly]{background:#f5f7fa;color:#52617b}
