:root{color-scheme:dark;--bg:#0b1220;--panel:#172235;--panel2:#222f45;--line:#35435b;--text:#f2f5f9;--muted:#a4afbe;--accent:#ffb63b;--green:#43d199;--blue:#42a9f7;--red:#f46f7c}*{box-sizing:border-box}html,body{margin:0;padding:0;min-height:100%;background:var(--bg);color:var(--text);font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif}body{padding-bottom:env(safe-area-inset-bottom)}button,input,textarea{font:inherit}button{cursor:pointer;border:0;border-radius:11px;min-height:43px;padding:10px 14px;font-weight:700;color:var(--text);touch-action:manipulation}button:disabled{opacity:.4;cursor:not-allowed}.appbar{height:70px;display:flex;align-items:center;justify-content:space-between;padding:10px 14px;gap:12px;border-bottom:1px solid var(--line)}.branding{display:flex;align-items:center;gap:10px}.logo{font-size:31px;color:var(--accent)}.branding h1{font-size:19px;line-height:1.05;margin:0}.branding small{font-size:9px;letter-spacing:.08em;color:var(--muted)}.gps-chip{font-size:11px;white-space:nowrap;background:#334058;padding:7px 9px;border-radius:999px}.gps-chip.ok{background:#114838;color:#94ffce}.gps-chip.err{background:#532935;color:#ffc0c0}main{max-width:900px;margin:auto}.map-wrap{position:relative;height:min(49vh,500px);min-height:310px;background:#1e293b;overflow:hidden}#map{width:100%;height:100%}.map-overlay{position:absolute;z-index:450;bottom:43px;left:10px;right:10px;display:flex;align-items:center;justify-content:space-between;gap:8px;pointer-events:none}#mapStatus{background:#111c31eb;padding:7px 10px;border-radius:9px;font-size:12px;max-width:80%;box-shadow:0 2px 15px #0006}.iconbtn{pointer-events:auto;background:#1a2b46;color:white;box-shadow:0 1px 10px #000a;border:1px solid #445775;min-width:44px}.legend{position:absolute;z-index:450;bottom:9px;left:9px;border-radius:7px;background:#111c31df;padding:6px 10px;display:flex;gap:12px;font-size:11px}.dot{display:inline-block;width:9px;height:9px;border-radius:50%;margin-right:3px}.dot.blue{background:var(--blue)}.dot.orange{background:var(--accent)}.dot.green{background:var(--green)}.map-error{position:absolute;inset:0;display:grid;place-content:center;padding:30px;color:white;text-align:center;background:#1f283b;z-index:1000}.controls,.panel{background:var(--panel);margin:12px;border:1px solid var(--line);border-radius:15px;padding:13px}.mode-select{display:grid;grid-template-columns:1fr 1fr;gap:8px}.tab{background:var(--panel2);color:#b8c6d7;font-size:13px}.tab.selected{background:#4b390f;color:#ffdb8c;outline:1px solid #9b6b21}.summary{display:flex;justify-content:space-around;padding:14px 0}.summary div{display:flex;flex-direction:column;align-items:center;gap:3px}.summary small{font-size:10px;color:var(--muted);letter-spacing:.1em}.summary strong{font-size:22px}.button-row{display:flex;align-items:center;gap:8px}.button-row>button{flex:1}.button-row.wrap{flex-wrap:wrap}.button-row.wrap>button{flex:auto}.primary{background:var(--accent);color:#1d222d}.danger{background:#a9354b}.secondary{background:var(--panel2);border:1px solid #43556f}.info{padding:12px;margin-top:10px;background:#1e3143;border-left:3px solid var(--blue);border-radius:8px;font-size:12px;color:#d3e0ef;line-height:1.5}.panel-heading{display:flex;align-items:center;justify-content:space-between;gap:10px}h2{font-size:17px;margin:0}p{color:var(--muted);line-height:1.5}.panel-heading p{font-size:12px;margin:4px 0 0}.text-btn{background:transparent;color:var(--accent);padding:7px;min-height:35px;white-space:nowrap}.warn{color:var(--red)}.stop-list{display:grid;gap:9px;margin-top:10px}.stop-card{background:var(--panel2);border:1px solid #354962;border-radius:12px;padding:11px;display:grid;grid-template-columns:33px minmax(0,1fr) auto;align-items:start;gap:10px}.stop-id{width:32px;height:32px;border-radius:50%;display:grid;place-items:center;font-weight:800;background:#6d4f18;color:#ffe4ab}.stop-id.done{background:#125e41;color:#d3ffe9}.stop-data{min-width:0}.stop-data strong{display:block;font-size:14px;overflow-wrap:anywhere}.stop-data span{display:block;font-size:12px;color:var(--muted);margin-top:3px;overflow-wrap:anywhere}.stop-data small{display:block;color:#efc779;margin-top:5px;font-size:11px}.stop-actions{display:flex;flex-direction:column;gap:6px}.stop-actions button{min-height:32px;padding:6px 9px;background:#334861;font-size:12px}.stop-actions button.done{background:#125e41}.stop-actions button.undo{background:#44506c}.empty{text-align:center;font-size:13px;padding:12px}.next-banner{margin-top:10px;padding:12px;background:#113d34;border:1px solid #266a58;border-radius:9px;font-size:13px;line-height:1.5}.tools p{font-size:13px}.micro{font-size:11px!important;color:#a6b2c2;line-height:1.6}dialog{background:#172235;color:var(--text);border:1px solid #52617b;border-radius:16px;width:min(93vw,540px);box-shadow:0 20px 100px #000c;max-height:90vh;overflow:auto}dialog::backdrop{background:#02070dc9}dialog form{display:grid;gap:12px}dialog label{display:grid;gap:5px;font-size:12px;color:#d2dbe6}dialog input:not([type=checkbox]),dialog textarea{background:#263850;color:var(--text);border:1px solid #566c87;border-radius:8px;padding:11px;width:100%;font-size:16px}dialog .checkrow{display:flex;align-items:center;font-size:13px;gap:8px}dialog .coords{font-size:11px;color:var(--muted)}.dialog-actions{display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end}.dialog-actions button{font-size:12px;min-height:37px}.hidden{display:none!important}.toast{position:fixed;bottom:24px;left:50%;transform:translateX(-50%);background:#233e56;color:#fff;padding:12px 18px;border-radius:12px;z-index:3000;max-width:92vw;box-shadow:0 6px 25px #0008;font-size:13px;text-align:center}.leaflet-container{background:#233347}.leaflet-popup-content,.leaflet-popup-content-wrapper{background:#18263c;color:#fff}.leaflet-popup-tip{background:#18263c}.leaflet-control-attribution{font-size:9px!important}@media(min-width:720px){main{display:grid;grid-template-columns:1fr 320px;align-items:start;gap:0 0}.map-wrap{grid-column:1;grid-row:1/4;height:calc(100vh - 85px);min-height:550px;position:sticky;top:5px}.controls,.panel{grid-column:2;margin:8px}.button-row{flex-wrap:wrap}.button-row>button{min-width:47%}.summary strong{font-size:18px}}

/* v0.3 — Stato consegnato permanente e leggibile sul telefono */
.stop-card.delivered{border-color:#26785c;background:#193c36}
.delivery-completed{display:inline-block;margin-top:8px;padding:7px 10px;border-radius:8px;background:#0a6045;border:1px solid #40b88b;color:#f2fff8;font-size:12px;font-weight:900;letter-spacing:.025em;line-height:1.35}
.stop-data .delivery-timestamp{color:#b8f5d9;font-size:11px;margin-top:4px}
.stop-actions button.done{background:#126448;border:1px solid #3fbd8c;color:#fff}
.dialog-delivery-status{padding:10px;border-radius:9px;border:1px solid #52617b;font-size:12px;font-weight:700;color:#cbd5e3}
.dialog-delivery-status.delivered{background:#0c4936;border:1px solid #2dac7c;color:#b9ffe0}
@media(max-width:430px){.stop-card{grid-template-columns:33px minmax(0,1fr);}.stop-actions{grid-column:2;display:flex;flex-direction:row;flex-wrap:wrap}.stop-actions button{flex:1;min-height:40px}}

/* v0.4 — Tre azioni distinte, sempre una sotto l'altra, su PC e Android. */
.stop-card{grid-template-columns:33px minmax(0,1fr);}
.stop-actions{grid-column:1/-1;display:grid;grid-template-columns:minmax(0,1fr);gap:7px;margin-top:3px;}
.stop-actions button{width:100%;min-height:45px;padding:10px 12px;font-size:13px;line-height:1.2;text-align:center;}
.stop-actions button.done{background:#126448;border:1px solid #3fbd8c;color:#fff;}
.stop-actions button.done.is-completed{background:#0b6343;border:1px solid #51d7a2;color:#fff;opacity:1;cursor:default;}
.stop-actions button.edit-stop{background:#344b68;border:1px solid #5a7295;color:#fff;}
.stop-actions button.undo{background:#794149;border:1px solid #b36c78;color:#fff;}
.stop-actions button.undo:disabled{background:#3a4656;border-color:#506075;color:#d3d8e1;opacity:.55;cursor:not-allowed;}
@media(max-width:430px){.stop-actions{grid-column:1/-1;display:grid;grid-template-columns:1fr;}.stop-actions button{flex:none;min-height:46px;}}

/* v0.6 — Ripartenza dal principio e diario giornaliero */
.start-over-btn{background:#20466a;border:1px solid #6191c1;color:#f0f8ff;flex-basis:100%!important;font-size:13px;letter-spacing:.02em;min-height:50px}
.start-marker{display:grid;place-items:center;width:34px;height:34px;border:3px solid #fefefe;border-radius:50%;background:#7c3aed;color:#fff;font-weight:900;box-shadow:0 2px 12px #000a}
.diary-panel{border-color:#436688}
.diary-heading p{font-size:12px;margin:5px 0 12px}
.diary-panel>label{display:block;font-size:12px;color:#c5d2e4;margin-bottom:6px}
.diary-panel select{width:100%;min-height:46px;padding:8px 12px;border-radius:10px;background:#273850;border:1px solid #5e7392;color:#fff;font-size:16px}
.diary-summary{font-weight:700;font-size:12px;color:#bde4fd;background:#17334e;padding:9px;border-radius:8px;margin-top:10px}
.diary-list{display:grid;gap:12px;margin-top:12px;max-height:430px;overflow:auto}
.diary-group{border:1px solid #405373;border-radius:11px;padding:10px;background:#202e44}
.diary-group h3{font-size:14px;margin:0 0 5px}
.diary-shift,.diary-empty{font-size:11px;margin:4px 0 8px}
.diary-event{display:grid;grid-template-columns:66px minmax(0,1fr);gap:9px;border-top:1px solid #42516b;padding:9px 0;font-size:11px}
.diary-event time{font-size:12px;color:#a7c9df;font-weight:800;font-variant-numeric:tabular-nums}
.diary-event strong{display:block;overflow-wrap:anywhere}
.diary-event small{display:block;color:#b2c0d1;margin-top:4px;overflow-wrap:anywhere}
.diary-undone strong{color:#ffa6af}
.diary-delivered strong{color:#a0f5cd}
.diary-buttons{display:grid;grid-template-columns:1fr;gap:8px;margin-top:12px}
.diary-buttons button{min-height:46px}
.diary-buttons .primary{background:#46d39b;color:#082719}

/* v0.7 — Comandi vocali e indicatore visivo grande delle consegne */
.voice-controls{margin-top:12px;padding:12px;border:1px solid #45617f;border-radius:11px;background:#1a2c44}
.voice-control-buttons{display:grid;grid-template-columns:minmax(0,1fr) 112px;gap:8px}
.voice-control-buttons button{min-height:49px;font-size:12px;padding:8px;color:#fff}
.voice-toggle{background:#18694b;border:1px solid #40b78b}
.voice-toggle[aria-pressed="false"]{background:#444c5b;border-color:#5f7088}
.voice-test{background:#345376;border:1px solid #688eb9}
.voice-help{margin:8px 0 0;font-size:11px;color:#bdd0e7}
.voice-arrival-banner{margin-top:10px;padding:13px;border-radius:10px;font-size:14px;font-weight:900;line-height:1.5;overflow-wrap:anywhere}
.voice-arrival-banner.approaching{background:#514010;border:2px solid #ecc04f;color:#fff3bc}
.voice-arrival-banner.at-stop{background:#0b644b;border:2px solid #65e7b4;color:#fff;font-size:16px}
@media(max-width:400px){.voice-control-buttons{grid-template-columns:1fr}.voice-arrival-banner.at-stop{font-size:15px}}

/* v0.8 — Archivio percorsi, pulsanti comodi anche da telefono */
.routes-panel{border-color:#60809e}
.routes-intro{font-size:13px;margin:9px 0 12px}
.active-route{background:#173a3f;border:1px solid #2a8c78;border-radius:12px;padding:12px;margin-bottom:14px;display:flex;flex-direction:column;gap:5px}
.active-route small{font-size:10px;color:#b3e9de;letter-spacing:.1em}
.active-route strong{font-size:16px;overflow-wrap:anywhere}
.route-name-label{display:block;font-size:12px;color:#d0dfec;margin-bottom:6px}
.route-name-row{display:flex;gap:8px;align-items:stretch}
.route-name-row input{flex:1;min-width:0;border:1px solid #617995;background:#283a54;color:#fff;padding:11px;border-radius:10px;font-size:16px}
.route-name-row button{white-space:nowrap;font-size:12px}
.route-main-actions{display:grid;grid-template-columns:1fr;gap:8px;margin-top:12px}
.route-main-actions button{min-height:78px;font-size:14px}
.route-new-btn{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;width:100%;padding:14px 10px;text-align:center;line-height:1.35;white-space:normal}
.route-new-btn strong{font-size:15px;letter-spacing:.02em}
.route-new-btn span{display:block;font-size:12px;font-weight:550;opacity:.95}
.routes-panel h3{font-size:14px;display:flex;justify-content:space-between;align-items:center;margin:18px 0 6px;gap:8px}
.routes-panel h3 small{font-size:11px;color:#b0c1d0;font-weight:400}
.archive-list{display:grid;gap:9px}
.archive-item{background:#22324a;border:1px solid #425e7b;border-radius:12px;padding:12px;display:grid;gap:10px}
.archive-details{display:grid;gap:5px;min-width:0;overflow-wrap:anywhere}
.archive-details small{font-size:11px;color:#bbcada}
.archive-actions{display:grid;grid-template-columns:1fr 1fr;gap:7px}
.archive-actions button{font-size:12px;min-height:43px}
.archive-actions .archive-delete{grid-column:1 / -1;background:#5b3242;color:#ffced4}
@media(max-width:390px){.route-name-row{flex-direction:column}}

/* v0.9.1: Nuovo percorso e ultimo comando nella sezione Salvataggio e sicurezza. */
.tools #resetBtn{flex:1 1 100%;}

/* v0.9.2 — Protezione schermo: stato reale, non promessa di GPS in background. */
.screen-guard-box{margin:12px 0;padding:10px 12px;background:#202f46;border:1px solid #526b88;border-radius:11px}
.screen-guard-status{display:block;padding:8px 12px;border-radius:8px;text-align:center;font-weight:850;letter-spacing:.03em;font-size:14px;background:#32445e;color:#f2f6ff}
.screen-guard-status.active{background:#0c6448;border:1px solid #48bb93;color:#f4fff9}
.screen-guard-status.pending{background:#3e4c64;color:#eaf2ff}
.screen-guard-status.retry,.screen-guard-status.hidden{background:#71401a;border:1px solid #eea65b;color:#fff1db}
.screen-guard-status.unsupported{background:#793540;border:1px solid #f08f95;color:#fff3f5}
.screen-guard-help{font-size:11px;margin:8px 1px 0;color:#c6d4e7;line-height:1.5}
