:root {
  --bg: #0c0f14;
  --panel: #141922;
  --panel-2: #1b2230;
  --line: #232c3b;
  --ink: #e6ecf3;
  --muted: #8b96a7;
  --accent: #4aa8ff;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, #16202e 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-weight: 400; }

.topbar {
  display: flex; align-items: flex-end; justify-content: flex-start;
  gap: 16px; padding: 10px 22px; border-bottom: 1px solid var(--line);
  background: rgba(12, 15, 20, 0.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 500; flex-wrap: wrap;
}
.logo { font-size: 26px; line-height: 1; color: var(--accent); filter: drop-shadow(0 0 10px #1c5e9b); padding-bottom: 6px; }

.controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; flex: 1; }
.controls label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.controls input, .controls select {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 14px; min-width: 96px;
}
#grid { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 1px; text-transform: none; min-width: 110px; }
.grid-input { display: flex; gap: 6px; align-items: stretch; }
.geo-btn {
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--accent); border: 1px solid var(--line);
  border-radius: 8px; padding: 0 11px; cursor: pointer;
}
.geo-btn:hover { color: var(--accent); border-color: var(--accent); }
.geo-btn:disabled { opacity: 0.5; cursor: default; }
.geo-btn.busy { animation: rw-spin 0.8s linear infinite; }
.grid-msg { margin: 8px 0 0; padding: 7px 11px; border-radius: 8px; font-size: 12.5px;
  color: #ffb3a8; background: color-mix(in srgb, #d84c3e 16%, var(--panel));
  border: 1px solid color-mix(in srgb, #d84c3e 34%, var(--line)); }
#dx { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 1px; text-transform: none; min-width: 96px; }
.ghost-btn {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }
.ghost-btn.ok { color: #2ec27e; border-color: #2ec27e; }

.controls button {
  background: var(--accent); color: #04121f; border: 0; border-radius: 8px;
  padding: 9px 18px; font-weight: 650; cursor: pointer; font-size: 14px;
}
.controls button:hover { filter: brightness(1.08); }

.solar-strip {
  display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 22px; border-bottom: 1px solid var(--line);
}
.chip {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; display: flex; flex-direction: column; min-width: 78px;
}
.chip .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; }
.chip .v { font-size: 19px; font-family: ui-monospace, Menlo, monospace; font-weight: 600; }
.chip .v small { font-size: 11px; color: var(--muted); }
.chip.hot { background: color-mix(in srgb, #d84c3e 18%, var(--panel)); border-color: color-mix(in srgb, #d84c3e 40%, var(--line)); }
.chip.hot .v { color: #ff9b8c; }


.grid-layout {
  display: grid; gap: 16px; padding: 16px 22px 28px;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  grid-template-areas: "path path" "timeline map" "bands detail";
}
.bands-panel { grid-area: bands; }
.detail-panel { grid-area: detail; }
.timeline-panel { grid-area: timeline; }
.path-panel { grid-area: path; }
.map-panel { grid-area: map; }
@media (max-width: 980px) {
  .grid-layout { grid-template-columns: 1fr; grid-template-areas: "path" "timeline" "map" "bands" "detail"; }
}

/* Signal path (hero): wide diagram + a small compass beside it. */
.path-body { display: flex; gap: 16px; align-items: stretch; }
#bounce { flex: 1 1 auto; min-width: 0; width: 100%; height: 384px; display: block; }
.rose-block { flex: 0 0 132px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#rose { width: 118px; height: 118px; }
.rose-cap { margin: 0; font-size: 10.5px; line-height: 1.35; color: var(--muted); text-align: center; }
.rose-cap b { color: var(--ink); }
.path-legend { gap: 6px 14px; flex: 0 0 auto; }
/* Keep the signal-path header on one line: title left, status centre (truncates
   if long), legend right. */
.path-panel .panel-head { flex-wrap: nowrap; }
.path-panel .panel-head h2 { flex: 0 0 auto; white-space: nowrap; }
.path-meta { flex: 1 1 auto; min-width: 0; text-align: center; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 980px) {
  .path-panel .panel-head { flex-wrap: wrap; }
  .path-meta { white-space: normal; overflow: visible; flex-basis: 100%; text-align: left; }
}

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: 0.2px; }
.hint { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

.legend { display: flex; gap: 8px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.bandgrid { display: flex; flex-direction: column; gap: 6px; }
.brow {
  display: grid; grid-template-columns: 62px 1fr 1fr 92px; gap: 8px; align-items: stretch;
  cursor: pointer;
}
.brow.head { cursor: default; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.brow.head > div { padding: 0 4px; }
.reach-head { display: flex; align-items: center; }
.reach { position: relative; display: flex; align-items: center; min-width: 0; }
.reach-bar { width: 100%; height: 10px; border-radius: 5px; border: 1px solid rgba(255,255,255,0.08); }
.reach-mark { position: absolute; top: 50%; width: 2px; height: 16px; margin-top: -8px; background: #e6ecf3; box-shadow: 0 0 0 1px rgba(0,0,0,0.5); border-radius: 1px; }
@media (max-width: 560px) { .brow { grid-template-columns: 52px 1fr 1fr; } .reach, .reach-head { display: none; } }
.bname { display: flex; align-items: center; font-family: ui-monospace, Menlo, monospace; font-weight: 600; font-size: 15px; }
.cell {
  border-radius: 8px; padding: 8px 11px; display: flex; align-items: center; justify-content: space-between;
  border: 1px solid rgba(255,255,255,0.06); color: #06120c; font-weight: 600;
}
.cell .lab { font-size: 13px; }
.cell .sub { font-size: 11px; opacity: 0.78; font-family: ui-monospace, Menlo, monospace; }
.brow.sel .bname { color: var(--accent); }
.brow:not(.head):hover .cell { outline: 1px solid rgba(255,255,255,0.25); }

.detail h3 { margin: 4px 0 8px; font-size: 14px; }
.detail .facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px 12px; margin: 0 0 14px; }
.detail .facts div { display: flex; flex-direction: column; gap: 2px; }
.detail .facts dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.detail .facts dd { margin: 0; color: var(--ink); font-family: ui-monospace, Menlo, monospace; font-weight: 600; font-size: 13px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.chart-title { color: var(--ink); font-weight: 600; }
.chart-legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid; vertical-align: middle; margin: 0 5px 0 10px; }
.chart-legend i.lg-rx { border-color: #e6ecf3; }
.chart-legend i.lg-tx { border-color: #57b894; }
.chart-legend i.lg-floor { border-top-style: dashed; border-color: rgba(230,236,243,0.6); }
.snrdist { width: 100%; height: 150px; display: block; margin: 0 0 12px; }
.modetable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.modetable th, .modetable td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.modetable th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.modetable td.mname { font-family: ui-monospace, Menlo, monospace; font-weight: 600; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; color: #06120c; }
.explain { margin: 12px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); }
.explain li { padding: 3px 0 3px 16px; position: relative; }
.explain li::before { content: "›"; position: absolute; left: 2px; color: var(--accent); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--panel-2); color: var(--muted); border: 0; padding: 6px 14px; cursor: pointer; font-size: 12px; font-weight: 600; }
.seg button.active { background: var(--accent); color: #04121f; }

.heat-wrap { position: relative; }
#heatmap { width: 100%; height: 360px; display: block; }
#heatcursor { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.heat-tip {
  position: fixed; pointer-events: none; z-index: 900; background: #05080d; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-size: 12px; display: none; max-width: 240px;
}
.heat-tip .hk { color: var(--muted); }

.layers { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.layers label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
#map { width: 100%; height: 360px; border-radius: 10px; overflow: hidden; }
.leaflet-container { background: #0a0e13; }
.qth-dot { background: var(--accent); border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 10px var(--accent); }
.dx-dot { background: #6cb2ff; border: 2px solid #fff; border-radius: 2px; transform: rotate(45deg); box-shadow: 0 0 10px #6cb2ff; }
#az { width: 5.5em; }

.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 22px 26px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.foot a.about-cta { color: var(--accent); font-weight: 600; }

/* ---- about page ---- */
.about-wrap { max-width: 940px; margin: 0 auto; padding: 22px 22px 70px; display: flex; flex-direction: column; gap: 16px; }
.about-wrap .panel { padding: 18px 22px; }
.about-wrap h2 { margin: 0 0 4px; font-size: 17px; }
.about-wrap h3 { margin: 16px 0 6px; font-size: 13.5px; color: var(--accent); }
.about-wrap h3:first-of-type { margin-top: 4px; }
.about-wrap p { margin: 8px 0; line-height: 1.6; }
.about-wrap .lead { color: var(--muted); font-size: 14.5px; }
.about-wrap ul { margin: 8px 0; padding-left: 20px; }
.about-wrap li { margin: 5px 0; line-height: 1.55; }
.about-wrap code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
.about-wrap .key { color: var(--ink); font-weight: 600; }
.about-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.about-table th, .about-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.about-table th { color: var(--muted); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; }
.about-table td:first-child { white-space: nowrap; font-weight: 600; color: var(--ink); }
.about-table td:nth-child(2) { color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 13px; }

/* ---- phones ---- */
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .brand h1 { font-size: 17px; }
  .controls { gap: 8px; width: 100%; }
  .controls label { flex: 1 1 calc(50% - 8px); }
  .controls input, .controls select { min-width: 0; width: 100%; }
  .controls > button[type="submit"] { flex: 1 1 100%; }
  .solar-strip { padding: 10px 14px; gap: 8px; }
  .chip { min-width: 62px; padding: 6px 10px; }
  .chip .v { font-size: 17px; }
  .grid-layout { padding: 12px 14px 24px; }
  .headline { margin: 12px 14px 0; gap: 6px 14px; }
  .headline .hl-grow { margin-left: 0; flex-basis: 100%; }
  #map { height: 320px; }
  #heatmap { height: 240px; }
  .foot { padding: 12px 14px 22px; }
}

.error { color: #ff8a7a; padding: 10px 22px; }

.loading { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; background: rgba(8,11,16,0.7); backdrop-filter: blur(3px); }
.loading[hidden] { display: none; }
.load-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; min-width: 260px; box-shadow: 0 12px 40px rgba(0,0,0,0.45); }
.load-title { font-weight: 650; font-size: 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 9px; }
.load-spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: rw-spin 0.8s linear infinite; flex: 0 0 auto; }
@keyframes rw-spin { to { transform: rotate(360deg); } }
.load-list { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.load-list li { display: flex; align-items: center; gap: 9px; padding: 3px 0; color: var(--muted); transition: color 0.15s; }
.load-list li .ic { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line); flex: 0 0 auto; position: relative; }
.load-list li.done { color: var(--ink); }
.load-list li.done .ic { background: #2ec27e; border-color: #2ec27e; }
.load-list li.done .ic::after { content: "✓"; position: absolute; inset: -3px 0 0 0; text-align: center; font-size: 10px; color: #04121f; }
