/* ===== Design system: Modern civic SaaS ===== */
:root {
  --bg: #f3f6f9; --surface: #ffffff; --surface-2: #f8fafc; --border: #e3e8ee;
  --text: #16202a; --muted: #5f6b7a; --primary: #0f3d5e; --primary-2: #1a5f8f; --accent: #d9432f;
  --ok: #1f8a4c; --warn: #c8811a; --danger: #c0392b; --info: #2f6fdb;
  --l1: #d64545; --l2: #e8933a; --l3: #e2c12a; --l4: #4aa85e; --l5: #1f6fb2;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --sidebar: 15.625rem;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Segoe UI", Inter, system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: .875rem; line-height: 1.5; }
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .bold { font-weight: 600; }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--primary); color: #dbe7f1; padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem 1rem; color: #fff; font-weight: 700; font-size: .95rem; line-height: 1.2; }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #e94b3c, #f6b93b); display: grid; place-items: center; font-size: 1.1rem; flex-shrink: 0; }
.brand-logo { display: block; background: #fff; border-radius: 12px; padding: .55rem .75rem; margin: .2rem .3rem .45rem; }
.brand-logo img { display: block; width: 100%; height: auto; }
.brand-sub { color: #fff; font-weight: 700; font-size: .8rem; letter-spacing: .04em; line-height: 1.3; padding: 0 .5rem 1rem; opacity: .92; }
.nav-group { margin-top: .8rem; }
.nav-group > .label { font-size: .875rem; text-transform: uppercase; letter-spacing: .08em; color: #8fb0c9; padding: .25rem .6rem; }
details.nav-group > summary.label { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none;
  border-radius: 8px; user-select: none; }
details.nav-group > summary.label::-webkit-details-marker { display: none; }
details.nav-group > summary.label::after { content: "▾"; font-size: .9rem; transition: transform .15s; }
details.nav-group:not([open]) > summary.label::after { transform: rotate(-90deg); }
details.nav-group > summary.label:hover { background: rgba(255,255,255,.08); color: #dbe7f1; }
details.nav-group > summary.label:focus-visible { outline: 2px solid #f6b93b; outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { details.nav-group > summary.label::after { transition: none; } }
.nav a { display: block; padding: .42rem .6rem; border-radius: 8px; color: #dbe7f1; font-size: .88rem; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.nav a.sub { padding-left: 1.6rem; font-size: .875rem; color: #b8cde0; }
.main { flex: 1; min-width: 0; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: .6rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; position: sticky; top: 0; z-index: 5; }
.topbar .title { font-weight: 650; font-size: 1.05rem; }
.content { padding: 1.25rem 1.5rem 3rem; max-width: 1400px; }
/* tiêu đề trang: dải banner nhạt + hình minh họa theo nhóm chức năng (body[data-section] = blueprint) */
.page-head { display: flex; align-items: center; gap: 1rem 1.2rem; margin-bottom: 1rem; flex-wrap: wrap;
  background: linear-gradient(120deg, #f6faff 0%, #e6f0fa 100%); border: 1px solid var(--border); border-radius: 14px; padding: .9rem 1.2rem; }
.page-head > :first-child { flex: 1 1 280px; min-width: 0; }
.page-head h1 { margin-bottom: .2rem; }
.page-head p { margin: 0; color: var(--muted); }
.page-head::before { content: ""; flex: none; width: 132px; height: 80px; background: center / contain no-repeat; display: none; }
body[data-section="dashboard"] .page-head::before { display: block; background-image: url("../img/heads/dashboard.svg"); }
body[data-section="members"] .page-head::before { display: block; background-image: url("../img/heads/members.svg"); }
body[data-section="communities"] .page-head::before { display: block; background-image: url("../img/heads/communities.svg"); }
body[data-section="competency"] .page-head::before { display: block; background-image: url("../img/heads/competency.svg"); }
body[data-section="training"] .page-head::before { display: block; background-image: url("../img/heads/training.svg"); }
body[data-section="support"] .page-head::before { display: block; background-image: url("../img/heads/support.svg"); }
body[data-section="events"] .page-head::before { display: block; background-image: url("../img/heads/events.svg"); }
body[data-section="kpi"] .page-head::before { display: block; background-image: url("../img/heads/kpi.svg"); }
body[data-section="honors"] .page-head::before { display: block; background-image: url("../img/heads/honors.svg"); }
body[data-section="qr"] .page-head::before { display: block; background-image: url("../img/heads/qr.svg"); }
body[data-section="ai"] .page-head::before { display: block; background-image: url("../img/heads/ai.svg"); }
@media (max-width: 720px) { .page-head::before { width: 84px; height: 52px; } }
@media print { .page-head { background: none; border: 0; padding: 0; } .page-head::before { display: none !important; } }

/* cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; }
.card + .card { margin-top: 1rem; }
.card h2, .card h3 { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); } .g5 { grid-template-columns: repeat(5, 1fr); }
.g-23 { grid-template-columns: 2fr 1fr; } .g-32 { grid-template-columns: 3fr 2fr; }
@media (max-width: 1100px) { .g4, .g5 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: 1fr 1fr; } .g-23, .g-32 { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .g2, .g3, .g4, .g5 { grid-template-columns: 1fr; } .sidebar { display: none; } .content { padding: 1rem; } }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat .v { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; color: var(--primary); line-height: 1.1; }
.stat .l { color: var(--muted); font-size: .875rem; margin-top: .2rem; }
.stat .d { font-size: .875rem; margin-top: .3rem; }
.stat.accent .v { color: var(--accent); } .stat.ok .v { color: var(--ok); } .stat.info .v { color: var(--info); } .stat.danger .v { color: var(--danger); }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .875rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:hover td { background: #fafcfe; }
.table-wrap { overflow-x: auto; }

/* badges / levels */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .875rem; font-weight: 600; background: #e9eef4; color: #34495e; white-space: nowrap; }
.badge.ok { background: #e2f4e8; color: #1f6b3b; } .badge.warn { background: #fbeed7; color: #8a5a10; } .badge.danger { background: #fbe1de; color: #9b2a1f; } .badge.info { background: #e1ebfb; color: #1f4fa3; }
.badge.primary { background: var(--primary); color: #fff; }
.lvl { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; }
.dots { display: inline-flex; gap: 2px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: #dde3ea; display: inline-block; }
.dots.l1 i:nth-child(-n+1), .dots.l2 i:nth-child(-n+2), .dots.l3 i:nth-child(-n+3), .dots.l4 i:nth-child(-n+4), .dots.l5 i:nth-child(-n+5) { background: var(--c); }
.dots.l1 { --c: var(--l1);} .dots.l2 { --c: var(--l2);} .dots.l3 { --c: var(--l3);} .dots.l4 { --c: var(--l4);} .dots.l5 { --c: var(--l5);}
.lvl-pill { display: inline-block; min-width: 2.2rem; text-align: center; padding: .1rem .4rem; border-radius: 6px; color: #fff; font-weight: 700; font-size: .875rem; }
.lvl-pill.l1 { background: var(--l1);} .lvl-pill.l2 { background: var(--l2);} .lvl-pill.l3 { background: var(--l3); color:#333;} .lvl-pill.l4 { background: var(--l4);} .lvl-pill.l5 { background: var(--l5);}

/* progress bar */
.bar { height: 10px; background: #e7ecf2; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary-2); border-radius: 999px; }
.bar.ok > span { background: var(--ok); } .bar.warn > span { background: var(--warn); } .bar.danger > span { background: var(--danger); }
.bar-row { display: grid; grid-template-columns: 9.5rem 1fr 3.2rem; align-items: center; gap: .6rem; padding: .28rem 0; font-size: .875rem; }

/* forms & buttons */
input, select, textarea { font: inherit; padding: .48rem .6rem; border: 1px solid #cfd8e2; border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd3ea; border-color: var(--primary-2); }
label { display: block; font-size: .875rem; font-weight: 600; color: var(--muted); margin-bottom: .2rem; }
.field { margin-bottom: .75rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; } .row > .auto { flex: 0 0 auto; }
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .48rem .9rem; border-radius: 8px; border: 1px solid var(--primary); background: var(--primary); color: #fff; font-weight: 600; font-size: .875rem; cursor: pointer; white-space: nowrap; width: auto; }
.btn:hover { background: var(--primary-2); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--primary); }
.btn.ghost:hover { background: #eef3f8; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #a93226; }
.btn.accent { background: var(--accent); border-color: var(--accent); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.sm { padding: .3rem .6rem; font-size: .875rem; }
.btn.block { width: 100%; justify-content: center; }
.flash { padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; background: #e2f4e8; color: #1f6b3b; border: 1px solid #bfe5cc; }
.flash.error { background: #fbe1de; color: #9b2a1f; border-color: #f2b9b3; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filters > * { width: auto; min-width: 10rem; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem .8rem; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tabs a.active, .tabs a:hover { color: var(--primary); border-bottom-color: var(--primary); text-decoration: none; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .45rem 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: .6rem; align-items: center; }
.list li:last-child { border-bottom: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #1a5f8f, #56a3d9); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: .875rem; flex-shrink: 0; }
.kv { display: grid; grid-template-columns: 8.75rem 1fr; gap: .3rem .8rem; font-size: .88rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.chart-box { position: relative; height: 260px; }
details summary { cursor: pointer; font-weight: 600; }
.tree ul { list-style: none; padding-left: 1.2rem; margin: 0; border-left: 1px dashed #cfd8e2; }
.tree > ul { border-left: 0; padding-left: 0; }
.tree li { padding: .2rem 0; }
.tree .node { display: inline-flex; gap: .5rem; align-items: center; }
/* danh sách cộng đồng: bảng phân cấp */
.comm-table td { vertical-align: middle; }
.comm-name { display: flex; align-items: center; gap: .35rem; white-space: nowrap; min-width: 13rem; }
.comm-name.d1 { padding-left: 1.3rem; } .comm-name.d2 { padding-left: 2.6rem; } .comm-name.d3 { padding-left: 3.9rem; }
.comm-name.d4 { padding-left: 5.2rem; } .comm-name.d5 { padding-left: 6.5rem; }
.comm-branch { color: #9fb0c0; font-size: .9rem; }
.comm-table tr.lvl-0 td, .comm-table tr.lvl-1 td { background: #f5f8fb; }
.comm-table tr.lvl-0 .comm-name a, .comm-table tr.lvl-1 .comm-name a, .comm-table tr.lvl-2 .comm-name a { font-weight: 700; }
.comm-table code { background: #eef2f6; padding: .1rem .35rem; border-radius: 5px; }
.ai-msg { padding: .8rem 1rem; border-radius: 12px; margin-bottom: .7rem; max-width: 85%; }
.ai-msg.user { background: var(--primary); color: #fff; margin-left: auto; }
.ai-msg.bot { background: var(--surface-2); border: 1px solid var(--border); }
.ai-msg p { margin: .3rem 0; }
.pagination { display: flex; gap: .3rem; margin-top: 1rem; }
.pagination a, .pagination span { padding: .3rem .6rem; border-radius: 6px; border: 1px solid var(--border); background: #fff; }
.pagination .cur { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Cổng người dân (mobile-first) =====
   - Cỡ chữ gốc theo nhóm tuổi (html[data-age]); mọi kích thước dùng rem nên phóng to đồng đều.
   - Màu theo token --m-*; html[data-mode="dark"] đổi bộ token cho ban đêm.
   - Chỉ áp dụng cho trang có html[data-age] (cổng người dân), không ảnh hưởng trang quản trị. */
html[data-age="young"]  { font-size: 16px; }
html[data-age="middle"] { font-size: 18px; }
html[data-age="senior"] { font-size: 20px; }

html[data-age] {
  --m-bg: #e9eef3; --m-surface: #ffffff; --m-surface-2: #f3f6f9;
  --m-text: #14202b; --m-muted: #4a5866; --m-border: #cdd6df; --m-strong: #8795a4;
  --m-primary: #0b4f86; --m-ink: #0b4f86; --m-accent: #b3321d; --m-sel: #e1ecf8;
  --m-head-1: #0b3a5c; --m-head-2: #16609a; --m-focus: #f0a500;
  --m-ok-bg: #e2f3e7; --m-ok-ink: #17552f; --m-err-bg: #fbe3df; --m-err-ink: #8a2215;
  --m-info-bg: #e3edfb; --m-info-ink: #173f7a; --m-warn-bg: #fcefd6; --m-warn-ink: #7a4d08;
  /* ánh xạ token chung để .card/.stat/.badge… trong cổng theo đúng màu */
  --bg: var(--m-bg); --surface: var(--m-surface); --surface-2: var(--m-surface-2);
  --text: var(--m-text); --muted: var(--m-muted); --border: var(--m-border);
  --primary: var(--m-primary); --primary-2: var(--m-ink); --accent: var(--m-accent);
  color-scheme: light;
}
html[data-age][data-mode="dark"] {
  --m-bg: #0c1218; --m-surface: #161f29; --m-surface-2: #1d2833;
  --m-text: #eef3f8; --m-muted: #b3c0cc; --m-border: #2f3d4b; --m-strong: #6a7e92;
  --m-primary: #1f6fb2; --m-ink: #8ccaff; --m-accent: #c4432d; --m-sel: #1b3552;
  --m-head-1: #081c2c; --m-head-2: #0f3553; --m-focus: #ffc94d;
  --m-ok-bg: #15301f; --m-ok-ink: #a6e7bd; --m-err-bg: #3a1916; --m-err-ink: #ffb8ad;
  --m-info-bg: #16283f; --m-info-ink: #a9cdfb; --m-warn-bg: #362710; --m-warn-ink: #f7d08a;
  --shadow: none;
  color-scheme: dark;
}
html[data-mode="dark"] .when-light, html:not([data-mode="dark"]) .when-dark { display: none; }

.m-body { background: var(--m-bg); color: var(--m-text); font-size: 1rem; line-height: 1.55; }
html[data-age="senior"] .m-body { line-height: 1.6; }
.m-wrap { max-width: 520px; margin: 0 auto; min-height: 100vh; background: var(--m-surface); display: flex; flex-direction: column; }
.m-body a { color: var(--m-ink); }
.m-body .muted { color: var(--m-muted); }
.m-body .small { font-size: max(.85rem, 14px); }
html[data-age="senior"] .m-body .small { font-size: .9rem; }
.m-body :focus-visible { outline: 3px solid var(--m-focus); outline-offset: 2px; }

/* đầu trang */
.m-head { background: linear-gradient(135deg, var(--m-head-1), var(--m-head-2)); color: #fff; padding: .9rem 1.1rem 1.2rem; }
.m-head-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.m-head .t .m-logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #fff; margin-right: .45rem; vertical-align: middle; }
.m-head .t .m-logo img { width: 26px; height: 26px; }
.m-head .t { font-size: max(.72rem, 14px); text-transform: uppercase; letter-spacing: .08em; opacity: .9; font-weight: 600; }
.m-head h1 { font-size: 1.35rem; line-height: 1.3; margin: .35rem 0 0; color: #fff; }
.m-head .sub { opacity: .95; font-size: .92rem; margin-top: .35rem; }
.m-tools { display: flex; gap: .4rem; flex-shrink: 0; }
.m-tool { min-width: 2.6rem; height: 2.6rem; padding: 0 .5rem; display: grid; place-items: center; border-radius: 12px;
          background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.35); color: #fff !important; font-weight: 800; font-size: 1rem; text-decoration: none !important; }
.m-tool:hover { background: rgba(255,255,255,.26); }
.m-content { padding: 1rem 1.1rem 7rem; flex: 1; }

/* thẻ, thông báo, huy hiệu */
.m-card { background: var(--m-surface); border: 1px solid var(--m-border); border-radius: 16px; padding: 1rem 1.05rem; margin-bottom: .9rem; box-shadow: var(--shadow); }
/* hộp thoại đăng ký qua link mời */
.m-dialog { box-sizing: border-box; width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; border: 1px solid var(--m-border);
  border-radius: 18px; padding: 1.1rem 1.1rem 1.2rem; background: var(--m-surface); color: var(--m-text); box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.m-dialog::backdrop { background: rgba(8, 22, 34, .55); }
.m-dialog[open]:not(:modal) { position: fixed; inset: 12px; margin: auto; height: fit-content; z-index: 50; }
.m-dialog-x { background: none; border: 0; font-size: 1.3rem; line-height: 1; padding: .4rem .5rem; cursor: pointer; color: var(--m-muted); min-height: 44px; min-width: 44px; }
/* cổng thành viên: ẩn danh song song với đăng nhập SĐT */
.m-two { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
@media (max-width: 360px) { .m-two { grid-template-columns: 1fr; } }
.m-choice { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; padding: .8rem; border: 2px solid var(--m-border);
  border-radius: 14px; color: var(--m-text); text-decoration: none; background: var(--m-surface); }
.m-choice p { margin: 0 0 .3rem; flex: 1; }
.m-choice .ic { font-size: 1.6rem; line-height: 1; }
.m-choice.is-current { border-color: var(--m-ok-ink, #1f6b3b); background: var(--m-ok-bg, #e2f4e8); }
a.m-choice:hover { border-color: var(--m-focus); text-decoration: none; }
.m-head .m-id-chip, .m-head .m-id-chip u { color: #fff; }
.m-id-chip { display: inline-block; margin-top: .55rem; padding: .3rem .7rem; border-radius: 999px; background: rgba(255,255,255,.16);
  color: #fff; font-size: max(.8rem, 14px); text-decoration: none; }
.m-head .m-id-chip:hover { background: rgba(255,255,255,.26); text-decoration: none; }
.choice-line { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; margin: .35rem 0; text-align: left; }
.choice-line input { width: auto; margin-top: .2rem; flex-shrink: 0; }
.btn-line { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.m-body input.m-readonly { background: var(--m-surface-2); color: var(--m-muted); }
.m-card h3 { font-size: 1.05rem; }
.m-card summary { font-weight: 700; min-height: 2.4rem; display: flex; align-items: center; }
.m-body .stat { background: var(--m-surface); border-color: var(--m-border); }
.m-body .stat .v, .m-body .big-num { color: var(--m-ink); }
.m-body .flash { background: var(--m-ok-bg); color: var(--m-ok-ink); border: 1px solid transparent; border-radius: 12px; padding: .8rem 1rem; }
.m-body .flash.error { background: var(--m-err-bg); color: var(--m-err-ink); }
.m-body .flash a { color: inherit; font-weight: 700; text-decoration: underline; }
.m-body .badge { background: var(--m-surface-2); color: var(--m-text); border: 1px solid var(--m-border); font-size: max(.8rem, 14px); }
.m-body .badge.ok { background: var(--m-ok-bg); color: var(--m-ok-ink); }
.m-body .badge.danger { background: var(--m-err-bg); color: var(--m-err-ink); }
.m-body .badge.info { background: var(--m-info-bg); color: var(--m-info-ink); }
.m-body .badge.warn { background: var(--m-warn-bg); color: var(--m-warn-ink); }
.m-body .badge.primary { background: var(--m-primary); color: #fff; }

/* ô nhập & nút: cao tối thiểu ~44px (thanh niên) → ~55px (cao tuổi) */
.m-body input, .m-body select, .m-body textarea { font-size: 1rem; min-height: 2.75rem; padding: .55rem .75rem; border-radius: 10px;
  background: var(--m-surface); color: var(--m-text); border: 1.5px solid var(--m-strong); }
.m-body label { font-size: .9rem; color: var(--m-text); font-weight: 600; }
.m-body .btn { min-height: 2.75rem; font-size: 1rem; font-weight: 700; border-radius: 12px; padding: .6rem 1.1rem;
  background: var(--m-primary); border-color: var(--m-primary); color: #fff; justify-content: center; }
.m-body .btn:hover { filter: brightness(1.08); }
.m-body .btn.ghost { background: transparent; color: var(--m-ink); border: 2px solid var(--m-ink); }
.m-body .btn.accent { background: var(--m-accent); border-color: var(--m-accent); }
.m-body .btn.ok { background: #1c6e3d; border-color: #1c6e3d; }
.btn-xl { min-height: 3.4rem !important; font-size: 1.15rem !important; }

/* lựa chọn trắc nghiệm / radio / checkbox: nút tròn to, cả dòng bấm được */
.m-body input[type="radio"], .m-body input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 1.4rem; height: 1.4rem; min-height: 0; padding: 0; margin: 0; flex: none;
  border: 2px solid var(--m-strong); background: var(--m-surface); display: inline-grid; place-items: center; cursor: pointer; vertical-align: middle; }
.m-body input[type="radio"] { border-radius: 50%; }
.m-body input[type="checkbox"] { border-radius: 6px; }
.m-body input[type="radio"]:checked { border-color: var(--m-ink); background: radial-gradient(var(--m-ink) 0 45%, var(--m-surface) 50%); }
.m-body input[type="checkbox"]:checked { border-color: var(--m-ink); background: var(--m-ink); }
.m-body input[type="checkbox"]:checked::after { content: "✓"; color: var(--m-surface); font-weight: 900; font-size: .95rem; line-height: 1; }
.choice { display: flex; align-items: center; gap: .8rem; min-height: 3rem; padding: .7rem .95rem; margin-bottom: .55rem; cursor: pointer;
  border: 1.5px solid var(--m-border); border-radius: 12px; background: var(--m-surface); color: var(--m-text); font-weight: 500; line-height: 1.4; }
html[data-age="senior"] .choice { border-width: 2px; }
.choice:hover { border-color: var(--m-strong); }
.choice:has(input:checked) { border-color: var(--m-ink); background: var(--m-sel); font-weight: 700; box-shadow: inset 0 0 0 1px var(--m-ink); }

/* thang mức 1–5 */
.lvl-select { display: flex; gap: .35rem; }
.lvl-select label { flex: 1; margin: 0; }
.lvl-select input { position: absolute; opacity: 0; pointer-events: none; }
.lvl-select span { display: grid; place-items: center; min-height: 2.75rem; border-radius: 10px; border: 1.5px solid var(--m-strong); font-weight: 800; color: var(--m-text); cursor: pointer; font-size: 1rem; background: var(--m-surface); }
.lvl-select input:focus-visible + span { outline: 3px solid var(--m-focus); }
.lvl-select input:checked + span { color: #fff; border-color: transparent; }
.lvl-select label:nth-of-type(1) input:checked + span { background: var(--l1);} .lvl-select label:nth-of-type(2) input:checked + span { background: var(--l2);} .lvl-select label:nth-of-type(3) input:checked + span { background: var(--l3); color:#222;} .lvl-select label:nth-of-type(4) input:checked + span { background: var(--l4);} .lvl-select label:nth-of-type(5) input:checked + span { background: var(--l5);}

/* menu trang chủ */
.m-menu { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.m-menu a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; min-height: 6.2rem; padding: .9rem .6rem; border-radius: 16px;
  background: var(--m-surface-2); border: 1.5px solid var(--m-border); color: var(--m-text); font-weight: 700; text-align: center; font-size: .95rem; line-height: 1.3; text-decoration: none; }
.m-menu a .ic { font-size: 2rem; line-height: 1; }
.m-menu a.primary { background: var(--m-primary); color: #fff; border-color: var(--m-primary); }
.m-menu a.accent { background: var(--m-accent); color: #fff; border-color: var(--m-accent); }
.m-menu a.wide { grid-column: span 2; flex-direction: row; min-height: 4rem; }
html[data-age="senior"] .m-menu { grid-template-columns: 1fr; }        /* cao tuổi: mỗi nút một hàng, dễ bấm */
html[data-age="senior"] .m-menu a { flex-direction: row; justify-content: flex-start; min-height: 4.2rem; padding: .8rem 1.1rem; text-align: left; gap: .9rem; }
html[data-age="senior"] .m-menu a.wide { grid-column: auto; }

/* thanh điều hướng dưới */
.m-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px; background: var(--m-surface);
  border-top: 1px solid var(--m-border); display: flex; justify-content: space-around; padding: .35rem 0 calc(.45rem + env(safe-area-inset-bottom)); z-index: 10; }
.m-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem; min-height: 3rem; justify-content: center;
  font-size: max(.72rem, 14px); font-weight: 600; color: var(--m-muted) !important; text-decoration: none !important; border-radius: 10px; }
.m-nav a .ic { font-size: 1.45rem; line-height: 1; }
.m-nav a.active { color: var(--m-ink) !important; font-weight: 800; background: var(--m-sel); }

/* màn hình chào: chọn độ tuổi & màu */
.m-step { font-size: 1.15rem; margin: 1.1rem 0 .6rem; }
.m-options { display: grid; gap: .65rem; margin-bottom: .9rem; }
.m-options-row { grid-template-columns: repeat(3, 1fr); }
.m-option { display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; border: 2px solid var(--m-border); border-radius: 16px; background: var(--m-surface); cursor: pointer; margin: 0; color: var(--m-text); }
.m-option:has(input:checked) { border-color: var(--m-ink); background: var(--m-sel); box-shadow: inset 0 0 0 1px var(--m-ink); }
.m-option-icon { font-size: 2.1rem; line-height: 1; }
.m-option-body { display: flex; flex-direction: column; gap: .1rem; font-weight: 400; }
.m-option-body b { font-size: 1.05rem; }
.age-senior .m-option-body b { font-size: 1.18rem; }
.age-young .m-option-body b { font-size: .98rem; }
.m-option-sub { font-weight: 700; color: var(--m-muted); font-size: .9rem; }
.m-option-desc { color: var(--m-muted); font-size: max(.85rem, 14px); }
.m-option-compact { flex-direction: column; text-align: center; gap: .35rem; padding: .75rem .35rem; }
.m-option-compact input { position: absolute; opacity: 0; pointer-events: none; }
.m-option-compact .m-option-body b { font-size: .9rem; }

/* bài kiểm tra */
.q-num { display: inline-block; font-size: max(.8rem, 14px); font-weight: 800; letter-spacing: .04em; color: var(--m-ink); background: var(--m-sel); border-radius: 999px; padding: .15rem .6rem; margin-bottom: .45rem; }
.q-title { font-size: 1.1rem; line-height: 1.45; margin: 0 0 .75rem; font-weight: 700; }
.q-submit { padding: .4rem 0 .6rem; }
.q-progress { text-align: center; font-weight: 700; color: var(--m-muted); margin-bottom: .45rem; font-size: .9rem; }

.video { aspect-ratio: 16/9; width: 100%; border: 0; border-radius: 12px; background: #000; }

/* thumbnail video (tỷ lệ 16:9, co giãn theo bề ngang điện thoại) */
.thumb { position: relative; display: block; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; background: var(--m-surface-2); flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-ph { display: grid; place-items: center; width: 100%; height: 100%; font-size: 2.2rem; }
.thumb-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 2.6rem; height: 2.6rem; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0,0,0,.62); color: #fff; font-size: 1.05rem; padding-left: .15rem; border: 2px solid rgba(255,255,255,.85); }
.thumb-play.big { width: 4.2rem; height: 4.2rem; font-size: 1.7rem; background: #d62b2b; border-color: #fff; }
.thumb-badge { position: absolute; right: .4rem; bottom: .4rem; background: rgba(0,0,0,.75); color: #fff; font-size: max(.75rem, 14px); font-weight: 700; padding: .12rem .45rem; border-radius: 6px; }

/* danh sách khóa học: ảnh bìa lớn trên, chữ dưới */
.course-card { display: block; background: var(--m-surface); border: 1.5px solid var(--m-border); border-radius: 16px; overflow: hidden; margin-bottom: 1rem; color: var(--m-text) !important; text-decoration: none !important; box-shadow: var(--shadow); }
.course-card .thumb { border-radius: 0; }
.course-body { display: flex; flex-direction: column; gap: .3rem; padding: .85rem 1rem 1rem; }
.course-title { font-size: 1.12rem; font-weight: 800; line-height: 1.35; }
.course-desc { font-size: 1rem; line-height: 1.55; color: var(--m-text); }
.course-meta { font-size: .88rem; color: var(--m-muted); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

/* danh sách bài học: thumbnail trái + tiêu đề phải; cao tuổi xếp dọc cho ảnh & chữ to */
.lesson-item { display: grid; grid-template-columns: 42% 1fr; gap: .8rem; align-items: center; padding: .6rem; margin-bottom: .7rem;
  background: var(--m-surface); border: 1.5px solid var(--m-border); border-radius: 14px; color: var(--m-text) !important; text-decoration: none !important; }
.lesson-item:hover { border-color: var(--m-strong); }
.lesson-item.seen { background: var(--m-surface-2); }
.lesson-body { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.lesson-no { font-size: max(.82rem, 14px); font-weight: 800; color: var(--m-muted); text-transform: uppercase; letter-spacing: .03em; }
.seen-mark { color: var(--m-ok-ink); }
.lesson-title { font-size: 1.02rem; font-weight: 700; line-height: 1.4; }
html[data-age="senior"] .lesson-item { grid-template-columns: 1fr; padding: .7rem; }
html[data-age="senior"] .lesson-title { font-size: 1.1rem; }

/* trang bài học */
.video-lite { position: relative; display: block; width: 100%; aspect-ratio: 16/9; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: #000; cursor: pointer; }
.video-lite img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .9; }
.video-lite:hover img { opacity: 1; }
.video-hint { position: absolute; left: 0; right: 0; bottom: 0; padding: .9rem .8rem .55rem; color: #fff; font-weight: 700; font-size: .9rem;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); text-align: left; }
.lesson-heading { font-size: 1.3rem; line-height: 1.35; margin: 1rem 0 .5rem; }
.lesson-content { font-size: 1.12rem; line-height: 1.75; color: var(--m-text); white-space: pre-line; margin: 0 0 1.2rem; }
html[data-age="senior"] .lesson-content { font-size: 1.15rem; line-height: 1.8; }
.lesson-nav { margin-top: 1rem; }
.lesson-nav .row > .btn { flex: 1; }

/* print */
@media print {
  .sidebar, .topbar, .no-print, .m-nav { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
.print-page { max-width: 900px; margin: 0 auto; padding: 2rem; background: #fff; }
.print-page h1 { text-align: center; }
.poster { max-width: 520px; margin: 2rem auto; text-align: center; padding: 2rem; border: 6px solid var(--primary); border-radius: 24px; }
.poster img { width: 300px; height: 300px; }
.poster h1 { font-size: 1.6rem; color: var(--primary); }

/* thumbnail nhỏ trong trang quản trị */
.admin-thumb { width: 100px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; display: block; background: #e7ecf2; }
.m-body .btn-next { flex-direction: column; gap: .15rem; white-space: normal; text-align: center; line-height: 1.3; padding: .7rem 1rem; }
.m-body .btn-next small { font-size: .9rem; font-weight: 600; opacity: .92; }
.lesson-nav .btn { white-space: normal; text-align: center; }

/* khóa học: lưới thẻ có ảnh bìa + mã số */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.6rem, 1fr)); gap: 1rem; }
.course-tile { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow); color: var(--text); text-decoration: none !important; transition: transform .12s, box-shadow .12s; }
.course-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,24,40,.12); }
.course-tile-img { position: relative; display: block; aspect-ratio: 16/9; background: #e7eef6; overflow: hidden; }
.course-tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.course-tile-ph { display: grid; place-items: center; width: 100%; height: 100%; font-size: 2.6rem; }
.course-tile-note { position: absolute; right: .5rem; bottom: .5rem; background: rgba(0,0,0,.6); color: #fff; font-size: .875rem; padding: .1rem .4rem; border-radius: 5px; }
.course-tile-body { display: flex; flex-direction: column; gap: .3rem; padding: .75rem .9rem .9rem; }
.course-tile-body b { font-size: .98rem; line-height: 1.35; }
.course-tile-stats { display: flex; flex-wrap: wrap; gap: .25rem .8rem; font-size: .875rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: .45rem; margin-top: .2rem; }
.course-tile-stats b { color: var(--text); }
.course-code { position: absolute; left: .5rem; top: .5rem; background: var(--primary); color: #fff; font-weight: 800; font-size: .875rem; letter-spacing: .03em;
  padding: .15rem .5rem; border-radius: 6px; font-family: Consolas, "Cascadia Mono", monospace; }
.course-code.inline { position: static; display: inline-block; vertical-align: middle; font-size: max(.72em, 14px); }

/* cỡ chữ trang quản trị: 4 mức, đổi bằng nút A− / A+ (html[data-fs]); cỡ nhỏ nhất = .875rem (bằng chữ "Sửa khóa học") */
html:not([data-age])[data-fs="1"] { font-size: 16px; }
html:not([data-age])[data-fs="2"] { font-size: 18px; }
html:not([data-age])[data-fs="3"] { font-size: 20px; }
html:not([data-age])[data-fs="4"] { font-size: 22px; }
.fs-ctl { display: inline-flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.fs-ctl button { border: 0; background: transparent; color: var(--primary); font-weight: 800; font-size: .875rem; min-width: 2.4rem; padding: .3rem .55rem; cursor: pointer; font-family: inherit; }
.fs-ctl button:hover:not(:disabled) { background: #eef3f8; }
.fs-ctl button:disabled { color: #b8c3cf; cursor: default; }
.fs-ctl .fs-now { min-width: 3.4rem; border-inline: 1px solid var(--border); color: var(--muted); font-weight: 700; }
.fs-ctl .fs-up { font-size: 1.05rem; }
.topbar .row > * { flex: none; }
.fs-ctl button { white-space: nowrap; }

/* Cổng người dân: chọn kỳ báo cáo / vinh danh, lưới chỉ số 2 cột */
.m-period { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.m-period .btn { justify-content: center; }
.m-stats { grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-top: 1rem; }

/* Chứng nhận: lưới ảnh thu nhỏ (hồ sơ người dân + hồ sơ quản trị) */
.cert-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem; margin-top: .5rem; }
.cert-card { display: flex; flex-direction: column; border: 1px solid #e6dcc6; border-radius: 14px; overflow: hidden; background: #fffdf8;
  color: inherit; text-decoration: none; transition: transform .18s, box-shadow .18s; }
.cert-card:hover { transform: translateY(-3px); box-shadow: 0 14px 28px -14px rgba(15, 61, 94, .45); text-decoration: none; }
.cert-thumb { position: relative; display: block; aspect-ratio: 2400 / 1697; background: linear-gradient(135deg, #fbf8f0, #efe4c8); overflow: hidden; }
.cert-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cert-thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.5) 50%, transparent 60%);
  transform: translateX(-100%); transition: transform .7s; }
.cert-card:hover .cert-thumb::after { transform: translateX(100%); }
.cert-meta { display: flex; flex-direction: column; gap: .15rem; padding: .6rem .75rem .2rem; line-height: 1.35; }
.cert-meta b { color: #0f3d5e; }
.cert-cta { padding: .1rem .75rem .65rem; color: #b8892d; font-weight: 700; }
.m-body .cert-card { background: var(--m-surface); border-color: var(--m-border); }
.m-body .cert-meta b { color: var(--m-ink); }
.m-body .cert-grid { grid-template-columns: 1fr; }
@media (min-width: 420px) { .m-body .cert-grid { grid-template-columns: 1fr 1fr; } }
@media (prefers-reduced-motion: reduce) { .cert-card, .cert-thumb::after { transition: none; } }

/* Footer dùng chung: đơn vị vận hành + kênh hỗ trợ */
.site-footer { border-top: 1px solid var(--border); background: #fff; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.site-footer .sf-inner { max-width: 1400px; padding: 1.1rem 1.5rem 1.3rem; display: grid; grid-template-columns: 1.1fr 1.4fr 1fr; gap: 1.25rem; align-items: start; }
.site-footer p { margin: 0; }
.site-footer b { color: var(--text); }
.site-footer .sf-site { font-weight: 700; color: var(--primary); margin-bottom: .2rem; }
.site-footer h4 { margin: 0 0 .2rem; font-size: .9rem; color: var(--text); }
.site-footer .sf-block { display: flex; gap: .8rem; align-items: flex-start; }
.site-footer .sf-qr { flex-shrink: 0; display: block; width: 96px; height: 96px; padding: 4px; background: #fff; border: 1px solid var(--border); border-radius: 10px; }
.site-footer .sf-qr img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.site-footer .sf-phone { font-weight: 700; white-space: nowrap; }
@media (max-width: 900px) { .site-footer .sf-inner { grid-template-columns: 1fr; gap: .9rem; } }
/* bản một dòng trên trang đăng nhập (nền xanh) */
.site-footer.compact { background: transparent; border: 0; color: #dbe7f1; text-align: center; }
.site-footer.compact .sf-inner { display: block; padding: 1rem 0 0; }
.site-footer.compact .sf-site { display: none; }
.site-footer.compact b, .site-footer.compact a { color: #fff; }
.site-footer.compact .sf-direct { margin-top: .25rem; }
/* cổng người dân: một cột, theo màu ngày/đêm, chừa chỗ cho thanh điều hướng dưới */
.m-body .site-footer { margin: 2rem -1.1rem -1rem; background: var(--m-surface-2); border-top: 1px solid var(--m-border); color: var(--m-muted); font-size: .9rem; }
.m-body .site-footer .sf-inner { grid-template-columns: 1fr; padding: 1.1rem; gap: 1rem; }
.m-body .site-footer b, .m-body .site-footer h4 { color: var(--m-text); }
.m-body .site-footer .sf-site { color: var(--m-ink); }
.m-body .site-footer a { color: var(--m-ink); }
.m-body .site-footer .sf-qr { border-color: var(--m-border); }

/* Số điện thoại + nút mở chat Zalo */
.phone-links { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; vertical-align: middle; }
.zalo-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; line-height: 0; transition: transform .15s, background .15s; }
.zalo-btn:hover { background: rgba(0, 104, 255, .1); transform: scale(1.08); text-decoration: none; }
.zalo-btn:focus-visible { outline: 2px solid #0068ff; outline-offset: 1px; }
.m-body .zalo-btn { width: 40px; height: 40px; }          /* vùng bấm đủ lớn trên điện thoại */
.m-body .zalo-btn svg { width: 26px; height: 26px; }
@media (prefers-reduced-motion: reduce) { .zalo-btn { transition: none; } }

/* cấu hình hệ thống */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem; }
.mod-item { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; font-weight: 400; }
.mod-item input { width: auto; margin-top: .25rem; flex-shrink: 0; }
.mod-item > span { display: flex; flex-direction: column; gap: .15rem; }
.mod-item.is-on { border-color: var(--ok); background: #f1faf4; }
.svc-card > summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem; cursor: pointer; list-style: none; }
.svc-card > summary::-webkit-details-marker { display: none; }
.svc-card > summary::before { content: "▸"; margin-right: .4rem; color: var(--muted); }
.svc-card[open] > summary::before { content: "▾"; }
.svc-card .svc-title { flex: 1; min-width: 14rem; }
.svc-card .svc-meta { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.svc-card.is-off { opacity: .72; }
.svc-card + .svc-card { margin-top: .6rem; }

/* công tắc bật/tắt dịch vụ */
.svc-switch { display: inline-flex; align-items: center; gap: .45rem; margin: 0; }
.switch { position: relative; width: 44px; height: 24px; border-radius: 999px; border: 0; padding: 0; cursor: pointer; flex-shrink: 0;
  background: #c3cdd7; transition: background .15s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch.on { background: var(--ok); }
.switch.on .knob { transform: translateX(20px); }
.switch:focus-visible { outline: 3px solid #f6b93b; outline-offset: 2px; }
.switch[disabled] { opacity: .6; cursor: progress; }
.switch-label { font-size: .85rem; color: var(--muted); white-space: nowrap; }
tr.row-off td { color: var(--muted); }
tr.row-off td a b { opacity: .7; }
@media (prefers-reduced-motion: reduce) { .switch, .switch .knob { transition: none; } }
.bulk-card td { vertical-align: middle; }
.bulk-card tr.bulk-total td { border-top: 2px solid var(--border); background: #f5f8fb; }
.bulk-card .btn[disabled] { opacity: .45; cursor: default; }
.svc-card h4 { margin: .2rem 0 .4rem; }

/* bài học: nội dung chi tiết, từng bước, slide, link HTML, thực hành */
.lesson-content h3 { font-size: 1.05rem; margin: 1.1rem 0 .4rem; color: var(--m-text, inherit); }
.lesson-content ul, .lesson-content ol { padding-left: 1.3rem; margin: .3rem 0 .8rem; }
.lesson-content li { margin: .25rem 0; }
.lesson-content p { margin: .4rem 0 .8rem; }
.practice-bar { margin: .6rem 0 1rem; }
.practice-bar .btn { white-space: normal; }
.lesson-block { margin: 1.2rem 0; }
.lesson-block > h3 { font-size: 1.05rem; margin: 0 0 .6rem; display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.step-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.step { display: flex; gap: .7rem; align-items: flex-start; background: var(--m-surface, #fff); border: 1px solid var(--m-border, #dde3ea); border-radius: 14px; padding: .8rem; }
.step-num { flex-shrink: 0; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--m-head-1, #0f3d5e); }
.step-body { min-width: 0; }
.step-body p { margin: .2rem 0 0; }
.step-body img { display: block; width: 100%; max-width: 420px; height: auto; margin-top: .5rem; border-radius: 10px; border: 1px solid var(--m-border, #dde3ea); }
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 0; border-radius: 14px; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slides:focus-visible { outline: 3px solid var(--m-focus, #f0a500); outline-offset: 2px; }
.slide { flex: 0 0 100%; scroll-snap-align: start; margin: 0; background: linear-gradient(135deg, var(--m-head-1, #0f3d5e), var(--m-head-2, #16609a)); color: #fff;
  min-height: 12rem; display: flex; flex-direction: column; justify-content: center; padding: 1.2rem; border-radius: 14px; box-sizing: border-box; }
.slide.has-img { background: var(--m-surface, #fff); color: inherit; border: 1px solid var(--m-border, #dde3ea); justify-content: flex-start; padding: 0; }
.slide img { width: 100%; height: auto; display: block; border-radius: 14px 14px 0 0; }
.slide figcaption { padding: .2rem 0; }
.slide.has-img figcaption { padding: .8rem 1rem 1rem; }
.slide figcaption b { font-size: 1.1rem; display: block; }
.slide figcaption p { margin: .4rem 0 0; }
.slide-nav { display: flex; justify-content: center; gap: .6rem; margin-top: .6rem; }
.html-guide { display: flex; gap: .7rem; align-items: center; text-decoration: none; color: inherit; }
.html-guide > span:last-child { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
/* mở ứng dụng (cổng thành viên) */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.app-tile { background: var(--m-surface, #fff); border: 1px solid var(--m-border, #dde3ea); border-radius: 16px; padding: .8rem; display: flex; flex-direction: column; gap: .3rem; }
.app-open { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; text-decoration: none; color: inherit; min-height: 44px; }
.app-open .app-ic { font-size: 2rem; line-height: 1; }
.app-store a { display: inline-block; margin-top: .2rem; }
/* soạn bài (khu quản trị) */
.compose-row { display: flex; gap: .8rem; padding: .7rem 0; border-top: 1px dashed var(--border); }
.compose-num { flex-shrink: 0; width: 4.2rem; font-weight: 700; color: var(--muted); }
.compose-fields { flex: 1; min-width: 0; }
.compose-thumb { max-width: 160px; border-radius: 8px; border: 1px solid var(--border); margin: .2rem 0; }
.compose-save { position: sticky; bottom: 0; padding: .8rem 0; background: linear-gradient(transparent, var(--bg, #f3f6f9) 40%); }

/* lịch sinh hoạt */
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
@media (max-width: 1100px) { .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.week-day { background: var(--surface-2, #f5f8fb); border: 1px solid var(--border); border-radius: 12px; padding: .5rem; min-height: 8rem; }
.week-day.is-today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.week-day-h { margin-bottom: .4rem; }
.cal-item { display: flex; flex-direction: column; gap: .1rem; padding: .45rem .5rem; margin-bottom: .4rem; border-radius: 10px; background: var(--surface, #fff);
  border-left: 4px solid var(--c, #2f6fdb); text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.cal-item:hover { text-decoration: none; filter: brightness(.97); }
.cal-time { font-weight: 700; font-size: .85rem; color: var(--c, #2f6fdb); }
.plan-row { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.cal-m { border-left: 5px solid var(--c, #2f6fdb); }
.cal-m.is-mine { background: var(--m-ok-bg, #e2f4e8); }

/* link mời: link & QR thao tác ngay trong danh sách */
.inv-share { display: flex; gap: .6rem; align-items: center; }
.inv-qr { flex-shrink: 0; padding: 3px; background: #fff; border: 1px solid var(--border); border-radius: 8px; cursor: zoom-in; line-height: 0; }
.inv-qr:hover { border-color: var(--primary); }
.inv-qr:focus-visible { outline: 3px solid #f6b93b; outline-offset: 2px; }
.inv-qr img { width: 64px; height: 64px; image-rendering: pixelated; }
.inv-body { min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.inv-url { font-size: .85rem; overflow-wrap: anywhere; }
.qr-dialog { width: min(420px, calc(100vw - 24px)); box-sizing: border-box; border: 1px solid var(--border); border-radius: 16px; padding: 1rem; }
.qr-dialog::backdrop { background: rgba(8, 22, 34, .55); }
.qr-dialog img { display: block; width: 100%; height: auto; margin: .8rem 0; border-radius: 10px; }

/* biểu tượng ứng dụng */
.app-logo { display: inline-block; flex-shrink: 0; border-radius: 22%; object-fit: contain; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.app-logo-emoji { display: inline-grid; place-items: center; line-height: 1; background: var(--m-surface-2, #f1f4f7); }
.app-head { display: flex; gap: .6rem; align-items: center; }
.app-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .3rem; }
.app-actions .btn { min-height: 40px; }
.practice-head { margin-bottom: .5rem; }
.icon-tools { border-top: 1px dashed var(--border); padding-top: .8rem; }

/* lưới ứng dụng: điện thoại 1 cột, máy lớn nhiều cột; nút chia đều bề ngang thẻ */
.app-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.app-tile { min-width: 0; }
.app-head > div { min-width: 0; }
.app-actions .btn { flex: 1 1 8.5rem; white-space: normal; justify-content: center; text-align: center; }

/* khai báo kỹ năng: tab theo nhóm, lưu từng kỹ năng */
.sk-progress { display: flex; align-items: center; gap: .7rem; margin-bottom: .6rem; font-size: .95rem; }
.sk-progress > span { white-space: nowrap; }
.sk-bar { flex: 1; height: 10px; border-radius: 99px; background: var(--m-surface-2, #eef2f6); overflow: hidden; }
.sk-bar i { display: block; height: 100%; background: var(--m-ok-ink, #1f8a4c); border-radius: 99px; transition: width .3s; }
.sk-tabs { display: flex; gap: .45rem; overflow-x: auto; padding: .2rem .1rem .6rem; margin: 0 -.1rem .4rem; scroll-snap-type: x proximity;
  position: sticky; top: 0; z-index: 4; background: var(--m-bg, #e9eef3); scrollbar-width: thin; }
.sk-tab { flex: 0 0 auto; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; gap: .1rem; min-width: 5.6rem; max-width: 8rem;
  padding: .45rem .55rem; border-radius: 14px; border: 1.5px solid var(--m-border, #cdd6df); background: var(--m-surface, #fff); color: var(--m-text);
  font: inherit; cursor: pointer; text-align: center; }
.sk-tab-ic { font-size: 1.35rem; line-height: 1; }
.sk-tab-name { font-size: .82rem; font-weight: 700; line-height: 1.2; }
.sk-tab-count { font-size: .78rem; color: var(--m-muted, #4a5866); }
.sk-tab[aria-selected="true"] { border-color: var(--m-head-1, #0b3a5c); background: var(--m-head-1, #0b3a5c); color: #fff; }
.sk-tab[aria-selected="true"] .sk-tab-count { color: #dbe7f1; }
.sk-tab.is-done:not([aria-selected="true"]) { border-color: var(--m-ok-ink, #1f6b3b); }
.sk-tab.is-done .sk-tab-count::after { content: " ✓"; }
.sk-tab:focus-visible { outline: 3px solid var(--m-focus, #f0a500); outline-offset: 2px; }
.sk-panel-h { margin: .4rem 0 .6rem; font-size: 1.05rem; }
.sk-app { font-size: .85rem; font-weight: 700; color: var(--m-muted, #4a5866); margin: .8rem 0 .4rem; }
.sk-card { border-left: 5px solid var(--m-border, #cdd6df); }
.sk-card.is-saved { border-left-color: var(--m-ok-ink, #1f8a4c); }
.sk-card.is-dirty { border-left-color: var(--m-focus, #f0a500); }
.sk-head { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; margin-bottom: .55rem; }
.sk-state { font-size: .8rem; color: var(--m-muted, #4a5866); white-space: nowrap; }
.sk-card.is-saved .sk-state { color: var(--m-ok-ink, #1f8a4c); }
.sk-card.is-dirty .sk-state { color: #a8650a; font-weight: 700; }
fieldset.lvl-select { border: 0; padding: 0; margin: 0; min-width: 0; }
.lvl-labeled span { flex-direction: column; gap: .05rem; padding: .3rem .1rem; min-height: 3.4rem; line-height: 1.1; }
.lvl-labeled span b { font-size: 1.1rem; }
.lvl-labeled span small { font-size: .62rem; font-weight: 600; text-align: center; color: var(--m-muted, #4a5866); }
.lvl-labeled input:checked + span small { color: inherit; }
.sk-foot { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-top: .65rem; flex-wrap: wrap; }
.sk-want { display: flex; align-items: center; gap: .4rem; margin: 0; font-weight: 400; font-size: .9rem; }
.sk-want input { width: auto; }
.sk-save { min-width: 6.5rem; }
.sk-nav { display: flex; justify-content: space-between; gap: .6rem; margin: 1rem 0; }
@media (prefers-reduced-motion: reduce) { .sk-bar i { transition: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---- Cài đặt ứng dụng (PWA) ---- */
.m-install { display: flex; align-items: center; gap: .7rem; background: var(--m-surface); border: 1px solid var(--m-border);
  border-left: 4px solid #0b3a5c; border-radius: 14px; padding: .65rem .7rem; margin-bottom: .9rem; box-shadow: var(--shadow); }
.m-install[hidden] { display: none; }
.m-install img { border-radius: 12px; flex: none; }
.m-install-t { flex: 1; min-width: 0; line-height: 1.3; }
.m-install-t span { display: block; font-size: .88em; color: var(--m-muted, #5b6b7a); }
.m-install-x { background: none; border: 0; font-size: 1.1rem; color: var(--m-muted, #5b6b7a); padding: .3rem .4rem; cursor: pointer; }
.inst-hero { display: flex; gap: .9rem; align-items: center; }
.inst-hero img { border-radius: 18px; flex: none; box-shadow: var(--shadow); }
.inst-guides details { border-top: 1px solid var(--m-border); padding: .55rem 0; }
.inst-guides details:first-of-type { border-top: 0; }
.inst-guides summary { cursor: pointer; font-weight: 600; padding: .2rem 0; }
.inst-guides ol { margin: .5rem 0 .3rem 1.2rem; padding: 0; line-height: 1.6; }
.inst-key { display: inline-block; min-width: 1.5em; text-align: center; border: 1px solid var(--m-border); border-radius: 6px; padding: 0 .25em; }
@media (display-mode: standalone) { .js-hide-standalone { display: none !important; } }

/* ---- Mở ứng dụng thiết yếu: theo nhóm, mỗi ứng dụng một dòng ---- */
.apps-jump { display: flex; gap: .4rem; overflow-x: auto; padding: .1rem 0 .7rem; margin-bottom: .2rem; scrollbar-width: none; }
.apps-jump::-webkit-scrollbar { display: none; }
.apps-jump a { flex: none; padding: .35rem .75rem; border-radius: 999px; border: 1px solid var(--m-border); background: var(--m-surface);
  color: inherit; text-decoration: none; font-size: .9em; white-space: nowrap; }
.apps-jump a.is-local { border-color: #b08a3e; background: #fbf4e6; color: #6b4e14; font-weight: 600; }
.apps-sec { background: var(--m-surface); border: 1px solid var(--m-border); border-radius: 16px; padding: .85rem .9rem .3rem;
  margin-bottom: .9rem; box-shadow: var(--shadow); scroll-margin-top: .6rem; }
.apps-sec-local { border-color: #d9c18f; background: linear-gradient(180deg, #fbf4e6 0, var(--m-surface) 5.5rem); }
.apps-sec-head { display: flex; gap: .7rem; align-items: center; margin-bottom: .3rem; }
.apps-sec-head h2 { margin: 0; font-size: 1.12em; }
.apps-sec-head p { margin: .1rem 0 0; font-size: .86em; color: var(--m-muted, #5b6b7a); }
.apps-sec-logo { border-radius: 50%; flex: none; }
.apps-sec-emoji { font-size: 1.7rem; line-height: 1; flex: none; width: 44px; text-align: center; }
.apps-list { list-style: none; margin: 0; padding: 0; }
.app-row { display: flex; align-items: center; gap: .7rem; padding: .65rem 0; border-top: 1px solid var(--m-border); }
.app-row:first-child { border-top: 0; }
.app-row-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; line-height: 1.3; }
.app-row-d { font-size: .86em; color: var(--m-muted, #5b6b7a); }
.app-row-links { display: flex; flex-wrap: wrap; gap: .25rem .8rem; font-size: .82em; margin-top: .15rem; }
.app-row-links a[hidden] { display: none; }
.app-row-btn { flex: none; min-width: 4.2rem; min-height: 44px; justify-content: center; }
[data-mode="dark"] .apps-jump a.is-local { background: #3a2f17; color: #f1d9a6; border-color: #6b5524; }
[data-mode="dark"] .apps-sec-local { border-color: #6b5524; background: linear-gradient(180deg, #2c2414 0, var(--m-surface) 5.5rem); }
@media (max-width: 360px) { .app-row { flex-wrap: wrap; } .app-row-btn { margin-left: calc(46px + .7rem); } }

/* ---- Chứng nhận: cột ảnh ---- */
.cert-icon { display: block; width: 96px; height: auto; aspect-ratio: 720 / 509; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--border, #dde3ea); background: #f6f1e6; }
.cert-table td { vertical-align: middle; }

/* ---- Chuyển Đổi Số Làng Xuân Trạch Văn Hiến ---- */
.vdx-hero { display: flex; gap: .8rem; align-items: center; border-color: #d9c18f; background: linear-gradient(180deg, #fbf4e6, var(--m-surface)); }
.vdx-hero img { border-radius: 50%; flex: none; }
.vdx-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.vdx-card { display: flex; gap: .8rem; align-items: flex-start; background: var(--m-surface); border: 1px solid var(--m-border);
  border-radius: 16px; padding: .8rem; box-shadow: var(--shadow); }
.vdx-card.is-missing { border-style: dashed; box-shadow: none; opacity: .92; }
.vdx-qr { flex: none; width: 112px; height: 112px; padding: 0; border: 1px solid var(--m-border); border-radius: 12px; background: #fff;
  overflow: hidden; cursor: zoom-in; }
.vdx-qr img { display: block; width: 100%; height: 100%; }
.vdx-qr-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; cursor: default;
  background: var(--m-surface-2, #f1f4f7); color: var(--m-muted, #5b6b7a); border-style: dashed; }
.vdx-qr-empty span { font-size: 2rem; line-height: 1; }
.vdx-qr-empty small { font-size: .78em; }
.vdx-body { flex: 1; min-width: 0; }
.vdx-body h3 { margin: .15rem 0 .2rem; font-size: 1.02em; line-height: 1.3; }
.vdx-body p { margin: 0 0 .4rem; font-size: .88em; color: var(--m-muted, #5b6b7a); }
.vdx-kind { font-size: .78em; font-weight: 600; color: #8a6420; }
.vdx-wait { color: #8a5a10 !important; font-weight: 600; }
.vdx-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.vdx-actions a[hidden] { display: none; }
.vdx-actions .btn { min-height: 42px; }
.vdx-dialog { border: 0; border-radius: 18px; padding: 1rem 1.2rem; max-width: min(92vw, 360px); text-align: center; }
.vdx-dialog img { width: min(80vw, 280px); height: auto; }
.vdx-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.vdx-tile { background: linear-gradient(135deg, #fbf4e6, #f3e3bf) !important; border-color: #d9c18f !important; color: #5a3f0c !important; font-weight: 700; }
[data-mode="dark"] .vdx-hero { background: linear-gradient(180deg, #2c2414, var(--m-surface)); border-color: #6b5524; }
[data-mode="dark"] .vdx-kind { color: #e2c27e; }
[data-mode="dark"] .vdx-tile { background: linear-gradient(135deg, #3a2f17, #2c2414) !important; color: #f1d9a6 !important; border-color: #6b5524 !important; }
.vdx-admin.is-missing { border-left: 4px solid #c0392b; }
.vdx-admin-head { display: flex; gap: .8rem; align-items: center; }
.vdx-qr-mini { width: 72px; height: 72px; border-radius: 8px; border: 1px solid var(--border, #dde3ea); flex: none; }
div.vdx-qr-mini { display: grid; place-items: center; font-size: 1.8rem; border-style: dashed; background: #f6f7f9; }
@media (max-width: 380px) { .vdx-card { flex-direction: column; align-items: center; text-align: center; } .vdx-actions { justify-content: center; } }
.vdx-actions .btn { max-width: 100%; white-space: normal; text-align: center; justify-content: center; flex: 1 1 auto; }
@media (max-width: 420px) { .vdx-qr { width: 92px; height: 92px; } .vdx-card { gap: .65rem; padding: .7rem; } }

/* ---- Mã QR của trang (góc trên phải) — kiểu đầy đủ do static/js/pageqr.js nạp ---- */
.page-qr { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 3px; border-radius: 9px;
  background: #fff; border: 1px solid rgba(15, 61, 94, .25); cursor: zoom-in; flex: none; line-height: 0; }
.page-qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.m-tools .page-qr { width: 44px; height: 44px; border-color: rgba(255, 255, 255, .55); }
@media print { .topbar .page-qr, .m-tools .page-qr { display: none; } }

.admin-scope { min-width: 12rem; line-height: 1.35; }

/* ---- Trang Super admin ---- */
.sa-badge { background: #2b1d4a; color: #f3d77a; }
.sa-nav { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.sa-nav a { padding: .35rem .75rem; border-radius: 999px; border: 1px solid var(--border, #dde3ea); background: #fff; text-decoration: none; font-size: .9rem; }
.sa-sec { scroll-margin-top: 1rem; margin-top: 1rem; }
.sa-matrix td:first-child { font-weight: 600; }
.sa-n { color: #b3bdc8; }
.sa-tree tr.sa-orphan td:first-child b::after { content: " · chưa có quản trị viên"; font-weight: 400; font-size: .8em; color: #a35a00; }
.sa-off { opacity: .55; text-decoration: line-through; }
.sa-assign { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.sa-assign select { max-width: 12rem; }
.sa-sub { border-left: 3px solid #f0b429; padding-left: .8rem; margin: .4rem 0 .8rem; }

/* nút hiện / ẩn mật khẩu (js/pwtoggle.js) */
.pw-wrap { position: relative; display: block; }
.pw-wrap > input { padding-right: 2.6rem; }
.pw-eye { position: absolute; top: 0; right: 0; bottom: 0; width: 2.5rem; display: flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 0 8px 8px 0; padding: 0; }
.pw-eye:hover { color: var(--primary-2); }
.pw-eye:focus-visible { outline: 2px solid #bcd3ea; outline-offset: -2px; }
