:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #171f2b;
  --border: #232d3b;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #4f8cff;
  --green: #3fb950;
  --red: #f85149;
  --amber: #d29922;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.loading { padding: 40px; color: var(--muted); }

#app { min-height: 100vh; }

/* --- top bar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar .actions { display: flex; gap: 8px; }

/* --- generic layout --- */
.page { max-width: 1100px; margin: 0 auto; padding: 24px; }
.center-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}

/* --- buttons / inputs --- */
button, .btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { border-color: var(--red); color: var(--red); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  width: 100%;
}
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
form .row { display: flex; gap: 12px; }
form .row > div { flex: 1; }

/* --- login --- */
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 320px;
}
.login-card h1 { font-size: 18px; margin: 0 0 20px; }
.login-card .error { color: var(--red); font-size: 13px; margin-top: 10px; }

/* --- server groups --- */
.server-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}
.server-group summary {
  cursor: pointer;
  padding: 12px 16px;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
}
.server-group summary::-webkit-details-marker { display: none; }
.server-group .server-meta { color: var(--muted); font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 16px; border-top: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: rgba(255,255,255,0.02); }
td.actions-cell { white-space: nowrap; }
td.actions-cell button { margin-right: 6px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.up { background: var(--green); }
.dot.down { background: var(--red); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge.prod { background: rgba(63,185,80,0.15); color: var(--green); }
.badge.demo { background: rgba(210,153,34,0.15); color: var(--amber); }
.badge.staging { background: rgba(79,140,255,0.15); color: var(--accent); }
.badge.suspended { background: rgba(248,81,73,0.15); color: var(--red); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px; max-width: 360px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.toast.error { border-color: var(--red); color: var(--red); }
.toast.success { border-color: var(--green); color: var(--green); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 14px; margin: 0 0 14px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.feature-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.feature-row:first-child { border-top: none; }
.feature-row .name { font-size: 13px; }
.feature-row .source { color: var(--muted); font-size: 11px; margin-left: 8px; }

.switch {
  position: relative; width: 38px; height: 22px; display: inline-block;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px; cursor: pointer; transition: 0.15s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px;
  background: var(--muted); border-radius: 50%; transition: 0.15s;
}
.switch input:checked + .slider { background: rgba(63,185,80,0.25); border-color: var(--green); }
.switch input:checked + .slider::before { transform: translateX(16px); background: var(--green); }

.back-link { display: inline-block; margin-bottom: 16px; color: var(--muted); }
.empty { color: var(--muted); padding: 24px; text-align: center; }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 24px; width: 420px; max-width: 90vw;
}
dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog h2 { margin-top: 0; font-size: 15px; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
