*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --orange: #E8440A;
  --orange-dark: #C33A08;
  --orange-light: #FDE8E0;
  --beige: #F2EDE8;
  --beige-dark: #E8E0D8;
  --text: #1A1A1A;
  --text-muted: #6B6560;
  --white: #FFFFFF;
  --success: #16A34A;
  --success-bg: #DCFCE7;
  --fail: #DC2626;
  --fail-bg: #FEE2E2;
  --pending: #CA8A04;
  --pending-bg: #FEF9C3;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--beige);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Header ── */
.header {
  background: #fff;
  border-bottom: 1px solid #EDE5DC;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 6px rgba(232,68,10,0.07);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-brand {
  text-decoration: none;
  display: flex; flex-direction: column; line-height: 1.2;
}
.header-brand-main { font-size: 15px; font-weight: 800; color: var(--orange); letter-spacing: -0.3px; }
.header-brand-sub { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.header-logo { height: 38px; width: auto; display: block; }

.header-divider { width: 1px; height: 28px; background: #EDE5DC; }

.header-page { font-size: 13px; font-weight: 600; color: var(--text-muted); }

.header-right { display: flex; align-items: center; gap: 10px; }
.header-unit {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.3;
}
.header-unit strong { display: block; color: var(--text); font-size: 13px; font-weight: 700; }

/* ── Main ── */
.main { padding: 20px 16px 40px; max-width: 680px; margin: 0 auto; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--orange);
  color: var(--white);
  width: 100%;
}
.btn-primary:hover { background: var(--orange-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  background: transparent;
  color: var(--orange);
  border: 1.5px solid var(--orange);
}
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 8px; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  padding: 6px 12px;
}
.btn-ghost:hover { color: var(--orange); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

/* ── Progress Bar ── */
.progress-wrap { margin: 8px 0 4px; }
.progress-bar {
  height: 10px;
  background: var(--beige-dark);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), #FF6B35);
  border-radius: 99px;
  transition: width 0.6s ease;
}
.progress-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
}
.progress-count { font-weight: 700; color: var(--orange); font-size: 20px; }

/* ── Task List ── */
.task-list { list-style: none; }
.task-item {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.15s, transform 0.15s;
  border: 1.5px solid transparent;
}
.task-item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.task-item.locked { opacity: 0.45; pointer-events: none; }
.task-item.done { border-color: var(--success); }
.task-item.fail { border-color: var(--fail); }

.task-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--beige-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--text-muted);
}
.task-item.done .task-num { background: var(--success-bg); color: var(--success); }
.task-item.fail .task-num { background: var(--fail-bg); color: var(--fail); }
.task-item.active .task-num { background: var(--orange-light); color: var(--orange); }

.task-info { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 14px; }
.task-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  flex-shrink: 0;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.badge-done { background: var(--success-bg); color: var(--success); }
.badge-fail { background: var(--fail-bg); color: var(--fail); }
.badge-active { background: var(--orange-light); color: var(--orange); }
.badge-locked { background: var(--beige-dark); color: var(--text-muted); }
.badge-minitest { background: #EEF2FF; color: #4338CA; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--beige-dark);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: var(--white);
  color: var(--text);
  transition: border-color 0.15s;
  outline: none;
}
.form-input:focus, .form-textarea:focus { border-color: var(--orange); }
.form-textarea { resize: vertical; min-height: 100px; }

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--beige);
}
.login-card {
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .brand { font-size: 20px; font-weight: 800; color: var(--orange); }
.login-logo .sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }

/* ── Alert ── */
.alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: var(--fail-bg); color: var(--fail); }
.alert-success { background: var(--success-bg); color: var(--success); }

/* ── Divider ── */
.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 24px 0 12px;
}

/* ── Loading ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Minitest badge on task ── */
.task-group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 0 8px;
}

/* ── Back button ── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 16px;
  padding: 4px 0;
}
.back-btn:hover { color: var(--orange); }

/* ── Video embed ── */
.video-wrap {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 12px 0;
  aspect-ratio: 16/9;
}
.video-wrap iframe { width: 100%; height: 100%; border: none; }
.video-link-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--beige);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  border: 1.5px solid var(--beige-dark);
  margin: 12px 0;
  transition: border-color 0.15s;
}
.video-link-btn:hover { border-color: var(--orange); color: var(--orange); }
.video-icon { font-size: 24px; }

/* ── Status summary ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-box .num { font-size: 26px; font-weight: 800; color: var(--orange); }
.stat-box .lbl { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Footer ── */
.footer {
  background: #0E0E0E;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 24px 20px;
  text-align: center;
  font-size: 13px;
  color: #555;
  margin-top: 40px;
}
.footer a { color: var(--orange); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ── Module Cards ── */
.module-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 14px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
  text-decoration: none;
  display: block;
  color: var(--text);
}
.module-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--orange); }
.module-card.locked { opacity: 0.45; pointer-events: none; cursor: default; }

.module-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.module-num {
  font-size: 11px; font-weight: 800; color: var(--orange);
  text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0;
  background: var(--orange-light); padding: 3px 8px; border-radius: 6px;
  display: inline-block; text-align: center; min-width: 72px; width: fit-content;
}
.module-title { font-size: 16px; font-weight: 700; margin: 4px 0 2px; }
.module-desc { font-size: 13px; color: var(--text-muted); }

.module-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--beige-dark);
}
.module-stat {
  font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 4px;
}
.module-stat strong { color: var(--text); }

.module-progress { margin-top: 10px; }
.module-progress .progress-bar { height: 6px; }

/* ── Module detail page ── */
.video-section {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  color: white;
}
.video-section .label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: rgba(255,255,255,.6); margin-bottom: 6px; }
.video-section .title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }

.task-item-sm {
  background: var(--white);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--text);
  border: 1.5px solid transparent;
  transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.task-item-sm:hover { border-color: var(--orange); }
.task-item-sm.locked { opacity: .45; pointer-events: none; }
.task-item-sm.done { border-color: var(--success); }
.task-item-sm.fail { border-color: var(--fail); }

/* Responsive tweak for wider screens */
@media (min-width: 480px) {
  .main { padding: 28px 24px 60px; }
  .login-card { padding: 40px 36px; }
}
