:root {
  --bg: #101418;
  --panel: rgba(18, 23, 29, 0.92);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e8eaed;
  --text-dim: #9aa0a6;
  --accent: #f5c518;
  --accent-dim: rgba(245, 197, 24, 0.15);
  --ok: #34d399;
  --err: #f87171;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  font-family: var(--font);
  color: var(--text);
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

#globe {
  position: absolute;
  inset: 0;
  z-index: 500;
  background: radial-gradient(ellipse at center, #12161c 0%, #05070a 100%);
}
#globe canvas { display: block; }
#globe-hint {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 501;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 11px;
  pointer-events: none;
}

.hidden { display: none !important; }

/* ---------------- barra superiore ---------------- */
#topbar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  /* sopra #controls (1000): altrimenti i menu a tendina della topbar
     (ricerca, voli speciali) finiscono sotto i controlli mappa che, a parità
     di z-index e venendo dopo nel DOM, intercettano i clic */
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

#brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
#brand b { color: var(--accent); font-weight: 700; }

#search-wrap { position: relative; flex: 1; max-width: 420px; }

#search {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--text-dim); }

#search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}
.search-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}
.search-item:hover { background: var(--accent-dim); }
.search-item .si-main { font-weight: 600; }
.search-item .si-sub { color: var(--text-dim); font-size: 12px; }

#stats { margin-left: auto; text-align: right; white-space: nowrap; }
#stat-count { font-size: 16px; font-weight: 700; color: var(--accent); }
.stat-sub { display: block; font-size: 11px; color: var(--text-dim); }

/* ---------------- voli speciali ---------------- */
#btn-special {
  padding: 6px 11px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 8px;
  color: var(--err);
  font-size: 12.5px;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
}
#btn-special:hover { background: rgba(248, 113, 113, 0.22); }
#btn-special.pulse { animation: pulse-red 1.2s infinite; }
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.45); }
  50% { box-shadow: 0 0 10px 3px rgba(248, 113, 113, 0.55); }
}

#special-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 320px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}
.sp-item:hover { background: var(--accent-dim); }
.sp-item .si-main { font-weight: 600; }
.sp-item .si-sub { color: var(--text-dim); font-size: 11px; margin-left: auto; text-align: right; }
.sp-tag {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}
.sp-tag.emg { background: rgba(248, 113, 113, 0.16); color: var(--err); }
.sp-tag.mil { background: rgba(52, 211, 153, 0.14); color: var(--ok); }

/* ---------------- controlli layer/filtri ---------------- */
#controls {
  position: absolute;
  top: 76px;
  right: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.ctrl-group {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.ctrl-group button {
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 12.5px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ctrl-group button:hover { color: var(--text); }
.ctrl-group button.active { background: var(--accent); color: #1a1a1a; font-weight: 600; }

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--accent); cursor: pointer; }
.toggle:hover { color: var(--text); }

.ctrl-col {
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  padding: 9px 11px;
  width: 216px;
}
.ctrl-col input[type="text"] {
  padding: 6px 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font);
  outline: none;
}
.ctrl-col input[type="text"]:focus { border-color: var(--accent); }
.f-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}
.f-row span { width: 60px; }
.f-row b { width: 32px; text-align: right; font-size: 10.5px; color: var(--text); font-weight: 600; }
.f-row input[type="range"] { flex: 1; accent-color: var(--accent); cursor: pointer; }

/* ---------------- legenda quota ---------------- */
#legend {
  position: absolute;
  bottom: 24px;
  right: 12px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  font-size: 10.5px;
  color: var(--text-dim);
  box-shadow: var(--shadow);
}
#legend-bar {
  width: 120px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg,
    hsl(30, 85%, 55%), hsl(60, 85%, 55%), hsl(120, 85%, 50%),
    hsl(190, 85%, 55%), hsl(230, 85%, 62%), hsl(280, 85%, 62%));
}

/* ---------------- timeline meteo ---------------- */
#weather-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
#wx-play {
  width: 32px;
  height: 26px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
#wx-play:hover { background: rgba(255, 255, 255, 0.14); }
#wx-slider { width: 190px; accent-color: var(--accent); cursor: pointer; }
#wx-time { font-size: 11.5px; color: var(--text-dim); min-width: 108px; }

/* ---------------- stato ---------------- */
#status {
  position: absolute;
  bottom: 24px;
  left: 12px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  font-size: 11.5px;
  color: var(--text-dim);
  box-shadow: var(--shadow);
}
#status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.3s;
}
#status-dot.ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
#status-dot.err { background: var(--err); box-shadow: 0 0 6px var(--err); }

/* ---------------- pannello dettagli ---------------- */
#panel, #airport-panel {
  position: absolute;
  top: 76px;
  left: 12px;
  bottom: 56px; /* lascia visibile l'indicatore di stato sotto */
  z-index: 1000;
  width: 320px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  overflow-y: auto;
}

#panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px 10px;
}
#p-callsign { margin: 0; font-size: 22px; letter-spacing: 0.5px; color: var(--accent); }
#p-operator { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

#panel-actions { display: flex; gap: 6px; }
#panel-actions button {
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}
#panel-actions button:hover { background: rgba(255, 255, 255, 0.14); }
#btn-follow.active { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 600; }

#p-photo-wrap { position: relative; margin: 0 12px; border-radius: 8px; overflow: hidden; min-height: 120px; background: rgba(255,255,255,0.04); }
#p-photo { display: block; width: 100%; height: auto; }
#p-photo-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 12px;
}
#p-photo-credit {
  position: absolute; right: 6px; bottom: 6px;
  padding: 2px 7px;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 5px;
  color: #fff; font-size: 10px;
  text-decoration: none;
}
#p-photo-credit:hover { text-decoration: underline; }

#p-route {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 12px 12px 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}
.route-airport { flex: 1; min-width: 0; }
.route-airport:last-child { text-align: right; }
.route-code { font-size: 19px; font-weight: 700; }
.route-name {
  font-size: 11px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.route-arrow { color: var(--accent); font-size: 15px; }

#p-progress { margin: 10px 12px 0; }
#p-progress-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
#p-progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.6s ease;
}
#p-progress-text { margin-top: 5px; font-size: 11px; color: var(--text-dim); }

#p-status {
  margin: 10px 12px 0;
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.35;
}
#p-status.ok { background: rgba(52, 211, 153, 0.12); border: 1px solid rgba(52, 211, 153, 0.35); color: var(--ok); }
#p-status.warn { background: rgba(245, 197, 24, 0.1); border: 1px solid rgba(245, 197, 24, 0.35); color: var(--accent); }
#p-status.alert { background: rgba(248, 113, 113, 0.12); border: 1px solid rgba(248, 113, 113, 0.4); color: var(--err); }

#p-schedule {
  margin: 10px 12px 0;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}
#p-schedule .sched-delay { font-weight: 700; color: var(--err); }
#p-schedule .sched-ok { font-weight: 700; color: var(--ok); }
#p-schedule .sched-dim { color: var(--text-dim); font-size: 11px; }

.search-item.global { border-top: 1px solid var(--panel-border); }
.search-item.global .si-main { color: var(--accent); }

/* ---------------- pannello aeroporto ---------------- */
#ap-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px 6px;
}
#ap-code { margin: 0; font-size: 20px; color: var(--accent); }
#ap-name { font-size: 12px; color: var(--text-dim); margin-top: 2px; max-width: 230px; }
#ap-close {
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
}
#ap-close:hover { background: rgba(255, 255, 255, 0.14); }
.ap-section { padding: 4px 12px; }
.ap-section h3 {
  margin: 8px 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}
.ap-list { display: flex; flex-direction: column; gap: 4px; }
.ap-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}
.ap-item:hover { background: var(--accent-dim); }
.ap-item .si-main { font-weight: 600; }
.ap-item .si-sub { color: var(--text-dim); font-size: 11.5px; text-align: right; margin-left: auto; }

.ap-status {
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.ap-status.ph-cruise { background: rgba(96, 165, 250, 0.16); color: #93c5fd; }
.ap-status.ph-climb { background: rgba(52, 211, 153, 0.16); color: #6ee7b7; }
.ap-status.ph-descend { background: rgba(245, 197, 24, 0.16); color: var(--accent); }
.ap-status.ph-taxi { background: rgba(167, 139, 250, 0.16); color: #c4b5fd; }
.ap-status.ph-ground { background: rgba(154, 160, 166, 0.16); color: var(--text-dim); }

#ap-sched h4 {
  margin: 8px 2px 4px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  font-weight: 600;
}
.sched-time {
  font-weight: 700;
  color: var(--accent);
  font-size: 12.5px;
  flex-shrink: 0;
  width: 42px;
}

/* icone aeree sul globo (al posto dei pallini) */
#globe-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;   /* il drag del globo resta libero */
  z-index: 2;
}
.globe-plane {
  position: absolute;
  left: -8px;
  top: -8px;
  width: 16px;
  height: 16px;
  pointer-events: auto;   /* ma le icone restano cliccabili */
  cursor: pointer;
}
.globe-plane svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 2px rgba(0,0,0,0.9)); }
.globe-plane:hover svg path { stroke: #fff; stroke-width: 1px; }
.ap-empty { font-size: 12px; color: var(--text-dim); padding: 2px 2px 6px; }
#ap-note { margin-top: auto; padding: 10px 14px 14px; font-size: 10.5px; color: var(--text-dim); }

#p-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
}
.cell {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}
.cell label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); }
.cell output { display: block; font-size: 14px; font-weight: 600; margin-top: 3px; }
.cell output small { font-weight: 400; color: var(--text-dim); font-size: 11px; }

#p-note { padding: 0 14px 14px; font-size: 10.5px; color: var(--text-dim); }

/* ---------------- icone aerei ---------------- */
.plane-wrap { background: none !important; border: none !important; }
.plane-holder { position: absolute; left: 0; top: 0; }
.plane-icon {
  position: absolute;
  left: 0; top: 0;
  width: var(--plane-size, 26px);
  height: var(--plane-size, 26px);
  margin-left: calc(var(--plane-size, 26px) / -2);
  margin-top: calc(var(--plane-size, 26px) / -2);
  cursor: pointer;
  transition: transform 0.9s linear;
}
.plane-icon.selected, .plane-icon:hover {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.8));
}
.plane-icon svg { width: 100%; height: 100%; display: block; }
.plane-icon.grounded { opacity: 0.65; width: calc(var(--plane-size, 26px) * 0.72); height: calc(var(--plane-size, 26px) * 0.72); margin-left: calc(var(--plane-size, 26px) * -0.36); margin-top: calc(var(--plane-size, 26px) * -0.36); }
.plane-icon.selected svg path { stroke: #ffffff; stroke-width: 1.6px; }
.plane-icon:hover svg path { stroke: #ffffff; stroke-width: 1px; }

/* anello pulsante per le emergenze */
.plane-holder.emergency::before {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: calc(var(--plane-size, 26px) * 1.7);
  height: calc(var(--plane-size, 26px) * 1.7);
  margin-left: calc(var(--plane-size, 26px) * -0.85);
  margin-top: calc(var(--plane-size, 26px) * -0.85);
  border: 2px solid rgba(248, 113, 113, 0.85);
  border-radius: 50%;
  pointer-events: none;
  animation: emg-ring 1.3s ease-out infinite;
}
@keyframes emg-ring {
  0% { transform: scale(0.55); opacity: 1; }
  100% { transform: scale(1.15); opacity: 0; }
}
.plane-holder.emergency .plane-icon svg path { stroke: #ff3b3b; stroke-width: 1.4px; }

/* etichetta stile FR24: box con callsign, quota e velocità
   (fuori da .plane-icon così non ruota con l'aereo) */
.plane-label {
  position: absolute;
  left: calc(var(--plane-size, 26px) / 2 + 4px);
  top: -12px;
  padding: 3px 7px;
  background: rgba(13, 17, 22, 0.87);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-left: 2px solid var(--accent);
  border-radius: 5px;
  font-size: 10px;
  font-family: var(--font);
  line-height: 1.3;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
}
.plane-label b {
  display: block;
  color: var(--accent);
  font-size: 10.5px;
  letter-spacing: 0.3px;
}
.plane-label span { color: var(--text-dim); }

/* tooltip leaflet ristilizzato */
.leaflet-tooltip.plane-tip {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--font);
  font-size: 11.5px;
  box-shadow: var(--shadow);
  padding: 6px 9px;
}
.leaflet-tooltip.plane-tip::before { display: none; }
.plane-tip b { color: var(--accent); }
.plane-tip .tip-sub { color: var(--text-dim); font-size: 10.5px; }

/* attribution leaflet in tema */
.leaflet-control-attribution {
  background: rgba(16, 20, 24, 0.75) !important;
  color: var(--text-dim) !important;
  font-size: 9.5px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

.leaflet-control-zoom { margin-top: 140px !important; }
.leaflet-control-zoom a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-color: var(--panel-border) !important;
}
.leaflet-control-zoom a:hover { background: rgba(255, 255, 255, 0.1) !important; }

/* ---------------- bottone controlli (solo mobile) ---------------- */
#btn-controls {
  display: none;
  position: absolute;
  top: 76px;
  right: 12px;
  z-index: 1001;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
body.controls-open #btn-controls { background: var(--accent); color: #1a1a1a; }

/* ---------------- responsive ---------------- */
@media (max-width: 720px) {
  #topbar {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 7px 10px;
  }
  #brand span { display: none; }        /* resta solo l'icona */
  #search-wrap { max-width: none; }
  #stats { display: none; }
  #btn-special { padding: 6px 8px; font-size: 11px; }

  /* controlli chiusi di default, si aprono col bottone ☰ */
  #btn-controls { display: flex; }
  #controls { display: none; top: 126px; }
  body.controls-open #controls { display: flex; }
  .ctrl-col { width: min(240px, calc(100vw - 24px)); }

  /* pannelli come bottom-sheet */
  #panel, #airport-panel {
    width: calc(100vw - 24px);
    top: auto;
    max-height: 58vh;
    bottom: 12px;
  }

  /* barra meteo a tutta larghezza, slider elastico */
  #weather-bar {
    left: 12px;
    right: 12px;
    transform: none;
    bottom: 12px;
  }
  #wx-slider { width: auto; flex: 1; }
  #wx-time { min-width: 0; white-space: nowrap; }

  /* lo zoom si fa col pinch, l'indicatore di stato si sposta in alto */
  .leaflet-control-zoom { display: none; }
  #status { bottom: auto; top: 64px; left: 12px; }
  #legend { display: none; }
}

/* ---------------- icone navi (layer AIS di CraftWatch) ---------------- */
.ship-icon {
  position: absolute;
  left: 0; top: 0;
  width: calc(var(--plane-size, 26px) * 0.62);
  height: calc(var(--plane-size, 26px) * 0.62);
  margin-left: calc(var(--plane-size, 26px) * -0.31);
  margin-top: calc(var(--plane-size, 26px) * -0.31);
  cursor: pointer;
  transition: transform 0.9s linear;
}
.ship-icon svg { width: 100%; height: 100%; display: block; }
.ship-icon.moored { opacity: 0.55; }
.ship-icon.selected svg path, .ship-icon:hover svg path { stroke: #ffffff; stroke-width: 1.4px; }

#ship-panel {
  position: absolute;
  top: 76px;
  left: 12px;
  bottom: 56px;
  z-index: 1000;
  width: 320px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  overflow-y: auto;
}
#ship-panel.hidden { display: none; }
#s-name { margin: 0; font-size: 20px; color: var(--accent); }
#s-flag { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
#s-dest {
  margin: 4px 12px 0;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  font-size: 12.5px;
}
#s-dest b { color: var(--accent); }

@media (max-width: 720px) {
  #ship-panel { width: calc(100vw - 24px); top: auto; max-height: 58vh; bottom: 12px; }
}

/* controlli disabilitati quando il layer aerei è spento */
.ctrl-disabled { opacity: 0.35; pointer-events: none; }
#search:disabled { opacity: 0.5; cursor: not-allowed; }

/* posizioni AIS invecchiate (>15 min) e riga meteo del pannello nave */
.ship-icon.stale { opacity: 0.3; }
#s-weather {
  margin: 8px 12px 0;
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
}
#s-weather.hidden { display: none; }

/* frecce del vento del layer mare */
.wind-arrow {
  position: absolute;
  left: 0; top: 0;
  pointer-events: none;
  opacity: 0.75;
}
.wind-arrow svg { width: 100%; height: 100%; display: block; }
.wind-arrow svg path { fill: #e8eaed; stroke: rgba(0,0,0,0.6); stroke-width: 0.6; }

/* navi sul globo: leggermente più piccole degli aerei */
.globe-ship { width: 12px; height: 12px; margin-left: -6px; margin-top: -6px; }

/* navi più leggibili sulle mappe chiare: bordo netto e meno trasparenza */
.ship-icon svg { filter: drop-shadow(0 0 1.5px rgba(255,255,255,0.7)); }
.ship-icon.moored { opacity: 0.78; }
.ship-icon.stale { opacity: 0.45; }

/* avviso zona navi in sintonizzazione / senza copertura */
#ship-warmup {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  max-width: min(560px, calc(100vw - 24px));
  padding: 9px 14px;
  background: var(--panel);
  border: 1px solid rgba(245, 197, 24, 0.45);
  border-radius: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  font-size: 12.5px;
  color: var(--text);
  text-align: center;
  pointer-events: none;
}
