/* ===== Tab "Theo dõi học tập" — Sổ theo dõi học tập (lớp, học sinh, bài kiểm tra,
   nộp bài, nhận xét, so sánh, báo cáo). Dùng chung token/thành phần của style.css
   (--primary, --border, .card, .btn, .field...), chỉ bổ sung những gì chưa có sẵn.
   Tên lớp CSS khớp đúng với mã HTML do js/tracking.js sinh ra (tiền tố tk-). ===== */

#panel-tracking { padding: 0; }
.tk-shell { display: flex; flex-direction: column; }
.tk-view { margin-top: 4px; }
.tk-muted { color: var(--text-muted); }

/* ----- Thanh chọn lớp / học kỳ (sticky) ----- */
.tk-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  gap: 10px 22px;
  flex-wrap: wrap;
  align-items: center;
}
.tk-seg-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tk-seg-group + .tk-seg-group {
  padding-left: 22px;
  border-left: 1px solid var(--border);
}
.tk-seg-lbl {
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  white-space: nowrap;
}
.tk-seg { display: flex; gap: 4px; flex-wrap: wrap; background: var(--surface-0); padding: 3px; border-radius: 99px; }
.tk-seg button {
  border: 1px solid transparent;
  background: none;
  padding: 5px 13px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background .15s ease, color .15s ease;
}
.tk-seg button:hover:not(.active) { color: var(--text-primary); }
.tk-seg button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.tk-role-badge {
  font-size: 11.5px;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--bg-accent);
  color: var(--text-accent);
  border: 1px solid var(--border);
  font-weight: 700;
  margin-left: auto;
}

/* ----- Tab strip con (Tổng quan / Học sinh / Bài kiểm tra / ...) ----- */
.tk-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  margin: 10px 0 18px;
  border-bottom: 1px solid var(--border);
}
.tk-tabs button {
  border: 0;
  background: none;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  border-radius: 0;
}
.tk-tabs button.active {
  color: var(--primary);
  border-bottom-color: var(--accent-yellow);
  background: none;
}

/* ----- Layout chung ----- */
.tk-panels {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 900px) { .tk-panels { grid-template-columns: 1fr; } }

.tk-split {
  display: grid;
  grid-template-columns: 300px minmax(0,1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 860px) { .tk-split { grid-template-columns: minmax(0,1fr); } }

.tk-sub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 0 24px;
}
@media (max-width: 700px) { .tk-sub-grid { grid-template-columns: 1fr; } }

.tk-dash-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.tk-dash-header h2 { font-size: 1.3rem; margin: 0 0 4px 0; color: var(--text-primary); }
.tk-dash-header .tk-sub { color: var(--text-muted); font-size: 13px; }
.tk-sub-label { color: var(--text-muted); font-size: 0.85em; font-weight: 500; }

/* Hàng nút hành động (Xuất ảnh/Xuất Excel/Sửa/Xóa...): giữ tất cả trên 1 dòng
   khi đủ chỗ, chỉ xuống dòng khi màn hình thực sự quá hẹp — khác .row dùng
   grid 3 cột cố định nên luôn đẩy nút thứ 4 xuống dòng dù còn chỗ trống. */
.tk-btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ----- Thẻ số liệu (tkTile) ----- */
.tk-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 14px 0;
}
@media (max-width: 700px) { .tk-stat-grid { grid-template-columns: repeat(2, 1fr); } }
.tk-stat-card {
  background: var(--bg-accent);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.tk-stat-card .num { font-size: 1.6rem; font-weight: 800; color: var(--primary); line-height: 1; font-variant-numeric: tabular-nums; }
.tk-stat-card .num.tk-up { color: var(--text-success); }
.tk-stat-card .num.tk-down { color: var(--text-danger); }
.tk-stat-card .lbl { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }

.tk-chartbox { position: relative; height: 260px; }

/* ----- Danh sách chọn (lớp/bài/học sinh) ----- */
.tk-list {
  display: flex;
  flex-direction: column;
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.tk-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: #fff;
  padding: 8px 11px;
  border-radius: 0;
  font-weight: 500;
  width: 100%;
}
.tk-list .tk-item:last-child { border-bottom: 0; }
.tk-item.active {
  background: var(--bg-accent);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--primary);
}
.tk-item-name { font-weight: 700; font-size: 13.5px; }
.tk-item-meta { color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 11.5px; }

.tk-check-list { padding: 4px; }
.tk-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
}
.tk-check-list .tk-check-item:last-child { border-bottom: 0; }

/* ----- Bảng dữ liệu chung ----- */
.tk-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tk-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .03em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
}
.tk-table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tk-table td.n, .tk-table th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tk-table tfoot td { border-bottom: none; padding-top: 12px; font-weight: 700; }
.tk-scroll { overflow-x: auto; }

/* ----- Form nhập điểm / tạo bài ----- */
.tk-new-exam-form { max-width: 460px; margin-bottom: 14px; }
.tk-score-in { width: 86px; text-align: right; }
.tk-footnote { font-size: 12px; margin-top: 8px; }
.tk-up { color: var(--text-success); }
.tk-down { color: var(--text-danger); }

/* ----- Nhãn xếp loại (band pill) ----- */
.tk-pill {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
}
.tk-pill.gioi { background: #0f6759; }
.tk-pill.kha  { background: #30a450; }
.tk-pill.tb   { background: #c79a2b; color: #2a2000; }
.tk-pill.yeu  { background: #c4763b; }
.tk-pill.kem  { background: #b5473c; }
.tk-band-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }

/* ----- Trạng thái nộp bài ----- */
.tk-status {
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 3px 13px;
  font-size: 12px;
  font-weight: 700;
  background: #fff;
  color: var(--text-primary);
}
.tk-status-done { background: var(--bg-success); border-color: var(--border-success); color: var(--text-success); }
.tk-status-late { background: var(--bg-warning); border-color: var(--border-warning); color: var(--text-warning); }
.tk-status-miss { color: var(--text-muted); }
.tk-sub-row { justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border); }
.tk-sub-row:last-child { border-bottom: 0; }

.tk-progress { height: 10px; background: var(--bg-accent); border-radius: 99px; overflow: hidden; display: flex; }
.tk-progress i { display: block; height: 100%; }
.tk-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.tk-legend span { display: inline-flex; align-items: center; gap: 5px; }
.tk-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }

/* ----- Nhận xét / ghi chú học sinh ----- */
.tk-comment { border-left: 3px solid var(--accent-yellow); padding: 4px 0 4px 10px; margin-bottom: 10px; font-size: 13.5px; }
.tk-comment-private { border-left-color: var(--border-danger); }
.tk-comment-date { font-size: 11.5px; color: var(--text-muted); }

/* ----- Trạng thái trống ----- */
.tk-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 20px;
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 26px 26px;
  border-radius: 16px;
  min-height: 55vh;
  justify-content: center;
}
.tk-empty h2 { margin: 0 0 8px 0; color: var(--text-primary); font-size: 1.3rem; }
.tk-empty p { color: var(--text-muted); max-width: 460px; line-height: 1.6; margin-bottom: 20px; }
.tk-empty-inline { padding: 30px 16px; text-align: center; color: var(--text-muted); border: 1px dashed var(--border); border-radius: 10px; }

/* ----- Báo cáo (xem trước + xuất ảnh A4, dựng ngoài màn hình rồi chụp bằng html2canvas) ----- */
.tk-prevwrap {
  overflow: hidden;
  background: var(--surface-0);
  border-radius: 10px;
  padding: 16px;
  height: 500px;
  width: 334px;
  margin: 0 auto;
  position: relative;
}
/* Phiếu A4 gốc rộng 794px — JS (tkReportsView) đặt transform:scale() trực tiếp lên
   phần tử con để thu nhỏ vừa khung xem trước; origin top-left để không bị lệch. */
.tk-prevwrap > div { transform-origin: top left; }
.tk-report {
  width: 794px;
  min-height: 1123px;
  box-sizing: border-box;
  background: #FFFDF7;
  color: #22281F;
  padding: 56px 60px;
  font-family: 'Inter', -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  transform: scale(0.42);
  transform-origin: top left;
  position: absolute;
  top: 16px;
  left: 16px;
}
.tk-report .rt-head { display: flex; align-items: center; gap: 16px; border-bottom: 2px solid var(--primary); padding-bottom: 18px; margin-bottom: 24px; }
.tk-report .rt-logo { width: 56px; height: 56px; object-fit: contain; }
.tk-report .rt-school { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary); }
.tk-report .rt-teacher { font-size: 0.8rem; color: #5B6255; margin-top: 2px; }
.tk-report h1 { font-size: 1.5rem; font-weight: 800; margin: 20px 0 2px 0; }
.tk-report .rt-meta { font-size: 0.85rem; color: #5B6255; margin-bottom: 22px; }
.tk-report .rt-stats { display: flex; gap: 14px; margin-bottom: 26px; }
.tk-report .rt-stat { flex: 1; background: #F7F4EC; border: 1px solid #DCD6C4; border-radius: 10px; padding: 14px 16px; }
.tk-report .rt-stat .n { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.tk-report .rt-stat .l { font-size: 0.7rem; color: #5B6255; margin-top: 4px; }
.tk-report table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tk-report th { text-align: left; font-size: 0.72rem; font-weight: 700; color: #5B6255; padding: 7px 8px; border-bottom: 1px solid #DCD6C4; }
.tk-report td { padding: 7px 8px; border-bottom: 1px solid #DCD6C4; }