:root {
  --sidebar-w: 256px;

  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  --brand-slate:    #2b2f36;
  --brand-bronze:   #b07d36;
  --brand-parchment:#c9b48d;
  --brand-paper:    #f4f1e9;

  --indigo-50:  #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-200: #c7d2fe;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;

  --emerald-50:  #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;

  --amber-50:  #fffbeb;
  --amber-100: #fef3c7;
  --amber-200: #fde68a;
  --amber-600: #d97706;
  --amber-700: #b45309;

  --red-50:  #fef2f2;
  --red-100: #fee2e2;
  --red-200: #fecaca;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-700: #b91c1c;

  --radius-sm:  6px;
  --radius-md:  8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl:20px;
}

/* ── Reset ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-gutter: stable; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--slate-700);
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

p, h1, h2, h3, h4 { margin-top: 0; }
a { color: inherit; text-decoration: none; }

/* ── Auth ─────────────────────────────────────── */
.auth-screen {
  min-height: 100vh;
  background: var(--slate-50);
}

.auth-main-only {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-main-only .toast-stack {
  width: min(440px, 100%);
  margin-bottom: 1rem;
}

.auth-card-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: var(--radius-2xl);
  border: 1px solid var(--slate-200);
  overflow: hidden;
}

.auth-card-head {
  padding: 2rem 1.5rem 1.75rem;
  background: var(--brand-slate);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

.auth-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
}

.auth-brand-name {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f3eee2;
  margin: 0;
  line-height: 1;
}

.auth-brand-sub {
  font-size: 0.8125rem;
  color: rgba(243, 238, 226, 0.55);
  margin: 0;
}

.auth-card-body { padding: 1.5rem; }

.auth-footer-links {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.8125rem;
}
.auth-footer-links a {
  color: var(--brand-bronze);
  text-decoration: none;
}
.auth-footer-links a:hover { text-decoration: underline; }

.auth-info {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: var(--slate-600);
  margin-bottom: 1.25rem;
}

/* ── App layout ───────────────────────────────── */
.app-screen { background: var(--slate-50); }

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--slate-200);
  display: flex;
  flex-direction: column;
  z-index: 20;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 1rem 1rem 0.875rem;
  border-bottom: 1px solid var(--slate-100);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--brand-slate);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-name {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--brand-slate);
  margin: 0;
  line-height: 1.3;
}

.brand-scroll { color: var(--brand-bronze); }

.brand-tag {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--slate-400);
}

.brand-sub {
  font-size: 0.6875rem;
  color: var(--slate-400);
  margin: 0;
  line-height: 1.3;
}

.sidebar-company-switcher {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--slate-100);
  flex-shrink: 0;
}

.sidebar-company-switcher select {
  margin-bottom: 0;
  font-size: 0.8125rem;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.sidebar-nav-section { margin-bottom: 1.25rem; }

.sidebar-nav-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0 0.5rem;
  margin-bottom: 0.25rem;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--slate-600);
  text-decoration: none;
  transition: background 0.1s ease, color 0.1s ease;
  cursor: pointer;
  line-height: 1.4;
}

.side-link:hover {
  background: var(--slate-100);
  color: var(--slate-800);
}

.side-link.is-active {
  background: var(--indigo-50);
  color: var(--indigo-700);
}

.side-link.is-active .icon-svg { color: var(--indigo-600); }

.side-link-button {
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--slate-100);
  flex-shrink: 0;
}

.sidebar-footer form,
.sidebar-footer .button_to { margin: 0; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.25rem;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--indigo-100);
  color: var(--indigo-700);
  font-size: 0.6875rem;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.user-info { flex: 1; min-width: 0; }

.user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--slate-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  line-height: 1.3;
}

.user-role {
  font-size: 0.6875rem;
  color: var(--slate-400);
  margin: 0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Main content ─────────────────────────────── */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  background: var(--slate-50);
  display: flex;
  flex-direction: column;
}

.app-main-inner {
  padding: 2rem 2.5rem;
  flex: 1;
}

/* ── Mobile topbar ────────────────────────────── */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--slate-200);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}
.mobile-topbar-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--slate-800);
  margin: 0;
}

.hamburger-btn {
  display: none;
  background: none;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 0.375rem;
  color: var(--slate-600);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.1s ease;
  line-height: 1;
}

.hamburger-btn:hover {
  background: var(--slate-100);
  transform: none;
  box-shadow: none;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 18;
  background: rgba(15, 23, 42, 0.25);
  backdrop-filter: blur(2px);
}

.sidebar-overlay.is-visible { display: block; }

/* ── Page head ────────────────────────────────── */
.page-head {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.page-title {
  margin: 0 0 0.2rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--slate-900);
  letter-spacing: -0.015em;
}

.page-subtitle {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--slate-500);
}

/* ── Card ─────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius-2xl);
  border: 1px solid var(--slate-200);
  padding: 1.25rem;
}


/* ── Stats ────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: var(--slate-100);
  color: var(--slate-500);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.stat-icon.accent   { background: var(--indigo-50);  color: var(--indigo-600); }
.stat-icon.success  { background: var(--emerald-50); color: var(--emerald-600); }
.stat-icon.warning  { background: var(--amber-50);   color: var(--amber-600); }
.stat-icon.danger   { background: var(--red-50);     color: var(--red-600); }

.stat-number {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--slate-900);
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-label {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--slate-500);
}

/* ── Table ────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table thead th {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 0 0.875rem 0.625rem;
  border-bottom: 1px solid var(--slate-200);
  background: transparent;
  white-space: nowrap;
}

.table tbody tr { transition: background 0.1s ease; }

.table tbody tr:hover { background: var(--slate-50); }

.table tbody td {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
  color: var(--slate-700);
}

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

/* Row actions hidden until hover */
.table tbody tr .row-actions {
  opacity: 0;
  transition: opacity 0.1s ease;
}

.table tbody tr:hover .row-actions { opacity: 1; }

/* ── Badges ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 500;
}

.badge-green  { background: var(--emerald-50); color: var(--emerald-700); box-shadow: inset 0 0 0 1px var(--emerald-200); }
.badge-amber  { background: var(--amber-50);   color: var(--amber-700);   box-shadow: inset 0 0 0 1px var(--amber-200); }
.badge-red    { background: var(--red-50);     color: var(--red-700);     box-shadow: inset 0 0 0 1px var(--red-200); }
.badge-indigo,
.badge-purple,
.badge-blue   { background: var(--indigo-50);  color: var(--indigo-700);  box-shadow: inset 0 0 0 1px var(--indigo-200); }
.badge-slate  { background: var(--slate-100);  color: var(--slate-600);   box-shadow: inset 0 0 0 1px var(--slate-200); }

/* ── Buttons ──────────────────────────────────── */
.btn,
.btn-secondary,
.btn-danger,
.ghost-button,
button:not(.side-link-button):not(.hamburger-btn):not(.link-like):not(.btn-secondary):not(.btn-danger):not(.ghost-button),
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.1s ease;
}

.btn,
button:not(.side-link-button):not(.hamburger-btn):not(.link-like):not(.btn-secondary):not(.btn-danger):not(.ghost-button),
input[type="submit"]:not(.btn-secondary):not(.btn-danger) {
  background: var(--indigo-600);
  color: #fff;
}
.btn:hover,
button:not(.side-link-button):not(.hamburger-btn):not(.link-like):not(.btn-secondary):not(.btn-danger):not(.ghost-button):hover,
input[type="submit"]:not(.btn-secondary):not(.btn-danger):hover { background: var(--indigo-700); }

.btn-secondary,
.ghost-button {
  background: #fff;
  color: var(--slate-700);
  border-color: var(--slate-200);
}
.btn-secondary:hover,
.ghost-button:hover { background: var(--slate-50); }

.btn-danger {
  background: #fff;
  color: var(--red-600);
  border-color: var(--red-200);
  transition: background 0.1s ease, color 0.1s ease;
}
.btn-danger:hover { background: var(--red-50); }

.btn-warning {
  background: #fff;
  color: #92400e;
  border-color: #fcd34d;
  transition: background 0.1s ease, color 0.1s ease;
}
.btn-warning:hover { background: #fffbeb; }

.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.8125rem; }

button.link-like {
  background: transparent;
  border: none;
  color: var(--indigo-600);
  font-size: 0.875rem;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  display: inline;
  transition: color 0.1s ease;
  box-shadow: none;
  transform: none;
}

button.link-like:hover {
  color: var(--indigo-700);
  background: transparent;
  box-shadow: none;
  transform: none;
}

/* ── Forms ────────────────────────────────────── */
label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--slate-600);
  margin-bottom: 0.375rem;
}

input, select, textarea {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
  background: #fff;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--slate-800);
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--indigo-600);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin-bottom: 0;
  accent-color: var(--indigo-600);
}

input[type="file"] {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
  background: var(--slate-50);
  color: var(--slate-600);
  padding: 0.375rem 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
}

input[type="file"]::file-selector-button,
input[type="file"]::-webkit-file-upload-button {
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
  background: #fff;
  color: var(--slate-700);
  padding: 0.375rem 0.625rem;
  margin-right: 0.625rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s ease;
}

input[type="file"]:hover::file-selector-button,
input[type="file"]:hover::-webkit-file-upload-button {
  background: var(--slate-100);
  box-shadow: none;
}

.form-card { max-width: 680px; }

.form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.form-actions > * { margin: 0; }
.form-actions form, .form-actions .button_to { margin: 0; }
.form-actions .button_to button,
.form-actions .button_to input[type="submit"] { margin: 0; }

.form-actions-vertical { flex-direction: column; align-items: stretch; }
.form-actions-vertical > * { width: 100%; }
.form-actions-vertical .button_to { width: 100%; }
.form-actions-vertical .button_to button,
.form-actions-vertical .button_to input[type="submit"] { width: 100%; }

/* ── Flash ────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--slate-200);
  background: #fff;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--slate-700);
}

.flash.notice {
  border-color: var(--emerald-200);
  background: var(--emerald-50);
  color: var(--emerald-700);
}

.flash.alert {
  border-color: var(--red-200);
  background: var(--red-50);
  color: var(--red-700);
}

.toast-stack {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 80;
  display: grid;
  gap: 0.5rem;
  width: min(400px, calc(100vw - 2.5rem));
}

.toast { box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1); }

/* ── Progress ─────────────────────────────────── */
.progress-track {
  background: var(--slate-100);
  border-radius: 999px;
  overflow: hidden;
  height: 6px;
  margin-top: 0.5rem;
}

.progress-fill,
.progress-bar-fill {
  background: var(--indigo-600);
  height: 100%;
  transition: width 220ms ease-out;
}

/* ── Course grid ──────────────────────────────── */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.course-grid-stacked { grid-template-columns: 1fr; }

.course-card-footer {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.course-card-actions { justify-content: flex-end; }

.course-code {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  background: var(--indigo-50);
  color: var(--indigo-700);
  font-size: 0.6875rem;
  font-weight: 600;
  border: 1px solid var(--indigo-200);
}

/* ── KPI row ──────────────────────────────────── */
.kpi-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.kpi {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--slate-600);
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 0.375rem 0.625rem;
}

.kpi strong { color: var(--slate-800); }

/* ── Alert box ────────────────────────────────── */
.alert-box {
  border-left: 3px solid var(--amber-600);
  background: var(--amber-50);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 0.75rem 0.875rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--amber-700);
}

.alert-list { margin: 0.375rem 0 0; padding-left: 1rem; }

/* ── Inline meta / muted ──────────────────────── */
.inline-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--slate-500);
  flex-wrap: wrap;
  font-size: 0.8125rem;
}

.muted { color: var(--slate-500); font-size: 0.8125rem; }

/* ── Action buttons ───────────────────────────── */
.action-buttons {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.action-buttons > * { flex: 0 0 auto; }
.action-buttons .button_to { margin: 0; flex: 0 0 auto; }

.users-action-col,
.users-action-cell { width: 280px; min-width: 280px; }
.users-action-cell { vertical-align: middle; }

/* ── Header row ───────────────────────────────── */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* ── Tabs ─────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--slate-200);
  overflow-x: auto;
  background: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
}

.tab-link {
  text-decoration: none;
  color: var(--slate-500);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 0.875rem;
  border-radius: 0;
  white-space: nowrap;
  transition: color 0.1s ease;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-link:hover { color: var(--slate-700); background: none; }

.tab-link.is-active {
  color: var(--indigo-600);
  border-bottom-color: var(--indigo-600);
  background: none;
  box-shadow: none;
}

/* ── Exam ─────────────────────────────────────── */
.exam-question-panel { display: none; }
.exam-question-panel.is-active { display: block; }

.exam-question-nav { display: flex; flex-wrap: wrap; gap: 0.375rem; }

.exam-question-pill {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--slate-200);
  background: var(--slate-100);
  color: var(--slate-600);
  font-weight: 500;
  font-size: 0.8125rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background 0.1s ease;
}

.exam-question-pill.is-open {
  background: #fff;
  border: 2px dashed var(--slate-300);
  color: var(--slate-400);
}
.exam-question-pill.is-active {
  background: var(--indigo-600);
  border: 2px solid var(--indigo-700);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 0 3px var(--indigo-100);
}
.exam-question-pill.is-answered {
  background: var(--emerald-500);
  border: 2px solid var(--emerald-600);
  color: #fff;
}

/* Exam progress bar */
.exam-progress-bar { margin-bottom: 0.25rem; }
.exam-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--slate-600);
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.exam-progress-legend {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8125rem;
  color: var(--slate-500);
}
.exam-legend-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}
.exam-legend-dot.is-answered { background: var(--emerald-500); }
.exam-legend-dot.is-open { background: #fff; border: 2px dashed var(--slate-300); }
.exam-progress-track {
  height: 6px;
  background: var(--slate-100);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.exam-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--emerald-500);
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* ── Module Wizard ───────────────────────────── */
.module-wizard-panel {
  display: none;
}
.module-wizard-panel.is-active {
  display: block;
}

.module-step-dots {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}
.module-step-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--slate-100);
  color: var(--slate-400);
  border: 2px dashed var(--slate-300);
  cursor: default;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  flex-shrink: 0;
}
.module-step-dot.is-done {
  background: var(--emerald-500);
  color: #fff;
  border-style: solid;
  border-color: var(--emerald-500);
}
.module-step-dot.is-current {
  background: var(--indigo-600);
  color: #fff;
  border-style: solid;
  border-color: var(--indigo-600);
  box-shadow: 0 0 0 3px var(--indigo-100);
}
.module-step-dot.is-exam {
  background: var(--slate-200);
  color: var(--slate-500);
  border-style: solid;
  border-color: var(--slate-300);
}

.module-wizard-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--slate-100);
}

/* ── Modal ────────────────────────────────────── */
.exam-result-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.exam-result-modal-card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: var(--radius-2xl);
  border: 1px solid var(--slate-200);
  padding: 1.5rem;
}

.exam-result-modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--slate-900);
}

.exam-result-modal-message {
  margin: 0;
  color: var(--slate-500);
  font-size: 0.875rem;
  line-height: 1.6;
}

.exam-result-modal-actions {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── Button loading ───────────────────────────── */
.button-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  cursor: wait;
  pointer-events: none;
}

.button-loading::after {
  content: " ";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-left: 0.4rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-right-color: transparent;
  animation: spin 600ms linear infinite;
  vertical-align: middle;
}

.btn-secondary.button-loading::after,
.ghost-button.button-loading::after {
  border-color: rgba(71, 85, 105, 0.4);
  border-right-color: transparent;
}

/* ── Skeleton ─────────────────────────────────── */
.skeleton-card {
  padding: 1.25rem;
  border-radius: var(--radius-2xl);
  background: #fff;
  border: 1px solid var(--slate-200);
}

.skeleton-line,
.skeleton-pill {
  background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-50) 37%, var(--slate-100) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.2s ease-in-out infinite;
}

.skeleton-line { height: 12px; border-radius: 6px; margin-bottom: 10px; }
.skeleton-line-short { width: 140px; }
.skeleton-line-long  { width: 240px; }
.skeleton-pill { width: 80px; height: 22px; border-radius: 999px; }

/* ── PDF viewer ───────────────────────────────── */
.pdf-viewer-shell { width: 100%; }
.pdf-viewer-scroll { height: 560px; overflow-y: auto; padding-right: 2px; }

/* ── Icons ────────────────────────────────────── */
.icon-svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
}

/* ── Page transition ──────────────────────────── */
.page-transition { animation: page-enter 150ms ease-out both; }

.toast-enter { animation: toast-enter 150ms ease-out; }
.toast-leave { animation: toast-leave 150ms ease-in forwards; }
.item-enter  { animation: item-enter 180ms ease-out; }
.item-leave  { animation: item-leave 160ms ease-in forwards; }
.question-transition { animation: question-enter 150ms ease-out; }

html[data-turbo-preview] .item-enter,
html[data-turbo-preview] .question-transition,
html[data-turbo-preview] .toast-enter,
html[data-turbo-preview] .toast-leave,
html[data-turbo-preview] .page-transition {
  animation: none !important;
  transition: none !important;
}

/* ── Keyframes ────────────────────────────────── */
@keyframes page-enter {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes question-enter {
  from { opacity: 0; transform: translateX(6px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes item-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes item-leave {
  from { opacity: 1; transform: translateX(0); max-height: 220px; }
  to   { opacity: 0; transform: translateX(10px); max-height: 0; margin: 0; padding-top: 0; padding-bottom: 0; }
}

@keyframes toast-enter {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-leave {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(-4px); }
}

@keyframes skeleton-loading {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Mobile ───────────────────────────────────── */
@media (max-width: 768px) {
  .app-main { margin-left: 0; }

  .mobile-topbar { display: flex; }
  .hamburger-btn { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  }

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

  .app-main-inner { padding: 1.25rem; }
  .page-head { flex-direction: column; }

  .toast-stack {
    right: 0.75rem;
    width: min(400px, calc(100vw - 1.5rem));
  }
}

.hover-row:hover { background: var(--slate-50); }

/* Einklappbare Einstellungs-Bereiche */
.settings-section {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  margin-bottom: 0.75rem;
  background: #fff;
}
.settings-section > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.9rem 1rem;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--slate-800);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius-lg);
}
.settings-section > summary::-webkit-details-marker { display: none; }
.settings-section > summary::after {
  content: "\25BE";
  color: var(--slate-400);
  transition: transform 0.15s ease;
}
.settings-section[open] > summary::after { transform: rotate(180deg); }
.settings-section > summary:hover { background: var(--slate-50); }
.settings-body { padding: 0.25rem 1rem 1.1rem; }
.settings-body > label:first-child { margin-top: 0; }

/* Global search in sidebar */
.sidebar-search {
  padding: 0.6rem 0.75rem 0.5rem;
  border-bottom: 1px solid var(--slate-100);
  flex-shrink: 0;
}
.sidebar-search-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  height: 34px;
}
.sidebar-search-icon {
  position: absolute;
  left: 0.6rem;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  color: var(--slate-400);
  pointer-events: none;
}
.sidebar-search-input {
  width: 100%;
  height: 34px;
  line-height: 34px;
  background: var(--slate-100);
  border: 1.5px solid transparent;
  border-radius: 8px;
  font-size: 0.8125rem;
  color: var(--slate-800);
  padding: 0 0.75rem 0 2rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  box-sizing: border-box;
  vertical-align: middle;
}
.sidebar-search-input::placeholder { color: var(--slate-400); }
.sidebar-search-input:hover { background: var(--slate-200, #e2e8f0); }
.sidebar-search-input:focus {
  background: #fff;
  border-color: var(--indigo-400, #818cf8);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

/* Search results page */
.search-category-header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate-400);
  margin: 0 0 0.5rem;
}
.search-result-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s;
}
.search-result-row:hover { background: var(--slate-50); }
.search-result-icon {
  width: 30px; height: 30px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
}
.search-result-main { flex: 1; min-width: 0; }
.search-result-title { font-size: 0.875rem; font-weight: 500; color: var(--slate-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-sub { font-size: 0.78rem; color: var(--slate-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.upload-status {
  padding: 0.65rem 1rem;
  border-radius: var(--radius-xl);
  font-size: 0.875rem;
  border: 1px solid transparent;
}
.upload-status--uploading {
  background: var(--slate-50);
  border-color: var(--slate-200);
  color: var(--slate-600);
}
.upload-status--success {
  background: var(--emerald-50);
  border-color: var(--emerald-200);
  color: var(--emerald-700);
}
.upload-status--error {
  background: var(--red-50);
  border-color: var(--red-200);
  color: var(--red-700);
}

@media (prefers-reduced-motion: reduce) {
  .page-transition { animation: none !important; }
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
