:root {
  --bg: #f2f4f3;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7480;
  --line: #e3e7e6;
  --side: #1e2733;
  --side-2: #2a3542;
  --side-text: #c9d1da;
  --top-1: #2c5466;
  --top-2: #3d7486;
  --hero: #0f1720;
  --mint: #4fd1a5;
  --mint-dark: #2fae84;
  --brand: #2f7a73;
  --brand-soft: #e3f1ee;
  --gold: #e7c55a;
  --accent: #c8792c;
  --accent-soft: #fbefe2;
  --danger: #b4382f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 2px 8px rgba(16,24,40,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, textarea, select { font: inherit; }
a { color: var(--brand); }
.hidden { display: none !important; }
h1, h2, h3 { line-height: 1.25; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 270px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-text);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--mint), var(--top-2)); color: #fff; font-weight: 800; font-size: 18px; flex: none;
}
.brand b { color: #fff; display: block; font-size: 15px; }
.brand small { font-size: 11.5px; opacity: .75; }
.nav-sec { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; opacity: .55; margin: 16px 10px 6px; }
.nav-item {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left;
  background: none; border: 0; color: var(--side-text); padding: 9px 10px; border-radius: 10px; cursor: pointer;
  text-decoration: none; font-size: 14px;
}
.nav-item:hover { background: var(--side-2); }
.nav-item.active { background: var(--top-2); color: #fff; }
.nav-item .ico { width: 22px; text-align: center; flex: none; }
.nav-item .sub { display: block; font-size: 11.5px; opacity: .7; }
.nav-code {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; flex: none;
  color: #fff; font-size: 11.5px; font-weight: 700;
}
.nav-lessons { margin: 2px 0 6px 22px; border-left: 1px solid #3a4655; padding-left: 8px; }
.nav-lessons a { display: block; padding: 5px 8px; color: var(--side-text); font-size: 13px; text-decoration: none; border-radius: 8px; }
.nav-lessons a:hover { background: var(--side-2); }
.nav-lessons a.active { color: #fff; background: var(--side-2); }
.nav-lessons a .done { color: var(--mint); }
.class-switch {
  display: grid; gap: 4px; margin: 0 4px 6px; padding: 10px; border-radius: 10px;
  background: var(--side-2); font-size: 12px; color: var(--side-text);
}
.class-switch b { color: #fff; font-size: 13.5px; }
.class-switch select {
  width: 100%; padding: 7px 8px; border-radius: 8px; border: 1px solid #3a4655;
  background: var(--side); color: #fff; font-size: 13.5px;
}
.cpick { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 12px; background: #fff; margin: 0; }
.cpick legend { font-size: 13.5px; font-weight: 600; padding: 0 4px; }
.cgroup { padding: 6px 0; border-top: 1px dashed var(--line); }
.cgroup:first-of-type { border-top: 0; }
.cgroup .cg { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.cgroup .cls { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0 0 22px; }
.cgroup .cls label { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.ctags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.cedit { display: inline-block; }
.cedit[open] { display: block; width: 100%; margin-top: 8px; }
.cedit > summary { list-style: none; }
.cedit > summary::-webkit-details-marker { display: none; }
.cedit-in { display: grid; gap: 8px; margin-top: 8px; justify-items: start; }
.cedit-in .cpick { width: 100%; }
.side .me { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid #344050; font-size: 12.5px; }
.side .me .btn { margin-top: 8px; background: var(--side-2); color: #fff; border-color: #3a4655; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: linear-gradient(110deg, var(--top-1), var(--top-2)); color: #fff;
  padding: 18px 24px; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 21px; }
.topbar .tsub { font-size: 13px; opacity: .85; }
.topbar .menu-btn { display: none; background: rgba(255,255,255,.15); border: 0; color: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px; padding: 6px 12px; text-align: center; min-width: 74px;
}
.stat b { display: block; font-size: 17px; }
.stat span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 24px 40px; flex: 1; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .topbar { padding: 14px 16px; }
  .topbar .menu-btn { display: inline-block; }
  main { padding: 16px; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 17px; }
.meta { color: var(--muted); font-size: 13px; }
.eyebrow { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: var(--brand); }
.section-title { margin: 2px 0 2px; font-size: 21px; }
.grid2 { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* Welcome */
.welcome { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: center; }
.welcome .name { font-size: 24px; font-weight: 800; margin: 2px 0; }
.chipbox { border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; font-size: 13px; }
.chipbox small { display: block; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.chipbox.gold { background: #fdf6dc; border-color: #f0dc95; color: #8a6a12; font-weight: 600; }

/* Hero */
.hero {
  background: radial-gradient(1200px 400px at 0% 0%, #1d2b38 0%, var(--hero) 60%);
  color: #fff; border-radius: 22px; padding: 30px; margin-bottom: 18px;
  display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; align-items: end;
}
.hero .badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--gold); background: rgba(231,197,90,.12); border: 1px solid rgba(231,197,90,.3); padding: 4px 10px; border-radius: 8px; }
.hero h2 { font-size: clamp(28px, 4.2vw, 44px); margin: 14px 0 10px; letter-spacing: -.02em; }
.hero h2 span { color: var(--mint); display: block; }
.hero p { color: #c3ccd6; margin: 0 0 18px; max-width: 560px; }
.hero .hstats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero .hbox { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 12px; padding: 12px 14px; }
.hero .hbox b { font-size: 24px; display: block; }
.hero .hbox.gold { background: rgba(231,197,90,.12); border-color: rgba(231,197,90,.3); }
.hero .hbox.gold b { color: var(--gold); }
.hero .hprog { grid-column: 1 / -1; }
.hero .hprog .bar { height: 8px; background: rgba(255,255,255,.12); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.hero .hprog .bar div { height: 100%; background: var(--mint); }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; padding: 22px; } }

/* Chapter rows */
.chap-row {
  display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 12px; text-decoration: none; color: inherit;
  border: 1px solid transparent;
}
.chap-row:hover { background: #f6f8f8; border-color: var(--line); }
.code {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 800; font-size: 14px;
}
.chap-row .t { font-weight: 700; }
.chap-row .s { font-size: 13px; color: var(--muted); }
.chap-row .arrow { margin-left: auto; color: #aab2bb; }
.big-stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; background: #f6f8f8; border-radius: 12px; padding: 12px; margin: 12px 0; }
.big-stats b { font-size: 22px; display: block; }
.big-stats span { font-size: 11px; color: var(--muted); }

/* Dark panel */
.dark-panel { background: var(--hero); color: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.dark-panel .eyebrow { color: var(--gold); }
.dark-panel h3 { font-size: 20px; margin: 4px 0 12px; }
.learn-item { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 12px 14px; margin-top: 8px; }
.learn-item b::before { content: "✓"; color: var(--mint); margin-right: 8px; }
.learn-item div { font-size: 13px; color: #aeb8c3; margin-left: 22px; }

/* Tiles */
.tile { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; margin: 0; }
.tile:hover { border-color: #c9d6d3; }
.tile .ti { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 21px; color: #fff; flex: none; }
.tile b { display: block; }

/* Module cards */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.mod-card {
  display: block; text-decoration: none; color: inherit; background: #fff;
  border: 1px solid var(--line); border-top: 4px solid var(--c, var(--brand)); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: transform .12s;
}
.mod-card:hover { transform: translateY(-2px); }
.mod-card .head { display: flex; gap: 12px; align-items: flex-start; }
.mod-card .head .code { width: 38px; height: 38px; background: var(--c); }
.mod-card h4 { margin: 0; font-size: 15px; }
.mod-card .vi { font-size: 12.5px; color: var(--muted); }
.mod-card p { font-size: 13px; color: var(--muted); margin: 10px 0; }
.mod-card .mfoot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.dots { letter-spacing: 2px; color: var(--c); }
.dots i { font-style: normal; color: #d6dbdf; }
.done-badge { color: var(--mint-dark); font-weight: 700; }

/* Lesson */
.hint {
  display: flex; gap: 10px; background: #eef6f4; border: 1px solid #cfe5df; border-radius: 12px;
  padding: 10px 14px; font-size: 13.5px; margin-bottom: 16px; color: #2c5c55;
}
.focus-box { border-left: 4px solid var(--brand); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: #f0f3f3; border: 1px solid var(--line); }
.lesson-body { font-size: 16.5px; line-height: 1.85; }
.lesson-body h2 { font-size: 19px; margin: 22px 0 6px; color: var(--top-1); }
.lesson-body p { margin: 0 0 14px; }
.tr {
  position: relative; border-bottom: 1.5px dashed #8fb9b0; cursor: help; outline: none;
}
.tr:hover, .tr:focus { background: #e3f3ee; border-bottom-color: var(--brand); }
.tr:hover::after, .tr:focus::after {
  content: attr(data-vi);
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 20;
  background: #1e2733; color: #fff; font-size: 14px; line-height: 1.45; font-weight: 500;
  padding: 8px 12px; border-radius: 10px; width: max-content; max-width: min(380px, 80vw);
  box-shadow: 0 8px 24px rgba(0,0,0,.2); white-space: normal;
}
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Generic UI ---------- */
.admin-box { border: 1px dashed var(--brand); background: var(--brand-soft); }
.admin-box > summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.form { display: grid; gap: 10px; margin-top: 12px; }
.form label { display: grid; gap: 4px; font-size: 14px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type=text], input[type=email], input[type=number], input[type=datetime-local], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff;
}
textarea { min-height: 80px; resize: vertical; }
textarea.tall { min-height: 260px; font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 9px; text-decoration: none; font-size: 14px; font-weight: 500;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.mint { background: var(--mint); border-color: var(--mint); color: #062a1f; font-weight: 700; }
.btn.dark { background: var(--hero); border-color: var(--hero); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: #e6c3c0; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.tag.closed { background: #eee; color: #555; }
.tag.final { background: var(--accent-soft); color: #8a4f17; }

.pinned .box {
  background: var(--accent-soft); border: 1px solid #efd3b4; border-left: 5px solid var(--accent);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px;
}
.pinned .box strong { color: #8a4f17; }
.pinned ul { margin: 6px 0 0; padding-left: 20px; }

.progress { height: 8px; background: #eee; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); width: 0%; transition: width .2s; }
.progress-text { font-size: 13px; color: var(--muted); }

.opt {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; margin-top: 6px;
}
.opt.final { border-color: var(--accent); background: var(--accent-soft); }
.opt .bar { height: 6px; background: #eee; border-radius: 99px; margin-top: 4px; overflow: hidden; }
.opt .bar > div { height: 100%; background: var(--brand); }
.opt .voters { font-size: 12px; color: var(--muted); }

.file-list { list-style: none; padding: 0; margin: 8px 0 0; }
.file-list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 4px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.file-list li:first-child { border-top: 0; }
.file-list .fi { width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; background: #f3eded; margin-right: 8px; }
audio { width: 100%; max-width: 420px; }

/* Footer */
.foot { background: var(--hero); color: #b8c2cc; padding: 30px 24px 20px; font-size: 13.5px; }
.foot .cols { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.foot h4 { color: #fff; margin: 0 0 8px; font-size: 14.5px; }
.foot ul { margin: 0; padding-left: 16px; }
.disclaimer {
  max-width: 1180px; margin: 22px auto 0; border: 1px solid #6b5a1e; background: rgba(231,197,90,.06);
  border-radius: 12px; padding: 12px 16px; color: #e8d9a4; font-size: 12.5px; white-space: pre-line;
}
.copy { max-width: 1180px; margin: 16px auto 0; font-size: 12px; opacity: .6; }
@media (max-width: 860px) { .foot .cols { grid-template-columns: 1fr; } }

/* Video modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal .inner { width: 100%; max-width: 1000px; }
.modal .bar-top { display: flex; justify-content: space-between; color: #fff; margin-bottom: 8px; gap: 10px; }
.player { position: relative; background: #000; border-radius: 10px; overflow: hidden; user-select: none; }
.player video { width: 100%; max-height: 80vh; display: block; }
.watermark {
  position: absolute; pointer-events: none; color: rgba(255,255,255,.35);
  font-size: 14px; font-weight: 600; transition: top 1.5s, left 1.5s; white-space: nowrap;
  text-shadow: 0 0 2px rgba(0,0,0,.6);
}

/* ---------- Bảo vệ nội dung (học viên) ---------- */
body.protect { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.protect input, body.protect textarea { -webkit-user-select: text; user-select: text; }
.wm-layer { position: fixed; inset: 0; pointer-events: none; z-index: 45; background-repeat: repeat; }
.shield {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; text-align: center;
  background: rgba(15,23,32,.92); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); color: #fff; padding: 20px;
}
@media print {
  body.protect > * { display: none !important; }
  body.protect::after { content: "Nội dung khoá học không được phép in."; display: block; padding: 40px; font-size: 20px; }
}

.center-box { min-height: 90vh; display: grid; place-items: center; text-align: center; padding: 16px; }
.center-box .card { max-width: 440px; }
.google-btn { font-size: 16px; padding: 12px 20px; }
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: #222; color: #fff; padding: 10px 16px; border-radius: 9px; z-index: 120; max-width: 90vw;
}
