:root { --radius: 18px; }
body { background: #f5f7fb; }
.logo-small { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; background:#fff; padding:2px; }
.card { border: 0; border-radius: var(--radius); box-shadow: 0 10px 25px rgba(18,38,63,.06); }
.card-stat { min-height: 120px; }
.card-stat .number { font-size: 2rem; font-weight: 800; }
.table thead th { background: #f0f4ff; white-space: nowrap; }
.badge-soft { background: #eef5ff; color: #0d6efd; }
.search-box { max-width: 360px; }
.action-col { width: 1%; white-space: nowrap; }
.print-header { display:none; }
@media print {
  nav, .no-print, .btn, .page-title { display:none!important; }
  body { background:#fff; }
  .card { box-shadow:none; border:1px solid #ddd; }
  .print-header { display:block; text-align:center; margin-bottom:18px; }
  .container-fluid { width:100%; padding:0; }
}

.selected-row { background: #fff3cd !important; box-shadow: inset 4px 0 0 #ffc107; }
.exam-pick-card { transition: .15s ease; }
.exam-pick-card:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(18,38,63,.1); }
.sticky-side { position: sticky; top: 84px; }
.table-hover tbody tr.selected-row td { background: #fff3cd !important; }
.already-awarded-row td { background: #d1e7dd !important; }
.modal-backdrop { z-index: 1040; }

.app-footer { border-top: 1px solid rgba(0,0,0,.06); background: #fff; }

.already-assigned-row td { background: #f8d7da !important; }
.table-hover tbody tr.already-assigned-row:hover td { background: #f5c2c7 !important; }
.table-hover tbody tr.selected-row td { background: #fff3cd !important; }
.profile-btn-wrap { white-space: normal !important; width: 96px; line-height: 1.15; }
.filter-panel .form-label { font-size: .875rem; font-weight: 600; margin-bottom: .25rem; }
.filter-scroll { max-height: 150px; overflow: auto; }

.profile-btn-wrap { width: 112px; min-width:112px; white-space: normal !important; line-height: 1.15; text-align:center; padding-left:.45rem; padding-right:.45rem; }
.already-assigned-row.selected-row td { background: #f8d7da !important; box-shadow: inset 4px 0 0 #dc3545; }
.student-pick-row { cursor: pointer; }
.student-pick-row input[type=checkbox] { cursor: pointer; }

/* V3.6: nút hồ sơ giải học sinh ép đúng 2 dòng, không vỡ thành 3-4 dòng */
.profile-btn-wrap {
  width: 132px !important;
  min-width: 132px !important;
  max-width: 132px !important;
  white-space: normal !important;
  line-height: 1.08 !important;
  text-align: center !important;
  padding: .35rem .45rem !important;
}
.profile-btn-wrap span { display: block; white-space: nowrap; }
.profile-btn-wrap .line-1,
.profile-btn-wrap .line-2 { display:block; white-space:nowrap; }
.compact-filter { max-height: 180px; overflow: auto; }

/* V3.9: báo cáo gọn hơn */
.filter-box { border: 1px solid rgba(0,0,0,.08); border-radius: 14px; padding: 12px; background: #fff; }
.filter-panel .form-label { font-size: .88rem; font-weight: 700; }


/* V3.11: bộ lọc báo cáo gọn, rõ nhóm, chuyên nghiệp hơn */
.report-filter-card { border: 1px solid rgba(13,110,253,.08); }
.report-filter-main { background: linear-gradient(135deg,#f8fbff,#eef5ff); border: 1px solid rgba(13,110,253,.12); }
.report-action-bar .btn { min-width: 108px; }
.report-filter-card .filter-box { background:#fff; border:1px solid rgba(0,0,0,.08); border-radius:14px; padding:12px; }
.report-filter-card .filter-scroll { max-height: 132px; overflow:auto; }
.report-filter-card .form-check { margin-bottom: .2rem; }
.report-filter-card .form-label { font-size:.86rem; font-weight:700; color:#344767; }
@media (max-width: 768px) { .report-action-bar .btn { width: 100%; } }

/* V3.17: ổn định logo trên điện thoại */
.navbar-brand { min-width: 0; max-width: 72vw; }
.navbar-brand .logo-small { flex: 0 0 auto; display: inline-block !important; }
.navbar-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-logo { max-height: 72px; max-width: 160px; object-fit: contain; }
@media (max-width: 576px) {
  .logo-small { width: 32px; height: 32px; }
  .navbar-brand span { max-width: calc(72vw - 44px); }
}


/* V3.19: giữ menu đúng vị trí như V3.17, chỉ ổn định nguồn logo */
.navbar-brand { min-width: 0; max-width: 72vw; overflow: hidden; }
.navbar-brand .logo-small { flex: 0 0 auto; display: inline-block !important; object-fit: contain; background: #fff; }
.navbar-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-logo { height:72px; max-width:120px; object-fit:contain; }
.settings-logo-preview { max-height:80px; max-width:160px; object-fit:contain; }
.login-logo { display:block; margin-left:auto; margin-right:auto; max-height:72px; max-width:160px; object-fit:contain; }
@media (max-width: 576px) {
  .logo-small { width: 32px !important; height: 32px !important; }
  .navbar-brand { max-width: 72vw; }
  .navbar-brand span { max-width: calc(72vw - 44px); font-size: .98rem; }
  .dashboard-logo { height:58px; max-width:96px; }
}

/* V3.20: BMS premium color theme - phối theo hướng xanh navy + vàng kim, hợp logo trường và giao diện chuyên nghiệp */
:root {
  --radius: 18px;
  --bms-primary: #123c63;
  --bms-primary-2: #1f5f99;
  --bms-primary-dark: #0b2946;
  --bms-primary-soft: #eaf3ff;
  --bms-accent: #f2b705;
  --bms-accent-2: #e8842a;
  --bms-danger: #d93838;
  --bms-success: #147d6f;
  --bms-ink: #18233d;
  --bms-muted: #64748b;
  --bms-bg: #f4f7fb;
  --bms-card: #ffffff;
  --bms-border: rgba(18,60,99,.12);
  --bms-shadow: 0 14px 34px rgba(18, 60, 99, .10);
}

html { background: var(--bms-bg); }
body {
  background:
    radial-gradient(circle at 0% 0%, rgba(242,183,5,.10), transparent 28%),
    radial-gradient(circle at 100% 0%, rgba(31,95,153,.12), transparent 30%),
    var(--bms-bg);
  color: var(--bms-ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--bms-primary-2); text-decoration: none; }
a:hover { color: var(--bms-primary-dark); }
.text-muted { color: var(--bms-muted) !important; }

/* Thanh điều hướng */
.navbar.bg-primary,
.navbar-dark.bg-primary {
  background: linear-gradient(95deg, var(--bms-primary-dark) 0%, var(--bms-primary) 48%, var(--bms-primary-2) 100%) !important;
  border-bottom: 4px solid var(--bms-accent);
  box-shadow: 0 10px 28px rgba(11,41,70,.24) !important;
}
.navbar-brand {
  font-weight: 800;
  letter-spacing: .1px;
}
.navbar-brand span { color: #fff; }
.logo-small {
  border-radius: 12px;
  background: #fff;
  padding: 3px;
  box-shadow: 0 5px 15px rgba(0,0,0,.18);
}
.navbar-dark .navbar-nav .nav-link {
  color: rgba(255,255,255,.84);
  border-radius: 999px;
  padding-left: .9rem;
  padding-right: .9rem;
  transition: .15s ease;
}
.navbar-dark .navbar-nav .nav-link:hover,
.navbar-dark .navbar-nav .nav-link:focus {
  color: #fff;
  background: rgba(255,255,255,.12);
}
.navbar-dark .navbar-nav .nav-link.active {
  color: #102a43 !important;
  background: linear-gradient(135deg, #fff5cf, var(--bms-accent));
  box-shadow: 0 5px 14px rgba(242,183,5,.28);
}
.navbar .btn-light {
  border: 0;
  color: var(--bms-primary-dark);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}

/* Tiêu đề, card, dashboard */
.page-title h1,
h1, h2, h3, h4, h5, h6 { color: var(--bms-ink); }
.page-title h1 {
  font-weight: 800;
  padding-left: .85rem;
  border-left: 5px solid var(--bms-accent);
}
.card {
  background: var(--bms-card);
  border: 1px solid var(--bms-border);
  border-radius: var(--radius);
  box-shadow: var(--bms-shadow);
}
.card:hover { box-shadow: 0 16px 36px rgba(18,60,99,.13); }
.card-stat {
  border-top: 4px solid var(--bms-accent);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}
.card-stat .number,
.card .h2 {
  color: var(--bms-primary);
  font-weight: 900;
}
.dashboard-logo,
.settings-logo-preview,
.login-logo {
  background: #fff;
  border-radius: 18px;
  padding: 6px;
  box-shadow: 0 8px 22px rgba(18,60,99,.14);
}

/* Bảng dữ liệu */
.table {
  --bs-table-color: var(--bms-ink);
}
.table thead th {
  background: linear-gradient(180deg, #edf6ff 0%, #e2efff 100%) !important;
  color: var(--bms-primary-dark);
  border-bottom: 1px solid rgba(18,60,99,.18);
  font-weight: 800;
}
.table tbody tr { vertical-align: middle; }
.table-hover tbody tr:hover td {
  background: #fffaf0 !important;
}

/* Nút bấm */
.btn {
  border-radius: 999px;
  font-weight: 700;
}
.btn-primary {
  background: linear-gradient(135deg, var(--bms-primary), var(--bms-primary-2));
  border-color: var(--bms-primary);
  box-shadow: 0 6px 14px rgba(18,60,99,.18);
}
.btn-primary:hover,
.btn-primary:focus {
  background: linear-gradient(135deg, var(--bms-primary-dark), var(--bms-primary));
  border-color: var(--bms-primary-dark);
}
.btn-outline-primary {
  color: var(--bms-primary);
  border-color: var(--bms-primary-2);
}
.btn-outline-primary:hover,
.btn-outline-primary:focus {
  color: #fff;
  background: var(--bms-primary);
  border-color: var(--bms-primary);
}
.btn-success {
  background: linear-gradient(135deg, #0f766e, #14947f);
  border-color: #0f766e;
}
.btn-outline-success { color:#0f766e; border-color:#0f766e; }
.btn-outline-success:hover { background:#0f766e; border-color:#0f766e; }
.btn-warning,
.profile-btn-wrap {
  background: linear-gradient(135deg, #ffd95a, var(--bms-accent)) !important;
  border-color: #e6a800 !important;
  color: #3d2b00 !important;
  box-shadow: 0 5px 14px rgba(242,183,5,.22);
}
.btn-outline-danger { border-color: var(--bms-danger); color: var(--bms-danger); }
.btn-outline-danger:hover,
.btn-danger { background: var(--bms-danger); border-color: var(--bms-danger); }
.btn-light { background: #f8fafc; border-color: #e2e8f0; }

/* Badge và trạng thái */
.badge { border-radius: 999px; font-weight: 800; }
.badge-soft,
.text-bg-primary {
  background: var(--bms-primary-soft) !important;
  color: var(--bms-primary) !important;
}
.text-bg-warning {
  background: #fff0b8 !important;
  color: #5c4100 !important;
}
.text-bg-danger {
  background: #ffe1e1 !important;
  color: #a51515 !important;
}
.text-bg-success {
  background: #dff8f4 !important;
  color: #0f766e !important;
}
.text-bg-secondary,
.text-bg-light {
  background: #edf2f7 !important;
  color: #334155 !important;
}

/* Form */
.form-control,
.form-select {
  border-radius: 14px;
  border-color: #d7e1ef;
}
.form-control:focus,
.form-select:focus {
  border-color: var(--bms-primary-2);
  box-shadow: 0 0 0 .22rem rgba(31,95,153,.14);
}
.form-label { color: #32455f; font-weight: 700; }
.modal-content { border: 0; border-radius: 22px; box-shadow: 0 22px 60px rgba(18,60,99,.20); }
.modal-header {
  background: linear-gradient(135deg, #f7fbff, #edf6ff);
  border-bottom: 1px solid var(--bms-border);
  border-radius: 22px 22px 0 0;
}
.modal-title { font-weight: 800; color: var(--bms-primary-dark); }

/* Màu dòng chọn/gán giải */
.selected-row td,
.table-hover tbody tr.selected-row td {
  background: #fff3bf !important;
  box-shadow: inset 5px 0 0 var(--bms-accent);
}
.already-assigned-row td,
.table-hover tbody tr.already-assigned-row:hover td {
  background: #ffe3e3 !important;
  box-shadow: inset 5px 0 0 var(--bms-danger);
}
.already-assigned-row.selected-row td {
  background: #ffd6d6 !important;
  box-shadow: inset 5px 0 0 var(--bms-danger);
}
.already-awarded-row td { background: #dff8f4 !important; }

/* Bộ lọc báo cáo */
.filter-box,
.report-filter-card .filter-box {
  background: #ffffff;
  border: 1px solid var(--bms-border);
  border-radius: 16px;
}
.report-filter-card {
  border: 1px solid rgba(18,60,99,.10);
  overflow: hidden;
}
.report-filter-main {
  background: linear-gradient(135deg, #f7fbff 0%, #edf6ff 70%, #fff9e6 100%);
  border: 1px solid rgba(18,60,99,.12);
}
.report-action-bar .btn { min-width: 112px; }

/* Footer */
.app-footer {
  background: linear-gradient(95deg, var(--bms-primary-dark), var(--bms-primary));
  color: rgba(255,255,255,.78) !important;
  border-top: 3px solid var(--bms-accent);
}

@media (max-width: 576px) {
  .navbar-dark .navbar-nav .nav-link {
    border-radius: 12px;
    padding-top: .55rem;
    padding-bottom: .55rem;
  }
  .card { border-radius: 16px; }
  .btn { border-radius: 14px; }
}

/* V3.31: Điểm thưởng - thẻ dọc, hẹp và cao để hình PNG toàn thân là nội dung chính */
.dojo-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(145px, 1fr));
  gap: 22px 16px;
  align-items: stretch;
}
.bonus-student-card {
  min-width: 0;
}
.dojo-student-tile {
  position: relative;
  height: 395px;
  min-height: 395px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 10px 16px;
  background: #fff;
  border: 1px solid #dfe3e8;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(15, 23, 42, .10);
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.dojo-student-tile:hover {
  border-color: #c6cdd6;
  box-shadow: 0 5px 14px rgba(15, 23, 42, .14);
  transform: translateY(-2px);
}
.dojo-student-tile.selected {
  background: #fff7cf;
  border-color: #e5b800;
  box-shadow: 0 0 0 3px rgba(242, 183, 5, .22), 0 5px 14px rgba(15, 23, 42, .14);
}
.dojo-student-tile.selected::before {
  content: "✓";
  position: absolute;
  left: 8px;
  top: 8px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #16a34a;
  border: 2px solid #fff;
  font-size: .86rem;
  font-weight: 900;
  z-index: 4;
  box-shadow: 0 1px 5px rgba(0,0,0,.22);
}
.dojo-student-tile.gift-ready {
  background: #fffaf0;
  border-color: #f4b942;
}

/* Hình PNG toàn thân chiếm phần lớn chiều cao của ô, không có khung ảnh riêng */
.dojo-avatar-hit {
  order: 1;
  width: 100%;
  height: 305px;
  min-height: 305px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
  cursor: pointer;
}
.dojo-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center bottom;
  margin: 0;
  padding: 0;
  border: 0 !important;
  outline: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.dojo-avatar-fallback {
  width: 118px;
  height: 118px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 70px;
  border-radius: 50%;
  color: #4b3b66;
  background: #eef4ff;
  font-size: 2.5rem;
}
.dojo-student-name {
  order: 2;
  width: 100%;
  min-height: 2.45em;
  color: #161616;
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 850;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-wrap: anywhere;
}
.dojo-points {
  position: absolute;
  top: 10px;
  right: 9px;
  width: 43px;
  height: 43px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(180deg, #8ee51b 0%, #49ae05 100%);
  border: 3px solid #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.27), inset 0 1px 2px rgba(255,255,255,.55);
  font-size: 1.05rem;
  line-height: 1;
  font-weight: 900;
  z-index: 3;
}
.dojo-points.negative {
  background: linear-gradient(180deg, #ff766c, #d42929);
}
.dojo-gift-badge {
  position: absolute;
  right: 12px;
  bottom: 10px;
  font-size: 1.2rem;
  line-height: 1;
}

/* Popup lịch sử và thư viện ảnh */
.bonus-modal-avatar {
  width: 124px;
  height: 124px;
  flex: 0 0 124px;
  display: block;
  object-fit: contain;
  object-position: center bottom;
  border: 0;
  outline: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.bonus-avatar-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #eef4ff;
  font-size: 2rem;
}
.avatar-choice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-height: 190px;
  overflow: auto;
  padding: 4px;
}
.avatar-choice-grid-modal {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  max-height: 300px;
}
.avatar-choice {
  position: relative;
  margin: 0;
  cursor: pointer;
}
.avatar-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.avatar-choice img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
}
.avatar-choice input:checked + img {
  border-color: var(--bms-accent);
  box-shadow: 0 0 0 3px rgba(242,183,5,.22);
}
.avatar-lib-tile {
  padding: 6px;
  border: 1px solid var(--bms-border);
  border-radius: 12px;
  background: #fff;
}
.avatar-lib-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border: 0;
  background: transparent;
}

@media (max-width: 1199.98px) {
  .dojo-grid { grid-template-columns: repeat(4, minmax(145px, 1fr)); gap: 18px 14px; }
  .dojo-student-tile { height: 360px; min-height: 360px; }
  .dojo-avatar-hit { height: 272px; min-height: 272px; }
}
@media (max-width: 767.98px) {
  .dojo-grid { grid-template-columns: repeat(3, minmax(125px, 1fr)); gap: 14px 10px; }
  .dojo-student-tile { height: 325px; min-height: 325px; padding: 10px 8px 13px; }
  .dojo-avatar-hit { height: 242px; min-height: 242px; }
  .dojo-student-name { font-size: .94rem; }
  .dojo-points { width: 39px; height: 39px; font-size: .98rem; }
}
@media (max-width: 575.98px) {
  .dojo-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 13px 10px; }
  .dojo-student-tile { height: 310px; min-height: 310px; }
  .dojo-avatar-hit { height: 228px; min-height: 228px; }
  .dojo-student-name { font-size: .95rem; }
  .avatar-choice-grid-modal { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}


/* V3.32: Thư viện dùng chung + Ấp trứng + trạng thái chọn rõ hơn */
.dojo-student-tile.selected {
  background: linear-gradient(180deg, #d9e8ff 0%, #b9d2f5 100%);
  border-color: #0b4f8a;
  box-shadow: 0 0 0 4px rgba(11,79,138,.30), 0 8px 22px rgba(11,47,84,.20);
  transform: translateY(-2px);
}
.dojo-student-tile.selected .dojo-student-name {
  color: #082f57;
  font-weight: 900;
}
.dojo-student-tile.selected::before {
  width: 32px;
  height: 32px;
  background: #0b4f8a;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.avatar-lib-egg {
  background: #fffaf0;
  border-color: #f1c76d;
}
.avatar-lib-egg img {
  background: linear-gradient(180deg, #fffdf6, #fff7dc);
}

/* V3.33: Thu nhỏ thẻ còn khoảng 75%, giữ tỷ lệ dọc; trạng thái chọn sẫm rõ hơn */
.dojo-grid {
  grid-template-columns: repeat(8, minmax(112px, 1fr));
  gap: 16px 12px;
}
.dojo-student-tile {
  height: 296px;
  min-height: 296px;
  padding: 9px 8px 12px;
  gap: 6px;
}
.dojo-avatar-hit {
  height: 228px;
  min-height: 228px;
}
.dojo-student-name {
  min-height: 2.35em;
  font-size: .92rem;
}
.dojo-points {
  top: 8px;
  right: 7px;
  width: 38px;
  height: 38px;
  font-size: .96rem;
}
.dojo-student-tile.selected {
  background: linear-gradient(180deg, #164f86 0%, #0a2f55 100%);
  border-color: #061d35;
  box-shadow: 0 0 0 4px rgba(5,35,64,.38), 0 10px 24px rgba(5,35,64,.28);
}
.dojo-student-tile.selected .dojo-student-name {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.32);
}
.dojo-student-tile.selected::before {
  background: #ffd447;
  color: #082f57;
  border-color: #fff;
}
.avatar-lib-hatching {
  background: #f4fbff;
  border-color: #79b9dd;
}
.avatar-lib-hatching img {
  background: linear-gradient(180deg, #f8fdff, #e7f6ff);
}

@media (max-width: 1399.98px) {
  .dojo-grid { grid-template-columns: repeat(7, minmax(112px, 1fr)); }
}
@media (max-width: 1199.98px) {
  .dojo-grid { grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 15px 11px; }
  .dojo-student-tile { height: 286px; min-height: 286px; }
  .dojo-avatar-hit { height: 218px; min-height: 218px; }
}
@media (max-width: 767.98px) {
  .dojo-grid { grid-template-columns: repeat(3, minmax(115px, 1fr)); gap: 13px 9px; }
  .dojo-student-tile { height: 276px; min-height: 276px; padding: 8px 7px 11px; }
  .dojo-avatar-hit { height: 208px; min-height: 208px; }
}
@media (max-width: 575.98px) {
  .dojo-grid { grid-template-columns: repeat(2, minmax(128px, 1fr)); gap: 12px 9px; }
  .dojo-student-tile { height: 286px; min-height: 286px; }
  .dojo-avatar-hit { height: 216px; min-height: 216px; }
}
