:root {
  --bg-main: #090d16;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(24, 34, 53, 0.95);
  --bg-input: rgba(10, 15, 26, 0.8);
  --border: #1f293d;
  --border-light: #2e3d5b;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --emerald: #10b981;
  --emerald-hover: #059669;
  --amber: #f59e0b;
  --rose: #ef4444;
  --purple: #a855f7;
  --blue: #38bdf8;

  --radius: 12px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography & Helpers ── */
.font-mono { font-family: 'JetBrains Mono', monospace; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-muted); }
.text-purple { color: var(--purple); }
.text-emerald { color: var(--emerald); }
.text-blue { color: var(--blue); }
.text-amber { color: var(--amber); }
.text-rose { color: var(--rose); }

.hidden { display: none !important; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 18px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-sm { padding: 5px 10px; font-size: 11.5px; border-radius: 6px; }
.btn-lg { padding: 12px 20px; font-size: 14px; }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-emerald {
  background: var(--emerald);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-emerald:hover { background: var(--emerald-hover); transform: translateY(-1px); }

.btn-secondary {
  background: rgba(30, 41, 59, 0.8);
  border-color: var(--border-light);
  color: #cbd5e1;
}
.btn-secondary:hover { background: rgba(51, 65, 85, 0.9); color: #fff; }

.btn-danger-soft {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.btn-danger-soft:hover { background: rgba(239, 68, 68, 0.28); color: #fff; }

/* ── Login Overlay ── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, #1e1b4b 0%, #090d16 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(16px);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  margin-bottom: 14px;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.login-header h2 { font-size: 22px; font-weight: 800; }
.login-header p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Form Inputs ── */
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.form-input, .input-with-icon input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  outline: none;
  transition: all 0.15s ease;
}

.form-input:focus, .input-with-icon input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.input-with-icon {
  position: relative;
}

.input-with-icon i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.input-with-icon input {
  padding-left: 38px;
}

.alert-box {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 14px;
}
.alert-danger { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: #fca5a5; }

/* ── Top Nav ── */
.top-nav {
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.3);
}

.nav-brand h1 { font-size: 17px; font-weight: 700; }
.nav-brand .sub-title { font-size: 11.5px; color: var(--text-muted); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.8);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.green { background: #34d399; box-shadow: 0 0 8px #34d399; }

/* ── Main Layout ── */
.main-container {
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-purple .stat-icon { background: rgba(168, 85, 247, 0.15); color: var(--purple); }
.stat-emerald .stat-icon { background: rgba(16, 185, 129, 0.15); color: var(--emerald); }
.stat-blue .stat-icon { background: rgba(56, 189, 248, 0.15); color: var(--blue); }
.stat-amber .stat-icon { background: rgba(245, 158, 11, 0.15); color: var(--amber); }

.stat-data .stat-val { font-size: 22px; font-weight: 800; display: block; }
.stat-data .stat-label { font-size: 12px; color: var(--text-muted); }

/* ── Card ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }

/* ── Toolbar ── */
.toolbar-wrapper {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.search-box {
  position: relative;
  min-width: 280px;
  flex: 1;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  outline: none;
}
.search-box input:focus { border-color: var(--primary); }

.filter-pills {
  display: flex;
  gap: 6px;
  background: rgba(15, 23, 42, 0.8);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover { color: #fff; }
.pill.active { background: var(--primary); color: #fff; }

.toolbar-actions {
  display: flex;
  gap: 8px;
}

/* ── Table ── */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  background: rgba(15, 23, 42, 0.6);
  padding: 14px 18px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.badge-emerald { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-blue { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }
.badge-purple { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-rose { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

/* ── Key Copy Box ── */
.key-copy-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-light);
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 700;
  color: #38bdf8;
  cursor: pointer;
  transition: all 0.15s ease;
}

.key-copy-box:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: var(--primary);
}

/* ── Modals ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  backdrop-filter: blur(8px);
}

.modal-card {
  width: 100%;
  max-width: 620px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85);
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-avatar {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.2);
  color: var(--emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-header p { font-size: 12px; color: var(--text-muted); }

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}
.btn-close:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(10, 15, 26, 0.5);
}
