/* ===== 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; }
.nav-group { margin-top: .8rem; }
.nav-group > .label { font-size: .875rem; text-transform: uppercase; letter-spacing: .08em; color: #8fb0c9; padding: .25rem .6rem; }
.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); }

/* 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; }
.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 { 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); }
.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-child(1) input:checked + span { background: var(--l1);} .lvl-select label:nth-child(2) input:checked + span { background: var(--l2);} .lvl-select label:nth-child(3) input:checked + span { background: var(--l3); color:#222;} .lvl-select label:nth-child(4) input:checked + span { background: var(--l4);} .lvl-select label:nth-child(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; } }
