:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1f2631;
  --fg: #e6edf3;
  --muted: #8b949e;
  --accent: #4ea1ff;
  --warn: #ffb454;
  --ok: #5dd39e;
  --bad: #ff6b6b;
  --border: #2a313c;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#app { display: flex; flex-direction: column; height: 100vh; }

header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
header h1 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: .2px; }
header .controls { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; font-size: 13px; }
header label { display: inline-flex; align-items: center; gap: 6px; color: var(--fg); }
header select, header button {
  background: var(--panel-2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 8px; font-size: 12px;
}
header button { cursor: pointer; }
header .hint { color: var(--muted); font-size: 12px; margin-left: auto; }

main { flex: 1; display: flex; min-height: 0; }
#map { flex: 1; min-height: 0; }

#sidebar {
  width: 400px; background: var(--panel); border-left: 1px solid var(--border);
  padding: 14px 16px; overflow-y: auto; font-size: 13px;
}
#sidebar h2 { margin: 0 0 8px; font-size: 14px; }
#sidebar h3 { margin: 12px 0 6px; font-size: 13px; color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.hidden { display: none; }

#selection .chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 999px; font-size: 12px; margin: 3px 4px 3px 0;
}
#selection .chip .x { color: var(--muted); cursor: pointer; }

#profile-summary { margin-bottom: 8px; font-size: 12px; }
#profile-summary .tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-weight: 600; font-size: 11px; text-transform: uppercase; margin-right: 6px; }
#profile-summary .tag.ok { background: rgba(93,211,158,.15); color: var(--ok); border: 1px solid rgba(93,211,158,.4); }
#profile-summary .tag.warn { background: rgba(255,180,84,.15); color: var(--warn); border: 1px solid rgba(255,180,84,.4); }
#profile-summary .tag.bad { background: rgba(255,107,107,.15); color: var(--bad); border: 1px solid rgba(255,107,107,.4); }

canvas#profile {
  width: 100%; height: 180px; background: #0a0d12; border: 1px solid var(--border); border-radius: 6px;
}
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-top: 6px; }
.legend .sw { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 3px; border-radius: 1px; }
.legend .sw-los { background: var(--accent); }
.legend .sw-fresnel { background: rgba(255,180,84,.7); }
.legend .sw-terrain { background: #8b949e; height: 10px; border-radius: 2px; }

.foot { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.foot .types { list-style: none; padding: 0; margin: 6px 0; font-size: 12px; }
.foot .types li { margin: 4px 0; display: flex; align-items: center; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid #fff; }
.type-tv { background: #e63946; }
.type-peak { background: #4ea1ff; }
.type-meteo { background: #b084ff; }
.type-candidate { background: #5dd39e; }

/* Leaflet custom markers */
.site-marker {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 2px 4px rgba(0,0,0,.4);
}
.site-marker.sel { outline: 3px solid #ffeb3b; outline-offset: 2px; }
.site-label {
  background: rgba(22,27,34,.85); color: #fff; border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 3px; font-size: 11px; white-space: nowrap;
  transform: translate(10px, -50%);
}

/* Leaflet popup styling */
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--fg); border: 1px solid var(--border); }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 10px 12px; font-size: 12px; }
.leaflet-popup-content strong { color: var(--accent); }

@media (max-width: 900px) {
  main { flex-direction: column; }
  #sidebar { width: 100%; max-height: 40vh; border-left: none; border-top: 1px solid var(--border); }
}
