* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Segoe UI', Inter, -apple-system, sans-serif;
  background: #0B1120;
  color: #F9FAFB;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* === LOGIN === */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #111827 0%, #0B1120 70%);
}
.login-card {
  width: 380px;
  text-align: center;
  background: #111827;
  border: 1px solid #1F2937;
  border-radius: 16px;
  padding: 48px 36px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}
.login-card h1 { font-size: 26px; margin-bottom: 4px; }
.login-card .sub { color: #6B7280; font-size: 13px; margin-bottom: 28px; }
.login-card input { width: 100%; margin-bottom: 14px; }
.login-card button { margin-top: 4px; }

/* === ADMIN LAYOUT === */
#admin-screen {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 220px;
  background: #0F172A;
  border-right: 1px solid #1E293B;
  padding: 20px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar-logo {
  padding: 8px 20px 24px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #F9FAFB;
  border-bottom: 1px solid #1E293B;
  margin-bottom: 12px;
}
.sidebar-logo span { color: #3B82F6; }
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
  flex: 1;
}
.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: transparent;
  color: #9CA3AF;
  border: none;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}
.sidebar-btn:hover { background: #1E293B; color: #F9FAFB; }
.sidebar-btn.active { background: #1E3A5F; color: #60A5FA; font-weight: 600; }
.sidebar-btn .icon { font-size: 16px; width: 22px; text-align: center; }
.sidebar-bottom {
  padding: 12px 20px;
  border-top: 1px solid #1E293B;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-bottom span { color: #6B7280; font-size: 12px; }

/* Main content */
.main-content {
  flex: 1;
  padding: 28px 32px;
  max-width: calc(100vw - 220px);
  overflow-x: auto;
}

/* === STATS CARDS === */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.stat-card {
  background: #111827;
  border: 1px solid #1F2937;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #F9FAFB;
  line-height: 1.2;
}
.stat-card .stat-label {
  font-size: 11px;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}
.stat-card.stat-total { border-left: 3px solid #3B82F6; }
.stat-card.stat-active { border-left: 3px solid #22C55E; }
.stat-card.stat-banned { border-left: 3px solid #EF4444; }
.stat-card.stat-expired { border-left: 3px solid #F59E0B; }
.stat-card.stat-today { border-left: 3px solid #A855F7; }
.stat-card.stat-soon { border-left: 3px solid #F97316; }

/* === CARDS === */
.card {
  background: #111827;
  border: 1px solid #1F2937;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}
.card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #F9FAFB;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* Generate form - horizontal layout */
.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 11px; color: #6B7280; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group textarea {
  width: auto;
  min-width: 140px;
}
.form-group textarea {
  background: #1F2937;
  color: #F9FAFB;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
  font-family: inherit;
  resize: vertical;
}
.form-group textarea:focus { border-color: #3B82F6; background: #1E2D42; }

input, select {
  background: #1F2937;
  color: #F9FAFB;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}
input:focus, select:focus { border-color: #3B82F6; background: #1E2D42; }

button {
  background: #3B82F6;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
button:hover { background: #2563EB; }
.btn-sm { padding: 7px 14px; font-size: 12px; width: auto; }
.btn-xs { padding: 4px 10px; font-size: 11px; width: auto; border-radius: 6px; }
.btn-ghost { background: transparent; color: #9CA3AF; }
.btn-ghost:hover { background: #1E293B; color: #F9FAFB; }
.btn-danger { background: #EF4444; }
.btn-danger:hover { background: #DC2626; }
.btn-success { background: #22C55E; }
.btn-success:hover { background: #16A34A; }
.btn-warning { background: #F59E0B; }
.btn-warning:hover { background: #D97706; }
.btn-outline { background: transparent; border: 1px solid #374151; color: #D1D5DB; }
.btn-outline:hover { background: #1F2937; }

/* === CHECKBOX === */
input[type="checkbox"] {
  accent-color: #3B82F6;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* === TABLE === */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 12px 14px;
  color: #6B7280;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #1F2937;
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #1A2332;
  vertical-align: middle;
}
tbody tr { transition: background 0.1s ease; }
tbody tr:hover td { background: #1A2332; }

.key-cell { font-family: 'JetBrains Mono', 'Menlo', monospace; font-size: 12px; letter-spacing: 0.3px; }

/* === BADGES === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-active { background: #064E3B; color: #6EE7B7; }
.badge-banned { background: #7F1D1D; color: #FCA5A5; }
.badge-expired { background: #78350F; color: #FDBA74; }

/* === FILTERS === */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-bar select { width: auto; min-width: 120px; }
.filter-bar input { width: auto; min-width: 200px; }
.filter-bar .count { color: #6B7280; font-size: 12px; margin-left: auto; white-space: nowrap; }

/* === PAGINATION === */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}
.pgn-btn, .pgn-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  background: #1F2937;
  color: #D1D5DB;
  border: none;
  transition: all 0.1s ease;
}
.pgn-btn:hover { background: #374151; color: #F9FAFB; }
.pgn-current { background: #3B82F6; color: white; cursor: default; }

/* === ACTIONS === */
.actions { display: flex; gap: 4px; flex-wrap: nowrap; }

.result {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  word-break: break-all;
}
.result.success { background: #064E3B; color: #6EE7B7; }
.result.error { background: #7F1D1D; color: #FCA5A5; }

/* === TOAST === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1F2937;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 13px;
  color: #F9FAFB;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  z-index: 999;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: #111827;
  border: 1px solid #1F2937;
  border-radius: 16px;
  padding: 32px;
  width: 460px;
  max-width: 90vw;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.modal h3 { font-size: 17px; margin-bottom: 20px; }
.modal .form-group { margin-bottom: 16px; }
.modal .form-group label { font-size: 12px; color: #9CA3AF; margin-bottom: 6px; display: block; }
.modal .form-group input, .modal .form-group textarea { width: 100%; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.modal .modal-actions button { min-width: 100px; }
.modal .key-display {
  background: #1F2937;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  letter-spacing: 1px;
  color: #60A5FA;
  text-align: center;
  margin-bottom: 20px;
  border: 1px solid #374151;
}

/* === USER MANAGEMENT === */
.role-select {
  background: #1F2937;
  color: #F9FAFB;
  border: 1px solid #374151;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}
.role-select:focus {
  outline: none;
  border-color: #3B82F6;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { max-width: 100vw; padding: 16px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input, .filter-bar select { width: 100%; }
  .form-row { flex-direction: column; }
  .form-group input { width: 100%; }
}
