:root {
  --bg: #0a0e1a;
  --bg-2: #0e1424;
  --card: #121a2c;
  --card-2: #0f1626;
  --border: #1e2a44;
  --border-soft: #16203a;
  --text: #e6ecf7;
  --text-2: #94a3bd;
  --text-3: #64748b;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #16203f 0%, transparent 55%),
              radial-gradient(900px 500px at -10% 110%, #191036 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

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

/* ---------- Shell layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  border-right: 1px solid var(--border);
  background: rgba(10, 14, 26, 0.7);
  backdrop-filter: blur(8px);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 22px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--grad);
  display: grid; place-items: center;
  box-shadow: 0 4px 18px rgba(79, 140, 255, 0.35);
}
.brand .logo svg { width: 18px; height: 18px; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  background: none;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 17px; height: 17px; opacity: 0.85; }
.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.nav-item.active { background: var(--grad); color: #fff; box-shadow: 0 6px 20px rgba(79, 140, 255, 0.3); }

.sidebar .spacer { flex: 1; }

.side-user {
  border-top: 1px solid var(--border);
  padding: 14px 8px 4px;
  font-size: 12.5px;
  color: var(--text-2);
}

.main { padding: 30px 36px; max-width: 1080px; }

/* ---------- Page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; }
.page-sub { color: var(--text-3); font-size: 13px; margin-top: 3px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.primary { background: var(--grad); border: none; color: #fff; box-shadow: 0 6px 18px rgba(79, 140, 255, 0.3); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.green { background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.4); color: var(--green); }
.btn.danger { background: transparent; border-color: rgba(248, 113, 113, 0.4); color: var(--red); }
.btn.danger:hover { background: rgba(248, 113, 113, 0.08); border-color: var(--red); }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.icon-btn {
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn svg { width: 13px; height: 13px; }
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.card h3 .hint { font-size: 11px; color: var(--text-3); font-weight: 500; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(400px 120px at 100% 0%, rgba(79, 140, 255, 0.12), transparent);
  pointer-events: none;
}
.stat .label { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.6px; }
.stat .value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); }
.stat .value.amber { color: var(--amber); }

/* ---------- Table ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; color: var(--text-3); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.015); }
.actions-cell { text-align: right; white-space: nowrap; }
.actions-cell .icon-btn { margin-left: 6px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.3px; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.badge.green { background: rgba(52, 211, 153, 0.12); color: var(--green); }
.badge.green .dot { background: var(--green); }
.badge.red { background: rgba(248, 113, 113, 0.12); color: var(--red); }
.badge.red .dot { background: var(--red); }
.badge.amber { background: rgba(251, 191, 36, 0.12); color: var(--amber); }
.badge.amber .dot { background: var(--amber); }
.badge.gray { background: rgba(148, 163, 189, 0.12); color: var(--text-2); }
.badge.gray .dot { background: var(--text-2); }

.mono { font-family: "Cascadia Code", "JetBrains Mono", Consolas, monospace; font-size: 12px; }
.muted { color: var(--text-3); }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 15px; }
.form-row label { display: block; font-size: 12px; color: var(--text-2); font-weight: 600; margin-bottom: 7px; }
input, select, textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15); }
input::placeholder { color: var(--text-3); }

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 160px; }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(4, 7, 15, 0.72);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow);
}
.modal h3 { font-size: 16px; margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.key-box {
  background: #060a14;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  user-select: all;
  color: var(--accent);
}

/* ---------- Auth screens ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 400px;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 34px;
  box-shadow: var(--shadow);
}
.auth-logo {
  width: 48px; height: 48px; border-radius: 13px;
  background: var(--grad);
  display: grid; place-items: center;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(79, 140, 255, 0.35);
}
.auth-logo svg { width: 24px; height: 24px; }
.auth-card h1 { font-size: 21px; margin-bottom: 6px; }
.auth-card .sub { font-size: 13px; color: var(--text-3); margin-bottom: 22px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 9px; z-index: 100; }
.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 380px;
  animation: slideIn 0.2s ease;
  border-left: 3px solid var(--accent);
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.empty { color: var(--text-3); text-align: center; padding: 34px; font-size: 13.5px; }

/* ---------- Misc ---------- */
.pill-url {
  display: inline-block;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 6px 11px;
  border-radius: 8px;
  color: var(--text-2);
  margin-bottom: 4px;
}
.curl-box {
  background: #060a14;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12.5px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: #a5b4cf;
  line-height: 1.7;
}
.curl-box .hl { color: var(--green); }
.curl-box .kw { color: var(--accent); }

.section-note { font-size: 12.5px; color: var(--text-3); margin: -6px 0 16px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { padding-bottom: 0; padding-right: 12px; }
  .nav-item { white-space: nowrap; }
  .sidebar .spacer { display: none; }
  .side-user { display: none; }
  .main { padding: 20px; }
}