/* ==========================================================================
   HỆ THỐNG QUẢN LÝ NỘP BÀI VÀ ĐIỂM HỌC SINH - CÔ LINH
   Giao diện thân thiện, hiện đại, tối ưu cho Mobile, iPad và A4 Print
   ========================================================================== */

:root {
  --primary: #4F46E5;
  --primary-light: #EEF2FF;
  --primary-hover: #4338CA;
  --accent: #06B6D4;
  --bg-main: #F8FAFC;
  --card-bg: #FFFFFF;
  --text-main: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;

  /* Bảng màu theo yêu cầu Mục 10 */
  --status-green: #10B981;    /* Đã hoàn thành */
  --status-green-bg: #ECFDF5;
  --status-yellow: #F59E0B;   /* Cần sửa */
  --status-yellow-bg: #FFFBEB;
  --status-orange: #F97316;   /* Nộp trễ */
  --status-orange-bg: #FFF7ED;
  --status-red: #EF4444;      /* Chưa nộp */
  --status-red-bg: #FEF2F2;
  --status-blue: #3B82F6;     /* Đã nộp lại / Đã nộp đúng hạn */
  --status-blue-bg: #EFF6FF;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* Header & Navigation */
header.app-header {
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #6366F1, #4F46E5);
  color: #FFF;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.brand-info h1 {
  font-size: 17px;
  font-weight: 700;
  color: #0F172A;
  line-height: 1.2;
}

.brand-info p {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Navigation Tabs */
nav.app-nav {
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.nav-tabs {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  padding: 0 16px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.nav-tab:hover {
  color: var(--primary);
  background-color: #F8FAFC;
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.nav-tab.highlight {
  color: #D97706;
}

.nav-tab.highlight.active {
  color: #B45309;
  border-bottom-color: #D97706;
}

/* Main Content Area */
main.app-main {
  max-width: 1200px;
  margin: 20px auto 60px;
  padding: 0 16px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Common Card */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: #1E293B;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #FFF;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: #F1F5F9;
}

.btn-success {
  background: var(--status-green);
  color: #FFF;
}

.btn-success:hover {
  background: #059669;
}

.btn-warning {
  background: var(--status-yellow);
  color: #FFF;
}

.btn-danger {
  background: var(--status-red);
  color: #FFF;
}

.btn-kiosk {
  background: linear-gradient(135deg, #10B981, #059669);
  color: white;
  padding: 14px 28px;
  font-size: 17px;
  border-radius: 14px;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
  font-weight: 700;
}

.btn-kiosk:hover {
  transform: scale(1.02);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 16px;
  border-radius: 12px;
}

/* Form Controls */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #FFF;
  font-size: 14px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-green {
  background-color: var(--status-green-bg);
  color: #065F46;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-yellow {
  background-color: var(--status-yellow-bg);
  color: #92400E;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-orange {
  background-color: var(--status-orange-bg);
  color: #9A3412;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.badge-red {
  background-color: var(--status-red-bg);
  color: #991B1B;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-blue {
  background-color: var(--status-blue-bg);
  color: #1E40AF;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ==========================================================================
   KIOSK MODE: GÓC NỘP BÀI HỌC SINH
   ========================================================================== */
.kiosk-container {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

.kiosk-header {
  margin-bottom: 24px;
}

.kiosk-badge {
  display: inline-block;
  background: #EEF2FF;
  color: #4F46E5;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.kiosk-title {
  font-size: 26px;
  font-weight: 800;
  color: #0F172A;
  margin-bottom: 6px;
}

.kiosk-subtitle {
  color: var(--text-muted);
  font-size: 15px;
}

.kiosk-card {
  background: #FFF;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  border: 2px solid #E0E7FF;
}

.kiosk-assignment-selector {
  margin-bottom: 20px;
  text-align: left;
}

.camera-box {
  position: relative;
  width: 100%;
  max-width: 460px;
  aspect-ratio: 4/3;
  margin: 0 auto 16px;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Scanning Overlay Frame */
.scan-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
}

.scan-reticle::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #10B981;
  box-shadow: 0 0 10px #10B981, 0 0 20px #10B981;
  animation: scanLaser 2s infinite ease-in-out;
}

.scan-reticle.reticle-success {
  border-color: #10B981 !important;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45), 0 0 35px #10B981 !important;
  transform: translate(-50%, -50%) scale(1.04);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scanLaser {
  0% { top: 0; opacity: 0.8; }
  50% { top: 100%; opacity: 1; }
  100% { top: 0; opacity: 0.8; }
}

.scan-hint {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  color: #FFF;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

/* Quick Student Fallback Picker */
.quick-picker-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  margin-top: 8px;
}

.quick-student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 12px;
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
  background: #F8FAFC;
  border-radius: 12px;
  border: 1px dashed var(--border);
}

.quick-student-btn {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFF;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s;
}

.quick-student-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Celebration Popup for Student Submit */
.celebrate-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.celebrate-card {
  background: #FFF;
  width: 100%;
  max-width: 440px;
  border-radius: 24px;
  padding: 30px 24px;
  text-align: center;
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.25);
  position: relative;
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.celebrate-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  margin: 0 auto 16px;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
  animation: bounce 1s infinite alternate ease-in-out;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.celebrate-name {
  font-size: 22px;
  font-weight: 800;
  color: #0F172A;
  margin-bottom: 6px;
}

.celebrate-detail {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.celebrate-badges {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ==========================================================================
   BẢNG THEO DÕI NHANH (MỤC 6)
   ========================================================================== */
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #FFF;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-pill.active {
  background: var(--primary);
  color: #FFF;
  border-color: var(--primary);
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.data-table th {
  background: #F1F5F9;
  color: #475569;
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:hover td {
  background-color: #F8FAFC;
}

/* Score Badges */
.score-pill {
  display: inline-block;
  padding: 3px 8px;
  font-weight: 700;
  border-radius: 6px;
  font-size: 13px;
}

.score-high {
  background: #ECFDF5;
  color: #047857;
}

.score-med {
  background: #FFFBEB;
  color: #B45309;
}

.score-low {
  background: #FEF2F2;
  color: #B91C1C;
}

/* ==========================================================================
   CHẾ ĐỘ CHẤM BÀI NHANH CHO CÔ LINH (MỤC 4 & 5)
   ========================================================================== */
.grading-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .grading-grid {
    grid-template-columns: 1fr;
  }
}

.grade-btn-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.grade-status-option {
  padding: 12px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #FFF;
  cursor: pointer;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.15s;
}

.grade-status-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.quick-scores {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.score-chip {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #F8FAFC;
  font-weight: 700;
  cursor: pointer;
}

.score-chip:hover, .score-chip.active {
  background: var(--primary);
  color: #FFF;
  border-color: var(--primary);
}

.quick-notes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.note-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 14px;
  background: #F1F5F9;
  border: 1px solid var(--border);
  cursor: pointer;
}

.note-chip:hover {
  background: #E2E8F0;
}

/* Timeline History */
.timeline {
  position: relative;
  padding-left: 24px;
  margin-top: 14px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 16px;
}

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid #FFF;
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-content {
  background: #F8FAFC;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
}

.timeline-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ==========================================================================
   THỐNG KÊ 3 CHIỀU (MỤC 7)
   ========================================================================== */
.stats-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #FFF;
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.stat-card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.stat-card-value {
  font-size: 28px;
  font-weight: 800;
  color: #0F172A;
}

.stat-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.highlight-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.highlight-card {
  background: #FFF;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
}

.highlight-card h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.highlight-list {
  list-style: none;
  font-size: 13px;
}

.highlight-list li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
}

/* ==========================================================================
   TRANG IN THẺ QR MINI KHỔ A4 (MỤC 1 & YÊU CẦU 4)
   ========================================================================== */
.a4-print-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  background: #FFF;
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.a4-sheet {
  background: #FFF;
  width: 100%;
  max-width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 10mm;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border);
}

.qr-grid-a4 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6mm;
}

.qr-card-mini {
  border: 1px dashed #94A3B8;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FFF;
  page-break-inside: avoid;
}

.qr-card-mini .qr-canvas-box {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFF;
}

.qr-card-mini .qr-canvas-box svg,
.qr-card-mini .qr-canvas-box img,
.qr-card-mini .qr-canvas-box canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  object-fit: contain;
}

.qr-card-mini .qr-info {
  flex-grow: 1;
  overflow: hidden;
}

.qr-card-mini .qr-class {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
}

.qr-card-mini .qr-name {
  font-size: 13px;
  font-weight: 800;
  color: #0F172A;
  line-height: 1.2;
  margin: 2px 0;
  white-space: normal;
}

.qr-card-mini .qr-code-label {
  font-size: 11px;
  font-weight: 700;
  color: #64748B;
  background: #F1F5F9;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}

/* ==========================================================================
   PRINT MEDIA QUERY (CHO IN A4)
   ========================================================================== */
@media print {
  body {
    background: #FFF !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  header.app-header,
  nav.app-nav,
  .a4-print-toolbar,
  .no-print {
    display: none !important;
  }

  main.app-main {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .tab-pane {
    display: none !important;
  }

  #pane-print {
    display: block !important;
  }

  .a4-sheet {
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    padding: 5mm !important;
    margin: 0 !important;
  }

  .qr-grid-a4 {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 4mm !important;
  }

  .qr-card-mini {
    border: 1px dashed #000 !important;
  }
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal-card {
  background: #FFF;
  border-radius: var(--radius);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

/* ==========================================================================
   LOGIN SCREEN & ROLE TABS
   ========================================================================== */
.login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #EEF2FF 0%, #F8FAFC 50%, #E0E7FF 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-wrapper {
  width: 100%;
  max-width: 580px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-brand-header {
  text-align: center;
}

.login-logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), #3730A3);
  color: #FFF;
  font-size: 32px;
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.25);
  margin-bottom: 12px;
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  color: #0F172A;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.login-card {
  background: #FFFFFF;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border);
}

.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #F1F5F9;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 24px;
  gap: 4px;
}

.login-tab {
  background: transparent;
  border: none;
  padding: 12px 14px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.login-tab:hover {
  color: var(--text-main);
}

.login-tab.active {
  background: #FFFFFF;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.login-pane-header {
  text-align: center;
  margin-bottom: 20px;
}

.login-role-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366F1, #4F46E5);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.student-avatar-gradient {
  background: linear-gradient(135deg, #10B981, #059669) !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2) !important;
}

.login-pane-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.login-pane-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrap .pin-field {
  padding-right: 44px;
  font-size: 18px;
  letter-spacing: 2px;
  font-weight: 600;
}

.btn-toggle-pin {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-error-msg {
  color: var(--status-red);
  font-size: 13px;
  font-weight: 600;
  margin-top: 6px;
  background: var(--status-red-bg);
  padding: 6px 12px;
  border-radius: 8px;
  border-left: 3px solid var(--status-red);
}

.login-tip {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  background: var(--bg-main);
  padding: 8px 12px;
  border-radius: 8px;
}

.btn-qr-login {
  background: linear-gradient(135deg, #10B981, #059669);
  color: white;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.btn-qr-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px dashed #CBD5E1;
}

.login-divider span {
  padding: 0 10px;
}

.login-student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
}

.login-student-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.login-student-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.student-chip-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #E2E8F0;
  color: #334155;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.login-student-chip:hover .student-chip-order {
  background: var(--primary);
  color: white;
}

/* Kiosk Shortcut Card */
.kiosk-shortcut-card {
  background: linear-gradient(135deg, #4338CA, #312E81);
  color: white;
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 8px 20px rgba(49, 46, 129, 0.25);
}

.kiosk-shortcut-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kiosk-shortcut-icon {
  font-size: 28px;
  background: rgba(255, 255, 255, 0.15);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kiosk-shortcut-info h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.kiosk-shortcut-info p {
  font-size: 12px;
  color: #CBD5E1;
  line-height: 1.3;
}

.login-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.teacher-user-pill {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 5px 12px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* ==========================================================================
   STUDENT PORTAL
   ========================================================================== */
.student-portal-screen {
  min-height: 100vh;
  background: var(--bg-main);
}

.student-header {
  border-bottom: 2px solid #10B981 !important;
}

.student-portal-main {
  padding: 24px 20px;
}

.student-portal-container {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.student-hero-card {
  background: white;
  border-radius: var(--radius);
  padding: 22px 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.student-hero-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.student-avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, #10B981, #059669);
  color: white;
  font-size: 28px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
  flex-shrink: 0;
}

.student-role-badge {
  font-size: 11px;
  font-weight: 700;
  color: #059669;
  background: #ECFDF5;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 4px;
}

.student-hero-details h2 {
  font-size: 22px;
  font-weight: 800;
  color: #0F172A;
  margin-bottom: 4px;
}

.student-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.student-card-qr-box {
  width: 80px;
  height: 80px;
  background: white;
  padding: 4px;
  border-radius: 10px;
  border: 1px dashed #CBD5E1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.student-card-qr-box svg,
.student-card-qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.student-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.sp-stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.sp-stat-icon {
  font-size: 22px;
  margin-bottom: 6px;
}

.sp-stat-num {
  font-size: 26px;
  font-weight: 800;
  color: #0F172A;
  line-height: 1.1;
  margin-bottom: 4px;
}

.sp-stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* Quick Self-Submit Banner */
.student-submit-banner {
  background: linear-gradient(135deg, #EEF2FF, #E0E7FF);
  border: 1px solid #C7D2FE;
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.submit-banner-badge {
  font-size: 11px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.5px;
}

.submit-banner-info h3 {
  font-size: 16px;
  font-weight: 700;
  color: #1E1B4B;
  margin: 2px 0 4px 0;
}

.submit-banner-info p {
  font-size: 13px;
  color: #4338CA;
}

.submit-banner-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.teacher-note-pill {
  background: #FFFBEB;
  border-left: 3px solid #F59E0B;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #92400E;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .student-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .kiosk-shortcut-card {
    flex-direction: column;
    text-align: center;
  }
  .kiosk-shortcut-info {
    flex-direction: column;
  }
  .student-hero-card {
    flex-direction: column;
    text-align: center;
  }
  .student-hero-left {
    flex-direction: column;
  }
  .student-hero-meta {
    justify-content: center;
  }
}


/* =====================================================================
   LIBRARY & READING RACE STYLES ("3A7 – HÀNH TRÌNH ĐỌC SÁCH")
   Modeled after duong-dua-doc-sach-3a7 reference site
   ===================================================================== */

.lib-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 0 40px;
}

/* Hero Header */
.lib-hero-header {
  background: white;
  border: 1px solid #d1fae5;
  border-radius: 24px;
  padding: 20px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  gap: 16px;
  flex-wrap: wrap;
}

.lib-hero-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lib-hero-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 32px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  flex-shrink: 0;
}

.lib-hero-titles h2 {
  font-size: 24px;
  font-weight: 900;
  color: #17352a;
  letter-spacing: -0.5px;
  margin: 0;
  line-height: 1.2;
}

.lib-hero-titles p {
  font-size: 13px;
  font-weight: 800;
  color: #059669;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 4px 0 0;
}

.lib-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 4 Metric Stats Cards */
.lib-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.lib-stat-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 22px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.lib-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.lib-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: white;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.lib-stat-icon.emerald { background: #059669; }
.lib-stat-icon.sky { background: #0284c7; }
.lib-stat-icon.violet { background: #7c3aed; }
.lib-stat-icon.rose { background: #e11d48; }

.lib-stat-val {
  font-size: 28px;
  font-weight: 900;
  color: #0f172a;
  line-height: 1;
  margin-bottom: 4px;
}

.lib-stat-label {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
}

/* 3D Library Navigation Sub-Tabs */
.lib-tabs-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.nav-tab-3d {
  background: white;
  border: 2px solid #e2e8f0;
  color: #475569;
  border-radius: 18px;
  padding: 14px 10px;
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.nav-tab-3d:hover {
  border-color: #10b981;
  color: #059669;
  transform: translateY(-1px);
}

.nav-tab-3d.active {
  background: #059669;
  border-color: #047857;
  color: white;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
  transform: translateY(-2px);
}

.nav-tab-3d.nav-tab-borrow.active { background: #0284c7; border-color: #0369a1; box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35); }
.nav-tab-3d.nav-tab-return.active { background: #d97706; border-color: #b45309; box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35); }
.nav-tab-3d.nav-tab-library.active { background: #7c3aed; border-color: #6d28d9; box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35); }
.nav-tab-3d.nav-tab-stats.active { background: #0d9488; border-color: #0f766e; box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35); }

/* Library Sub Panes */
.lib-sub-pane {
  display: none;
}
.lib-sub-pane.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

/* SECTION 1: READING RACE TRACK */
.race-section-card {
  background: white;
  border-radius: 24px;
  border: 1px solid #d1fae5;
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
}

.race-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.race-badge {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #d97706;
  margin-bottom: 4px;
  display: block;
}

.race-title {
  font-size: 26px;
  font-weight: 900;
  color: #17352a;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.race-subtitle {
  font-size: 13px;
  color: #64748b;
  margin: 4px 0 0;
}

/* Milestone Summary Banner */
.race-milestones-summary-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.ms-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.ms-pill-t12 {
  background: #f0f9ff;
  border-color: #bae6fd;
}

.ms-pill-t4 {
  background: #fefce8;
  border-color: #fef08a;
}

.ms-pill-avg {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.ms-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}

.ms-body {
  min-width: 0;
}

.ms-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 2px;
}

.ms-val {
  font-size: 15px;
  font-weight: 900;
  color: #0f172a;
  white-space: nowrap;
}

/* Race Toolbar (Search & Filter Pills) */
.race-toolbar-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.race-filter-pills-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.race-filter-pills-row::-webkit-scrollbar {
  display: none;
}

.race-filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 800;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.race-filter-pill.active {
  background: #059669;
  color: #ffffff;
  border-color: #059669;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}

.race-filter-pill:hover:not(.active) {
  background: #f1f5f9;
  border-color: #94a3b8;
}

/* Desktop defaults for mobile-adaptive elements */
.race-track-bar-container {
  position: relative;
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
}

.race-track-milestones-mobile {
  display: none;
}

.race-rank-mobile {
  display: none;
}

.race-progress-unit {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}

.race-reader-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.race-board-wrapper {
  overflow-x: auto;
  border-radius: 18px;
  border: 1px solid #a7f3d0;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.race-board-table {
  min-width: 980px;
}

.race-grid-row {
  display: grid;
  grid-template-columns: 56px 200px 1fr 100px 220px;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
}

.race-header-row {
  background: #17352a;
  color: white;
  font-size: 13px;
  font-weight: 700;
  padding: 14px 18px;
}

/* Track Header with Milestones */
.race-track-header {
  position: relative;
  height: 48px;
  font-size: 11px;
  color: #a7f3d0;
}

.race-track-header-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 20px;
  font-weight: 900;
  color: white;
}

.race-track-header-bot {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20px;
}

/* Student Row Styles */
.race-student-row {
  border-top: 1px solid #e2e8f0;
  transition: background 0.15s ease;
}

.race-student-row:hover {
  background: #f8fafc;
}

.race-student-row.rank-1 {
  background: linear-gradient(90deg, #fef3c7, #fffbeb, #fef3c7);
  border-color: #fde68a;
}
.race-student-row.rank-2 {
  background: linear-gradient(90deg, #f1f5f9, #ffffff, #f1f5f9);
  border-color: #e2e8f0;
}
.race-student-row.rank-3 {
  background: linear-gradient(90deg, #ffedd5, #fff7ed, #ffedd5);
  border-color: #fed7aa;
}

/* Rank Medals & Numbers */
.rank-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 15px;
  background: #ecfdf5;
  color: #065f46;
}

.rank-medal-icon {
  font-size: 26px;
  display: inline-block;
  line-height: 1;
}

/* Reader Info */
.race-reader-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.race-pet-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #a7f3d0;
  background: white;
  font-size: 22px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.15s;
}

.race-pet-avatar:hover {
  transform: scale(1.1);
  border-color: #059669;
}

.race-reader-names {
  min-width: 0;
}

.race-reader-name {
  font-weight: 800;
  font-size: 14px;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.race-reader-code {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
}

/* Progress Track Bar */
.race-track-cell {
  position: relative;
  height: 42px;
  display: flex;
  align-items: center;
}

.race-track-bg {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 10px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}

.race-track-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, #34d399, #059669);
  transition: width 0.4s ease;
}

/* Milestone pins on the track */
.milestone-pin-11 {
  position: absolute;
  left: 33.33%;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 18px;
  background: rgba(255,255,255,0.9);
  z-index: 2;
}

.milestone-pin-15 {
  position: absolute;
  left: 45.45%;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: #38bdf8;
  border-radius: 4px;
  z-index: 2;
}

.milestone-pin-22 {
  position: absolute;
  left: 66.66%;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 18px;
  background: rgba(255,255,255,0.9);
  z-index: 2;
}

.race-runner-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: white;
  border: 2px solid #059669;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: grid;
  place-items: center;
  font-size: 16px;
  z-index: 3;
  transition: left 0.4s ease;
}

/* Progress text */
.race-progress-text {
  text-align: right;
  font-size: 15px;
  font-weight: 900;
  color: #065f46;
}

.race-progress-sub {
  font-size: 11px;
  font-weight: 700;
  color: #d97706;
  margin-top: 2px;
}

/* Teacher Controls */
.race-controls-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.btn-race-step {
  height: 36px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-race-step.inc {
  background: #059669;
  color: white;
}
.btn-race-step.inc:hover {
  background: #047857;
  transform: scale(1.04);
}

.btn-race-step.dec {
  background: white;
  border-color: #cbd5e1;
  color: #475569;
}
.btn-race-step.dec:hover {
  background: #f1f5f9;
  color: #e11d48;
}

.btn-race-step:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}

/* SECTION 2: BORROW BOOK WORKFLOW */
.borrow-grid-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
}

.borrow-step-card {
  background: white;
  border-radius: 24px;
  border: 1px solid #e2e8f0;
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
}

.borrow-step-badge {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
  display: block;
}

.borrow-step-badge.step1 { color: #059669; }
.borrow-step-badge.step2 { color: #0284c7; }

.borrow-selected-badge {
  margin-top: 12px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 800;
  color: #065f46;
  display: flex;
  align-items: center;
  gap: 8px;
}

.scan-aqua-btn {
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
  color: white;
  border: none;
  border-radius: 18px;
  font-weight: 900;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  width: 100%;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
  transition: all 0.2s ease;
}

.scan-aqua-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.45);
}

.scan-aqua-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* SECTION 3: RETURN BOOK WORKFLOW */
.return-hero-card {
  max-width: 680px;
  margin: 0 auto;
  background: white;
  border-radius: 28px;
  border: 1px solid #fed7aa;
  padding: 40px 32px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.return-circle-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #fef3c7;
  color: #d97706;
  display: grid;
  place-items: center;
  font-size: 36px;
  margin: 0 auto 20px;
}

/* SECTION 4: CATALOG OF 75 BOOKS */
.catalog-toolbar {
  background: white;
  border-radius: 22px;
  border: 1px solid #e2e8f0;
  padding: 18px 24px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.catalog-search-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.catalog-pills-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.cat-pill {
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  transition: all 0.15s;
}

.cat-pill:hover, .cat-pill.active {
  background: #059669;
  color: white;
  border-color: #047857;
}

/* Book Grid Cards */
.books-card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book-card-item {
  background: white;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.book-card-item:hover {
  border-color: #a7f3d0;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.book-stt-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: #ecfdf5;
  color: #065f46;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.book-stt-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1;
}

.book-stt-num {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.1;
}

.book-meta-main {
  flex: 1;
  min-width: 0;
}

.book-meta-title {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 4px;
}

.book-meta-author {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 4px;
}

.book-meta-contrib {
  font-size: 12px;
  color: #6d28d9;
  font-weight: 700;
}

.book-status-tag {
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.book-status-tag.available {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.book-status-tag.borrowed {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

/* Modals */
.lib-qr-modal-preview {
  text-align: center;
  padding: 20px;
}

.lib-qr-box {
  width: 200px;
  height: 200px;
  margin: 0 auto 16px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .borrow-grid-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  /* Sub-tabs bar: Smooth horizontal scrollable strip */
  .lib-tabs-bar {
    display: flex !important;
    overflow-x: auto !important;
    gap: 8px !important;
    padding-bottom: 6px !important;
    margin-bottom: 16px !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }
  .lib-tabs-bar::-webkit-scrollbar {
    display: none !important;
  }
  .nav-tab-3d {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    padding: 10px 16px !important;
    font-size: 13px !important;
    border-radius: 14px !important;
  }

  /* Overview Metrics 4 cards */
  .lib-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 16px !important;
  }
  .lib-stat-card {
    padding: 12px !important;
    border-radius: 14px !important;
  }
  .lib-stat-val {
    font-size: 22px !important;
  }
  .lib-stat-label {
    font-size: 11px !important;
  }

  /* Reading Race Mobile Card */
  .race-section-card {
    padding: 14px !important;
    border-radius: 20px !important;
  }

  .race-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    margin-bottom: 14px !important;
  }

  .race-title {
    font-size: 20px !important;
    line-height: 1.25 !important;
  }

  .race-subtitle {
    font-size: 12px !important;
  }

  .race-milestones-summary-card {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .ms-pill {
    padding: 10px 12px !important;
    gap: 8px !important;
  }

  .ms-pill-avg {
    grid-column: span 2 !important;
  }

  .ms-icon {
    font-size: 22px !important;
  }

  .ms-title {
    font-size: 9.5px !important;
  }

  .ms-val {
    font-size: 13px !important;
  }

  .race-board-wrapper {
    overflow-x: visible !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .race-board-table {
    min-width: 100% !important;
    width: 100% !important;
  }

  /* Hide Desktop Table Header on Mobile */
  .race-header-row {
    display: none !important;
  }

  /* Student Row becomes a Mobile Card */
  .race-student-row {
    display: grid !important;
    grid-template-columns: auto 1fr auto !important;
    grid-template-areas:
      "rank reader progress"
      "track track track"
      "controls controls controls" !important;
    row-gap: 8px !important;
    column-gap: 10px !important;
    padding: 12px 14px !important;
    margin-bottom: 12px !important;
    border-radius: 18px !important;
    border: 1.5px solid #e2e8f0 !important;
    background: #ffffff !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05) !important;
  }

  .race-student-row.rank-1 {
    border-color: #fde68a !important;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%) !important;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.15) !important;
  }

  .race-student-row.rank-2 {
    border-color: #cbd5e1 !important;
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%) !important;
  }

  .race-student-row.rank-3 {
    border-color: #fed7aa !important;
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%) !important;
  }

  .race-col-rank {
    grid-area: rank !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .rank-badge {
    width: 32px !important;
    height: 32px !important;
    font-size: 13px !important;
  }

  .rank-medal-icon {
    font-size: 26px !important;
  }

  .race-reader-info {
    grid-area: reader !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    min-width: 0 !important;
  }

  .race-pet-avatar {
    width: 38px !important;
    height: 38px !important;
    font-size: 20px !important;
  }

  .race-reader-names {
    min-width: 0 !important;
    flex: 1 !important;
  }

  .race-reader-name {
    font-size: 14px !important;
    font-weight: 800 !important;
    color: #0f172a !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2 !important;
  }

  .race-reader-code {
    font-size: 11px !important;
    font-weight: 700 !important;
    color: #64748b !important;
  }

  .race-rank-mobile {
    display: inline-block !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    color: #059669 !important;
    background: #ecfdf5 !important;
    padding: 1px 5px !important;
    border-radius: 4px !important;
  }

  .race-progress-text {
    grid-area: progress !important;
    text-align: right !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    justify-content: center !important;
  }

  .race-progress-main {
    font-size: 15px !important;
    font-weight: 900 !important;
    color: #065f46 !important;
    line-height: 1.1 !important;
  }

  .race-progress-unit {
    font-size: 11px !important;
    font-weight: 700 !important;
    color: #64748b !important;
  }

  .race-progress-sub {
    font-size: 11px !important;
    margin-top: 1px !important;
  }

  /* Track layout on mobile */
  .race-track-cell {
    grid-area: track !important;
    width: 100% !important;
    margin-top: 6px !important;
    margin-bottom: 4px !important;
    padding: 0 !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .race-track-milestones-mobile {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    height: 16px !important;
    font-size: 9.5px !important;
    font-weight: 800 !important;
    margin-bottom: 4px !important;
  }

  .rt-m {
    position: absolute !important;
    transform: translateX(-50%) !important;
    white-space: nowrap !important;
    line-height: 1 !important;
  }

  .rt-0 {
    left: 0% !important;
    transform: translateX(0%) !important;
    color: #94a3b8 !important;
  }

  .rt-11 {
    left: 33.33% !important;
    color: #64748b !important;
  }

  .rt-15 {
    left: 45.45% !important;
    color: #0284c7 !important;
    font-weight: 900 !important;
    background: #e0f2fe !important;
    padding: 1px 4px !important;
    border-radius: 4px !important;
  }

  .rt-22 {
    left: 66.66% !important;
    color: #64748b !important;
  }

  .rt-33 {
    left: 100% !important;
    transform: translateX(-100%) !important;
    color: #b45309 !important;
    font-weight: 900 !important;
    background: #fef3c7 !important;
    padding: 1px 4px !important;
    border-radius: 4px !important;
  }

  .race-track-bar-container {
    position: relative !important;
    width: 100% !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
  }

  .race-track-bg {
    height: 12px !important;
    border-radius: 12px !important;
  }

  .race-runner-marker {
    width: 32px !important;
    height: 32px !important;
    font-size: 18px !important;
  }

  /* Teacher Touch-friendly Action Buttons */
  .race-controls-cell {
    grid-area: controls !important;
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 2fr !important;
    gap: 8px !important;
    margin-top: 4px !important;
    padding-top: 10px !important;
    border-top: 1px dashed #e2e8f0 !important;
  }

  .btn-race-step {
    height: 42px !important;
    font-size: 13.5px !important;
    font-weight: 800 !important;
    border-radius: 12px !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
  }

  .btn-race-step.dec {
    background: #f8fafc !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1 !important;
  }

  .btn-race-step.inc {
    background: #059669 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25) !important;
  }
}

/* All Books QR Print Sheet Styles */
.book-qr-grid-a4 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4mm;
}

.book-qr-card {
  border: 1.5px dashed #059669;
  border-radius: 6px;
  padding: 4px 6px;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38mm;
  box-sizing: border-box;
  page-break-inside: avoid;
  break-inside: avoid;
}

.book-qr-card .qr-col {
  width: 29mm;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.book-qr-card .qr-graphic {
  width: 27mm;
  height: 27mm;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-qr-card .qr-graphic svg,
.book-qr-card .qr-graphic img {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.book-qr-card .book-code-mono {
  font-family: monospace;
  font-size: 8pt;
  font-weight: 900;
  color: #065f46;
  margin-top: 1px;
  letter-spacing: 0.5px;
}

/* =====================================================================
   STUDENT PORTAL READING RACE & ACTIVE LOANS (Req 6)
   ===================================================================== */
.sp-race-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.sp-race-stat-item {
  background: white;
  border: 1px solid #d1fae5;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.sp-race-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #ecfdf5;
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
}

.sp-race-val {
  font-size: 16px;
  font-weight: 900;
  color: #065f46;
  line-height: 1.2;
}

.sp-race-lbl {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-top: 2px;
}

/* Excel File Drop Zone */
.excel-drop-zone {
  border: 2px dashed #38bdf8;
  border-radius: 16px;
  background: #f0f9ff;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.excel-drop-zone:hover {
  background: #e0f2fe;
  border-color: #0284c7;
  transform: translateY(-1px);
}

/* Tablet & Mobile Responsiveness */
@media (max-width: 768px) {
  .sp-race-stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .sp-race-stat-item {
    padding: 10px 12px;
  }

  .student-race-portal-card {
    padding: 12px !important;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  /* Tablet optimization (iPads) */
  .borrow-grid-layout {
    grid-template-columns: 1fr !important;
  }

  .sp-race-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .books-card-list {
    grid-template-columns: 1fr !important;
  }

  .lib-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ====================================================================
   TEACHER ANIMAL GROUP & RANKING SYSTEM (4 TIERS - TEACHER ONLY)
   ==================================================================== */
.badge-animal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.badge-animal-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Dolphin Tier - Smartest / Xuất sắc */
.badge-animal-dolphin,
.tier-card-dolphin .animal-tier-badge,
.badge-dolphin {
  color: #0284c7;
  background: #e0f2fe;
  border-color: #7dd3fc;
}

/* Monkey Tier - Better / Khá giỏi */
.badge-animal-monkey,
.tier-card-monkey .animal-tier-badge,
.badge-monkey {
  color: #059669;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

/* Orange Cat Tier - Ordinary / Đạt chuẩn */
.badge-animal-orange_cat,
.badge-animal-cat,
.tier-card-cat .animal-tier-badge,
.badge-cat {
  color: #c2410c;
  background: #fff7ed;
  border-color: #fed7aa;
}

/* Turtle & Snail Tier - Need Improvement / Cần rèn luyện */
.badge-animal-turtle_snail,
.badge-animal-turtle,
.tier-card-turtle .animal-tier-badge,
.badge-turtle {
  color: #be185d;
  background: #fdf2f8;
  border-color: #fbcfe8;
}

/* Animal Picker Button in Table */
.animal-picker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 32px;
  padding: 2px 8px;
  background: transparent;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  border-radius: 999px;
  transition: all 0.15s ease;
}

.animal-picker-btn:hover {
  transform: translateY(-1px);
  filter: brightness(0.96);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* Tier Filter Bar */
.animal-tier-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.animal-tier-filter-btn:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.animal-tier-filter-btn.active {
  background: #1e293b;
  color: #ffffff;
  border-color: #1e293b;
  box-shadow: 0 2px 6px rgba(30, 41, 59, 0.15);
}

.animal-tier-filter-btn.tier-btn-dolphin.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.animal-tier-filter-btn.tier-btn-monkey.active {
  background: #059669;
  color: #ffffff;
  border-color: #059669;
}

.animal-tier-filter-btn.tier-btn-cat.active {
  background: #ea580c;
  color: #ffffff;
  border-color: #ea580c;
}

.animal-tier-filter-btn.tier-btn-turtle.active {
  background: #be185d;
  color: #ffffff;
  border-color: #be185d;
}

.tier-count-chip {
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.08);
  font-size: 11px;
}

.animal-tier-filter-btn.active .tier-count-chip {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Modal Tier Cards */
.animal-tier-card {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 14px;
  background: #ffffff;
  transition: all 0.2s ease;
}

.animal-tier-card.tier-card-dolphin {
  border-left: 4px solid #0284c7;
  background: #f0f9ff;
}

.animal-tier-card.tier-card-monkey {
  border-left: 4px solid #059669;
  background: #f0fdf4;
}

.animal-tier-card.tier-card-cat {
  border-left: 4px solid #c2410c;
  background: #fffaf0;
}

.animal-tier-card.tier-card-turtle {
  border-left: 4px solid #be185d;
  background: #fff1f2;
}

.animal-tier-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.animal-tier-badge {
  font-size: 12px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid;
}

.animal-tier-sub {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}

/* Mascot Options Grid */
.animal-options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.animal-option-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.animal-option-chip:hover {
  border-color: #3b82f6;
  background: #f8fafc;
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.animal-option-chip.selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px #3b82f6;
}

.animal-chip-icon {
  font-size: 22px;
  line-height: 1;
}

.animal-chip-label,
.animal-tier-sub,
.animal-name,
.animal-sub {
  display: none !important;
}

/* ====================================================================
   GRADING ANIMAL MASCOT SELECTOR
   ==================================================================== */
.grade-animal-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 640px) {
  .grade-animal-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.animal-tier-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  background: white;
  border: 2px solid #E2E8F0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.animal-tier-btn:hover {
  border-color: #94A3B8;
  transform: translateY(-1px);
}

.animal-tier-btn.selected {
  border-color: var(--primary);
  background: #EFF6FF;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.animal-tier-btn .animal-icon {
  font-size: 24px;
  line-height: 1;
}

/* ====================================================================
   GRADING QUESTIONS BREAKDOWN
   ==================================================================== */
.grade-questions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.grade-question-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: white;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  gap: 8px;
}

.grade-question-title {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  min-width: 80px;
}

.grade-question-actions {
  display: flex;
  gap: 6px;
}

.q-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #CBD5E1;
  background: white;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.q-btn:hover {
  transform: translateY(-1px);
}

.q-btn.q-btn-correct.active {
  background: #10B981;
  color: white;
  border-color: #059669;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}

.q-btn.q-btn-needfix.active {
  background: #F59E0B;
  color: white;
  border-color: #D97706;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
}

.q-btn.q-btn-wrong.active {
  background: #EF4444;
  color: white;
  border-color: #DC2626;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
}

/* Question Presets */
.quick-question-presets .preset-chip {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  background: #E2E8F0;
  border-radius: 12px;
  cursor: pointer;
  color: #334155;
  transition: all 0.15s ease;
}

.quick-question-presets .preset-chip:hover {
  background: var(--primary);
  color: white;
}

/* ====================================================================
   TEAMS MANAGEMENT TAB & CARDS
   ==================================================================== */
.teams-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.team-card {
  background: white;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.team-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.team-card-header {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.team-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.team-avatar-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.team-card-title {
  font-size: 16px;
  font-weight: 800;
  color: #0F172A;
  margin: 0;
  line-height: 1.3;
}

.team-card-actions {
  display: flex;
  gap: 6px;
}

.team-card-body {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.team-motto {
  font-size: 13px;
  color: #475569;
  font-style: italic;
  margin-bottom: 12px;
  padding-left: 8px;
  border-left: 3px solid #CBD5E1;
}

.team-members-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #64748B;
  margin-bottom: 8px;
}

.team-members-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.team-member-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #F1F5F9;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #1E293B;
  border: 1px solid #E2E8F0;
}

.team-member-pill .member-symbol {
  font-size: 14px;
}

/* Team Modal Controls */
.team-quick-icons .icon-chip {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #CBD5E1;
  background: white;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.team-quick-icons .icon-chip:hover {
  border-color: var(--primary);
  transform: scale(1.1);
}

.team-quick-colors .color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-block;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 0 0 1px #CBD5E1;
  transition: all 0.15s ease;
}

.team-quick-colors .color-dot:hover {
  transform: scale(1.15);
}

.team-student-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 6px;
}

.team-student-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: white;
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
  user-select: none;
}

.team-student-item:hover {
  background: #F8FAFC;
  border-color: #94A3B8;
}

.team-student-item.selected {
  background: #EFF6FF;
  border-color: var(--primary);
}

.team-student-item input[type="checkbox"] {
  cursor: pointer;
}

.team-student-item .student-item-sym {
  font-size: 14px;
}

.team-student-item .student-item-name {
  color: #1E293B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ====================================================================
   BATCH & SINGLE GRADING CONTROLS AND SELECTORS
   ==================================================================== */
.grade-mode-toggle-bar {
  display: flex;
  gap: 6px;
  background: #F1F5F9;
  padding: 4px;
  border-radius: 8px;
  margin-top: 6px;
  margin-bottom: 10px;
}

.grade-mode-btn {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
}

.grade-mode-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.grade-animal-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-animal-filter {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid #CBD5E1;
  background: white;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-animal-filter:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.grade-student-selector-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.grade-student-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: white;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s ease;
  user-select: none;
}

.grade-student-item:hover {
  border-color: #93C5FD;
  background: #F8FAFC;
}

.grade-student-item.selected {
  border-color: var(--primary);
  background: #EFF6FF;
  font-weight: 700;
}

.grade-student-item.active-single {
  border-color: var(--primary);
  background: #EEF2FF;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.grade-student-item .st-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grade-student-item .st-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.grade-student-item input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
}

.grade-batch-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}

.batch-st-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
  border-radius: 9999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
}

.batch-st-chip .chip-remove {
  cursor: pointer;
  color: #DC2626;
  font-weight: 800;
  margin-left: 2px;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.batch-st-chip .chip-remove:hover {
  background: #FEE2E2;
}

/* ==================================================================== */
/* 5-ROW HORIZONTAL GRADING TABLE & GOALS BANNER                        */
/* ==================================================================== */
.grade-questions-horizontal-wrapper {
  margin-top: 10px;
  margin-bottom: 12px;
}

.grade-horizontal-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  border: 1px solid #E2E8F0;
  background: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.grade-horizontal-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
  font-size: 13px;
}

.grade-horizontal-table th,
.grade-horizontal-table td {
  padding: 8px 10px;
  border: 1px solid #E2E8F0;
  text-align: center;
  vertical-align: middle;
}

.gh-row-head {
  background: #F8FAFC;
  color: #1E293B;
  font-weight: 700;
}

.gh-col-label {
  width: 110px;
  min-width: 105px;
  text-align: left !important;
  font-weight: 700;
  background: #F8FAFC;
  font-size: 12px;
  color: #334155;
  white-space: nowrap;
}

.gh-col-label .gh-icon {
  margin-right: 4px;
}

.gh-col-q {
  font-weight: 800;
  color: #1E293B;
  background: #F1F5F9;
  font-size: 12px;
  padding: 10px 8px;
}

.gh-col-cell {
  padding: 6px 8px;
}

.gh-choice-btn {
  width: 100%;
  border-radius: 6px;
  padding: 6px 6px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.gh-choice-btn.gh-btn-correct.active {
  background: #10B981;
  color: #FFFFFF;
  border-color: #059669;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.35);
}

.gh-choice-btn.gh-btn-correct:not(.active):hover {
  background: #ECFDF5;
  border-color: #10B981;
  color: #065F46;
}

.gh-choice-btn.gh-btn-wrong.active {
  background: #EF4444;
  color: #FFFFFF;
  border-color: #DC2626;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.35);
}

.gh-choice-btn.gh-btn-wrong:not(.active):hover {
  background: #FEF2F2;
  border-color: #EF4444;
  color: #991B1B;
}

.gh-choice-btn.gh-btn-needfix.active {
  background: #F59E0B;
  color: #FFFFFF;
  border-color: #D97706;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.35);
}

.gh-choice-btn.gh-btn-needfix:not(.active):hover {
  background: #FFFBEB;
  border-color: #F59E0B;
  color: #92400E;
}

.gh-col-note {
  padding: 6px 8px;
}

.gh-note-input {
  width: 100%;
  font-size: 11px;
  padding: 5px 7px;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  outline: none;
  background: #FFFFFF;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.gh-note-input:focus {
  border-color: #3B82F6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

#grade-assignment-goals-banner {
  animation: fadeInGoals 0.2s ease-out;
}

@keyframes fadeInGoals {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====================================================================
   STUDENT NORMAL AVATAR & COLOR GROUP STYLING
   ==================================================================== */
.student-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.color-group-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  background: #F8FAFC;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #E2E8F0;
}

.color-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.color-filter-btn:hover {
  background: #F1F5F9;
  border-color: #94A3B8;
}

.color-filter-btn.active {
  background: #1E293B;
  color: #FFFFFF;
  border-color: #1E293B;
  box-shadow: 0 1px 4px rgba(30, 41, 59, 0.25);
}

.color-filter-btn .color-count-chip {
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.color-filter-btn.active .color-count-chip {
  background: rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
}

.color-group-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  background: none;
  border: 1px solid transparent;
}

.color-group-pill:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.color-bullet {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.color-preset-card {
  transition: all 0.15s ease;
}

.color-preset-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.color-preset-card.selected {
  outline: 2px solid #2563EB;
  outline-offset: 1px;
}

