:root {
  --bg: #0b0f1a;
  --card: #131a2b;
  --border: #232d45;
  --text: #e8edf7;
  --muted: #8b96b3;
  --accent: #6366f1;
  --accent2: #8b5cf6;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px 300px at 15% 0%, rgba(99,102,241,.18), transparent),
    radial-gradient(500px 300px at 90% 10%, rgba(139,92,246,.14), transparent);
}
.view { min-height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

#login-view { align-items: center; justify-content: center; padding: 24px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.login-card { width: 100%; max-width: 380px; text-align: center; }
.logo { font-size: 52px; margin-bottom: 8px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

.field { text-align: left; margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: #0d1322; color: var(--text);
  font-size: 15px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.2); }

.btn-primary {
  width: 100%; padding: 13px; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 15px; font-weight: 700;
  transition: transform .12s ease, opacity .12s;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:disabled { opacity: .5; cursor: wait; transform: none; }
.btn-secondary {
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border);
  background: #1a2340; color: var(--text); cursor: pointer; font-weight: 600; font-size: 14px;
}
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost {
  padding: 8px 14px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 600;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border); }
.error { color: var(--red); font-size: 13px; margin: -8px 0 12px; }

/* Dashboard */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: rgba(11,15,26,.8); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo-sm { font-size: 28px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; display: flex; flex-direction: column; gap: 20px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px; display: flex; flex-direction: column; gap: 4px;
}
.stat-num { font-size: 30px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--muted); }
.card h2 { font-size: 17px; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row .grow { flex: 1; min-width: 220px; }
.form-row .btn-primary { width: auto; padding: 12px 26px; margin-bottom: 16px; white-space: nowrap; }
.new-key {
  margin-top: 18px; padding: 16px; border-radius: 14px;
  background: rgba(34,197,94,.08); border: 1px solid rgba(34,197,94,.35);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.new-key small { display: block; color: var(--muted); margin-bottom: 6px; }
.new-key code { font-size: 17px; font-weight: 700; letter-spacing: .03em; color: var(--green); font-family: ui-monospace, monospace; }
.table-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.table-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 860px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #0d1322; }
tr:last-child td { border-bottom: none; }
td code { font-family: ui-monospace, monospace; font-size: 12px; background: #0d1322; padding: 4px 8px; border-radius: 6px; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.active { background: rgba(34,197,94,.15); color: var(--green); }
.badge.revoked { background: rgba(239,68,68,.15); color: var(--red); }
.badge.bound { background: rgba(99,102,241,.15); color: #a5b4fc; }
.badge.free { background: rgba(139,150,179,.15); color: var(--muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.icon-btn {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: #0d1322; color: var(--text); cursor: pointer; font-size: 12px; font-weight: 600;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.danger:hover { border-color: var(--red); color: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 30px !important; }
.muted { color: var(--muted); font-size: 12px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1a2340; border: 1px solid var(--accent); color: var(--text);
  padding: 12px 22px; border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 99;
}
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-row .btn-primary { width: 100%; }
}
