:root {
  --bg: #0b0f1a;
  --bg-elevated: #10162a;
  --card: #131a2e;
  --card-border: #232c47;
  --sidebar: #0c1120;
  --text: #e7eaf5;
  --text-dim: #8891ac;
  --text-faint: #5c6584;
  --purple: #7c5cff;
  --purple-dim: #4c3aa8;
  --blue: #3b9cff;
  --green: #34c77b;
  --amber: #f5a623;
  --red: #ef4d5e;
  --radius: 12px;
  --font-display: "Sora", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px 8px;
}
.brand-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: var(--font-display);
  color: white;
  flex-shrink: 0;
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.nav-section-label {
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin: 18px 10px 8px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg-elevated); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, var(--purple), #6845e0);
  color: white;
  font-weight: 600;
}
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .6; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  font-size: 12px;
}
.status-pill { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--green); margin-bottom: 4px; }
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); }

/* ---------- Main ---------- */
.main {
  flex: 1;
  min-width: 0;
  padding: 24px 32px 60px 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 26px;
  flex-wrap: wrap;
  gap: 14px;
}
.page-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--text-dim); font-size: 13.5px; margin-top: 4px; }

.topbar-actions { display: flex; gap: 10px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.98); }
.btn-primary { background: linear-gradient(135deg, var(--purple), #6845e0); border-color: transparent; color: white; }
.btn-danger { background: rgba(239,77,94,.12); border-color: rgba(239,77,94,.35); color: #ff8a97; }
.btn-danger:hover { background: rgba(239,77,94,.22); }
.btn-success { background: rgba(52,199,123,.14); border-color: rgba(52,199,123,.35); color: #5fe0a3; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Cards / Stats ---------- */
.grid { display: grid; gap: 18px; }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-2 { grid-template-columns: 1.4fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1200px) { .grid-5 { grid-template-columns: repeat(3, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid-5, .grid-3 { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-title { font-weight: 700; font-size: 15px; }
.card-subtitle { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

.stat-card { position: relative; overflow: hidden; }
.stat-icon {
  width: 38px; height: 38px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; font-size: 17px;
}
.stat-label { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin: 3px 0 2px 0; }
.stat-hint { font-size: 11.5px; color: var(--text-faint); }
.stat-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; }

.icon-purple { background: rgba(124,92,255,.15); color: #a78bfa; }
.icon-blue { background: rgba(59,156,255,.15); color: #7cc0ff; }
.icon-green { background: rgba(52,199,123,.15); color: #5fe0a3; }
.icon-amber { background: rgba(245,166,35,.15); color: #f7c165; }
.icon-red { background: rgba(239,77,94,.15); color: #ff8a97; }

.bar-purple { background: var(--purple); }
.bar-blue { background: var(--blue); }
.bar-green { background: var(--green); }
.bar-amber { background: var(--amber); }
.bar-red { background: var(--red); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 100px;
  font-size: 11.5px; font-weight: 600;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { background: rgba(52,199,123,.14); color: #5fe0a3; }
.badge-red { background: rgba(239,77,94,.14); color: #ff8a97; }
.badge-amber { background: rgba(245,166,35,.14); color: #f7c165; }
.badge-gray { background: rgba(136,145,172,.14); color: var(--text-dim); }
.badge-purple { background: rgba(124,92,255,.14); color: #a78bfa; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 46px 20px; color: var(--text-dim); }
.empty-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--bg-elevated); border: 1px solid var(--card-border);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px auto; font-size: 26px; color: var(--text-faint);
}
.empty-title { color: var(--text); font-weight: 700; margin-bottom: 4px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; color: var(--text-faint); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 12px; border-bottom: 1px solid var(--card-border);
}
td { padding: 12px; border-bottom: 1px solid var(--card-border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.015); }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12.5px; color: var(--text-dim); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email], input[type=number], select, textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: 9px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font-body);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--purple); }
.form-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }
.form-row { display: flex; gap: 14px; }
.form-row > * { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--card-border); border-radius: 100px; transition: .2s;
}
.switch .slider:before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(18px); }

.alert { padding: 12px 14px; border-radius: 9px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: rgba(239,77,94,.1); border: 1px solid rgba(239,77,94,.3); color: #ff8a97; }
.alert-success { background: rgba(52,199,123,.1); border: 1px solid rgba(52,199,123,.3); color: #5fe0a3; }
.alert-info { background: rgba(59,156,255,.1); border: 1px solid rgba(59,156,255,.3); color: #7cc0ff; }

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(124,92,255,.15), transparent 45%),
              radial-gradient(circle at 80% 80%, rgba(59,156,255,.12), transparent 45%), var(--bg);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--card-border); border-radius: 16px; padding: 32px;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; }

/* ---------- Utility ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 18px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 18px; }
.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.text-sm { font-size: 12.5px; }
.w-full { width: 100%; }
