:root {
  --bg: #0a0710;
  --bg-elevated: #120c1f;
  --surface: #160f26;
  --surface-2: #1d1433;
  --text: #ece9f5;
  --muted: #a89fc2;
  --border: #2d2347;
  --primary: #a855f7;
  --primary-dark: #7e22ce;
  --primary-glow: rgba(168, 85, 247, 0.35);
  --primary-text: #ffffff;
  --online: #34d399;
  --offline: #6b6480;
  --danger: #f43f5e;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse 900px 500px at 10% -10%, rgba(168,85,247,0.18), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(126,34,206,0.15), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Tahoma, sans-serif;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ===== Topbar + Tabs ===== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: linear-gradient(180deg, var(--bg-elevated), rgba(18,12,31,0.85));
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(6px);
}
.topbar h1 {
  font-size: 19px;
  margin: 0;
  background: linear-gradient(90deg, #d8b4fe, var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: .5px;
  font-weight: 800;
}

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  transition: all .15s ease;
}
.tab-btn:hover { color: var(--text); border-color: var(--border); }
.tab-btn.active {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  box-shadow: 0 0 14px var(--primary-glow);
}

main { max-width: 1000px; margin: 24px auto; padding: 0 16px; }
.tab-page { display: block; }

/* ===== Cards ===== */
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
}
.card.glow { box-shadow: 0 0 0 1px rgba(168,85,247,0.08), 0 10px 40px -10px rgba(126,34,206,0.35); }
.card h2 { margin-top: 0; font-size: 16px; color: #e3d8fb; }

label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }

input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
select { cursor: pointer; }
select + input { margin-top: 8px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.row input, .row select { flex: 1; min-width: 120px; }

.btn {
  border: none;
  border-radius: 9px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: transform .1s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: var(--primary-text);
  box-shadow: 0 4px 18px -4px var(--primary-glow);
}
.btn.primary:hover { box-shadow: 0 6px 22px -2px var(--primary-glow); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { border-color: var(--primary); color: #e3d8fb; }
.btn.danger { background: linear-gradient(135deg, #be123c, var(--danger)); color: white; }
.btn.small { padding: 5px 10px; font-size: 12px; margin-inline-start: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { text-align: right; padding: 11px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tbody tr:hover { background: rgba(168,85,247,0.05); }

.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 6px; }
.status-dot.online { background: var(--online); box-shadow: 0 0 8px var(--online); }
.status-dot.offline { background: var(--offline); }

.disabled-row { opacity: .45; }

.modal {
  position: fixed; inset: 0; background: rgba(5,3,10,.6);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(3px);
}
.modal-box {
  background: linear-gradient(180deg, var(--surface), var(--bg-elevated));
  border-radius: 14px; padding: 22px;
  width: 100%; max-width: 420px; border: 1px solid var(--border);
}
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin-top: 14px; }
.checkbox-row input { width: auto; }

.setup-card { max-width: 480px; margin: 40px auto; }

.error-text { color: var(--danger); font-size: 13px; margin: 8px 0 0; }

.hint-text { color: var(--muted); font-size: 12px; margin: 6px 0 0; line-height: 1.6; }
.hint-text code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: monospace;
  color: #e3d8fb;
}

.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 12px;
}
.brand-purple { color: var(--primary); font-weight: 700; }

/* ===== Monitor stat cards ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
}
.stat-card .value {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(90deg, #e9d5ff, var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 6px; }

.details-list div { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.details-list div:last-child { border-bottom: none; }
.details-list span.key { color: var(--muted); }

/* ===== Bandwidth bars ===== */
.bw-bar-wrap { background: var(--surface-2); border-radius: 6px; overflow: hidden; height: 8px; width: 100%; min-width: 80px; }
.bw-bar { height: 100%; background: linear-gradient(90deg, var(--primary-dark), var(--primary)); }
