:root {
  --bg: #0a0e12;
  --panel: #0e151b;
  --panel-line: #1b2a36;
  --green: #38e07b;
  --amber: #ffb84d;
  --cyan: #4dd2ff;
  --text: #c8d6e0;
  --muted: #5f7587;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
}

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

#app {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: 52px 1fr;
  grid-template-areas: "top top" "map side";
  height: 100vh;
}

#topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 24px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-line);
  z-index: 1000;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.logo { color: var(--green); letter-spacing: -2px; font-size: 18px; }
.title { font-weight: 700; font-size: 16px; letter-spacing: 1px; }
.subtitle { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }

.stats { display: flex; gap: 22px; margin-left: auto; }
.stat { text-align: center; line-height: 1.1; }
.stat span { color: var(--green); font-size: 18px; font-weight: 700; }
.stat label { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: 1px; }

.conn { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); }
.conn .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 6px currentColor; }
.conn.live .dot { background: var(--green); }
.conn.live { color: var(--green); }
.conn.down .dot { background: #e0483a; }

#map { grid-area: map; height: 100%; background: #060a0e; }

#sidebar { grid-area: side; background: var(--panel); border-left: 1px solid var(--panel-line);
  display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--panel-line);
  font-size: 11px; letter-spacing: 2px; color: var(--muted); }
#filter { background: #0a1218; border: 1px solid var(--panel-line); color: var(--text);
  font-family: var(--mono); font-size: 11px; padding: 4px 8px; width: 130px; border-radius: 3px; }
#filter:focus { outline: none; border-color: var(--green); }

#feed { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#feed li { padding: 8px 12px; border-bottom: 1px solid #11202b; cursor: pointer;
  display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; }
#feed li:hover { background: #0c1822; }
#feed li.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(56,224,123,.22); } to { background: transparent; } }
#feed .emoji { font-size: 18px; text-align: center; }
#feed .name { font-size: 12px; color: var(--text); }
#feed .meta { font-size: 10px; color: var(--muted); }
#feed .conf { font-size: 11px; color: var(--amber); text-align: right; }
#feed .bearing { color: var(--cyan); }

#legend { position: absolute; left: 12px; bottom: 12px; z-index: 900;
  background: rgba(14,21,27,.92); border: 1px solid var(--panel-line); border-radius: 6px;
  padding: 8px 10px; font-size: 10px; color: var(--muted); }
#legend hr { border: none; border-top: 1px solid var(--panel-line); margin: 6px 0; }
.legend-row { display: flex; align-items: center; gap: 7px; padding: 1px 0; }
.legend-row .ic { font-size: 13px; }
.legend-row .ray { color: var(--cyan); font-weight: 700; }

/* Leaflet marker glyphs */
.bird-marker { display: flex; align-items: center; justify-content: center;
  font-size: 20px; text-shadow: 0 0 4px #000, 0 0 8px #000; }
.station-marker { font-size: 20px; filter: drop-shadow(0 0 4px var(--green)); }
.estimate-marker { font-size: 22px; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.25); opacity: .65; } }

/* Leaflet popup theme */
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text);
  border: 1px solid var(--panel-line); border-radius: 6px; font-family: var(--mono); }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 10px 12px; font-size: 12px; line-height: 1.5; }
.popup-title { color: var(--green); font-weight: 700; font-size: 13px; }
.popup-sci { color: var(--muted); font-style: italic; font-size: 11px; }
.popup-row { color: var(--text); }
.popup-row b { color: var(--cyan); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
