/* ── Reset & Variables ───────────────────────────────────────────────────────── */
:root {
  --bg:       #0f0f13;
  --bg2:      #1a1a1f;
  --bg3:      #252529;
  --bg4:      #2e2e33;
  --border:   #27272a;
  --border2:  #3f3f46;
  --primary:  #3b82f6;
  --primary-h:#2563eb;
  --primary-l:#60a5fa;
  --success:  #10b981;
  --warning:  #f59e0b;
  --error:    #ef4444;
  --text:     #ffffff;
  --text2:    #a1a1aa;
  --muted:    #71717a;
  --radius:   8px;
  --radius-lg:12px;
  --shadow:   0 4px 24px rgba(0,0,0,.4);
  --transition: all .15s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-l); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo .logo-text { font-size: 13px; font-weight: 700; line-height: 1.2; }
.sidebar-logo .logo-sub  { font-size: 10px; color: var(--muted); }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 8px 12px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-link.active { background: rgba(59,130,246,.15); color: var(--primary-l); }
.nav-link .nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.nav-link.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--bg4);
  color: var(--text2);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.nav-link.active .nav-badge { background: rgba(59,130,246,.25); color: var(--primary-l); }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

.main-content {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.page-body { padding: 28px; flex: 1; }

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-header p  { font-size: 13px; color: var(--text2); }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Stat grid ───────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent, var(--primary));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card.green  { --accent: var(--success); }
.stat-card.yellow { --accent: var(--warning); }
.stat-card.red    { --accent: var(--error); }
.stat-card.purple { --accent: #8b5cf6; }

.stat-num  { font-size: 30px; font-weight: 800; line-height: 1; margin-bottom: 6px; }
.stat-label{ font-size: 12px; color: var(--text2); }
.stat-sub  { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── Table ───────────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg3); }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-trial    { background: rgba(245,158,11,.12); color: var(--warning);  border: 1px solid rgba(245,158,11,.25); }
.badge-monthly  { background: rgba(59,130,246,.12);  color: var(--primary-l);border: 1px solid rgba(59,130,246,.25); }
.badge-lifetime { background: rgba(16,185,129,.12);  color: var(--success);  border: 1px solid rgba(16,185,129,.25); }
.badge-active   { background: rgba(16,185,129,.12);  color: var(--success);  border: 1px solid rgba(16,185,129,.25); }
.badge-revoked  { background: rgba(239,68,68,.12);   color: var(--error);    border: 1px solid rgba(239,68,68,.25); }
.badge-expired  { background: rgba(245,158,11,.12);  color: var(--warning);  border: 1px solid rgba(245,158,11,.25); }
.badge-bound    { background: rgba(16,185,129,.12);  color: var(--success);  border: 1px solid rgba(16,185,129,.25); }
.badge-unbound  { background: var(--bg3);            color: var(--muted);    border: 1px solid var(--border); }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text2);
}
.field input,
.field select,
.field textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.field select { cursor: pointer; }
.field .hint { font-size: 11px; color: var(--muted); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--primary-h); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,.3); }
.btn-success  { background: var(--success);  color: #fff; }
.btn-success:hover:not(:disabled)  { background: #059669; }
.btn-danger   { background: var(--error);    color: #fff; }
.btn-danger:hover:not(:disabled)   { background: #dc2626; }
.btn-warning  { background: var(--warning);  color: #000; }
.btn-warning:hover:not(:disabled)  { background: #d97706; }
.btn-ghost    { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled)    { background: var(--bg3); color: var(--text); border-color: var(--border2); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px;  font-size: 11px; }
.btn-icon { padding: 7px; border-radius: var(--radius); }

/* ── Toolbar (search + actions row) ─────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .search-wrap { position: relative; flex: 1; min-width: 200px; }
.toolbar .search-wrap input { padding-left: 34px; }
.toolbar .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.toolbar-right { display: flex; gap: 8px; margin-left: auto; }

/* ── Pagination ──────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}
.pagination .page-info { font-size: 12px; color: var(--muted); margin: 0 4px; }

/* ── Filter tabs ─────────────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 16px;
  width: fit-content;
}
.filter-tab {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}
.filter-tab.active { background: var(--bg2); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.filter-tab:hover:not(.active) { color: var(--text2); }

/* ── Alerts / inline messages ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: rgba(16,185,129,.1);  border: 1px solid rgba(16,185,129,.25); color: #6ee7b7; }
.alert-error   { background: rgba(239,68,68,.1);   border: 1px solid rgba(239,68,68,.25);  color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,.1);  border: 1px solid rgba(245,158,11,.25); color: #fcd34d; }
.alert-info    { background: rgba(59,130,246,.1);  border: 1px solid rgba(59,130,246,.25); color: #93c5fd; }

/* ── Toast ───────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  max-width: 340px;
  box-shadow: var(--shadow);
  animation: toastIn .2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast-success { background: #064e3b; border: 1px solid var(--success); color: #6ee7b7; }
.toast-error   { background: #450a0a; border: 1px solid var(--error);   color: #fca5a5; }
.toast-warning { background: #451a03; border: 1px solid var(--warning); color: #fcd34d; }
.toast-info    { background: #1e3a5f; border: 1px solid var(--primary); color: #93c5fd; }
@keyframes toastIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform:scale(.96); } to { opacity:1; transform:scale(1); } }
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 4px; }
.modal-close:hover { color: var(--error); background: rgba(239,68,68,.1); }
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Key display ─────────────────────────────────────────────────────────────── */
.key-display {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  letter-spacing: .12em;
  color: var(--success);
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  user-select: all;
}
.key-display:hover { border-color: var(--success); background: rgba(16,185,129,.05); }
.key-mono { font-family: 'Courier New', monospace; font-size: 12px; letter-spacing: .06em; }

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state svg { opacity: .3; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Login page ──────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
.login-card h1 { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-card p  { font-size: 13px; color: var(--text2); text-align: center; margin-bottom: 28px; }

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.text-muted   { color: var(--muted); }
.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary-l); }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.gap-12{ gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }
