*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #2b63d9;
  --brand-dark: #1a4fb8;
  --brand-light: #e8f0ff;
  --text: #0d1b3e;
  --text-sec: #4a5e7e;
  --border: #dde6f5;
  --bg: #f0f4fb;
  --card: #ffffff;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --maintenance: #7c3aed;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(17,45,110,0.08);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── LOGIN ────────────────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8f0ff 0%, #f0f4fb 60%, #e4edff 100%);
}

.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 40px rgba(17,45,110,0.14);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Syne', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}

.login-card h1 {
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  color: var(--text);
  margin-bottom: 4px;
}

.login-card > p {
  color: var(--text-sec);
  font-size: 0.88rem;
  margin-bottom: 24px;
}

.login-err {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}
.login-err.show { display: block; }

/* ── FORM ELEMENTS ────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.field small { display: block; color: var(--text-sec); font-size: 0.78rem; margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 150ms;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); }
.field textarea { resize: vertical; font-family: 'Courier New', monospace; font-size: 0.82rem; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 140px; }

/* ── BUTTONS ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background 150ms, transform 100ms, box-shadow 150ms;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(43,99,217,0.25); }
.btn-primary:hover { background: var(--brand-dark); }

.btn-ghost { background: transparent; color: var(--text-sec); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: #fecaca; }

.btn-sm { padding: 6px 13px; font-size: 0.82rem; }
.btn-full { width: 100%; justify-content: center; padding: 11px; font-size: 0.95rem; margin-top: 4px; }

/* ── APP LAYOUT ───────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8899b4;
  padding: 8px 10px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 0.88rem;
  color: var(--text-sec);
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  text-align: left;
  transition: background 120ms, color 120ms;
  width: 100%;
}
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-sec);
  cursor: pointer;
  border: none;
  border-top: 1px solid var(--border);
  background: none;
  font-family: inherit;
  width: 100%;
  transition: color 120ms;
}
.sidebar-logout svg { width: 16px; height: 16px; }
.sidebar-logout:hover { color: var(--danger); }

/* ── MAIN CONTENT ─────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(17,45,110,0.05);
}

#page-title-bar {
  font-family: 'Syne', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sec);
  background: var(--brand-light);
  color: var(--brand);
  padding: 4px 12px;
  border-radius: 999px;
}

/* ── PAGES ────────────────────────────────────────────────────────── */
.page { display: none; padding: 28px; }
.page.active { display: block; }

.page-header { margin-bottom: 24px; }
.page-header h2 { font-family: 'Syne', sans-serif; font-size: 1.35rem; color: var(--text); margin-bottom: 4px; }
.page-header p { color: var(--text-sec); font-size: 0.9rem; }

/* ── CARDS ────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
}

/* ── TOGGLE ───────────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.toggle-row > div strong { display: block; font-size: 0.92rem; font-weight: 600; }
.toggle-row > div p { color: var(--text-sec); font-size: 0.83rem; margin-top: 2px; }

.toggle { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  cursor: pointer;
  transition: background 200ms;
}
.toggle span::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  left: 3px;
  top: 3px;
  transition: transform 200ms;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle input:checked + span { background: var(--brand); }
.toggle input:checked + span::before { transform: translateX(20px); }

/* ── LIST ITEMS ───────────────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }

.list-item__icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-sec);
}
.list-item__icon svg { width: 18px; height: 18px; }

.list-item__info { flex: 1; min-width: 0; }
.list-item__info strong { display: block; font-size: 0.9rem; font-weight: 600; }
.list-item__info small { color: var(--text-sec); font-size: 0.8rem; word-break: break-all; }

.list-item__actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Status badge in list */
.svc-status {
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px;
}
.svc-status--operational { background: #dcfce7; color: #15803d; }
.svc-status--degraded    { background: #fef3c7; color: #92400e; }
.svc-status--down        { background: #fee2e2; color: #991b1b; }
.svc-status--maintenance { background: #ede9fe; color: #5b21b6; }

/* Status select in list */
.svc-select {
  font-size: 0.8rem;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  cursor: pointer;
  background: #fff;
  color: var(--text);
}

/* Edit input */
.edit-input {
  font-size: 0.88rem;
  padding: 5px 8px;
  border: 1.5px solid var(--brand);
  border-radius: 6px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}

/* ── TOAST ────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #1e293b;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  transform: translateY(80px);
  opacity: 0;
  transition: transform 250ms ease, opacity 250ms ease;
  z-index: 999;
  max-width: 300px;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}
.toast.toast-error { background: #7f1d1d; }
.toast.toast-success { background: #14532d; }

/* ── LOADING ──────────────────────────────────────────────────────── */
.loading-state {
  text-align: center;
  padding: 30px;
  color: var(--text-sec);
  font-size: 0.9rem;
}

/* ── RESPONSIVE ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .page { padding: 16px; }
}
