/**
 * public/css/admin.css
 * CyberHeroesHQ admin design system — cyber-themed dark SaaS aesthetic.
 * Sidebar + topbar shell, KPI cards, sortable tables, badges, modals, toasts.
 *
 * All color/tokens use ds-* variables set in the admin shell (_shell.ejs).
 * ds-* aliases are provided for shared ds-* component classes.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables — ds-* tokens already set in _shell.ejs; admin-* aliases for legacy ── */
:root {
  --admin-bg:         var(--ds-bg);
  --admin-surface:    var(--ds-surface);
  --admin-surface-2:  var(--ds-surface-2);
  --admin-border:     var(--ds-border);
  --admin-border-2:   var(--ds-border-light);
  --admin-text:       var(--ds-text);
  --admin-muted:      var(--ds-text-muted);
  --admin-muted-2:    var(--ds-text-dim);
  --admin-accent:     var(--ds-primary);
  --admin-accent-dim: var(--ds-primary-light);
  --admin-accent-2:   var(--ds-accent);
  --admin-success:    var(--ds-success);
  --admin-success-dim:var(--ds-success-light);
  --admin-warning:    var(--ds-warning);
  --admin-warning-dim:var(--ds-warning-light);
  --admin-danger:     var(--ds-danger);
  --admin-danger-dim: var(--ds-danger-light);
  --admin-purple:     var(--ds-accent);
  --admin-purple-dim:  var(--ds-info-light);
  --admin-sidebar-w:  var(--ds-sidebar-w, 240px);
  --admin-topbar-h:   var(--ds-nav-h, 58px);
  --admin-radius:     var(--ds-radius-md, 10px);
  --admin-radius-sm:  var(--ds-radius-sm, 6px);
  --admin-shadow:     var(--ds-shadow-lg, 0 4px 24px rgba(0,0,0,0.5));
  --admin-shadow-sm:  var(--ds-shadow-sm, 0 2px 8px rgba(0,0,0,0.35));
  --ds-font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--admin-bg);
  color: var(--admin-text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Sidebar */
.admin-sidebar {
  width: var(--admin-sidebar-w);
  background: var(--admin-surface);
  border-right: 1px solid var(--admin-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: width 0.2s ease;
  overflow: hidden;
}
.admin-sidebar.collapsed {
  width: 60px;
}
.sidebar-logo {
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--admin-accent), var(--admin-accent-2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.sidebar-logo-text {
  font-size: 14px; font-weight: 700;
  color: #fff; line-height: 1.2;
  white-space: nowrap;
}
.sidebar-logo-sub {
  font-size: 10px; color: var(--admin-muted);
  font-weight: 500; letter-spacing: 0.5px; text-transform: uppercase;
  margin-top: 1px; white-space: nowrap;
}
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--admin-border) transparent;
}
.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--admin-muted-2);
  padding: 14px 10px 4px;
  white-space: nowrap;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--admin-radius-sm);
  color: var(--admin-muted);
  text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 1px;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}
.nav-item:hover {
  background: var(--admin-surface-2);
  color: var(--admin-text);
}
.nav-item.active {
  background: var(--admin-accent-dim);
  color: var(--admin-accent);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--admin-accent);
  border-radius: 0 2px 2px 0;
}
.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.nav-label { flex: 1; }
.nav-badge {
  font-size: 10px; font-weight: 800;
  background: var(--admin-warning);
  color: #000;
  padding: 1px 5px;
  border-radius: 99px;
  min-width: 18px; text-align: center;
  line-height: 1.6;
}
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--admin-border);
  flex-shrink: 0;
}
.admin-role-badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}
.admin-role-super    { color: #f8c400; background: #f8c40022; }
.admin-role-district { color: #58a6ff; background: #58a6ff22; }
.admin-role-content  { color: #22d3a0; background: #22d3a022; }
.admin-role-support  { color: #f59e0b; background: #f59e0b22; }
.admin-email {
  font-size: 12px; color: var(--admin-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block;
}
.logout-link {
  font-size: 12px; color: var(--admin-danger);
  text-decoration: none; display: block; margin-top: 6px;
}
.logout-link:hover { text-decoration: underline; }
.sidebar-collapse-btn {
  background: none; border: none;
  color: var(--admin-muted); cursor: pointer;
  font-size: 14px; padding: 2px;
  opacity: 0.5;
}
.sidebar-collapse-btn:hover { opacity: 1; color: var(--admin-text); }

/* Main area */
.admin-main {
  margin-left: var(--admin-sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.2s ease;
}
.admin-sidebar.collapsed + .admin-main { margin-left: 60px; }

/* Topbar */
.admin-topbar {
  background: var(--admin-surface);
  border-bottom: 1px solid var(--admin-border);
  padding: 0 28px;
  height: var(--admin-topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-collapse-btn {
  background: none; border: none;
  color: var(--admin-muted); cursor: pointer;
  font-size: 18px; padding: 4px;
  border-radius: 4px;
  display: flex; align-items: center;
}
.topbar-collapse-btn:hover { background: var(--admin-surface-2); color: var(--admin-text); }
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--admin-muted);
}
.breadcrumb-sep { opacity: 0.4; }
.breadcrumb-current { color: var(--admin-text); font-weight: 600; }
.topbar-right {
  display: flex; align-items: center; gap: 12px;
}
.topbar-btn {
  background: none; border: 1px solid var(--admin-border);
  color: var(--admin-muted); cursor: pointer;
  font-size: 12px; padding: 6px 12px;
  border-radius: var(--admin-radius-sm);
  display: flex; align-items: center; gap: 6px;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.topbar-btn:hover { border-color: var(--admin-accent); color: var(--admin-accent); }

/* ── Search trigger button (topbar) ──────────────────────────────────────────── */
.search-trigger-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--admin-surface-2);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-sm);
  color: var(--admin-muted);
  font-size: 12px; font-family: inherit;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.search-trigger-btn:hover {
  border-color: var(--admin-accent);
  color: var(--admin-accent);
  background: var(--admin-surface);
}
.search-trigger-btn kbd {
  background: var(--admin-bg);
  border: 1px solid var(--admin-border-2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
}
.topbar-time {
  font-size: 12px; color: var(--admin-muted);
  font-variant-numeric: tabular-nums;
}

/* Page content */
.admin-content {
  padding: 28px;
  flex: 1;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}
.page-header-left {}
.page-title { font-size: 20px; font-weight: 800; color: #fff; line-height: 1.2; }
.page-subtitle { font-size: 13px; color: var(--admin-muted); margin-top: 4px; }
.page-header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── KPI Cards ─────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
}
.kpi-card:hover { border-color: var(--admin-accent); transform: translateY(-1px); }
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: var(--accent-color, var(--admin-accent-dim));
  border-radius: 50%;
  transform: translate(30%, -30%);
  opacity: 0.15;
  pointer-events: none;
}
.kpi-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--admin-muted);
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 30px; font-weight: 800; color: #fff;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-delta {
  font-size: 11px; font-weight: 600; margin-top: 6px;
  display: inline-flex; align-items: center; gap: 3px;
}
.kpi-delta-up   { color: var(--admin-success); }
.kpi-delta-down { color: var(--admin-danger); }
.kpi-card .kpi-accent { color: var(--accent-color, var(--admin-accent)); }

/* ── Cards & Panels ────────────────────────────────────────────────────────── */
.card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--admin-border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--admin-surface-2);
}
.card-title {
  font-size: 13px; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: 8px;
}
.card-title-icon { font-size: 15px; }
.card-actions { display: flex; align-items: center; gap: 8px; }
.card-body { padding: 0; }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.admin-table-wrap {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--admin-border) transparent;
}
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table thead th {
  font-size: 11px; font-weight: 700; color: var(--admin-muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: 10px 16px; text-align: left;
  background: var(--admin-surface-2);
  border-bottom: 1px solid var(--admin-border);
  white-space: nowrap;
  position: sticky; top: 0;
  cursor: pointer;
  user-select: none;
}
.admin-table thead th:hover { color: var(--admin-accent); }
.admin-table thead th .sort-icon { margin-left: 4px; opacity: 0.4; font-size: 10px; }
.admin-table thead th.sort-asc  .sort-icon { opacity: 1; color: var(--admin-accent); }
.admin-table thead th.sort-desc .sort-icon { opacity: 1; color: var(--admin-accent); }
.admin-table tbody tr {
  border-bottom: 1px solid var(--admin-border-2);
  transition: background 0.1s;
}
.admin-table tbody tr:last-child { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--admin-surface-2); }
.admin-table tbody td {
  font-size: 13px; color: var(--admin-text);
  padding: 11px 16px; vertical-align: middle;
}
.td-name { font-weight: 600; color: #fff; }
.td-mono  { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--admin-muted); }
.td-email { color: var(--admin-accent); font-size: 12px; }
.td-meta  { font-size: 11px; color: var(--admin-muted); }
.td-actions { display: flex; align-items: center; gap: 6px; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px;
  border-radius: 99px; display: inline-flex; align-items: center;
  gap: 4px; line-height: 1.4; letter-spacing: 0.2px;
  white-space: nowrap;
}
.badge-blue   { color: #38bdf8; background: #38bdf822; }
.badge-green  { color: #22d3a0; background: #22d3a022; }
.badge-yellow { color: #f59e0b; background: #f59e0b22; }
.badge-red    { color: #f43f5e; background: #f43f5e22; }
.badge-purple { color: #a855f7; background: #a855f722; }
.badge-gray   { color: var(--admin-muted); background: var(--admin-border); }
.badge-active   .badge-dot, .badge-green .badge-dot { background: var(--admin-success); }
.badge-pending  .badge-dot, .badge-yellow .badge-dot { background: var(--admin-warning); }
.badge-inactive .badge-dot, .badge-red .badge-dot    { background: var(--admin-danger); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  padding: 7px 16px; border-radius: var(--admin-radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; white-space: nowrap;
  transition: all 0.15s;
  line-height: 1.4;
}
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-lg { padding: 10px 22px; font-size: 14px; }
.btn-primary {
  background: var(--admin-accent); color: #000; border-color: var(--admin-accent);
  font-weight: 700;
}
.btn-primary:hover { background: #00e5ff; border-color: #00e5ff; }
.btn-secondary {
  background: var(--admin-surface-2); color: var(--admin-text);
  border-color: var(--admin-border);
}
.btn-secondary:hover { border-color: var(--admin-accent); color: var(--admin-accent); }
.btn-danger {
  background: var(--admin-danger-dim); color: var(--admin-danger);
  border-color: var(--admin-danger);
}
.btn-danger:hover { background: var(--admin-danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--admin-muted); border-color: var(--admin-border); }
.btn-ghost:hover { border-color: var(--admin-accent); color: var(--admin-accent); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn-loading { opacity: 0.7; cursor: wait; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--admin-muted); margin-bottom: 6px;
  letter-spacing: 0.2px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--admin-bg);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-sm);
  padding: 8px 12px;
  color: var(--admin-text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--admin-accent);
  box-shadow: 0 0 0 3px var(--admin-accent-dim);
}
.form-input::placeholder { color: var(--admin-muted-2); }
.form-select { cursor: pointer; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--admin-muted); margin-top: 4px; }
.form-error-msg { font-size: 12px; color: var(--admin-danger); margin-top: 4px; }

/* ── Search bar ──────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center;
}
.search-input-wrap {
  position: relative; flex: 1; min-width: 200px;
}
.search-input-wrap .form-input { padding-left: 36px; }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--admin-muted); font-size: 14px; pointer-events: none;
}
.search-bar .form-select { min-width: 140px; }

/* ── Filters & Pagination ────────────────────────────────────────────────────── */
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--admin-border);
  flex-wrap: wrap; gap: 10px;
}
.toolbar-left { display: flex; align-items: center; gap: 8px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.pagination {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--admin-muted);
}
.pagination a, .pagination span {
  padding: 5px 10px; border-radius: var(--admin-radius-sm);
  text-decoration: none; display: inline-flex; align-items: center;
}
.pagination a { color: var(--admin-muted); border: 1px solid var(--admin-border); }
.pagination a:hover { border-color: var(--admin-accent); color: var(--admin-accent); }
.pagination .current { background: var(--admin-accent); color: #000; font-weight: 700; border: 1px solid var(--admin-accent); }

/* ── Modals ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(7,11,18,0.8);
  backdrop-filter: blur(4px);
  z-index: 200; display: flex;
  align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border-2);
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-shadow);
  width: 100%; max-width: 520px;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-lg { max-width: 760px; }
.modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--admin-border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; color: #fff; }
.modal-close {
  background: none; border: none; color: var(--admin-muted);
  font-size: 20px; cursor: pointer; padding: 2px; line-height: 1;
}
.modal-close:hover { color: var(--admin-text); }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--admin-border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── Toasts ──────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 300; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--admin-surface-2);
  border: 1px solid var(--admin-border-2);
  border-radius: var(--admin-radius);
  padding: 12px 16px;
  display: flex; align-items: flex-start; gap: 10px;
  box-shadow: var(--admin-shadow);
  min-width: 280px; max-width: 400px;
  animation: slideIn 0.2s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-success { border-left: 3px solid var(--admin-success); }
.toast-error   { border-left: 3px solid var(--admin-danger); }
.toast-info    { border-left: 3px solid var(--admin-accent); }
.toast-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-msg  { font-size: 13px; color: var(--admin-text); flex: 1; }
.toast-msg strong { display: block; margin-bottom: 2px; }
.toast-close { background: none; border: none; color: var(--admin-muted); cursor: pointer; font-size: 16px; padding: 0; }

/* ── Alerts ──────────────────────────────────────────────────────────────────── */
.alert {
  padding: 11px 14px; border-radius: var(--admin-radius-sm);
  font-size: 13px; margin-bottom: 16px;
  border: 1px solid transparent;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: var(--admin-success-dim); border-color: var(--admin-success); color: var(--admin-success); }
.alert-error   { background: var(--admin-danger-dim);  border-color: var(--admin-danger);  color: var(--admin-danger); }
.alert-warning { background: var(--admin-warning-dim); border-color: var(--admin-warning); color: var(--admin-warning); }
.alert-info    { background: var(--admin-accent-dim);  border-color: var(--admin-accent);  color: var(--admin-accent); }
.alert-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }

/* ── Empty States ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty-icon { font-size: 40px; margin-bottom: 8px; opacity: 0.3; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--admin-muted); }
.empty-desc  { font-size: 13px; color: var(--admin-muted-2); }

/* ── Charts placeholder ─────────────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  height: 200px;
  display: flex; align-items: center; justify-content: center;
}
.chart-placeholder {
  text-align: center; color: var(--admin-muted-2); font-size: 13px;
}
.sparkline-bar {
  display: flex; align-items: flex-end; gap: 3px;
  height: 40px; justify-content: flex-end;
}
.sparkline-bar span {
  width: 6px; border-radius: 2px;
  background: var(--admin-accent-dim);
  transition: background 0.15s;
}
.sparkline-bar span:hover { background: var(--admin-accent); }

/* ── Quick action grid ───────────────────────────────────────────────────────── */
.qa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  padding: 16px;
}
.qa-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--admin-bg);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-sm);
  text-decoration: none; color: var(--admin-text);
  font-size: 13px; font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.qa-item:hover {
  border-color: var(--admin-accent);
  background: var(--admin-accent-dim);
  color: var(--admin-accent);
}
.qa-icon { font-size: 20px; }

/* ── Divider ─────────────────────────────────────────────────────────────────── */
.divider {
  border: none; border-top: 1px solid var(--admin-border);
  margin: 20px 0;
}

/* ── Inline stat row ────────────────────────────────────────────────────────── */
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--admin-border);
  font-size: 13px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row-lbl { color: var(--admin-muted); }
.stat-row-val { font-weight: 600; color: var(--admin-text); }

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--admin-border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 10px 16px;
  background: none; border: none;
  color: var(--admin-muted); font-size: 13px; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  text-decoration: none;
}
.tab-btn:hover { color: var(--admin-text); }
.tab-btn.active { color: var(--admin-accent); border-bottom-color: var(--admin-accent); }

/* ── Progress bar ────────────────────────────────────────────────────────────── */
.progress-bar {
  width: 100%; height: 6px;
  background: var(--admin-border);
  border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--admin-accent), var(--admin-accent-2));
  transition: width 0.4s ease;
}

/* ── Chip/tag ────────────────────────────────────────────────────────────────── */
.chip {
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 4px;
  background: var(--admin-border); color: var(--admin-muted);
  display: inline-flex; align-items: center; gap: 4px;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--admin-border); border-radius: 99px; }

/* ── ds-* Shared Component Aliases (for use alongside admin-* classes) ────────── */

/* Shell */
.admin-shell  { display: flex; min-height: 100vh; } /* keep existing */
.admin-sidebar { /* existing sidebar — already ds-sidebar compatible */ }

/* Cards */
.ds-card        { background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: var(--ds-radius-lg); box-shadow: var(--ds-shadow-sm); }
.ds-card-padded  { padding: 20px; }
.ds-card-header  { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.ds-card-title   { font-size: 1rem; font-weight: 700; color: var(--ds-text); }
.ds-card-grid    { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.ds-card:hover   { box-shadow: var(--ds-shadow-md); }

/* Metric card */
.ds-metric-card  { background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: var(--ds-radius-lg); padding: 20px 24px; box-shadow: var(--ds-shadow-sm); display: flex; flex-direction: column; gap: 6px; }
.ds-metric-val    { font-size: 2rem; font-weight: 800; color: var(--ds-text); line-height: 1; }
.ds-metric-label  { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ds-text-muted); margin-top: 2px; }
.ds-metrics-grid  { display: grid; gap: 16px; margin-bottom: 28px; }
.ds-metrics-grid--2 { grid-template-columns: repeat(2, 1fr); }
.ds-metrics-grid--3 { grid-template-columns: repeat(3, 1fr); }
.ds-metrics-grid--4 { grid-template-columns: repeat(4, 1fr); }
.ds-metrics-grid--5 { grid-template-columns: repeat(5, 1fr); }
.ds-metric-delta--up   { color: var(--ds-success); }
.ds-metric-delta--down { color: var(--ds-danger); }

/* Buttons */
.ds-btn { font-family: var(--ds-font); font-size: 0.875rem; font-weight: 600; border: none; border-radius: var(--ds-radius-sm); padding: 9px 18px; cursor: pointer; text-align: center; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: background 0.15s, box-shadow 0.15s; white-space: nowrap; line-height: 1.4; }
.ds-btn:hover { text-decoration: none; }
.ds-btn-primary   { background: var(--ds-primary); color: #fff; }
.ds-btn-primary:hover { background: var(--ds-primary-hover); color: #fff; }
.ds-btn-secondary { color: var(--ds-primary); background: var(--ds-primary-light); border: 1.5px solid rgba(37,99,235,0.2); }
.ds-btn-secondary:hover { background: #dbeafe; }
.ds-btn-ghost     { color: var(--ds-text-muted); background: none; border: 1.5px solid var(--ds-border); }
.ds-btn-ghost:hover { background: var(--ds-surface-2); color: var(--ds-text); }
.ds-btn-danger    { color: var(--ds-danger); background: var(--ds-danger-light); border: 1.5px solid rgba(239,68,68,0.2); }
.ds-btn-danger:hover { background: #fee2e2; }
.ds-btn-success   { color: var(--ds-success); background: var(--ds-success-light); border: 1.5px solid rgba(34,197,94,0.2); }
.ds-btn-success:hover { background: #dcfce7; }
.ds-btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.ds-btn-lg { padding: 12px 28px; font-size: 1rem; }
.ds-btn-logout { font-family: var(--ds-font); font-size: 0.82rem; font-weight: 500; color: var(--ds-text-muted); background: none; border: 1.5px solid var(--ds-border); border-radius: var(--ds-radius-sm); padding: 5px 12px; cursor: pointer; transition: background 0.15s; }
.ds-btn-logout:hover { background: var(--ds-surface-2); }

/* Table */
.ds-table-wrap  { background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: var(--ds-radius-lg); overflow: hidden; box-shadow: var(--ds-shadow-sm); }
.ds-table        { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.ds-table thead tr { background: var(--ds-surface-2); border-bottom: 1px solid var(--ds-border); }
.ds-table th     { padding: 11px 16px; text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ds-text-muted); white-space: nowrap; }
.ds-table td     { padding: 13px 16px; border-bottom: 1px solid var(--ds-border-light); vertical-align: middle; color: var(--ds-text); }
.ds-table tbody tr:last-child td { border-bottom: none; }
.ds-table tbody tr { transition: background 0.1s; }
.ds-table tbody tr:hover td { background: var(--ds-surface-2); }

/* Badges */
.ds-badge        { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; vertical-align: middle; }
.ds-badge-primary  { background: var(--ds-primary-light); color: var(--ds-primary); }
.ds-badge-success  { background: var(--ds-success-light); color: #15803d; }
.ds-badge-warning   { background: var(--ds-warning-light); color: #92400e; }
.ds-badge-danger    { background: var(--ds-danger-light);  color: #b91c1c; }
.ds-badge-info      { background: var(--ds-info-light);    color: #075985; }
.ds-badge-neutral   { background: var(--ds-surface-2); color: var(--ds-text-muted); }
.ds-badge-role      { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 7px; border-radius: 4px; }
.ds-code-badge      { font-family: 'Courier New', monospace; font-size: 0.78rem; font-weight: 700; color: var(--ds-primary); background: var(--ds-primary-light); border: 1px solid rgba(37,99,235,0.2); border-radius: 6px; padding: 3px 10px; letter-spacing: 0.05em; white-space: nowrap; }

/* Alerts */
.ds-alert       { padding: 12px 16px; border-radius: var(--ds-radius-sm); font-size: 0.875rem; font-weight: 500; margin-bottom: 20px; border: 1px solid transparent; }
.ds-alert-success { background: var(--ds-success-light); color: #15803d; border-color: #bbf7d0; }
.ds-alert-warning  { background: var(--ds-warning-light); color: #92400e; border-color: #fde68a; }
.ds-alert-danger   { background: var(--ds-danger-light);  color: #b91c1c; border-color: #fca5a5; }
.ds-alert-info      { background: var(--ds-info-light);    color: #075985; border-color: #93c5fd; }

/* Forms */
.ds-field       { display: flex; flex-direction: column; gap: 6px; }
.ds-field label { font-size: 0.83rem; font-weight: 600; color: var(--ds-text-muted); }
.ds-field input, .ds-field select, .ds-field textarea { font-family: var(--ds-font); font-size: 0.95rem; padding: 10px 14px; border: 1.5px solid var(--ds-border); border-radius: var(--ds-radius-sm); outline: none; transition: border-color 0.15s, box-shadow 0.15s; color: var(--ds-text); background: var(--ds-surface); }
.ds-field input:focus, .ds-field select:focus, .ds-field textarea:focus { border-color: var(--ds-primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.ds-form        { display: flex; flex-direction: column; gap: 16px; }

/* Empty state */
.ds-empty-state { text-align: center; padding: 60px 24px; background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: var(--ds-radius-lg); }
.ds-empty-icon  { font-size: 3rem; margin-bottom: 16px; }
.ds-empty-state h2 { font-size: 1.1rem; font-weight: 700; color: var(--ds-text); margin-bottom: 8px; }
.ds-empty-state p  { color: var(--ds-text-muted); font-size: 0.9rem; margin-bottom: 24px; max-width: 400px; margin-left: auto; margin-right: auto; line-height: 1.6; }

/* Callout */
.ds-callout { display: flex; align-items: flex-start; gap: 14px; padding: 16px 20px; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md); margin-bottom: 20px; font-size: 0.875rem; }
.ds-callout-icon { font-size: 24px; line-height: 1; flex-shrink: 0; }
.ds-callout-body { flex: 1; color: var(--ds-text); line-height: 1.6; }
.ds-callout-body strong { color: var(--ds-text); }

/* Modal */
.ds-modal { border: none; border-radius: var(--ds-radius-lg); padding: 0; max-width: 480px; width: 100%; box-shadow: var(--ds-shadow-lg); }
.ds-modal::backdrop { background: rgba(15,23,42,0.5); backdrop-filter: blur(4px); }
.ds-modal-inner { padding: 32px; }
.ds-modal-title { font-size: 1.15rem; font-weight: 700; color: var(--ds-text); margin-bottom: 6px; }
.ds-modal-sub { font-size: 0.875rem; color: var(--ds-text-muted); margin-bottom: 24px; line-height: 1.5; }
.ds-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* Progress */
.ds-progress-row  { display: flex; align-items: center; gap: 12px; }
.ds-progress-track { flex: 1; height: 10px; background: var(--ds-border); border-radius: 5px; overflow: hidden; }
.ds-progress-fill  { height: 100%; border-radius: 5px; background: var(--ds-primary); transition: width 0.4s ease; }
.ds-progress-pct   { font-size: 0.82rem; font-weight: 600; color: var(--ds-text-muted); width: 40px; text-align: right; flex-shrink: 0; }

/* Activity feed */
.ds-activity-feed  { display: flex; flex-direction: column; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md); overflow: hidden; background: var(--ds-surface); }
.ds-activity-item  { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--ds-border-light); }
.ds-activity-item:last-child { border-bottom: none; }
.ds-activity-avatar { font-size: 1.4rem; line-height: 1; flex-shrink: 0; margin-top: 2px; }
.ds-activity-body  { flex: 1; font-size: 0.84rem; color: var(--ds-text-muted); line-height: 1.4; }
.ds-activity-name  { font-weight: 600; color: var(--ds-text); }
.ds-activity-mission { font-weight: 500; color: var(--ds-primary); }
.ds-activity-class  { color: var(--ds-text-dim); font-size: 0.8rem; }
.ds-activity-score  { font-size: 0.8rem; color: var(--ds-success); margin-top: 2px; }
.ds-activity-time  { font-size: 0.75rem; color: var(--ds-text-dim); white-space: nowrap; flex-shrink: 0; margin-top: 2px; }

/* Pagination */
.ds-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 24px; }
.ds-page-info  { color: var(--ds-text-muted); font-size: 13px; }

/* Loading */
.ds-spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--ds-border); border-top-color: var(--ds-primary); border-radius: 50%; animation: ds-spin 0.7s linear infinite; }
@keyframes ds-spin { to { transform: rotate(360deg); } }
.ds-loading-text { font-size: 13px; color: var(--ds-text-dim); padding: 16px 0; }
.ds-skeleton { background: linear-gradient(90deg, var(--ds-surface-2) 25%, var(--ds-border-light) 50%, var(--ds-surface-2) 75%); background-size: 200% 100%; animation: ds-shimmer 1.4s ease infinite; border-radius: var(--ds-radius-sm); }
@keyframes ds-shimmer { to { background-position: -200% 0; } }
.ds-skeleton-line { height: 14px; margin-bottom: 8px; }
.ds-skeleton-block { height: 80px; margin-bottom: 12px; }

/* Page structure */
.ds-page-header  { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.ds-page-title   { font-size: 1.6rem; font-weight: 700; color: var(--ds-text); margin-bottom: 4px; }
.ds-page-sub     { font-size: 0.875rem; color: var(--ds-text-muted); }
.ds-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ds-breadcrumb-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ds-text-muted); margin-bottom: 20px; }
.ds-breadcrumb-row a { color: var(--ds-primary); }
.ds-breadcrumb-row a:hover { text-decoration: underline; }
.ds-main-content { flex: 1; padding: 28px; }
.ds-container     { max-width: 1200px; }

/* Topbar */
.ds-topbar { height: var(--ds-nav-h, 58px); background: var(--ds-surface); border-bottom: 1px solid var(--ds-border); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 50; }
.ds-topbar-left  { display: flex; align-items: center; gap: 12px; flex: 1; }
.ds-topbar-collapse-btn { background: none; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-sm); padding: 6px 8px; cursor: pointer; font-size: 16px; color: var(--ds-text-muted); transition: background 0.12s; }
.ds-topbar-collapse-btn:hover { background: var(--ds-surface-2); }
.ds-breadcrumb  { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ds-text-muted); }
.ds-breadcrumb a { color: var(--ds-text-muted); }
.ds-breadcrumb a:hover { color: var(--ds-primary); text-decoration: none; }
.ds-breadcrumb-sep { color: var(--ds-border); }
.ds-breadcrumb-current { color: var(--ds-text); font-weight: 600; }
.ds-topbar-right { display: flex; align-items: center; gap: 10px; }
.ds-topbar-time  { font-size: 12px; color: var(--ds-text-dim); font-variant-numeric: tabular-nums; }

/* Sidebar */
.ds-sidebar    { position: fixed; top: 0; left: 0; height: 100vh; width: var(--ds-sidebar-w, 240px); background: var(--ds-surface); border-right: 1px solid var(--ds-border); display: flex; flex-direction: column; z-index: 200; transition: width 0.2s ease; overflow: hidden; }
.ds-sidebar.collapsed { width: 60px; }
.ds-sidebar-logo { padding: 20px 16px 18px; border-bottom: 1px solid var(--ds-border); display: flex; align-items: center; gap: 10px; min-height: 64px; flex-shrink: 0; }
.ds-sidebar-logo-icon { font-size: 22px; line-height: 1; flex-shrink: 0; }
.ds-sidebar-logo-text { font-weight: 700; font-size: 15px; color: var(--ds-text); white-space: nowrap; }
.ds-sidebar-logo-sub  { font-size: 11px; color: var(--ds-text-muted); white-space: nowrap; }
.ds-sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.ds-nav-section-label { padding: 8px 16px 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ds-text-dim); white-space: nowrap; }
.ds-nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; font-size: 13px; font-weight: 500; color: var(--ds-text-muted); text-decoration: none; border-radius: 0; transition: background 0.12s, color 0.12s; white-space: nowrap; cursor: pointer; border: none; background: none; width: 100%; text-align: left; }
.ds-nav-item:hover { background: var(--ds-surface-2); color: var(--ds-text); text-decoration: none; }
.ds-nav-item.active { background: var(--ds-primary-light); color: var(--ds-primary); }
.ds-nav-icon { font-size: 16px; line-height: 1; flex-shrink: 0; width: 20px; text-align: center; }
.ds-nav-label { flex: 1; }
.ds-nav-badge { font-size: 10px; font-weight: 700; background: var(--ds-danger); color: #fff; padding: 1px 5px; border-radius: 10px; flex-shrink: 0; }
.ds-sidebar-footer { padding: 16px; border-top: 1px solid var(--ds-border); flex-shrink: 0; }
.ds-shell { display: flex; min-height: 100vh; }
.ds-shell--sidebar { flex-direction: row; }
.ds-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ds-shell--sidebar .ds-main { margin-left: var(--ds-sidebar-w, 240px); transition: margin-left 0.2s ease; }

/* ── Utility ──────────────────────────────────────────────────────────────────── */
.text-accent  { color: var(--admin-accent); }
.text-success { color: var(--admin-success); }
.text-danger  { color: var(--admin-danger); }
.text-warning { color: var(--admin-warning); }
.text-muted   { color: var(--admin-muted); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.font-mono    { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.mt-4         { margin-top: 16px; }
.mb-4         { margin-bottom: 16px; }

/* ── Responsive ───────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-sidebar { width: 0; overflow: hidden; border-right: none; }
  .admin-sidebar.open { width: var(--admin-sidebar-w); border-right: 1px solid var(--admin-border); }
  .admin-main { margin-left: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-content { padding: 16px; }
  .page-header { flex-direction: column; }
  .table-toolbar { flex-direction: column; align-items: flex-start; }
  .modal { max-width: 100%; margin: 10px; }
}