:root {
  /* Bộ màu theo template DropX Admin: slate + chàm (indigo). */
  --nen: #f9fafb;
  --the: #ffffff;
  --the-2: #f3f4f6;
  --chu: #111827;
  --chu-phu: #6b7280;
  --vien: #e5e7eb;
  --tim: #6366f1;
  --tim-dam: #4f46e5;
  --tim-nhat: rgb(99 102 241 / 10%);
  --xanh: #10b981;
  --xanh-nhat: rgb(16 185 129 / 12%);
  --do: #ef4444;
  --do-nhat: rgb(239 68 68 / 10%);
  --vang: #d97706;
  --vang-nhat: rgb(245 158 11 / 14%);
  --code-nen: #0f172a;
  --code-chu: #e2e8f0;
  --thanh-tren: rgb(255 255 255 / 85%);
  --bong: 0 1px 2px rgb(16 24 40 / 5%), 0 1px 3px rgb(16 24 40 / 6%);
  --bo: 12px;
  color-scheme: light;
}
/* Tối: theo máy (trừ khi đã chọn sáng), hoặc đã chọn tối bằng nút đổi giao diện. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --nen: #0f172a;
    --the: #1e293b;
    --the-2: #172033;
    --chu: #f1f5f9;
    --chu-phu: #94a3b8;
    --vien: #334155;
    --tim: #818cf8;
    --tim-dam: #6366f1;
    --tim-nhat: rgb(99 102 241 / 14%);
    --xanh: #34d399;
    --xanh-nhat: rgb(52 211 153 / 14%);
    --do: #f87171;
    --do-nhat: rgb(248 113 113 / 14%);
    --vang: #fbbf24;
    --vang-nhat: rgb(251 191 36 / 14%);
    --code-nen: #0b1222;
    --thanh-tren: rgb(30 41 59 / 85%);
    --bong: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --nen: #0f172a;
    --the: #1e293b;
    --the-2: #172033;
    --chu: #f1f5f9;
    --chu-phu: #94a3b8;
    --vien: #334155;
    --tim: #818cf8;
    --tim-dam: #6366f1;
    --tim-nhat: rgb(99 102 241 / 14%);
    --xanh: #34d399;
    --xanh-nhat: rgb(52 211 153 / 14%);
    --do: #f87171;
    --do-nhat: rgb(248 113 113 / 14%);
    --vang: #fbbf24;
    --vang-nhat: rgb(251 191 36 / 14%);
    --code-nen: #0b1222;
    --thanh-tren: rgb(30 41 59 / 85%);
    --bong: 0 1px 2px rgb(0 0 0 / 30%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  background: var(--nen);
  color: var(--chu);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--tim); }
button, select { font: inherit; }
code, pre, textarea.code { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Thanh trên ---------- */
.thanh-tren {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px; background: var(--thanh-tren); border-bottom: 1px solid var(--vien);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 5; min-height: 60px;
}
.thanh-tren .giua { flex: 1; display: flex; justify-content: center; align-items: center; gap: 8px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--chu); text-decoration: none; white-space: nowrap; }
.logo .robo { font-size: 22px; }
.huy-hieu {
  font-size: 12.5px; padding: 3px 10px; border-radius: 999px;
  background: var(--tim-nhat); color: var(--tim); white-space: nowrap;
}
.huy-hieu.thu { background: var(--vang-nhat); color: var(--vang); }
.huy-hieu.chon-ncc { padding: 0; }
.huy-hieu.chon-ncc select {
  appearance: none; -webkit-appearance: none; border: 0; outline: 0; cursor: pointer;
  font: inherit; color: inherit; background: transparent; border-radius: inherit;
  padding: 3px 26px 3px 10px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 13px center, right 9px center; background-size: 4px 4px; background-repeat: no-repeat;
}
.huy-hieu.chon-ncc select:focus-visible { box-shadow: 0 0 0 2px var(--tim); }
.huy-hieu.chon-ncc option { color: var(--chu); background: var(--the); }

.nut {
  border: 1px solid transparent; border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: 14px;
  background: var(--tim-dam); color: #fff; white-space: nowrap; transition: background .15s, border-color .15s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.nut:hover:not(:disabled) { filter: brightness(1.08); }
.nut.phu { background: var(--the); color: var(--chu); border-color: var(--vien); }
.nut.phu:hover:not(:disabled) { border-color: var(--tim); color: var(--tim); filter: none; }
.nut.xanh { background: var(--xanh); color: #fff; }
.nut.nho { padding: 4px 10px; font-size: 13px; }
.nut:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Trang danh sách bài ---------- */
.trang { max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; }
.trang h1 { font-size: 28px; margin: 0 0 6px; }
p.phu { color: var(--chu-phu); margin: 0 0 24px; }
.luoi-bai { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.the-bai {
  display: block; background: var(--the); border: 1px solid var(--vien); border-radius: 16px;
  padding: 20px; text-decoration: none; color: inherit; box-shadow: var(--bong); transition: transform .15s;
}
.the-bai:hover { transform: translateY(-2px); border-color: var(--tim); }
.the-bai h2 { font-size: 18px; margin: 8px 0 6px; }
.the-bai p { margin: 0; color: var(--chu-phu); font-size: 14.5px; }

/* ---------- Trang làm bài: 3 cột ---------- */
.ba-cot {
  --cot-trai: 32%; --cot-phai: 26%;
  display: grid;
  grid-template-columns: var(--cot-trai) 6px 1fr 6px var(--cot-phai);
  height: calc(100vh - 52px);
  padding: 8px; gap: 0;
}
.bang {
  background: var(--the); border: 1px solid var(--vien); border-radius: 12px;
  display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
}
.thanh-keo { cursor: col-resize; border-radius: 3px; }
.thanh-keo:hover, .thanh-keo.dang-keo { background: var(--tim-nhat); }
.thanh-keo.doc { cursor: row-resize; height: 6px; }

.the-tab {
  display: flex; align-items: center; gap: 2px; padding: 4px 6px;
  background: var(--the-2); border-bottom: 1px solid var(--vien); min-height: 40px;
}
.the-tab button.tab {
  border: 0; background: none; color: var(--chu-phu); padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.the-tab button.tab.chon { color: var(--chu); background: var(--the); font-weight: 600; }
.the-tab .day-phai { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.noi-dung { flex: 1; overflow: auto; padding: 14px 16px; min-height: 0; }

.de-bai h1 { font-size: 20px; margin: 0 0 6px; }
.de-bai p { margin: 0 0 10px; }
.de-bai pre, .tin pre {
  background: var(--code-nen); color: var(--code-chu); padding: 10px 12px; border-radius: 8px; overflow-x: auto; margin: 8px 0;
}
.de-bai code, .tin code { background: var(--tim-nhat); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.de-bai pre code, .tin pre code { background: none; padding: 0; color: inherit; }
.vi-du { background: var(--the-2); border-left: 3px solid var(--vien); border-radius: 6px; padding: 8px 12px; margin: 8px 0; font-size: 14px; }
.vi-du b { display: inline-block; min-width: 80px; }
.vi-du code { white-space: pre-wrap; }

.ds-nop { width: 100%; border-collapse: collapse; font-size: 14px; }
.ds-nop th, .ds-nop td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--vien); }
.ds-nop th { color: var(--chu-phu); font-weight: 600; font-size: 13px; }

/* cột giữa: soạn code + bảng test */
.cot-giua { display: grid; grid-template-rows: 1fr 6px var(--cao-console, 38%); min-width: 0; min-height: 0; }
select.chon-ngon-ngu {
  border: 1px solid var(--vien); background: var(--the); color: var(--chu); border-radius: 6px; padding: 4px 8px; font-size: 14px;
}
.vung-code { flex: 1; min-height: 0; position: relative; }
.vung-code .CodeMirror { position: absolute; inset: 0; height: auto; font-size: 14.5px; font-family: "JetBrains Mono", ui-monospace, monospace; }
.vung-code textarea.code {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; resize: none; padding: 12px;
  background: var(--code-nen); color: var(--code-chu); font-size: 14.5px;
}

.chip-hang { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  border: 1px solid var(--vien); background: var(--the-2); color: var(--chu); border-radius: 7px;
  padding: 4px 10px; font-size: 13.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip.chon { border-color: var(--tim); background: var(--tim-nhat); }
.chip .cham { width: 7px; height: 7px; border-radius: 50%; background: var(--chu-phu); }
.chip .cham.dat { background: var(--xanh); } .chip .cham.truot { background: var(--do); }
.nhan-o { font-size: 12.5px; color: var(--chu-phu); margin: 8px 0 4px; }
textarea.o-test, .o-xem {
  width: 100%; min-height: 40px; border: 1px solid var(--vien); border-radius: 8px; padding: 8px 10px;
  background: var(--the-2); color: var(--chu); font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13.5px;
  white-space: pre-wrap; resize: vertical; margin: 0;
}
.o-xem.loi { color: var(--do); background: var(--do-nhat); border-color: transparent; }
.ket-luan { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
.ket-luan.dat { color: var(--xanh); } .ket-luan.truot { color: var(--do); }
.ket-luan small { font-size: 13px; color: var(--chu-phu); font-weight: 400; margin-left: 8px; }
.trong { color: var(--chu-phu); font-size: 14px; }

/* cột phải: Robo */
.chat .dau { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--vien); background: var(--the-2); }
.chat .dau .robo { font-size: 26px; }
.chat .dau b { display: block; font-size: 15px; }
.chat .dau span { color: var(--chu-phu); font-size: 12.5px; }
.dong-tin { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px; min-height: 0; }
.tin { max-width: 94%; padding: 9px 12px; border-radius: 12px; font-size: 14.5px; }
.tin p { margin: 0 0 6px; } .tin p:last-child { margin: 0; }
.tin.hs { align-self: flex-end; background: var(--tim); color: #fff; border-bottom-right-radius: 4px; }
.tin.hs code { background: rgb(255 255 255 / 18%); }
.tin.robo { align-self: flex-start; background: var(--tim-nhat); border-bottom-left-radius: 4px; }
.tin.he-thong { align-self: center; background: var(--vang-nhat); color: var(--vang); font-size: 13px; }
.tin .nhan { display: block; font-size: 11.5px; color: var(--chu-phu); margin-top: 4px; }
.tin .thoi-gian { display: block; font-size: 11.5px; color: var(--chu-phu); margin-top: 2px; font-variant-numeric: tabular-nums; }
.dang-nghi { color: var(--chu-phu); font-size: 14px; }
.chat .day { padding: 10px 12px; border-top: 1px solid var(--vien); }
.nut-nhanh { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chat form { display: flex; gap: 8px; }
input.o-nhap {
  flex: 1; min-width: 0; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--vien);
  background: var(--the); color: var(--chu); font: inherit;
}

@media (max-width: 1100px) {
  .ba-cot { display: flex; flex-direction: column; height: auto; gap: 8px; }
  .thanh-keo { display: none; }
  .ba-cot > .bang { min-height: 360px; }
  .cot-giua { grid-template-rows: 460px 8px auto; }
  .cot-giua .thanh-keo { display: block; visibility: hidden; }
  .chat { height: 560px; }
  .thanh-tren .logo .chu-logo { display: none; }
}
@media (max-width: 640px) {
  .thanh-tren { flex-wrap: wrap; }
  .thanh-tren .giua { order: 3; flex-basis: 100%; }
}

/* ---------- Hỏi thầy cô ---------- */
.khung-chat { display: flex; flex-direction: column; padding: 0; min-height: 0; flex: 1; }
.khung-chat[hidden] { display: none; }
#thay-co { display: flex; flex-direction: column; gap: 10px; padding: 12px; min-height: 0; flex: 1; overflow-y: auto; }
#thay-co .dong-tin { padding: 0; flex: 1; }
.huy-hieu.dem { background: var(--do); color: #fff; padding: 1px 7px; font-size: 11.5px; }
/* Nút quay lại ghim ở đầu khung đang cuộn (nội dung dài vẫn thấy nút). */
/* Khung cuộn có đệm trên (--dem-tren): ghim lùi lên đúng bằng phần đệm và lấy nền phủ kín, không lộ nội dung cuộn qua. */
.thanh-quay-lai {
  position: sticky; top: calc(-1 * var(--dem-tren, 14px)); z-index: 3;
  margin: calc(-1 * var(--dem-tren, 14px)) 0 8px; padding: calc(var(--dem-tren, 14px) + 2px) 0 6px; background: var(--the);
}
#thay-co { --dem-tren: 12px; }
.hang-dau { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.trong-giua { text-align: center; padding: 24px 8px; color: var(--chu-phu); }
.ds-cau { display: flex; flex-direction: column; gap: 8px; }
.the-cau {
  text-align: left; border: 1px solid var(--vien); background: var(--the-2); color: var(--chu); border-radius: 10px;
  padding: 9px 11px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; font-size: 14px; width: 100%;
}
.the-cau:hover, .the-cau.chon { border-color: var(--tim); }
.the-cau .dong1 { display: flex; gap: 6px; align-items: center; }
.the-cau .dong1 .luc { margin-left: auto; color: var(--chu-phu); font-size: 12.5px; }
.the-cau .dong2 { color: var(--chu-phu); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.the-cau .ten { font-weight: 600; }
.tt { font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.tt-moi { background: var(--vang-nhat); color: var(--vang); }
.tt-dang-trao-doi { background: var(--tim-nhat); color: var(--tim); }
.tt-da-xong { background: var(--xanh-nhat); color: var(--xanh); }
.form-tc { display: flex; flex-direction: column; gap: 8px; }
.form-tc label { font-size: 14px; display: flex; gap: 8px; align-items: center; }
.o-nguoi { font-size: 14px; white-space: nowrap; }
#nguoi-dung { display: flex; gap: 8px; align-items: center; }

/* Bảng trong đề bài (markdown) */
.bang-md { border-collapse: collapse; margin: 8px 0; font-size: 14px; }
.bang-md th, .bang-md td { border: 1px solid var(--vien); padding: 4px 10px; text-align: left; vertical-align: top; }
.bang-md th { background: var(--the-2); }
.vi-du pre { margin: 2px 0 6px; white-space: pre-wrap; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13.5px; }
.nhom-chuong { margin: 28px 0 10px; font-size: 19px; }
.nhom-chuong small { color: var(--chu-phu); font-weight: 400; font-size: 14px; }
.sao { color: #e8a317; letter-spacing: 1px; font-size: 13px; }

details.chuong > summary { cursor: pointer; list-style: none; }
details.chuong > summary::-webkit-details-marker { display: none; }

/* Tiến độ: trạng thái từng bài */
.tt-bai { display: inline-block; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; margin-bottom: 8px; }
.tt-bai.dung { color: var(--xanh); background: var(--xanh-nhat); }
.tt-bai.sai { color: var(--do); background: color-mix(in srgb, var(--do) 14%, transparent); }
.the-bai { position: relative; }
.the-bai.dung { border-color: color-mix(in srgb, var(--xanh) 55%, transparent); }
.the-bai.sai { border-color: color-mix(in srgb, var(--do) 45%, transparent); }
.the-bai .dau-tt { position: absolute; top: 12px; right: 12px; font-size: 12px; font-weight: 600; }
.the-bai.dung .dau-tt { color: var(--xanh); }
.the-bai.sai .dau-tt { color: var(--do); }
.nhom-chuong .tien-do-chuong { font-size: 13px; font-weight: 500; color: var(--xanh); margin-left: 6px; }
.loc-tt { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.loc-tt button.chon { border-color: var(--tim); color: var(--tim); }
.ds-nop .phu-nut { font-size: 12px; padding: 2px 8px; }
.the-bai[hidden], details.chuong[hidden] { display: none; }
.loc-tt .nut { background: var(--the); color: var(--chu-phu); border: 1px solid var(--vien); font-size: 13px; padding: 5px 12px; }
.loc-tt .nut.chon { background: var(--tim-nhat); color: var(--tim); border-color: var(--tim); }

/* Danh sách bài dạng bảng: trạng thái · bài · độ khó */
.bang-bai { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--the); border: 1px solid var(--vien);
  border-radius: 14px; overflow: hidden; box-shadow: var(--bong); }
.bang-bai th { text-align: left; font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--chu-phu); padding: 12px 16px; border-bottom: 1px solid var(--vien); }
.bang-bai td { padding: 12px 16px; border-bottom: 1px solid var(--vien); vertical-align: middle; }
.bang-bai tbody tr:last-child td { border-bottom: 0; }
.bang-bai .cot-tt { width: 118px; text-align: center; white-space: nowrap; }
.bang-bai .cot-kho { width: 120px; text-align: right; white-space: nowrap; }
.dong-bai { cursor: pointer; }
.dong-bai:hover td { background: var(--tim-nhat); }
.dong-bai a { color: inherit; text-decoration: none; font-weight: 500; }
.dong-bai:hover a { color: var(--tim); }
.ma-bai { margin-left: 8px; font-size: 12px; color: var(--chu-phu); }
.o-tt { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--vien); font-size: 13px; font-weight: 700; line-height: 1; vertical-align: middle; }
.o-tt.dung { background: var(--xanh); border-color: var(--xanh); color: #fff; }
.o-tt.sai { border-color: var(--do); color: var(--do); }
.sao-mo { opacity: .22; }
.dau-tich { color: var(--xanh); margin-left: 6px; font-size: .8em; vertical-align: middle; }
@media (max-width: 600px) {
  .bang-bai .cot-tt { width: 52px; } .bang-bai .cot-kho { width: 84px; }
  .bang-bai th, .bang-bai td { padding: 10px 8px; } .ma-bai { display: none; }
}


/* ================= Bố cục dashboard (template DropX) ================= */
.icon { flex-shrink: 0; vertical-align: middle; }
.nut-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex-shrink: 0;
  border: 1px solid var(--vien); border-radius: 10px; background: var(--the); color: var(--chu-phu); cursor: pointer;
}
.nut-icon:hover { color: var(--tim); border-color: var(--tim); }
.nut.nho { padding: 6px 10px; font-size: 13px; }

body.co-thanh-ben { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; height: auto; align-items: start; }
body.co-thanh-ben.thu-thanh-ben { grid-template-columns: 0 1fr; }
body.thu-thanh-ben .thanh-ben { visibility: hidden; }
.thanh-ben {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--the);
  border-right: 1px solid var(--vien); display: flex; flex-direction: column;
}
.thuong-hieu {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px; min-height: 60px;
  border-bottom: 1px solid var(--vien); text-decoration: none; color: var(--chu);
}
.thuong-hieu b { display: block; font-size: 16px; line-height: 1.2; }
.thuong-hieu small { display: block; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--chu-phu); }
.logo-o {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.menu-ben { padding: 8px 10px 24px; }
.nhom-ben { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--chu-phu); padding: 14px 10px 6px; }
.muc-ben {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; font-size: 13.5px;
  color: var(--chu); text-decoration: none; font-weight: 500;
}
.muc-ben .icon { color: var(--chu-phu); width: 17px; height: 17px; }
.muc-ben span:not(.dem-ben) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muc-ben:hover { background: var(--the-2); }
.muc-ben.chon { background: var(--tim-nhat); color: var(--tim); }
.muc-ben.chon .icon { color: var(--tim); }
.dem-ben { font-size: 11.5px; color: var(--chu-phu); font-variant-numeric: tabular-nums; }
.dem-ben.xong { color: var(--xanh); font-weight: 600; }
.man-che { display: none; }

.phan-chinh { min-width: 0; display: flex; flex-direction: column; }
.o-tim {
  flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px;
  border: 1px solid var(--vien); border-radius: 10px; background: var(--the); color: var(--chu-phu);
}
.o-tim:focus-within { border-color: var(--tim); box-shadow: 0 0 0 3px var(--tim-nhat); }
.o-tim input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--chu); font: inherit; font-size: 14px; }
.o-tim kbd { font: 11px "JetBrains Mono", monospace; border: 1px solid var(--vien); border-radius: 5px; padding: 1px 6px; color: var(--chu-phu); }
.thanh-tren #trang-thai { margin-left: auto; }
.o-nguoi { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 4px; border: 1px solid var(--vien); border-radius: 10px; background: var(--the); }
.avatar {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
}
.ten-nguoi { display: flex; flex-direction: column; line-height: 1.2; }
.ten-nguoi b { font-size: 13px; white-space: nowrap; }
.ten-nguoi small { font-size: 11px; color: var(--xanh); }

.trang-rong { padding: 20px 28px 48px; max-width: 1280px; width: 100%; }
.duong-dan { display: flex; align-items: center; gap: 6px; color: var(--chu-phu); font-size: 13.5px; margin-bottom: 14px; }
.duong-dan b { color: var(--chu); font-weight: 500; }
.trang-rong h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
.trang-rong > p.phu { margin-bottom: 20px; font-size: 14.5px; }

.luoi-kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.the-kpi {
  position: relative; overflow: hidden; border-radius: var(--bo); padding: 18px 20px; color: #fff;
  display: flex; flex-direction: column; gap: 2px; min-height: 120px;
}
.the-kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%; background: rgb(255 255 255 / 10%); }
.the-kpi.cham { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.the-kpi.xanh { background: linear-gradient(135deg, #10b981, #059669); }
.the-kpi.lam { background: linear-gradient(135deg, #38bdf8, #3b82f6); }
.the-kpi.cam { background: linear-gradient(135deg, #f97316, #ef4444); }
.kpi-dau { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; opacity: .92; }
.kpi-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: rgb(255 255 255 / 18%); position: relative; z-index: 1; }
.the-kpi b { font-size: 30px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; margin-top: 4px; }
.the-kpi small { font-size: 13px; opacity: .9; }

.khung { background: var(--the); border: 1px solid var(--vien); border-radius: var(--bo); box-shadow: var(--bong); margin-bottom: 14px; overflow: hidden; }
.nhom-ds { margin-top: 26px; }
.nhom-ds[hidden] { display: none; }
.dau-nhom-ds { display: flex; align-items: center; gap: 10px; margin: 0 2px 12px; padding-bottom: 10px; border-bottom: 1px solid var(--vien); font-size: 18px; font-weight: 700; }
.dau-nhom-ds > .icon { color: var(--tim); }
.con-nhom { margin-left: 9px; padding-left: 28px; }
.con-nhom > details.chuong { position: relative; overflow: visible; }
.con-nhom > details.chuong::before { content: ""; position: absolute; left: -28px; top: 26px; width: 26px; border-top: 2px solid var(--vien); }
.con-nhom > details.chuong::after { content: ""; position: absolute; left: -28px; top: -15px; bottom: -15px; border-left: 2px solid var(--vien); }
.con-nhom > details.chuong:first-child::after { top: -12px; }
.con-nhom > details.chuong:last-child::after { bottom: auto; height: 43px; }
.con-nhom > details.chuong > .bang-bai { border-radius: 0 0 var(--bo) var(--bo); overflow: hidden; }
.dau-nhom-ds small { color: var(--chu-phu); font-size: 13px; font-weight: 500; }
.dau-nhom-ds .tien-do { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500; color: var(--chu-phu); padding-right: 44px; }
.dau-nhom-ds { position: relative; }
.dau-khung { display: flex; align-items: center; gap: 10px; padding: 14px 18px; font-size: 15px; }
.dau-khung > .icon { color: var(--tim); }
.dau-khung b { font-weight: 600; }
.dau-khung small { color: var(--chu-phu); font-size: 13px; }
.dau-khung .tien-do { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--chu-phu); }
.tien-do .vach { width: 110px; height: 6px; border-radius: 99px; background: var(--the-2); overflow: hidden; }
.tien-do .vach span { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #10b981); border-radius: 99px; }
.tien-do .so { font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.dau-khung .mui { color: var(--chu-phu); transition: transform .15s; display: inline-flex; }
details[open] > .dau-khung .mui { transform: rotate(90deg); }
details[open] > .dau-khung { border-bottom: 1px solid var(--vien); }
.khung .bang-bai { border: 0; border-radius: 0; box-shadow: none; }
.khung .bang-bai th { background: var(--the-2); }
.loc-tt .nut span { font-size: 12px; opacity: .75; margin-left: 2px; }
.khong-thay { text-align: center; padding: 30px; }

@media (max-width: 1100px) { .luoi-kpi { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  body.co-thanh-ben { display: block; }
  .thanh-ben { position: fixed; left: 0; top: 0; z-index: 30; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  body.mo-thanh-ben .thanh-ben { transform: none; }
  body.mo-thanh-ben .man-che { display: block; position: fixed; inset: 0; z-index: 20; background: rgb(15 23 42 / 50%); }
  .trang-rong { padding: 16px 16px 40px; }
  .an-hep { display: none !important; }
  .ten-nguoi { display: none; }
  .o-nguoi { padding: 3px; }
  .thanh-tren { padding: 8px 12px; gap: 8px; }
}
@media (max-width: 600px) {
  .luoi-kpi { gap: 10px; }
  .the-kpi { min-height: 100px; padding: 14px; }
  .the-kpi b { font-size: 24px; }
  .dau-khung { flex-wrap: wrap; padding: 12px 14px; }
  .dau-khung .tien-do { margin-left: 0; width: 100%; }
  .o-tim kbd { display: none; }
}
@media (max-width: 1250px) { .an-hep { display: none !important; } }
body.co-thanh-ben .thanh-tren { flex-wrap: nowrap; }
@media (max-width: 600px) {
  .dau-khung .mui { margin-left: auto; }
  .dau-khung .tien-do { order: 5; }
}
.o-tim { min-width: 0; }
.o-tim input { width: 100%; }
@media (max-width: 600px) {
  .dau-khung small { display: none; }
  .thanh-tren .nut-icon, .avatar { width: 34px; height: 34px; }
}
.vung-code > .monaco-editor { position: absolute !important; inset: 0; }
.vung-code { overflow: hidden; }
.chuyen-bai { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chuyen-bai select { min-width: 0; max-width: 320px; height: 38px; }
.nut-icon:disabled { opacity: .4; cursor: not-allowed; color: var(--chu-phu); border-color: var(--vien); }

/* ---------- Bài SQL: bảng kết quả, cấu trúc CSDL ---------- */
.bang-sql-boc { overflow: auto; max-height: 340px; border: 1px solid var(--vien); border-radius: 8px; margin: 6px 0 2px; background: var(--the); }
.bang-sql { border-collapse: collapse; font-size: 13px; font-family: "JetBrains Mono", ui-monospace, monospace; min-width: 100%; }
.bang-sql th { position: sticky; top: 0; background: var(--the-2); font-weight: 600; text-align: left; }
.bang-sql th, .bang-sql td { padding: 4px 10px; border-bottom: 1px solid var(--vien); white-space: nowrap; }
.bang-sql tr.lech td { background: var(--do-nhat); }
.bang-sql td.o-null { color: var(--chu-phu); font-style: italic; }
.nho-chu { font-size: 12px; }
.chu-lech { color: var(--do); }
.csdl { border: 1px solid var(--vien); border-radius: 10px; padding: 8px 12px; margin: 12px 0; background: var(--the-2); }
.csdl-dau { font-weight: 600; margin-bottom: 4px; }
.csdl-bang { margin: 4px 0; }
.csdl-bang > summary { cursor: pointer; padding: 4px 0; }
.csdl-bang .cau-truc { font-family: inherit; margin: 4px 0 6px; }
.csdl-bang .cau-truc td, .csdl-bang .cau-truc th { white-space: normal; }
.chuong-ly-thuyet { margin: 0 18px 12px; padding: 10px 14px; border-radius: 10px; background: var(--tim-nhat); font-size: 14px; }
.chuong-ly-thuyet > summary { cursor: pointer; font-weight: 600; }

/* ---------- Sân chơi SQL ---------- */
.san-choi { display: grid; grid-template-columns: minmax(260px, 34%) 1fr; gap: 8px; padding: 8px; height: calc(100vh - 62px); }
.san-choi > .bang > .noi-dung { overflow: auto; padding: 4px 14px 14px; }
.san-choi-giua { display: grid; grid-template-rows: 1fr 1fr; gap: 8px; min-height: 0; }
.ket-qua-san-choi > .noi-dung { overflow: auto; padding: 10px 14px; }
.ket-qua-san-choi .bang-sql-boc { max-height: none; }
@media (max-width: 860px) {
  .san-choi { display: flex; flex-direction: column; height: auto; }
  .san-choi-giua { grid-template-rows: 380px auto; }
}
