:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #172033;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: #1e3a8a;
  --accent-soft-text: #93c5fd;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #450a0a;
  --danger-soft-text: #fca5a5;
  --warn: #92400e;
  --warn-hover: #78350f;
  --warn-soft: #451a03;
  --warn-soft-text: #fdba74;
  --success: #14532d;
  --success-text: #86efac;
  --neutral: #475569;
  --neutral-hover: #334155;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
}

a { color: var(--accent-soft-text); }

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.container.wide { max-width: 1000px; }

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.navbar .brand { font-size: 1rem; font-weight: 600; color: var(--text); text-decoration: none; }
.navbar .brand:hover { color: var(--text); }

.navbar-right { display: flex; align-items: center; gap: 1rem; }

.navbar .user-chip { font-size: 0.85rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.4rem; }

.navbar .nav-link { color: var(--accent-soft-text); text-decoration: none; font-size: 0.85rem; }
.navbar .nav-link:hover { text-decoration: underline; }

.logout-form { display: inline; }
.logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
}
.logout-btn:hover { border-color: var(--text-muted); color: var(--text); }

/* Cards & sections */
.card {
  background: var(--surface);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  font-size: 0.95rem;
  margin: 0 0 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

.page-title { font-size: 1.4rem; margin: 0 0 0.25rem; }
.page-subtitle { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 1.5rem; }

/* Forms */
label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; color: var(--text-muted); }

input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.9rem;
}

textarea { font-family: ui-monospace, monospace; font-size: 0.8rem; min-height: 4.5rem; }

.field-hint { color: var(--text-faint); font-size: 0.8rem; margin: -0.75rem 0 1rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.2;
}
.btn:hover { background: var(--accent-hover); }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-hover); }
.btn.warn { background: var(--warn); }
.btn.warn:hover { background: var(--warn-hover); }
.btn.neutral { background: var(--neutral); }
.btn.neutral:hover { background: var(--neutral-hover); }
a.btn.disabled { background: var(--neutral); pointer-events: none; cursor: not-allowed; }

/* Badges */
.badge { padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; }
.badge.active, .badge.set { background: var(--success); color: var(--success-text); }
.badge.disabled, .badge.pending { background: var(--danger-soft); color: var(--danger-soft-text); }
.badge.role { background: var(--accent-soft); color: var(--accent-soft-text); }

/* Table */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }
tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
form.inline { display: inline; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 6px; font-size: 0.85rem; margin-bottom: 1.5rem; }
.alert.error { background: var(--danger-soft); color: var(--danger-soft-text); }
.alert.notice { background: var(--success); color: var(--success-text); }
.alert.warning { background: var(--warn-soft); color: var(--warn-soft-text); }

/* Ports quick-pick */
.ports { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.port-btn { padding: 0.3rem 0.7rem; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; color: #cbd5e1; cursor: pointer; font-size: 0.85rem; }
.port-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-soft-text); }

/* Code blocks */
pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1rem; overflow-x: auto; font-size: 0.85rem; }
code { background: var(--surface-alt); padding: 0.15rem 0.4rem; border-radius: 4px; }

/* Login page */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--surface); padding: 2rem; border-radius: 8px; width: 320px; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }

/* Summary hero on /me */
.hero {
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.hero .hero-label { color: var(--accent-soft-text); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.3rem; }
.hero .hero-url { font-size: 1.15rem; font-weight: 600; }
.hero .hero-url a { color: var(--text); text-decoration: none; }
.hero .hero-url a:hover { text-decoration: underline; }
.hero .hero-meta { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.5rem; }

.section-divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.settings-note { color: var(--text-faint); font-size: 0.8rem; margin-bottom: 1rem; }
