:root {
  --bg: #11151a;
  --panel: #182028;
  --line: #2a3541;
  --text: #e3e8ee;
  --muted: #8b98a6;
  --accent: #4ea1ff;
  --good: #3ccf7a;
  --fair: #f0b429;
  --poor: #ef5350;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

body { display: flex; flex-direction: column; }

button, select, input {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }

header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
header .spacer { flex: 1; }
#user { color: var(--muted); }

.modes { display: flex; }
.modes button { border-radius: 0; }
.modes button:first-child { border-radius: 6px 0 0 6px; }
.modes button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.modes button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

main { flex: 1; display: flex; min-height: 0; }

aside {
  width: 320px;
  padding: 12px 16px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
aside input[type="search"] { width: 100%; }
aside label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
aside label.check { flex-direction: row; align-items: center; color: var(--text); }
aside section { display: flex; flex-direction: column; gap: 8px; }

.list-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

#devices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#devices li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
#devices li.selected { border-color: var(--swatch, var(--accent)); background: #1d2732; }
#devices .swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--swatch, var(--line)); }
#devices .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#devices .meta { grid-column: 2; color: var(--muted); font-size: 12px; }
#devices .stale { color: var(--fair); }

.legend, .hint, .status { color: var(--muted); font-size: 12px; margin: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 3px 0 8px; }
.dot.good { background: var(--good); }
.dot.fair { background: var(--fair); }
.dot.poor { background: var(--poor); }

#map { flex: 1; position: relative; min-width: 0; }
.live .cesium-viewer-animationContainer,
.live .cesium-viewer-timelineContainer { display: none; }
.live .cesium-viewer-bottom { bottom: 0; }

@media (max-width: 720px) {
  main { flex-direction: column; }
  aside { width: 100%; max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
}
