@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --ink: #eaf3f4;
  --muted: #8ba1a8;
  --panel: #0b1821;
  --panel-2: #10232c;
  --line: rgba(172, 209, 214, .14);
  --cyan: #39e1d0;
  --lime: #b7ec68;
  --amber: #ffc857;
  --red: #ff5874;
  --mono: "DM Mono", monospace;
  --sans: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: #071218; color: var(--ink); font-family: var(--sans); overflow: hidden; }
button, select, input { font: inherit; }
button { color: inherit; }

.topbar {
  height: 72px; display: flex; align-items: center; gap: 28px; padding: 0 24px;
  background: #08151d; border-bottom: 1px solid var(--line); position: relative; z-index: 1001;
}
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; min-width: 260px; }
.brand b { font-size: 20px; letter-spacing: .18em; display: block; line-height: 1; }
.brand small { color: var(--muted); display: block; font-size: 10px; margin-top: 5px; letter-spacing: .03em; }
.brand-mark { width: 36px; height: 36px; position: relative; display: grid; align-content: center; gap: 4px; transform: skewY(-12deg); }
.brand-mark i { background: var(--cyan); height: 3px; border-radius: 3px; display: block; }
.brand-mark i:nth-child(1) { width: 23px; margin-left: 10px; }
.brand-mark i:nth-child(2) { width: 32px; }
.brand-mark i:nth-child(3) { width: 19px; margin-left: 4px; }
.top-status { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.top-status small, .top-status b { display: block; }
.top-status small { color: var(--muted); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.top-status b { font: 500 11px var(--mono); margin-top: 3px; }
.status-dot { width: 7px; height: 7px; background: var(--amber); box-shadow: 0 0 12px var(--amber); border-radius: 50%; }
.status-dot.live { background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.experimental { color: var(--amber); border: 1px solid rgba(255,200,87,.35); border-radius: 3px; padding: 7px 10px; font: 500 9px var(--mono); letter-spacing: .06em; }

.workspace { height: calc(100vh - 144px); display: grid; grid-template-columns: minmax(0, 1fr) 440px; }
.map-shell { min-width: 0; position: relative; border-right: 1px solid var(--line); }
#map { width: 100%; height: 100%; background: #0b1d25; }
.leaflet-control-zoom { border: 1px solid var(--line) !important; box-shadow: 0 8px 24px rgba(0,0,0,.24) !important; }
.leaflet-control-zoom a { color: var(--ink) !important; background: rgba(9,24,32,.94) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { color: #789099 !important; background: rgba(6,18,24,.78) !important; }
.leaflet-control-attribution a { color: #a5bcc1 !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #0b1b23; color: var(--ink); }
.leaflet-popup-content { font: 12px var(--mono); line-height: 1.6; }

.glass { background: rgba(7, 20, 27, .82); border: 1px solid rgba(184, 225, 228, .17); backdrop-filter: blur(14px); box-shadow: 0 10px 30px rgba(0,0,0,.22); }
.map-title { position: absolute; z-index: 500; left: 24px; top: 22px; border-radius: 6px; padding: 15px 18px 14px; pointer-events: none; }
.eyebrow { display: block; color: var(--cyan); font: 500 9px var(--mono); letter-spacing: .13em; }
.map-title h1 { font-size: 18px; margin: 6px 0 3px; letter-spacing: -.02em; }
.map-title p { font: 10px var(--mono); color: var(--muted); margin: 0; }
.quality-row { display: flex; gap: 6px; margin-top: 10px; }
.quality-row span { padding: 4px 6px; border: 1px solid rgba(57,225,208,.18); border-radius: 3px; background: rgba(57,225,208,.06); color: #a8c2c7; font: 8px var(--mono); }
.turbulence-raster { image-rendering: auto; filter: saturate(1.04) contrast(1.04); }
.map-actions { position: absolute; z-index: 500; right: 20px; top: 20px; display: flex; border-radius: 5px; overflow: hidden; }
.action-button, .icon-button { background: transparent; border: 0; cursor: pointer; }
.action-button { padding: 11px 15px; font-size: 11px; font-weight: 700; }
.action-button span { color: var(--cyan); margin-right: 6px; }
.action-button.active { background: rgba(57,225,208,.14); }
.icon-button { width: 38px; color: var(--muted); border-left: 1px solid var(--line); font-size: 20px; }
.route-hint { position: absolute; z-index: 500; top: 75px; right: 20px; padding: 9px 12px; color: var(--muted); font: 10px var(--mono); border-radius: 4px; display: none; }
.route-hint.visible { display: block; }
.legend { z-index: 500; position: absolute; left: 24px; bottom: 28px; width: 224px; padding: 12px 14px; border-radius: 5px; }
.legend-labels, .legend-values { display: flex; justify-content: space-between; color: var(--muted); font: 9px var(--mono); }
.legend-scale { height: 7px; border-radius: 7px; margin: 7px 0 5px; background: linear-gradient(90deg, #183b45 0%, #25c8b7 32%, #e3e86d 53%, #ffae46 73%, #ee4168 100%); }
.map-disclaimer { position: absolute; z-index: 500; right: 18px; bottom: 9px; color: rgba(225,239,241,.52); font: 9px var(--mono); }

.sidebar { background: var(--panel); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #28414b transparent; }
.control-section, .provenance { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; }
.section-heading b { color: var(--cyan); font: 500 10px var(--mono); }
.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.level-button { border: 1px solid var(--line); background: #0d1d25; padding: 9px 5px; border-radius: 4px; color: #9fb0b5; font: 500 10px var(--mono); cursor: pointer; transition: .15s ease; }
.level-button:hover { border-color: rgba(57,225,208,.5); color: var(--ink); }
.level-button.active { color: #041615; background: var(--cyan); border-color: var(--cyan); font-weight: 700; }
.field-label { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 9px; }
.select-wrap { position: relative; }
.select-wrap:after { content: "⌄"; position: absolute; right: 12px; top: 8px; color: var(--cyan); pointer-events: none; }
select { width: 100%; appearance: none; background: #0d1d25; color: var(--ink); border: 1px solid var(--line); border-radius: 4px; padding: 10px 34px 10px 12px; font-size: 11px; }

.risk-card { margin: 18px 22px 12px; padding: 17px; display: grid; grid-template-columns: 76px 1fr; gap: 16px; align-items: center; border-radius: 6px; background: linear-gradient(135deg, rgba(57,225,208,.10), rgba(15,35,44,.42)); border: 1px solid rgba(57,225,208,.18); }
.risk-ring { width: 72px; height: 72px; border-radius: 50%; display: grid; place-content: center; text-align: center; background: radial-gradient(circle at center, #0d1f27 58%, transparent 60%), conic-gradient(var(--cyan) 0deg, #223740 0deg); }
.risk-ring span { font: 500 19px var(--mono); }
.risk-ring small { color: var(--muted); font: 8px var(--mono); margin-top: 2px; }
.risk-card h2 { font-size: 16px; margin: 6px 0 4px; }
.risk-card p { color: var(--muted); font-size: 10px; line-height: 1.45; margin: 0; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 22px 15px; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.metrics article { padding: 11px 9px; text-align: center; background: #0d1d25; border-right: 1px solid var(--line); }
.metrics article:last-child { border: 0; }
.metrics span { display: block; min-height: 24px; color: var(--muted); font-size: 8px; line-height: 1.25; }
.metrics b { font: 500 12px var(--mono); }
.warning-card { margin: 0 22px 16px; padding: 14px; display: grid; grid-template-columns: 28px 1fr; gap: 11px; border: 1px solid rgba(255,200,87,.25); border-radius: 5px; background: rgba(255,200,87,.06); }
.warning-icon { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: #111; background: var(--amber); font: 700 13px var(--mono); }
.warning-card .eyebrow { color: var(--amber); }
.warning-card h3 { font-size: 12px; margin: 4px 0 2px; }
.warning-card p { color: var(--muted); font-size: 9px; margin: 0; }
.route-panel { display: none; padding: 18px 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.route-panel.visible { display: block; }
.profile-toolbar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: -2px 0 10px; }
.profile-tab { border: 1px solid var(--line); border-radius: 3px; padding: 7px 4px; background: #0d1d25; color: var(--muted); font: 500 8px var(--mono); cursor: pointer; }
.profile-tab:hover { color: var(--ink); border-color: rgba(57,225,208,.35); }
.profile-tab.active { background: rgba(57,225,208,.12); color: var(--cyan); border-color: rgba(57,225,208,.4); }
.profile-chart-wrap { position: relative; width: 100%; height: 252px; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: #08171e; }
#altitudeChart { display: block; width: 100%; height: 100%; }
.chart-tooltip { position: absolute; z-index: 2; display: none; min-width: 116px; padding: 7px 9px; pointer-events: none; transform: translate(9px, -100%); border: 1px solid rgba(184,225,228,.24); border-radius: 3px; background: rgba(5,16,22,.94); box-shadow: 0 8px 18px rgba(0,0,0,.3); color: var(--ink); font: 8px/1.55 var(--mono); }
.chart-tooltip.visible { display: block; }
.profile-key { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; color: var(--muted); font: 8px/1.4 var(--mono); margin: 8px 0 11px; }
.profile-key span { white-space: nowrap; color: #bdd0d3; }
.profile-key i { display: inline-block; width: 13px; height: 2px; margin: 0 4px 2px 0; background: #fff; box-shadow: 0 0 4px rgba(255,255,255,.75); }
.profile-key small { color: #70888f; text-align: right; font: inherit; }
#routeResults:before { content: "QUOTE PIÙ FAVOREVOLI"; display: block; margin-bottom: 4px; color: var(--muted); font: 8px var(--mono); letter-spacing: .08em; }
.route-choice { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); font: 10px var(--mono); }
.route-choice:first-child { border-top: 0; }
.route-choice b { color: var(--cyan); }
.route-choice small { color: var(--muted); }
.route-alert { color: var(--amber); font-size: 9px; line-height: 1.45; margin-top: 10px; }
.provenance { border-top: 1px solid var(--line); }
.provenance p { color: var(--muted); font-size: 9px; line-height: 1.55; margin: 8px 0; }
.provenance a { color: var(--cyan); font: 9px var(--mono); text-decoration: none; }

.timeline { height: 72px; display: grid; grid-template-columns: 52px minmax(0,1fr) 52px; background: #08151d; border-top: 1px solid var(--line); position: relative; z-index: 1001; }
.time-nav { background: transparent; border: 0; border-right: 1px solid var(--line); font-size: 30px; color: var(--muted); cursor: pointer; }
.time-nav:last-child { border: 0; border-left: 1px solid var(--line); }
.time-nav:hover { color: var(--cyan); }
.timeline-track { position: relative; padding: 12px 28px 0; }
.timeline-label { display: flex; align-items: baseline; gap: 12px; font: 10px var(--mono); }
.timeline-label span { color: var(--muted); }
.timeline-label b { color: var(--ink); }
#timeSlider { width: 100%; height: 3px; margin: 11px 0 0; accent-color: var(--cyan); cursor: pointer; display: block; }
.timeline-ticks { display: flex; justify-content: space-between; color: #607880; font: 8px var(--mono); margin-top: 3px; }
.toast { position: fixed; z-index: 3000; left: 50%; bottom: 90px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #102630; color: var(--ink); border: 1px solid var(--line); border-radius: 4px; padding: 10px 14px; font: 10px var(--mono); transition: .2s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  body { overflow: auto; }
  .topbar { height: 62px; padding: 0 14px; }
  .brand { min-width: 0; }
  .brand small, .top-status { display: none; }
  .experimental { margin-left: auto; font-size: 7px; }
  .workspace { display: block; height: auto; }
  .map-shell { height: 58vh; border-right: 0; }
  .sidebar { height: auto; overflow: visible; }
  .timeline { position: sticky; bottom: 0; height: 68px; }
  .map-title { left: 12px; top: 12px; max-width: calc(100% - 110px); }
  .map-title h1 { font-size: 14px; }
  .map-actions { right: 10px; top: 10px; }
  .action-button { width: 40px; overflow: hidden; white-space: nowrap; padding: 10px 12px; }
  .action-button span { font-size: 16px; }
  .legend { left: 12px; bottom: 24px; }
  .profile-chart-wrap { height: 270px; }
}
