html, body { width: 100%; height: 100%; overflow: hidden; }
body { background: #07101d; }
#map { position: absolute; inset: 0; overflow: hidden; }
.glass { border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.topbar { position: absolute; z-index: 100; top: max(13px, env(safe-area-inset-top)); left: 13px; right: 13px; display: flex; justify-content: space-between; gap: 12px; pointer-events: none; }
.brand, .status-cluster { pointer-events: auto; border-radius: 16px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 9px 13px; }
.brand h1 { margin: 0; font-size: 16px; line-height: 1.05; letter-spacing: .02em; }
.brand small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.status-cluster { display: flex; align-items: center; gap: 8px; padding: 8px 9px; }
.badge-button { cursor: pointer; color: #cbd5e1; }
.badge-button:hover { border-color: var(--line-strong); }
.panel { position: absolute; z-index: 90; top: 84px; right: 13px; width: min(390px, calc(100vw - 26px)); max-height: calc(100vh - 105px); overflow: auto; border-radius: 19px; scrollbar-width: thin; transition: transform .24s ease, opacity .24s ease; }
.panel.collapsed { transform: translateX(calc(100% + 28px)); opacity: 0; pointer-events: none; }
.panel-head { position: sticky; z-index: 3; top: 0; padding: 13px; border-bottom: 1px solid var(--line); border-radius: 19px 19px 0 0; background: var(--panel-strong); }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.metric { min-width: 0; padding: 9px 8px; border: 1px solid var(--line); border-radius: 11px; background: rgba(15, 23, 42, .52); }
.metric strong { display: block; font-size: 18px; line-height: 1; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.metric span { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }
.control-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.primary-controls .btn { flex: 1 1 auto; font-size: 11px; white-space: nowrap; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field.compact { margin-top: 10px; }
.field.compact label { margin-bottom: 4px; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.field.compact input, .field.compact select { min-height: 35px; padding: 7px 9px; font-size: 11px; }
.layer-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
.layer-controls .btn { min-height: 33px; padding: 6px 8px; font-size: 10px; }
.legend { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 9px; }
.legend-bar { height: 8px; flex: 1; border: 1px solid rgba(255, 255, 255, .15); border-radius: 999px; background: linear-gradient(90deg, #ef4444 0%, #f59e0b 50%, #2563eb 100%); }
.panel-section { border-bottom: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; padding: 12px 13px 6px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .11em; }
.device-list { padding: 0 9px 12px; }
.device-card { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 9px; align-items: center; width: 100%; margin-top: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(15, 23, 42, .48); color: inherit; text-align: left; cursor: pointer; transition: border-color .14s ease, background .14s ease, transform .14s ease; }
.device-card:hover { transform: translateY(-1px); border-color: rgba(66, 211, 255, .43); background: rgba(17, 34, 55, .66); }
.device-card.selected { border-color: rgba(66, 211, 255, .7); box-shadow: inset 0 0 0 1px rgba(66, 211, 255, .12); }
.signal-dot { width: 11px; height: 11px; border-radius: 50%; box-shadow: 0 0 14px currentColor; }
.device-main { min-width: 0; }
.device-name { overflow: hidden; font-size: 12px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.device-meta { overflow: hidden; margin-top: 4px; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.device-side { text-align: right; }
.device-level { font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; }
.device-quality { margin-top: 3px; color: var(--muted); font-size: 8px; }
.empty { padding: 25px 15px 30px; color: var(--muted); font-size: 11px; line-height: 1.55; text-align: center; }
.device-details { padding: 15px 13px 16px; border-bottom: 1px solid var(--line); background: rgba(5, 14, 26, .42); }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.detail-head small { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
.detail-head h2 { max-width: 290px; margin: 4px 0 0; overflow: hidden; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.detail-id { max-width: 290px; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 10px; background: rgba(15, 23, 42, .65); color: #dbeafe; cursor: pointer; font-size: 19px; }
.detail-level-row { display: flex; align-items: center; gap: 14px; margin-top: 13px; }
.detail-level-ring { --level: 0; --signal: #ef4444; width: 78px; height: 78px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--signal) calc(var(--level) * 1%), rgba(148, 163, 184, .12) 0); position: relative; }
.detail-level-ring::before { content: ""; position: absolute; inset: 9px; border: 1px solid var(--line); border-radius: 50%; background: #081421; }
.detail-level-ring strong, .detail-level-ring span { z-index: 1; }
.detail-level-ring strong { margin-left: 8px; font-size: 26px; line-height: 1; }
.detail-level-ring span { margin-top: 3px; margin-left: -4px; color: var(--muted); font-size: 10px; }
.detail-signal { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.detail-signal strong { font-size: 16px; }
.detail-signal span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 12px; }
.detail-grid div { min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: rgba(15, 23, 42, .44); }
.detail-grid strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.detail-grid span { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; }
.chart-wrap { margin-top: 12px; padding: 9px; border: 1px solid var(--line); border-radius: 12px; background: rgba(4, 12, 23, .62); }
.chart-title { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; }
#historyChart { display: block; width: 100%; height: 118px; margin-top: 5px; }
.detail-actions { display: flex; gap: 7px; margin-top: 11px; }
.detail-actions .btn { flex: 1 1 auto; min-height: 34px; padding: 6px 8px; font-size: 10px; }
.panel-footer { display: flex; gap: 7px; flex-wrap: wrap; padding: 12px; }
.panel-footer .btn { flex: 1 1 auto; min-height: 34px; padding: 6px 8px; font-size: 10px; }
.map-controls { position: absolute; z-index: 80; left: 13px; top: 88px; display: flex; flex-direction: column; overflow: hidden; border-radius: 13px; }
.map-control { width: 39px; height: 39px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: #e2e8f0; cursor: pointer; font-size: 22px; font-weight: 700; }
.map-control:last-child { border-bottom: 0; }
.map-control:hover { background: rgba(30, 58, 85, .72); }
.map-control.text { font-size: 10px; letter-spacing: .04em; }
.panel-toggle { position: absolute; z-index: 95; top: 89px; right: 13px; display: none; padding: 8px 11px; border-radius: 11px; color: #dce8f5; cursor: pointer; }
/* Self-contained slippy map */
.sm-map { background: #0a1727; touch-action: none; cursor: grab; user-select: none; }
.sm-map.dragging { cursor: grabbing; }
.sm-map-grid { position: absolute; inset: 0; overflow: hidden; background: radial-gradient(circle at 50% 45%, #14304b 0, #0b1727 58%, #07101d 100%); }
.sm-map-grid::before { content: ""; position: absolute; inset: 0; opacity: var(--grid-opacity, .12); background-image: linear-gradient(rgba(132, 161, 190, .45) 1px, transparent 1px), linear-gradient(90deg, rgba(132, 161, 190, .45) 1px, transparent 1px); background-size: var(--grid-size, 80px) var(--grid-size, 80px); }
.sm-map-grid::after { content: attr(data-center); position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: rgba(148, 163, 184, .16); font-size: clamp(18px, 3vw, 38px); font-weight: 850; letter-spacing: .12em; white-space: nowrap; }
.sm-map-tiles { position: absolute; inset: 0; overflow: hidden; }
.sm-map-tile { pointer-events: none; position: absolute; left: 0; top: 0; width: 256px; height: 256px; opacity: 0; transition: opacity .25s ease; will-change: transform; }
.sm-map-tile.loaded { opacity: 1; }
.sm-map-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sm-map-offline { position: absolute; left: 13px; bottom: 13px; display: none; padding: 8px 10px; border: 1px solid rgba(245, 158, 11, .42); border-radius: 10px; background: rgba(120, 53, 15, .82); color: #fde7b0; font-size: 10px; }
.sm-map-offline.show { display: block; }
.sm-map-attribution { position: absolute; right: 8px; bottom: 5px; padding: 3px 5px; border-radius: 4px; background: rgba(4, 10, 20, .72); color: #9fb0c5; font-size: 8px; }
.sm-map-attribution a { color: #9fdcf4; text-decoration: none; }
.sm-map-attribution a:hover { text-decoration: underline; }
.sm-map:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
@media (max-width: 760px) {
  .topbar { top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; }
  .brand { padding: 7px 9px; }
  .brand .logo { width: 34px; height: 34px; }
  .brand small { display: none; }
  .status-cluster { padding: 7px; }
  .status-cluster .badge-button { display: none; }
  .map-controls { top: 67px; left: 8px; }
  .panel-toggle { display: block; top: 68px; right: 8px; }
  .panel { top: auto; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); left: 8px; width: auto; max-height: 51vh; border-radius: 17px; }
  .panel.collapsed { transform: translateY(calc(100% + 28px)); }
  .panel-head { border-radius: 17px 17px 0 0; }
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .metric { padding: 8px 6px; }
  .metric strong { font-size: 16px; }
  .primary-controls { flex-wrap: nowrap; overflow-x: auto; }
  .primary-controls .btn { flex: 0 0 auto; }
  .device-details { padding-bottom: 12px; }
}
@media (max-width: 420px) {
  .brand-copy h1 { font-size: 14px; }
  .status-cluster .badge { padding: 5px 7px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .layer-controls { grid-template-columns: repeat(2, 1fr); }
}
.export-control{display:flex;flex:2 1 170px;gap:6px;min-width:0}.export-control select{min-width:0;flex:1;border:1px solid var(--line);border-radius:9px;background:#081421;color:var(--text);padding:6px 8px;font-size:10px}.export-control .btn{flex:0 0 auto}.panel-footer>button{flex:1 1 auto}
#channelBadge.satellite{border-color:rgba(66,211,255,.45);background:linear-gradient(145deg,rgba(30,64,175,.32),rgba(8,145,178,.2));color:#d9f7ff;box-shadow:0 0 24px rgba(56,189,248,.12)}
@media(max-width:720px){#channelBadge{display:none}}
