:root {
  --bg: #0e1412;
  --bg-elev: #151c19;
  --bg-row: #121916;
  --line: #24302b;
  --text: #e7efea;
  --muted: #8a9a92;
  --accent: #3ecf8e;
  --accent-dim: #1f6b4a;
  --warn: #e6b35a;
  --danger: #e06b6b;
  --online: #3ecf8e;
  --offline: #5a6760;
  --sensor: #6ec8ff;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 10% -10%, #163528 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #122033 0%, transparent 50%),
    var(--bg);
  color: var(--text);
}

.top {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 20, 18, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; gap: 0.75rem; align-items: center; min-width: 200px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #1a8fbf);
  box-shadow: 0 0 0 1px rgba(62,207,142,.35);
}
.brand-name { font-weight: 600; letter-spacing: 0.02em; }
.brand-sub { color: var(--muted); font-size: 0.78rem; }
.top-metrics { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.metric {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  min-width: 110px;
}
.metric b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.metric span { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.top-controls { display: flex; gap: 0.6rem; align-items: end; }
label { font-size: 0.75rem; color: var(--muted); display: grid; gap: 0.25rem; }
select, button {
  font: inherit;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent-dim); }

.tabs {
  display: flex; gap: 0.35rem;
  padding: 0.75rem 1.25rem 0;
}
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}
.tab.active {
  color: var(--text);
  border-color: var(--line);
  background: var(--bg-elev);
}

main { padding: 0.85rem 1.25rem 2rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel {
  background: rgba(21, 28, 25, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem;
  margin-bottom: 0.85rem;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-bottom: 0.75rem;
}
.panel-head h2, .panel-head h3, aside h3 { margin: 0; font-size: 1rem; }
.muted { color: var(--muted); font-size: 0.85rem; }

.table-wrap { overflow: auto; max-height: 360px; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td {
  text-align: left;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 500; font-size: 0.72rem; letter-spacing: 0.04em; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.selected { background: #1a2621; }
.mono { font-family: var(--mono); font-size: 0.8rem; }
.status {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block;
}
.status.on { background: var(--online); box-shadow: 0 0 8px rgba(62,207,142,.5); }
.status.off { background: var(--offline); }
.chip {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  font-family: var(--mono);
}

.charts {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.chart-card {
  background: var(--bg-row);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem;
}
.chart-card.narrow { width: 100%; }
.chart-label { color: var(--muted); font-size: 0.75rem; margin-bottom: 0.35rem; }
canvas { width: 100%; height: auto; display: block; }

.map-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0.85rem;
}
#map {
  height: min(72vh, 720px);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.map-canvas {
  height: min(72vh, 720px);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.table-wrap.tall { max-height: 70vh; }
.panel.nested {
  margin: 0 0 0.85rem;
  padding: 0.65rem;
  background: var(--bg-row);
}
.net-bars { display: grid; gap: 0.55rem; margin-top: 0.35rem; }
.net-row-top {
  display: flex; justify-content: space-between; gap: 0.75rem;
  font-size: 0.82rem; margin-bottom: 0.2rem;
}
.net-track {
  height: 8px; border-radius: 999px; background: #1a2420; overflow: hidden;
}
.net-fill { height: 100%; border-radius: 999px; }
.swatch {
  width: 10px; height: 10px; border-radius: 3px;
  display: inline-block; margin-right: 0.4rem; vertical-align: middle;
}
.side-card { display: grid; gap: 0.65rem; }
.map-stats.compact {
  grid-template-columns: 1fr 1fr;
}
.legend { display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.78rem; color: var(--muted); }
.legend .dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 0.3rem;
}
.gw-online { background: var(--online); }
.gw-offline { background: var(--offline); }
.sensor { background: var(--sensor); }
.map-stats { display: grid; gap: 0.5rem; margin: 0.75rem 0 1rem; }
.map-stats div {
  background: var(--bg-row);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}
.hints { margin: 0.5rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.85rem; }
.hints li { margin-bottom: 0.4rem; }

@media (max-width: 980px) {
  .charts, .map-layout { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; }
}
