:root {
  --bg: #070d16; --panel: #0e1724; --panel2: #132033; --stroke: rgba(255,255,255,.10);
  --text: #e8eef6; --muted: #93a4b8; --accent: #3cf0a0; --spot: #ff4fd8; --warn: #ffb020;
  --glass: rgba(10,16,26,.82);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr); height: 100dvh; overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--stroke); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
button:hover { border-color: rgba(255,255,255,.25); }
button:disabled, select:disabled, input:disabled { opacity: .45; cursor: not-allowed; }
button.icon { width: 32px; padding: 5px 0; font-size: 17px; line-height: 1; }
button.link { background: none; border: 0; color: var(--accent); padding: 2px 0; }
select, input { background: #0a1320; border: 1px solid var(--stroke); border-radius: 7px; padding: 5px 7px; }
input[type=range] { padding: 0; width: 100%; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--stroke); flex-wrap: wrap; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand b { font-size: 16px; letter-spacing: .2px; }
.logo { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--accent); background: radial-gradient(circle at 35% 35%, #1b4a6e, #0b2540); }
.badge { font-size: 11px; color: var(--bg); background: var(--accent); border-radius: 6px; padding: 1px 6px; font-weight: 600; }
.tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tools.right { margin-left: auto; }
.tog[aria-pressed=true] { background: #17405a; border-color: #2f88b5; color: #fff; }
.sel { display: flex; align-items: center; gap: 6px; color: var(--muted); }

/* Map */
#mapWrap { position: relative; overflow: hidden; touch-action: none; background: #000; }
#map, #top { position: absolute; inset: 0; width: 100%; height: 100%; }
#top { pointer-events: none; }
#mapWrap.grabbing { cursor: grabbing; }
.hover { position: absolute; top: 10px; left: 10px; display: flex; gap: 8px; align-items: flex-start; pointer-events: none; max-width: calc(100% - 20px); flex-wrap: wrap; }
.hover .box { background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--stroke); border-radius: 10px; padding: 8px 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.hover .title { font-weight: 600; font-size: 13px; }
.hover hr { border: 0; border-top: 1px solid var(--stroke); margin: 5px 0; }
.hover .muted, .muted { color: var(--muted); }
.hover table { border-collapse: collapse; }
.hover td { padding: 0 8px 0 0; white-space: nowrap; }
.hover td.cmt { max-width: 240px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.hover .spothead { color: var(--spot); font-weight: 600; }
.wheelbox h4 { margin: 0; font-size: 13px; } .wheelbox .sub { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.wheelbox .err { color: var(--warn); width: 250px; height: 250px; display: grid; place-items: center; text-align: center; padding: 20px; }
.wheelbox canvas { display: block; }
.legends { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 8px; align-items: flex-end; pointer-events: none; flex-wrap: wrap; }
.legend { background: var(--glass); border: 1px solid var(--stroke); border-radius: 8px; padding: 6px 8px; font-size: 11px; }
.legend .bar { height: 8px; border-radius: 4px; width: 170px; margin: 3px 0; }
.legend .ends { display: flex; justify-content: space-between; color: var(--muted); width: 170px; }
.legend.right { margin-left: auto; }
.legend .chips { display: flex; gap: 2px; margin-top: 3px; }
.legend .chips span { padding: 1px 4px; border-radius: 3px; color: #111; font-weight: 600; }
.badgebox { position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; background: var(--glass); border: 1px solid var(--stroke); border-radius: 20px; padding: 4px 12px; font-size: 12px; pointer-events: none; white-space: nowrap; }
.badgebox .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.zoombadge { position: absolute; top: 10px; right: 10px; background: var(--glass); border: 1px solid var(--stroke); border-radius: 8px; padding: 4px 6px 4px 10px; font-size: 12px; }
.zoombadge button { padding: 2px 8px; font-size: 12px; }
.toast { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--glass); border: 1px solid var(--stroke); padding: 6px 12px; border-radius: 8px; font-size: 12px; }

/* Info bar */
.infobar { display: grid; grid-template-columns: minmax(0, 2.4fr) 1fr 1fr 1.3fr; gap: 10px; padding: 10px 12px; background: var(--panel); border-top: 1px solid var(--stroke); }
.card { background: rgba(255,255,255,.035); border: 1px solid var(--stroke); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.card h2 { margin: 0 0 6px; font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card h2 span { text-transform: none; letter-spacing: 0; font-weight: 400; }
.clock .time { font-size: 34px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.clock .sub, .sun { color: var(--muted); font-size: 12px; }
.sun b { color: var(--text); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.tile { background: rgba(255,255,255,.03); border-radius: 8px; padding: 6px 8px; min-width: 0; }
.tile .k { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.tile .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .r { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Settings drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100%); background: var(--panel); border-left: 1px solid var(--stroke); z-index: 20; display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,.4); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--stroke); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.tabs { display: flex; gap: 4px; padding: 8px 14px 0; flex-wrap: wrap; }
.tabs button { border-radius: 8px 8px 0 0; border-bottom: 0; }
.tabs button.on { background: #17405a; }
.tab { padding: 6px 14px 20px; overflow-y: auto; flex: 1; }
.tab h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 16px 0 8px; display: flex; align-items: center; gap: 8px; }
.tab label { display: block; margin: 8px 0; color: var(--muted); font-size: 12.5px; }
.tab label input:not([type=checkbox]):not([type=range]), .tab label select { display: block; width: 100%; margin-top: 3px; color: var(--text); }
.tab label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
.tab .row { display: flex; gap: 8px; align-items: flex-end; }
.tab .row label { flex: 1; }
.tab .row > button { margin-bottom: 8px; }
.note { color: var(--muted); font-size: 12px; margin: 6px 0; }
.bands { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px 8px; }
.bands label { margin: 2px 0; display: flex; gap: 6px; align-items: center; color: var(--text); }
.locked { position: relative; border: 1px dashed rgba(255,255,255,.18); border-radius: 10px; padding: 2px 12px 10px; margin-top: 14px; background: rgba(255,255,255,.02); }
.locked > *:not(h3):not(.lockmsg) { opacity: .5; }
.lock { font-size: 10px; letter-spacing: .5px; color: var(--bg); background: var(--warn); border-radius: 5px; padding: 1px 6px; text-transform: none; }
.lockmsg { color: var(--warn); font-size: 12.5px; margin: 10px 0 0; }
.lockmsg a { color: var(--accent, #3cf0a0); font-weight: 600; }

/* Help */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30; display: grid; place-items: center; padding: 16px; }
.modal-body { background: var(--panel); border: 1px solid var(--stroke); border-radius: 14px; width: min(760px, 100%); max-height: 90dvh; display: flex; flex-direction: column; }
.helptext { padding: 4px 20px 20px; overflow-y: auto; line-height: 1.5; }
.helptext h1 { font-size: 20px; } .helptext h2 { font-size: 16px; margin-top: 22px; } .helptext code { background: #0a1320; padding: 1px 4px; border-radius: 4px; }
.helptext li { margin: 2px 0; }
.helptext .help-version { margin-top: 22px; opacity: .7; font-size: 13px; }

[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .infobar { grid-template-columns: 1fr 1fr; }
  .infobar .sw { grid-column: 1 / -1; }
  .infobar .sun { display: none; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .toolbar { padding: 6px 8px; gap: 6px; flex-wrap: wrap; }
  .brand .badge { display: none; }
  .tools.right { margin-left: auto; flex-wrap: nowrap; }
  .toolbar .tools:not(.right) { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tools button { padding: 4px 7px; font-size: 12.5px; white-space: nowrap; }
  .infobar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 6px 8px; gap: 6px; }
  .infobar .sw { grid-column: 1 / -1; }
  .infobar .sun { display: none; }
  .infobar .card { padding: 6px 10px; }
  .clock .time { font-size: 20px; }
  .clock .sub { display: none; }
  .card h2 { margin-bottom: 3px; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .tile { padding: 3px 6px; }
  .tile .v { font-size: 15px; }
  .tile .r { display: none; }
  .legend:not(.cov) { display: none; }
  .legend .chips span { padding: 1px 2px; font-size: 9px; }
  .hover { top: 6px; left: 6px; }
  .hover .box { font-size: 11px; }
  .zoombadge { top: auto; bottom: 64px; }
  .badgebox { bottom: auto; top: 6px; font-size: 11px; max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis; }
}

/* First-visit welcome dialog */
.modal[hidden] { display: none; }
.welcome { width: min(440px, 100%); padding: 0 18px 18px; gap: 10px; }
.welcome p { margin: 4px 0 6px; line-height: 1.45; }
.welcome label { display: flex; flex-direction: column; gap: 4px; }
.welcome-buttons { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.welcome .primary { background: #2f8f6a; color: #fff; border: 0; border-radius: 8px; padding: 8px 18px; font-weight: 600; cursor: pointer; }

/* Antennas by band */
.anttable { width: 100%; border-collapse: collapse; font-size: 12px; margin: 4px 0 6px; }
.anttable th { text-align: left; color: var(--muted); font-weight: 500; padding: 2px 3px; }
.anttable td { padding: 2px 3px; white-space: nowrap; }
.anttable select { width: 100%; min-width: 0; }
.anttable input { width: 72px; }
.anttable input:disabled { opacity: .45; }
.anttable td.note { white-space: normal; font-size: 11px; }

.homelink { color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; margin: 0 10px; }
.homelink:hover { color: var(--text); }
