:root {
  --brand: #f5821f;
  --brand-light: #ff9d47;
  --brand-dark: #d96a0a;
  --brand-soft: #fff2e4;
  --ink: #15110c;
  --muted: #6b6258;
  --border: #e7e0d6;
  --bg: #fbf9f6;
  --card: #ffffff;
  --green: #22a559;
  --blue: #2563eb;
  --red: #dc2626;
  --font-head: "Be Vietnam Pro", sans-serif;
  --font-body: "Inter", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
}

h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 800; letter-spacing: -0.01em; }

#app { min-height: 100vh; }

svg.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; }

@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(18px, -14px) scale(1.08); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.85); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- Dark "tech" panel base (hero, login bg) ---------- */
.dark-panel {
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(1px 1px at 20px 20px, rgba(255,255,255,.09) 1px, transparent 0),
    radial-gradient(1px 1px at 60px 60px, rgba(255,255,255,.07) 1px, transparent 0),
    radial-gradient(ellipse 620px 320px at 12% -10%, rgba(245,130,31,.38), transparent 60%),
    radial-gradient(ellipse 520px 280px at 105% 105%, rgba(37,99,235,.28), transparent 60%),
    linear-gradient(160deg, #121319 0%, #1b1d29 55%, #121319 100%);
  background-size: 42px 42px, 42px 42px, auto, auto, auto;
}
.dark-panel::before, .dark-panel::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(55px);
  opacity: .5;
  pointer-events: none;
  animation: blobFloat 11s ease-in-out infinite;
}
.dark-panel::before { width: 240px; height: 240px; background: var(--brand); top: -70px; right: -50px; }
.dark-panel::after { width: 200px; height: 200px; background: #3b82f6; bottom: -70px; left: 8%; animation-delay: -5s; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  position: relative;
  z-index: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 34px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,.04), 0 0 60px rgba(245,130,31,.15);
  animation: popIn .35s ease;
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-logo img { height: 36px; width: auto; border-radius: 8px; }
.login-logo .wordmark { font-family: var(--font-head); font-weight: 800; font-size: 19px; }
.login-logo .wordmark .brand { color: var(--brand); }
.login-card h1 {
  font-size: 19px;
  margin: 0 0 4px;
  color: var(--ink);
}
.login-card .sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 24px;
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--font-body);
  background: #fff;
}
.field input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 9999px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, background .15s, opacity .15s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand-light), var(--brand) 55%, var(--brand-dark));
  color: #fff;
  width: 100%;
  padding: 13px;
  box-shadow: 0 8px 20px rgba(245,130,31,.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(245,130,31,.45); }
.btn-primary:active { transform: translateY(0); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--ink); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost-dark { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); color: #fff; backdrop-filter: blur(6px); }
.btn-ghost-dark:hover { background: rgba(255,255,255,.18); }
.btn-danger { background: #fee2e2; color: var(--red); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.error-msg { background: #fee2e2; color: var(--red); padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.ok-msg { background: #e8f6ee; color: #15803d; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }

/* ---------- Top bar ---------- */
.topbar {
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand-block { display: flex; align-items: center; gap: 10px; }
.topbar .brand-block img { height: 32px; width: auto; border-radius: 7px; box-shadow: 0 0 0 3px #fff2e4; }
.topbar .brand-block .wordmark { font-family: var(--font-head); font-weight: 800; font-size: 16px; }
.topbar .brand-block .wordmark .brand { color: var(--brand); }
.topbar .brand-block .sub { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); font-family: var(--font-body); }
.topbar .right { display: flex; align-items: center; gap: 10px; }
.topbar .user-chip { font-size: 13px; color: var(--muted); }

.container { max-width: 1040px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------- Hero / progress panel ---------- */
.hero-panel {
  border-radius: 24px;
  padding: 28px 26px 24px;
  margin-bottom: 26px;
  animation: fadeUp .4s ease;
}
.hero-top { position: relative; z-index: 1; display: flex; align-items: center; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.hero-panel .ring {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff;
  background: conic-gradient(var(--brand-light) calc(var(--pct) * 1%), rgba(255,255,255,.12) 0);
  flex-shrink: 0;
  box-shadow: 0 0 26px rgba(245,130,31,.45);
}
.hero-panel .ring span { background: #16171f; color: #fff; width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-family: var(--font-body); font-weight: 700; }
.hero-panel h2 { margin: 0 0 4px; font-size: 17px; color: #fff; }
.hero-panel .hero-sub { margin: 0; font-size: 13px; color: rgba(255,255,255,.65); }

.topic-tabs { position: relative; z-index: 1; display: flex; gap: 8px; flex-wrap: wrap; }
.topic-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(6px);
  color: #fff;
  border-radius: 9999px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background .15s, transform .12s;
}
.topic-tab:hover { background: rgba(255,255,255,.16); }
.topic-tab .count { color: rgba(255,255,255,.6); font-weight: 500; }
.topic-tab.active { background: #fff; color: var(--ink); border-color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.topic-tab.active .count { color: var(--muted); }
.topic-tab svg { width: 15px; height: 15px; }

/* ---------- Dashboard ---------- */
.level-block { margin-bottom: 30px; animation: fadeUp .35s ease; }
.level-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.level-dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.level-head h3 { margin: 0; font-size: 15.5px; }
.level-head .count-badge { font-size: 11.5px; color: var(--muted); font-family: var(--font-body); font-weight: 500; padding: 2px 9px; border: 1px solid var(--border); border-radius: 20px; }

.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.lesson-card {
  --lc: var(--brand);
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--lc);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: box-shadow .18s, transform .18s, border-color .18s;
  position: relative;
}
.lesson-card:hover {
  box-shadow: 0 16px 32px color-mix(in srgb, var(--lc) 28%, transparent);
  transform: translateY(-3px);
}
.lesson-card .status {
  position: absolute; top: 14px; right: 14px;
  font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}
.status.done { background: #e8f6ee; color: #15803d; }
.status.todo { background: var(--bg); color: var(--muted); }
.lesson-card h4 { margin: 0 26px 8px 0; font-size: 14px; line-height: 1.4; font-family: var(--font-body); font-weight: 700; }
.lesson-card p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.lesson-card .score { margin-top: 10px; font-size: 12px; color: var(--brand-dark); font-weight: 700; }

/* ---------- Lesson view ---------- */
.lesson-header { margin-bottom: 18px; animation: fadeUp .3s ease; }
.back-link { color: var(--brand-dark); font-size: 13px; cursor: pointer; display: inline-block; margin-bottom: 10px; font-weight: 600; }
.lesson-header .kicker-chip {
  display: inline-flex; align-items: center; gap: 6px;
  color: #fff; background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
  padding: 4px 12px; border-radius: 20px; margin-bottom: 10px;
}
.lesson-header h2 { margin: 0 0 6px; font-size: 22px; }
.lesson-body { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 26px 28px; animation: fadeUp .35s ease; }
.lb-section { margin-bottom: 20px; }
.lb-section:last-child { margin-bottom: 0; }
.lb-label { display: flex; align-items: center; gap: 9px; font-family: var(--font-head); font-weight: 700; font-size: 13.5px; margin-bottom: 9px; color: var(--ink); }
.lb-icon {
  width: 26px; height: 26px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand-dark); flex-shrink: 0;
}
.lb-icon svg { width: 15px; height: 15px; }
.lb-text { margin: 0; font-size: 14.5px; line-height: 1.75; color: var(--ink); padding-left: 35px; }
.lb-prompt-wrap { position: relative; padding-left: 35px; }
.lb-prompt {
  background: var(--brand-soft);
  border: 1px solid #f6d9b8;
  border-radius: 12px;
  padding: 14px 44px 14px 16px;
  font-size: 13.5px;
  line-height: 1.7;
  font-style: italic;
  color: #7a4108;
  margin: 0;
}
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid #f6d9b8; background: #fff; color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.copy-btn:hover { background: var(--brand-soft); }
.copy-btn svg { width: 14px; height: 14px; }
.lb-note-wrap { padding-left: 35px; }
.lb-note {
  background: #fff7ed;
  border-left: 3px solid var(--brand);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.7;
  margin: 0;
}

.quiz-box { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 26px 28px; margin-top: 20px; animation: fadeUp .4s ease; }
.quiz-box h3 { margin: 0 0 18px; font-size: 15.5px; }
.quiz-q { margin-bottom: 20px; }
.quiz-q p.qtext { font-weight: 700; margin: 0 0 10px; font-size: 14px; font-family: var(--font-body); }
.quiz-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px;
  margin-bottom: 8px; cursor: pointer; font-size: 13.5px;
  transition: border-color .12s, background .12s, transform .1s;
}
.quiz-opt:hover { background: var(--bg); }
.quiz-opt .opt-letter {
  width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; color: var(--muted);
}
.quiz-opt .opt-text { flex: 1; }
.quiz-opt .opt-icon { width: 18px; height: 18px; flex-shrink: 0; display: none; }
.quiz-opt .opt-icon svg { width: 100%; height: 100%; }
.quiz-opt.selected { border-color: var(--brand); background: var(--brand-soft); }
.quiz-opt.selected .opt-letter { background: var(--brand); border-color: var(--brand); color: #fff; }
.quiz-opt.correct { border-color: #16a34a; background: #e8f6ee; }
.quiz-opt.correct .opt-letter { background: #16a34a; border-color: #16a34a; color: #fff; }
.quiz-opt.correct .opt-icon.icon-check { display: flex; color: #16a34a; }
.quiz-opt.wrong { border-color: var(--red); background: #fee2e2; }
.quiz-opt.wrong .opt-letter { background: var(--red); border-color: var(--red); color: #fff; }
.quiz-opt.wrong .opt-icon.icon-x { display: flex; color: var(--red); }
.quiz-result {
  margin-top: 16px; padding: 16px 18px; border-radius: 14px;
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, #fff7ed, #fff);
  border: 1px solid #f6d9b8;
  animation: popIn .3s ease;
}
.quiz-result .result-icon {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 6px 16px rgba(245,130,31,.4);
}
.quiz-result .result-icon svg { width: 22px; height: 22px; }
.quiz-result .result-text { font-weight: 700; font-size: 14.5px; }
.quiz-result .result-text small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- Admin ---------- */
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 22px; }
.admin-stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px;
}
.admin-stat-card .num { font-family: var(--font-head); font-weight: 800; font-size: 24px; color: var(--brand-dark); }
.admin-stat-card .label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.admin-table th, .admin-table td { padding: 12px 14px; text-align: left; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.admin-table th { background: var(--bg); font-weight: 700; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; font-family: var(--font-body); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #fffaf4; }
.name-cell { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
  color: #fff; font-size: 11.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.pill { font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 700; }
.pill.admin { background: #f3e8ff; color: #7e22ce; }
.pill.nhanvien { background: #dbeafe; color: var(--blue); }
.bar-bg { width: 100px; height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-light), var(--brand)); }

.modal-overlay { position: fixed; inset: 0; background: rgba(21,17,12,0.55); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-card { background: #fff; border-radius: 18px; padding: 26px; width: 100%; max-width: 380px; animation: popIn .2s ease; }
.modal-card h3 { margin: 0 0 16px; font-size: 16px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }

@media (max-width: 600px) {
  .container { padding: 20px 14px 50px; }
  .lesson-body, .quiz-box { padding: 18px 18px; }
  .lb-text, .lb-prompt-wrap, .lb-note-wrap { padding-left: 0; margin-top: 6px; }
  .hero-top { gap: 14px; }
}
