/* ================================================================
   CICLOANTS  — Design System  v3.0  LIGHT THEME
   Alta leggibilità per uso in bici all'aperto
   ================================================================ */

/* ── Imports ──────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

/* ── CSS Custom Properties ────────────────────────────────────── */
:root {
  /* Colori sfondo */
  --bg-page:        #f0f4f8;
  --bg-surface:     #ffffff;
  --bg-raised:      #e8edf3;
  --bg-card:        #ffffff;
  --glass-border:   rgba(0, 90, 200, 0.15);
  --glass-shadow:   0 4px 20px rgba(0, 0, 0, 0.10);

  /* Accenti vivaci (leggibili in piena luce) */
  --cyan:           #005cc5;
  --cyan-dim:       rgba(0, 92, 197, 0.12);
  --cyan-glow:      0 0 0 3px rgba(0, 92, 197, 0.25);
  --green:          #0a7d3e;
  --orange:         #d46000;
  --red:            #c0003e;
  --purple:         #6b00d4;

  /* Testo */
  --text-primary:   #0d1b2a;
  --text-secondary: #3a5068;
  --text-muted:     #7b96b2;

  /* Gradiente feromoni (saturo, visibile anche alla luce) */
  --phero-gradient: linear-gradient(135deg, #005cc5 0%, #00a3cc 25%, #0a7d3e 50%, #d46000 75%, #c0003e 100%);

  /* Dimensioni */
  --header-h:       64px;
  --sidebar-w:      380px;
  --radius-sm:      8px;
  --radius-md:      14px;
  --radius-lg:      20px;

  /* Transizioni */
  --ease:           cubic-bezier(0.4, 0, 0.2, 1);
  --transition:     0.22s var(--ease);
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbars ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 99px; }

/* ================================================================
   HEADER
   ================================================================ */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: #ffffff;
  border-bottom: 2px solid #d8e4f0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  z-index: 1000;
}

/* Brand */
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.ant-logo {
  font-size: 28px;
  animation: antBob 2.5s ease-in-out infinite;
}

@keyframes antBob {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%       { transform: translateY(-4px) rotate(5deg); }
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--cyan);
}

.brand-tagline {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Stats pills */
.header-stats {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--glass-border);
  border-radius: 99px;
  white-space: nowrap;
}

.stat-icon { font-size: 13px; }

.stat-value {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--cyan);
  transition: color 0.3s;
}

.stat-unit {
  font-size: 11px;
  color: var(--text-muted);
}

/* Sidebar toggle (mobile) */
.sidebar-toggle {
  display: none;
  background: var(--bg-raised);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 18px;
  margin-left: auto;
  flex-shrink: 0;
  font-weight: 700;
}

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: #ffffff;
  border-right: 1.5px solid #d8e4f0;
  box-shadow: 2px 0 16px rgba(0,0,0,0.06);
  z-index: 900;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

/* Sidebar sections */
.sidebar-section {
  padding: 14px 20px;
  border-bottom: 1px solid #e8edf3;
}

.sidebar-section:last-child { border-bottom: none; }

.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-icon { font-size: 14px; }

/* ── Search fields ──────────────────────────────────────────────── */
.search-group { display: flex; flex-direction: column; gap: 0; }

.search-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.point-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  z-index: 1;
}

.badge-a {
  background: var(--cyan);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 92, 197, 0.4);
}

.badge-b {
  background: var(--green);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(10, 125, 62, 0.4);
}

.search-input {
  flex: 1;
  background: var(--bg-raised);
  border: 1.5px solid #c8d8e8;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
  border-color: var(--cyan);
  box-shadow: var(--cyan-glow);
  background: #ffffff;
}

.search-connector {
  display: flex;
  align-items: center;
  padding: 4px 0 4px 36px;
  gap: 10px;
}

.connector-dots {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.connector-dots span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
}

.btn-swap {
  background: var(--bg-raised);
  border: 1.5px solid #c8d8e8;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 16px;
  transition: all var(--transition);
  margin-left: auto;
}

.btn-swap:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--cyan-dim);
  transform: rotate(180deg);
}

/* Autocomplete dropdown */
.suggestions-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 36px;
  right: 0;
  background: #ffffff;
  border: 1.5px solid #c8d8e8;
  border-radius: var(--radius-sm);
  overflow: hidden;
  z-index: 2000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.suggestion-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid #edf2f7;
}

.suggestion-item:last-child { border-bottom: none; }

.suggestion-item:hover { background: var(--cyan-dim); }

.sug-icon { font-size: 12px; flex-shrink: 0; margin-top: 1px; }

.sug-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Primary button ──────────────────────────────────────────── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
  padding: 13px 20px;
  background: var(--cyan);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
  letter-spacing: 0.2px;
  box-shadow: 0 4px 14px rgba(0, 92, 197, 0.35);
}

.btn-primary:hover {
  background: #0047a0;
  box-shadow: 0 6px 20px rgba(0, 92, 197, 0.5);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ant-spin {
  display: inline-block;
  transition: transform var(--transition);
}

.btn-primary:not(:disabled):hover .btn-ant-spin {
  animation: antSpin 0.5s linear infinite;
}

@keyframes antSpin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ── Slider ────────────────────────────────────────────────────── */
.slider-wrap { display: flex; flex-direction: column; gap: 8px; }

.slider-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.alpha-badge {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
  background: var(--cyan-dim);
  padding: 2px 8px;
  border-radius: 99px;
  border: 1.5px solid var(--cyan);
}

.pheromone-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 99px;
  background: var(--phero-gradient);
  cursor: pointer;
  outline: none;
}

.pheromone-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--cyan);
  box-shadow: 0 2px 8px rgba(0, 92, 197, 0.4);
  cursor: pointer;
  transition: box-shadow var(--transition);
}

.pheromone-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 2px 14px rgba(0, 92, 197, 0.7);
}

.pheromone-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--cyan);
  box-shadow: 0 2px 8px rgba(0, 92, 197, 0.4);
  cursor: pointer;
}

.hint-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 6px;
}

/* ── Account/Profile/Leaderboard ───────────────────────────────── */
.auth-guest,
.auth-user {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-input {
  width: 100%;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-btn {
  margin-top: 0;
  padding: 10px 12px;
  font-size: 13px;
}

.auth-btn-secondary {
  background: #0a7d3e;
  box-shadow: 0 4px 14px rgba(10, 125, 62, 0.35);
}

.auth-btn-secondary:hover {
  background: #076731;
  box-shadow: 0 6px 20px rgba(10, 125, 62, 0.45);
}

.auth-btn-logout {
  background: #c0003e;
  box-shadow: 0 4px 14px rgba(192, 0, 62, 0.35);
}

.auth-btn-logout:hover {
  background: #a20035;
  box-shadow: 0 6px 20px rgba(192, 0, 62, 0.45);
}

.auth-user-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.profile-stat {
  background: var(--bg-raised);
  border: 1px solid #d8e4f0;
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.profile-stat span {
  font-size: 11px;
  color: var(--text-muted);
}

.profile-stat strong {
  font-size: 14px;
  color: var(--text-primary);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-raised);
  border: 1px solid #d8e4f0;
  border-radius: var(--radius-sm);
}

.leaderboard-item-me {
  border-color: var(--cyan);
  background: var(--cyan-dim);
}

.leaderboard-rank {
  font-weight: 700;
  color: var(--cyan);
}

.leaderboard-name {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.leaderboard-km {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Route Cards ────────────────────────────────────────────────── */
#route-cards { display: flex; flex-direction: column; gap: 8px; }

.route-card {
  background: var(--bg-raised);
  border: 1.5px solid #d8e4f0;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: all var(--transition);
  cursor: default;
}

.route-card-best {
  border-color: var(--cyan);
  background: var(--cyan-dim);
  box-shadow: 0 0 0 2px rgba(0, 92, 197, 0.15);
}

.route-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.route-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.route-card-best .route-label { color: var(--cyan); }

.route-score {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--cyan-dim);
  color: var(--cyan);
  border: 1px solid rgba(0, 92, 197, 0.3);
}

.route-card-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.route-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.route-stat-icon { font-size: 12px; }

/* Phero meter bar */
.phero-bar-wrap {
  margin-top: 8px;
  background: #d8e4f0;
  border-radius: 99px;
  height: 5px;
  overflow: hidden;
}

.phero-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--phero-gradient);
  transition: width 0.6s var(--ease);
}

/* ── Legend ─────────────────────────────────────────────────────── */
.legend-grid { display: flex; flex-direction: column; gap: 10px; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-swatch {
  width: 36px;
  height: 10px;
  border-radius: 99px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.08);
}

.legend-desc {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 2px;
}

.legend-desc strong {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 700;
}

.legend-desc span {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── About section ────────────────────────────────────────────── */
.about-section { padding-bottom: 14px; }

.about-card {
  background: var(--bg-raised);
  border: 1.5px solid #d8e4f0;
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.about-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.about-text strong { color: var(--cyan); font-weight: 700; }

.about-formula {
  background: #e8edf3;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  text-align: center;
  border: 1px solid #d0dae6;
}

.about-formula code {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--green);
  font-weight: 700;
  letter-spacing: -0.2px;
}

/* ================================================================
   MAP CONTAINER
   ================================================================ */
.map-container {
  position: fixed;
  top: var(--header-h);
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 1;
  background: var(--bg-page);
}

/* Override Leaflet defaults */
.leaflet-container {
  background: #e8edf3 !important;
  font-family: 'Space Grotesk', sans-serif;
  cursor: crosshair;
}

.leaflet-control-zoom {
  border: 1.5px solid #c8d8e8 !important;
  border-radius: var(--radius-sm) !important;
  background: #ffffff !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
  overflow: hidden;
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
  background: #ffffff !important;
  color: var(--text-primary) !important;
  border: none !important;
  border-bottom: 1px solid #d8e4f0 !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  transition: color var(--transition) !important;
}

.leaflet-control-zoom-out { border-bottom: none !important; }

.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
  background: var(--cyan-dim) !important;
  color: var(--cyan) !important;
}

.leaflet-control-attribution {
  background: rgba(255,255,255,0.85) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
}

.leaflet-control-attribution a {
  color: var(--text-secondary) !important;
}

/* ── Map Markers ─────────────────────────────────────────────── */
.map-marker {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: transform 0.2s;
}

.marker-a {
  background: var(--cyan);
  color: #ffffff;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 0 0 3px rgba(0, 92, 197, 0.3), 0 4px 12px rgba(0,0,0,0.25);
}

.marker-b {
  background: var(--green);
  color: #ffffff;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 0 0 3px rgba(10, 125, 62, 0.3), 0 4px 12px rgba(0,0,0,0.25);
}

.pos-marker {
  font-size: 24px;
  filter: drop-shadow(0 2px 6px rgba(180, 60, 0, 0.6));
  animation: posPulse 1s ease-in-out infinite;
}

@keyframes posPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

/* Route primary line animation */
.route-primary {
  animation: routeGlow 2s ease-in-out infinite alternate;
}

@keyframes routeGlow {
  from { opacity: 0.85; }
  to   { opacity: 1; }
}

/* ================================================================
   FLOATING ACTION BUTTONS
   ================================================================ */
.fab-group {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 800;
}

.fab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 0 14px;
  height: 50px;
  border-radius: 99px;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.fab-icon { font-size: 18px; }
.fab-label { font-size: 13px; }

.fab-track {
  background: #ffffff;
  border-color: rgba(212, 96, 0, 0.4);
  color: var(--orange);
}

.fab-track:hover {
  border-color: var(--orange);
  background: rgba(212, 96, 0, 0.08);
  box-shadow: 0 4px 20px rgba(212, 96, 0, 0.25);
  transform: translateY(-2px);
}

.fab-track.recording {
  background: rgba(212, 96, 0, 0.10);
  border-color: var(--orange);
  animation: recordPulse 1.2s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(212, 96, 0, 0.3); }
  50%       { box-shadow: 0 0 22px rgba(212, 96, 0, 0.65); }
}

/* ── POI Styles ─────────────────────────────────────────────── */
.poi-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.poi-actions {
  display: flex;
  gap: 8px;
}

.btn-secondary {
  background: var(--bg-raised);
  border: 1.5px solid #d8e4f0;
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--cyan);
}

.poi-marker {
  font-size: 24px;
  text-align: center;
  line-height: 30px;
}

.poi-popup {
  font-family: var(--font-family);
  max-width: 200px;
}

.poi-popup h4 {
  margin: 0 0 4px 0;
  color: var(--text-primary);
}

.poi-popup p {
  margin: 0 0 4px 0;
  color: var(--text-secondary);
}

.poi-popup small {
  color: var(--text-muted);
  font-size: 12px;
}

.fab-locate {
  background: #ffffff;
  border-color: rgba(0, 92, 197, 0.35);
  color: var(--cyan);
}

.fab-locate:hover {
  border-color: var(--cyan);
  background: var(--cyan-dim);
  box-shadow: 0 4px 20px rgba(0, 92, 197, 0.25);
  transform: translateY(-2px);
}

/* Stato "in ricerca GPS" */
.fab-locate.locating {
  border-color: var(--cyan);
  animation: locatePulse 1s ease-in-out infinite;
}

@keyframes locatePulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(0, 92, 197, 0.2); }
  50%       { box-shadow: 0 2px 22px rgba(0, 92, 197, 0.55); }
}

/* ================================================================
   TRACKING BAR
   ================================================================ */
.tracking-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  height: 54px;
  background: #ffffff;
  border-top: 2px solid rgba(212, 96, 0, 0.5);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  z-index: 700;
}

.tracking-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--orange);
  animation: trackPulse 1s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes trackPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 96, 0, 0.6); }
  50%       { box-shadow: 0 0 0 8px rgba(212, 96, 0, 0); }
}

.tracking-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--orange);
}

.tracking-distance {
  font-family: 'Space Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-left: auto;
}

.btn-stop {
  padding: 8px 16px;
  background: rgba(212, 96, 0, 0.10);
  border: 2px solid var(--orange);
  border-radius: var(--radius-sm);
  color: var(--orange);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-stop:hover {
  background: var(--orange);
  color: #ffffff;
}

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */
.toast-container {
  position: fixed;
  bottom: 80px;
  right: 28px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  max-width: 320px;
  border: 1.5px solid transparent;
  box-shadow: 0 4px 20px rgba(0,0,0,0.14);
  transform: translateY(16px);
  opacity: 0;
  transition: all 0.35s var(--ease);
  line-height: 1.4;
}

.toast.toast-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast-info    { background: #dbeeff; border-color: #90c0ff; color: #003a99; }
.toast-success { background: #d4f7e5; border-color: #6fdc9f; color: #025c2e; }
.toast-warning { background: #ffecd4; border-color: #ffc97a; color: #8a4200; }
.toast-error   { background: #ffe0e8; border-color: #ff91aa; color: #800028; }

/* ================================================================
   RESPONSIVE — Mobile
   ================================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .header-stats { display: none; }
  .sidebar-toggle { display: flex; }

  .sidebar {
    width: 320px;
    transform: translateX(-100%);
    z-index: 1100;
  }

  .sidebar.open { transform: translateX(0); }

  .map-container { left: 0; }

  .fab-group { right: 14px; bottom: 20px; }
  .fab-label { display: none; }
  .fab { width: 52px; height: 52px; padding: 0; justify-content: center; }

  .tracking-bar { left: 0; }
}

/* ================================================================
   NAVIGATION PANEL — Turn-by-turn
   ================================================================ */

.nav-panel { display: flex; flex-direction: column; gap: 14px; }

/* Current maneuver card */
.nav-current {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--cyan-dim);
  border: 1.5px solid rgba(0, 92, 197, 0.3);
  border-radius: var(--radius-md);
  padding: 14px;
}

.nav-arrow-wrap {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--cyan-dim);
  border: 2.5px solid var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(0, 92, 197, 0.15);
}

/* The arrow icon — CSS rotation drives direction */
.nav-arrow-icon {
  font-size: 34px;
  display: inline-block;
  transition: transform 0.4s var(--ease);
  line-height: 1;
}

.nav-arrow-icon[data-dir="straight"]      { transform: rotate(0deg); }
.nav-arrow-icon[data-dir="left"]          { transform: rotate(-90deg); }
.nav-arrow-icon[data-dir="right"]         { transform: rotate(90deg); }
.nav-arrow-icon[data-dir="slight left"]   { transform: rotate(-45deg); }
.nav-arrow-icon[data-dir="slight right"]  { transform: rotate(45deg); }
.nav-arrow-icon[data-dir="sharp left"]    { transform: rotate(-130deg); }
.nav-arrow-icon[data-dir="sharp right"]   { transform: rotate(130deg); }
.nav-arrow-icon[data-dir="uturn"]         { transform: rotate(180deg); }
.nav-arrow-icon[data-dir="arrive"]        { transform: none; }
.nav-arrow-icon[data-dir="depart"]        { transform: rotate(0deg); }
.nav-arrow-icon[data-dir="roundabout"]    { transform: none; }

.nav-details { flex: 1; min-width: 0; }

.nav-dist {
  font-family: 'Space Mono', monospace;
  font-size: 30px;
  font-weight: 700;
  color: var(--cyan);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.nav-instruction {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 5px;
  line-height: 1.35;
}

.nav-street {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.nav-step-counter {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* Progress */
.nav-progress { display: flex; flex-direction: column; gap: 6px; }

.nav-progress-bar {
  height: 6px;
  background: #d8e4f0;
  border-radius: 99px;
  overflow: hidden;
}

.nav-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  border-radius: 99px;
  transition: width 0.6s var(--ease);
}

.nav-totals {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-totals strong { color: var(--text-secondary); }

/* Next steps list */
.nav-steps-list { display: flex; flex-direction: column; gap: 5px; }

.nav-step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-raised);
  border: 1px solid #d8e4f0;
  border-radius: var(--radius-sm);
}

.nav-step-arrow {
  font-size: 13px;
  display: inline-block;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  transition: transform 0.3s var(--ease);
}

/* Same direction mapping for step list mini-arrows */
.nav-step-arrow[data-dir="left"]         { transform: rotate(-90deg); }
.nav-step-arrow[data-dir="right"]        { transform: rotate(90deg); }
.nav-step-arrow[data-dir="slight left"]  { transform: rotate(-45deg); }
.nav-step-arrow[data-dir="slight right"] { transform: rotate(45deg); }
.nav-step-arrow[data-dir="sharp left"]   { transform: rotate(-130deg); }
.nav-step-arrow[data-dir="sharp right"]  { transform: rotate(130deg); }
.nav-step-arrow[data-dir="uturn"]        { transform: rotate(180deg); }

.nav-step-text {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.nav-step-dist {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Stop nav button */
.btn-stop-nav {
  width: 100%;
  padding: 12px;
  background: rgba(192, 0, 62, 0.07);
  border: 2px solid rgba(192, 0, 62, 0.4);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-stop-nav:hover {
  background: rgba(192, 0, 62, 0.15);
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(192, 0, 62, 0.15);
}

/* Navigate button on route card */
.btn-nav-start {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
  padding: 12px 16px;
  background: var(--cyan);
  border: none;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.2px;
  box-shadow: 0 3px 10px rgba(0, 92, 197, 0.3);
}

.btn-nav-start:hover {
  background: #0047a0;
  box-shadow: 0 5px 16px rgba(0, 92, 197, 0.45);
  transform: translateY(-1px);
}

/* ================================================================
   UTILITY ANIMATIONS
   ================================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s var(--ease) both; }

/* Heatmap layer fade-in on load */
.leaflet-heatmap-layer {
  transition: opacity 0.5s ease;
}

/* ================================================================
   POI — Points of Interest
   ================================================================ */

/* FAB POI button */
.fab-poi {
  background: #ffffff;
  border-color: rgba(107, 0, 212, 0.35);
  color: var(--purple);
}
.fab-poi:hover {
  border-color: var(--purple);
  background: rgba(107, 0, 212, 0.08);
  box-shadow: 0 4px 20px rgba(107, 0, 212, 0.25);
  transform: translateY(-2px);
}
.fab-poi.recording {
  border-color: var(--purple);
  background: rgba(107, 0, 212, 0.10);
  animation: poiPulse 1.2s ease-in-out infinite;
}
@keyframes poiPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(107, 0, 212, 0.3); }
  50%       { box-shadow: 0 0 22px rgba(107, 0, 212, 0.65); }
}

/* Modal overlay */
.poi-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 20px;
}
.poi-modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.poi-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.poi-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.poi-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--bg-raised);
  border: 1.5px solid #d8e4f0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 22px;
  transition: all var(--transition);
}
.poi-type-btn span {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 600;
}
.poi-type-btn:hover,
.poi-type-btn.selected {
  border-color: var(--cyan);
  background: var(--cyan-dim);
}
.poi-type-btn.selected {
  box-shadow: var(--cyan-glow);
}
.poi-desc-input {
  width: 100%;
  min-height: 80px;
  background: var(--bg-raised);
  border: 1.5px solid #c8d8e8;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
}
.poi-desc-input:focus {
  border-color: var(--cyan);
  box-shadow: var(--cyan-glow);
}
.poi-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: center;
}

/* Marker sulla mappa */
.poi-map-marker {
  font-size: 22px;
  line-height: 32px;
  text-align: center;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  cursor: pointer;
  transition: transform 0.2s;
}
.poi-map-marker:hover { transform: scale(1.25); }

/* Popup POI */
.poi-popup h4 { margin: 0 0 4px; font-size: 14px; color: var(--text-primary); }
.poi-popup p  { margin: 0 0 4px; font-size: 12px; color: var(--text-secondary); }
.poi-popup small { font-size: 11px; color: var(--text-muted); }
