:root {
  --bg: #f4f6f8;
  --bg-card: #ffffff;
  --bg-panel: #fafbfc;
  --border: #e5e9ee;
  --text: #161c24;
  --muted: #5c6873;
  --accent: #2f6fed;      /* primary blue */
  --accent-2: #7c5cff;    /* secondary violet (Required badge, brand mark) */
  --success: #16a34a;
  --warn: #b45309;
  --warn-bg: #fff7e6;
  --error: #dc2626;
  --shadow: 0 2px 8px rgba(16, 24, 40, .07);
  --shadow-md: 0 8px 22px rgba(16, 24, 40, .10);
  --topbar-bg: #0f1b33;
  --topbar-border: rgba(255, 255, 255, .08);
  --topbar-text: #e8edf7;
  --topbar-text-muted: rgba(232, 237, 247, .64);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--topbar-border);
  background: var(--topbar-bg);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--topbar-text); }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 9px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(47, 111, 237, .35);
}
.brand-text { font-weight: 600; letter-spacing: 1px; font-size: 14px; color: var(--topbar-text); }
.brand-text em { font-style: normal; color: #8fb3ff; }
.nav { display: flex; align-items: center; gap: 20px; }
.nav a { color: var(--topbar-text-muted); text-decoration: none; font-size: 14px; transition: color .15s; }
.nav a:hover { color: #ffffff; }
.nav-user { color: var(--topbar-text-muted); font-size: 13px; }
.topbar .btn-ghost { color: var(--topbar-text-muted); border-color: transparent; }
.topbar .btn-ghost:hover { color: #ffffff; border-color: var(--topbar-border); background: rgba(255,255,255,.06); }

.container { flex: 1; width: 100%; max-width: 1000px; margin: 0 auto; padding: 28px 24px 60px; }
.footer { padding: 16px 24px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; text-align: center; background: var(--bg-card); }

h1 { font-size: 26px; margin: 8px 0 14px; font-weight: 700; letter-spacing: -.2px; }
h2 { font-size: 19px; margin: 22px 0 10px; font-weight: 600; }
.muted { color: var(--muted); }
.crumb { color: var(--muted); text-decoration: none; font-size: 13px; }
.crumb:hover { color: var(--accent); }
.inline { display: inline; }

a { color: var(--accent); }

.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); font-size: 14px; cursor: pointer; text-decoration: none;
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent); color: #ffffff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(47, 111, 237, .28);
}
.btn-primary:hover { background: #2559c4; border-color: #2559c4; color: #ffffff; filter: none; box-shadow: 0 4px 12px rgba(47, 111, 237, .34); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.alert { padding: 12px 16px; border-radius: 8px; margin: 12px 0; font-size: 14px; border: 1px solid; }
.alert-error { border-color: #f3c7c7; color: var(--error); background: #fdecec; }
.alert-warn { border-color: #f5dfb8; color: var(--warn); background: var(--warn-bg); }
.alert-info { border-color: #bcd4fb; color: var(--accent); background: #eaf1ff; }

.auth-card {
  max-width: 400px; margin: 60px auto; padding: 32px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-md);
  position: relative; overflow: hidden;
}
.auth-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.auth-card h1 { margin-top: 0; }
label { display: block; margin: 14px 0; font-size: 14px; color: var(--muted); }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 15px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,111,237,.12); }

.track { margin-bottom: 30px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.module-card {
  display: block; padding: 18px; border-radius: 12px; text-decoration: none; color: var(--text);
  background: var(--bg-card); border: 1px solid var(--border); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.module-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.module-card.is-complete { border-color: #bfe6cc; }
.module-card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.module-card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.module-card p { font-size: 13px; margin: 8px 0; }
.module-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 8px; }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.badge-required { background: #f1edff; color: var(--accent-2); border: 1px solid #ddd3ff; }
.badge-done { background: #e6f7ec; color: var(--success); border: 1px solid #bfe6cc; }
.badge-draft { background: var(--warn-bg); color: var(--warn); border: 1px solid #f5dfb8; }

.progressbar { height: 6px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progressbar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--success)); }

.lesson-list { padding-left: 22px; }
.lesson-list li { margin: 10px 0; }
.lesson-list li a { color: var(--text); text-decoration: none; }
.lesson-list li a:hover { color: var(--accent); }
.lesson-list li.is-done a { color: var(--muted); }

.lesson-content { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 26px 30px; box-shadow: var(--shadow); }
.lesson-content a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.lesson-content a:hover { border-bottom-color: var(--accent); }
.lesson-content img { max-width: 100%; }
.lesson-content code { background: var(--bg-panel); padding: 2px 6px; border-radius: 4px; }
.lesson-content pre { background: var(--bg-panel); padding: 14px; border-radius: 8px; overflow-x: auto; }
.lesson-content table { border-collapse: collapse; width: 100%; }
.lesson-content th, .lesson-content td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.lesson-actions { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }

/* Lesson stepper */
.lesson-meta-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.step-progress { height: 5px; background: var(--bg-panel); border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.step-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s ease; }
.step-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.step-tab {
  flex: 1 1 100px; text-align: center; padding: 9px 8px; border-radius: 8px; font-size: 12px;
  cursor: pointer; background: var(--bg-panel); color: var(--muted); border: 1px solid var(--border);
}
.step-tab.is-active { background: var(--accent); color: #ffffff; border-color: var(--accent); font-weight: 600; }
.step-panel { display: none; }
.step-panel.is-active { display: block; }
.step-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.step-dots { display: flex; gap: 6px; }
.step-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.step-dot.is-active { background: var(--accent); }

.quiz-box { margin-top: 26px; padding: 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.question { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin: 16px 0; background: var(--bg-panel); }
.question legend { font-weight: 600; padding: 0 6px; }
.option { display: flex; align-items: center; gap: 10px; margin: 8px 0; cursor: pointer; color: var(--text); }
.option input { width: auto; margin: 0; }

.result-card { text-align: center; padding: 30px; border-radius: 14px; margin-bottom: 26px; border: 1px solid var(--border); background: var(--bg-card); box-shadow: var(--shadow-md); }
.result-card.is-pass { border-color: #bfe6cc; }
.result-card.is-fail { border-color: #f3c7c7; }
.result-card .score { font-size: 46px; font-weight: 700; margin: 6px 0; }
.result-card.is-pass .score { color: var(--success); }
.result-card.is-fail .score { color: var(--error); }
.result-card .btn { margin: 6px 4px; }

.review-item { border-left: 3px solid var(--border); padding: 10px 16px; margin: 12px 0; }
.review-item.is-correct { border-left-color: var(--success); }
.review-item.is-wrong { border-left-color: var(--error); }
.review-prompt { font-weight: 600; }

.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin: 16px 0; box-shadow: var(--shadow); }
.form-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 160px; margin: 0; }
.form-row .btn { margin-bottom: 2px; }

.table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; }
.table th, .table td { border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.table tr.is-inactive td { color: var(--muted); text-decoration: line-through; }
.table .actions { white-space: nowrap; }
.temp-pass { font-size: 16px; color: var(--text); background: var(--bg-panel); padding: 3px 8px; border-radius: 6px; }

/* Department picker */
.dept-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0; }
.dept-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 20px 10px; border: 2px solid var(--border); border-radius: 12px; cursor: pointer;
  text-align: center; background: var(--bg-card); transition: border-color .15s, box-shadow .15s;
}
.dept-tile:hover { border-color: var(--accent); }
.dept-tile:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.dept-tile input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dept-tile-icon {
  width: 40px; height: 40px; border-radius: 50%; background: var(--bg-panel);
  display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; color: var(--muted);
}
.dept-name { font-size: 14px; font-weight: 600; }
.dept-sub { font-size: 12px; }
.dept-tile.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,111,237,.12); }
.dept-tile.is-selected .dept-tile-icon { background: var(--accent); color: #ffffff; }
.dept-tile-check {
  position: absolute; top: 8px; right: 8px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: #ffffff; font-size: 11px; line-height: 18px; font-weight: 700;
}
.dept-extras { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 6px; }
.dept-extras-label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; margin: 0 0 10px; }
.dept-extra-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 14px; cursor: pointer; }
.dept-extra-row input { width: auto; margin: 0; }
