:root {
  --bg: #050507;
  --panel: #0b0a0e;
  --panel-2: #111015;
  --line: #221c30;
  --text: #f5f3fa;
  --muted: #968caf;
  --accent: #a550f5;
  --accent-2: #b96dff;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #ff5d6c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

body {
  background:
    radial-gradient(900px 480px at 12% -10%, rgba(165, 80, 245, .18), transparent 60%),
    radial-gradient(700px 380px at 100% 0%, rgba(165, 80, 245, .08), transparent 55%),
    var(--bg);
}

.hidden { display: none !important; }
.mono { font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; }
.muted { color: var(--muted); }
.right { text-align: right; }
.grow { flex: 1 1 220px; }
.accent { color: var(--accent); }

.brand {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: .4px;
  line-height: 1.1;
}
.brand-sub {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 3.4px;
  margin-top: 2px;
}

/* ---------------------------------------------------------------- login */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}
.login-card {
  width: min(380px, 100%);
  padding: 28px;
  display: grid;
  gap: 12px;
}
.login-card .brand { margin-top: 4px; }
.label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  margin-top: 10px;
}

/* ---------------------------------------------------------------- inputs */
.input {
  min-height: 38px;
  width: 100%;
  padding: 8px 11px;
  color: var(--text);
  background: #08070b;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #5f5672; }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(165, 80, 245, .14);
}

.btn {
  min-height: 38px;
  padding: 8px 14px;
  color: var(--text);
  background: #14111b;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0710;
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 28px; padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.btn.warn { color: var(--warn); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.error {
  min-height: 18px;
  margin: 2px 0 0;
  color: var(--bad);
  font-size: 12.5px;
}

/* ---------------------------------------------------------------- shell */
.app { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 7, 11, .78);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.top-actions { display: flex; align-items: center; gap: 14px; }

.wrap {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px 28px 64px;
  display: grid;
  gap: 18px;
}

/* ---------------------------------------------------------------- stats */
.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: grid;
  gap: 4px;
}
.stat-label { color: var(--muted); font-size: 10.5px; letter-spacing: 2px; }
.stat-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
  letter-spacing: .2px;
}
.gen-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.gen-row .input { width: auto; }
.gen-row select { min-width: 140px; }
.gen-row .qty { width: 86px; }

.generated {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #08070b;
  padding: 12px;
}
.generated-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .6px;
  text-transform: uppercase;
}
.gen-list {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: #050408;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-2);
  font: 13px/1.7 "Cascadia Mono", "Consolas", monospace;
  overflow: auto;
}

/* ---------------------------------------------------------------- table */
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.table-head h2 { margin: 0; }
.search { width: min(340px, 100%); }

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
  font-size: 13px;
}
thead th {
  position: sticky;
  top: 0;
  background: #0e0c13;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(34, 28, 48, .55);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(165, 80, 245, .045); }
td.key { color: var(--text); font-size: 12.5px; }
td.note { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.actions { white-space: nowrap; }
td.actions .btn + .btn { margin-left: 5px; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .8px;
  border: 1px solid transparent;
}
.badge.unused { color: var(--muted); border-color: #2c2539; background: #14111b; }
.badge.active { color: var(--good); border-color: rgba(74, 222, 128, .3); background: rgba(74, 222, 128, .08); }
.badge.expired { color: var(--warn); border-color: rgba(251, 191, 36, .28); background: rgba(251, 191, 36, .07); }
.badge.revoked { color: var(--bad); border-color: rgba(255, 93, 108, .3); background: rgba(255, 93, 108, .08); }

.empty { color: var(--muted); text-align: center; margin: 18px 0 4px; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  padding: 11px 16px;
  background: #14111b;
  border: 1px solid var(--accent);
  border-radius: 9px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
  color: var(--text);
  font-weight: 600;
  z-index: 50;
}
.toast.bad { border-color: var(--bad); color: #ffd5d9; }

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .topbar, .wrap { padding-left: 16px; padding-right: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top-actions .mono { display: none; }
}
