:root {
  --bg: #ffffff;
  --panel: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --selected: #dbeafe;
  --error: #dc2626;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --panel: #111827;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: #1f2937;
    --accent: #60a5fa;
    --selected: #1e3a8a;
    --error: #f87171;
  }
}

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

#sidebar {
  width: 340px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
}
#map { flex: 1; }

.bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 12px; }
#empty { padding: 12px; }

button, select, input {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.link { border: none; background: none; color: var(--accent); padding: 0; }
button.icon { border: none; background: none; padding: 2px 6px; opacity: 0.5; }
button.icon:hover { opacity: 1; }

.conn { color: var(--muted); font-size: 12px; }
.conn.on { color: #16a34a; }

#list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
#list li:hover { background: color-mix(in srgb, var(--selected) 50%, transparent); }
#list li.selected { background: var(--selected); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.info { flex: 1; min-width: 0; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

dialog {
  max-width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
dialog h2 { margin-top: 0; font-size: 18px; }
dialog .bar { border: none; padding: 0; }
pre {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  overflow-x: auto;
  user-select: all;
}

.login-page { align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; }
.login-card button { background: var(--accent); color: #fff; border: none; padding: 8px; }
.error { color: var(--error); margin: 0; min-height: 1.4em; }

@media (max-width: 700px) {
  body:not(.login-page) { flex-direction: column-reverse; }
  #sidebar { width: 100%; max-height: 40vh; border-right: none; border-top: 1px solid var(--border); }
}
