/* ================================================================
   Field Academy — Main Stylesheet v1.0.0
   Light mode default, dark mode via [data-theme="dark"]
   Fonts: IBM Plex Sans (core), Sora (premium/hero only)
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=Sora:wght@500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --font-base:    'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Sora', 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Colours */
  --primary:       #4F46E5;
  --primary-dark:  #3730A3;
  --primary-light: #EEF2FF;
  --secondary:     #06B6D4;
  --success:       #10B981;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --info:          #3B82F6;

  /* Neutrals */
  --gray-50:  #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* Semantic */
  --bg:          #F9FAFB;
  --surface:     #FFFFFF;
  --surface-2:   #F3F4F6;
  --border:      #E5E7EB;
  --text:        #111827;
  --text-muted:  #6B7280;
  --text-light:  #9CA3AF;

  /* Layout */
  --sidebar-w:   256px;
  --topbar-h:    64px;
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   16px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:      0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:   0 10px 32px rgba(0,0,0,.12);

  --transition: 0.2s ease;
}

/* Dark Mode */
[data-theme="dark"] {
  --bg:         #0F172A;
  --surface:    #1E293B;
  --surface-2:  #334155;
  --border:     #334155;
  --text:       #F1F5F9;
  --text-muted: #94A3B8;
  --text-light: #64748B;
  --primary-light: #1e1b4b;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-base);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
img { max-width: 100%; display: block; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  transition: transform var(--transition);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 1rem;
}
.sidebar-brand .brand-name { font-weight: 700; font-size: 1rem; color: var(--text); }
.sidebar-brand .brand-version { font-size: 0.7rem; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 16px 4px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-light); }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.nav-item.active { background: var(--primary-light); color: var(--primary); border-left-color: var(--primary); }
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-title { font-size: 1.0625rem; font-weight: 600; color: var(--text); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.page-content { padding: 28px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.card-body { padding: 22px; }
.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Stat Cards ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); gap: 18px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
a.stat-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}
a.stat-card:hover .stat-value { color: var(--primary); }
a.stat-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.stat-card .stat-label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card .stat-sub   { font-size: 0.8rem; color: var(--text-muted); }
.stat-card .stat-icon  { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.stat-card.primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.success .stat-icon { background: #D1FAE5; color: var(--success); }
.stat-card.warning .stat-icon { background: #FEF3C7; color: var(--warning); }
.stat-card.danger  .stat-icon { background: #FEE2E2; color: var(--danger); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-base);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; opacity: .9; }
.btn-sm { padding: 5px 12px; font-size: 0.8125rem; }
.btn-lg { padding: 11px 24px; font-size: 1rem; }
.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); opacity: 1; }
.btn-secondary { background: var(--gray-100); color: var(--text); border-color: var(--border); }
.btn-success   { background: var(--success); color: white; }
.btn-danger    { background: var(--danger);  color: white; }
.btn-warning   { background: var(--warning); color: white; }
.btn-outline   { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-outline:hover { background: var(--surface-2); }
.btn-icon { padding: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 14px;
  font-family: var(--font-base);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.form-control::placeholder { color: var(--text-light); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.8rem; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* Password input with show/hide toggle */
.password-wrap { position: relative; }
.password-wrap .form-control { padding-right: 40px; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.password-toggle:hover { color: var(--text); background: rgba(0,0,0,.04); }
.password-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success   { background: #D1FAE5; color: #065F46; }
.badge-info      { background: #DBEAFE; color: #1E40AF; }
.badge-warning   { background: #FEF3C7; color: #92400E; }
.badge-danger    { background: #FEE2E2; color: #991B1B; }
.badge-secondary { background: var(--gray-100); color: var(--gray-600); }
.badge-dark      { background: var(--gray-700); color: white; }
.badge-primary   { background: var(--primary-light); color: var(--primary); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table th {
  background: var(--surface-2);
  padding: 11px 16px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th.text-right, .table td.text-right { text-align: right; }
.table td {
  padding: 12px 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Progress Bar ───────────────────────────────────────────── */
.progress { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; background: var(--primary); transition: width .4s ease; }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }

/* ── Alerts / Flashbars ─────────────────────────────────────── */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
  font-size: 0.875rem;
  margin-bottom: 16px;
}
.alert-success { background: #D1FAE5; border-color: var(--success); color: #065F46; }
.alert-danger  { background: #FEE2E2; border-color: var(--danger);  color: #991B1B; }
.alert-warning { background: #FEF3C7; border-color: var(--warning); color: #92400E; }
.alert-info    { background: #DBEAFE; border-color: var(--info);    color: #1E40AF; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination-nav { margin-top: 16px; }
.pagination { display: flex; gap: 4px; list-style: none; }
.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
}
.page-link:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); text-decoration: none; }
.page-item.active .page-link { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(640px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.2rem; padding: 4px; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-btn {
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover  { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Breadcrumb ─────────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); text-decoration: none; }
.breadcrumb .sep { color: var(--text-light); }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 16px; opacity: .4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 0.875rem; }

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 0.7rem; }
.avatar.lg { width: 48px; height: 48px; font-size: 1rem; }

/* ── Learner portal ─────────────────────────────────────────── */
.learner-layout { max-width: 520px; margin: 0 auto; min-height: 100vh; background: var(--bg); }
.learner-topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--primary);
  color: white;
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.learner-topbar .topbar-logo { font-weight: 700; font-size: 1.0625rem; }
.learner-content { padding: 16px 16px 90px; }
.learner-bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 200;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  text-decoration: none;
  border-top: 2px solid transparent;
  transition: color var(--transition);
}
.bottom-nav-item.active { color: var(--primary); border-top-color: var(--primary); }
.bottom-nav-item svg { width: 22px; height: 22px; }

/* Training card (learner) */
.training-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  transition: box-shadow var(--transition);
}
.training-card:hover { box-shadow: var(--shadow); text-decoration: none; }
.training-card .tc-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.training-card .tc-body { flex: 1; min-width: 0; }
.training-card .tc-title { font-weight: 600; font-size: 0.9375rem; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.training-card .tc-meta  { font-size: 0.8rem; color: var(--text-muted); }

/* Online indicator */
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; }
.offline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); display: inline-block; }

/* ── Quiz styles ────────────────────────────────────────────── */
.quiz-question { margin-bottom: 28px; }
.quiz-question h4 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 14px; }
.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.quiz-option:hover { border-color: var(--primary); background: var(--primary-light); }
.quiz-option input { cursor: pointer; }
.quiz-option.correct { border-color: var(--success); background: #D1FAE5; }
.quiz-option.wrong   { border-color: var(--danger);  background: #FEE2E2; }

/* ── Certificate preview ────────────────────────────────────── */
.certificate-preview {
  background: white;
  border: 8px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 48px;
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
}
.certificate-preview .cert-logo { font-size: 1.5rem; font-weight: 800; color: var(--primary); margin-bottom: 12px; }
.certificate-preview h1 { font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.certificate-preview .cert-name { font-size: 1.5rem; font-weight: 600; color: var(--primary); margin: 16px 0; }
.certificate-preview .cert-course { font-size: 1rem; color: var(--text-muted); }
.certificate-preview .cert-number { font-size: 0.8rem; color: var(--text-light); margin-top: 24px; }

/* ── Utility ────────────────────────────────────────────────── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-small   { font-size: 0.8125rem; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-600       { font-weight: 600; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mb-4         { margin-bottom: 4px; }
.mb-8         { margin-bottom: 8px; }
.mb-16        { margin-bottom: 16px; }
.mb-24        { margin-bottom: 24px; }
.gap-8        { gap: 8px; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap    { flex-wrap: wrap; }
.w-full       { width: 100%; }

/* ── Dark mode toggle ───────────────────────────────────────── */
.theme-toggle {
  width: 42px; height: 24px;
  background: var(--gray-300);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
  border: none;
  flex-shrink: 0;
}
.theme-toggle::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform var(--transition);
}
[data-theme="dark"] .theme-toggle { background: var(--primary); }
[data-theme="dark"] .theme-toggle::after { transform: translateX(18px); }

/* ── Offline banner ─────────────────────────────────────────── */
#offline-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--warning);
  color: #1a1a1a;
  text-align: center;
  padding: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  display: none;
  z-index: 9999;
}

/* ── Login page ─────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: min(420px, 100%);
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-mark { width: 56px; height: 56px; background: var(--primary); border-radius: 14px; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 800; font-size: 1.4rem; }
.login-logo h1 { font-size: 1.4rem; font-weight: 700; }
.login-logo p  { color: var(--text-muted); font-size: 0.875rem; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
}

/* ── Chart wrapper ──────────────────────────────────────────── */
.chart-container { position: relative; height: 260px; }

/* ── Sortable (course builder) ──────────────────────────────── */
.sortable-list { list-style: none; }
.sortable-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: grab;
}
.sortable-item:active { cursor: grabbing; opacity: .8; }
.drag-handle { color: var(--text-light); cursor: grab; }

/* ── Streak badge ───────────────────────────────────────────── */
.streak-badge { display: inline-flex; align-items: center; gap: 4px; background: #FEF3C7; color: #92400E; padding: 4px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; }

/* ── Inline filter popover (e.g. dashboard cohort filter) ──── */
.cohort-filter { position: relative; }
.cohort-filter > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.cohort-filter > summary::-webkit-details-marker { display: none; }
.cohort-filter[open] > .cohort-filter-trigger { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.cohort-filter-trigger .cohort-filter-count {
  background: var(--primary); color: white; font-weight: 600;
  font-size: 10.5px; padding: 1px 6px; border-radius: 999px; margin-left: 2px;
}
.cohort-filter-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 50;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
}

/* ──────────────────────────────────────────────────────────────
   Completion-by-Cohort card (hand-rolled bar chart)
   Token map: design's --ink→--text, --ink-soft→--text-muted,
   --ink-faint→--text-light, --line→--border, --hover→--surface-2,
   --accent / --ontrack→--primary. --attention amber and ink
   declared locally to match the design spec.
   ────────────────────────────────────────────────────────────── */
.cohort-card {
  --cohort-attention:      #F59E0B;
  --cohort-attention-ink:  #92400E;
  --cohort-nodata-dot:     var(--text-light);
  padding: 22px 26px 18px;
}
.cohort-card .cohort-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
}
.cohort-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--primary); margin-bottom: 6px;
}
.cohort-title {
  font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em;
  color: var(--text); margin: 0;
  font-family: var(--font-display, var(--font-base));
}
.cohort-sub {
  font-size: 0.825rem; color: var(--text-muted); margin: 4px 0 0;
}
.cohort-stats {
  display: flex; align-items: flex-start; gap: 24px; flex-wrap: wrap;
}
.cohort-stat { text-align: right; }
.cohort-stat-num {
  font-variant-numeric: tabular-nums;
  font-size: 24px; font-weight: 700; color: var(--text); line-height: 1;
  letter-spacing: -0.02em;
}
.cohort-stat-num.warn { color: var(--cohort-attention-ink); }
.cohort-stat-pct { font-size: 13px; margin-left: 1px; color: var(--text-light); font-weight: 600; }
.cohort-stat-lbl { font-size: 11px; color: var(--text-light); margin-top: 5px; }

/* Controls row */
.cohort-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin: 18px 0 16px; flex-wrap: wrap;
}
.cohort-seg {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px;
}
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: transparent; padding: 6px 12px;
  border-radius: 7px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  font-family: inherit;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 2px rgba(15,23,42,.08);
}
.seg-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-light);
}
.seg-dot.ontrack   { background: var(--primary); }
.seg-dot.attention { background: var(--cohort-attention); }
.seg-dot.nodata    { background: var(--text-light); opacity: .7; }

.cohort-controls-right {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.cohort-legend { display: inline-flex; gap: 14px; }
.cohort-legend .lg {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-muted); font-weight: 500;
}
.sortwrap {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 2px 28px 2px 10px; background: var(--surface); position: relative;
  color: var(--text-muted); transition: border-color var(--transition);
  cursor: pointer;
}
.sortwrap:hover { border-color: var(--text-light); }
.sortwrap select {
  appearance: none; -webkit-appearance: none; border: 0;
  background: transparent; padding: 5px 4px;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--text); cursor: pointer; outline: none;
}
.sortwrap .chev { position: absolute; right: 9px; pointer-events: none; color: var(--text-light); }

/* Chart */
.cohort-chart { display: flex; gap: 14px; padding-top: 4px; }
.cohort-chart .yaxis {
  position: relative; width: 34px; flex-shrink: 0;
}
.cohort-chart .ytick {
  position: absolute; right: 0; width: 100%; text-align: right;
  font-variant-numeric: tabular-nums; font-size: 11px;
  color: var(--text-light);
}
.cohort-chart .ypct { opacity: .55; margin-left: 1px; }
.cohort-chart .plot { flex: 1; position: relative; min-width: 0; }
.cohort-chart .grid { position: relative; }
.cohort-chart .gline {
  position: absolute; left: 0; right: 0; height: 1px;
  background: var(--surface-2);
}
.cohort-chart .gline.base { background: var(--border); height: 1.5px; }
.cohort-chart .bars { position: absolute; inset: 0; display: flex; align-items: flex-end; }
.cohort-chart .col { flex: 1; position: relative; min-width: 0; }
.cohort-chart .col.is-clickable { cursor: pointer; }
.cohort-chart .bar-track {
  position: relative; display: flex; align-items: flex-end; justify-content: center;
}
.cohort-chart .col-hi {
  position: absolute; inset: 0 6px 0 6px; background: var(--surface-2);
  border-radius: 10px; transition: opacity .18s ease; opacity: 0; z-index: 0;
}
.cohort-chart .bar {
  position: relative; z-index: 1;
  width: 58%; max-width: 64px; min-width: 26px;
  border-radius: 7px 7px 3px 3px;
  transition: height .5s cubic-bezier(.22,1,.36,1),
              box-shadow .18s ease;
  animation: cohortBarIn .55s cubic-bezier(.22,1,.36,1) both;
}
.cohort-chart .val {
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 600;
  white-space: nowrap;
}
.cohort-chart .val .pct { opacity: .6; margin-left: 1px; }
.cohort-chart .ghost {
  position: relative; z-index: 1;
  width: 58%; max-width: 64px; min-width: 26px; height: 30px;
  border: 1.5px dashed var(--border);
  border-radius: 7px 7px 3px 3px;
  background: repeating-linear-gradient(135deg, transparent 0 6px, var(--surface-2) 6px 7px);
}
.cohort-chart .ghost-tag {
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-style: italic; color: var(--text-light); white-space: nowrap;
}
.cohort-chart .xlabels {
  display: flex; gap: 0; margin-top: 8px;
}
.cohort-chart .xlabel {
  flex: 1; text-align: center; font-size: 12px; font-weight: 600;
  color: var(--text-muted); padding: 0 4px; line-height: 1.3;
  text-wrap: balance; min-width: 0; transition: color .16s ease;
}
.cohort-chart .xlabel.on { color: var(--text); }
.cohort-chart .empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text-light); font-style: italic;
}
.cohort-empty {
  text-align: center; color: var(--text-muted); font-size: 0.875rem; margin: 24px 0;
}

/* Tooltip */
.cohort-chart .tip {
  position: absolute; transform: translate(-50%, -100%);
  background: var(--text); color: white; border-radius: 11px;
  padding: 10px 12px; box-shadow: 0 12px 30px -8px rgba(15,23,42,.45);
  min-width: 150px; max-width: 200px; z-index: 5; pointer-events: none;
  animation: cohortTipIn .14s ease both;
}
.cohort-chart .tip-name { font-size: 12.5px; font-weight: 700; margin-bottom: 4px; }
.cohort-chart .tip-row { display: flex; align-items: center; gap: 8px; }
.cohort-chart .tip-val {
  font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 600;
  letter-spacing: -0.02em;
}
.cohort-chart .tip-pill {
  padding: 3px 7px; border-radius: 999px; background: rgba(255,255,255,.12);
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 600;
}
.cohort-chart .tip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cohort-chart .tip-sub { font-size: 10.5px; color: rgba(255,255,255,.6); margin-top: 6px; }
.cohort-chart .tip-arrow {
  position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%) rotate(45deg);
  width: 10px; height: 10px; background: var(--text); border-radius: 2px;
}

@keyframes cohortBarIn {
  from { opacity: .35; transform: translateY(10px); }
  to   { opacity: 1;   transform: translateY(0); }
}
@keyframes cohortTipIn {
  from { opacity: 0; transform: translate(-50%, calc(-100% + 5px)); }
  to   { opacity: 1; transform: translate(-50%, -100%); }
}

@media (max-width: 720px) {
  .cohort-card .cohort-head { flex-direction: column; align-items: stretch; }
  .cohort-stats { justify-content: flex-start; }
  .cohort-controls { flex-direction: column; align-items: stretch; }
  .cohort-controls-right { justify-content: space-between; }
}

/* ── Display font (Sora) — hero / premium surfaces only ───────
   Body text and standard headings inherit IBM Plex Sans via
   --font-base on <body>. */
.page-title,
.stat-card .stat-value,
.sidebar-brand .brand-name,
.login-logo h1,
.certificate-preview h1,
.certificate-preview .cert-name {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

/* ──────────────────────────────────────────────────────────────
   Admin layout — classes referenced by the admin/* pages that
   weren't defined in the original stylesheet.
   ────────────────────────────────────────────────────────────── */
.app-layout   { display: flex; min-height: 100vh; }
.main-wrapper { flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.main-content { padding: 28px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-title    { font-size: 1.5rem; font-weight: 700; color: var(--text); margin: 0; }
.page-subtitle { font-size: 0.875rem; color: var(--text-muted); margin: 4px 0 0; }

/* Cards within main-content get breathing room between each other. */
.main-content > .card,
.main-content > .alert { margin-bottom: 20px; }
.main-content > .card:last-child { margin-bottom: 0; }

/* Filter rows inside cards. */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
}

/* Tab-style nav (e.g. Regions / Branches / Teams). */
.tabs-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-item {
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition);
}
.tab-item:hover  { color: var(--primary); text-decoration: none; }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Admin uses .data-table; original CSS only defines .table — alias them. */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 12px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table th.text-right,
.data-table td.text-right { text-align: right; }
.data-table .empty-state { padding: 40px 20px; text-align: center; color: var(--text-muted); }

/* Ghost button used by admin modals. */
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.link-primary { color: var(--primary); font-weight: 500; }
.link-primary:hover { text-decoration: underline; }

/* Tailwind-style spacing scale (1 unit = 4px) — admin pages were
   written assuming mb-4 = 1rem. Overrides the earlier mb-* defs. */
.mb-1  { margin-bottom: 4px;  }
.mb-2  { margin-bottom: 8px;  }
.mb-3  { margin-bottom: 12px; }
.mb-4  { margin-bottom: 16px; }
.mb-5  { margin-bottom: 20px; }
.mb-6  { margin-bottom: 24px; }
.mb-8  { margin-bottom: 32px; }
.mb-10 { margin-bottom: 40px; }
.w-full { width: 100%; }

/* When admin layout is in use, ensure main-content does NOT get the
   sidebar offset applied twice (sidebar is fixed, main-wrapper sits
   inside .app-layout flex, so main-content shouldn't add margin-left). */
.app-layout > .main-wrapper { margin-left: var(--sidebar-w); }
.app-layout .main-content   { margin-left: 0; }

/* ──────────────────────────────────────────────────────────────
   Progress Overview card (hand-rolled SVG donut + breakdown)
   ────────────────────────────────────────────────────────────── */
.progress-overview {
  --po-c-completed:   #2BB789;
  --po-c-in_progress: #5B8DEF;
  --po-c-not_started: #E0A83C;
  --po-c-overdue:     #DD5A52;
  --po-track:         var(--surface-2);
  padding: 0;
}
.progress-overview .po-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--surface-2);
}
.progress-overview .po-title {
  font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em;
  color: var(--text); margin: 0;
  font-family: var(--font-display, var(--font-base));
}
.progress-overview .po-sub {
  font-size: 12.5px; color: var(--text-light); margin: 3px 0 0; font-weight: 500;
}

/* Period pill */
.po-period { position: relative; }
.po-period > summary {
  list-style: none; display: inline-flex; align-items: center; gap: 7px;
  cursor: pointer;
}
.po-period > summary::-webkit-details-marker { display: none; }
.po-period-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 10px;
  transition: border-color var(--transition), color var(--transition);
}
.po-period-pill .seg-dot { background: var(--po-c-completed); }
.po-period > summary:hover .po-period-pill { border-color: var(--text-light); color: var(--text); }
.po-period[open] .po-period-pill { border-color: var(--primary); color: var(--primary); }
.po-period-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  z-index: 50; min-width: 240px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 12px 14px;
}
.po-period-opt {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.875rem; padding: 5px 2px; cursor: pointer;
  color: var(--text);
}
.po-period-opt input { accent-color: var(--primary); }
.po-period-dates {
  display: flex; gap: 6px; align-items: center;
  margin-top: 4px; padding-left: 22px;
}
.po-period-dates input[type=date] {
  flex: 1; min-width: 0;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 8px; font-size: 12.5px; font-family: inherit;
  background: var(--surface); color: var(--text);
}
.po-period-dates input[type=date]:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

/* Body */
.po-body {
  display: grid; grid-template-columns: 240px 1fr; gap: 30px;
  align-items: center; padding: 26px 28px 28px;
}
.po-donut-wrap {
  position: relative; width: 240px; height: 240px; flex-shrink: 0;
}
.po-donut {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
  animation: poDonutIn .9s cubic-bezier(.2,.7,.2,1) both;
}
.po-track {
  fill: none; stroke: var(--po-track); stroke-width: 22;
}
.po-seg {
  fill: none; stroke-width: 22; stroke-linecap: round;
  transition: stroke-width .2s ease, opacity .2s ease;
}
.po-body.is-hovered .po-seg:not(.is-active) { opacity: 0.25; }
.po-seg.is-active { stroke-width: 30; }
.po-c-completed   { background: var(--po-c-completed);   stroke: var(--po-c-completed); }
.po-c-in_progress { background: var(--po-c-in_progress); stroke: var(--po-c-in_progress); }
.po-c-not_started { background: var(--po-c-not_started); stroke: var(--po-c-not_started); }
.po-c-overdue     { background: var(--po-c-overdue);     stroke: var(--po-c-overdue); }

.po-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.po-metric { display: flex; align-items: baseline; line-height: 1; }
.po-metric-num {
  font-size: 46px; font-weight: 800; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums; color: var(--text);
  font-family: var(--font-display, var(--font-base));
}
.po-metric-pct {
  font-size: 22px; font-weight: 700; color: var(--text-light);
  margin-left: 2px;
}
.po-metric-lbl {
  font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-light); margin-top: 7px;
}
.po-metric-meta {
  font-size: 12px; color: var(--text-muted); margin-top: 4px;
}
.po-metric-meta strong { color: var(--text); font-weight: 700; }

/* Legend rows */
.po-legend { display: flex; flex-direction: column; gap: 4px; }
.po-row {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 12px; align-items: center;
  padding: 10px 12px; border-radius: 12px;
  cursor: default; transition: background var(--transition);
}
.po-row:hover { background: var(--surface-2); }
.po-row.is-active { background: var(--surface-2); }
.po-swatch {
  width: 11px; height: 11px; border-radius: 4px; flex-shrink: 0;
}
.po-row-mid { min-width: 0; }
.po-row-name {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  margin-bottom: 6px;
}
.po-bar-track {
  height: 6px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden;
}
.po-bar {
  height: 100%; border-radius: 999px;
  transform-origin: left; transform: scaleX(0);
  animation: poBarIn .9s cubic-bezier(.2,.7,.2,1) both;
  animation-delay: var(--row-delay, 0ms);
}
.po-row-right { text-align: right; min-width: 56px; }
.po-count {
  font-size: 14px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.po-pct {
  font-size: 12px; font-weight: 600; color: var(--text-light);
  margin-top: 1px;
}

@keyframes poDonutIn {
  from { transform: rotate(-112deg) scale(.94); }
  to   { transform: rotate(-90deg) scale(1); }
}
@keyframes poBarIn {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@media (max-width: 720px) {
  .po-body { grid-template-columns: 1fr; gap: 18px; padding: 22px; }
  .po-donut-wrap { margin: 0 auto; }
}
