:root {
  --bg: #020617;
  --bg-main: #0b1220;
  --sidebar: #0f172a;
  --panel: #111827;
  --panel-hover: #1e293b;
  --border: #1e293b;
  --border-light: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.15);
  --accent-border: #6d28d9;
  --ok: #4ade80;
  --warn: #fbbf24;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, rgba(124, 58, 237, 0.12), transparent 55%), var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  text-align: center;
}

.login-card .muted {
  text-align: center;
  margin-bottom: 20px;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: #c4b5fd; text-decoration: none; }
a:hover { color: #ddd6fe; }

/* —— App shell —— */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
}

.sidebar-brand strong {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #cbd5e1;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--panel-hover);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-soft);
  color: #fff;
  border-color: rgba(124, 58, 237, 0.35);
}

.nav-item .icon {
  width: 18px;
  height: 18px;
  opacity: 0.85;
  flex-shrink: 0;
}

.nav-item.active .icon { opacity: 1; }

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 8px;
}

.nav-item.external {
  color: var(--muted);
  font-size: 0.85rem;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}

.sidebar-footer a { font-size: inherit; }

/* —— Main content —— */
.main {
  flex: 1;
  min-width: 0;
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
}

.page-header {
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.6) 0%, transparent 100%);
}

.page-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.page-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 640px;
}

.content {
  padding: 24px 32px 48px;
  max-width: 920px;
}

.team-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.team-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.45);
}

.team-main strong { font-weight: 600; }

.team-actions { gap: 8px; }

button.small {
  font-size: 0.8rem;
  padding: 6px 12px;
}

button.danger {
  border-color: rgba(248, 113, 113, 0.45);
  color: #fca5a5;
}

button.danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.12);
}

.cred-banner {
  margin-top: 16px;
  border-color: rgba(124, 58, 237, 0.45);
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.08), transparent);
}

.cred-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-top: 8px;
  font-size: 0.9rem;
}

.cred-row .muted { min-width: 72px; }

.cred-row code {
  font-family: ui-monospace, monospace;
  color: #e9d5ff;
}

/* —— Cards & forms —— */
.card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 14px;
  transition: border-color 0.15s;
}

.card:hover { border-color: var(--border-light); }

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card-link:hover {
  border-color: var(--accent-border);
  background: #131c2e;
  text-decoration: none;
}

.card h2, .card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 600;
}

.muted { color: var(--muted); font-size: 0.9rem; }

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input, textarea, select {
  width: 100%;
  background: #0a0f1a;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea { min-height: 130px; resize: vertical; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-light);
  background: #1e293b;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

button:hover:not(:disabled) { background: #334155; }

button.primary {
  background: linear-gradient(180deg, #7c3aed, #6d28d9);
  border-color: #7c3aed;
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #8b5cf6, #7c3aed);
}

button.warn { border-color: #92400e; color: #fbbf24; background: rgba(146, 64, 14, 0.2); }

button:disabled { opacity: 0.5; cursor: not-allowed; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge.ok, .badge.on { color: var(--ok); border-color: #166534; background: rgba(22, 101, 52, 0.2); }
.badge.off { color: var(--muted); border-color: var(--border); }
.badge.miss { color: var(--warn); border-color: #92400e; background: rgba(146, 64, 14, 0.15); }

.server-list { display: grid; gap: 10px; }

.server-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0a0f1a;
}

.server-meta { flex: 1; min-width: 0; }
.server-meta strong { font-size: 0.95rem; }
.server-url { margin-top: 6px; font-size: 0.8rem; color: var(--muted); word-break: break-all; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.note { margin-top: 12px; font-size: 0.9rem; padding: 10px 14px; border-radius: 10px; }
.note.ok { color: var(--ok); background: rgba(22, 101, 52, 0.12); border: 1px solid #166534; }
.note.err { color: #fca5a5; background: rgba(127, 29, 29, 0.2); border: 1px solid #991b1b; }

.auth-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 16px 18px;
  margin-bottom: 16px;
  border: 1px solid #92400e;
  border-radius: 12px;
  background: rgba(146, 64, 14, 0.12);
}
.auth-row { display: flex; gap: 8px; flex-wrap: wrap; min-width: min(100%, 420px); }
.auth-row input { flex: 1; min-width: 200px; }

.footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.85em;
  background: #0a0f1a;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Mobile: collapsible top nav fallback */
@media (max-width: 768px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px;
  }
  .nav-item { padding: 8px 10px; font-size: 0.8rem; }
  .nav-divider { display: none; }
  .sidebar-footer { display: none; }
  .page-header, .content { padding-left: 16px; padding-right: 16px; }
}
