/* Danh sách thẻ bé */
.kids-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.kid-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2.5px solid transparent;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
  cursor: pointer;
  transition: all 0.2s ease;
}

.kid-card.active {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.15);
  transform: translateY(-2px);
}

.kid-avatar-square {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  overflow: hidden;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.kid-avatar-square img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kid-name { font-size: 14px; font-weight: 800; color: var(--text-main); }
.kid-nick { font-size: 11px; font-weight: 700; color: #8b5cf6; margin-top: 1px; }
.kid-score { font-size: 20px; font-weight: 900; color: var(--primary); line-height: 1.1; margin-top: 2px; }
.score-unit { font-size: 11px; font-weight: 600; color: var(--text-sub); }

.btn-edit-kid {
  background: none;
  border: none;
  font-size: 15px;
  cursor: pointer;
  padding: 4px;
  opacity: 0.6;
}
.btn-edit-kid:hover { opacity: 1; }

/* Level & Progress Bar */
.level-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.level-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.level-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}

.level-title-text {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
  flex: 1;
  margin-left: 8px;
}

.level-pts-target { font-size: 11px; font-weight: 700; color: var(--text-sub); }

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: #f1f5f9;
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5 0%, #06b6d4 100%);
  border-radius: 6px;
  transition: width 0.4s ease;
}

/* Thẻ Streak */
.streak-card {
  background: linear-gradient(135deg, #ffedd5 0%, #fef3c7 100%);
  border: 1.5px solid #fed7aa;
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.streak-icon { font-size: 32px; line-height: 1; }
.streak-count { font-size: 15px; font-weight: 800; color: #c2410c; }
.streak-desc { font-size: 12px; font-weight: 600; color: #9a3412; margin-top: 2px; }

/* Huy hiệu */
.badges-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.badges-row::-webkit-scrollbar { display: none; }

.badge-item {
  flex: 0 0 calc(25% - 8px);
  min-width: 76px;
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 10px 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.badge-item.locked { filter: grayscale(1); opacity: 0.4; background: #f8fafc; }
.badge-item.unlocked { border-color: #fde047; background: #fefce8; box-shadow: 0 3px 8px rgba(234, 179, 8, 0.15); }
.badge-emoji { font-size: 24px; }
.badge-name { font-size: 10px; font-weight: 800; color: var(--text-main); }

/* Bàn phím bấm điểm */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-btn {
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 84px;
  text-align: left;
  cursor: pointer;
  border: 1.5px solid transparent;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
  transition: transform 0.1s ease;
}
.action-btn:active { transform: scale(0.96); }
.btn-top-row { display: flex; align-items: center; gap: 8px; }
.btn-emoji { font-size: 22px; }
.btn-label { font-size: 13px; font-weight: 700; color: var(--text-main); line-height: 1.25; }
.btn-pts { font-size: 13px; font-weight: 800; align-self: flex-end; }

.theme-pos { background: var(--pos-bg); border-color: var(--pos-border); }
.theme-pos .btn-pts { color: var(--pos-text); }
.theme-neg { background: var(--neg-bg); border-color: var(--neg-border); }
.theme-neg .btn-pts { color: var(--neg-text); }
.theme-reward { background: var(--reward-bg); border-color: var(--reward-border); }
.theme-reward .btn-pts { color: var(--reward-text); }

/* Sổ cái */
.log-box {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 6px 14px;
  border: 1px solid var(--border);
}
.log-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.log-row:last-child { border-bottom: none; }
.log-title { font-size: 13px; font-weight: 700; }
.log-time { font-size: 11px; color: var(--text-sub); margin-top: 2px; }
.log-point { font-size: 14px; font-weight: 800; }
.pts-plus { color: var(--pos-text); }
.pts-minus { color: var(--neg-text); }

.btn-delete-log {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  margin-left: 8px;
}
.btn-delete-log:hover { color: #dc2626; }

/* Toast Undo */
.undo-toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 13px;
  font-weight: 600;
}
.undo-toast.show { transform: translateX(-50%) translateY(0); }
.btn-undo-action {
  background: #f59e0b;
  color: #000000;
  border: none;
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
}

/* Bộ chọn Icon Emoji Palette */
.emoji-picker-container { margin-bottom: 10px; }
.emoji-picker-label { font-size: 11px; font-weight: 700; color: var(--text-sub); margin-bottom: 6px; }
.emoji-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #f8fafc;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  max-height: 100px;
  overflow-y: auto;
}
.emoji-btn-item {
  width: 32px;
  height: 32px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.emoji-btn-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.1);
}

.input-emoji-display {
  width: 44px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: #f1f5f9;
  border: 1.5px solid var(--border);
  border-radius: 10px;
}

.manage-tab-bar { display: flex; gap: 6px; margin-bottom: 14px; }
.manage-tab {
  flex: 1; padding: 8px; border-radius: 10px; border: 1px solid var(--border);
  background: #f8fafc; font-size: 12px; font-weight: 700; cursor: pointer;
}
.manage-tab.active { background: var(--primary); color: #ffffff; border-color: var(--primary); }
.manage-add-box { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; }
.input-text { flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); font-size: 13px; }
.input-num { width: 75px; padding: 10px 8px; border-radius: 10px; border: 1px solid var(--border); font-size: 13px; }
.criteria-item-row {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 12px;
  background: #f8fafc; border-radius: 12px; margin-bottom: 8px; border: 1px solid var(--border);
}

/* Modal Form Avatar */
.avatar-preview-wrapper { margin-bottom: 16px; text-align: center; }
.avatar-box {
  width: 96px; height: 96px; border-radius: 26px; margin: 0 auto 10px;
  background: #f1f5f9; display: flex; align-items: center; justify-content: center;
  font-size: 44px; overflow: hidden; border: 2.5px solid var(--primary);
}
.avatar-box img { width: 100%; height: 100%; object-fit: cover; }
.btn-upload-avatar {
  background: #e0e7ff; color: var(--primary); padding: 7px 16px;
  border-radius: 20px; font-size: 12px; font-weight: 800; cursor: pointer;
}
.form-group { text-align: left; margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 700; color: var(--text-sub); display: block; margin-bottom: 6px; }
.form-input { width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); font-size: 14px; }

/* Dashboard Thống Kê & Bộ Lọc */
.period-filter-bar { display: flex; background: #f1f5f9; padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.period-btn {
  flex: 1; padding: 7px 0; border: none; background: transparent; border-radius: 8px;
  font-size: 12px; font-weight: 700; color: var(--text-sub); cursor: pointer;
}
.period-btn.active { background: #ffffff; color: var(--primary); box-shadow: 0 2px 4px rgba(0,0,0,0.06); }
.stats-summary-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.stat-kpi-card { padding: 10px; border-radius: 12px; text-align: center; }
.kpi-label { font-size: 11px; font-weight: 700; color: var(--text-sub); }
.kpi-value { font-size: 16px; font-weight: 900; margin-top: 2px; }
.bg-green { background: var(--pos-bg); } .bg-green .kpi-value { color: var(--pos-text); }
.bg-red { background: var(--neg-bg); } .bg-red .kpi-value { color: var(--neg-text); }
.bg-orange { background: var(--reward-bg); } .bg-orange .kpi-value { color: var(--reward-text); }

.chart-wrapper { background: #f8fafc; border: 1px solid var(--border); border-radius: 14px; padding: 12px; margin-bottom: 16px; }
.chart-title { font-size: 12px; font-weight: 800; color: var(--text-sub); margin-bottom: 8px; text-transform: uppercase; }
.chart-wrapper canvas { max-height: 180px; width: 100% !important; }

.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px); z-index: 999; justify-content: center; align-items: flex-end;
}
.modal-backdrop.active { display: flex; }
.modal-card {
  background: #ffffff; width: 100%; max-width: 520px; max-height: 88vh;
  border-radius: 24px 24px 0 0; padding: 20px 18px calc(var(--safe-bottom) + 20px);
  overflow-y: auto; box-shadow: 0 -8px 24px rgba(0,0,0,0.12);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 17px; font-weight: 800; }
.btn-close-modal {
  background: #f1f5f9; border: none; width: 32px; height: 32px; border-radius: 50%;
  font-size: 14px; font-weight: bold; color: var(--text-sub); cursor: pointer;
}
.modal-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.backup-desc { font-size: 13px; color: var(--text-sub); margin-bottom: 12px; line-height: 1.4; }
.btn-modal-action { width: 100%; padding: 12px; border-radius: 12px; font-size: 14px; font-weight: 700; border: none; cursor: pointer; margin-bottom: 8px; }
.btn-export { background: var(--primary); color: #ffffff; }
.btn-import { background: #f1f5f9; color: var(--text-main); border: 1.5px dashed var(--border); }