/* Layout: mappa a tutto schermo, barra di ricerca in alto, "cruscotto" in basso, fogli che salgono dal basso. */
:root {
  --bg: #0d0f12;          /* asfalto */
  --panel: #171a1f;       /* carbonio */
  --panel-2: #20242b;
  --line: #2c313a;
  --fg: #eef0f2;
  --muted: #8b939e;
  --accent: #f5c400;      /* giallo Modena */
  --accent-ink: #1a1500;
  --live: #ff3b30;        /* spia "online" */
  --ok: #34c759;
  --font-display: "Saira Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.4 var(--font-body);
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; background: var(--bg); }
.leaflet-container { background: var(--bg); font-family: var(--font-body); }
.leaflet-control-attribution { background: rgba(13,15,18,.7) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-control-zoom { display: none; }
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.95) saturate(.35); }

/* Barra in alto */
.topbar {
  position: fixed; z-index: 500; left: 0; right: 0; top: 0;
  padding: calc(var(--safe-top) + 12px) 16px 0;
  display: flex; gap: 10px; align-items: center;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.search-pill {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 25px;
  text-align: left; box-shadow: 0 6px 24px rgba(0,0,0,.45);
}
.search-pill svg { width: 20px; height: 20px; fill: var(--accent); flex: none; }
.search-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.search-pill.has-dest span { color: var(--fg); font-weight: 600; }
.avatar-btn {
  width: 50px; height: 50px; flex: none; padding: 0;
  border-radius: 50%; border: 2px solid var(--accent); background: var(--panel-2); overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,.45);
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }

.demo-badge {
  position: fixed; z-index: 500; left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-top) + 72px);
  background: var(--accent); color: var(--accent-ink);
  font: 700 12px/1 var(--font-display); letter-spacing: .08em;
  padding: 6px 10px; border-radius: 6px;
}

.map-tools {
  position: fixed; z-index: 500; right: 16px;
  bottom: calc(var(--safe-bottom) + 112px);
  display: flex; flex-direction: column; gap: 10px;
}
.tool {
  position: relative; width: 50px; height: 50px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line);
  display: grid; place-items: center; box-shadow: 0 6px 24px rgba(0,0,0,.45);
}
.tool svg { width: 24px; height: 24px; fill: var(--fg); }
.tool .count {
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--accent); color: var(--accent-ink);
  font: 700 13px/22px var(--font-display); text-align: center;
}

/* Cruscotto */
.dock {
  position: fixed; z-index: 500; left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(var(--safe-bottom) + 14px);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  background: linear-gradient(to top, var(--bg) 55%, rgba(13,15,18,0));
}
.gauge { display: flex; flex-direction: column; align-items: center; font-variant-numeric: tabular-nums; }
.gauge-num { font: 800 34px/1 var(--font-display); }
.gauge-unit { font: 500 11px/1.2 var(--font-display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.online-btn {
  display: flex; align-items: center; gap: 10px;
  height: 64px; padding: 0 26px; border-radius: 32px;
  background: var(--accent); color: var(--accent-ink); border: 0;
  font: 800 20px/1 var(--font-display); letter-spacing: .06em;
  box-shadow: 0 8px 28px rgba(245,196,0,.28);
  transition: transform .12s ease, background .2s ease;
}
.online-btn:active { transform: scale(.96); }
.online-btn .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent-ink); opacity: .35; }
.online-btn[aria-pressed="true"] { background: var(--panel-2); color: var(--fg); box-shadow: 0 0 0 2px var(--live) inset; }
.online-btn[aria-pressed="true"] .dot { background: var(--live); opacity: 1; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,59,48,.6); } 50% { box-shadow: 0 0 0 7px rgba(255,59,48,0); } }

/* Fogli */
.sheet {
  position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0;
  max-height: 70vh; overflow-y: auto;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(var(--safe-bottom) + 20px);
  box-shadow: 0 -12px 40px rgba(0,0,0,.6);
  animation: up .22s ease-out;
}
.sheet.tall { max-height: 88vh; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font: 800 26px/1.1 var(--font-display); letter-spacing: .02em; text-transform: uppercase; }
.close { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--panel-2); font-size: 22px; line-height: 1; }

.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
input[type="search"], .field input {
  width: 100%; height: 46px; padding: 0 14px;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn {
  height: 46px; padding: 0 18px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  font: 700 17px/1 var(--font-display); letter-spacing: .06em; text-transform: uppercase;
}
.btn.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.btn.wide { width: 100%; margin-top: 14px; }

.results { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.results li button {
  width: 100%; text-align: left; padding: 12px 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid transparent;
}
.results li button:active { border-color: var(--accent); }
.results .r-main { display: block; font-weight: 600; }
.results .r-sub { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .empty { color: var(--muted); padding: 8px 2px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font: 600 12px/1 var(--font-display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.photo-pick {
  position: relative; display: block; height: 150px; border-radius: var(--radius); overflow: hidden;
  background: var(--panel-2) repeating-linear-gradient(45deg, transparent 0 12px, rgba(255,255,255,.03) 12px 24px);
  border: 1px dashed var(--line); cursor: pointer;
}
.photo-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-pick img:not([src]), .photo-pick img[src=""] { display: none; }
.photo-pick span {
  position: absolute; left: 12px; bottom: 10px; padding: 5px 9px; border-radius: 6px;
  background: rgba(0,0,0,.6); font: 600 13px/1 var(--font-display); letter-spacing: .08em; text-transform: uppercase;
}
.photo-pick input { position: absolute; inset: 0; opacity: 0; }
.colors { display: flex; flex-wrap: wrap; gap: 10px; }
.colors button { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); }
.colors button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--fg); }
.note { margin: 0; font-size: 13px; color: var(--muted); }
.note b { color: var(--fg); }

/* Scheda pilota */
.driver-card { display: flex; gap: 14px; align-items: center; }
.driver-card img { width: 96px; height: 72px; object-fit: cover; border-radius: 10px; background: var(--panel-2); flex: none; }
.driver-info { min-width: 0; }
.car-name { font: 800 22px/1.1 var(--font-display); text-transform: uppercase; }
.specs { color: var(--accent); font: 600 14px/1.3 var(--font-display); letter-spacing: .06em; }
.bio { color: var(--muted); font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 10px; }
.stats div { background: var(--panel-2); border-radius: 10px; padding: 10px; }
.stats dt { font: 600 11px/1 var(--font-display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stats dd { margin: 6px 0 0; font: 700 20px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.dest-line { font-size: 15px; }
.dest-line .label { color: var(--muted); }
#dDest { font-weight: 600; }

.driver-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.driver-list button {
  width: 100%; display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  padding: 8px; text-align: left; background: var(--panel-2); border: 0; border-radius: 12px;
}
.driver-list img { width: 56px; height: 42px; object-fit: cover; border-radius: 8px; background: var(--bg); }
.driver-list .l-name { font-weight: 600; display: block; }
.driver-list .l-car { font-size: 13px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.driver-list .l-dist { font: 700 16px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.driver-list > div { min-width: 0; }
.driver-list .empty { color: var(--muted); padding: 10px 2px; }

/* Marker auto */
.car-marker { width: 44px; height: 44px; position: relative; }
.car-marker .arrow { position: absolute; inset: 0; transition: transform .6s linear; }
.car-marker svg { width: 44px; height: 44px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }
.car-marker .tag {
  position: absolute; left: 50%; top: 44px; transform: translateX(-50%);
  white-space: nowrap; padding: 2px 6px; border-radius: 4px;
  background: rgba(13,15,18,.85); color: var(--fg);
  font: 700 11px/1.2 var(--font-display); letter-spacing: .04em;
}
.car-marker.me .tag { background: var(--accent); color: var(--accent-ink); }
.dest-marker { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--bg); box-shadow: 0 0 0 2px currentColor; background: currentColor; }

.toast {
  position: fixed; z-index: 2000; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 110px);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--fg); color: var(--bg); font-weight: 600; text-align: center;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Convoglio ---------- */
.count {
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--live); color: #fff;
  font: 700 13px/22px var(--font-display); text-align: center;
}
.tool .count { background: var(--accent); color: var(--accent-ink); }
.convoy-btn {
  position: relative; justify-self: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 0; padding: 0;
}
.convoy-btn .ico-wrap {
  width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line);
  transition: background .2s ease;
}
.convoy-btn svg { width: 28px; height: 28px; fill: var(--accent); }
.convoy-btn.active .ico-wrap { background: var(--accent); border-color: var(--accent); }
.convoy-btn.active svg { fill: var(--accent-ink); }
.convoy-btn .count { top: -4px; right: -6px; }

.sheet-head h2.with-ico { display: flex; align-items: center; gap: 10px; }
.sheet-head h2.with-ico svg { width: 28px; height: 28px; fill: var(--accent); }

.convoy-body { display: flex; flex-direction: column; gap: 18px; }
.cv-section { display: flex; flex-direction: column; gap: 8px; }
.cv-section > h3 {
  margin: 0; font: 700 13px/1 var(--font-display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.cv-hint { margin: 0; color: var(--muted); font-size: 14px; }
.cv-card { background: var(--panel-2); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.cv-card.mine { box-shadow: 0 0 0 2px var(--accent) inset; }
.cv-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.cv-top > div { min-width: 0; }
.cv-name { font: 800 21px/1.1 var(--font-display); text-transform: uppercase; overflow-wrap: anywhere; }
.cv-dest { color: var(--muted); font-size: 14px; }
.cv-dest b { color: var(--fg); font-weight: 600; }
.pill {
  flex: none; padding: 4px 8px; border-radius: 6px;
  font: 700 11px/1 var(--font-display); letter-spacing: .08em; text-transform: uppercase;
  background: var(--line); color: var(--fg);
}
.pill.same { background: var(--accent); color: var(--accent-ink); }
.pill.lead { background: transparent; box-shadow: 0 0 0 1px var(--accent) inset; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px 4px 6px; border-radius: 14px; background: var(--bg); font-size: 13px; font-weight: 600; }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cv-list li { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.cv-list li > div { min-width: 0; }
.cv-list .dot { width: 12px; height: 12px; border-radius: 50%; }
.cv-list .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.cv-list .sub { font-size: 13px; color: var(--muted); display: block; }
.cv-list .acts { display: flex; gap: 6px; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--live); border: 1px solid var(--live); }
.btn:disabled { opacity: .45; cursor: default; }
.cv-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cv-actions .btn { flex: 1 1 140px; }
.cv-create { display: flex; gap: 8px; }
.cv-create input {
  flex: 1; min-width: 0; height: 46px; padding: 0 14px;
  background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 10px;
}

/* Compagni di convoglio sulla mappa */
.cv-badge {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg);
}
.cv-badge svg { width: 14px; height: 14px; fill: var(--accent-ink); filter: none; }
.car-marker.mate .tag { box-shadow: 0 0 0 1px var(--accent); }

.stats dd.small { font-size: 15px; line-height: 1.15; overflow-wrap: anywhere; }

/* Link all'app Android (solo da browser Android) */
.apk-link {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--accent); color: var(--fg); text-decoration: none;
}
.apk-link b { font: 700 16px/1.2 var(--font-display); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.apk-link span { font-size: 13px; color: var(--muted); }

/* Convoglio privato */
.pills { display: flex; gap: 6px; flex: none; align-items: flex-start; }
.pill.priv { display: inline-flex; align-items: center; gap: 4px; background: var(--fg); color: var(--bg); }
.pill .lock { width: 11px; height: 11px; fill: currentColor; }
.cv-check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); cursor: pointer; }
.cv-check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.cv-check span { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.cv-check b { color: var(--fg); font-size: 15px; }

/* Gruppi di icone vicine */
.cl-marker {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--panel); border: 3px solid var(--fg);
  box-shadow: 0 0 0 4px rgba(13,15,18,.45), 0 4px 12px rgba(0,0,0,.5);
  font: 800 19px/1 var(--font-display); color: var(--fg); font-variant-numeric: tabular-nums;
}
.cl-marker.with-cv { border-color: var(--accent); color: var(--accent); }

/* Un convoglio = un'icona */
.cv-marker { position: relative; width: 52px; height: 52px; }
.cv-marker .cv-ico {
  position: absolute; inset: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg); border: 3px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(245,196,0,.25), 0 4px 12px rgba(0,0,0,.5);
}
.cv-marker.mine .cv-ico { background: var(--accent); }
.cv-marker .cv-ico svg { width: 28px; height: 28px; fill: var(--accent); }
.cv-marker.mine .cv-ico svg { fill: var(--accent-ink); }
.cv-marker .cv-ico em {
  position: absolute; top: -6px; right: -8px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px;
  background: var(--fg); color: var(--bg); font: 800 13px/22px var(--font-display); font-style: normal; text-align: center;
}
.cv-marker .cv-lbl {
  position: absolute; left: 50%; top: 56px; transform: translateX(-50%);
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 2px 7px; border-radius: 4px; background: var(--accent); color: var(--accent-ink);
  font: 800 12px/1.3 var(--font-display); letter-spacing: .04em; text-transform: uppercase;
}

/* Liste: righe di convoglio e membri toccabili */
.driver-list .cv-ico-sm { width: 56px; height: 42px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; }
.driver-list .cv-ico-sm svg { width: 26px; height: 26px; fill: var(--accent); }
.cv-list li.tap { cursor: pointer; }
.cv-list li.tap:active { background: var(--line); }
.cv-list .chev { font-size: 24px; color: var(--muted); }

/* Tasto "centra su di me": acceso quando la mappa ti segue */
.tool.on { background: var(--accent); border-color: var(--accent); }
.tool.on svg { fill: var(--accent-ink); }
/* Gruppo che contiene anche la tua auto */
.cl-marker.with-me { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.driver-list .me-row { box-shadow: 0 0 0 1px var(--accent) inset; }

/* Meet */
.meet-btn { display: flex; align-items: center; justify-content: center; gap: 10px; }
.meet-btn svg { width: 22px; height: 22px; fill: currentColor; }
.meet-btn.pending { background: transparent; color: var(--fg); border: 1px solid var(--accent); }
.meet-card { background: var(--panel-2); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.meet-card.ok { box-shadow: 0 0 0 2px var(--accent) inset; }
.meet-who { font: 800 21px/1.15 var(--font-display); text-transform: uppercase; }
.meet-place { font-size: 16px; font-weight: 600; }
.meet-place small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.meet-times { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.meet-times div { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.meet-times dt { font: 600 11px/1 var(--font-display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.meet-times dd { margin: 4px 0 0; font: 700 19px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.searching { display: flex; align-items: center; gap: 12px; color: var(--muted); }

/* ---------- Barra in alto: auto + menu, orario d'arrivo nella ricerca ---------- */
.top-right { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.menu-btn {
  width: 40px; height: 40px; border-radius: 50%; padding: 0;
  display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.45);
}
.menu-btn svg { width: 20px; height: 20px; fill: var(--fg); }
.menu-btn[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); }
.menu-btn[aria-expanded="true"] svg { fill: var(--accent-ink); }
.search-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.search-txt small { font-size: 12px; color: var(--accent); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-pop {
  position: fixed; z-index: 900; right: 16px; top: calc(var(--safe-top) + 122px);
  width: min(260px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,.6); display: flex; flex-direction: column;
}
.menu-me { padding: 10px 12px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; flex-direction: column; }
.menu-me b { font: 800 18px/1.1 var(--font-display); text-transform: uppercase; }
.menu-me span { color: var(--accent); font: 700 14px/1.3 var(--font-display); letter-spacing: .04em; }
.menu-pop button {
  display: flex; align-items: center; gap: 12px; padding: 12px; border: 0; border-radius: 10px;
  background: none; text-align: left; font-weight: 600;
}
.menu-pop button:active, .menu-pop button:hover { background: var(--panel-2); }
.menu-pop button svg { width: 22px; height: 22px; fill: var(--accent); flex: none; }

/* ---------- Tasto Challenge ---------- */
.tool.challenge svg { fill: var(--accent); }

/* ---------- Segnalazione rapida ---------- */
.report-btn {
  position: relative; justify-self: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 0; padding: 0;
}
.report-btn .ico-wrap {
  width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line);
}
.report-btn svg { width: 26px; height: 26px; fill: var(--live); }
.report-btn[aria-expanded="true"] .ico-wrap { background: var(--live); border-color: var(--live); }
.report-btn[aria-expanded="true"] svg { fill: #fff; }
.report-fan {
  position: fixed; z-index: 800; right: 12px; bottom: calc(var(--safe-bottom) + 104px);
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  animation: up .18s ease-out;
}
.report-fan button {
  display: flex; align-items: center; gap: 10px; padding: 6px 16px 6px 6px; border-radius: 30px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.55);
  font: 800 16px/1 var(--font-display); letter-spacing: .06em; text-transform: uppercase;
}
.report-fan .r-ico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); }
.report-fan svg { width: 26px; height: 26px; fill: var(--fg); }
.report-fan [data-report="speed"] .r-ico { background: #0a84ff; }
.report-fan [data-report="police"] .r-ico { background: #1d3fa8; }
.report-fan [data-report="works"] .r-ico { background: #ff8a00; }
.report-fan button:disabled { opacity: .5; }

/* Segnalazioni sulla mappa */
.hz-marker { position: relative; width: 36px; height: 36px; }
.hz-marker .hz-ico {
  position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.55);
}
.hz-marker svg { width: 20px; height: 20px; fill: #fff; }
.hz-marker.speed .hz-ico { background: #0a84ff; }
.hz-marker.police .hz-ico { background: #1d3fa8; }
.hz-marker.works .hz-ico { background: #ff8a00; }
.hz-marker.pending { opacity: .6; }
.hz-marker.pending .hz-ico { border-style: dashed; }
.hz-marker em {
  position: absolute; top: -8px; right: -12px; padding: 1px 5px; border-radius: 8px;
  background: var(--fg); color: var(--bg); font: 800 11px/14px var(--font-display); font-style: normal;
}

/* ---------- Classifica ---------- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; background: var(--bg); border-radius: 12px; margin-bottom: 12px; }
.tabs button { height: 40px; border: 0; border-radius: 9px; background: none; font: 700 15px/1 var(--font-display); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--panel-2); color: var(--fg); }
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-list li {
  display: grid; grid-template-columns: 34px 12px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: var(--panel-2);
}
.lb-list li.me { box-shadow: 0 0 0 2px var(--accent) inset; }
.lb-list .rank { font: 800 18px/1 var(--font-display); color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.lb-list li:nth-child(1) .rank { color: #f5c400; }
.lb-list li:nth-child(2) .rank { color: #c9d1d9; }
.lb-list li:nth-child(3) .rank { color: #d08a4a; }
.lb-list .dot { width: 12px; height: 12px; border-radius: 50%; }
.lb-list .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-list .pts { font: 800 18px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.lb-list .empty, .lb-list .sep { grid-template-columns: 1fr; color: var(--muted); background: none; text-align: center; padding: 4px; }
.lb-how { margin-top: 10px; }

/* ---------- Sfide della settimana ---------- */
.goals-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.goals-list li { background: var(--panel-2); border-radius: 12px; padding: 12px; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.goals-list li.done { opacity: .6; }
.goals-list li.ready { box-shadow: 0 0 0 2px var(--accent) inset; }
.goals-list .g-title { font: 800 18px/1.1 var(--font-display); text-transform: uppercase; }
.goals-list .g-desc { grid-column: 1; font-size: 13px; color: var(--muted); }
.goals-list .g-pts { grid-row: 1; grid-column: 2; font: 800 18px/1 var(--font-display); color: var(--accent); }
.goals-list .g-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; }
.goals-list .g-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.goals-list .g-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
body.fan-open .map-tools { opacity: 0; pointer-events: none; transition: opacity .15s; }

/* ---------- Menu con foto profilo ---------- */
.menu-btn { width: 50px; height: 50px; }
.menu-btn svg { width: 24px; height: 24px; }
.menu-pop { top: calc(var(--safe-top) + 72px); }
.menu-me { flex-direction: row !important; align-items: center; gap: 12px; }
.menu-me img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; background: var(--panel-2); border: 2px solid var(--accent); flex: none; }
.menu-me > div { display: flex; flex-direction: column; min-width: 0; }
.menu-pop button[data-menu="record"] svg { fill: var(--live); }
.menu-pop button[data-menu="record"].on { background: rgba(255,59,48,.12); }

/* ---------- Registrazione di un giro ---------- */
.rec-bar {
  position: fixed; z-index: 600; left: 16px; right: 82px; top: calc(var(--safe-top) + 74px);
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px;
  background: var(--panel); border: 1px solid var(--live); border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.45);
}
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--live); animation: pulse 1.4s infinite; flex: none; }
.rec-stats { flex: 1; display: flex; gap: 10px; align-items: baseline; min-width: 0; font-variant-numeric: tabular-nums; }
.rec-stats b { font: 800 20px/1 var(--font-display); }
.rec-stats span { color: var(--muted); font-weight: 600; }
.rec-bar .btn { background: var(--live); color: #fff; }
body.recording .demo-badge { display: none; }

/* ---------- Giri: statistiche e bacheca ---------- */
.ride-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.ride-stats div { background: var(--panel-2); border-radius: 10px; padding: 10px; }
.ride-stats dt { font: 600 11px/1.1 var(--font-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ride-stats dd { margin: 6px 0 0; font: 800 20px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.ride-stats .private dd::after { content: " 🔒"; font-size: 12px; }
.ride-meta { color: var(--muted); font-size: 14px; }
.ride-meta b { color: var(--fg); }
.ride-form { display: flex; flex-direction: column; gap: 10px; }
.ride-form input[type="text"] { width: 100%; height: 46px; padding: 0 14px; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; }
.rides-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rides-list li > button {
  width: 100%; text-align: left; padding: 12px; border: 0; border-radius: 12px; background: var(--panel-2);
  display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center;
}
.rides-list canvas { width: 64px; height: 64px; border-radius: 10px; background: var(--bg); }
.rides-list .r-name { font: 800 18px/1.1 var(--font-display); text-transform: uppercase; display: block; }
.rides-list .r-by { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.rides-list .r-nums { font: 700 15px/1.2 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.rides-list .empty { color: var(--muted); padding: 8px 2px; }
