:root {
  --bg: #0a0f17;
  --bg-2: #0f1622;
  --surface: #131c2a;
  --surface-2: #192436;
  --line: #22304a;
  --line-2: #2c3d5c;
  --text: #e6edf7;
  --text-2: #a4b2c8;
  --muted: #6b7a93;
  --green: #34e3a4;
  --green-dim: rgba(52, 227, 164, .14);
  --amber: #ffb547;
  --amber-dim: rgba(255, 181, 71, .14);
  --blue: #6aa8ff;
  --blue-dim: rgba(106, 168, 255, .14);
  --red: #ff6b7d;
  --c0: #ff6b7d; --c1: #ff9f5a; --c2: #ffd166; --c3: #9be36b; --c4: #34e3a4;
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'Space Grotesk', system-ui, -apple-system, Segoe UI, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --panel-w: 440px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(1200px 600px at 75% -10%, rgba(52, 227, 164, .07), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(106, 168, 255, .06), transparent 60%);
  color: var(--text);
  font: 15px/1.45 var(--font);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 15, 23, .82);
  backdrop-filter: blur(10px);
  z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 36px; height: 36px; color: var(--green); flex: none; }
.brand-mark .sweep { transform-origin: 16px 16px; animation: sweep 4s linear infinite; }
@keyframes sweep { to { transform: rotate(360deg); } }
.brand h1 { margin: 0; font-size: 18px; letter-spacing: -.01em; font-weight: 700; }
.tagline { margin: 0; font-size: 12px; color: var(--muted); }

.solar { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.stat {
  display: flex; flex-direction: column; align-items: center; min-width: 56px;
  padding: 5px 10px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line);
}
.stat .k { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat .v { font: 600 15px/1.2 var(--mono); }
.stat .v.good { color: var(--green); } .stat .v.warn { color: var(--amber); } .stat .v.bad { color: var(--red); }

.top-actions { display: flex; align-items: center; gap: 10px; }
.cluster-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; color: var(--text-2); white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.cluster-pill.ok .dot { background: var(--green); box-shadow: 0 0 0 4px var(--green-dim); animation: blink 2.4s ease-in-out infinite; }
.cluster-pill.warn .dot { background: var(--amber); }
.cluster-pill.off .dot { background: var(--red); }
@keyframes blink { 50% { box-shadow: 0 0 0 7px transparent; } }
.station-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  border-radius: 999px; border: 1px solid var(--green); background: var(--green-dim);
  color: var(--green); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.station-btn svg { width: 18px; height: 18px; }
.station-btn:hover { background: rgba(52, 227, 164, .22); }
.station-btn .mono { font-weight: 500; }

.banner {
  padding: 9px 20px; font-size: 13.5px; background: var(--amber-dim); color: var(--amber);
  border-bottom: 1px solid rgba(255, 181, 71, .3);
}

/* ---------- layout ---------- */
.layout { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); min-height: 0; overflow: hidden; overflow: clip; }
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #070b11; }
.map-legend {
  position: absolute; left: 14px; bottom: 14px; z-index: 500;
  display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 12px; font-size: 12px; color: var(--text-2);
  background: rgba(15, 22, 34, .88); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(6px);
}
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lg.live { background: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }
.lg.active { background: var(--blue); }
.lg.upcoming { background: transparent; border: 2px solid var(--amber); }
.lg.night { background: rgba(0, 0, 0, .55); border: 1px solid var(--line-2); border-radius: 3px; }

/* ---------- list panel ---------- */
.panel {
  display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--line); background: var(--bg-2);
}
.panel-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; gap: 4px; background: var(--surface); border-radius: 12px; border: 1px solid var(--line); }
.seg button {
  border: 0; background: transparent; padding: 8px 6px; border-radius: 9px; color: var(--text-2); font-weight: 600; font-size: 13.5px;
  display: inline-flex; justify-content: center; gap: 6px; align-items: center;
}
.seg button b { font: 500 12px var(--mono); padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg button[aria-selected="true"] b { background: var(--green-dim); color: var(--green); }
.filters { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--muted); }
.search input, .filters select, dialog input, dialog select {
  width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); outline: none; min-width: 0;
}
.search input { padding-left: 32px; }
.filters select { width: auto; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }
.bandbar { display: flex; gap: 5px; flex-wrap: wrap; }
.bandbar button {
  border: 1px solid var(--line); background: transparent; color: var(--text-2);
  padding: 3px 9px; border-radius: 999px; font: 500 12px var(--mono);
}
.bandbar button[aria-pressed="true"] { border-color: var(--green); color: var(--green); background: var(--green-dim); }

.list { overflow-y: auto; padding: 10px; display: grid; gap: 8px; align-content: start; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: 14px; }
.empty b { color: var(--text-2); display: block; font-size: 15px; margin-bottom: 4px; }

.card {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; text-align: left; width: 100%;
  padding: 12px 13px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); transition: border-color .15s, transform .15s, background .15s;
}
.card:hover { border-color: var(--line-2); background: var(--surface-2); }
.card.selected { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; }
.card-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.call { font: 700 18px/1.15 var(--mono); letter-spacing: .01em; }
.status { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status.live { background: var(--green); box-shadow: 0 0 0 4px var(--green-dim); animation: blink 2s ease-in-out infinite; }
.status.active { background: var(--blue); }
.status.upcoming { border: 2px solid var(--amber); }
.entity { color: var(--text-2); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { grid-column: 1; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); }
.meta .freq { color: var(--green); font-family: var(--mono); font-weight: 500; }
.meta .freq.stale { color: var(--text-2); }
.meta .when { color: var(--amber); }
.freqs { grid-column: 1; display: flex; flex-wrap: wrap; gap: 5px; margin: 2px 0 1px; }
.fq {
  font: 600 12.5px/1 var(--mono); color: var(--green); padding: 5px 7px; border-radius: 7px;
  background: var(--green-dim); border: 1px solid rgba(52, 227, 164, .3); white-space: nowrap;
}
.fq small { font-size: 10.5px; font-weight: 500; opacity: .75; margin-left: 2px; }
.fq.stale { color: var(--text-2); background: var(--surface-2); border-color: var(--line); }
.fq.more { color: var(--muted); background: transparent; border-style: dashed; border-color: var(--line-2); }
.freqtab tr.hot td:first-child { color: var(--green); font-weight: 700; }
.chips { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.chip {
  font: 500 11px/1 var(--mono); padding: 4px 6px; border-radius: 6px; color: #0a0f17;
  position: relative;
}
.chip.on::after { content: ''; position: absolute; top: -3px; right: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--green); border: 2px solid var(--surface); }
.chip.none { background: var(--surface-2); color: var(--muted); }

.gauge { grid-row: 1 / span 3; grid-column: 2; align-self: start; display: grid; place-items: center; width: 54px; height: 54px; position: relative; }
.gauge svg { width: 54px; height: 54px; transform: rotate(-90deg); }
.gauge .num { position: absolute; font: 700 14px var(--mono); }
.gauge .num small { font-size: 9px; opacity: .7; }
.gauge.forecast .num { opacity: .85; }
.gauge .sub { position: absolute; bottom: -14px; font: 500 10px var(--mono); color: var(--muted); white-space: nowrap; }

/* ---------- drawer ---------- */
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: var(--panel-w); z-index: 900;
  background: var(--bg-2); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translateX(105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  overflow-y: auto; scrollbar-width: thin;
}
.drawer.open { transform: none; }
.drawer-inner { padding: 16px 18px 28px; display: grid; gap: 16px; }
.d-head { display: flex; align-items: flex-start; gap: 12px; }
.d-head .call { font-size: 26px; }
.d-head .entity { font-size: 14.5px; white-space: normal; }
.icon-btn { margin-left: auto; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; width: 34px; height: 34px; display: grid; place-items: center; flex: none; }
.icon-btn:hover { border-color: var(--line-2); }
.icon-btn svg { width: 16px; height: 16px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-2); }
.badge.live { color: var(--green); border-color: rgba(52, 227, 164, .4); background: var(--green-dim); }
.badge.upcoming { color: var(--amber); border-color: rgba(255, 181, 71, .4); background: var(--amber-dim); }
.badge.active { color: var(--blue); border-color: rgba(106, 168, 255, .4); background: var(--blue-dim); }
.links { display: flex; gap: 8px; flex-wrap: wrap; }
.links a { color: var(--blue); text-decoration: none; font-size: 13.5px; border: 1px solid var(--line); padding: 5px 10px; border-radius: 8px; }
.links a:hover { border-color: var(--blue); }

.hero {
  display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center;
  padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
}
.hero .big { font: 700 40px/1 var(--mono); }
.hero .big small { font-size: 18px; opacity: .6; }
.hero .lab { font-weight: 600; }
.hero p { margin: 4px 0 0; font-size: 13px; color: var(--text-2); }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fact { padding: 10px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); }
.fact .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.fact .v { font: 600 14px/1.3 var(--mono); margin-top: 2px; }
.fact .v small { font-family: var(--font); font-weight: 400; color: var(--text-2); }

h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.bands { display: grid; gap: 4px; }
.brow {
  display: grid; grid-template-columns: 48px 46px 1fr 40px; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 8px; background: transparent; border: 1px solid transparent; text-align: left; width: 100%;
}
.brow:hover, .brow.open { background: var(--surface); border-color: var(--line); }
.brow .b { font: 600 13px var(--mono); display: flex; align-items: center; gap: 5px; }
.brow .b .live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.brow .m { font: 500 11px var(--mono); color: var(--text-2); }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; }
.brow .p { font: 600 13px var(--mono); text-align: right; }
.reasons { grid-column: 1 / -1; margin: 6px 0 2px; padding-left: 18px; color: var(--text-2); font-size: 12.5px; }
.reasons li { margin: 2px 0; }

.spots { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.spots th { text-align: left; font-weight: 500; color: var(--muted); padding: 4px 6px; border-bottom: 1px solid var(--line); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.spots td { padding: 6px; border-bottom: 1px solid rgba(34, 48, 74, .5); font-family: var(--mono); }
.spots td.c { font-family: var(--font); color: var(--text-2); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spots tr.near td:nth-child(4) { color: var(--green); }
.info { font-size: 13.5px; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0; }
.fine { font-size: 11.5px; color: var(--muted); margin: 0; }

/* ---------- ticker ---------- */
.ticker {
  display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 14px;
  border-top: 1px solid var(--line); background: rgba(10, 15, 23, .95); font-size: 13px; z-index: 1000;
}
.ticker-label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .1em; flex: none; }
.ticker-label .dot { background: var(--green); }
.ticker-track { overflow: hidden; flex: 1; min-width: 0; mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent); }
.ticker-rail { display: flex; gap: 26px; white-space: nowrap; }
.tick { display: inline-flex; gap: 8px; align-items: baseline; color: var(--text-2); cursor: pointer; border: 0; background: none; padding: 0; }
.tick b { font-family: var(--mono); color: var(--text); }
.tick .f { font-family: var(--mono); color: var(--green); }
.tick .t { color: var(--muted); font-size: 12px; }
.tick.new { animation: flash 1.6s ease-out; }
@keyframes flash { from { color: var(--green); } }

/* ---------- map bits ---------- */
.leaflet-container { font-family: var(--font); background: #070b11; }
/* Turn the light OSM tiles into a dark map that matches the UI */
.dark-tiles { filter: invert(1) hue-rotate(180deg) brightness(.82) contrast(.92) saturate(.35); }
.leaflet-control-attribution { background: rgba(10, 15, 23, .75) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--text-2) !important; }
.leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--line) !important; }
.pin { position: relative; width: 14px; height: 14px; }
.pin i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid #0a0f17; }
.pin.live i { background: var(--green); }
.pin.live::before { content: ''; position: absolute; inset: -9px; border-radius: 50%; border: 2px solid var(--green); animation: ping 2s ease-out infinite; }
.pin.active i { background: var(--blue); }
.pin.upcoming i { background: #0a0f17; border-color: var(--amber); }
.pin.sel i { box-shadow: 0 0 0 3px #fff; }
.pin-label {
  position: absolute; left: 18px; top: -5px; font: 600 11px var(--mono); color: var(--text);
  text-shadow: 0 1px 3px #000, 0 0 2px #000; white-space: nowrap; pointer-events: none;
}
.pin.upcoming .pin-label { color: var(--text-2); }
@keyframes ping { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
.home-pin { width: 16px; height: 16px; border-radius: 4px; background: var(--amber); border: 2px solid #0a0f17; transform: rotate(45deg); box-shadow: 0 0 0 4px var(--amber-dim); }
.leaflet-tooltip.dx-tip { background: var(--surface); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); font-size: 12.5px; }
.leaflet-tooltip.dx-tip::before { display: none; }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line-2); border-radius: 18px; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--bg-2); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(3, 6, 10, .7); backdrop-filter: blur(3px); }
dialog form { padding: 22px; display: grid; gap: 14px; }
dialog h2 { margin: 0; font-size: 20px; }
dialog p { margin: 0; font-size: 13.5px; }
dialog label { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
dialog .row { display: flex; gap: 8px; }
dialog input { font-family: var(--mono); text-transform: uppercase; }
dialog small { font-size: 12px; font-weight: 400; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.primary { background: var(--green); color: #05110c; border: 0; padding: 9px 18px; border-radius: 10px; font-weight: 700; }
.primary:hover { filter: brightness(1.08); }
.ghost { background: transparent; border: 1px solid var(--line-2); padding: 8px 14px; border-radius: 10px; color: var(--text-2); white-space: nowrap; }
.ghost:hover { color: var(--text); border-color: var(--muted); }
.error { color: var(--red); font-size: 13px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) { .hide-sm { display: none; } :root { --panel-w: 400px; } }
@media (max-width: 900px) {
  body { overflow: auto; grid-template-rows: auto auto auto auto; }
  .topbar { flex-wrap: wrap; gap: 10px 14px; padding: 10px 16px; }
  .solar { order: 3; width: 100%; margin: 0; justify-content: space-between; }
  .stat { flex: 1; min-width: 0; }
  .top-actions { margin-left: auto; }
  .cluster-pill #clusterText { display: none; }
  .layout { grid-template-columns: 1fr; }
  .map-wrap { height: 46vh; }
  .map-legend { display: none; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .list { overflow: visible; }
  .drawer { position: fixed; top: 0; width: 100%; z-index: 1500; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
  .search { grid-column: 1 / -1; }
  .ticker { position: sticky; bottom: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
