/* Quản lý TMY: giao diện CRM, màu thương hiệu Thanh Mai Yokohama (xanh đậm, xanh nhạt). Máy tính: menu trái; điện thoại: menu dưới. */
:root {
  --brand: #10291a;
  --brand-2: #1a4a2a;
  --accent: #a8d5b5;
  --soft: #e5efd7;
  --bg: #f3f6f4;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --ok: #1f7a3a;
  --bad: #c62828;
  --warn: #a16207;
  --blue: #1d4ed8;
  --bar: #2f6b45;          /* màu cột biểu đồ / thanh tỉ trọng (một chuỗi, một màu) */
  --radius: 14px;
  --lift: 0 1px 2px rgba(16, 41, 26, .06), 0 6px 18px rgba(16, 41, 26, .07);
  --side-w: 236px;
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: 'Roboto', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif; line-height: 1.5; font-size: 15px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; color: var(--brand); }
h2 { font-size: 19px; color: var(--brand); }
h3 { font-size: 16px; color: var(--brand); margin-bottom: 10px; }
.meta { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.nowrap { white-space: nowrap; }

/* ---------- khung ---------- */
.tmy-logo { display: block; height: 28px; aspect-ratio: 253 / 160; background: currentColor;
  -webkit-mask: url(/logo-tmy.png) center / contain no-repeat; mask: url(/logo-tmy.png) center / contain no-repeat; }
.tmy-logo.full { height: 70px; aspect-ratio: 347 / 220; -webkit-mask-image: url(/logo-tmy-full.png); mask-image: url(/logo-tmy-full.png); color: var(--brand); margin: 0 auto 10px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: flex; color: var(--soft); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 16px; }
.brand-text small { font-size: 11px; opacity: .7; }
.side { display: none; }
.topbar { position: sticky; top: 0; z-index: 40; background: var(--brand); color: #fff; padding: 10px 16px; }
.view { max-width: 1100px; margin: 0 auto; padding: 18px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px); }
.view.wide { max-width: 1320px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); box-shadow: 0 -2px 10px rgba(0,0,0,.05); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 2px; font-size: 11px; color: var(--muted); min-width: 0; }
.tabbar a span { font-size: 19px; line-height: 1.2; }
.tabbar a.on { color: var(--brand); font-weight: 700; }
body.no-chrome .topbar, body.no-chrome .tabbar, body.no-chrome .side { display: none !important; }
body.no-chrome .view { padding-bottom: 24px; }
@media (min-width: 1000px) {
  .side { display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--brand); color: #fff; padding: 18px 12px; z-index: 40; }
  .side .brand { padding: 0 8px 18px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 12px; }
  .sidenav { display: flex; flex-direction: column; gap: 2px; }
  .sidenav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: rgba(255,255,255,.82); font-weight: 500; }
  .sidenav a span { width: 22px; text-align: center; }
  .sidenav a:hover { background: rgba(255,255,255,.08); color: #fff; }
  .sidenav a.on { background: var(--soft); color: var(--brand); font-weight: 700; }
  .side-user { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255,255,255,.12); display: flex; flex-direction: column; font-size: 13px; }
  .side-user small { opacity: .65; }
  .topbar, .tabbar { display: none; }
  #app { padding-left: var(--side-w); }
  body.no-chrome #app { padding-left: 0; }
  .view { padding: 26px 28px 40px; }
}

/* ---------- thành phần chung ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--lift); border: 1px solid rgba(16,41,26,.05); margin-bottom: 14px; }
.card-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.card-h h3 { margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; border-radius: 10px;
  padding: 9px 16px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--brand-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.ghost:hover { background: var(--soft); }
.btn.sm { padding: 6px 12px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.danger-t { color: var(--bad); border-color: #f1c4c4; }
.lnk { border: 0; background: none; color: var(--blue); padding: 0 2px; font-size: 13px; }
.chip { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; background: #eef2ef; color: var(--muted); white-space: nowrap; }
.chip.ok { background: #e3f4e8; color: var(--ok); }
.chip.bad { background: #fde8e8; color: var(--bad); }
.chip.warn { background: #fdf3d7; color: var(--warn); }
.chip.blue { background: #e4ecfd; color: var(--blue); }
.spinner { padding: 40px; text-align: center; color: var(--muted); }
.empty { text-align: center; padding: 50px 16px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 300; transition: .2s; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { background: var(--bad); }
@media (min-width: 1000px) { .toast { bottom: 24px; } }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--brand); font-weight: 500; }

/* bộ lọc */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; }
.filters input[type=search] { flex: 1 1 260px; }
.filters select, .filters input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; min-width: 0; max-width: 100%; }
.filters .dr { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

/* bảng */
.tbl-wrap { overflow-x: auto; background: #fff; border-radius: var(--radius); }
#st-tbl > .tbl-wrap, #pm-tbl > .tbl-wrap, #u-tbl > .tbl-wrap, #c-tbl > .tbl-wrap { box-shadow: var(--lift); border: 1px solid rgba(16,41,26,.05); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfa; white-space: nowrap; position: sticky; top: 0; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--brand); }
.tbl th.asc::after { content: ' ▲'; font-size: 9px; }
.tbl th.desc::after { content: ' ▼'; font-size: 9px; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid #f0f2f0; vertical-align: top; }
.tbl td small { display: block; color: var(--muted); font-size: 12px; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #f6faf4; }
.tbl tr.click:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; }
.tbl a { color: var(--blue); }
.empty-row { text-align: center; color: var(--muted); padding: 30px 12px !important; }
.pager { display: flex; justify-content: center; gap: 4px; margin: 14px 0; flex-wrap: wrap; }
.pager button { min-width: 36px; height: 36px; border: 1px solid var(--line); background: #fff; border-radius: 9px; }
.pager button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .gap { align-self: center; color: var(--muted); padding: 0 2px; }
/* điện thoại: bảng học viên / thanh toán thành thẻ (mỗi ô một dòng có nhãn) */
@media (max-width: 720px) {
  .hide-sm { display: none; }
  #st-tbl .tbl thead, #pm-tbl .tbl thead { display: none; }
  #st-tbl .tbl tr, #pm-tbl .tbl tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  #st-tbl .tbl td, #pm-tbl .tbl td { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; padding: 3px 0; border: 0; text-align: left; }
  #st-tbl .tbl td::before, #pm-tbl .tbl td::before { content: attr(data-l); color: var(--muted); font-size: 12px; padding-top: 2px; }
  #st-tbl .tbl td .cv, #pm-tbl .tbl td .cv { min-width: 0; overflow-wrap: anywhere; }
  #st-tbl .tbl td.hide-sm, #pm-tbl .tbl td.hide-sm { display: none; }
}

/* popup */
.pop-bg { position: fixed; inset: 0; z-index: 200; background: rgba(16, 24, 20, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.fp-bg { align-items: flex-start; overflow-y: auto; padding: 6vh 16px; }
.pop { max-width: 420px; width: 100%; margin: 0; }
.pop-h { display: block; font-size: 17px; margin-bottom: 6px; }
.pop-btns, .fp-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; align-items: center; }
.fp-btns .sp { flex: 1; }
.fp { width: 100%; max-width: 480px; margin: 0; background: #fff; }
.fp.wide { max-width: 780px; }
.fp-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.fp-h h3 { margin: 0; font-size: 18px; }
.fp-x { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--muted); padding: 0 4px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 500; color: #374151; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border: 1px solid #d6dbd7; border-radius: 9px; background: #fff; }
.field input:focus, .field select:focus, .field textarea:focus, .filters input:focus, .filters select:focus { outline: 2px solid var(--accent); border-color: var(--brand-2); }
.req { color: var(--bad); font-style: normal; }
.ro { padding: 9px 11px; background: #f6f8f6; border-radius: 9px; }
.grid2 { display: grid; grid-template-columns: 1fr; column-gap: 14px; }
.grid2 h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--brand-2); margin: 6px 0 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.grid2 h4:first-child { border-top: 0; padding-top: 0; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } .span2 { grid-column: 1 / -1; } }
.form-err { color: var(--bad); font-size: 14px; white-space: pre-line; min-height: 0; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 4px 0 10px; }
.pick { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.pick button { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 10px; }
.pick button:hover { background: var(--soft); }
.pick small { display: block; color: var(--muted); font-size: 12px; }

/* chi tiết */
.detail-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.detail-grid .card { margin-bottom: 0; }
.detail-grid + .card, .detail-grid ~ .card { margin-top: 14px; }
@media (min-width: 860px) { .detail-grid { grid-template-columns: 1fr 1fr; } }
.dl { margin: 0; display: grid; gap: 2px; }
.dl > div { display: grid; grid-template-columns: 140px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px dashed #edf0ed; }
.dl > div:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; word-break: break-word; }
.dl a { color: var(--blue); }
.note { margin: 0; white-space: normal; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 16px; border-left: 2px solid var(--soft); position: relative; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--bar); }
.timeline small { display: block; color: var(--muted); font-size: 12px; }
.pay-amt { font-size: 28px; font-weight: 700; color: var(--brand); margin-bottom: 8px; font-variant-numeric: tabular-nums; }

/* chỉ số */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpis.sm { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi { background: #fff; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--lift); border: 1px solid rgba(16,41,26,.05); display: flex; flex-direction: column; gap: 2px; }
.kpi > span { color: var(--muted); font-size: 13px; }
.kpi > b { font-size: 24px; color: var(--brand); font-variant-numeric: tabular-nums; line-height: 1.25; }
.kpis.sm .kpi > b { font-size: 17px; }
.kpi em { font-style: normal; font-size: 13px; }
.kpi em small, .kpi > small { color: var(--muted); font-size: 12px; }
.kpi a { color: var(--blue); }
.dl-up { color: var(--ok); font-weight: 600; }
.dl-down { color: var(--bad); font-weight: 600; }

/* biểu đồ */
.charts { display: grid; gap: 14px; grid-template-columns: 1fr; }
.charts .card { margin-bottom: 0; }
@media (min-width: 1100px) { .charts { grid-template-columns: 1fr 1fr; } }
.charts + * { margin-top: 14px; }
.chart { width: 100%; height: 230px; display: block; overflow: visible; }
.chart .grid { stroke: #eef1ee; stroke-width: 1; }
.chart .base { stroke: #cfd6d0; stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--bar); }
.chart .hit { fill: transparent; }
.chart .hit.on { fill: rgba(47, 107, 69, .08); }
.tip { position: fixed; z-index: 400; background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12); pointer-events: none; max-width: 260px; }
details.raw summary { cursor: pointer; font-weight: 500; color: var(--brand); }
details.raw .tbl-wrap { margin-top: 10px; max-height: 360px; overflow: auto; }
.bd-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.bd-grid .card { margin-bottom: 0; }
@media (min-width: 1100px) { .bd-grid { grid-template-columns: 1fr 1fr; } }
.tbl.bd td small { display: inline; margin-left: 6px; }
.tbl .share { width: 34%; min-width: 140px; }
.share { white-space: nowrap; }
td.share { display: table-cell; }
td.share .sbar { display: inline-block; vertical-align: middle; width: calc(100% - 52px); }
td.share span { display: inline-block; width: 48px; text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sbar { height: 8px; background: #eef2ef; border-radius: 99px; overflow: hidden; }
.sbar i { display: block; height: 100%; background: var(--bar); border-radius: 99px; }
.hbars { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.hb { display: grid; grid-template-columns: 130px 1fr 60px; gap: 10px; align-items: center; padding: 5px 4px; border-radius: 8px; }
.hb:hover { background: #f6faf4; }
.hb b { text-align: right; font-variant-numeric: tabular-nums; }

/* đăng nhập, tài khoản */
.auth-wrap { max-width: 400px; margin: 8vh auto 0; }
.auth-logo { text-align: center; margin-bottom: 18px; }
.auth-logo h1 { font-size: 24px; }
.auth-logo p { color: var(--muted); margin: 4px 0 0; }
.acct { max-width: 560px; }
.acct-hd { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--brand); color: var(--soft); display: grid; place-items: center; font-size: 22px; font-weight: 700; }

/* cây nhóm bên trái (Tất cả → Năm → Tháng → Tokutei / JLPT) + bảng bên phải */
.split { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.split-main { min-width: 0; }
.tree-box { padding: 12px 8px; margin-bottom: 0; max-height: 300px; overflow: auto; }
@media (min-width: 1000px) {
  .split { grid-template-columns: 250px minmax(0, 1fr); }
  .tree-box { position: sticky; top: 16px; max-height: calc(100vh - 32px); }
}
.tree-h { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 8px 8px; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tn { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px calc(4px + var(--d) * 14px); border-radius: 9px; cursor: pointer; user-select: none; }
.tn:hover { background: #f1f5ef; }
.tn.on { background: var(--soft); font-weight: 700; color: var(--brand); }
.tw { width: 20px; height: 20px; flex: none; border: 0; background: none; padding: 0; color: var(--muted); font-size: 12px; display: grid; place-items: center; border-radius: 5px; transition: transform .15s; }
button.tw:hover { background: #e3e9e1; }
.tw.open { transform: rotate(90deg); }
.tl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn .cnt { font-size: 12px; background: #eef2ef; color: #4b5563; border-radius: 6px; padding: 0 6px; font-variant-numeric: tabular-nums; font-weight: 500; }
.tn.on .cnt { background: #fff; }
.tn .sum { font-size: 11px; color: var(--muted); min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
@media (min-width: 721px) and (max-width: 1480px) { .hide-md { display: none; } }   /* bảng cạnh cây nhóm: ẩn bớt cột phụ */
#st-tbl .tbl td:nth-child(2), #pm-tbl .tbl td:nth-child(2) { max-width: 230px; min-width: 170px; }   /* tên + email dài: xuống dòng thay vì đẩy bảng rộng ra */
.tbl td small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }   /* email dài: một dòng, cắt bằng … (rê chuột / mở chi tiết để xem đủ) */
@media (min-width: 1000px) and (max-width: 1480px) { .split { grid-template-columns: 228px minmax(0, 1fr); } .tbl th, .tbl td { padding-left: 10px; padding-right: 10px; } }
.sidenav a em { font-style: normal; }
.side-toggle { display: none; }
@media (min-width: 1000px) {
  .side { transition: width .18s; }
  .side-toggle { display: grid; place-items: center; position: absolute; top: 14px; right: 10px; width: 32px; height: 32px; border: 0; border-radius: 8px;
    background: transparent; color: rgba(255,255,255,.75); font-size: 18px; }
  .side-toggle:hover { background: rgba(255,255,255,.1); color: #fff; }
  #app { transition: padding-left .18s; }
  /* thu gọn: cột biểu tượng 68px, rê chuột hiện tên (title) */
  body.side-mini { --side-w: 68px; }
  body.side-mini .side { padding: 14px 8px; }
  body.side-mini .side .brand { padding: 44px 0 14px; justify-content: center; }
  body.side-mini .side .brand-text, body.side-mini .sidenav a em, body.side-mini .side-user { display: none; }
  body.side-mini .side-toggle { left: 18px; right: auto; }
  body.side-mini .sidenav a { justify-content: center; padding: 11px 0; }
  body.side-mini .sidenav a span { width: auto; font-size: 19px; }
}
/* cây rộng hơn để không cắt chữ (cây thanh toán có thêm cột tổng tiền) */
@media (min-width: 1000px) {
  .split, .split.money { grid-template-columns: 270px minmax(0, 1fr); }
  .split.money { grid-template-columns: 310px minmax(0, 1fr); }
}
.tn { padding-left: calc(4px + var(--d) * 12px); }

#st-tbl .tbl td:nth-child(2) .cv, #pm-tbl .tbl td:nth-child(2) .cv { max-width: 210px; }   /* giới hạn ô tên để email cắt bằng … */
@media (max-width: 720px) { #st-tbl .tbl td:nth-child(2) .cv, #pm-tbl .tbl td:nth-child(2) .cv { max-width: none; } }
@media (min-width: 1000px) and (max-width: 1480px) { body:not(.side-mini) .split { grid-template-columns: 232px minmax(0, 1fr); } body:not(.side-mini) .split.money { grid-template-columns: 280px minmax(0, 1fr); } }

/* thanh tìm kiếm một ô (kính lúp) */
.searchbar { display: flex; align-items: center; gap: 10px; background: #eef1ef; border-radius: 10px; padding: 0 14px; margin-bottom: 12px; color: #4b5563; }
.searchbar:focus-within { background: #fff; box-shadow: 0 0 0 2px var(--accent); }
.searchbar input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 11px 0; font-size: 15px; outline: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 10px; }
.chips:empty { display: none; }
.fchip { border: 1px solid #cfe0c9; background: var(--soft); color: var(--brand); border-radius: 99px; padding: 3px 10px; font-size: 13px; }
.fchip b { margin-left: 2px; }
.fchip:hover { background: #d9e8cc; }
/* đóng băng dòng tiêu đề: bảng cuộn trong khung cao vừa màn hình, tiêu đề cột dính trên cùng */
@media (min-width: 721px) {
  #st-tbl > .tbl-wrap, #pm-tbl > .tbl-wrap { max-height: calc(100vh - 210px); overflow: auto; }
  .tbl thead th { position: sticky; top: 0; z-index: 2; background: #f6f8f6; box-shadow: inset 0 -1px 0 var(--line); }
}

/* ================= bố cục như AppSheet (30/10/2026): thanh trên trắng + menu trái sáng ================= */
:root { --appbar-h: 60px; }
.topbar { display: none !important; }
.appbar { position: sticky; top: 0; z-index: 60; height: var(--appbar-h); background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 16px; }
.appbar .brand { gap: 12px; color: var(--brand); flex: none; }
.appbar .tmy-logo { height: 26px; color: var(--brand); }
.appbar .brand b { font-size: 20px; font-weight: 500; color: #1f2937; white-space: nowrap; }
.appbar-search { flex: 1; max-width: 560px; margin-left: 24px; }
.appbar-search:empty { display: none; }
.appbar-search .searchbar { margin: 0; }
.appbar .side-toggle { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent;
  color: #374151; font-size: 20px; position: static; flex: none; }
.appbar .side-toggle:hover { background: #f1f3f1; }
h1.bc { font-size: 22px; font-weight: 400; color: #374151; display: flex; align-items: center; gap: 10px; }
h1.bc a { color: #6b7280; }
h1.bc a:hover { color: var(--brand); }
h1.bc i { font-style: normal; color: #9ca3af; font-size: 20px; }
@media (max-width: 999px) {
  .appbar { height: auto; min-height: 56px; flex-wrap: wrap; padding: 8px 12px; gap: 8px 10px; }
  .appbar .side-toggle { display: none; }
  .appbar .brand b { font-size: 17px; }
  .appbar-search { flex-basis: 100%; max-width: none; margin: 0; }
}
@media (min-width: 1000px) {
  :root { --side-w: 220px; }
  #app { padding-left: 0; }
  .side { position: fixed; top: var(--appbar-h); bottom: 0; left: 0; width: var(--side-w); background: #fff; color: #374151; border-right: 1px solid var(--line);
    padding: 12px 10px; display: flex; flex-direction: column; z-index: 40; }
  .sidenav a { color: #374151; font-weight: 500; border-radius: 22px; }
  .sidenav a:hover { background: #f1f5ef; color: var(--brand); }
  .sidenav a.on { background: var(--soft); color: var(--brand); }
  .side-user { border-top: 1px solid var(--line); color: #374151; }
  .view, .view.wide { margin: 0 0 0 var(--side-w); max-width: none; padding: 18px 24px 40px; }
  body.no-chrome .view { margin-left: auto; }
  body.side-mini { --side-w: 68px; }
  body.side-mini .side { padding: 12px 8px; }
  body.side-mini .sidenav a { justify-content: center; padding: 11px 0; border-radius: 50%; width: 48px; height: 48px; margin: 0 auto; }
  /* bảng không giới hạn chiều cao: cuộn cả trang, tiêu đề cột dính ngay dưới thanh trên */
  #st-tbl > .tbl-wrap, #pm-tbl > .tbl-wrap { max-height: none; overflow: visible; }
  .list-view .tbl thead th { top: var(--appbar-h); }   /* chỉ bảng Học viên / Thanh toán (trang khác: tiêu đề dính trong khung bảng) */
  .tree-box { top: calc(var(--appbar-h) + 12px); max-height: calc(100vh - var(--appbar-h) - 24px); }
}
body.no-chrome .appbar, body.no-chrome .side { display: none !important; }

@media (min-width: 1000px) { .side, #app { transition: none !important; } }
@media (max-width: 720px) { .tbl td small { white-space: normal; overflow-wrap: anywhere; } }

/* ================= trang danh sách kiểu AppSheet (đo theo ảnh 1280px): phẳng, nền trắng =================
   thanh trên 56 · cột biểu tượng 60 · dòng "Home ›" 50 · cây 240 (dòng 33) · bảng: tiêu đề 40, dòng 38, kẻ dọc giữa cột */
.icon-btn { width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: #4b5563; font-size: 18px; display: grid; place-items: center; }
.icon-btn:hover { background: #f1f3f4; color: var(--brand); }
@media (min-width: 1000px) {
  :root { --appbar-h: 56px; }
  body.side-mini { --side-w: 60px; }
  body.side-mini .sidenav a { width: 44px; height: 44px; }
  .view.list-view { padding: 0; background: #fff; min-height: calc(100vh - var(--appbar-h)); }
  .list-view .page-head { height: 50px; margin: 0; padding: 0 12px 0 16px; align-items: center; flex-wrap: nowrap; border-bottom: 1px solid #e5e7eb;
    position: sticky; top: var(--appbar-h); z-index: 30; background: #fff; }
  .list-view .page-head .acts { align-items: center; gap: 6px; }
  .list-view h1.bc { font-size: 19px; }
  .list-view .split, .list-view .split.money { grid-template-columns: 240px minmax(0, 1fr); gap: 0; align-items: stretch; }
  body:not(.side-mini) .list-view .split, body:not(.side-mini) .list-view .split.money { grid-template-columns: 240px minmax(0, 1fr); }
  .list-view .tree-box { margin: 0; padding: 8px 8px; border: 0; border-right: 1px solid #e5e7eb; border-radius: 0; box-shadow: none; background: #fff;
    position: sticky; top: calc(var(--appbar-h) + 50px); height: calc(100vh - var(--appbar-h) - 50px); max-height: none; overflow: auto; align-self: start; }
  .list-view .tree-h { display: none; }
  .list-view .tn { min-height: 33px; padding-top: 0; padding-bottom: 0; border-radius: 17px; font-size: 15px; }
  .list-view .tn.on { background: #e8eaed; color: #1f2937; font-weight: 500; }
  .list-view .tn .cnt { background: #eceef0; }
  .list-view .split-main { border-left: 0; }
  .list-view .chips { padding: 8px 12px 0; margin: 0; }
  .list-view #st-tbl > .tbl-wrap, .list-view #pm-tbl > .tbl-wrap { border-radius: 0; box-shadow: none; border: 0; background: #fff; }
  .list-view .tbl { font-size: 13.5px; }
  .list-view .tbl th { height: 40px; padding: 0 12px; font-size: 13.5px; font-weight: 700; color: #1f2937; background: #fff;
    border-bottom: 1px solid #e5e7eb; box-shadow: inset 0 -1px 0 #e5e7eb; top: calc(var(--appbar-h) + 50px); }
  .list-view .tbl th + th, .list-view .tbl td + td { border-left: 1px solid #edf0f2; }
  .list-view .tbl td { height: 38px; padding: 0 12px; border-bottom: 1px solid #eef0f2; vertical-align: middle; white-space: nowrap; }
  .list-view .tbl td .cv { overflow: hidden; text-overflow: ellipsis; }
  .list-view .tbl td.nm .cv, .list-view .tbl td.em .cv { max-width: 230px; }
  .list-view .tbl td.nm b { font-weight: 500; color: var(--brand); }
  .list-view .tbl td.em { color: #374151; }
  .list-view .tbl tr.click:hover td { background: #f6f8f6; }
  .list-view .chip { font-size: 11.5px; }
  .list-view .pager { margin: 12px 0 16px; }
}
@media (min-width: 1000px) and (max-width: 1480px) { .list-view .tbl td.em .cv { max-width: 190px; } }

/* ===== chi tiết học viên: khung bên phải trang Học viên (kéo đường giữa để đổi độ rộng) và trang riêng ===== */
.sd-bar { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 6px 10px 6px 16px; background: #fff; border-bottom: 1px solid #e5e7eb; }
.sd-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sd-title b { font-size: 17px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-title small { color: var(--muted); font-size: 12px; }
.sd-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.sd-tools .tb { width: 36px; height: 36px; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; color: #374151; display: grid; place-items: center; }
.sd-tools .tb:hover { background: #f1f5ef; color: var(--brand); }
.sd-tools .tb.danger:hover { color: var(--bad); border-color: #f1c4c4; background: #fff5f5; }
.sd-tools .btn.sm { gap: 6px; }
.tb-sep { width: 1px; height: 24px; background: #e5e7eb; margin: 0 4px; }
.sd-panel .sd-tools .tb[data-a="prev"], .sd-panel .sd-tools .tb[data-a="next"], .sd-panel .sd-tools .tb[data-a="open"], .sd-panel .sd-tools .tb[data-a="close"] { border-color: transparent; }
.sd-body { padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.sd-body .card { margin: 0; }
.sd-page .sd-bar { border: 1px solid #e5e7eb; border-radius: 12px 12px 0 0; }
.sd-page .sd-body { padding-left: 0; padding-right: 0; }
.sd-page { max-width: 900px; }
.tbl tr.sel td { background: #e8f0e4 !important; }
@media (min-width: 1000px) {
  /* đủ mạnh để thắng quy tắc 2 cột khi menu trái đang mở rộng (body:not(.side-mini) .list-view .split) */
  body .list-view .split.has-detail, body:not(.side-mini) .list-view .split.has-detail { grid-template-columns: 240px minmax(300px, 1fr) 6px var(--sdw, 44%); }
  .sd-resize { cursor: col-resize; background: #e5e7eb; position: sticky; top: calc(var(--appbar-h) + 50px); height: calc(100vh - var(--appbar-h) - 50px);
    touch-action: none; transition: background .15s; }
  .sd-resize:hover, .sd-resize.on { background: var(--accent); }
  .sd-resize::after { content: ''; position: absolute; left: 50%; top: 50%; width: 2px; height: 28px; margin: -14px 0 0 -1px; border-left: 1px solid #9ca3af; border-right: 1px solid #9ca3af; }
  .sd-panel { position: sticky; top: calc(var(--appbar-h) + 50px); height: calc(100vh - var(--appbar-h) - 50px); overflow: auto; background: #f7f8f7; min-width: 0; }
  .sd-panel .sd-bar { position: sticky; top: 0; z-index: 3; }
  .sd-panel .tbl th { position: static; top: auto; }
  .sd-panel .tbl td { white-space: normal; height: auto; padding: 8px 10px; }
  .sd-panel .dl > div { grid-template-columns: 130px 1fr; }
  /* bảng hẹp lại khi mở chi tiết: ẩn bớt cột phụ */
  /* mở chi tiết: bảng chỉ giữ Mã HV, Họ và tên, Khóa học, Trạng thái (như AppSheet); phần tràn bị cắt, không đè lên khung chi tiết */
  .list-view .split-main { overflow-x: clip; }
  .split.has-detail #st-tbl th:nth-child(3), .split.has-detail #st-tbl td:nth-child(3),
  .split.has-detail #st-tbl th:nth-child(7), .split.has-detail #st-tbl td:nth-child(7),
  .split.has-detail #st-tbl th:nth-child(8), .split.has-detail #st-tbl td:nth-child(8) { display: none; }
  .sd-panel { z-index: 31; }
}
.sd-resize[hidden], .sd-panel[hidden] { display: none !important; }
.sd-title small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ẩn / hiện cây nhóm; kéo đổi độ rộng cột; tên + mã trong khung chi tiết */
.ph-l { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tree-tg { margin-left: -6px; }
@media (min-width: 1000px) {
  body .list-view .split.tree-off, body:not(.side-mini) .list-view .split.tree-off { grid-template-columns: minmax(0, 1fr); }
  body .list-view .split.tree-off.has-detail, body:not(.side-mini) .list-view .split.tree-off.has-detail { grid-template-columns: minmax(180px, 1fr) 6px var(--sdw, 44%); }
  .split.tree-off > .tree-box { display: none; }
  body .list-view .split.has-detail, body:not(.side-mini) .list-view .split.has-detail { grid-template-columns: 240px minmax(180px, 1fr) 6px var(--sdw, 44%); }
}
@media (max-width: 999px) { .split.tree-off > .tree-box { display: none; } }
.tbl.fixed { table-layout: fixed; min-width: 100%; }
.tbl th { position: relative; }
.list-view .tbl th { position: sticky; }
.col-rz { position: absolute; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; z-index: 3; touch-action: none; }
.col-rz::after { content: ''; position: absolute; top: 25%; bottom: 25%; left: 3px; width: 2px; border-radius: 1px; background: transparent; }
.tbl th:hover .col-rz::after, .col-rz.on::after { background: var(--accent); }
.tbl.fixed td .cv { overflow: hidden; text-overflow: ellipsis; }
.sd-head { padding: 2px 2px 0; }
.sd-head h2 { font-size: 22px; font-weight: 500; color: #1f2937; line-height: 1.3; word-break: break-word; }
.sd-head > div { color: var(--muted); font-size: 13px; margin-top: 2px; }
.sd-title small { font-size: 13px; color: var(--muted); }
/* Thông tin học viên + Khóa học: ngang nhau ở trang mở rộng và khi khung chi tiết đủ rộng (≥ 820px) */
.sd-pair { display: grid; gap: 14px; grid-template-columns: 1fr; align-items: start; }
.sd-pair .card { margin: 0; }
.sd-panel { container-type: inline-size; }
@container (min-width: 820px) { .sd-pair { grid-template-columns: 1fr 1fr; } }
@media (min-width: 860px) { .sd-page .sd-pair { grid-template-columns: 1fr 1fr; } }
.sd-page { max-width: 1200px; }

/* bảng trong khung chi tiết (thanh toán, các khóa khác): không dính tiêu đề như bảng chính — trước đó tiêu đề bị đẩy xuống 106px, che các dòng */
.list-view .sd-panel .tbl th { position: relative; top: auto; height: auto; padding: 8px 10px; box-shadow: none; }
.list-view .sd-panel .tbl td { height: auto; padding: 8px 10px; white-space: normal; }
/* trang Thanh toán khi mở chi tiết: bảng chỉ giữ Ngày chuyển khoản, Học viên, Số tiền */
@media (min-width: 1000px) {
  .split.has-detail #pm-tbl th:nth-child(2), .split.has-detail #pm-tbl td:nth-child(2),
  .split.has-detail #pm-tbl th:nth-child(4), .split.has-detail #pm-tbl td:nth-child(4),
  .split.has-detail #pm-tbl th:nth-child(5), .split.has-detail #pm-tbl td:nth-child(5),
  .split.has-detail #pm-tbl th:nth-child(7), .split.has-detail #pm-tbl td:nth-child(7) { display: none; }
}
.sd-head a { color: var(--blue); }

/* chi tiết (trang riêng) trên điện thoại: không tràn ngang — bỏ nút thu gọn (không có khung bên phải), chữ dài tự xuống dòng */
@media (max-width: 999px) {
  .sd-tools .tb[data-a="shrink"], .sd-page .tb-sep { display: none; }
  .sd-page, .sd-page .sd-body, .sd-page .card { min-width: 0; max-width: 100%; }
  .sd-page dd { min-width: 0; overflow-wrap: anywhere; }
}
/* đổi nhanh trạng thái ở chi tiết học viên; cột doanh thu âm (xin rút nhiều hơn tiền đóng) */
.st-quick { width: auto; height: auto; min-height: 0; margin: 0; padding: 2px 8px; border: 1px solid transparent; font-family: inherit; line-height: 1.5; cursor: pointer; vertical-align: baseline; }
.st-quick:hover, .st-quick:focus { border-color: currentColor; outline: 0; }
.chart .bar.neg { fill: var(--bad); }
.field[hidden] { display: none; }
#out.btn.block { margin-top: 8px; }
