:root {
  --bg: #f3f6fa; --surface: #ffffff; --surface-2: #f7f9fc; --line: #e1e7ef; --line-2: #c9d3df;
  --ink: #182838; --ink-2: #44546a; --muted: #75839a;
  --brand: #0055af; --brand-2: #003b7e; --brand-3: #0a9be8; --brand-soft: #e7f0fb; --brand-ink: #ffffff;
  --ok: #0a7d42; --ok-soft: #e3f5ea; --warn: #9a5b00; --warn-soft: #fff3dc; --bad: #c22f2f; --bad-soft: #fde9e9;
  --gold: #b7791f; --gold-soft: #fdf3dd;
  --radius: 14px; --shadow: 0 1px 2px rgba(24,40,56,.06), 0 4px 14px rgba(24,40,56,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1319; --surface: #161d25; --surface-2: #1b232d; --line: #27313d; --line-2: #36424f;
    --ink: #e9eff5; --ink-2: #b7c3d0; --muted: #8796a8;
    --brand: #4d9cf0; --brand-2: #8cc0f6; --brand-3: #46b8f5; --brand-soft: #142a43; --brand-ink: #06121e;
    --ok: #4cc47f; --ok-soft: #123222; --warn: #f0b54a; --warn-soft: #33270f; --bad: #f07a7a; --bad-soft: #3a1717;
    --gold: #e6b450; --gold-soft: #33280f; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font); }
a { color: var(--brand); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .tiny { font-size: .78rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- khung ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 8px 16px; min-height: 58px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo img { height: 30px; width: auto; }
.logo .sub { font-size: .72rem; font-weight: 700; color: var(--brand); letter-spacing: .06em; text-transform: uppercase; border-left: 1px solid var(--line-2); padding-left: 10px; line-height: 1.2; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { text-decoration: none; color: var(--ink-2); padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: .93rem; }
.nav a.on, .nav a:hover { background: var(--brand-soft); color: var(--brand); }
.userbtn { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: .9rem; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; right: 16px; top: 54px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 210px; z-index: 40; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 8px; color: var(--ink); text-decoration: none; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-2); }
main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 96px; }
.tabbar { display: none; }
@media (max-width: 820px) {
  .nav { display: none; }
  .userbtn { margin-left: auto; }
  .logo .sub { display: none; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 600; padding: 4px 0; border-radius: 10px; }
  .tabbar a .i { display: block; font-size: 1.25rem; line-height: 1.3; }
  .tabbar a.on { color: var(--brand); background: var(--brand-soft); }
  h1 { font-size: 1.35rem; }
}

/* ---------- thành phần ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
.grid > .card { margin-top: 0; }
.stack > * + * { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 820px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .g2 { grid-template-columns: minmax(0, 1fr); } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); padding: 10px 16px; border-radius: 11px; font-weight: 650; cursor: pointer; text-decoration: none; min-height: 44px; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.sm { min-height: 34px; padding: 5px 11px; font-size: .88rem; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-3)); border-radius: 999px; transition: width .4s; }
.bar.ok > i { background: var(--ok); }
label.f { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 12px; }
label.f > span { display: block; margin-bottom: 5px; }
input.in, select.in, textarea.in { width: 100%; padding: 11px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); min-height: 44px; }
input.in:focus, select.in:focus, textarea.in:focus { outline: 2px solid var(--brand-3); outline-offset: 0; border-color: transparent; }
.err { color: var(--bad); font-weight: 600; font-size: .92rem; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; z-index: 60; box-shadow: var(--shadow); max-width: calc(100% - 32px); font-weight: 600; }
.toast.bad { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.tablewrap table.t tr:last-child td { border-bottom: 0; }

/* ---------- đăng nhập ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent), var(--bg); }
.login .card { width: 100%; max-width: 420px; padding: 28px 24px; }
.login .logo-big { display: block; width: 240px; max-width: 80%; margin: 0 auto 6px; }
.login h1 { text-align: center; font-size: 1.2rem; color: var(--brand-2); margin-top: 10px; }
.login .lead { text-align: center; color: var(--muted); font-size: .92rem; }

/* ---------- tổng quan ---------- */
.hero { background: linear-gradient(135deg, var(--brand-2), var(--brand) 55%, var(--brand-3)); color: #fff; border-radius: 18px; padding: 22px; display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; box-shadow: var(--shadow); }
.hero h1 { color: #fff; margin-bottom: 4px; }
.hero p { color: rgba(255,255,255,.88); margin: 0 0 12px; }
.hero .btn { background: #fff; color: var(--brand-2); border-color: #fff; }
@media (max-width: 560px) { .hero { grid-template-columns: 1fr; } .hero .ring { justify-self: start; } }
.ring { --p: 0; width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255,255,255,.22) 0); }
.ring > div { width: 88px; height: 88px; border-radius: 50%; background: var(--brand); display: grid; place-items: center; text-align: center; color: #fff; font-weight: 800; font-size: 1.5rem; line-height: 1; }
.ring small { display: block; font-size: .62rem; font-weight: 600; opacity: .85; margin-top: 3px; }
.ring.dark { background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--line) 0); }
.ring.dark > div { background: var(--surface); color: var(--ink); }
.ring.dark.ok { background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--line) 0); }
.stat { padding: 14px 16px; }
.stat .v { font-size: 1.55rem; font-weight: 800; color: var(--brand-2); font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .l { font-size: .82rem; color: var(--muted); font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stat .v { color: var(--brand-2); } }
.mod { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.mod:last-child { border-bottom: 0; }
.mod .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); font-size: 1.3rem; }
.mod .ttl { font-weight: 700; line-height: 1.3; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.badge { text-align: center; padding: 10px 6px; border-radius: 12px; border: 1px dashed var(--line-2); font-size: .74rem; color: var(--muted); line-height: 1.3; }
.badge .e { font-size: 1.7rem; display: block; filter: grayscale(1); opacity: .35; }
.badge.got { border-style: solid; border-color: var(--gold); background: var(--gold-soft); color: var(--ink); font-weight: 650; }
.badge.got .e { filter: none; opacity: 1; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 110px; padding-top: 8px; }
.chart .c { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.chart .c i { display: block; width: 100%; max-width: 26px; background: var(--brand); border-radius: 5px 5px 2px 2px; min-height: 2px; }
.chart .c i.zero { background: var(--line); }
.chart .c span { font-size: .62rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }

/* ---------- mục lục ---------- */
.module-card { padding: 0; overflow: hidden; }
.module-head { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; padding: 16px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.module-head .ic { width: 52px; height: 52px; border-radius: 14px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.5rem; }
.module-head .k { font-size: .75rem; color: var(--brand); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.lesson-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.lesson-row:last-child { border-bottom: 0; }
.lesson-row:hover:not(.locked) { background: var(--surface-2); }
.lesson-row .st { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .85rem; font-weight: 800; border: 2px solid var(--line-2); color: var(--muted); }
.lesson-row.done .st { background: var(--ok); border-color: var(--ok); color: #fff; }
.lesson-row.cur .st { border-color: var(--brand); color: var(--brand); }
.lesson-row.locked { opacity: .55; cursor: not-allowed; }
.lesson-row.quiz .st { border-radius: 8px; }

/* ---------- bài học ---------- */
.lesson-wrap { max-width: 760px; margin: 0 auto; }
.crumb { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.crumb a { color: var(--muted); }
.lesson-meta { position: sticky; top: 58px; z-index: 20; background: var(--bg); padding: 8px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .85rem; }
.lesson-meta .bar { flex: 1; min-width: 120px; }
.goal { background: var(--brand-soft); border-radius: 12px; padding: 12px 14px; font-size: .95rem; margin-bottom: 18px; }
.goal b { color: var(--brand); }
.blk { margin: 0 0 18px; }
.blk h2 { margin-top: 26px; padding-top: 4px; }
.blk ul, .blk ol { padding-left: 1.3em; margin: 0 0 .8em; }
.blk li { margin-bottom: .35em; }
mark { background: #fff1a8; color: inherit; padding: 0 2px; border-radius: 3px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) mark { background: #5a4a00; } }
.callout { border-radius: 12px; padding: 13px 15px 13px 46px; position: relative; border: 1px solid var(--line); background: var(--surface); }
.callout::before { position: absolute; left: 14px; top: 12px; font-size: 1.2rem; }
.callout .ct { font-weight: 800; margin-bottom: 3px; }
.callout p:last-child { margin-bottom: 0; }
.callout.tip { background: var(--brand-soft); border-color: transparent; } .callout.tip::before { content: "💡"; }
.callout.warn { background: var(--warn-soft); border-color: transparent; } .callout.warn::before { content: "⚠️"; }
.callout.say { background: var(--ok-soft); border-color: transparent; } .callout.say::before { content: "🗣️"; }
.callout.key { background: var(--gold-soft); border-color: transparent; } .callout.key::before { content: "🔑"; }
.callout.no { background: var(--bad-soft); border-color: transparent; } .callout.no::before { content: "⛔"; }
.flip { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.flip button { position: relative; min-height: 128px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; padding: 14px; text-align: left; box-shadow: var(--shadow); transition: background .2s; }
.flip button .f { font-weight: 750; color: var(--brand-2); font-size: 1.02rem; }
.flip button .b { display: none; font-size: .9rem; color: var(--ink-2); }
.flip button .hint { position: absolute; right: 10px; bottom: 6px; font-size: .7rem; color: var(--muted); }
.flip button.on { background: var(--brand-soft); }
.flip button.on .f { font-size: .82rem; color: var(--brand); }
.flip button.on .b { display: block; }
.check { border: 2px solid var(--brand); border-radius: 14px; padding: 16px; background: var(--surface); }
.check .k { font-size: .74rem; font-weight: 800; color: var(--brand); letter-spacing: .06em; text-transform: uppercase; }
.check .q { font-weight: 700; margin: 4px 0 10px; }
.opt { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; padding: 11px 13px; margin-bottom: 8px; border: 1px solid var(--line-2); border-radius: 11px; background: var(--surface); cursor: pointer; line-height: 1.45; }
.opt:hover { border-color: var(--brand); }
.opt .box { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-2); margin-top: 1px; display: grid; place-items: center; font-size: .75rem; font-weight: 800; }
.opt.multi .box { border-radius: 6px; }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); }
.opt.sel .box { border-color: var(--brand); background: var(--brand); color: #fff; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .box { border-color: var(--ok); background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.reveal { border: 2px dashed var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.fb.reveal-note { margin-top: 6px; background: var(--ok-soft); color: var(--ink, inherit); }
.opt.wrong .box { border-color: var(--bad); background: var(--bad); color: #fff; }
.fb { border-radius: 10px; padding: 10px 12px; font-size: .93rem; margin-top: 4px; }
.fb.ok { background: var(--ok-soft); } .fb.bad { background: var(--bad-soft); }
.scenario .ctx { background: var(--surface-2); border-left: 4px solid var(--brand-3); border-radius: 0 10px 10px 0; padding: 10px 12px; font-style: italic; margin-bottom: 10px; }
.steps { counter-reset: s; list-style: none; padding: 0 !important; }
.steps li { position: relative; padding: 0 0 14px 44px; margin: 0 !important; }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: .9rem; }
.steps li::after { content: ""; position: absolute; left: 14px; top: 32px; bottom: 2px; width: 2px; background: var(--line); }
.steps li:last-child::after { display: none; }
.steps li .sh { display: block; font-weight: 750; }
details.faq { border: 1px solid var(--line); border-radius: 11px; background: var(--surface); margin-bottom: 8px; }
details.faq summary { cursor: pointer; padding: 12px 14px; font-weight: 700; list-style: none; position: relative; padding-right: 36px; }
details.faq summary::after { content: "+"; position: absolute; right: 14px; top: 9px; font-size: 1.3rem; color: var(--brand); }
details.faq[open] summary::after { content: "–"; }
details.faq .a { padding: 0 14px 12px; color: var(--ink-2); }
.figure { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.figure { overflow-x: auto; }
.figure svg { width: 100%; height: auto; max-height: 520px; }
@media (max-width: 640px) { .figure svg.wide { min-width: 640px; } .figure .swipe { display: block; } }
.figure .swipe { display: none; font-size: .75rem; color: var(--muted); }
.figure .cap { font-size: .82rem; color: var(--muted); margin-top: 6px; }
.lesson-end { border-top: 1px solid var(--line); margin-top: 28px; padding-top: 18px; }
.ask textarea { min-height: 80px; }
.note { border-left: 3px solid var(--line-2); padding: 6px 10px; margin: 8px 0; font-size: .92rem; }
.note .ans { border-left: 3px solid var(--ok); padding-left: 10px; margin-top: 6px; }

/* ---------- công cụ ---------- */
.tool { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 16px; }
.tool h3 { display: flex; align-items: center; gap: 8px; }
.tool .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 12px; }
.tool .out { background: var(--brand-soft); border-radius: 12px; padding: 14px; margin-top: 4px; }
.tool .out .big { font-size: 1.5rem; font-weight: 800; color: var(--brand-2); }
.tool .out ol, .tool .out ul { margin: .3em 0 .3em 1.2em; padding: 0; }
.chain { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.chain .s { background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 6px 10px; font-size: .86rem; font-weight: 650; }
.chain .ar { color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 11px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface); padding: 8px 12px; cursor: pointer; font-weight: 600; font-size: .9rem; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand); color: #fff; }

/* ---------- làm bài ---------- */
.quiz-wrap { max-width: 760px; margin: 0 auto; }
.quiz-top { position: sticky; top: 58px; z-index: 20; background: var(--bg); padding: 10px 0; display: flex; gap: 12px; align-items: center; }
.timer { font-weight: 800; font-variant-numeric: tabular-nums; padding: 6px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.timer.low { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.qcard .qn { font-size: .8rem; font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: .05em; }
.qcard .qq { font-size: 1.08rem; font-weight: 700; margin: 6px 0 14px; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.palette button { height: 38px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 700; font-size: .85rem; }
.palette button.ans { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.palette button.cur { outline: 2px solid var(--brand); outline-offset: 1px; }
.palette button.flag { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.result-head { text-align: center; padding: 26px 18px; }
.result-head .ring { margin: 0 auto 10px; width: 132px; height: 132px; }
.result-head .ring > div { width: 104px; height: 104px; font-size: 1.9rem; }
.rv { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; background: var(--surface); }
.rv.ok { border-left: 5px solid var(--ok); } .rv.bad { border-left: 5px solid var(--bad); }
.rv .ex { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: .93rem; margin-top: 8px; }

/* ---------- chứng nhận ---------- */
.cert { background: #fff; color: #182838; border: 10px solid #0055af; outline: 2px solid #0a9be8; outline-offset: -18px; padding: 44px 40px; text-align: center; border-radius: 6px; max-width: 900px; margin: 0 auto; aspect-ratio: 1.414; display: flex; flex-direction: column; justify-content: center; position: relative; }
.cert img { width: 260px; max-width: 60%; margin: 0 auto 10px; }
.cert .t1 { font-size: .85rem; letter-spacing: .3em; text-transform: uppercase; color: #003b7e; font-weight: 700; }
.cert .t2 { font-size: 2.1rem; font-weight: 800; color: #0055af; margin: 8px 0; }
.cert .name { font-size: 2rem; font-weight: 800; margin: 12px 0 4px; border-bottom: 2px solid #c9d3df; display: inline-block; padding: 0 30px 4px; }
.cert .meta { font-size: .9rem; color: #44546a; margin-top: 18px; }
@media (max-width: 600px) { .cert { padding: 26px 16px; aspect-ratio: auto; } .cert .t2 { font-size: 1.4rem; } .cert .name { font-size: 1.4rem; } }
@media print {
  .topbar, .tabbar, .noprint { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .cert { border-width: 12px; max-width: none; width: 100%; height: 100vh; aspect-ratio: auto; }
  @page { size: A4 landscape; margin: 10mm; }
}

/* ---------- quản lý ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(10,20,30,.45); z-index: 50; }
.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(640px, 100%); background: var(--bg); z-index: 51; overflow-y: auto; padding: 18px 16px 40px; box-shadow: -8px 0 30px rgba(0,0,0,.18); }
.sortable th { cursor: pointer; user-select: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.pwbox { font-family: ui-monospace, Menlo, monospace; background: var(--gold-soft); padding: 2px 8px; border-radius: 6px; font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.searchbox { max-width: 360px; }

/* ---------- nhiều khóa, 2 kênh ---------- */
.viewbar { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: .85rem; padding: 6px 12px; }
.ccard { text-decoration: none; color: inherit; display: block; transition: transform .15s, box-shadow .15s; }
.ccard:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(24,40,56,.10); }
.ccard .ttl, .librow .ttl { font-weight: 800; font-size: 1.05rem; margin-top: 8px; line-height: 1.3; }
.cic { width: 46px; height: 46px; border-radius: 13px; background: var(--brand-soft); display: grid; place-items: center; font-size: 1.5rem; flex: none; }
.cl2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.librow { display: grid; grid-template-columns: 46px 1fr auto; gap: 14px; align-items: center; text-decoration: none; color: inherit; }
.librow .ttl { margin-top: 0; }
.trackpick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
@media (max-width: 480px) { .trackpick { grid-template-columns: 1fr; } }
.tp { display: block; border: 2px solid var(--line-2); border-radius: 13px; padding: 12px; cursor: pointer; font-weight: 400; position: relative; background: var(--surface); }
.tp input { position: absolute; opacity: 0; pointer-events: none; }
.tp .e { font-size: 1.5rem; display: block; }
.tp b { display: block; font-size: 1rem; margin: 2px 0; }
.tp small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.tp.on { border-color: var(--brand); background: var(--brand-soft); }
