:root {
  --bg-app: #0d1117;
  --bg-surface: #161b22;
  --bg-raised: #1f2630;
  --border: #30363d;
  --text-main: #e6edf3;
  --text-muted: #8b949e;
  --accent: #38bdf8;
  --primary: #238636;
  --primary-hover: #2ea043;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 0.75rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 8px;
  object-fit: contain; flex-shrink: 0; background: #0b1220; padding: 3px; border: 1px solid var(--border);
}
.auth-brand { display: flex; align-items: center; gap: 0.85rem; margin-bottom: 0.75rem; }
.auth-logo {
  width: 48px; height: 48px; border-radius: 10px;
  object-fit: contain; flex-shrink: 0; background: #0b1220; padding: 4px; border: 1px solid var(--border);
}
.brand-badge {
  width: 38px; height: 38px; border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 0.85rem;
}
.brand-title { font-weight: 700; font-size: 1rem; }
.brand-sub { font-size: 0.75rem; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.nav-link {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-weight: 500;
}
.nav-link:hover { background: var(--bg-raised); text-decoration: none; }
.nav-link.active { background: rgba(56, 189, 248, 0.14); color: var(--accent); font-weight: 600; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 0.9rem; display: flex; flex-direction: column; gap: 0.65rem; }
.user-chip { display: flex; flex-direction: column; font-size: 0.85rem; }
.user-chip small { color: var(--text-muted); }
.copy { font-size: 0.72rem; color: var(--text-muted); text-align: center; }

.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
}
.page-title { margin: 0; font-size: 1.15rem; font-weight: 700; flex: 1; }
.mobile-menu-btn { display: none; }
.content { padding: 1.5rem; max-width: 1400px; width: 100%; margin: 0 auto; }

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}
.kpi-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.kpi-val { font-size: 1.65rem; font-weight: 800; margin-top: 0.25rem; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.table th { font-size: 0.76rem; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.table td.empty { text-align: center; color: var(--text-muted); padding: 1.5rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 0.9rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 600; font-size: 0.86rem; cursor: pointer;
}
.btn-sm { padding: 0.32rem 0.65rem; font-size: 0.78rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: var(--bg-raised); color: var(--text-main); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--text-main); border-color: var(--border); }
.btn-danger { background: rgba(239, 68, 68, 0.16); color: #f87171; border-color: rgba(239, 68, 68, 0.35); }

.pill {
  display: inline-block; padding: 0.18rem 0.55rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700;
}
.pill-active { background: rgba(35, 134, 54, 0.2); color: #4ade80; }
.pill-suspended { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.pill-info { background: rgba(56, 189, 248, 0.16); color: var(--accent); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.85rem; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.field input, .field textarea, .field select {
  width: 100%; padding: 0.55rem 0.75rem;
  background: var(--bg-app); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-main); font-size: 0.9rem;
}
.muted { color: var(--text-muted); }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: rgba(35, 134, 54, 0.16); border-color: rgba(74, 222, 128, 0.35); color: #86efac; }
.alert-error { background: rgba(239, 68, 68, 0.16); border-color: rgba(248, 113, 113, 0.35); color: #fca5a5; }
.alert-warning { background: rgba(245, 158, 11, 0.16); border-color: rgba(251, 191, 36, 0.35); color: #fde68a; }

.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 440px; }
.snippet-box {
  background: var(--bg-app); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.85rem; font-family: ui-monospace, monospace; font-size: 0.82rem; white-space: pre-wrap; margin: 0.75rem 0;
}
.hidden { display: none; }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; top: 0; bottom: 0; z-index: 50; transition: left 0.2s ease; }
  .sidebar.open { left: 0; }
  .mobile-menu-btn { display: inline-flex; }
}
