/* ═══════════════════════════════════════════════════════════════════════════
   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%; min-height: 340px; }
.map-layer svg { width: 100%; height: auto; }
.map-tooltip {
  position: absolute; pointer-events: none;
  background: var(--bg-elevated); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: var(--radius-sm);
  font-size: 0.8rem; color: var(--text-primary); white-space: nowrap;
  z-index: 50; box-shadow: var(--shadow-md);
}
.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; top: var(--header-h); right: 0; bottom: 0;
  width: 420px; max-width: 100%;
  background: var(--bg-surface); border-left: 1px solid var(--border);
  z-index: 200; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform var(--trans-mid);
  box-shadow: var(--shadow-lg);
}
.slide-panel:not(.hidden) { transform: translateX(0); }
.slide-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.slide-panel-title { font-size: 1rem; font-weight: 600; }
.slide-panel-close {
  background: transparent; border: none; color: var(--text-muted);
  padding: 4px; border-radius: var(--radius-sm);
}
.slide-panel-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.slide-panel-body { flex: 1; overflow-y: auto; padding: 20px; }
.slide-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 199;
}

/* ── 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: min(900px, 95vw); 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: grid; gap: 14px; }
.question-editor .form-group label { font-size: 0.82rem; }
.question-editor textarea { width: 100%; resize: vertical; min-height: 80px; padding: 8px 12px; }
.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; }
@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,.5); z-index: 299;
  }
  .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; }
}
