:root {
  --bg: #f8fafc;
  --bg-accent: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #475569;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #ccfbf1;
  --crimson: #dc2626;
  --crimson-soft: #fef2f2;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --radius: 14px;
  --sidebar-w: 270px;
  --navbar-h: 64px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small-text {
  font-size: 13px;
  margin: 4px 0 0;
}

/* ---------- Auth / Login Page (Split Hero Light Design) ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 28px 20px;
  background:
    radial-gradient(circle at 15% 15%, rgba(14, 165, 233, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(15, 118, 110, 0.12) 0%, transparent 45%),
    #f8fafc;
}

.login-split {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  gap: 36px;
  align-items: center;
}

.login-hero {
  padding: 12px 8px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  margin-bottom: 18px;
}

.hero-title {
  margin: 0;
  font-size: clamp(28px, 3.6vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
}

.hero-title span {
  color: var(--accent);
}

.hero-copy {
  margin: 14px 0 22px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 440px;
}

.hero-features {
  list-style: none;
  margin: 0 0 26px;
  padding: 0;
  display: grid;
  gap: 11px;
}

.hero-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #334155;
}

.feature-check {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.07);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  justify-self: center;
  padding: 30px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 3px;
  flex-shrink: 0;
}

.brand-logo.sm {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  padding: 2px;
}

.brand-kicker {
  margin: 0 0 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  color: var(--text);
}

.subtitle {
  margin: 14px 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: #b91c1c;
}

.form {
  display: grid;
  gap: 15px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.text-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.text-link:hover {
  text-decoration: underline;
}

.field input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  padding-right: 68px;
}

.ghost-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
}

.ghost-btn:hover {
  color: var(--text);
  background: rgba(15, 23, 42, 0.06);
}

.primary-btn,
.secondary-btn,
.danger-btn,
.ghost-outline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.primary-btn {
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: var(--accent);
  color: #ffffff;
  margin-top: 2px;
}

.primary-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.primary-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.secondary-btn {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.secondary-btn:hover {
  background: var(--bg-accent);
  border-color: #cbd5e1;
}

.auth-actions {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.danger-btn {
  padding: 8px 14px;
  background: var(--crimson-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
  font-size: 13px;
}

.danger-btn:hover:not(:disabled) {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

.ghost-outline-btn {
  padding: 7px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.ghost-outline-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.ghost-outline-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.card-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.card-footer code {
  color: var(--text);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
}

/* ---------- Full-Screen Unboxed Typing Welcome + Animated Workflow ---------- */
.welcome-stage {
  width: 100%;
  max-width: 780px;
  padding: 32px 20px;
  text-align: center;
  animation: fadeUp 0.35s ease;
}

.welcome-logo {
  width: 68px;
  height: 68px;
  object-fit: contain;
  margin-bottom: 20px;
}

.welcome-headline {
  margin: 0;
  font-size: clamp(28px, 4.2vw, 46px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--text);
  min-height: 1.3em;
}

.typing-cursor {
  display: inline-block;
  width: 3px;
  height: 0.95em;
  background: var(--accent);
  margin-left: 5px;
  vertical-align: -0.08em;
  animation: blink 0.75s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.workflow-track {
  margin: 30px auto 0;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.workflow-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  opacity: 0.45;
  transition: opacity 0.25s ease, color 0.25s ease;
}

.workflow-step.active {
  opacity: 1;
  color: var(--accent-hover);
}

.workflow-step.done {
  opacity: 1;
  color: var(--text);
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background-color 0.25s ease, transform 0.25s ease;
}

.workflow-step.active .step-dot {
  background: var(--accent);
  animation: pulseDot 1s ease-in-out infinite;
}

.workflow-step.done .step-dot {
  background: #10b981;
}

@keyframes pulseDot {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.35);
  }
}

.workflow-bar {
  margin: 18px auto 0;
  max-width: 360px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.workflow-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f766e, #0284c7);
  transition: width 0.25s ease;
}

/* ---------- Portal Shell (Navbar + Sidebar + Main + Footer) ---------- */
.portal-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portal-navbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--navbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.nav-user-pill:hover {
  border-color: var(--accent);
}

.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.menu-toggle-btn {
  display: none;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.portal-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.portal-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px 28px;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 18px;
}

.sidebar-heading {
  margin: 0 0 8px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.sidebar-item-btn {
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-item-btn:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.sidebar-item-btn.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 700;
  border-color: #99f6e4;
}

.lab-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-accent);
  color: var(--muted);
  text-transform: uppercase;
}

.lab-badge.done {
  background: #dcfce7;
  color: #15803d;
}

.portal-main {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 22px;
}

/* ---------- Analytics Grid ---------- */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.kpi-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.kpi-sub {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.dashboard-split {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

.progress-list {
  display: grid;
  gap: 13px;
}

.progress-row-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-accent);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f766e, #0284c7);
}

.lab-spotlight-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 12px;
}

.tag {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bg-accent);
  color: var(--muted);
}

.tag.accent {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

/* ---------- Profile & Details ---------- */
.loading-state {
  padding: 28px 0;
  text-align: center;
  color: var(--muted);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0284c7, #0f766e);
  color: #ffffff;
  font-weight: 800;
  font-size: 20px;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-title {
  flex: 1;
  min-width: 180px;
}

.profile-title h2 {
  margin: 0;
  font-size: 20px;
}

.profile-title p {
  margin: 4px 0 0;
  font-size: 13px;
}

.role-badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.role-badge.admin {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.role-badge.instructor {
  background: #f0f9ff;
  color: #0369a1;
  border-color: #bae6fd;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.detail-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.detail-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
}

.detail-value {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
  color: var(--text);
}

/* ---------- Admin Users Table ---------- */
.users-section {
  margin-top: 22px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filters-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search-input,
.filter-select {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.search-input {
  min-width: 220px;
}

.search-input:focus,
.filter-select:focus {
  border-color: var(--accent);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.users-table th,
.users-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}

.users-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--surface-2);
}

.users-table tbody tr:last-child td {
  border-bottom: none;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}

.user-detail-panel {
  margin-top: 18px;
  padding: 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-panel-header h3 {
  margin: 0;
  font-size: 16px;
}

.raw-details {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
}

.raw-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.raw-details pre {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  color: #334155;
}

/* ---------- Footer ---------- */
.portal-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-links a:hover {
  color: var(--accent);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .login-split {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .login-hero {
    text-align: center;
  }

  .hero-copy {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-features {
    justify-items: center;
  }

  .dashboard-split {
    grid-template-columns: 1fr;
  }

  .menu-toggle-btn {
    display: inline-flex;
  }

  .portal-sidebar {
    position: fixed;
    top: var(--navbar-h);
    left: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
  }

  .portal-sidebar.open {
    transform: translateX(0);
  }
}
