/* ==================== CPD System — Stylesheet ==================== */
:root {
  /* Palette: E2BB77 (gold) · E6D2B0 (sand) · 3680AB (blue) · 60C5FA (sky) */
  --gold: #E2BB77; --sand: #E6D2B0; --blue: #3680AB; --sky: #60C5FA;
  --bg: #F8F3E9; --surface: #FFFDF9; --surface-2: #F5EDDC; --text: #1B2B38; --muted: #667785;
  --border: #E9DCC2; --primary: #3680AB; --primary-d: #2D6E97; --primary-h: #245B7D; --primary-soft: #DCEFFB; --on-primary: #fff;
  --accent: #E2BB77; --accent-soft: #F8EBD2; --accent-ink: #6B4E12;
  --ok: #2B8A67; --ok-soft: #DAF0E6; --warn: #9A6B14; --warn-soft: #F8EBD2;
  --danger: #C2443D; --danger-soft: #F9E0DD; --info: #2D6E97; --info-soft: #DCEFFB;
  --side-bg: #173A52; --side-text: #D3E3EE; --side-active: #3680AB;
  --shadow: 0 1px 3px rgba(23,58,82,.07), 0 6px 18px rgba(23,58,82,.06);
  --radius: 14px; --sb-w: 72px; --sb-w-open: 260px; --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
[data-theme="dark"] {
  --bg: #0D1C27; --surface: #132A3B; --surface-2: #193449; --text: #EAF2F7; --muted: #9DB4C3;
  --border: #25455C; --primary: #60C5FA; --primary-d: #3680AB; --primary-h: #2D6E97; --primary-soft: #1C4660; --on-primary: #08202F;
  --accent-soft: #3F3319; --accent-ink: #E2BB77;
  --ok: #5CCB9E; --ok-soft: #123F31; --warn: #E2BB77; --warn-soft: #3F3319;
  --danger: #F08A82; --danger-soft: #4A1E1B; --info: #60C5FA; --info-soft: #1C4660; --side-bg: #0A1822;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Inter', 'Noto Sans Lao', 'Phetsarath OT', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; }
a { color: var(--primary-d); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 .5em; }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { text-align: right; } .center { text-align: center; }
.mt { margin-top: 18px; } .mb { margin-bottom: 18px; } .nowrap { white-space: nowrap; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app { flex-direction: column; }
.content { padding: 24px; flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; }

/* ---------- Topbar ---------- */
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 18px; cursor: pointer; display: grid; place-items: center; transition: .15s; }
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 12px; padding: 4px 12px 4px 4px; cursor: pointer; font: inherit; }
.avatar { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #3b82f6, #8b5cf6); color: #fff; display: grid; place-items: center; font-weight: 700; }
.uname { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.15); padding: 6px; display: none; }
.user-menu.open .dropdown { display: block; animation: pop .15s ease-out; }
.dropdown a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 8px; color: var(--text); }
.dropdown a:hover { background: var(--surface-2); text-decoration: none; }
.dd-head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; }
.dd-head small { color: var(--muted); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card h3 { font-size: 16px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(2, 1fr); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 9px 18px; font: inherit; font-weight: 500; cursor: pointer; transition: .15s; text-decoration: none !important; white-space: nowrap; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 13px 26px; font-size: 16px; }
.btn-primary { background: var(--primary-d); color: var(--on-primary); } .btn-primary:hover { background: var(--primary-h); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(54,128,171,.35); }
.btn-gold { background: var(--gold); color: #3a2a08; } .btn-gold:hover { filter: brightness(.95); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); } .btn-ghost:hover { background: var(--surface-2); }
.btn-ok { background: var(--ok); color: #fff; } .btn-danger { background: var(--danger); color: #fff; } .btn-warn { background: var(--gold); color: #3a2a08; }
.btn-white { background: #fff; color: #245B7D; } .btn-block { width: 100%; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-ok { background: var(--ok-soft); color: var(--ok); } .b-warn { background: var(--warn-soft); color: var(--warn); }
.b-danger { background: var(--danger-soft); color: var(--danger); } .b-info { background: var(--info-soft); color: var(--info); }
.b-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 10px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); }

/* Forms */
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(2, 1fr); }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }
.field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 500; font-size: 14px; }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; transition: .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { min-height: 110px; resize: vertical; }
input[type=file] { font: inherit; color: var(--muted); }
.checks { display: flex; gap: 18px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty i { font-size: 40px; display: block; margin-bottom: 8px; opacity: .5; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.searchbox { position: relative; }
.searchbox i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.searchbox input { padding-left: 36px; width: 100%; }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pager a { min-width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none !important; }
.pager a.active { background: var(--primary-d); color: var(--on-primary); border-color: var(--primary-d); }

/* Toasts */
.toasts { position: fixed; top: 76px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); box-shadow: 0 10px 30px rgba(0,0,0,.15); animation: slideIn .3s ease-out; }
.toast span { flex: 1; } .toast-x { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--muted); }
.t-success { border-left-color: var(--ok); } .t-success i { color: var(--ok); }
.t-danger { border-left-color: var(--danger); } .t-danger i { color: var(--danger); }
.t-warning { border-left-color: var(--warn); } .t-warning i { color: var(--warn); }
.t-info i { color: var(--info); }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(3px); z-index: 200; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--surface); border-radius: 18px; padding: 28px; width: min(420px, 100%); text-align: center; animation: pop .2s ease-out; }
.modal-icon { width: 60px; height: 60px; border-radius: 50%; background: var(--danger-soft); color: var(--danger); font-size: 28px; display: grid; place-items: center; margin: 0 auto 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

/* Hero */
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 44px 40px; color: #fff; background: linear-gradient(120deg, #1B4560 0%, #3680AB 58%, #60C5FA 100%); margin-bottom: 24px; }
.hero::before, .hero::after { content: ''; position: absolute; border-radius: 50%; background: rgba(226,187,119,.28); }
.hero::before { width: 320px; height: 320px; right: -80px; top: -120px; } .hero::after { width: 200px; height: 200px; right: 120px; bottom: -110px; }
.hero > * { position: relative; z-index: 1; }
.hero h1 { font-family: 'Playfair Display','Noto Sans Lao',serif; font-size: 32px; max-width: 700px; } .hero p { max-width: 640px; opacity: .92; font-size: 16px; }
.hero .cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
@media (max-width: 640px) { .hero { padding: 28px 22px; } .hero h1 { font-size: 24px; } }

.stat { display: flex; gap: 14px; align-items: center; }
.stat-ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; flex-shrink: 0; }
.stat-num { font-size: 28px; font-weight: 700; line-height: 1.1; } .stat-lbl { color: var(--muted); font-size: 13px; }
.i-blue { background: var(--primary-soft); color: var(--primary); } .i-green { background: var(--ok-soft); color: var(--ok); }
.i-orange { background: var(--accent-soft); color: var(--accent-ink); } .i-purple { background: #DDF1FD; color: #2380B8; }
[data-theme="dark"] .i-purple { background: #1C4660; color: #60C5FA; }

/* Course card */
.course-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; transition: transform .2s, box-shadow .2s; }
.course-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(15,23,42,.14); }
.course-cover { height: 130px; display: flex; align-items: flex-end; padding: 14px; color: #fff; background-size: cover; background-position: center; position: relative; }
.course-cover .hours { position: absolute; top: 12px; right: 12px; background: rgba(255,255,255,.95); color: #173A52; border-radius: 10px; padding: 4px 10px; font-weight: 700; font-size: 13px; }
.course-cover .cat { background: rgba(0,0,0,.35); padding: 2px 10px; border-radius: 99px; font-size: 12px; backdrop-filter: blur(4px); }
.course-body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.course-body h4 { font-size: 16px; margin: 0; }
.course-body h4 a { color: var(--text); }
.meta { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 13px; }
.meta i { width: 18px; display: inline-block; color: var(--primary); }
.course-foot { margin-top: auto; padding-top: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.seat-bar { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; } .seat-bar > i { display: block; height: 100%; background: var(--primary); }

/* News */
.news-card { display: flex; flex-direction: column; gap: 6px; }
.news-item { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.news-item:last-child { border-bottom: 0; }
.news-date { width: 54px; text-align: center; background: var(--surface-2); border-radius: 12px; padding: 6px 0; flex-shrink: 0; height: fit-content; }
.news-date b { font-size: 20px; display: block; line-height: 1.1; } .news-date small { font-size: 11px; color: var(--muted); }
.article { max-width: 820px; } .article .body { font-size: 16px; line-height: 1.9; white-space: pre-line; }

/* Progress ring */
.ring { --p: 0; --c: var(--primary); width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--border) 0); position: relative; flex-shrink: 0; }
.ring::before { content: ''; position: absolute; inset: 14px; background: var(--surface); border-radius: 50%; }
.ring > div { position: relative; text-align: center; } .ring b { font-size: 30px; display: block; line-height: 1; } .ring small { color: var(--muted); }
.progress { height: 10px; background: var(--border); border-radius: 6px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 6px; transition: width 1s ease; }
.progress.ok > i { background: var(--ok); }
.req-list { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.req-row .top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }

/* Auth */
.auth-wrap { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.auth-card { width: min(460px, 100%); padding: 32px; }
.auth-card.wide { width: min(720px, 100%); }
.auth-card h2 { text-align: center; }

/* Detail */
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
@media (max-width: 960px) { .detail-grid { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 7px 16px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 14px; text-decoration: none !important; }
.tabs a.active { background: var(--primary-d); color: var(--on-primary); border-color: var(--primary-d); box-shadow: inset 0 -3px 0 var(--gold); }
.footer { padding: 18px 24px; text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }
.chart-box { position: relative; height: 280px; }
.faq details { border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; background: var(--surface); margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 600; } .faq details[open] summary { margin-bottom: 8px; color: var(--primary); }
.steps { counter-reset: s; display: grid; gap: 14px; }
.steps > div { display: flex; gap: 14px; align-items: flex-start; }
.steps > div::before { counter-increment: s; content: counter(s); width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }

/* ---------- Language switch, editable selects, tab bar (new) ---------- */
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 99px; overflow: hidden; background: var(--surface); }
.lang-switch a { padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none !important; }
.lang-switch a.active { background: var(--gold); color: #3a2a08; }
.sel-wrap { display: flex; gap: 6px; align-items: stretch; }
.sel-wrap > select { flex: 1; min-width: 0; }
.sel-btn { width: 40px; border: 1px solid var(--border); background: var(--surface); color: var(--primary-d); border-radius: 10px; cursor: pointer; font-size: 16px; display: grid; place-items: center; flex-shrink: 0; }
.sel-btn:hover { background: var(--primary-soft); }
.sel-btn.gold { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--gold); }
.modal-box.left { text-align: left; } .modal-box.left h3 { margin-bottom: 12px; }
.modal-box .field { margin-bottom: 12px; }
.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr 70px 1fr 90px auto; gap: 8px; align-items: center; }
.tabbar, .m-only { display: none; }
.content { animation: fadeUp .25s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Mobile / Tablet = App mode (<= 1024px) ---------- */
@media (max-width: 1024px) {
  body { font-size: 15px; overscroll-behavior-y: none; }
  .m-only { display: inline-grid; }
  .app-only-desktop { display: none !important; }
  .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(10,24,34,.55); z-index: 70; opacity: 0; pointer-events: none; transition: .2s; }
  body.sb-open .sb-backdrop { opacity: 1; pointer-events: auto; }
  .uname, .user-btn > .bi-chevron-down { display: none; }
  .user-btn { padding: 0; background: none; border: 0; }
  .content { padding: 14px 14px calc(var(--tab-h) + var(--safe-b) + 22px); }
  /* Bottom tab bar */
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 20px rgba(23,58,82,.1); }
  .tabbar a, .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: none; border: 0; font: inherit; font-size: 11px; font-weight: 500; color: var(--muted); text-decoration: none !important; cursor: pointer; padding: 6px 2px; }
  .tabbar i { font-size: 22px; line-height: 1; transition: transform .2s; }
  .tabbar .active { color: var(--primary-d); font-weight: 700; }
  [data-theme="dark"] .tabbar .active { color: var(--primary); }
  .tabbar .active i { transform: translateY(-2px) scale(1.08); }
  .tabbar .active::before { content: ''; position: absolute; top: 0; width: 34px; height: 4px; border-radius: 0 0 4px 4px; background: var(--gold); }
  .tabbar .t-dot { position: absolute; top: 5px; left: calc(50% + 8px); min-width: 17px; height: 17px; border-radius: 9px; background: var(--gold); color: #3a2a08; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; font-style: normal; }
  /* Inputs: no iOS zoom, big targets */
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=tel], select, textarea { font-size: 16px; min-height: 46px; }
  .btn { min-height: 44px; } .btn-sm { min-height: 38px; padding: 7px 14px; }
  .icon-btn { width: 42px; height: 42px; }
  .card { border-radius: 16px; }
  .toolbar > * { flex: 1 1 100%; } .toolbar .btn { flex: 1 1 auto; } .toolbar select, .toolbar input { width: 100% !important; }
  .toasts { top: calc(64px + var(--safe-t)); right: 12px; left: 12px; width: auto; }
  .hero { border-radius: 20px; padding: 26px 20px; }
  .detail-grid > aside { position: static !important; }
  .grid.g-main, .detail-grid { grid-template-columns: 1fr; }
  /* Modal → bottom sheet */
  .modal { place-items: end center; padding: 0; }
  .modal-box { width: 100%; max-width: 560px; border-radius: 24px 24px 0 0; padding: 24px 20px calc(24px + var(--safe-b)); animation: sheetUp .25s ease-out; }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
  .auth-wrap { min-height: auto; padding-top: 6px; }
  .auth-card { padding: 22px 18px; }
  .opt-grid { grid-template-columns: 1fr 1fr; }
}
/* Phone: tables become cards */
@media (max-width: 720px) {
  .card:has(> .table-wrap) { background: transparent; border: 0; box-shadow: none; padding: 0 !important; }
  .table-wrap { border: 0 !important; overflow: visible; background: transparent; }
  .table-wrap table:not(.keep), .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap td, .table-wrap tfoot { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 8px 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
  .table-wrap td { display: flex; justify-content: space-between; align-items: center; gap: 14px; border: 0; padding: 7px 0; text-align: right; }
  .table-wrap td + td { border-top: 1px dashed var(--border); }
  .table-wrap td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex-shrink: 0; }
  .table-wrap td[data-label=""]::before { display: none; }
  .table-wrap td.cell-empty { display: none; }
  .table-wrap td:first-child:not([data-label=""]) { display: block; text-align: left; }
  .table-wrap td:first-child:not([data-label=""])::before { display: block; margin-bottom: 2px; }
  .table-wrap td .actions { justify-content: flex-end; }
  .table-wrap td .progress { min-width: 120px; }
  .table-wrap td select { width: auto; min-height: 38px; }
  .report-sheet .table-wrap, .report-sheet table { display: table; } 
  .kv { grid-template-columns: 110px 1fr; }
  .stat-num { font-size: 24px; }
}

/* ---------- Top navigation (logo + org name + menu) ---------- */
.sb-backdrop { display: none; }
.topnav { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 2px 14px rgba(23,58,82,.06); }
.topnav::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: linear-gradient(90deg, var(--gold), var(--sand) 40%, var(--sky)); }
.topnav-in { max-width: 1400px; margin: 0 auto; height: 70px; padding: 0 24px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none !important; flex-shrink: 0; max-width: 300px; }
.brand-logo { width: 46px; height: 46px; border-radius: 13px; background: var(--primary-soft); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; border: 1px solid var(--border); }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text b { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.brand-text small { font-size: 11px; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; }
.nav-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; overflow: visible; white-space: nowrap; }
.nav-link { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border-radius: 12px; color: var(--text); font-weight: 500; font-size: 14px; text-decoration: none !important; position: relative; flex-shrink: 0; background: none; border: 0; font-family: inherit; cursor: pointer; }
.nav-link i { font-size: 17px; color: var(--primary); }
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--primary-d); color: #fff; box-shadow: inset 0 -3px 0 var(--gold); }
.nav-link.active i { color: #fff; }
.nav-link .dot { font-style: normal; font-size: 11px; background: var(--gold); color: #3a2a08; font-weight: 700; min-width: 19px; height: 19px; border-radius: 10px; display: grid; place-items: center; padding: 0 5px; }
.nav-more { position: relative; flex-shrink: 0; }
.nav-more[hidden] { display: none; }
.nav-more-menu { position: absolute; right: 0; top: calc(100% + 10px); min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 14px 40px rgba(0,0,0,.18); padding: 6px; display: none; z-index: 60; white-space: normal; }
.nav-more.open .nav-more-menu { display: block; animation: pop .15s ease-out; }
.nav-more-menu .nav-link { width: 100%; }
.topnav-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-left: auto; }
.page-head { background: linear-gradient(110deg, var(--accent-soft), var(--surface-2) 70%); border-bottom: 1px solid var(--border); }
.page-head .wrap { max-width: 1400px; margin: 0 auto; padding: 16px 24px; }
.page-head h1 { margin: 0; font-size: 22px; font-family: 'Playfair Display', 'Noto Sans Lao', serif; }
.subnav { background: var(--surface); border-bottom: 1px solid var(--border); }
.subnav .wrap { max-width: 1400px; margin: 0 auto; padding: 8px 24px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.subnav a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 16px; border-radius: 99px; white-space: nowrap; font-size: 14px; color: var(--text); border: 1px solid var(--border); text-decoration: none !important; }
.subnav a.active { background: var(--gold); border-color: var(--gold); color: #3a2a08; font-weight: 600; }

/* ---------- Home: slider, search, sections ---------- */
.slider { position: relative; border-radius: 22px; overflow: hidden; height: 380px; margin-bottom: 26px; background: #1B4560; outline-offset: 3px; box-shadow: var(--shadow); }
.slide { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity .7s ease, visibility .7s; display: flex; align-items: flex-end; background-size: cover; background-position: center; }
.slide.on { opacity: 1; visibility: visible; z-index: 1; }
.slide.g0 { background-image: linear-gradient(120deg, #1B4560 0%, #3680AB 58%, #60C5FA 100%); }
.slide.g1 { background-image: linear-gradient(120deg, #245B7D 0%, #3680AB 50%, #E2BB77 100%); }
.slide.g2 { background-image: linear-gradient(120deg, #173A52 0%, #2D6E97 55%, #E6D2B0 100%); }
.slide::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(14,38,55,.82) 0%, rgba(14,38,55,.45) 55%, rgba(14,38,55,.1) 100%); }
.slide .in { position: relative; z-index: 1; color: #fff; max-width: 680px; padding: 40px 90px 64px; }
.slide .in .badge { background: var(--gold); color: #3a2a08; margin-bottom: 12px; }
.slide .in h2 { font-family: 'Playfair Display', 'Noto Sans Lao', serif; font-size: 32px; margin: 0 0 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slide .in p { margin: 0 0 18px; font-size: 16px; opacity: .95; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slider .arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(255,255,255,.55); background: rgba(14,38,55,.45); color: #fff; font-size: 20px; cursor: pointer; display: grid; place-items: center; backdrop-filter: blur(4px); transition: .15s; }
.slider .arrow:hover { background: var(--gold); color: #3a2a08; border-color: var(--gold); }
.slider .arrow.prev { left: 16px; } .slider .arrow.next { right: 16px; }
.slider .dots { position: absolute; left: 0; right: 0; bottom: 18px; z-index: 3; display: flex; gap: 8px; justify-content: center; }
.slider .dots button { width: 10px; height: 10px; padding: 0; border-radius: 99px; border: 0; background: rgba(255,255,255,.55); cursor: pointer; transition: .25s; }
.slider .dots button.on { width: 28px; background: var(--gold); }
.sec { margin-bottom: 30px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sec-head h2 { margin: 0; font-size: 21px; font-family: 'Playfair Display', 'Noto Sans Lao', serif; display: flex; align-items: center; gap: 10px; }
.sec-head h2::before { content: ''; width: 5px; height: 24px; border-radius: 3px; background: linear-gradient(var(--gold), var(--blue)); }
.sec-head a.more { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.search-box { background: linear-gradient(120deg, var(--accent-soft), var(--primary-soft)); border: 1px solid var(--border); border-radius: 22px; padding: 26px; }
.search-box h2 { margin: 0 0 14px; font-size: 21px; font-family: 'Playfair Display', 'Noto Sans Lao', serif; }
.search-row { display: flex; gap: 10px; }
.search-row .searchbox { flex: 1; }
.search-row input { height: 52px; font-size: 16px; border-radius: 14px; }
.search-row .btn { height: 52px; border-radius: 14px; padding: 0 28px; }
.scopes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.scopes label { cursor: pointer; }
.scopes input { position: absolute; opacity: 0; pointer-events: none; }
.scopes span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-size: 14px; transition: .15s; }
.scopes input:checked + span { background: var(--primary-d); color: #fff; border-color: var(--primary-d); box-shadow: inset 0 -3px 0 var(--gold); }
.scopes input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.hrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.ncard { display: flex; flex-direction: column; padding: 0; overflow: hidden; transition: transform .2s, box-shadow .2s; }
.ncard:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(23,58,82,.16); }
.ncard .thumb { height: 150px; background-size: cover; background-position: center; display: grid; place-items: center; color: rgba(255,255,255,.85); font-size: 44px; }
.ncard .thumb.g0 { background-image: linear-gradient(120deg, #1B4560, #3680AB 60%, #60C5FA); } .ncard .thumb.g1 { background-image: linear-gradient(120deg, #245B7D, #3680AB 50%, #E2BB77); } .ncard .thumb.g2 { background-image: linear-gradient(120deg, #173A52, #2D6E97 55%, #E6D2B0); }
.ncard .nb { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.ncard h3 { margin: 0; font-size: 16px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ncard h3 a { color: var(--text); }
.ncard p { margin: 0; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ncard .nf { margin-top: auto; padding-top: 6px; font-weight: 600; }
.stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.stats-grid .stat { flex-direction: column; align-items: flex-start; gap: 10px; padding: 18px; }
.stats-grid .stat-num { font-size: 30px; }
.result-sec { margin-bottom: 26px; }
.mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---------- Footer band ---------- */
.site-footer { margin-top: 36px; background: linear-gradient(135deg, #173A52 0%, #245B7D 55%, #3680AB 100%); color: #DCEBF4; border-top: 5px solid var(--gold); position: relative; }
.site-footer a { color: #fff; }
.sf-in { max-width: 1400px; margin: 0 auto; padding: 38px 24px 26px; display: grid; grid-template-columns: 1.6fr 1fr 1.3fr 1fr; gap: 30px; }
.sf-in h4 { color: var(--gold); font-size: 14px; letter-spacing: .8px; text-transform: uppercase; margin-bottom: 12px; }
.sf-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; color: #fff; font-weight: 700; }
.sf-brand .brand-logo { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; }
.sf-in p { margin: 0 0 8px; font-size: 14px; opacity: .92; }
.sf-in ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.sf-in li i { color: var(--gold); width: 22px; display: inline-block; }
.sf-social { display: flex; gap: 8px; margin-top: 10px; }
.sf-social a { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.14); display: grid; place-items: center; transition: .15s; text-decoration: none !important; }
.sf-social a:hover { background: var(--gold); color: #3a2a08; }
.sf-bottom { border-top: 1px solid rgba(255,255,255,.16); text-align: center; padding: 14px 24px; font-size: 13px; color: #B9D3E3; }

/* ---------- Mobile "More" sheet ---------- */
.sheet { display: none; }


@media (max-width: 1024px) {
  .topnav { background: var(--primary-d); padding-top: var(--safe-t); box-shadow: 0 2px 10px rgba(23,58,82,.25); }
  [data-theme="dark"] .topnav { background: var(--side-bg); }
  .topnav-in { height: 58px; padding: 0 14px; gap: 10px; }
  .brand { max-width: none; flex: 1; min-width: 0; color: #fff; }
  .brand-logo { width: 38px; height: 38px; border-radius: 11px; background: rgba(255,255,255,.95); }
  .brand-text b { color: #fff; font-size: 13px; }
  .brand-text small { display: none; }
  .nav-main { display: none; }
  .topnav-right { margin-left: 0; gap: 8px; }
  .topnav-right .btn { display: none; }
  .topnav .lang-switch { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); }
  .topnav .lang-switch a { color: #fff; padding: 4px 10px; } .topnav .lang-switch a.active { color: #3a2a08; }
  .topnav .user-btn { padding: 0; background: none; border: 0; }
  .topnav .icon-btn { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); color: #fff; }
  .page-head .wrap { padding: 10px 14px; } .page-head h1 { font-size: 18px; }
  .subnav .wrap { padding: 8px 14px; }
  .slider { height: 320px; border-radius: 20px; margin-bottom: 20px; }
  .slide .in { padding: 22px 20px 54px; } .slide .in h2 { font-size: 22px; } .slide .in p { font-size: 14px; margin-bottom: 14px; }
  .slider .arrow { width: 38px; height: 38px; font-size: 16px; top: auto; bottom: 10px; transform: none; } .slider .arrow.prev { left: auto; right: 62px; } .slider .arrow.next { right: 14px; }
  .slider .dots { justify-content: flex-start; padding-left: 20px; bottom: 26px; }
  .search-box { padding: 18px; border-radius: 18px; } .search-row { flex-direction: column; } .search-row .btn { width: 100%; }
  .hrow { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 14px; margin: 0 -14px; padding: 2px 14px 10px; scrollbar-width: none; }
  .hrow::-webkit-scrollbar { display: none; }
  .hrow > * { flex: 0 0 82%; max-width: 340px; scroll-snap-align: start; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } .stats-grid .stat { padding: 14px; }
  .sec { margin-bottom: 22px; } .sec-head h2 { font-size: 18px; }
  .site-footer { margin-top: 20px; padding-bottom: calc(var(--tab-h) + var(--safe-b)); }
  .sf-in { grid-template-columns: 1fr; padding: 26px 18px 14px; gap: 22px; }
  .sheet { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 16px calc(20px + var(--safe-b)); max-height: 82vh; overflow-y: auto; transform: translateY(105%); transition: transform .28s cubic-bezier(.4,0,.2,1); box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
  body.sheet-open .sheet { transform: none; }
  body.sheet-open .sb-backdrop { opacity: 1; pointer-events: auto; z-index: 85; }
  .sheet-grab { width: 44px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 10px; }
  .sheet h5 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 12px 6px 4px; }
  .sheet a { display: flex; align-items: center; gap: 14px; padding: 12px; min-height: 48px; border-radius: 12px; color: var(--text); text-decoration: none !important; }
  .sheet a i { font-size: 20px; color: var(--primary); width: 24px; text-align: center; }
  .sheet a.active { background: var(--primary-soft); color: var(--primary-d); font-weight: 600; }
  .sheet a:active { background: var(--surface-2); }
}
@media (min-width: 1025px) and (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } .sf-in { grid-template-columns: 1fr 1fr; } }
@media (max-width: 1024px) and (min-width: 721px) { .hrow > * { flex-basis: 46%; } .stats-grid { grid-template-columns: repeat(3, 1fr); } .sf-in { grid-template-columns: 1fr 1fr; } }
/* ---------- Print (ໃບຢັ້ງຢືນ / ລາຍງານ) ---------- */
.cert-page { background: #fff; color: #111; max-width: 1000px; margin: 20px auto; padding: 14px; }
.cert { border: 10px double #3680AB; outline: 3px solid #E2BB77; outline-offset: -22px; padding: 50px 40px; text-align: center; position: relative; background: #FFFBF2; color: #1B2B38; }
.cert h1 { font-family: 'Playfair Display','Noto Sans Lao',serif; font-size: 40px; color: #245B7D; margin-bottom: 4px; letter-spacing: 1px; }
.cert .name { font-size: 36px; font-weight: 700; margin: 18px 0; border-bottom: 2px solid #E2BB77; display: inline-block; padding: 0 40px 6px; }
.cert .course { font-size: 22px; font-weight: 600; color: #245B7D; margin: 12px 0; }
.cert .sign { display: flex; justify-content: space-around; margin-top: 50px; }
.cert .sign div { width: 220px; border-top: 1px solid #333; padding-top: 6px; }
.print-bar { text-align: center; margin: 14px; }
.report-sheet { background: #fff; color: #111; padding: 30px; max-width: 900px; margin: 0 auto; border: 1px solid var(--border); border-radius: 8px; }
.report-sheet table { background: #fff; } .report-sheet th { background: #f1f5f9; color: #334155; } .report-sheet td, .report-sheet th { border: 1px solid #cbd5e1; }
@media print {
  .topnav, .page-head, .subnav, .site-footer, .tabbar, .sheet, .print-bar, .no-print, .toasts, .sb-backdrop { display: none !important; }
  .main { margin: 0 !important; } .content { padding: 0; max-width: none; } body { background: #fff; }
  .cert-page { margin: 0; padding: 0; } .report-sheet { border: 0; padding: 0; }
  @page { size: A4 landscape; margin: 10mm; }
  .report-sheet-page { }
}

/* ---- multi images / gallery / avatar photo ---- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; margin: 8px 0; }
.media-grid:empty { display: none; }
.media-item { border: 1px solid var(--border); border-radius: 12px; padding: 6px; background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; }
.media-item img, .media-grid > img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; display: block; }
.media-item .check { font-size: 12px; } .media-item .danger { color: var(--danger, #c0392b); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 14px 0; }
.gallery a { display: block; border-radius: 12px; overflow: hidden; aspect-ratio: 4/3; background: var(--surface-2); }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; display: block; }
.gallery a:hover img { transform: scale(1.05); }
.gallery.hero-g a:first-child:nth-last-child(n+2) { grid-column: 1 / -1; aspect-ratio: 16/8; }
.gallery.hero-g a:first-child:last-child { grid-column: 1 / -1; aspect-ratio: auto; background: none; }
.gallery.hero-g a:first-child:last-child img { height: auto; }
.avatar.has-img { background: none; overflow: hidden; padding: 0; }
.avatar.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 22px; }
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(10,20,30,.92); display: none; align-items: center; justify-content: center; padding: 20px; }
.lightbox.on { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }
.lightbox button { position: absolute; background: rgba(255,255,255,.16); color: #fff; border: 0; width: 44px; height: 44px; border-radius: 50%; font-size: 22px; cursor: pointer; }
.lightbox .lb-x { top: 16px; right: 16px; } .lightbox .lb-p { left: 14px; top: 50%; } .lightbox .lb-n { right: 14px; top: 50%; }

/* ---- v3.5: mobile More sheet keeps the bottom tab bar visible ---- */
@media (max-width: 1024px) {
  .tabbar { z-index: 95; }
  .sb-backdrop { display: block !important; z-index: 85; }
  .sheet { z-index: 90; bottom: calc(var(--tab-h) + var(--safe-b)); max-height: calc(100vh - var(--tab-h) - var(--safe-b) - 70px); border-radius: 24px 24px 0 0; padding-bottom: 16px; overscroll-behavior: contain; }
  body.sheet-open { overflow: hidden; }
  body.sheet-open #tabMore { color: var(--primary-d); font-weight: 700; }
  [data-theme="dark"] body.sheet-open #tabMore { color: var(--primary); }
  .topnav .brand { flex: 1; min-width: 0; max-width: none; }
  .topnav .brand-text { min-width: 0; }
  .topnav .brand-text b { font-size: 13px; }
  .topnav .brand-text small { display: none; }
}

/* ---- v3.7: mobile bottom tab bar uses the same colour as the header ---- */
@media (max-width: 1024px) {
  .tabbar { background: var(--primary-d); border-top: 3px solid var(--gold); box-shadow: 0 -4px 20px rgba(23,58,82,.28); }
  [data-theme="dark"] .tabbar { background: var(--side-bg); }
  .tabbar a, .tabbar button { color: rgba(255,255,255,.72); }
  .tabbar .active, [data-theme="dark"] .tabbar .active, body.sheet-open #tabMore, [data-theme="dark"] body.sheet-open #tabMore { color: var(--gold); }
  .tabbar .active::before { display: none; }
  .tabbar .t-dot { background: var(--gold); color: #3a2a08; }
}
