:root {
  --bg: #0a0e17;
  --bg-elev: #111725;
  --bg-elev-2: #161d2e;
  --line: #212a3d;
  --line-soft: #1a2233;
  --text: #e7ecf4;
  --text-dim: #8a95ab;
  --text-mut: #5c6885;
  --brand: #5b8cff;
  --brand-2: #7c5cff;
  --green: #2fbf71;
  --amber: #f0b429;
  --red: #ef4d5a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* ── Layout ─────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, #0c1120 0%, #0a0e17 100%);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 8px 22px;
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; font-weight: 800;
  box-shadow: 0 6px 16px rgba(91, 140, 255, .35);
}
.brand .name { font-size: 16px; font-weight: 750; letter-spacing: -.02em; }
.brand .name span { color: var(--text-mut); font-weight: 500; display: block; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-mut); margin: 16px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 550;
  transition: all .15s ease;
}
.nav a svg { width: 18px; height: 18px; opacity: .85; flex: none; }
.nav a:hover { background: var(--bg-elev); color: var(--text); }
.nav a.active {
  background: linear-gradient(90deg, rgba(91,140,255,.16), rgba(124,92,255,.05));
  color: #fff;
  box-shadow: inset 2px 0 0 var(--brand);
}
.sidebar .foot { margin-top: auto; padding: 12px 10px 0; font-size: 12px; color: var(--text-mut); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; background: rgba(10,14,23,.8);
  backdrop-filter: blur(10px); z-index: 10;
}
.topbar .title { font-size: 17px; font-weight: 700; }
.topbar .right { display: flex; align-items: center; gap: 14px; color: var(--text-dim); font-size: 13px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg,var(--brand),var(--brand-2)); display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 13px; }

.content { padding: 28px; max-width: 1280px; width: 100%; }

/* ── Cards / stats ──────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--bg-elev); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 18px 20px; position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(circle, rgba(91,140,255,.14), transparent 70%); }
.stat .label { color: var(--text-dim); font-size: 12.5px; font-weight: 550; letter-spacing: .01em; }
.stat .value { font-size: 28px; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; }
.stat .delta { font-size: 12px; margin-top: 6px; color: var(--text-mut); }
.stat .delta.up { color: var(--green); }

.card {
  background: var(--bg-elev); border: 1px solid var(--line-soft);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 22px;
}
.card .card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.card .card-head h3 { font-size: 15px; }
.card .card-body { padding: 6px 0; }
.card.pad .card-body { padding: 20px; }

/* ── Table ──────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-mut); font-weight: 600; padding: 11px 20px; border-bottom: 1px solid var(--line-soft);
}
tbody td { padding: 13px 20px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-elev-2); }
td .muted, .muted { color: var(--text-mut); }
.mono { font-family: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace; font-size: 12.5px; }

/* ── Badges ─────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { color: #7ff0b0; background: rgba(47,191,113,.12); border-color: rgba(47,191,113,.25); }
.badge.amber { color: #ffd77a; background: rgba(240,180,41,.12); border-color: rgba(240,180,41,.25); }
.badge.red { color: #ff9aa2; background: rgba(239,77,90,.12); border-color: rgba(239,77,90,.25); }
.badge.blue { color: #a7c4ff; background: rgba(91,140,255,.12); border-color: rgba(91,140,255,.25); }
.badge.gray { color: var(--text-dim); background: rgba(140,149,171,.1); border-color: rgba(140,149,171,.2); }

/* ── Buttons / forms ────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 9px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13.5px;
  border: 1px solid var(--line); background: var(--bg-elev-2); color: var(--text);
  transition: all .15s ease;
}
.btn:hover { border-color: #2c3852; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border: none; color: #fff; box-shadow: 0 6px 16px rgba(91,140,255,.3); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #ff9aa2; border-color: rgba(239,77,90,.35); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }

.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 550; }
input, textarea, select {
  width: 100%; padding: 10px 13px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--line); color: var(--text); font: inherit;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); }
textarea { min-height: 92px; resize: vertical; font-family: "SF Mono", ui-monospace, monospace; font-size: 12.5px; }
.hint { font-size: 12px; color: var(--text-mut); margin-top: 5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Login ──────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1200px 600px at 20% -10%, rgba(91,140,255,.18), transparent 60%),
  radial-gradient(900px 500px at 90% 110%, rgba(124,92,255,.16), transparent 55%), var(--bg); }
.login-card { width: 380px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 18px; padding: 34px; box-shadow: var(--shadow); }
.login-card .brand { justify-content: center; padding-bottom: 8px; }
.login-card h2 { text-align: center; margin-bottom: 4px; }
.login-card p.sub { text-align: center; color: var(--text-dim); margin: 0 0 24px; font-size: 13px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; }
.error { background: rgba(239,77,90,.1); border: 1px solid rgba(239,77,90,.3); color: #ff9aa2; padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; }

.empty { text-align: center; padding: 50px 20px; color: var(--text-mut); }
.empty .big { font-size: 40px; margin-bottom: 8px; opacity: .5; }

.app-icon { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; background: var(--bg-elev-2); border: 1px solid var(--line-soft); }
.flex { display: flex; align-items: center; gap: 12px; }
.pagebar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.pagebar h1 { font-size: 22px; }
.pagebar .sub { color: var(--text-dim); font-size: 13px; margin-top: 3px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
