/* ═══════════════════════════════════════════════════════════════════════════
   admin.css — SolveMCQ Admin Panel Styles
   Dark professional theme. No dependency on main.css.
   ════════════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-deep:      #0d1117;
  --bg-surface:   #161b22;
  --bg-elevated:  #21262d;
  --bg-hover:     #30363d55;

  /* Accent colors */
  --accent:       #2ea043;
  --accent-hover: #3fb950;
  --accent-blue:  #388bfd;
  --accent-red:   #f85149;
  --accent-amber: #d29922;
  --accent-purple:#a371f7;
  --accent-teal:  #39d353;

  /* Text */
  --text-primary: #e6edf3;
  --text-muted:   #8b949e;
  --text-faint:   #484f58;

  /* Borders */
  --border:       #30363d;
  --border-subtle:#21262d;

  /* Layout */
  --header-h:     60px;
  --sidebar-w:    240px;
  --sidebar-w-collapsed: 64px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.4);
  --shadow-md:  0 4px 12px rgba(0,0,0,.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.6);

  /* Radius */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;

  /* Transitions */
  --trans-fast: 150ms ease;
  --trans-mid:  250ms ease;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; font-size: 0.875rem; }
input, select, textarea {
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(56,139,253,.2);
}
ul { list-style: none; }
svg { flex-shrink: 0; }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.75rem; }
.text-green { color: var(--accent); }
.text-red { color: var(--accent-red); }
.text-amber { color: var(--accent-amber); }
.spacer { flex: 1; }
.center-content { display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-weight: 500; border: 1px solid transparent;
  transition: background var(--trans-fast), opacity var(--trans-fast);
  white-space: nowrap;
}
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger {
  background: var(--accent-red); color: #fff; border-color: var(--accent-red);
}
.btn-danger:hover { opacity: .85; }
.btn-ghost {
  background: transparent; color: var(--text-primary); border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; padding: 10px 14px; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form-group label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.form-group input, .form-group textarea, .form-group select {
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--bg-elevated); border: 1px solid var(--border);
}
.input-full { width: 100%; padding: 8px 12px; border-radius: var(--radius-sm); }
.input-sm { padding: 5px 10px; font-size: 0.8rem; border-radius: var(--radius-sm); }
.input-reveal { position: relative; display: flex; }
.input-reveal input { flex: 1; padding-right: 40px; }
.reveal-btn {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 38px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--text-muted);
}
.reveal-btn:hover { color: var(--text-primary); }
.select-sm {
  padding: 4px 8px; font-size: 0.8rem; border-radius: var(--radius-sm);
  background: var(--bg-elevated); border-color: var(--border); color: var(--text-primary);
}

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Badge ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
.badge-superadmin { background: rgba(163,113,247,.2); color: var(--accent-purple); }
.nav-badge { font-size: 0.65rem; padding: 1px 5px; border-radius: 10px; }
.superadmin-badge { background: rgba(163,113,247,.25); color: var(--accent-purple); }

/* ══════════════════════════════════════════════════════════════════════════
   LOGIN SCREEN
═══════════════════════════════════════════════════════════════════════ */
.login-screen {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg-deep);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(46,160,67,.08) 0%, transparent 60%);
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  width: 360px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
}
.login-title { font-size: 1.3rem; font-weight: 600; }
.login-error {
  background: rgba(248,81,73,.12);
  border: 1px solid rgba(248,81,73,.4);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--accent-red);
  font-size: 0.85rem;
  margin-bottom: 14px;
}
.login-lockout {
  background: rgba(210,153,34,.12);
  border: 1px solid rgba(210,153,34,.4);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--accent-amber);
  font-size: 0.85rem;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.login-version {
  text-align: center; font-size: 0.75rem;
  color: var(--text-faint); margin-top: 18px;
}

/* Login card shake animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.login-card.shake { animation: shake 0.4s ease; }

/* ══════════════════════════════════════════════════════════════════════════
   PANEL LAYOUT
═══════════════════════════════════════════════════════════════════════ */
.admin-panel {
  display: grid;
  grid-template-areas:
    "header header"
    "sidebar main";
  grid-template-rows: var(--header-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--trans-mid);
}
.admin-panel.sidebar-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.admin-header {
  grid-area: header;
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px 0 0;
  gap: 0;
}
.header-left {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
}
.sidebar-toggle {
  width: var(--sidebar-w-collapsed); height: var(--header-h);
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--text-muted);
  flex-shrink: 0;
  transition: color var(--trans-fast);
}
.sidebar-toggle:hover { color: var(--text-primary); }
.header-logo {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; white-space: nowrap;
}
.header-logo-text { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); }
.logo-sub { color: var(--text-muted); font-weight: 400; }
.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.85rem; margin-left: 8px; }
.breadcrumb-item.active { color: var(--text-primary); }
.header-right {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.session-warning {
  display: flex; align-items: center; gap: 6px;
  background: rgba(210,153,34,.15); border: 1px solid rgba(210,153,34,.4);
  color: var(--accent-amber); border-radius: var(--radius-sm);
  padding: 4px 10px; font-size: 0.8rem;
}
.admin-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.header-admin { display: flex; align-items: center; gap: 10px; }
.admin-info { display: flex; flex-direction: column; line-height: 1.2; }
.admin-name { font-weight: 500; font-size: 0.875rem; }
.admin-role { font-size: 0.75rem; color: var(--text-muted); }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.admin-sidebar {
  grid-area: sidebar;
  position: fixed;
  top: var(--header-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  transition: width var(--trans-mid), transform var(--trans-mid);
  z-index: 90;
}
.admin-sidebar::-webkit-scrollbar { width: 3px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Collapsed state */
.admin-panel.sidebar-collapsed .admin-sidebar { width: var(--sidebar-w-collapsed); }
.admin-panel.sidebar-collapsed .nav-label,
.admin-panel.sidebar-collapsed .nav-badge,
.admin-panel.sidebar-collapsed .sidebar-version { display: none; }

.sidebar-overlay { display: none; }
.sidebar-nav {
  padding: 12px 0; flex: 1;
}
.nav-divider {
  height: 1px; background: var(--border);
  margin: 8px 12px;
}
.nav-item { position: relative; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 16px;
  color: var(--text-muted);
  border-radius: 0;
  transition: color var(--trans-fast), background var(--trans-fast);
  white-space: nowrap; overflow: hidden;
  position: relative;
  text-decoration: none;
}
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.nav-link.active {
  color: var(--text-primary);
  background: rgba(46,160,67,.12);
}
.nav-link.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.nav-icon { flex-shrink: 0; width: 18px; height: 18px; }
.nav-label { font-size: 0.875rem; font-weight: 500; }
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid var(--border-subtle);
}
.sidebar-version { font-size: 0.7rem; color: var(--text-faint); }

/* Collapsed sidebar — center icons & tooltip */
.admin-panel.sidebar-collapsed .nav-link { padding: 9px; justify-content: center; }
.admin-panel.sidebar-collapsed .nav-icon { width: 22px; height: 22px; }
.admin-panel.sidebar-collapsed .nav-item:hover .nav-link::after {
  content: attr(data-tooltip);
  position: absolute; left: calc(var(--sidebar-w-collapsed) + 6px);
  top: 50%; transform: translateY(-50%);
  background: var(--bg-elevated); color: var(--text-primary);
  padding: 4px 10px; border-radius: var(--radius-sm);
  font-size: 0.8rem; white-space: nowrap; border: 1px solid var(--border);
  z-index: 200; pointer-events: none;
}

/* ── Main content ──────────────────────────────────────────────────────────── */
.admin-main {
  grid-area: main;
  margin-top: var(--header-h);
  padding: 24px;
  overflow-y: auto; min-height: calc(100vh - var(--header-h));
  background: var(--bg-deep);
}

/* ── Sections ──────────────────────────────────────────────────────────────── */
.admin-section { display: none; }
.admin-section.active { display: block; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.section-title { font-size: 1.25rem; font-weight: 600; }
.section-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 0.9rem; font-weight: 600; }
.card-body { padding: 16px; }

/* ── Stat Cards ────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px;
  display: flex; align-items: center; gap: 14px;
  transition: border-color var(--trans-fast);
}
.stat-card--clickable { cursor: pointer; }
.stat-card--clickable:hover { border-color: var(--accent-blue); }
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon--blue   { background: rgba(56,139,253,.15); color: var(--accent-blue); }
.stat-icon--green  { background: rgba(46,160,67,.15);  color: var(--accent); }
.stat-icon--amber  { background: rgba(210,153,34,.15); color: var(--accent-amber); }
.stat-icon--red    { background: rgba(248,81,73,.15);  color: var(--accent-red); }
.stat-icon--purple { background: rgba(163,113,247,.15);color: var(--accent-purple); }
.stat-icon--teal   { background: rgba(57,211,83,.15);  color: var(--accent-teal); }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ── Chart Grid ────────────────────────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px; margin-bottom: 20px;
}
.chart-card .card-body { position: relative; }

/* ── Geo Map ───────────────────────────────────────────────────────────────── */
.geo-card { margin-bottom: 20px; }
.geo-map-container { position: relative; min-height: 360px; }
.map-layer { width: 100%; }
.map-layer.hidden { display: none; }
.map-layer svg { width: 100%; height: auto; display: block; }
.map-tooltip {
  position: absolute; pointer-events: none;
  background: var(--bg-elevated); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 0.8rem; color: var(--text-primary); white-space: nowrap;
  z-index: 50; box-shadow: var(--shadow-md); line-height: 1.6;
}
.geo-legend {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 8px 4px 2px; font-size: 11px; color: var(--text-muted);
}
.geo-legend-label { margin-right: 4px; font-weight: 600; color: var(--text-secondary); }
.geo-legend-swatch { display: inline-block; width: 22px; height: 10px; border-radius: 2px; }
.geo-legend-item { margin-right: 2px; }
.tab-pills {
  display: flex; gap: 4px;
}
.tab-pill {
  padding: 4px 12px; border-radius: 20px; font-size: 0.8rem;
  border: 1px solid var(--border); background: transparent; color: var(--text-muted);
  transition: all var(--trans-fast);
}
.tab-pill.active, .tab-pill:hover {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ── Server Status Grid ────────────────────────────────────────────────────── */
.server-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 14px; margin-bottom: 20px;
}
.gauge-value { font-size: 1.4rem; font-weight: 700; margin-top: 4px; }
.status-list { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.status-item { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--text-faint);
}
.status-dot--green { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.status-dot--red   { background: var(--accent-red); }
.status-dot--amber { background: var(--accent-amber); }
.status-label { color: var(--text-muted); flex: 1; }
.status-val { color: var(--text-primary); font-weight: 500; }

/* ── Quick Actions ─────────────────────────────────────────────────────────── */
.quick-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.quick-action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 20px; min-width: 110px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-muted);
  font-size: 0.8rem; font-weight: 500;
  transition: all var(--trans-fast); text-align: center;
}
.quick-action-btn:hover {
  border-color: var(--accent-blue); color: var(--text-primary);
  background: rgba(56,139,253,.07);
}
.quick-action-btn svg { color: var(--accent-blue); }

/* ── Search Box ────────────────────────────────────────────────────────────── */
.search-box {
  position: relative; display: flex; align-items: center;
}
.search-box svg { position: absolute; left: 10px; color: var(--text-muted); pointer-events: none; }
.search-box input {
  padding: 6px 12px 6px 32px; border-radius: 20px;
  width: 260px; background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.search-box--sm input { width: 150px; padding-left: 28px; font-size: 0.8rem; }
.search-box--sm svg { width: 12px; height: 12px; }

/* ── Tabulator Overrides ───────────────────────────────────────────────────── */
.tabulator {
  border: none !important;
  background: var(--bg-surface) !important;
  font-size: 0.85rem !important;
}
.tabulator .tabulator-header {
  background: var(--bg-elevated) !important;
  border-bottom: 1px solid var(--border) !important;
}
.tabulator .tabulator-col {
  background: transparent !important;
  border-right: 1px solid var(--border-subtle) !important;
  color: var(--text-muted) !important;
  font-weight: 600 !important;
}
.tabulator .tabulator-row {
  background: var(--bg-surface) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  color: var(--text-primary) !important;
}
.tabulator .tabulator-row:hover { background: var(--bg-hover) !important; }
.tabulator .tabulator-row.tabulator-selected { background: rgba(56,139,253,.1) !important; }
.tabulator .tabulator-footer {
  background: var(--bg-elevated) !important;
  border-top: 1px solid var(--border) !important;
  color: var(--text-muted) !important;
}
.tabulator .tabulator-page {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
}
.tabulator .tabulator-page.active { background: var(--accent) !important; }

/* ── Slide Panel ───────────────────────────────────────────────────────────── */
.slide-panel {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh; max-width: 100%;
  background: #0b1628;
  border-left: none;
  z-index: 250; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform var(--trans-mid);
  box-shadow: -4px 0 40px rgba(0,0,0,0.5);
  color: #e2e8f0;
}
body.slide-panel-active { overflow: hidden; }
.slide-panel:not(.hidden) { transform: translateX(0); }
.slide-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid rgba(99,179,237,0.15);
  flex-shrink: 0;
  background: #0d1f3c;
}
.slide-panel-title { font-size: 1.1rem; font-weight: 700; color: #90cdf4; }
.slide-panel-close {
  background: transparent; border: none; color: #718096;
  padding: 4px; border-radius: var(--radius-sm);
}
.slide-panel-close:hover { color: #e2e8f0; background: rgba(255,255,255,0.08); }
.slide-panel-body { flex: 1; overflow-y: auto; padding: 20px 24px; min-height: 0; }
.slide-panel-footer {
  flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 24px; border-top: 1px solid rgba(99,179,237,0.15);
  background: #0d1f3c;
}
.slide-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 199;
}

/* ── User Panel Components ───────────────────────────────────────────────────── */
.up-profile {
  display: flex; gap: 20px; align-items: flex-start;
  background: #0d1f3c; border-radius: 12px; padding: 20px;
  border: 1px solid rgba(99,179,237,0.2); margin-bottom: 20px;
}
.up-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, #3182ce, #63b3ed);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 700; color: white; flex-shrink: 0;
}
.up-info { flex: 1; }
.up-name  { font-size: 1.25rem; font-weight: 700; color: #e2e8f0; margin-bottom: 4px; }
.up-email { color: #90cdf4; font-size: 0.9rem; margin-bottom: 2px; }
.up-meta  { color: #718096; font-size: 0.82rem; margin-bottom: 2px; }
.up-userid {
  display: inline-block; background: rgba(99,179,237,0.1);
  color: #63b3ed; padding: 2px 8px; border-radius: 4px;
  font-size: 0.78rem; margin: 4px 0;
}

.up-stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-bottom: 20px;
}
.up-stat-card {
  background: #0d1f3c; border: 1px solid rgba(99,179,237,0.15);
  border-radius: 10px; padding: 14px 16px; text-align: center;
}
.up-stat-value {
  font-size: 1.6rem; font-weight: 800; color: #63b3ed; line-height: 1;
  margin-bottom: 4px;
}
.up-stat-label { font-size: 0.75rem; color: #718096; text-transform: uppercase; letter-spacing: 0.05em; }
.up-stat-note  { font-size: 0.72rem; color: #4a5568; margin-top: 4px; }
.up-partial    { color: #f6ad55; font-size: 1rem; }

.up-details { margin-bottom: 20px; }
.up-detail-group { margin-bottom: 14px; }
.up-detail-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: #4a5568; margin-bottom: 8px; font-weight: 600;
}
.up-detail-items { display: flex; flex-wrap: wrap; gap: 6px; }
.up-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 500;
}
.up-badge--full { background: rgba(72,187,120,0.15); color: #68d391; border: 1px solid rgba(72,187,120,0.3); }
.up-badge--part { background: rgba(246,173,85,0.15); color: #f6ad55; border: 1px solid rgba(246,173,85,0.3); }

.up-section-title {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: #4a5568; margin: 20px 0 10px; font-weight: 700;
  border-top: 1px solid rgba(99,179,237,0.1); padding-top: 16px;
}
.up-sessions-list { list-style: none; padding: 0; margin: 0 0 16px; }
.up-session-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; background: #0d1f3c; border-radius: 8px; margin-bottom: 8px;
  border: 1px solid rgba(99,179,237,0.1);
}
.up-session-info { flex: 1; overflow: hidden; }
.up-session-ip   { display: block; color: #90cdf4; font-size: 0.82rem; font-family: monospace; }
.up-session-ua   { display: block; color: #4a5568; font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-session-time { display: block; color: #718096; font-size: 0.72rem; }
.up-empty { color: #4a5568; font-style: italic; font-size: 0.85rem; }

.up-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding-top: 16px; border-top: 1px solid rgba(99,179,237,0.1); margin-top: 8px;
}

/* ── Content Panel Layout ──────────────────────────────────────────────────── */
.content-panels {
  display: grid;
  grid-template-columns: 220px 240px 1fr;
  gap: 0;
  height: calc(100vh - var(--header-h) - 100px);
  border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
  background: var(--bg-surface);
}
.content-panel {
  display: flex; flex-direction: column; overflow: hidden;
  border-right: 1px solid var(--border);
}
.content-panel:last-child { border-right: none; }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  flex-shrink: 0; gap: 8px;
}
.panel-header h3 { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-list { overflow-y: auto; flex: 1; padding: 6px 0; }
.panel-placeholder { padding: 20px; color: var(--text-faint); font-size: 0.85rem; text-align: center; }
.panel-loading { padding: 20px; color: var(--text-muted); font-size: 0.85rem; }

/* Subject/topic list items */
.panel-item {
  padding: 9px 14px; cursor: pointer; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-muted); transition: all var(--trans-fast);
  border-left: 3px solid transparent;
}
.panel-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.panel-item.active { background: rgba(46,160,67,.1); color: var(--text-primary); border-left-color: var(--accent); }
.panel-item-count { font-size: 0.75rem; color: var(--text-faint); }
.panel-group-header {
  padding: 6px 14px; font-size: 0.7rem; font-weight: 600;
  color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em;
  cursor: pointer; display: flex; align-items: center; justify-content: space-between;
}
.panel-group-header:hover { color: var(--text-muted); }

/* ── Settings ──────────────────────────────────────────────────────────────── */
.settings-tabs {
  display: flex; gap: 8px; margin-bottom: 20px;
}
.settings-tab {
  padding: 8px 16px; border-radius: 20px;
  background: var(--bg-surface); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.875rem;
  transition: all var(--trans-fast);
}
.settings-tab.active, .settings-tab:hover {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.settings-pane { max-width: 700px; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); margin-bottom: 14px; gap: 16px;
}
.toggle-label { font-weight: 600; font-size: 0.9rem; }
.toggle-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* Toggle switch */
.toggle-switch {
  position: relative; width: 48px; height: 26px; flex-shrink: 0; cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; background: var(--text-faint);
  border-radius: 26px; transition: background var(--trans-fast);
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-thumb {
  position: absolute; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px;
  transition: transform var(--trans-fast);
  box-shadow: var(--shadow-sm);
}
.toggle-switch input:checked ~ .toggle-thumb { transform: translateX(22px); }
/* Fix: thumb is outside track */
.toggle-switch { display: inline-flex; align-items: center; }
.toggle-switch .toggle-track { position: relative; }
.toggle-switch .toggle-thumb { position: absolute; }

/* Flag cards */
.flags-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.flag-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.flag-card-label { font-size: 0.9rem; font-weight: 500; }
.flag-card-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ── Audit filters ─────────────────────────────────────────────────────────── */
.audit-filters { margin-bottom: 14px; }
.audit-filters .card-body { padding: 12px 16px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-row .input-sm { flex: 1; min-width: 130px; max-width: 180px; }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; max-height: 90vh;
}
.modal--sm { width: 420px; max-width: 95vw; }
.modal--md { width: 600px; max-width: 95vw; }
.modal--lg { width: 760px; max-width: 95vw; }
.modal--fullscreen {
  width: 96vw; height: 92vh; max-height: 92vh;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: transparent; border: none; color: var(--text-muted);
  padding: 4px; border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}

/* Question Editor Layout */
.question-editor { display: flex; flex-direction: column; height: 100%; padding: 16px 20px; gap: 0; overflow: hidden; }
.question-editor .form-group { margin-bottom: 10px; }
.question-editor .form-group label { font-size: 0.78rem; }
.question-editor textarea { width: 100%; resize: vertical; min-height: 56px; padding: 6px 10px; font-size: 0.85rem; line-height: 1.35; }
.options-grid { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.option-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.option-row input[type="text"] { flex: 1; padding: 7px 12px; width: 100%; }
.option-correct { display: flex; align-items: center; gap: 4px; font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.option-correct input[type="radio"] { accent-color: var(--accent); }
.preview-img { max-width: 100%; max-height: 200px; border-radius: var(--radius-sm); margin-top: 8px; }
.preview-video { width: 100%; height: 180px; border-radius: var(--radius-sm); margin-top: 8px; border: none; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 400; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: var(--radius-md);
  background: var(--bg-elevated); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 0.875rem;
  min-width: 260px; max-width: 380px;
  animation: toast-in 0.25s ease;
}
.toast.toast-out { animation: toast-out 0.25s ease forwards; }
.toast--success { border-color: rgba(46,160,67,.5); }
.toast--error   { border-color: rgba(248,81,73,.5); }
.toast--warning { border-color: rgba(210,153,34,.5); }
.toast-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.toast--success .toast-dot { background: var(--accent); }
.toast--error   .toast-dot { background: var(--accent-red); }
.toast--warning .toast-dot { background: var(--accent-amber); }
.toast--info    .toast-dot { background: var(--accent-blue); }
.toast-msg { flex: 1; }
.toast-icon { flex-shrink: 0; font-size: 0.9rem; }
.toast-close {
  flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1rem; line-height: 1;
  padding: 2px 4px; border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  opacity: 0.7;
}
.toast-close:hover { color: var(--text); background: var(--bg-hover); opacity: 1; }
/* toast-visible: the toast is shown after being appended (opacity animation via keyframe already runs on append) */
.toast { opacity: 0; transform: translateX(20px); }
.toast.toast-visible { opacity: 1; transform: translateX(0); transition: opacity 0.25s ease, transform 0.25s ease; }
.toast.toast-out { opacity: 0; transform: translateX(20px); transition: opacity 0.25s ease, transform 0.25s ease; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ── Inline user profile (slide panel) ────────────────────────────────────── */
.user-profile-card { margin-bottom: 20px; }
.user-profile-avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; color: #fff; margin-bottom: 12px;
}
.user-profile-name { font-size: 1.1rem; font-weight: 600; }
.user-profile-meta { font-size: 0.8rem; color: var(--text-muted); }
.kv-list { display: grid; gap: 8px; }
.kv-row { display: flex; gap: 8px; font-size: 0.85rem; }
.kv-key { color: var(--text-muted); min-width: 100px; flex-shrink: 0; }
.kv-val { font-weight: 500; }
.session-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border-subtle); font-size: 0.8rem;
}
.section-subtitle { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin: 16px 0 8px; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
  .chart-grid { grid-template-columns: 1fr; }
  .server-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .content-panels { grid-template-columns: 1fr; height: auto; }
  .content-panel { border-right: none; border-bottom: 1px solid var(--border); min-height: 200px; }
  .content-panel:last-child { border-bottom: none; }
}

@media (max-width: 768px) {
  .admin-panel {
    grid-template-areas: "header" "main";
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr;
  }
  .admin-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
    z-index: 300;
  }
  .admin-panel.sidebar-open .admin-sidebar { transform: translateX(0); }
  .admin-panel.sidebar-open .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 299;
    /* FIX: pointer-events:none so clicks pass through to main content buttons.
       Sidebar close on outside-tap is now handled by JS (admin-ui.js)
       listening on admin-main touchstart/click instead of this overlay. */
    pointer-events: none;
  }
  /* BUG 3 FIX: ensure modal backdrop sits above sidebar (z-index 300) and overlay (299) */
  .modal-backdrop { z-index: 400; }
  .admin-main { padding: 16px; }
  .admin-panel.sidebar-collapsed .nav-label { display: block; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .server-grid { grid-template-columns: 1fr; }
  .slide-panel { width: 100%; }
  .filter-row .input-sm { max-width: 100%; }
  .admin-info { display: none; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .login-card { width: 100%; margin: 16px; border-radius: var(--radius-md); padding: 24px; }
  .modal--sm, .modal--md, .modal--lg, .modal--fullscreen { width: 100%; max-height: 100%; border-radius: 0; }
  .modal-backdrop { align-items: flex-end; }
  .search-box input { width: 180px; }
}

/* ══════════════════════════════════════════════════════════
   BUG FIX ADDITIONS — new elements added by bug fixes
   ══════════════════════════════════════════════════════════ */

/* C1/C2/C3: data-table for users, admins, questions */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  padding: 10px 12px; text-align: left; font-weight: 600;
  color: var(--text-secondary); border-bottom: 1px solid var(--border);
  white-space: nowrap; background: var(--bg-surface);
}
.data-table th[data-sort] { cursor: pointer; user-select: none; }
.data-table th[data-sort]:hover { color: var(--text-primary); }
.data-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  color: var(--text-primary); vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table .td-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.table-toolbar { padding: 8px 16px; display: flex; align-items: center; gap: 8px; }
.pagination-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--border);
}
.pagination-info { font-size: 0.8125rem; color: var(--text-secondary); }
.pagination-btns { display: flex; gap: 6px; margin-left: auto; }
.row-inactive td { opacity: 0.55; }

/* C4: settings forms */
.settings-card { margin-top: 16px; }
.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-actions { padding-top: 8px; display: flex; gap: 10px; }
.input-full {
  width: 100%; padding: 8px 12px; background: var(--bg-input, var(--bg-hover));
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 0.875rem; box-sizing: border-box;
}
.input-full:focus { outline: none; border-color: var(--accent, #388bfd); }
textarea.input-full { resize: vertical; min-height: 80px; }
.settings-preview { margin-top: 12px; min-height: 40px; }
.notif-preview-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 0.875rem;
}
.notif-live { background: rgba(46,160,67,0.15); border: 1px solid rgba(46,160,67,0.4); color: #2ea043; }
.notif-off  { background: var(--bg-hover); border: 1px solid var(--border); color: var(--text-secondary); }
.notif-dot  { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.preview-label { font-size: 0.75rem; opacity: 0.6; }
.maint-preview-screen {
  text-align: center; padding: 24px; background: var(--bg-hover);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.maint-icon { font-size: 2rem; margin-bottom: 8px; }
.maint-eta-text { color: var(--accent, #388bfd); font-weight: 500; }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.875rem; }
.alert-danger { background: rgba(248,81,73,0.1); border: 1px solid rgba(248,81,73,0.4); color: #f85149; }
.flags-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.flag-card { background: var(--bg-hover); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.flag-card-header { display: flex; align-items: center; gap: 12px; }
.flag-icon { font-size: 1.25rem; flex-shrink: 0; }
.flag-label { font-weight: 500; font-size: 0.875rem; color: var(--text-primary); }
.flag-desc { font-size: 0.8125rem; color: var(--text-secondary); }
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; margin-left: auto; flex-shrink: 0; }
.toggle-input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 22px; transition: background .2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  left: 3px; top: 3px; transition: transform .2s;
}
.toggle-input:checked + .toggle-slider { background: var(--accent, #388bfd); }
.toggle-input:checked + .toggle-slider::before { transform: translateX(18px); }

/* C5: question form — 3-column layout sized to fit the modal without scrolling */
.question-form-grid {
  display: grid;
  grid-template-columns: 1.15fr 1.15fr 0.85fr;
  gap: 20px;
  padding: 4px 0;
  flex: 1;
  min-height: 0;
}
.qf-col {
  display: flex; flex-direction: column;
  min-height: 0;
  overflow-y: auto;      /* fallback only — content is sized to avoid needing this */
  padding-right: 4px;
}
.qf-col1 { border-right: 1px solid var(--border); padding-right: 20px; }
.qf-col2 { border-right: 1px solid var(--border); padding-right: 20px; }
.qf-col3.qf-media { gap: 10px; }
.options-grid { display: flex; flex-direction: column; gap: 6px; }
.option-row { display: flex; align-items: center; gap: 10px; }
.option-label {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600; color: var(--text-primary); min-width: 52px; cursor: pointer;
}
.media-preview { margin-top: 6px; border-radius: var(--radius-sm); overflow: hidden; }
.media-preview img { max-width: 100%; max-height: 160px; border-radius: var(--radius-sm); }
.required { color: #f85149; }
.qf-media .form-group { margin-bottom: 14px; }

/* C7: perms checklist */
.perms-checklist { display: flex; flex-direction: column; gap: 12px; max-height: 280px; overflow-y: auto; padding: 4px 0; }
.perm-group { padding: 0; }
.perm-group-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin-bottom: 6px; }
.perm-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.perm-checkbox { accent-color: var(--accent, #388bfd); }
.perm-key { font-size: 0.75rem; margin-left: auto; font-family: monospace; }

/* Admin table badges */
.admin-username { font-weight: 600; }
.badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; }
.badge-purple { background: rgba(163,113,247,0.15); color: #a371f7; }
.badge-amber  { background: rgba(210,153,34,0.15);  color: #d29922; }
.badge-success{ background: rgba(46,160,67,0.15);   color: #2ea043; }
.badge-muted  { background: var(--bg-hover);         color: var(--text-secondary); }
.badge-danger { background: rgba(248,81,73,0.15);    color: #f85149; }
.badge-blue   { background: rgba(56,139,253,0.15);   color: #388bfd; }
.badge-superadmin { background: rgba(163,113,247,0.15); color: #a371f7; }
.status-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; }

@media (max-width: 1100px) {
  .question-form-grid { grid-template-columns: 1fr 1fr; }
  .qf-col3.qf-media { grid-column: 1 / -1; border-right: none; flex-direction: row; gap: 16px; }
  .qf-col3.qf-media .form-group { flex: 1; margin-bottom: 0; }
}

@media (max-width: 768px) {
  .question-form-grid { grid-template-columns: 1fr; overflow-y: auto; }
  .qf-col { overflow-y: visible; border-right: none !important; padding-right: 0 !important; }
  .qf-col3.qf-media { flex-direction: column; }
  .question-editor { overflow-y: auto; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONTENT BROWSER MODAL  (v11)
   ═══════════════════════════════════════════════════════════════════════════ */

.modal--browser {
  width: 90vw;
  max-width: 90vw;
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.cb-header { gap: 0; }
.cb-header-left { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.cb-app-title { font-size: 0.7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.cb-breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 0.85rem; flex-wrap: wrap; }
.bc-active { font-weight: 600; color: var(--text-primary); }
.bc-link { color: var(--accent); cursor: pointer; }
.bc-link:hover { text-decoration: underline; }
.bc-sep { color: var(--text-muted); }

/* Body */
.cb-body { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.cb-step { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.cb-step.hidden { display: none; }

/* Step headers */
.cb-step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cb-step-title { font-size: 1rem; font-weight: 600; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Lists */
.cb-list { flex: 1; overflow-y: auto; padding: 8px 12px; }
.cb-loading { display: flex; justify-content: center; padding: 40px; }
.cb-empty { color: var(--text-muted); text-align: center; padding: 40px; }

/* Subject groups */
.cb-subjects-grid { column-count: 2; column-gap: 12px; }
@media (max-width: 700px) { .cb-subjects-grid { column-count: 1; } }

.cb-group { break-inside: avoid; margin-bottom: 12px; }
.cb-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-hover);
  border-radius: 6px 6px 0 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.cb-group-count {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 0.7rem;
}

/* Main subject dropdown step */
.cb-mainsubject-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 16px;
}
.cb-dropdown-label {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
}
.cb-select {
  width: 100%;
  max-width: 480px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #000;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}
.cb-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 99,102,241), 0.12);
}
.cb-select option { background: #000; color: #fff; }

/* Subject items (display name list - no groups needed) */

.cb-subject-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-top: none;
  cursor: pointer;
  transition: background .12s;
}
.cb-subject-item:last-child { border-radius: 0 0 6px 6px; }
.cb-subject-item:hover { background: var(--bg-hover); }
.cb-item-name { flex: 1; font-size: 0.85rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-item-meta { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.cb-item-arrow { color: var(--text-muted); font-size: 1rem; flex-shrink: 0; }

/* Topic items */
.cb-topic-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.cb-topic-item:hover, .cb-topic-item.active { background: var(--bg-hover); }
.cb-topic-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.btn-xs { font-size: 0.72rem; padding: 2px 8px; }

/* Questions toolbar */
.cb-questions-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cb-questions-table-wrap { flex: 1; overflow-y: auto; }
.td-num { width: 48px; color: var(--text-muted); font-size: 0.8rem; }
.td-center { text-align: center; }

/* ── Configure Admin Modal ─────────────────────────────────────────────────── */
.btn-configure { border-color: var(--accent-muted, #388bfd44) !important; color: var(--accent, #58a6ff) !important; }
.btn-configure:hover { background: var(--accent-muted, #388bfd22) !important; }
.configure-admin-badge { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.configure-admin-note {
  font-size: 12px; color: var(--text-warning, #e3b341); background: var(--bg-warning, #e3b34118);
  border: 1px solid var(--border-warning, #e3b34144); border-radius: var(--radius-sm);
  padding: 8px 10px; margin-bottom: 12px; line-height: 1.5;
}
.configure-admin-info { margin-bottom: 4px; }
.form-section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin: 12px 0 8px;
}
.form-section-divider { border-top: 1px solid var(--border); margin: 16px 0 4px; }

/* ── PYQ Content Review (Phase 2) ─────────────────────────────────────────── */
/* Whole detail fits in the visible panel — laid out as 3 columns instead of
   one long stacked column, so nothing needs scrolling when a question opens. */
.review-detail {
  display: grid;
  grid-template-columns: 1.15fr 1.15fr 0.85fr;
  grid-template-rows: 1fr;
  gap: 20px;
  height: 100%;
  align-items: stretch;
}
.review-detail-col {
  display: flex; flex-direction: column; min-height: 0;
  overflow-y: auto;      /* fallback only — column is sized to fit the page */
}
.review-detail-col + .review-detail-col { border-left: 1px solid var(--border); padding-left: 20px; }
.review-detail-reasons { margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.review-detail label.text-sm.text-muted { display: block; margin: 10px 0 4px; }
.review-detail label.text-sm.text-muted:first-child { margin-top: 0; }
.review-textarea { width: 100%; min-height: 56px; resize: vertical; font-family: inherit; font-size: 0.85rem; }
#review-edit-explanation { min-height: 280px; flex: 1; }
#review-edit-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.review-option {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.review-option--correct { border-color: var(--accent, #2ea043); background: rgba(46,160,67,.08); }
.review-option-label { font-weight: 700; width: 18px; text-align: center; color: var(--text-muted); }
.review-option .review-edit-option-text { flex: 1; }
.review-media-wrap { max-height: 150px; overflow-y: auto; }
.review-thumb { max-width: 110px; max-height: 80px; border-radius: var(--radius-sm); margin: 4px 6px 4px 0; }
.review-reports-wrap { max-height: 160px; overflow-y: auto; }
.review-report-item { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
.review-report-item:last-child { border-bottom: none; }
.review-detail-meta { margin: 8px 0; }
.review-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 1100px) {
  .review-detail { grid-template-columns: 1fr 1fr; }
  .review-detail-col:nth-child(3) { grid-column: 1 / -1; border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: 14px; }
}
@media (max-width: 768px) {
  .review-detail { display: flex; flex-direction: column; gap: 6px; height: auto; }
  .review-detail-col { border-left: none !important; padding-left: 0 !important; }
}
.panel-group {
  margin: 8px 0 0; padding: 10px 12px;
  background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.panel-group h4 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 0 0 8px; }
.panel-group .form-label { margin-bottom: 4px; }
.panel-group .options-grid { gap: 6px; }


/* Payments dashboard details */
.table-scroll-x { overflow-x: auto; width: 100%; }
.payments-detail-table { min-width: 980px; }
.payment-detail-row td { background: var(--bg-surface); border-top: 0; padding: 14px 16px; }
.payment-detail-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 10px 18px; font-size: 12px; }
.payment-detail-grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.payment-detail-grid b { color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.payment-detail-grid code, .payment-detail-grid span { overflow-wrap: anywhere; }
.payments-pagination { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--text-muted); }
@media (max-width: 800px) { .payment-detail-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); } }


/* Rich notification controls */
.settings-subcard { margin: 14px 0; padding: 14px; border: 1px solid var(--border, rgba(255,255,255,.09)); border-radius: 10px; background: var(--surface2, rgba(255,255,255,.025)); }
.settings-subcard-title { font-weight: 700; margin-bottom: 10px; }
.settings-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.form-help { margin-top: 5px; font-size: 11px; color: var(--text3, #94a3b8); line-height: 1.45; }
.notif-preview-content { display:flex; flex-direction:column; align-items:center; gap:8px; }
.notif-preview-content a { color: inherit; text-decoration: underline; }
.notif-preview-action { display:inline-flex; min-height:32px; padding:7px 13px; align-items:center; justify-content:center; border-radius:7px; text-decoration:none !important; background:#2563eb; color:#fff !important; font-weight:800; background-color:#2563eb; }
.notif-preview-image { display:block; max-width:100%; max-height:180px; width:auto; height:auto; border-radius:8px; object-fit:contain; }
.notif-preview-timer { font-size:11px; font-weight:700; opacity:.85; }
@media (max-width:700px) { .settings-grid-2 { grid-template-columns:1fr; } }
