﻿/* ─────────────────────────────────────────────────────────────────────────────
   Crisab — tema "nerazzurro": nero, blu Inter e oro.
   Mobile-first: navigazione inferiore sul telefono, schede orizzontali da
   tablet/desktop, con la stessa base di componenti.
   ───────────────────────────────────────────────────────────────────────────── */

:root {
    --bg: #05080F;
    --bg-soft: #0A101C;
    --card: rgba(13, 20, 34, 0.92);
    --card-solid: #0E1626;
    --card-soft: #111C2F;
    --field: #0A1322;
    --line: rgba(120, 165, 255, 0.16);
    --text: #F3F7FF;
    --muted: #8FA3C2;
    --accent: #0A63D8;
    --accent-bright: #3D8BFF;
    --accent-2: #D4AF37;
    --accent-soft: rgba(10, 99, 216, 0.14);
    --gold: #D4AF37;
    --gold-bright: #F0C75E;
    --gold-soft: rgba(212, 175, 55, 0.14);
    --navy: #050A14;
    --navy-2: #0A1A33;
    --ok: #35C77A;
    --warn: #E0B34A;
    --bad: #FF5C63;
    --radius: 20px;
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
    --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.28);
    --backdrop: rgba(2, 5, 10, 0.72);
    --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(900px 520px at 8% -12%, rgba(61, 139, 255, 0.20), transparent 62%),
        radial-gradient(760px 420px at 100% 0%, rgba(212, 175, 55, 0.07), transparent 58%),
        var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

/* ── shell ─────────────────────────────────────────────────────────────── */
.app {
    max-width: 1320px;
    margin: 0 auto;
    padding: clamp(14px, 2.2vw, 30px);
    padding-bottom: 40px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: clamp(14px, 2vw, 24px);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
    width: 44px; height: 44px; border-radius: 14px;
    display: grid; place-items: center;
    background: repeating-linear-gradient(135deg,
        var(--accent) 0 7px, #05080F 7px 14px);
    box-shadow: 0 8px 22px rgba(10, 99, 216, 0.35),
                inset 0 0 0 2px rgba(212, 175, 55, 0.80);
    font-weight: 800; font-size: 18px; color: #ffffff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
}

.brand-txt strong { display: block; font-size: 17px; letter-spacing: 0.14em; }
.brand-txt strong::first-letter { color: var(--gold); }
.brand-txt span { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }

.top-actions { display: flex; align-items: center; gap: 10px; }

.pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 999px;
    background: var(--card); border: 1px solid var(--line);
    font-size: 12.5px; color: var(--muted); white-space: nowrap;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--ok); box-shadow: 0 0 12px var(--ok); }
.dot.demo { background: var(--warn); box-shadow: 0 0 12px var(--warn); }
.dot.off { background: var(--bad); }

.icon-btn {
    width: 42px; height: 42px; border-radius: 13px;
    display: grid; place-items: center;
    background: var(--card); border: 1px solid var(--line);
    color: var(--text); font-size: 17px;
    transition: transform .15s ease, border-color .15s;
}
.icon-btn:hover { transform: translateY(-1px); border-color: rgba(120,165,255,.34); box-shadow: var(--shadow-soft); }

/* ── tabs ──────────────────────────────────────────────────────────────── */
.tabs {
    display: flex; gap: 6px; padding: 6px;
    background: rgba(10, 17, 29, 0.78);
    border: 1px solid var(--line);
    border-radius: 16px;
    margin-bottom: clamp(16px, 2vw, 24px);
    overflow-x: auto;
    scrollbar-width: none;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    flex: 1 0 auto;
    padding: 11px 20px;
    border-radius: 11px;
    color: var(--muted);
    font-size: 14px; font-weight: 600;
    letter-spacing: .02em;
    transition: background .18s, color .18s;
    white-space: nowrap;
}
.tab.active {
    background: linear-gradient(145deg, #2F86FF 0%, #0A63D8 55%, #073B7A 100%);
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(10, 99, 216, 0.35),
                inset 0 -2px 0 var(--gold);
}
.tab:hover:not(.active) { color: var(--accent-bright); }

.panel { display: none; animation: fade .25s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ── hero ──────────────────────────────────────────────────────────────── */
.hero {
    display: grid;
    grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.6fr);
    gap: clamp(14px, 2vw, 22px);
    margin-bottom: clamp(14px, 2vw, 22px);
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    padding: clamp(16px, 2vw, 24px);
}

.soc-card {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    background:
        radial-gradient(420px 240px at 82% -10%, rgba(61, 139, 255, 0.42), transparent 68%),
        radial-gradient(280px 190px at 0% 105%, rgba(212, 175, 55, 0.16), transparent 72%),
        linear-gradient(155deg, #0A1526 0%, var(--navy) 56%, #0A2E63 100%);
    border-color: rgba(212, 175, 55, 0.28);
    color: #ffffff;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.50),
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.soc-card .gauge .track { stroke: rgba(255, 255, 255, 0.14); }
.soc-card .gauge-label b { color: #ffffff; }
.soc-card .gauge-label span { color: #9fc3ff; }
.soc-card .pill {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.16);
    color: #dbe8ff;
}

.gauge { position: relative; width: min(210px, 46vw); aspect-ratio: 1; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge .track { fill: none; stroke: rgba(255,255,255,.12); stroke-width: 12; }
.gauge .bar { fill: none; stroke: url(#socGrad); stroke-width: 12; stroke-linecap: round;
              transition: stroke-dashoffset .8s ease; }
.gauge-label {
    position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.gauge-label b { font-size: clamp(38px, 5.4vw, 56px); font-weight: 700; letter-spacing: -.02em; }
.gauge-label span { font-size: 12px; color: var(--muted); letter-spacing: .18em; text-transform: uppercase; }

.hero-side { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.stat {
    background: var(--card-soft);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    display: flex; flex-direction: column; gap: 6px;
}
.stat .k { font-size: 11.5px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; }
.stat .v { font-size: clamp(22px, 2.8vw, 30px); font-weight: 700; letter-spacing: -.02em; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }

.charge-strip { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
.charge-bar { flex: 1; height: 8px; border-radius: 99px; background: rgba(255,255,255,.10); overflow: hidden; }
.charge-bar i { display: block; height: 100%; border-radius: 99px;
                background: linear-gradient(90deg, var(--accent), var(--accent-bright) 72%, var(--gold));
                transition: width .6s cubic-bezier(.2,.8,.2,1); }

/* ── griglia ───────────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(12px, 1.6vw, 18px); }

.tile { padding: 18px; }
.tile h3 {
    font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 14px; display: flex; justify-content: space-between;
}
.tile h3 .state { color: var(--text); letter-spacing: 0; text-transform: none; font-size: 12.5px; }

.rows { display: flex; flex-direction: column; gap: 9px; }
.row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.row span:first-child { color: var(--muted); }
.row b { font-weight: 600; }

.badge-ok { color: var(--ok); }
.badge-bad { color: var(--bad); }

/* porte/finestrini */
.car-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.car-part {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 11px; border-radius: 11px;
    background: var(--card-soft); border: 1px solid var(--line);
    font-size: 13px;
}
.car-part.open { border-color: rgba(255, 92, 99, .40); background: rgba(255, 92, 99, .09); }
.car-part i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.car-part.open i { background: var(--bad); }
.car-mini .car-part[data-part="trunk"] { grid-column: 1 / -1; }

/* pneumatici */
.tires { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tire {
    padding: 10px; border-radius: 12px; text-align: center;
    background: var(--card-soft); border: 1px solid var(--line);
}
.tire b { display: block; font-size: 18px; }
.tire span { font-size: 11px; color: var(--muted); }
.tire.low b { color: var(--bad); }

/* ricarica */
.charge-big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.charge-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* mappa */
.map {
    height: 130px; border-radius: 12px;
    background:
        linear-gradient(rgba(61,139,255,.08) 1px, transparent 1px) 0 0 / 22px 22px,
        linear-gradient(90deg, rgba(61,139,255,.08) 1px, transparent 1px) 0 0 / 22px 22px,
        #0A1322;
    border: 1px solid var(--line);
    position: relative; overflow: hidden;
}
.map .pin {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
    box-shadow: 0 0 0 8px rgba(61,139,255,.16), 0 0 22px rgba(61,139,255,.60);
}
.map .coords { position: absolute; left: 10px; bottom: 8px; font-size: 11px; color: var(--muted); }

/* ── viaggi ────────────────────────────────────────────────────────────── */
.trips-overview { padding: clamp(16px, 2vw, 22px); }
.trips-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.trips-period {
    display: flex; gap: 4px; margin-top: 10px;
    background: var(--card-soft); border: 1px solid var(--line);
    border-radius: 11px; padding: 4px; overflow-x: auto; scrollbar-width: none;
}
.trips-period::-webkit-scrollbar { display: none; }
.trips-period button {
    padding: 7px 11px; border-radius: 8px; white-space: nowrap;
    color: var(--muted); font-size: 12px; font-weight: 600;
    transition: background .16s, color .16s;
}
.trips-period button.on {
    background: linear-gradient(145deg, #2F86FF, #073B7A);
    color: #fff;
    box-shadow: inset 0 -2px 0 var(--gold);
}
.trips-period button:active { transform: scale(.96); }

.trips-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.trip-kpi {
    background: var(--card-soft); border: 1px solid var(--line);
    border-radius: 14px; padding: 12px 14px; min-width: 0;
}
.trip-kpi span {
    display: block; color: var(--muted); font-size: 10px;
    letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.trip-kpi b { display: inline-block; font-size: 24px; letter-spacing: -.02em; margin-top: 3px; }
.trip-kpi small { color: var(--muted); font-size: 12px; margin-left: 4px; }
.trip-kpi.hero-kpi {
    background: linear-gradient(145deg, #0A63D8 0%, #073B7A 45%, var(--navy) 100%);
    border-color: rgba(212, 175, 55, 0.30); color: #fff;
}
.trip-kpi.hero-kpi span, .trip-kpi.hero-kpi small { color: #9fc3ff; }

.trip-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; color: var(--muted); font-size: 12.5px; }
.trip-facts b { color: var(--text); font-weight: 600; }
.trip-quality-line { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.trip-quality-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

.trip-help { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.trip-help summary { cursor: pointer; color: var(--accent); font-size: 12.5px; font-weight: 600; }
.trip-help p { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.trip-help .quality-badge { vertical-align: middle; }

.trips-list-card { margin-top: 16px; }
.trips-list-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 6px; }
.trip-range { font-size: 12px; color: var(--muted); }
.trip-day { margin-top: 12px; }
.trip-day:first-child { margin-top: 4px; }
.trip-day-head {
    display: flex; justify-content: space-between; gap: 10px;
    padding: 8px 2px; border-bottom: 1px solid var(--line);
    font-size: 12px; color: var(--muted);
}
.trip-day-head b { color: var(--text); font-size: 13px; }

.trip {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 14px; padding: 11px 2px;
    border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.trip:last-child { border-bottom: 0; }
.trip-when { grid-column: 1; grid-row: 1; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.trip-cost { grid-column: 2; grid-row: 1; text-align: right; font-weight: 700; color: var(--accent); white-space: nowrap; }
.trip-cost small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; margin-top: 1px; }
.trip-main { grid-column: 1; grid-row: 2; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.trip-main b { font-size: 14.5px; }
.trip-main span { color: var(--muted); font-size: 12px; }
.trip-q { grid-column: 2; grid-row: 2; justify-self: end; align-self: center; }
.trip.open { background: rgba(61,139,255,.08); border-radius: 10px; padding-left: 8px; padding-right: 8px; }
.trip.open .trip-when { color: var(--accent-bright); font-weight: 600; }
.trip { cursor: pointer; }
.trip.selected {
    background: rgba(61,139,255,.10);
    border-radius: 10px; padding-left: 8px; padding-right: 8px;
    box-shadow: inset 3px 0 0 var(--accent-bright);
}
.trip.selected .trip-main b { color: var(--accent-bright); }

/* contachilometri virtuale */
.meter-card { margin-top: 16px; }
.btn.meter-reset {
    width: auto; padding: 6px 12px; font-size: 11.5px; border-radius: 9px;
    letter-spacing: .04em; box-shadow: none;
}
.meter-seg { width: fit-content; max-width: 100%; margin-bottom: 14px; }
.meter-seg button { white-space: nowrap; }
.meter-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.meter-history { margin-top: 10px; }
.meter-cycle {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 12px; align-items: center;
    padding: 10px 2px; border-bottom: 1px solid var(--line);
}
.meter-cycle:last-child { border-bottom: 0; }
.meter-cycle-when b { font-size: 14.5px; }
.meter-cycle-when span, .meter-cycle-nums span {
    display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px;
}
.meter-cycle-nums { text-align: right; }
.meter-cycle-nums b { font-size: 13px; }
.meter-cycle-cost { text-align: right; font-weight: 700; color: var(--accent); font-size: 13px; white-space: nowrap; }

/* percorso del viaggio */
.trip-route-card { margin-top: 16px; }
.leaflet-map.trip-map { height: 280px; border-radius: 12px; overflow: hidden; }
.trip-route-foot {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; margin-top: 10px; flex-wrap: wrap;
}
.trip-route-stats { color: var(--muted); font-size: 12.5px; }
.btn.trip-route-link { width: auto; padding: 8px 12px; font-size: 12px; border-radius: 9px; }
.btn.trip-route-link.disabled { opacity: .45; pointer-events: none; }

@media (max-width: 720px) {
    .meter-kpis { grid-template-columns: 1fr 1fr; }
    .meter-seg { width: 100%; }
    .meter-seg button { flex: 1; }
    .leaflet-map.trip-map { height: 240px; }
}
@media (max-width: 460px) {
    .meter-cycle { grid-template-columns: minmax(0, 1fr) auto; }
    .meter-cycle-cost { display: none; }
    .leaflet-map.trip-map { height: 220px; }
}

.empty { padding: 34px; text-align: center; color: var(--muted); font-size: 14px; }

/* ── comandi ───────────────────────────────────────────────────────────── */
.cmd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.cmd {
    display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
    padding: 18px; border-radius: 16px;
    background: var(--card-soft); border: 1px solid var(--line);
    text-align: left; transition: transform .18s ease, border-color .18s, background .18s, box-shadow .18s;
}
.cmd:hover:not([disabled]) { transform: translateY(-2px); border-color: rgba(61,139,255,.46); background: rgba(61,139,255,.08); box-shadow: var(--shadow-soft); }
.cmd[disabled] { opacity: .45; cursor: not-allowed; }
.cmd i { font-size: 22px; font-style: normal; }
.cmd b { font-size: 14.5px; }
.cmd small { color: var(--muted); font-size: 12px; }

.notice {
    padding: 14px 16px; border-radius: 14px; font-size: 13.5px;
    background: rgba(61, 139, 255, .10); border: 1px solid rgba(61, 139, 255, .28);
    color: #A8CDFF; margin-bottom: 16px;
}

/* clima: pannello con temperatura, durata e comfort */
.cmd-climate { margin-bottom: 16px; }
.cmd-climate .hint { margin-top: 10px; }
#cmd-climate-state.on { color: var(--ok); }
#cmd-climate-state.off { color: var(--muted); }

.climate-setpoint {
    display: grid; grid-template-columns: 46px minmax(0, 1fr) 46px;
    align-items: center; gap: 10px; margin-top: 2px;
}
.climate-step {
    width: 46px; height: 46px; border-radius: 50%;
    background: var(--field); border: 1px solid var(--line);
    color: var(--accent-bright); font-size: 24px; line-height: 1;
    transition: border-color .18s, background .18s, transform .18s;
}
.climate-step:hover { border-color: rgba(61,139,255,.55); background: rgba(61,139,255,.12); }
.climate-step:active { transform: scale(.94); }
.climate-temp-box { text-align: center; min-width: 0; }
.climate-temp-box label {
    display: block; color: var(--muted); font-size: 10px;
    letter-spacing: .14em; text-transform: uppercase;
}
.climate-temp-value {
    display: flex; align-items: baseline; justify-content: center; gap: 4px;
}
.climate-temp-value input {
    width: 110px; padding: 0; background: transparent; border: 0;
    color: var(--text); font-size: 42px; font-weight: 800;
    letter-spacing: -.04em; text-align: right; font-variant-numeric: tabular-nums;
    -moz-appearance: textfield; appearance: textfield;
}
.climate-temp-value input::-webkit-outer-spin-button,
.climate-temp-value input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.climate-temp-value input:focus { outline: none; color: var(--accent-bright); }
.climate-temp-value span { color: var(--gold); font-size: 18px; font-weight: 700; }

.climate-presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 7px; margin-top: 10px; }
.climate-presets button {
    padding: 9px 6px; border-radius: 11px;
    background: var(--field); border: 1px solid var(--line);
    color: var(--muted); font-size: 12.5px; font-weight: 600;
    transition: color .18s, border-color .18s, background .18s;
}
.climate-presets button:hover { color: var(--text); border-color: rgba(61,139,255,.42); }
.climate-presets button.selected {
    color: #fff; border-color: rgba(61,139,255,.72);
    background: linear-gradient(135deg, rgba(10,99,216,.85), rgba(61,139,255,.55));
    box-shadow: 0 0 0 1px rgba(61,139,255,.22) inset;
}

.climate-duration { margin-top: 16px; }
.climate-duration-head {
    display: flex; justify-content: space-between; align-items: baseline;
    color: var(--muted); font-size: 10px; letter-spacing: .14em;
    text-transform: uppercase;
}
.climate-duration-head b { color: var(--text); font-size: 12px; letter-spacing: 0; text-transform: none; }
.climate-actions { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px; margin-top: 16px; }
.climate-actions .btn { padding: 12px; font-size: 14px; }

.comfort-title, .seat-title {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
    color: var(--muted); font-size: 10px; letter-spacing: .14em;
    text-transform: uppercase;
}
.comfort-title span { color: var(--gold); letter-spacing: .06em; }
.seat-title { margin-top: 16px; padding-top: 0; border-top: 0; }

.comfort-macros { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.comfort-macro {
    display: flex; align-items: center; gap: 10px; padding: 12px;
    border-radius: 14px; border: 1px solid var(--line);
    background: var(--card-soft); text-align: left; color: var(--text);
    transition: border-color .18s, background .18s, transform .18s;
}
.comfort-macro:hover { transform: translateY(-1px); }
.comfort-macro i { font-size: 20px; font-style: normal; line-height: 1; }
.comfort-macro span { min-width: 0; }
.comfort-macro b { display: block; font-size: 13px; }
.comfort-macro small { display: block; color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.comfort-macro.cool:hover, .comfort-macro.cool.on {
    border-color: rgba(61,139,255,.55); background: rgba(61,139,255,.10);
}
.comfort-macro.heat:hover, .comfort-macro.heat.on {
    border-color: rgba(212,175,55,.52); background: rgba(212,175,55,.09);
}
.comfort-macro.heat.on i { color: var(--gold-bright); }
.comfort-macro.cool.on i { color: var(--accent-bright); }

.comfort-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; margin-top: 10px; }
.comfort-toggle {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 11px 8px; border-radius: 13px;
    background: var(--field); border: 1px solid var(--line); color: var(--text);
    transition: border-color .18s, background .18s;
}
.comfort-toggle i { font-size: 18px; font-style: normal; line-height: 1; }
.comfort-toggle b { font-size: 12.5px; }
.comfort-toggle small { color: var(--muted); font-size: 10.5px; }
.comfort-toggle:hover { border-color: rgba(61,139,255,.42); }
.comfort-toggle.on {
    border-color: rgba(212,175,55,.62);
    background: linear-gradient(145deg, rgba(212,175,55,.20), rgba(61,139,255,.12));
    box-shadow: 0 0 18px rgba(212,175,55,.10);
}
.comfort-toggle.on small { color: var(--gold-bright); }

.seat-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px; margin-top: 10px;
}
.seat-block {
    padding: 10px 11px; border-radius: 13px;
    background: var(--card-soft); border: 1px solid var(--line);
}
.seat-name { display: block; color: var(--text); font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.seat-line { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.seat-line + .seat-line { margin-top: 6px; }
.seat-line > span { color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.seat-levels { display: flex; gap: 3px; }
.seat-level {
    width: 29px; height: 28px; border-radius: 8px;
    background: var(--field); border: 1px solid var(--line);
    color: var(--muted); font-size: 12px; font-weight: 700;
    transition: color .18s, border-color .18s, background .18s;
}
.seat-level:hover { color: var(--text); border-color: rgba(61,139,255,.42); }
.seat-level.on {
    color: #fff; border-color: rgba(61,139,255,.70);
    background: linear-gradient(135deg, var(--accent), var(--accent-bright));
    box-shadow: inset 0 -2px 0 var(--gold);
}

@media (max-width: 420px) {
    .climate-temp-value input { width: 92px; font-size: 36px; }
    .comfort-macros { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
    .seat-grid { grid-template-columns: 1fr; }
}

/* ── HUD ───────────────────────────────────────────────────────────────── */
.hud {
    position: fixed; inset: 0; z-index: 60;
    background: radial-gradient(900px 520px at 50% -10%, rgba(10, 99, 216, .24), transparent 65%), #03060C;
    color: var(--text);
    display: grid; grid-template-rows: 1fr auto;
    padding: clamp(20px, 4vw, 56px);
}
.hud .unit, .hud .sub, .hud-foot { color: var(--muted); }
.hud-main { display: grid; place-items: center; text-align: center; }
.hud-main .big { font-size: clamp(90px, 22vw, 260px); font-weight: 800; line-height: .9; letter-spacing: -.04em; }
.hud-main .unit { font-size: clamp(18px, 2.4vw, 34px); color: var(--gold-bright); letter-spacing: .2em; text-transform: uppercase; margin-top: 10px; }
.hud-main .sub { margin-top: 18px; color: var(--muted); font-size: clamp(14px, 1.6vw, 22px); }
.hud-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }
.hud-dots { display: flex; gap: 7px; }
.hud-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.2); }
.hud-dots i.on { background: var(--accent-bright); }

/* ── login ─────────────────────────────────────────────────────────────── */
.sheet {
    position: fixed; inset: 0; z-index: 70;
    background: var(--backdrop);
    backdrop-filter: blur(8px);
    display: grid; place-items: center;
    padding: 20px;
}
.sheet .card { width: min(430px, 100%); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 7px; }
.field input {
    width: 100%; padding: 13px 14px; border-radius: 12px;
    background: var(--field); border: 1px solid var(--line);
    font-size: 16px; letter-spacing: .06em;
}
.field input:focus { outline: none; border-color: rgba(61,139,255,.62); box-shadow: 0 0 0 3px rgba(61,139,255,.16); }
.field input::placeholder { color: #6F84A3; opacity: 1; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(0.85);
    opacity: .85;
    cursor: pointer;
}
select option { background: var(--card-solid); color: var(--text); }

.btn {
    width: 100%; padding: 14px; border-radius: 12px;
    font-weight: 700; font-size: 15px; letter-spacing: .01em;
    background: linear-gradient(145deg, #3D8BFF, #073B7A);
    color: #ffffff; transition: filter .15s, transform .15s, box-shadow .15s;
    box-shadow: 0 8px 20px rgba(10, 99, 216, 0.35);
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 10px 26px rgba(10, 99, 216, 0.45), 0 0 0 1px rgba(212, 175, 55, 0.35); }
.btn:active { transform: translateY(0) scale(.985); }
.btn:disabled { opacity: .5; filter: none; transform: none; cursor: not-allowed; box-shadow: none; }
.btn.ghost { background: var(--card-soft); color: var(--text); border: 1px solid var(--line); box-shadow: none; }

.hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-top: 10px; }
.msg { font-size: 13.5px; padding: 10px 12px; border-radius: 10px; margin: 10px 0; display: none; }
.msg.show { display: block; }
.msg.err { background: rgba(255,92,99,.10); border: 1px solid rgba(255,92,99,.32); color: #FF9AA0; }
.msg.ok { background: rgba(53,199,122,.10); border: 1px solid rgba(53,199,122,.32); color: #7FE3AE; }

/* ── toast ─────────────────────────────────────────────────────────────── */
.toast {
    position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
    background: #0E1626; color: var(--text); border: 1px solid rgba(212,175,55,.28);
    padding: 12px 20px; border-radius: 12px; font-size: 13.5px;
    opacity: 0; pointer-events: none; transition: .25s; z-index: 90;
    box-shadow: var(--shadow); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

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

@media (max-width: 640px) {
    .app { padding-bottom: 40px; }
    .hero-side { grid-template-columns: repeat(2, 1fr); }
    .grid { grid-template-columns: 1fr; }
    .brand-txt span { display: none; }
    .pill { padding: 7px 11px; font-size: 11.5px; }
    .tabs { position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
}

/* tablet in orizzontale: più colonne, testo più grande */
@media (min-width: 1100px) {
    body { font-size: 16px; }
    .grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Rifornimento / programma di ricarica ─────────────────────────────── */
.charge-now-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.charge-now .k { font-size: 11.5px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }
.charge-now-state { font-size: clamp(26px, 3.4vw, 38px); font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.charge-now-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.charge-now-soc { text-align: right; display: flex; flex-direction: column; }
.charge-now-soc b { font-size: clamp(38px, 5vw, 56px); line-height: 1; }
.charge-now-soc span { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.charge-bar.big { height: 10px; }
.card-title { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; gap: 10px; }
.card-title .state { color: var(--text); letter-spacing: 0; text-transform: none; font-size: 12.5px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.switch { display: flex; align-items: center; gap: 12px; margin: 18px 0 16px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 48px; height: 28px; border-radius: 99px; background: rgba(255,255,255,.12); border: 1px solid var(--line); position: relative; transition: .2s; flex: none; }
.switch-track i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: .2s; }
.switch input:checked + .switch-track { background: rgba(212,175,55,.20); border-color: rgba(212,175,55,.48); }
.switch input:checked + .switch-track i { left: 23px; background: var(--gold); }
.switch-label { font-size: 14px; }
.days { display: flex; gap: 8px; flex-wrap: wrap; }
.days button { border: 1px solid var(--line); background: var(--card-soft); color: var(--muted); border-radius: 10px; padding: 9px 12px; font: inherit; font-size: 13px; cursor: pointer; min-width: 44px; transition: background .16s, border-color .16s, transform .16s; }
.days button:active { transform: scale(.94); }
.days button.on { background: rgba(212,175,55,.14); border-color: rgba(212,175,55,.46); color: var(--gold-bright); font-weight: 600; }
.plan-note { margin-top: 14px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.plan-note.ok { color: var(--ok); }
.plan-note.warn { color: var(--warn); }
@media (max-width: 560px) {
    .two { grid-template-columns: 1fr; }
    .charge-now-soc b { font-size: 44px; }
}

/* ── Mappa ─────────────────────────────────────────────────────────────── */
.pos-tile { cursor: pointer; transition: border-color .18s, transform .18s; }
.pos-tile:hover { border-color: rgba(120,165,255,.36); transform: translateY(-1px); }
.pos-address { margin-top: 8px; min-height: 18px; }
.map-card { padding: 0; overflow: hidden; }
.map-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
            padding: clamp(16px, 2vw, 22px) clamp(16px, 2vw, 24px) 14px; }
.map-head .k { font-size: 11.5px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }
.map-addr { font-size: 17px; font-weight: 600; margin-top: 5px; line-height: 1.35; }
.map-coords { color: var(--muted); font-size: 12px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.leaflet-map { height: min(58vh, 500px); width: 100%; background: #0A1322; }
.map-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px;
            padding: 12px clamp(16px, 2vw, 24px); color: var(--muted); font-size: 12px; }
.map-foot a { color: var(--accent-2); white-space: nowrap; }
.seg { display: flex; gap: 4px; background: var(--card-soft); border: 1px solid var(--line);
       border-radius: 10px; padding: 4px; flex: none; }
.seg button { padding: 7px 11px; border-radius: 7px; color: var(--muted); font-size: 12px;
              font-weight: 600; cursor: pointer; }
.seg button.on {
    background: linear-gradient(145deg, #2F86FF, #073B7A);
    color: #fff;
    box-shadow: inset 0 -1px 0 var(--gold);
}
.car-pin { display: grid; place-items: center; }
.car-pin i { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); display: block;
             box-shadow: 0 0 0 8px rgba(61,139,255,.18), 0 0 22px rgba(61,139,255,.70); }
.leaflet-container { font: inherit; background: #0A1322; }
.leaflet-bar a { background: #0E1626; color: #F3F7FF; border-color: rgba(255,255,255,.10); }
.leaflet-bar a:hover { background: #16233A; }
.leaflet-control-attribution { background: rgba(5,8,15,.82) !important; color: #8FA3C2 !important; }
.leaflet-control-attribution a { color: #B9D4FF !important; }

/* ── Energia ───────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(12px, 1.6vw, 18px); }
.energy-big { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 18px; }
.energy-big b { font-size: 38px; letter-spacing: -.03em; }
.energy-big span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .14em; }
.spark { width: 100%; height: 64px; margin-top: 12px; display: block; overflow: visible; }
.spark polyline { filter: drop-shadow(0 0 6px rgba(61,139,255,.30)); }

/* ── Viaggi: mesi ──────────────────────────────────────────────────────── */
.month-table { margin-top: 4px; }
.month-head {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 12px; padding: 6px 2px; border-bottom: 1px solid var(--line);
    font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.month-head span:nth-child(2), .month-head span:nth-child(3) { text-align: right; }
.month-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 12px; align-items: center;
    padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.month-row:last-child { border-bottom: 0; }
.month-name b { display: block; font-size: 13.5px; text-transform: capitalize; }
.month-name span { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.month-km { text-align: right; }
.month-km b { display: block; font-size: 14px; }
.month-km span { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.month-cost { text-align: right; }
.month-cost b { display: block; font-size: 14px; color: var(--accent); }
.month-cost span { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.month-quality { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }

@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .trips-kpis { grid-template-columns: 1fr 1fr; }
    .trip-kpi b { font-size: 22px; }
    .map-head { flex-direction: column; }
    .leaflet-map { height: 52vh; }
    .map-foot { flex-direction: column; align-items: flex-start; gap: 6px; }
    .month-head, .month-row { grid-template-columns: minmax(0, 1fr) auto; }
    .month-head span:nth-child(3) { display: none; }
    .month-cost { grid-column: 1 / -1; text-align: left; display: flex; gap: 8px; align-items: baseline; }
    .month-cost b, .month-cost span { display: inline; }
}

/* ── Qualità dei dati ──────────────────────────────────────────────────── */
.quality-line {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-wrap: wrap; margin: 2px 0 14px;
}
.quality-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px; border-radius: 999px;
    font-size: 10px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; white-space: nowrap; line-height: 1.2;
    border: 1px solid var(--line); background: var(--card-soft);
    color: var(--muted);
}
.q-complete { color: var(--ok); background: rgba(53,199,122,.10); border-color: rgba(53,199,122,.30); }
.q-partial { color: var(--warn); background: rgba(224,179,74,.10); border-color: rgba(224,179,74,.32); }
.q-estimated { color: var(--accent-bright); background: rgba(61,139,255,.10); border-color: rgba(61,139,255,.30); }
.q-progress { color: var(--gold-bright); background: rgba(212,175,55,.10); border-color: rgba(212,175,55,.30); }
.q-none { color: var(--muted); }

.link-btn {
    background: none; color: var(--accent-2);
    font-size: 12.5px; font-weight: 600; padding: 5px 0;
}
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { opacity: .4; cursor: not-allowed; text-decoration: none; }

.card-title .quality-badge { margin-left: 8px; }
.sum-quality { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.trip-time { white-space: nowrap; }
.month-quality { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* ── Dettaglio ricarica ────────────────────────────────────────────────── */
body.modal-open { overflow: hidden; }
.detail {
    position: fixed; inset: 0; z-index: 80;
    background: var(--backdrop);
    backdrop-filter: blur(8px);
    display: grid; place-items: center;
    padding: 18px;
}
.detail-card {
    width: min(840px, 100%);
    max-height: min(92vh, 940px);
    overflow: auto;
    background: var(--card-solid);
}
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.detail-head .hint { margin-top: 6px; }
.detail-chart-wrap {
    margin: 14px 0 8px; padding: 8px;
    background: var(--card-soft);
    border: 1px solid var(--line); border-radius: 14px;
}
#detail-chart {
    width: 100%; max-width: 640px; height: auto;
    aspect-ratio: 480 / 220; display: block; margin: 0 auto;
}
.detail-legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin: 2px 0 14px; }
.detail-legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.lg-power { background: var(--accent-2); }
.lg-soc { background: var(--accent); }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.detail-grid > div {
    background: var(--card-soft); border: 1px solid var(--line);
    border-radius: 12px; padding: 10px 12px;
}
.detail-grid span {
    display: block; font-size: 10px; color: var(--muted);
    letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px;
}
.detail-grid b { font-size: 14.5px; font-weight: 600; }

/* ── Mobile-first: telefono e tablet dell'auto ─────────────────────────── */
@media (max-width: 640px) {
    .app { padding: calc(12px + env(safe-area-inset-top)) 12px 28px; }
    .topbar { flex-wrap: wrap; gap: 10px; }
    .brand-mark { width: 40px; height: 40px; border-radius: 12px; font-size: 16px; }
    .brand-txt strong { font-size: 15px; }
    .top-actions { gap: 8px; }
    .pill { padding: 6px 10px; font-size: 11px; }
    .icon-btn { width: 40px; height: 40px; }

    .tabs {
        position: sticky; top: env(safe-area-inset-top); z-index: 20;
        margin-left: -4px; margin-right: -4px;
        padding: 5px; border-radius: 14px;
        -webkit-overflow-scrolling: touch;
    }
    .tab { padding: 10px 15px; font-size: 13px; min-height: 44px; }

    .card { padding: 15px; border-radius: 16px; }
    .hero-side { gap: 8px; }
    .stat { padding: 12px; border-radius: 13px; }
    .stat .v { font-size: 21px; }
    .stat .k { font-size: 10px; }
    .charge-strip { gap: 10px; }

    .grid-2 { gap: 12px; }
    .energy-big b { font-size: 32px; }
    .energy-big { margin-bottom: 6px; }
    .row { font-size: 13.5px; gap: 12px; }
    .row b { text-align: right; }
    .card-title { font-size: 11px; }

    .trips-period { margin-left: -2px; margin-right: -2px; }
    .trips-period button { padding: 7px 9px; font-size: 11.5px; }
    .trip { font-size: 13px; gap: 3px 12px; }
    .trip-main b { font-size: 14px; }
    .trip-cost { font-size: 13.5px; }
    .trip-q .quality-badge { font-size: 9px; padding: 2px 6px; }

    .detail { padding: 0; }
    .detail-card {
        width: 100%; height: 100vh; height: 100dvh;
        max-height: 100vh; max-height: 100dvh;
        border-radius: 0; border: 0;
        padding: calc(18px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
    }
    #detail-chart { max-width: 100%; }
    .detail-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .detail-grid > div { padding: 9px 10px; }
    .detail-grid b { font-size: 13.5px; }
    .detail-legend { gap: 14px; font-size: 11.5px; }
    .detail-head .icon-btn { flex: none; }
}

@media (max-width: 380px) {
    .detail-grid { grid-template-columns: 1fr; }
    .tab { padding: 9px 12px; font-size: 12px; }
    .trips-kpis { gap: 7px; }
    .trip-kpi { padding: 10px 11px; }
    .trip-kpi b { font-size: 20px; }
}

/* ── Costi di esercizio e registro carburante ──────────────────────────── */
.mini-select {
    background: var(--card-solid);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 6px 9px;
    font-size: 12px;
    font-family: var(--font);
    letter-spacing: 0;
    text-transform: none;
    max-width: 48%;
}
.mini-select:focus { outline: none; border-color: rgba(61,139,255,.70); }
.cost-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.cost-tools .quality-badge { margin-left: 0; }
.cost-tools .mini-select { max-width: none; }

.cost-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 12px;
}
.cost-grid > div {
    background: var(--card-soft);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    min-width: 0;
}
.cost-grid span {
    display: block;
    font-size: 10px;
    color: var(--muted);
    letter-spacing: .1em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cost-grid b { display: block; font-size: 17px; margin-top: 4px; white-space: nowrap; }

.fuel-list { margin-top: 16px; }
.fuel-entry {
    display: grid;
    grid-template-columns: 96px 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 12px 2px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}
.fuel-entry:last-child { border-bottom: 0; }
.fuel-date { color: var(--muted); font-size: 12.5px; }
.fuel-main { font-weight: 600; min-width: 0; }
.fuel-main small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 2px; }
.fuel-money { color: var(--accent-2); font-weight: 700; white-space: nowrap; }
.fuel-del {
    background: none;
    color: var(--bad);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 4px;
    border-radius: 7px;
    white-space: nowrap;
}
.fuel-del:hover { background: rgba(255,92,99,.10); }

@media (max-width: 640px) {
    .cost-grid { grid-template-columns: 1fr 1fr; }
    .cost-grid b { font-size: 16px; }
    .mini-select { max-width: 52%; padding: 5px 7px; font-size: 11.5px; }
    .fuel-entry {
        grid-template-columns: 1fr auto;
        gap: 3px 10px;
        padding: 11px 0;
    }
    .fuel-entry .fuel-date { grid-column: 1; grid-row: 1; }
    .fuel-entry .fuel-money { grid-column: 2; grid-row: 1; }
    .fuel-entry .fuel-main { grid-column: 1; grid-row: 2; }
    .fuel-entry .fuel-del { grid-column: 2; grid-row: 2; justify-self: end; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Navigazione mobile, tema chiaro e animazioni
   ───────────────────────────────────────────────────────────────────────────── */

/* Navigazione inferiore: solo su telefono/tablet stretto */
.bottom-nav { display: none; }

.more-sheet {
    position: fixed; inset: 0; z-index: 75;
    display: flex; align-items: flex-end; justify-content: center;
    background: var(--backdrop);
    backdrop-filter: blur(8px);
    padding: 14px 14px 0;
    animation: backdropIn .2s ease both;
}
.more-card {
    width: min(540px, 100%);
    background: var(--card-solid);
    border: 1px solid var(--line);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -18px 50px rgba(0, 0, 0, .55);
    padding: 9px 18px calc(18px + env(safe-area-inset-bottom));
    animation: sheetUp .28s cubic-bezier(.2,.8,.2,1) both;
}
.more-handle {
    width: 42px; height: 4px; border-radius: 99px;
    background: rgba(255,255,255,.18);
    margin: 0 auto 12px;
}
.more-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.more-head strong { font-size: 16px; letter-spacing: .01em; }
.more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 14px 0 12px; }
.more-item {
    display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
    padding: 14px 12px; border-radius: 16px; text-align: left;
    background: var(--card-soft); border: 1px solid var(--line);
    transition: transform .18s, border-color .18s, background .18s;
}
.more-item:active { transform: scale(.96); }
.more-item.active { border-color: rgba(61,139,255,.46); background: rgba(61,139,255,.10); }
.more-ico { font-size: 22px; line-height: 1.1; margin-bottom: 4px; }
.more-item b { font-size: 13.5px; }
.more-item small { color: var(--muted); font-size: 10.5px; line-height: 1.25; }
.more-hud {
    width: 100%; padding: 13px; border-radius: 14px;
    background: var(--card-soft); border: 1px solid var(--line);
    font-size: 13.5px; font-weight: 600;
    transition: background .18s, transform .18s;
}
.more-hud:active { transform: scale(.985); background: var(--bg-soft); }

body.more-open { overflow: hidden; }

@media (max-width: 820px) {
    .tabs { display: none; }

    .bottom-nav {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 2px;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
        padding: 7px 7px calc(7px + env(safe-area-inset-bottom));
        background: rgba(5, 10, 19, 0.95);
        border-top: 1px solid rgba(120, 165, 255, 0.16);
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(18px) saturate(1.25);
    }
    .bnav-item {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 3px; min-width: 0; padding: 7px 2px 6px;
        border-radius: 13px; color: #8FA3C2;
        font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
        transition: color .18s, background .18s, transform .18s;
    }
    .bnav-item svg { width: 23px; height: 23px; flex: none; transition: transform .22s cubic-bezier(.2,.8,.2,1); }
    .bnav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .bnav-item.active { color: #8FC4FF; background: rgba(61, 139, 255, 0.18); box-shadow: inset 0 -2px 0 var(--gold); }
    .bnav-item.active svg { transform: translateY(-1px) scale(1.07); }
    .bnav-item:active { transform: scale(.92); }

    .app { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
    .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
    .leaflet-map { height: min(52vh, 430px); }
    /* Su telefono evito decine di blur in scorrimento: il vetro resta solo
       sulla barra inferiore e sulle finestre modali. */
    .card:not(.soc-card) { background: rgba(13, 20, 34, .97); backdrop-filter: none; }
}

@media (max-width: 640px) {
    .app {
        padding: calc(12px + env(safe-area-inset-top)) 12px calc(96px + env(safe-area-inset-bottom));
    }
    .topbar { flex-wrap: nowrap; gap: 8px; margin-bottom: 12px; }
    .brand { gap: 8px; min-width: 0; }
    .brand-mark { width: 36px; height: 36px; border-radius: 11px; font-size: 14px; flex: none; }
    .brand-txt { min-width: 0; }
    .brand-txt strong { font-size: 13.5px; letter-spacing: .10em; white-space: nowrap; }
    .brand-txt span { display: none; }
    .top-actions { gap: 6px; flex: none; }
    .pill { padding: 6px 9px; font-size: 10.5px; gap: 6px; max-width: 116px; }
    #conn-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .icon-btn { width: 38px; height: 38px; border-radius: 11px; font-size: 15px; }

    .hero { gap: 10px; }
    .soc-card { flex-direction: row; flex-wrap: wrap; justify-content: space-between; gap: 10px 14px; padding: 14px; }
    .gauge { width: 132px; min-width: 132px; }
    .gauge-label b { font-size: 36px; }
    .gauge-label span { font-size: 10px; letter-spacing: .13em; }
    #charge-pill { max-width: 46%; }
    #charge-text { overflow: hidden; text-overflow: ellipsis; }

    .hero-side { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .stat { padding: 12px 10px; min-width: 0; }
    .stat .v { font-size: clamp(18px, 5.6vw, 22px); overflow-wrap: anywhere; }
    .stat .k { font-size: 9.5px; letter-spacing: .08em; }
    .charge-strip { grid-column: 1 / -1; }

    .card { padding: 14px; border-radius: 16px; }
    .grid { gap: 10px; }
    .tile { padding: 14px; }
    .tile h3 { margin-bottom: 10px; }

    .cmd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
    .cmd { padding: 14px 12px; gap: 5px; border-radius: 14px; }
    .cmd i { font-size: 20px; }
    .cmd b { font-size: 13.5px; }
    .cmd small { font-size: 10.5px; line-height: 1.3; }

    .days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
    .days button { min-width: 0; padding: 10px 0; font-size: 11px; border-radius: 8px; }
    .field input { padding: 12px 13px; }
    .btn { padding: 13px; }

    .trips-top { gap: 8px; }
    .trips-top .icon-btn { flex: none; }
    .trips-kpis { gap: 8px; margin-top: 12px; }
    .trip-kpi { padding: 10px 11px; }
    .trip-kpi b { font-size: 21px; }
    .trip-kpi span { font-size: 9px; letter-spacing: .06em; }

    .cost-grid { gap: 8px; }
    .cost-grid > div { padding: 10px; }
    .cost-grid b { font-size: 15px; }
    .mini-select { max-width: 100%; }

    .detail { padding: 0; }
    .detail-card {
        border-radius: 0;
        padding: calc(16px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
    }
    .detail-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
    .detail-grid > div { padding: 8px 9px; }
    .detail-grid b { font-size: 12.5px; }

    .map-head { padding: 14px 14px 12px; }
    .map-foot { padding: 10px 14px; }
    .map-addr { font-size: 15px; }
}

@media (max-width: 380px) {
    #btn-hud { display: none; }
    .pill { max-width: 96px; }
    .bnav-item { font-size: 9.5px; }
    .bnav-item svg { width: 21px; height: 21px; }
    .more-grid { gap: 7px; }
    .more-item { padding: 12px 9px; }
}

/* ── Animazioni e feedback ─────────────────────────────────────────────── */
@keyframes panelIn {
    from { opacity: 0; transform: translateY(10px) scale(.996); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes riseIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes backdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes sheetUp {
    from { opacity: 0; transform: translateY(22px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulseDot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(53, 199, 122, .42); }
    50%      { box-shadow: 0 0 0 6px rgba(53, 199, 122, 0); }
}
@keyframes shimmer {
    from { transform: translateX(-110%); }
    to   { transform: translateX(210%); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.panel.active { animation: panelIn .26s cubic-bezier(.2,.8,.2,1) both; }
.panel.active > * { animation: riseIn .34s cubic-bezier(.2,.8,.2,1) both; }
.panel.active > *:nth-child(2) { animation-delay: .03s; }
.panel.active > *:nth-child(3) { animation-delay: .06s; }
.panel.active > *:nth-child(4) { animation-delay: .09s; }
.panel.active > *:nth-child(5) { animation-delay: .12s; }

.dot.live { animation: pulseDot 2.4s ease-in-out infinite; }

.charge-bar i { position: relative; overflow: hidden; }
.charge-bar i::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.42), transparent);
    animation: shimmer 2.6s ease-in-out infinite;
}

.card, .stat, .car-part, .tire {
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
@media (hover: hover) {
    .card:hover { box-shadow: 0 18px 44px rgba(0, 0, 0, 0.50), 0 0 0 1px rgba(61, 139, 255, 0.14); }
    .tile:hover { transform: translateY(-1px); }
}

.cmd { position: relative; }
.cmd:active:not([disabled]) { transform: scale(.975); }
.btn.busy, .cmd.busy { pointer-events: none; opacity: .72; }
.btn.busy::after, .cmd.busy::after {
    content: ""; display: inline-block; width: 14px; height: 14px;
    border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: spin .7s linear infinite;
    vertical-align: -2px; margin-left: 8px;
}
.cmd.busy::after { position: absolute; top: 14px; right: 14px; margin: 0; }

.sheet .card, .detail-card { animation: sheetUp .26s cubic-bezier(.2,.8,.2,1) both; }

:focus-visible {
    outline: 3px solid rgba(61, 139, 255, .55);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
