:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --surface-1: #fcfcfb;
  --surface-2: #ecebe5;
  --border: #dedbd1;
  --text-primary: #14181f;
  --text-secondary: #52514e;
  --text-muted: #6b6a66;
  --brand: #14406b;
  --brand-ink: #fbfaf6;
  --flame: #e8892b;
  --series-petrol: #2a78d6;
  --series-gas: #eb6834;
  --grid: #e4e2db;
  --axis: #8a8984;
  --status-good: #0ca30c;
  --status-good-text: #006300;
  --status-warning: #fab219;
  --status-critical: #d03b3b;
  --div-mid: #f0efec;
  --div-neg: #1c5cab;
  --div-pos: #c4471b;
  --seq-lo: #fbeadf;
  --series-electric: #2e9e6b;
  --seq-hi: #a8380f;
  --focus: #2a78d6;
  --radius: 12px;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface-1: #1a1a19;
    --surface-2: #242422;
    --border: #34342f;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #9e9d96;
    --brand: #0e2c4b;
    --series-petrol: #3987e5;
    --series-gas: #d95926;
    --grid: #2c2c29;
    --axis: #7d7c76;
    --status-good-text: #4cc94c;
    --div-mid: #383835;
    --div-neg: #5598e7;
    --div-pos: #e8783f;
    --seq-lo: #3b2c24;
    --series-electric: #36a874;
    --seq-hi: #f2925e;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text-primary); font-size: 15px; line-height: 1.45; }
h1, h2, h3 { font-family: "Space Grotesk", Inter, Arial, sans-serif; margin: 0; line-height: 1.15; }
h1 { font-size: 28px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
a { color: var(--series-petrol); }
button, input, select { font: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* Menu laterale: 4 gruppi (Monitoraggio, Veicoli e scadenze, Analisi, Gestione) */
.sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 232px; background: var(--brand); color: var(--brand-ink);
  display: flex; flex-direction: column; padding: 18px 12px; z-index: 1000; overflow-y: auto; }
.sidebar ~ main { margin-inline-start: 232px; }
.brand { font-family: "Space Grotesk", Inter, sans-serif; font-weight: 700; font-size: 20px; display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; box-shadow: 0 0 0 1.5px rgba(251, 250, 246, 0.35); flex: none; }
.brand .wordmark .link { color: var(--flame); }
.login .brand .logo { width: 48px; height: 48px; border-radius: 12px; box-shadow: none; }
.fleet-name { color: #b9c9db; padding: 4px 8px 0; }
.sidebar nav { flex: 1; margin-top: 14px; }
.nav-group { margin-bottom: 14px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #9fb4cc; padding: 0 10px 4px; font-weight: 600; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; color: var(--brand-ink); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.sidebar nav a .ic { width: 18px; height: 18px; fill: currentColor; opacity: 0.85; flex: none; }
.sidebar nav a.active { background: rgba(255, 255, 255, 0.16); font-weight: 600; box-shadow: inset 3px 0 0 var(--flame); }
[dir="rtl"] .sidebar nav a.active { box-shadow: inset -3px 0 0 var(--flame); }
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.1); }
.sidebar nav a .badge { margin-inline-start: auto; }
.user { font-size: 13px; color: #b9c9db; padding: 8px 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.12); overflow-wrap: anywhere; }
.user .link { color: var(--brand-ink); }
.menu-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar { position: sticky; top: 0; width: auto; inset-block: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; overflow: visible; }
  .sidebar ~ main { margin-inline-start: 0; }
  .fleet-name { display: none; }
  .menu-toggle { display: inline-block; margin-inline-start: auto; background: rgba(255, 255, 255, 0.14); color: var(--brand-ink); border: 0; border-radius: 8px; padding: 6px 12px; }
  .sidebar nav { flex-basis: 100%; display: none; margin-top: 8px; }
  .sidebar.open nav { display: block; }
  .sidebar .user { display: none; }
  .sidebar.open .user { display: block; flex-basis: 100%; }
}

/* Schede della pagina veicolo */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; cursor: pointer; color: var(--text-secondary); font-weight: 600; white-space: nowrap; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--text-primary); border-bottom-color: var(--flame); }

/* Scadenze */
.deadline-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 0; border-top: 1px solid var(--grid); }
.deadline-row:first-of-type { border-top: 0; }
.dl-main { display: flex; gap: 12px; align-items: flex-start; }
.dl-main > .status { min-width: 104px; padding-top: 2px; }
.dl-actions { flex: none; }
.status.muted .dot { background: transparent; border: 1.5px dashed var(--axis); }
.tag-soft { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.dl-group { margin-bottom: 16px; }
.dl-group h2 { display: flex; align-items: center; gap: 8px; }
.badge { background: var(--status-critical); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 12px; margin-inline-start: 4px; }
button.link { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; padding: 0 4px; }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-secondary); }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card h2 { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); margin-bottom: 16px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
@media (max-width: 900px) { .grid.two, .grid.three, .grid.halves { grid-template-columns: 1fr; } }

/* Riquadri numerici */
.stat { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--text-secondary); font-size: 13px; }
.stat .value { font-family: "Space Grotesk", Inter, sans-serif; font-size: 28px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* Tabelle */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: start; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
td.num, th.num { text-align: end; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* Stati: sempre icona + parola, mai solo colore */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.status.good .dot { background: var(--status-good); }
.status.good { color: var(--status-good-text); }
.status.warning .dot { background: var(--status-warning); clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; }
.status.critical .dot { background: var(--status-critical); border-radius: 2px; transform: rotate(45deg); width: 9px; height: 9px; }
.status.info .dot { background: var(--axis); }
.status.muted { color: var(--text-muted); font-weight: 400; }
.status.online .dot { background: var(--status-good); box-shadow: 0 0 0 3px rgba(12, 163, 12, 0.18); }
.fuel-tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); }
.fuel-tag::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: 6px; vertical-align: 0; }
.fuel-tag.LPG::before, .fuel-tag.CNG::before { background: var(--series-gas); }
.gas-type { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.fuel-tag.PETROL::before, .fuel-tag.DIESEL::before { background: var(--series-petrol); }
.fuel-tag.ELECTRIC::before { background: var(--series-electric); }

/* Avvisi */
.alert-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--grid); align-items: start; }
.alert-item:last-child { border-bottom: 0; }
.alert-item .title { font-weight: 600; }
.alert-item .detail { color: var(--text-secondary); font-size: 14px; margin-top: 2px; }
.alert-item .meta { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* Bottoni e moduli */
.btn { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.btn.secondary { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border); }
.btn.danger { background: transparent; color: var(--status-critical); border: 1px solid var(--status-critical); }
.btn:disabled { opacity: 0.55; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
label.field { display: grid; gap: 4px; font-size: 13px; color: var(--text-secondary); }
label.field input, label.field select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-primary); min-width: 0; width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; align-items: end; }
/* Etichette su due righe: i campi della stessa riga restano allineati in basso */
.switch-row { display: flex; gap: 12px; align-items: flex-start; }
.notice { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--text-secondary); }
.token-box { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px dashed var(--axis); padding: 10px 12px; border-radius: 8px; word-break: break-all; font-size: 15px; }
.error-text { color: var(--status-critical); font-size: 14px; }

/* Accesso */
.login { max-width: 380px; margin: 10vh auto; }
.login .brand { color: var(--brand); justify-content: center; margin-bottom: 16px; font-size: 26px; }
.login form { display: grid; gap: 12px; }

/* Mappe di taratura */
.heatmap { display: grid; grid-template-columns: 58px repeat(6, minmax(0, 1fr)); gap: 2px; font-size: 12px; }
.heatmap .ylab { color: var(--text-secondary); font-size: 11px; display: flex; align-items: center; }
.heatmap .xlab { color: var(--text-secondary); font-size: 10px; text-align: center; padding-top: 4px; }
.heatmap .cell { height: 34px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.heatmap .cell.empty { color: var(--text-muted); font-weight: 400; }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); margin-top: 10px; flex-wrap: wrap; }
.heat-legend .bar { height: 10px; width: 160px; border-radius: 5px; }
.axis-note { font-size: 11px; color: var(--text-muted); }

/* Grafici */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 6px; vertical-align: -1px; background: var(--c); }
.tooltip { position: fixed; z-index: 2000; pointer-events: none; background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); min-width: 140px; }
.tooltip .t-head { font-weight: 600; margin-bottom: 4px; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.tooltip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: 6px; }
details.table-view { margin-top: 8px; font-size: 13px; }
details.table-view summary { cursor: pointer; color: var(--text-secondary); }
details.table-view table { margin-top: 6px; }

#fleet-map, #vehicle-map { height: 320px; border-radius: 8px; background: var(--surface-2); }
.map-fallback { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); text-align: center; padding: 16px; }
.leaflet-tooltip.vehicle-label { font-weight: 600; }
/* Veicoli sulla mappa: grigio fermo da tempo, blu in servizio, verde in movimento (pulsa, freccia di marcia) */
.veh-icon { background: none; border: 0; }
.veh { position: relative; display: block; width: 30px; height: 30px; }
.veh-dot { position: absolute; left: 7px; top: 7px; width: 16px; height: 16px; box-sizing: border-box; border-radius: 50%;
  background: #8a8984; border: 2px solid #fcfcfb; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); transition: background .4s; }
.veh.on .veh-dot { background: #14406b; }
.veh.moving .veh-dot { background: #2e9e5b; }
.veh.moving::before { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(46, 158, 91, .45); animation: veh-pulse 1.8s ease-out infinite; }
.veh-arrow { position: absolute; inset: 0; transform: rotate(var(--hd, 0deg)); transition: transform .8s ease; display: none; }
.veh.has-heading .veh-arrow { display: block; }
.veh-arrow::before { content: ""; position: absolute; left: 50%; top: -4px; margin-left: -6px; border-left: 6px solid transparent;
  border-right: 6px solid transparent; border-bottom: 9px solid #2e9e5b; filter: drop-shadow(0 0 1px #fff); }
/* Punto in cui è stato aperto un avviso: spillo arancione con il punto esclamativo */
.alert-pin-icon { background: none; border: 0; }
.alert-pin { position: absolute; left: 3px; top: 0; width: 24px; height: 24px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); background: var(--flame); border: 2px solid #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .45); }
.alert-pin span { display: block; transform: rotate(45deg); color: #fff; font-weight: 800; font-size: 14px;
  line-height: 20px; text-align: center; }
@keyframes veh-pulse { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.9); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .veh.moving::before { animation: none; opacity: .5; } .veh-arrow { transition: none; } }
.live-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.live-grid div { font-size: 13px; color: var(--text-secondary); }
.live-grid b { display: block; font-size: 18px; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.finding { padding: 10px 0; border-bottom: 1px solid var(--grid); }
.finding:last-child { border-bottom: 0; }
.finding p { margin: 4px 0 0; color: var(--text-secondary); font-size: 14px; }
.big-score { font-family: "Space Grotesk", Inter, sans-serif; font-size: 44px; font-weight: 700; line-height: 1; }

/* Arabo: scrittura da destra a sinistra; grafici e mappe restano orientati come gli assi */
[dir="rtl"] body { font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif; }
[dir="rtl"] .chart, [dir="rtl"] svg, [dir="rtl"] .token-box, [dir="rtl"] input[type="number"],
[dir="rtl"] input[type="email"], [dir="rtl"] input[type="date"] { direction: ltr; }
[dir="rtl"] .num { unicode-bidi: plaintext; }
.lang-select { font: inherit; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: inherit; }
.country-info dt { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
.country-info dd { margin: 2px 0 0; }
.country-info ul { margin: 4px 0 0; padding-inline-start: 18px; }
.rule-to-verify { color: var(--text-secondary); }
/* Numeri con segno e unità: sempre letti da sinistra a destra, anche in arabo */
[dir="rtl"] .heatmap, [dir="rtl"] .heat-legend .bar { direction: ltr; }
[dir="rtl"] .live-grid b { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .live-grid b { text-align: right; display: block; }

/* Didascalia normativa sotto le scadenze */
.law-caption { display: block; margin-top: 4px; font-size: 11.5px; line-height: 1.35; color: var(--text-secondary); font-style: italic; }
p.law-caption { margin: 2px 0 0; }

/* Telematica: righe compatte, giorni lavorativi, eventi sulla mappa */
.mini-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--grid); font-size: 14px; }
.mini-row:last-child { border-bottom: 0; }
.monitors { list-style: none; padding: 0; margin: 6px 0 0; columns: 2; font-size: 13px; }
.days { border: 0; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.days legend { margin-bottom: 4px; }
.day { display: inline-flex; gap: 4px; align-items: center; font-size: 14px; }
.tag-warn { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: #fdf0d8; color: #7a4a00; }
.ev-marker { color: var(--flame); font-size: 14px; text-shadow: 0 0 2px #fff; line-height: 14px; text-align: center; }
.topbar nav { flex-wrap: wrap; }

/* Filtri rapidi della lista veicoli */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 13px; font-weight: 600; }
.chip.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.chip.active .muted { color: #b9c9db; }
details.dl-group summary { cursor: pointer; }
.stat .value-text { font-size: 20px; line-height: 1.2; display: block; }
.dl-origin { margin-top: 3px; }
@media (max-width: 640px) {
  .deadline-row { flex-direction: column; }
  .dl-main { flex-direction: column; gap: 4px; }
  .dl-main > .status { min-width: 0; }
}
.stack { display: grid; gap: 16px; align-content: start; }
.stack > .card { margin-bottom: 0; }

/* QR per collegare i telefoni */
.pairing { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.qr-wrap { background: #fff; padding: 6px; border-radius: 8px; border: 1px solid var(--border); line-height: 0; flex: none; }
.qr-wrap svg { width: 170px; height: 170px; }
.pairing > div:last-child { flex: 1; min-width: 180px; }
.pair-code { display: inline-block; font-size: 16px; letter-spacing: 1px; margin-top: 4px; }
.device-list { list-style: none; padding: 0; margin: 0; }
.device-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--grid); }

/* Messaggi con gli autisti */
.messages-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .messages-layout { grid-template-columns: 1fr; } }
.thread-list { padding: 8px; max-height: 70vh; overflow-y: auto; }
.thread { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: start; background: none; border: 0; border-radius: 8px; padding: 10px; cursor: pointer; color: var(--text-primary); }
.thread:hover { background: var(--surface-2); }
.thread.active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--flame); }
.thread-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conv { display: flex; flex-direction: column; gap: 8px; height: 50vh; min-height: 260px; overflow-y: auto; padding: 8px 4px; border-top: 1px solid var(--grid); border-bottom: 1px solid var(--grid); }
.bubble { max-width: 75%; padding: 8px 12px; border-radius: 14px; }
.bubble.mine { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-end-end-radius: 4px; }
.bubble.theirs { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-end-start-radius: 4px; }
.bubble.broadcast { outline: 2px dashed var(--flame); }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-meta { font-size: 11px; opacity: 0.75; margin-top: 3px; }
.composer { display: grid; gap: 8px; margin-top: 10px; }
.composer textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--surface-1); color: var(--text-primary); resize: vertical; }
.composer .quick { display: flex; flex-wrap: wrap; gap: 6px; }
.composer .btn { justify-self: start; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- 0.10: mappa grande, miniature, allegati */
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn.block, .block { display: block; }
.link-btn.block { text-align: start; padding: 4px 0; text-decoration: none; }
.small-btn { padding: 4px 10px; font-size: 12px; }
.map-page { display: grid; grid-template-columns: 300px 1fr; gap: 16px; height: calc(100vh - 120px); min-height: 480px; }
.map-page.fs { position: fixed; inset: 0; z-index: 900; height: 100vh; padding: 12px; background: var(--bg); }
.map-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 14px; }
.map-side input[type=search] { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-primary); }
.map-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.map-veh { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-bottom: 1px solid var(--grid); border-radius: 6px; }
.map-veh.active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--series-petrol); }
.map-veh label { display: flex; gap: 8px; align-items: flex-start; flex: 1; cursor: pointer; min-width: 0; }
.map-veh label > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.map-veh input { margin-top: 4px; accent-color: var(--brand); }
.map-veh .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--axis); margin-top: 5px; flex: none; border: 2px solid var(--surface-1); box-shadow: 0 0 0 1px var(--axis); }
.map-veh .dot.on { background: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.map-route-box { border-top: 1px solid var(--grid); padding-top: 10px; }
.map-main { position: relative; min-height: 0; }
#big-map { height: 100%; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.map-fs-btn { position: absolute; top: 12px; inset-inline-end: 12px; z-index: 500; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
@media (max-width: 900px) {
  .map-page { grid-template-columns: 1fr; grid-template-rows: auto 60vh; height: auto; }
  .map-page.fs { grid-template-rows: 35vh 1fr; }
  .map-side { max-height: 40vh; }
}
.map-overlay { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; flex-direction: column; }
.map-overlay-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-1); flex-wrap: wrap; }
.map-overlay-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.map-overlay-map { flex: 1; }
.alert-item.with-map { grid-template-columns: auto 1fr 150px auto; }
.mini-map { width: 150px; height: 96px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); cursor: zoom-in; overflow: hidden; }
.mini-map:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mini-map .leaflet-interactive { cursor: zoom-in; }
@media (max-width: 640px) {
  .alert-item.with-map { grid-template-columns: auto 1fr; }
  .alert-item.with-map .mini-map { grid-column: 1 / -1; width: 100%; height: 120px; }
}
.pos-cell { min-width: 180px; max-width: 260px; }
.pos-links { margin-top: 2px; font-size: 13px; }
.span-2 { grid-column: span 2; }
@media (max-width: 640px) { .span-2 { grid-column: auto; } }
.inline-search { display: flex; gap: 8px; }
.inline-search input { flex: 1; }
.zone-results { margin: 8px 0; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }
.attach-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; }
.attach-btn { cursor: pointer; padding: 6px 12px; font-size: 13px; }
.att-img img { display: block; max-width: 240px; max-height: 200px; border-radius: 8px; margin-bottom: 4px; }
.att-file { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); color: inherit; text-decoration: none; margin-bottom: 4px; }
.bubble.mine .att-file { background: rgba(255,255,255,.18); color: inherit; }
.map-side .card-head { flex-wrap: nowrap; gap: 8px; }
.map-side .card-head h2 { font-size: 16px; margin: 0; }
.map-side .card-head > span { white-space: nowrap; font-size: 13px; }
/* Mappa a tutto schermo (pulsante ⛶ su ogni mappa) */
.leaflet-container.map-is-fs { position: fixed !important; inset: 0; width: 100vw !important; height: 100vh !important; z-index: 1200; border-radius: 0 !important; margin: 0 !important; }
body.has-map-fs { overflow: hidden; }
.map-fs-ctl { font-size: 18px; line-height: 30px !important; text-align: center; font-weight: 700; text-decoration: none; color: var(--text-primary) !important; }
.mini-map.empty { display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px; font-size: 12px; color: var(--text-muted); cursor: default; background: var(--surface-2); }
/* Ricerca tra le conversazioni */
.thread-search { width: 100%; box-sizing: border-box; padding: 8px 10px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-primary); }
.thread[hidden], .map-veh[hidden] { display: none; }

/* Dati del veicolo in sola lettura finché non si preme «Modifica dati veicolo» */
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.plain-fieldset:disabled input, .plain-fieldset:disabled select { background: var(--surface-2); color: var(--text-primary); opacity: 1; cursor: default; }

/* Salute del mezzo: motivi dello stato */
.health-reasons { margin: 4px 0 10px; padding-left: 18px; font-size: 14px; }
.health-reasons li { margin: 2px 0; }
