:root { --bg: #f4f6f5; --surface: #fff; --text: #1d2621; --muted: #637168; --line: #dfe5e1; --brand: #0b6b3a; --brand-2: #138a4d; --soft: #e7f3ec; --danger: #b42318; --warn: #b54708; --link: #0a5f9e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #101512; --surface: #171f1a; --text: #e3ebe5; --muted: #9db0a4; --line: #2a362e; --brand: #3fb874; --brand-2: #5ccb8b; --soft: #1d3326; --danger: #f97066; --warn: #fdb022; --link: #79b8ef; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
code { background: var(--soft); padding: 1px 6px; border-radius: 5px; font-size: 13px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.abar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; background: var(--brand); color: #fff; flex-wrap: wrap; }
.abrand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.abrand img { background: #fff; border-radius: 50%; }
.aright { display: flex; align-items: center; gap: 16px; font-size: 14px; flex-wrap: wrap; }
.aright a { color: #e3f6ea; }
.who em { font-style: normal; background: rgba(255,255,255,.2); padding: 1px 8px; border-radius: 999px; font-size: 12px; margin-left: 4px; }
.anav { display: flex; align-items: stretch; gap: 2px; background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 20px; overflow-x: auto; }
.anav a { padding: 12px 14px; color: var(--text); white-space: nowrap; border-bottom: 3px solid transparent; font-weight: 500; }
.anav a.on { border-bottom-color: var(--brand); color: var(--brand); }
.anav a:hover { text-decoration: none; color: var(--brand); }
.anav .cur-site { display: flex; flex-direction: column; line-height: 1.2; padding: 7px 16px 7px 0; margin-right: 8px; border-right: 1px solid var(--line); }
.cur-site small { color: var(--muted); font-size: 12px; font-weight: 400; }
.amain { max-width: 1200px; margin: 0 auto; padding: 22px 20px 60px; }
@media (max-width: 600px) { .amain { padding: 16px; } .abar, .anav { padding-left: 16px; padding-right: 16px; } }

.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.btn:hover { background: var(--brand-2); }
.btn.sm { padding: 6px 12px; font-size: 14px; }
.btn.ghost { background: var(--surface); color: var(--brand); }
.btn-google { background: #fff; color: #1f1f1f; border-color: #dadce0; width: 100%; justify-content: center; padding: 12px; }
.btn-google:hover { background: #f6f8f7; }
.lnk { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; }
.lnk:hover { text-decoration: underline; }
.lnk.danger { color: var(--danger); }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert.ok { background: #ecfdf3; border-color: #abefc6; color: #067647; }
.alert.err { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.alert.warn { background: #fffaeb; border-color: #fedf89; color: #93370d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .alert { background: var(--surface); } }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1; min-width: 200px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
input[type=file] { padding: 6px; }
.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }

.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 13px; color: var(--muted); font-weight: 600; background: var(--bg); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl.compact td { padding: 7px 12px; }
.num { text-align: right !important; white-space: nowrap; }
.acts { white-space: nowrap; text-align: right; }
.acts > *, .acts form > * { margin-left: 10px; }
@media (max-width: 760px) {
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  .tbl td { border: 0; padding: 3px 12px; text-align: left !important; }
  .acts > *:first-child, .acts form > *:first-child { margin-left: 0; }
}
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.on { background: #ecfdf3; color: #067647; border-color: #abefc6; }
.tag.off { background: #f2f4f7; color: #475467; }
.tag.warn { background: #fffaeb; color: #b54708; border-color: #fedf89; }
.pager { display: flex; gap: 6px; margin-top: 16px; align-items: center; flex-wrap: wrap; }
.pager a, .pager b { padding: 5px 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.pager b { background: var(--brand); color: #fff; }
.crumbs { margin: 6px 0 12px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.panel summary { cursor: pointer; }
.form label { display: block; margin-bottom: 12px; font-weight: 500; font-size: 14px; }
.form label input:not([type=checkbox]), .form label select, .form label textarea, .editor label input:not([type=checkbox]), .editor label select, .editor label textarea { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
.editor label { display: block; margin-bottom: 14px; font-weight: 500; font-size: 14px; }
.chk { display: flex !important; align-items: center; gap: 8px; font-weight: 400 !important; }
.big { font-size: 18px !important; font-weight: 600 !important; }
.ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-items: start; }
.side-opts { position: sticky; top: 12px; }
@media (max-width: 900px) { .ed-grid { grid-template-columns: 1fr; } .side-opts { position: static; } }
.thumb-prev img { max-width: 100%; max-height: 160px; border-radius: 8px; margin-bottom: 8px; display: block; }
.thumb-prev.wide img { max-height: 120px; width: 100%; object-fit: cover; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-h { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.empty { border: 1px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); background: var(--surface); }
dialog { border: 0; border-radius: 14px; padding: 22px; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(16, 24, 20, .45); }
dialog .btns { justify-content: flex-end; margin-top: 8px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 16px 0 26px; }
.pick button { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font: inherit; color: var(--text); cursor: pointer; display: flex; flex-direction: column; }
.pick button:hover { border-color: var(--brand); }
.pick small { color: var(--muted); }

body.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, #0b6b3a, #2c8f57); }
.login-card { background: var(--surface); border-radius: 16px; padding: 30px 28px; width: min(420px, 100%); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card h1 { margin: 12px 0 4px; font-size: 20px; }
.login-card .alert { text-align: left; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #e0245e; color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.tabs-a { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs-a a { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.tabs-a a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs-a a.on .tag { background: rgba(255,255,255,.2); color: #fff; border-color: transparent; }
.composer textarea { font-size: 16px; }
.composer-foot { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.composer-foot .btn { margin-left: auto; }
.qa-adm .qa-text { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; overflow-wrap: anywhere; }
.qa-adm .qa-text img { max-width: 100%; height: auto; }
.qa-adm details { margin-bottom: 8px; }
.qa-adm summary { cursor: pointer; color: var(--link); font-weight: 600; margin-bottom: 8px; }
.qa-adm textarea { width: 100%; }
.acts-left > * { margin-right: 14px; }
/* Ảnh đại diện */
.avatar { display: grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.xl { width: 120px; height: 120px; font-size: 40px; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.avatar-panel { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.avatar-panel h2 { margin-bottom: 4px; }
.av-dlg { width: min(460px, calc(100vw - 24px)); }
.av-stage { background: #222; border-radius: 12px; overflow: hidden; touch-action: none; }
.av-stage canvas { display: block; width: 100%; height: auto; cursor: grab; touch-action: none; }
.av-stage canvas:active { cursor: grabbing; }
.av-zoom { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; }
.av-zoom input { flex: 1; }
.drop { position: relative; display: flex !important; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 34px 20px; border: 2px dashed var(--line); border-radius: 14px; cursor: pointer; background: var(--bg); }
.drop.over { border-color: var(--brand); background: var(--soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-ic { font-size: 34px; }
.drop small { color: var(--muted); max-width: 560px; font-weight: 400; }
.up-list { list-style: none; margin: 12px 0 0; padding: 0; }
.up-list li { display: grid; grid-template-columns: 30px 1fr; gap: 2px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.up-list .ic { font-size: 22px; grid-row: span 2; }
.up-list small { color: var(--muted); grid-column: 2; }
.cat-pick { display: block; width: 100%; margin-top: 4px; }
.cat-new { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.cat-new[hidden] { display: none; }
.cat-new > * { flex: 1 1 180px; }
.done { border-color: #abefc6; background: #ecfdf3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .done { background: var(--surface); } }
.split { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.tree { padding: 8px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
@media (max-width: 860px) { .tree { position: static; max-height: 260px; } }
.tree a { display: flex; justify-content: space-between; gap: 6px; padding: 6px 10px; border-radius: 7px; color: var(--text); font-size: 14px; }
.tree a span { color: var(--muted); font-size: 12px; }
.tree a:hover { background: var(--bg); text-decoration: none; }
.tree a.on { background: var(--soft); color: var(--brand); font-weight: 600; }
.tree a.sub, .tree small.sub { padding-left: 22px; display: flex; }
.tree-menu { margin: 10px 10px 2px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.tree-edit { margin-top: 10px; border-top: 1px solid var(--line); border-radius: 0 !important; padding-top: 10px !important; color: var(--link) !important; }
.bulkbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 10px; background: var(--soft); border: 1px solid var(--brand); border-radius: 10px; }
.bulkbar[hidden] { display: none; }
.bulkbar .move { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bulkbar .cat-pick { display: inline-block; width: auto; max-width: 260px; margin: 0; }
.bulkbar .cat-new { flex-basis: 100%; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.ck { width: 34px; }
.row-acts { font-size: 13px; margin-top: 2px; }
.tbl tr.sel td { background: var(--soft); }
/* Tùy chỉnh menu */
.menus { display: grid; gap: 12px; }
.menu-card { margin: 0; }
.menu-card.is-off { opacity: .65; }
.menu-card.orphan { border-style: dashed; }
.menu-card .menu-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.menu-card .mname { font-size: 16px; }
.sp { flex: 1; }
.grip { cursor: grab; color: var(--muted); font-size: 18px; user-select: none; padding: 0 4px; touch-action: none; }
.grip-demo { font-weight: 700; }
.subs { list-style: none; margin: 0; padding: 4px 0 0; min-height: 34px; }
.subs li { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--surface); flex-wrap: wrap; }
.subs li.is-off .sname { color: var(--muted); text-decoration: line-through; }
.subs li.sortable-ghost { opacity: .4; background: var(--soft); }
.ico { background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-size: 15px; padding: 2px 6px; }
.ico:hover { border-color: var(--line); background: var(--bg); }
.empty-sub { margin: 0; }
.preview { padding: 10px 14px; }
.preview ul { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 0; padding: 0; }
.preview li { padding: 6px 12px; border-radius: 6px; background: var(--bg); font-size: 14px; font-weight: 500; }
.preview li.on { background: var(--brand); color: #fff; }
.saved { position: fixed; bottom: 18px; right: 18px; background: var(--brand); color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 50; }
/* Quản trị hệ thống */
.admin-link { color: var(--brand) !important; font-weight: 700 !important; }
.sumcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.sumcard { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--text); }
.sumcard:hover { border-color: var(--brand); text-decoration: none; }
.sumcard.on { border-color: var(--brand); background: var(--soft); }
.sumcard b { font-size: 22px; color: var(--brand); line-height: 1.2; }
.sumcard small { color: var(--muted); font-size: 13px; }
.who-cell { display: flex; gap: 10px; align-items: center; }
.who-cell .avatar.sm { width: 36px; height: 36px; font-size: 13px; }
.avatar.gen { color: #fff; }
.tbl tr.row-off td { background: repeating-linear-gradient(135deg, transparent 0 8px, rgba(0,0,0,.025) 8px 16px); }
.tbl tr.row-off b { color: var(--muted); }
/* Lớp học */
.lh .sumcard { cursor: default; }
.lh .sumcard b { font-size: 17px; }
.warn-t { color: var(--warn); font-weight: 600; }
select.mins { padding: 4px 6px; font-size: 13px; }
.sub-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 16px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.sub-row.done { opacity: .6; }
.sub-row .files { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; }
.sub-grade { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sub-grade input[type=number] { width: 80px; }
.sub-grade .cmt { width: 200px; }
@media (max-width: 760px) { .sub-row { grid-template-columns: 1fr; } .sub-grade .cmt { width: 100%; } }
.crit { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; }
.crit legend { font-size: 14px; font-weight: 500; padding: 0 4px; }
.crit-row { display: grid; grid-template-columns: 1fr 90px 30px; gap: 6px; margin-bottom: 6px; }
.qr-dlg { width: min(640px, calc(100vw - 24px)); }
.qr-wrap { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; justify-content: center; }
#qrBox { background: #fff; padding: 12px; border-radius: 12px; }
.qr-code { font-size: 46px; font-weight: 800; letter-spacing: 6px; color: var(--brand); font-family: ui-monospace, Menlo, Consolas, monospace; }
.att-dlg { width: min(620px, calc(100vw - 24px)); }
.att-list { max-height: 60vh; overflow-y: auto; }
.att-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; }
.att-row.st-absent { background: rgba(180,35,24,.06); }
.att-row.st-late { background: rgba(181,71,8,.07); }
.att-row.st-present { background: rgba(6,118,71,.06); }
/* Tài khoản giảng viên (quanly/taikhoan.php) */
label.inl { display: flex !important; gap: 8px; align-items: center; font-weight: 400; margin: 0 0 10px; }
.bulkbar label.inl { margin: 0; }
label.inl input[type=checkbox] { width: auto; margin: 0; }
.bulkbar label.inl { white-space: nowrap; }
dialog label[hidden] { display: none !important; }

/* Trợ lý AI trong trình soạn bài (assets/ai-editor.js) */
.aibar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 12px; margin: 4px 0 10px; border: 1px dashed var(--brand); border-radius: 10px; background: var(--soft); }
.aibar > b { color: var(--brand); }
.aibar .chk { margin: 0; }
.aibar > small { flex-basis: 100%; }
dialog.ai-dlg { width: min(880px, calc(100vw - 24px)); max-height: calc(100vh - 32px); display: none; flex-direction: column; }
dialog.ai-dlg[open] { display: flex; }
dialog.ai-dlg h3 { margin: 0 0 12px; }
dialog.ai-dlg #aiBody { overflow: auto; min-height: 60px; }
dialog.ai-dlg form { display: contents; }
.ai-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 12px; }
.ai-opts select { width: 100%; }
.ai-prev { border: 1px solid var(--line); border-radius: 10px; padding: 6px 18px; background: var(--bg); line-height: 1.6; overflow-wrap: anywhere; }
.ai-prev img { max-width: 100%; height: auto; }
.ai-prev table { border-collapse: collapse; max-width: 100%; }
.ai-prev td, .ai-prev th { border: 1px solid var(--line); padding: 5px 9px; vertical-align: top; }
.ai-prev th { background: var(--soft); }
.ai-prev .callout { background: var(--soft); border-left: 4px solid var(--brand); border-radius: 8px; padding: 8px 14px; margin: 12px 0; }
.ai-t { margin: 0 0 4px; font-size: 20px; }
.ai-wait { display: flex; align-items: center; gap: 12px; padding: 22px 4px; color: var(--muted); }
.spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: aispin .8s linear infinite; flex: none; }
@keyframes aispin { to { transform: rotate(360deg); } }
b.warn { color: var(--warn); }
