:root {
  --bg-primary: #050508;
  --bg-surface: #0c0c12;
  --bg-surface-hover: #13131f;
  --bg-elevated: #161622;
  --border: #1c1c2e;
  --border-light: #282842;
  --accent: #2d7aff;
  --accent-hover: #4a8fff;
  --accent-glow: rgba(45, 122, 255, 0.25);
  --accent-dim: rgba(45, 122, 255, 0.12);
  --success: #22c55e;
  --success-dim: rgba(34, 197, 94, 0.12);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-dim: rgba(245, 158, 11, 0.12);
  --text: #e4e4e7;
  --text-secondary: #71717a;
  --text-muted: #3f3f50;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 4px 32px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.3);
  --sidebar-width: 260px;
  --transition: 0.15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #404060; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ─── Login Page ─── */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 0%, rgba(45, 122, 255, 0.06) 0%, transparent 60%);
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-card .logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-card .logo h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.login-card .logo p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

/* ─── Forms ─── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input[type="number"] { font-family: var(--font-mono); }

/* ─── Custom Select/Dropdown ─── */
select {
  width: 100%;
  padding: 10px 36px 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

select:hover { border-color: var(--border-light); }

select option {
  background: var(--bg-surface);
  color: var(--text);
  padding: 8px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
  border-color: var(--border-light);
}

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.sidebar-logo span {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-nav { flex: 1; padding: 12px; }

.nav-section { margin-bottom: 8px; }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.nav-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item .icon { width: 18px; text-align: center; font-size: 15px; }

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

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px 28px;
  min-height: 100vh;
}

/* ─── Page Header ─── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
.page-header .actions { display: flex; gap: 8px; }

/* ─── Cards ─── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-card .label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 500;
}

.stat-card .value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 4px;
  font-family: var(--font-mono);
}

.stat-card .value.accent { color: var(--accent); }
.stat-card .value.success { color: var(--success); }
.stat-card .value.danger { color: var(--danger); }
.stat-card .value.warning { color: var(--warning); }

/* ─── Tables ─── */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
}

table { width: 100%; border-collapse: collapse; }

thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}

tbody td {
  padding: 11px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

tbody td strong { color: var(--text); }
tbody tr:hover { background: var(--bg-surface-hover); }
tbody tr:last-child td { border-bottom: none; }

.mono { font-family: var(--font-mono); font-size: 12px; }

/* ─── Badges ─── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-active { background: var(--success-dim); color: var(--success); }
.badge-banned { background: var(--danger-dim); color: var(--danger); }
.badge-expired { background: var(--warning-dim); color: var(--warning); }
.badge-unused { background: var(--accent-dim); color: var(--accent); }
.badge-used { background: var(--success-dim); color: var(--success); }
.badge-disabled { background: rgba(63, 63, 80, 0.3); color: var(--text-muted); }
.badge-lifetime { background: rgba(45, 122, 255, 0.15); color: #5fa0ff; }
.badge-online { background: var(--success-dim); color: var(--success); }

/* ─── Modals ─── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
}

.modal h2 { font-size: 17px; margin-bottom: 18px; font-weight: 600; }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 22px;
}

/* ─── Toast ─── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideIn 0.25s ease;
  max-width: 340px;
}

.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--accent); color: #fff; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Toolbar ─── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar .search-input { max-width: 260px; }

.filter-group { display: flex; gap: 3px; }

.filter-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.filter-btn:hover { background: var(--bg-surface-hover); color: var(--text-secondary); }
.filter-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

/* ─── Pagination ─── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.pagination-btns { display: flex; gap: 4px; }

/* ─── Copy button ─── */
.copy-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 13px;
  transition: color var(--transition);
}
.copy-btn:hover { color: var(--accent); }

/* ─── Secret field ─── */
.secret-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.secret-field .masked { color: var(--text-muted); }

/* ─── Tabs ─── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  font-family: var(--font);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover { color: var(--text-secondary); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 40px; margin-bottom: 12px; opacity: 0.2; }
.empty-state p { margin-top: 8px; font-size: 13px; }

/* ─── Log colors ─── */
.log-ok { color: var(--success); }
.log-fail { color: var(--danger); }
.log-warn { color: var(--warning); }
.log-info { color: var(--text-secondary); }

/* ─── Textarea for keys ─── */
.keys-output {
  width: 100%;
  min-height: 200px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 12px;
  resize: vertical;
}

/* ─── Checkbox styled ─── */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* ─── Inline tag group (for multi-select permissions) ─── */
.perm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.perm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.perm-item:hover { border-color: var(--border-light); }
.perm-item.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

/* ─── Session status dot ─── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--text-muted); }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .perm-grid { grid-template-columns: 1fr; }
}
