/* Thanh cuộn nhỏ */
#qlistCard::-webkit-scrollbar {
  width: 6px;
}

#qlistCard::-webkit-scrollbar-track {
  background: transparent;
}

#qlistCard::-webkit-scrollbar-thumb {
  background: rgba(15,103,89,.35);
  border-radius: 999px;
}

#qlistCard::-webkit-scrollbar-thumb:hover {
  background: rgba(15,103,89,.55);
}
:root {
  /* ===== Bảng màu "xanh đậm, điểm nhấn vàng" — THPT Phan Huy Chú – Đống Đa ===== */
  --navy-deep: #093f37;     /* thanh điều hướng trái + thanh tiêu đề trên cùng */
  --surface-2: #ffffff;     /* thẻ thống kê, bộ lọc, thẻ câu hỏi */
  --surface-1: #ffffff;
  --surface-0: #edf3f0;     /* nền vùng làm việc, xanh xám rất nhạt */

  --text-primary: #243c35;  /* nội dung chính */
  --text-secondary: #667c73;/* thông tin phụ */
  --text-muted: #8a9c94;

  --border: #d8e5de;        /* đường viền xanh xám */
  --border-strong: #a9c2b7;

  --radius: 12px;

  --primary: #0f6759;       /* tiêu đề khu vực, nút chính, biểu tượng, số liệu */
  --primary-dark: #093f37;
  --primary-purple: #0f6759;

  --accent-green: #30a450;  /* checkbox, trạng thái chọn, viền nhấn */

  --bg-accent: #edf3f0;
  --text-accent: #0f6759;
  --border-accent: #30a450;

  --bg-danger: #fdecec;
  --text-danger: #b5473c;
  --border-danger: #e9a39a;

  --bg-success: #f2f8f4;
  --text-success: #0f6759;
  --border-success: #30a450;

  --bg-warning: #fdf6dc;
  --text-warning: #8a6d00;
  --border-warning: #e7cf6b;

  /* Vàng nhấn: tab đang hoạt động, số câu đã chọn, điểm nhấn quan trọng */
  --accent-yellow: #f7df69;
  --text-on-yellow: #093f37;

  --shadow-soft: 0 2px 10px rgba(9, 63, 55, 0.08);

  --gradient-main: #0f6759;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-2: #232320; --surface-1: #1a1a18; --surface-0: #141412;
    --text-primary: #f1efe8; --text-secondary: #b4b2a9; --text-muted: #888780;
    --border: rgba(255,255,255,0.14); --border-strong: rgba(255,255,255,0.24);
    --bg-accent: #0C447C; --text-accent: #B5D4F4; --border-accent: #378ADD;
    --bg-danger: #791F1F; --text-danger: #F7C1C1; --border-danger: #E24B4A;
    --bg-success: #27500A; --text-success: #C0DD97; --border-success: #639922;
    --bg-warning: #633806; --text-warning: #FAC775; --border-warning: #EF9F27;
  }
}
:root[data-theme="dark"] {
  --surface-2: #232320; --surface-1: #1a1a18; --surface-0: #141412;
  --text-primary: #f1efe8; --text-secondary: #b4b2a9; --text-muted: #888780;
  --border: rgba(255,255,255,0.14); --border-strong: rgba(255,255,255,0.24);
  --bg-accent: #0C447C; --text-accent: #B5D4F4; --border-accent: #378ADD;
  --bg-danger: #791F1F; --text-danger: #F7C1C1; --border-danger: #E24B4A;
  --bg-success: #27500A; --text-success: #C0DD97; --border-success: #639922;
  --bg-warning: #633806; --text-warning: #FAC775; --border-warning: #EF9F27;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;

  background: var(--surface-0);

  color: var(--text-primary);

  font-family:
    "Segoe UI",
    Arial,
    Helvetica,
    sans-serif;

  min-height: 100%;

  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
/* Bề rộng cố định của sidebar dọc, dùng chung cho nav + đẩy header/.wrap
   sang phải đúng bằng khoảng này */
:root {
  --sidebar-w: 230px;
}

.wrap {
  width: 96%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.35rem 1rem 3rem;

  /* Chừa chỗ bên trái cho sidebar dọc cố định */
  margin-left: var(--sidebar-w);
  width: calc(96% - var(--sidebar-w));
}
header.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;

  background: var(--navy-deep);

  border-bottom: 2px solid var(--accent-yellow);
  box-shadow: none;

  padding: 0.55rem 2rem;

  /* Header giờ chỉ còn 2 cột: tiêu đề (chiếm hết chỗ dư) và khu tài khoản
     (đúng kích thước nó cần). Dải tab đã chuyển ra sidebar dọc riêng. */
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 1rem;

  /* Header chừa chỗ bên trái cho sidebar dọc, giống .wrap */
  margin-left: var(--sidebar-w);
}

/* Khối logo + tiêu đề + phụ đề: cột trái của lưới, luôn bị cắt gọn bên trong
   biên cột của nó, không bao giờ tràn sang dải tab ở cột giữa */
.header-tieude {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  overflow: hidden;
}

.header-logo-khung {
  display: grid;
  place-items: center;
  flex: none;

  width: clamp(28px, 3vw, 36px);
  height: clamp(28px, 3vw, 36px);
  border-radius: 10px;
  padding: 6px;

  background: #ffffff;
  box-shadow: none;
}

.header-logo {
  height: 100%;
  width: 100%;
  object-fit: contain;
}

/* Khu tài khoản: cột phải của header, sát mép phải */
header.top > .tai-khoan {
  justify-self: end;
}

header.top h1 {
  font-family: "Playfair Display", "Segoe UI", Arial, serif;
  /* Tự co giãn theo độ rộng màn hình, để "NGÂN HÀNG CÂU HỎI TOÁN" luôn
     hiện trọn vẹn thay vì bị cắt khi cột trái của header hẹp lại */
  font-size: clamp(15px, 1.6vw, 22px);
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.2px;
  color: #ffffff;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-sub-khung {
  display: inline-block;
  max-width: 100%;
  margin-top: 2px;
}

/* Màn hẹp (laptop, tablet ngang): thu nhỏ tiêu đề + ẩn logo/phụ đề bớt rườm rà,
   để khối trái chắc chắn không chạm vào dải tab neo giữa header */
@media (max-width: 1100px) {
  .header-tieude {
    max-width: 38vw;
  }
  header.top h1 {
    font-size: 22px;
  }
  header.top .sub {
    font-size: 11px;
  }
}

@media (max-width: 860px) {
  .header-logo-khung {
    width: 42px;
    height: 42px;
  }
  header.top h1 {
    font-size: 18px;
  }
  header.top .sub {
    display: none;
  }
}

header.top .sub {
  display: block;
  font-size: 13px;
  font-style: italic;
  color: rgba(255,255,255,.72);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  opacity: 1;
  transform: translateY(0);
  transition: opacity .16s ease, transform .16s ease;
}

/* Khi đổi tab: dòng phụ đề mờ dần + trượt nhẹ xuống trước khi đổi chữ,
   rồi hiện lại bình thường — xem capNhatMoTaHeader() trong common.js */
header.top .sub.sub-doi {
  opacity: 0;
  transform: translateY(4px);
}

/* Sidebar dọc cố định bên trái toàn trang, thay cho dải tab ngang trước đây */
.tabs {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 25;

  width: var(--sidebar-w);

  display: flex;
  flex-direction: column;
  gap: 4px;

  padding: 1.4rem 14px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 1.4rem);

  background: var(--navy-deep);
  border-right: none;
  box-shadow: none;

  overflow-y: auto;
}

.tab-btn {
  border: none;
  background: transparent;

  width: 100%;
  text-align: left;

  padding: 11px 14px;
  border-radius: 10px;

  font-family: "Oswald", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  color: #f3f0e4;
  cursor: pointer;

  transition:
    background .15s ease,
    color .15s ease;
}

.tab-btn:hover {
  background: rgba(255,255,255,.10);
  color: #ffffff;
}

.tab-btn.active {
  background: var(--accent-yellow);
  color: var(--navy-deep);

  box-shadow: none;
}

/* Ô đổi ảnh đại diện, nằm trên cùng sidebar, phía trên nút "Ngân hàng" */
.sidebar-avatar-nut {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;

  width: 100%;
  padding: 14px 10px 16px;
  margin-bottom: 6px;

  border: none;
  border-bottom: 1px solid rgba(255,255,255,.14);
  border-radius: 0;
  background: transparent;

  cursor: pointer;
  transition: background .15s ease;
}

.sidebar-avatar-nut:hover {
  background: rgba(255,255,255,.08);
}

.sidebar-avatar-khung {
  position: relative;

  width: 56px;
  height: 56px;

  display: grid;
  place-items: center;

  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(255,255,255,.3);

  overflow: hidden;
}

.sidebar-avatar-nut:hover .sidebar-avatar-khung {
  border-color: var(--accent-yellow);
}

.sidebar-avatar-chucai {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy-deep);
}

.sidebar-avatar-anh {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Biểu tượng máy ảnh nhỏ hiện đè góc dưới-phải khi di chuột, gợi ý bấm để đổi ảnh */
.sidebar-avatar-khung::after {
  content: "📷";
  position: absolute;
  right: -2px;
  bottom: -2px;

  width: 20px;
  height: 20px;

  display: grid;
  place-items: center;

  font-size: 11px;

  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(15,50,43,.25);
  border: 1px solid var(--border);
}

.sidebar-avatar-nhan {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,.75);
  text-align: center;
  line-height: 1.3;
}

@media (max-width: 760px) {
  .sidebar-avatar-nut {
    display: none;
  }
}

@media (max-width: 760px) {
  :root { --sidebar-w: 0px; }

  .tabs {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;

    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    gap: 2px;

    padding: 6px 8px;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);

    background: var(--navy-deep);
    border-right: none;
    border-top: 2px solid var(--accent-yellow);
    box-shadow: none;
  }

  .tab-btn {
    flex: 1 1 0;
    text-align: center;
    font-size: 11px;
    padding: 8px 4px;
  }

  .wrap,
  header.top {
    margin-left: 0;
  }

  .wrap {
    width: 96%;
    padding-bottom: calc(58px + 1.5rem);
  }
}
.panel { display: none; padding: 1rem; }
.panel.active { display: block; }
.card {
  background: #ffffff;

  border: 1px solid var(--border);
  border-radius: 12px;

  padding: 1.15rem 1.3rem;
  margin-bottom: 1rem;

  box-shadow: none;

  transition: border-color .15s ease;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: none;
}
label {
  font-size: 12px;
  font-weight: 700;

  color: var(--text-secondary);

  display: block;
  margin-bottom: 6px;
}
input[type=text],
input[type=number],
textarea,
select {
  width: 100%;

  padding: 10px 12px;

  border: 1px solid var(--border);
  border-radius: 10px;

  background: #ffffff;
  color: var(--text-primary);

  font-size: 14px;
  font-family: inherit;

  outline: none;

  box-shadow: none;

  transition: border-color .15s ease;
}
input[type=text]:focus,
input[type=number]:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);

  box-shadow: 0 0 0 3px rgba(15,103,89,.12);

  background: #ffffff;
}
textarea { min-height: 70px; resize: vertical; line-height: 1.5; }
.row {
  display: grid;

  grid-template-columns:
    repeat(3, minmax(0, 1fr));

  gap: 14px;

  margin-bottom: 14px;
}
@media (max-width: 1000px) {
  .row {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 650px) {
  .row {
    grid-template-columns: 1fr;
  }
}
/* Bọc ngoài .matrix-row: cho phép cuộn ngang riêng hàng này khi màn hình
   không đủ rộng, thay vì để các ô tràn ra ngoài khung thẻ câu hỏi. */
.matrix-row-cuon {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;   /* chừa chỗ cho thanh cuộn, không đè lên nội dung */
}

.matrix-row-cuon::-webkit-scrollbar {
  height: 6px;
}
.matrix-row-cuon::-webkit-scrollbar-track {
  background: transparent;
}
.matrix-row-cuon::-webkit-scrollbar-thumb {
  background: rgba(15,103,89,.4);
  border-radius: 999px;
}

.matrix-row {
  display: grid;
  grid-template-columns:
    95px
    180px
    180px
    220px
    140px
    180px
    120px;
  gap: 10px;
  align-items: end;

  /* Giữ đúng tổng độ rộng các cột cố định; không co lại dưới mức này.
     Khi khung cha hẹp hơn, .matrix-row-cuon sẽ hiện thanh cuộn ngang
     thay vì để hàng này bị bóp nhỏ hoặc tràn ra ngoài. */
  width: max-content;
  min-width: 100%;
}

.matrix-row .field {
  min-width: 0;   /* để label/select con co được, ellipsis mới ăn */
}

/* Nhãn và nội dung ô chọn dài quá thì cắt gọn thành "…", không làm vỡ layout */
.matrix-row .field label,
.matrix-row .field select {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.field { margin-bottom: 10px; }
button {
  border: 1px solid var(--border);

  background: #ffffff;
  color: var(--text-primary);

  padding: 9px 15px;
  border-radius: 10px;

  font-size: 13px;
  font-weight: 700;

  cursor: pointer;

  box-shadow: none;

  transition:
    background .15s ease,
    border-color .15s ease;
}

button:hover {
  background: var(--surface-0);
  border-color: var(--border-strong);

  box-shadow: none;
  transform: none;
}

button:active {
  transform: none;
}

button.primary {
  background: var(--primary);
  color: #ffffff;

  border-color: transparent;

  box-shadow: none;
}

button.primary:hover {
  background: var(--primary-dark);

  box-shadow: none;
}

button.danger {
  color: var(--text-danger);

  background: var(--bg-danger);
  border-color: var(--border-danger);
}

button.small {
  padding: 7px 11px;
  font-size: 12px;
  border-radius: 10px;
}
.opts { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.opt-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.opt-row input[type=text] { flex: 1; }
.badge {
  display: inline-flex;
  align-items: center;

  font-size: 11px;
  font-weight: 700;

  padding: 4px 9px;

  border-radius: 999px;

  border: 1px solid transparent;

  line-height: 1.2;
}

.b-blue {
  background: var(--surface-0);
  color: var(--primary);
  border-color: var(--border);
}

.b-green {
  background: #eafaf1;
  color: #148552;
  border-color: rgba(20,133,82,.10);
}

.b-amber {
  background: #fff6df;
  color: #b76d00;
  border-color: rgba(183,109,0,.10);
}

.b-red {
  background: #fff0f0;
  color: #d93c44;
  border-color: rgba(217,60,68,.10);
}
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;

  margin-bottom: 1rem;

  padding: 14px;

  background: #ffffff;

  border: 1px solid var(--border);
  border-radius: 12px;

  box-shadow: none;
}
.filters label {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.filters select,
.filters input {
  width: auto;
  min-width: 140px;
  flex: 1 1 150px;
}

.filters #fSearch {
  flex: 2 1 240px;
}
.qlist-item {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;

  padding: 14px 16px;
  margin-bottom: 12px;

  background: #ffffff;

  border: 1px solid var(--border);
  border-radius: 12px;

  box-shadow: none;

  transition: border-color .15s ease;
}

.qlist-item:hover {
  transform: none;

  border-color: #30a450;

  box-shadow: 0 2px 10px rgba(48,164,80,.14);
}

.qlist-item:last-child {
  margin-bottom: 0;
}

.qmeta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;

  margin: 8px 0;
}

.qcontent {
  font-size: 14px;
  line-height: 1.65;

  color: var(--text-primary);
}

.qopts {
  margin-top: 10px;

  font-size: 13px;
  color: var(--text-secondary);

  background: var(--surface-0);

  padding: 10px 12px;

  border-radius: 10px;
  border: 1px solid var(--border);
}

.qopts div {
  padding: 3px 0;
}

.qopts .correct {
  color: var(--text-success);
  font-weight: 700;
}

.actions-row {
  display: flex;
  gap: 8px;

  margin-top: 10px;
  flex-wrap: wrap;
}
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;

  margin-bottom: 1rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;

  min-height: 86px;

  padding: 16px 18px;

  background: #ffffff;

  border: 1px solid var(--border);
  border-radius: 12px;

  box-shadow: none;

  color: var(--text-secondary);

  font-size: 12px;
  font-weight: 700;

  position: relative;
  overflow: hidden;
}

.stat::before {
  display: none;
}

.stat b {
  font-size: 27px;
  line-height: 1;

  font-weight: 800;
  color: var(--primary);
}

@media (max-width: 900px) {
  .stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .stats-row {
    grid-template-columns: 1fr;
  }
}
.check { width: 18px; height: 18px; margin-top: 3px; flex-shrink: 0; cursor: pointer; accent-color: #30a450; }
.selbar {
  position: sticky;
  bottom: 12px;
  z-index: 10;

  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;

  margin: 12px 0 0;
  padding: 12px 14px;

  background: #ffffff;

  border: 1px solid var(--border-strong);
  border-radius: 12px;

  box-shadow: 0 2px 12px rgba(15,50,43,.08);
}
.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text-primary);
  color: var(--surface-2); padding: 10px 18px; border-radius: var(--radius); font-size: 13px; z-index: 100;
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.formtitle {
  font-size: 17px;
  font-weight: 800;

  margin: 0 0 14px;

  color: var(--primary);
  letter-spacing: -0.2px;
}
.img-prev { max-width: 100%; border-radius: 6px; margin-top: 6px; display: none; }
.opt-img-tools { flex: 0 0 100%; margin-left: 26px; display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.opt-img-preview { display: none; max-width: 240px; max-height: 150px; object-fit: contain; border-radius: 6px; border: 1px solid var(--border); }
.opt-img-remove { display: none; }
.tf-list { display: grid; gap: 10px; margin-top: 6px; }
.tf-row { border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.tf-main { display: grid; grid-template-columns: 28px minmax(0,1fr) 110px; gap: 8px; align-items: center; }
.tf-letter { font-weight: 600; }
.tf-explanation { margin-top: 8px; }
@media (max-width: 650px) { .tf-main { grid-template-columns: 28px 1fr; } .tf-correct { grid-column: 2; } }
.word-import-overlay {
  position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center;
  padding: 20px; background: rgba(0,0,0,.42);
}
.word-import-overlay.show { display: flex; }
.word-import-box {
  width: min(1100px, 96vw); max-height: 90vh; overflow: auto; background: var(--surface-2);
  border-radius: 10px; padding: 18px; box-shadow: 0 18px 50px rgba(0,0,0,.2);
}
.word-import-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 10px; }
.word-import-list { margin-top: 12px; max-height: 48vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.word-import-item { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.word-import-item:last-child { border-bottom: none; }
.word-import-item img { display: block; max-width: 220px; max-height: 130px; object-fit: contain; margin: 6px 0; }
.word-item-fields { display:grid; grid-template-columns:110px minmax(150px,1fr) minmax(150px,1fr) 140px 130px; gap:8px; margin:10px 0 4px; padding:9px; background:var(--surface-1); border-radius:8px; }
.word-item-fields .field { margin:0; }
.word-item-fields label { font-size:11px; }
@media (max-width: 800px) { .word-import-grid, .word-item-fields { grid-template-columns: 1fr 1fr; } }
.exam-item { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 0.5px solid var(--border); }
.exam-item .n { color: var(--text-muted); font-size: 12px; width: 20px; }
.exam-item .t { flex: 1; font-size: 13px; }
/* ===== MÀN HÌNH ĐĂNG NHẬP ===== */
#loginScreen{
  position:fixed;
  inset:0;
  z-index:99999;

  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px;

  background:
    radial-gradient(circle at 15% 15%, rgba(48,164,80,.16), transparent 42%),
    radial-gradient(circle at 85% 20%, rgba(15,103,89,.14), transparent 45%),
    radial-gradient(circle at 50% 100%, rgba(247,223,105,.18), transparent 50%),
    var(--surface-0, #edf3f0);
}

.login-box{
  width:420px;
  max-width:100%;

  padding:38px 36px 30px;

  background:#ffffff;

  border:1px solid var(--border);
  border-radius:22px;

  box-shadow: 0 20px 48px rgba(9,63,55,.14), 0 2px 8px rgba(9,63,55,.06);

  text-align:center;
}

.login-icon{
  width:72px;
  height:72px;
  margin:0 auto 18px;

  display:flex;
  align-items:center;
  justify-content:center;

  border-radius:20px;
  background:linear-gradient(135deg, var(--primary, #0f6759), var(--accent-green, #30a450));
  box-shadow:0 8px 20px rgba(15,103,89,.32);
}

.login-box h2{
  margin:0 0 6px;

  text-align:center;

  font-size:23px;
  font-weight:800;

  color: var(--primary-dark, #093f37);
}

.login-sub{
  margin:0 0 26px;
  text-align:center;
  font-size:13.5px;
  color: var(--text-secondary, #667c73);
}

.login-field-label{
  display:flex;
  align-items:center;
  gap:5px;
  text-align:left;
  font-size:12.5px;
  font-weight:700;
  color: var(--text-secondary, #667c73);
  margin:0 0 6px;
}
.login-field-label .login-label-icon{ flex:none; opacity:.8; }

.login-input-wrap{
  position:relative;
  margin-bottom:16px;
}

.login-input-wrap .login-input-icon{
  position:absolute;
  left:13px;
  top:50%;
  transform:translateY(-50%);
  display:flex;
  color: var(--text-secondary, #667c73);
  opacity:.65;
  pointer-events:none;
}

.login-box input{
  width:100%;
  box-sizing:border-box;
  margin:0;
  padding:12px 14px 12px 38px;
  border:1.5px solid var(--border);
  border-radius:12px;
  font-size:15px;
  background:var(--surface-0, #f7faf8);
  transition:border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

#loginPassword{
  padding-right:42px;
}

.login-box input:focus{
  outline:none;
  border-color: var(--primary, #0f6759);
  background:#ffffff;
  box-shadow:0 0 0 3px rgba(15,103,89,.12);
}

/* Độ đặc hiệu cao hơn ".login-box button" (2 class thay vì 1) để chắc chắn
   không bị khối CSS của nút chính (gradient, width:100%, padding lớn) ghi
   đè, dù hai khối này đứng trước/sau nhau thế nào trong file. */
.login-box button.login-toggle-pw{
  position:absolute !important;
  right:6px !important;
  top:50% !important;
  left:auto !important;
  transform:translateY(-50%) !important;
  width:30px !important;
  height:30px !important;
  padding:0 !important;
  border:0 !important;
  background:transparent !important;
  color: var(--text-secondary, #667c73);
  cursor:pointer;
  border-radius:8px;
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:.7;
  box-shadow:none !important;
}
.login-box button.login-toggle-pw:hover{
  opacity:1;
  background:var(--surface-0, #edf3f0) !important;
  transform:translateY(-50%) !important;
}
.login-box button.login-toggle-pw:active{ transform:translateY(-50%) !important; }

.login-box button{
  width:100%;
  padding:13px;
  border:0;
  border-radius:12px;
  background: linear-gradient(135deg, var(--primary, #0f6759), var(--primary-dark, #093f37));
  color:#ffffff;
  font-weight:700;
  font-size:15px;
  cursor:pointer;
  box-shadow:0 8px 18px rgba(15,103,89,.26);
  transition:transform .12s ease, box-shadow .12s ease, filter .12s ease;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
}
.login-box button:hover{
  transform:translateY(-1px);
  box-shadow:0 10px 22px rgba(15,103,89,.32);
  filter:brightness(1.04);
}
.login-box button:active{ transform:translateY(0); }

.login-divider{
  display:flex;
  align-items:center;
  gap:12px;
  margin:20px 0 16px;
  color:var(--text-muted, #8a9c94);
  font-size:11px;
  font-weight:700;
  letter-spacing:.06em;
}
.login-divider::before, .login-divider::after{
  content:'';
  flex:1;
  height:1px;
  background:var(--border);
}

.login-secondary-btn{
  background:#ffffff !important;
  color:var(--primary, #0f6759) !important;
  border:1.5px solid var(--border) !important;
  box-shadow:none !important;
}
.login-secondary-btn:hover{
  background:var(--surface-0, #edf3f0) !important;
  border-color:var(--primary, #0f6759) !important;
  transform:none;
}

.login-hint{
  font-size:12px;
  color:var(--text-muted, #8a9c94);
  margin:12px 0 0;
  line-height:1.5;
  text-align:left;
}

#loginMessage{
  margin-top:14px;
  text-align:center;
  font-size:14px;
}

@media (max-width: 480px){
  .login-box{ padding:30px 22px 24px; border-radius:18px; }
}
/* Danh sách câu hỏi có thanh cuộn riêng */
#qlistCard {
  grid-column: 2;
  grid-row: 2;
  margin-bottom: 0;
  position: relative;
  height: 1000px;
  min-height: 0;
  max-height: 560px;

  overflow-y: auto;
  overflow-x: hidden;

  box-sizing: border-box;

  background: transparent;
  border: none;
  box-shadow: none;

  padding: 2px 8px 20px 2px;
  margin-bottom: 0;
}
.bank-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;

  margin-bottom: 16px;
  padding: 20px 22px;

  background: var(--primary);

  border-radius: 16px;

  color: #ffffff;

  box-shadow: none;

  overflow: hidden;
}

.bank-hero-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;

  opacity: .82;

  margin-bottom: 6px;
}

.bank-hero h2 {
  margin: 0 0 6px;

  font-size: 24px;
  font-weight: 800;
}

.bank-hero p {
  margin: 0;

  max-width: 680px;

  font-size: 13px;
  line-height: 1.6;

  color: rgba(255,255,255,.88);
}

.bank-hero-badge {
  width: 76px;
  height: 76px;

  flex: 0 0 76px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 22px;

  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.24);

  font-size: 38px;
  font-weight: 700;

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.22);
}

@media (max-width: 700px) {
  .bank-hero-badge {
    display: none;
  }

  .bank-hero {
    padding: 18px;
  }

  .bank-hero h2 {
    font-size: 20px;
  }
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;

  margin: 4px 0 10px;
}

.section-heading-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
}

.section-heading-sub {
  margin-top: 3px;

  font-size: 12px;
  color: var(--text-muted);
}

.nut-ghi-chu {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 3px 10px;
  border: 1px solid var(--border-warning);
  border-radius: 999px;
  background: var(--bg-warning);
  color: var(--text-warning);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  vertical-align: middle;
}
.nut-ghi-chu:hover {
  filter: brightness(0.97);
}

/* ===== Modal "Chú thích chọn câu hỏi" (giữa màn hình, ESC/✕ để đóng) ===== */
.modal-ghi-chu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 63, 55, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-ghi-chu {
  background: var(--surface-1);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 50px rgba(9, 63, 55, 0.35);
}
.modal-ghi-chu-top {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.modal-ghi-chu-title {
  font-weight: 800;
  font-size: 15px;
  color: var(--primary);
}
.modal-ghi-chu-close {
  all: unset;
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
}
.modal-ghi-chu-close:hover {
  background: var(--surface-0);
}
.modal-ghi-chu-body {
  padding: 16px 18px 20px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-primary);
}
.modal-ghi-chu-body p { margin: 0 0 8px; }
.modal-ghi-chu-body ol { margin: 0 0 14px; padding-left: 20px; }
.modal-ghi-chu-body li { margin-bottom: 4px; }
.qlist-heading {
  margin-top: 2px;
}

.qlist-heading-note {
  padding: 7px 10px;

  background: var(--accent-yellow);
  color: var(--text-on-yellow);

  border: none;
  border-radius: 999px;

  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 650px) {
  .qlist-heading-note {
    display: none;
  }
}
html {
  overflow-y: scroll !important;
}

body {
  overflow-y: visible !important;
  min-height: 100vh;
}
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;

  margin: 14px 0 8px;
  flex-wrap: wrap;
}

.pagination button {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;

  border-radius: 10px;

  background: #ffffff;
  color: var(--text-secondary);

  border: 1px solid var(--border);

  font-size: 12px;
  font-weight: 700;
}

.pagination button.active {
  background: var(--accent-yellow);
  color: var(--navy-deep);
  font-weight: 800;

  border-color: transparent;

  box-shadow: none;
}

.pagination button:disabled {
  opacity: .4;
  cursor: default;
  transform: none;
}
.pagination-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 28px;

  color: var(--text-muted);

  font-size: 14px;
  font-weight: 800;
}
.bank-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-rows: auto 560px auto;
  column-gap: 18px;
  row-gap: 0;
  align-items: stretch;
}

.filter-sidebar {
  grid-column: 1;
    grid-row: 1 / 3;
  align-self: stretch;
  min-height: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;

  padding: 16px;

  box-shadow: none;
}

.bank-main {
  display: contents;
}

.qlist-heading { grid-column: 2; grid-row: 1; }
#pagination    { grid-column: 2; grid-row: 3; }

.filter-sidebar .filters {
  
  display: flex;
  flex-direction: column;
  gap: 10px;

  padding: 0;
  margin: 0;

  background: transparent;
  border: none;
  box-shadow: none;
}
.filter-sidebar .filters #fSearch {
  flex: none;
  width: 100%;
  height: auto;
  min-height: 42px;
}

.filter-sidebar .filters select,
.filter-sidebar .filters input {
  width: 100%;
  min-width: 0;
  flex: none;
}

.filter-sidebar .filters label {
  width: 100%;
}

@media (max-width: 1000px) {
  .bank-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .filter-sidebar,
  .qlist-heading,
  #qlistCard,
  #pagination {
    grid-column: auto;
    grid-row: auto;
  }
}

/* Tab Ngân hàng: rút ngắn khoảng trống dưới phân trang */
.wrap:has(#panel-bank.active) { padding-bottom: 12px; }
#panel-bank { padding-bottom: 0; }
#panel-bank .pagination { margin-bottom: 0; }
.cong-tac-sap-xep {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  user-select: none;
  vertical-align: middle;
}

.cong-tac-sap-xep input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.cong-tac-truot {
  position: relative;
  width: 40px;
  height: 22px;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.cong-tac-truot::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.2s ease;
}

.cong-tac-sap-xep input:checked + .cong-tac-truot {
  background: var(--primary);
}

.cong-tac-sap-xep input:checked + .cong-tac-truot::before {
  transform: translateX(18px);
}

.cong-tac-sap-xep input:focus-visible + .cong-tac-truot {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== Tab Soạn đề theo ma trận: khung tải file Excel ===== */
.khung-tai-matran {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;

  margin-top: 14px;
  padding: 12px 16px;

  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.khung-tai-matran-noidung {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1 1 280px;
}

.khung-tai-matran-nut {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.khung-tai-matran-nut a.small {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.ket-qua-doc-matran {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
}

.ket-qua-doc-matran.thanh-cong {
  background: #eafaf1;
  border: 1px solid rgba(20,133,82,.18);
  color: #148552;
}

.ket-qua-doc-matran.co-canh-bao {
  background: #fff6df;
  border: 1px solid rgba(183,109,0,.2);
  color: #8a5800;
}

.ket-qua-doc-matran.loi {
  background: #fff0f0;
  border: 1px solid rgba(217,60,68,.2);
  color: #b3272f;
}

.ket-qua-doc-matran ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

/* Khung "Xem danh sách câu hỏi" ở tab Game ôn tập: giới hạn chiều cao + cuộn dọc
   khi danh sách câu hỏi dài, để không kéo giãn cả trang. */
.xem-truoc-cau-hoi {
  max-height: 360px;
  overflow-y: auto;
}

.xem-truoc-cau-hoi::-webkit-scrollbar {
  width: 6px;
}

.xem-truoc-cau-hoi::-webkit-scrollbar-track {
  background: transparent;
}

.xem-truoc-cau-hoi::-webkit-scrollbar-thumb {
  background: rgba(15,103,89,.35);
  border-radius: 999px;
}

.xem-truoc-cau-hoi::-webkit-scrollbar-thumb:hover {
  background: rgba(15,103,89,.55);
}

/* Ô "Dạng câu hỏi" bị khóa cố định theo trò chơi đang chọn ở tab Game ôn tập */
#gameType:disabled {
  background: #eef2f0;
  color: var(--text-secondary);
  cursor: not-allowed;
  opacity: .85;
}

/* ===== Tab Tài khoản: duyệt giáo viên mới đăng ký ===== */
.dong-cho-duyet {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.dong-cho-duyet.dong-da-duyet { opacity: .75; }
.dong-cho-duyet-email {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dong-cho-duyet-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chon-vai-tro-moi {
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
}

/* ===== Tab "Game ôn tập" ===== */
.step-badge {
  flex: none;
  background: var(--accent-yellow);
  color: var(--text-on-yellow);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 900px) {
  .setup-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  .setup-grid { grid-template-columns: 1fr; }
}

.radio-group {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 900px) {
  .games-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  .games-grid { grid-template-columns: 1fr; }
}

.game-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  background: #ffffff;
  transition: border-color .15s ease, box-shadow .15s ease;
  position: relative;
  overflow: hidden;
}

.game-card.active { cursor: pointer; }

.game-card.active:hover {
  border-color: #30a450;
  box-shadow: 0 2px 12px rgba(48,164,80,.14);
}

.game-card.dang-chon {
  border-color: #30a450;
  border-width: 2px;
  background: #f2f8f4;
}

.game-card.dang-chon h3::after {
  content: "✓ Đang chọn";
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #30a450;
  vertical-align: middle;
}

.game-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--surface-0);
  margin-bottom: 12px;
}

.game-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--primary);
}

.game-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.game-card .status {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-success);
  color: var(--text-success);
}

.game-card .status.soon {
  background: var(--surface-0);
  color: var(--text-muted);
}