/* ── RESET & BASE ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8f8fc;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── TOPBAR ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 64px;
  background: #fff;
  border-bottom: 1px solid #e8e8f0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.brand {
  font-size: 1.25rem;
  font-weight: 800;
  color: #1a1a2e;
}

.kid-count {
  font-size: 0.9rem;
  color: #888;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.search-input {
  padding: 0.45rem 0.9rem;
  border: 1.5px solid #e0e0ea;
  border-radius: 8px;
  font-size: 0.9rem;
  width: 220px;
  background: #f8f8fc;
  transition: border-color 0.2s;
}
.search-input:focus {
  outline: none;
  border-color: #1a1a2e;
}

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1.1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }
.btn-full { width: 100%; }

.btn-dark    { background: #1a1a2e; color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid #d0d0de; color: #1a1a2e; }
.btn-outline:hover { background: #f0f0f8; }
.btn-cyan    { background: #e0f7fa; color: #007c91; border: none; }
.btn-red     { background: #ef4444; color: #fff; }
.btn-ghost   { background: transparent; color: #aaa; font-size: 0.78rem; font-weight: 400; }
.btn-ghost:hover { color: #ef4444; }

.btn-dark.attended {
  background: #4a4a6a;
  opacity: 0.7;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  color: #bbb;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
}
.icon-btn:hover { color: #555; }

/* ── KIDS GRID ──────────────────────────────────────────────────────────── */
main {
  padding: 1.5rem;
}

.kids-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1rem;
}

/* ── KID CARD ───────────────────────────────────────────────────────────── */
.kid-card {
  background: linear-gradient(160deg, #f0eeff 0%, #eaf4ff 100%);
  border-radius: 16px;
  padding: 1.1rem 1rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  position: relative;
  border: 1px solid rgba(180,160,255,0.15);
  transition: transform 0.15s, box-shadow 0.15s;
}
.kid-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(100,80,200,0.1);
}
.kid-card.hidden { display: none; }

.kid-date {
  font-size: 0.72rem;
  color: #999;
  text-align: right;
  position: absolute;
  top: 0.75rem;
  right: 0.9rem;
}

/* ── AVATAR ─────────────────────────────────────────────────────────────── */
.avatar-wrap {
  display: flex;
  justify-content: center;
  position: relative;
  margin-bottom: 0.1rem;
}

.avatar-img,
.avatar-initials {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-initials {
  background: #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #666;
}

.avatar-edit-btn {
  position: absolute;
  bottom: 0;
  right: calc(50% - 52px);
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  border: 1.5px solid #e0e0ea;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  cursor: pointer;
  color: #888;
  transition: color 0.15s;
}
.avatar-edit-btn:hover { color: #1a1a2e; }

/* ── KID INFO ───────────────────────────────────────────────────────────── */
.kid-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
}

.kid-name {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a2e;
}

.birthday-badge {
  text-align: center;
  font-size: 0.78rem;
  color: #555;
  border: 1px solid #d0d0de;
  border-radius: 8px;
  padding: 0.2rem 0.6rem;
  align-self: center;
  width: fit-content;
  margin: 0 auto;
}

.age-text {
  text-align: center;
  font-size: 0.82rem;
  font-style: italic;
  color: #888;
}

/* ── POINTS ─────────────────────────────────────────────────────────────── */
.points-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.points-value {
  font-size: 2rem;
  font-weight: 800;
  color: #1a1a2e;
  line-height: 1;
}

/* ── STORE ROW ──────────────────────────────────────────────────────────── */
.store-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.store-label {
  text-align: center;
  font-size: 0.78rem;
  color: #aaa;
}

.store-controls {
  display: flex;
  gap: 0.4rem;
}

.store-input {
  flex: 1;
  padding: 0.4rem 0.5rem;
  border: 1.5px solid #e0e0ea;
  border-radius: 7px;
  font-size: 0.9rem;
  background: #fff;
  text-align: center;
  min-width: 0;
}
.store-input:focus { outline: none; border-color: #1a1a2e; }

/* ── UNDO & DELETE ──────────────────────────────────────────────────────── */
.undo-row { }
.delete-row { text-align: center; }

/* ── MODALS ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 1.75rem 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-sm { max-width: 300px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-header h2 { font-size: 1.15rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #888;
  line-height: 1;
}
.modal-close:hover { color: #1a1a2e; }

/* ── FORMS ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.35rem;
}
input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"] {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid #e0e0ea;
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fafafa;
  transition: border-color 0.2s;
}
input:focus { outline: none; border-color: #1a1a2e; }
.form-actions { margin-top: 0.5rem; }

/* ── ALERTS ─────────────────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  font-weight: 500;
}
.alert-error   { background: #fde8e8; color: #b91c1c; }
.alert-success { background: #dcfce7; color: #166534; }

/* ── LOGIN ──────────────────────────────────────────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #3b0764 100%);
  min-height: 100vh;
}
.login-box {
  background: #fff;
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
  text-align: center;
}
.login-logo { font-size: 3rem; margin-bottom: 0.5rem; }
.login-box h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: 0.2rem; }
.login-box > p { color: #888; margin-bottom: 1.5rem; }
.login-box .form-group { text-align: left; }

/* ── OVERVIEW ───────────────────────────────────────────────────────────── */
.overview-page { max-width: 960px; margin: 0 auto; }

.page-header { margin-bottom: 1.25rem; }
.page-header h2 { font-size: 1.5rem; font-weight: 800; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: #fff;
  border-radius: 14px;
  padding: 1.25rem 1rem;
  text-align: center;
  border: 1px solid #e8e8f0;
}
.stat-number { font-size: 2.2rem; font-weight: 800; }
.stat-label  { font-size: 0.82rem; color: #888; margin-top: 0.2rem; }

.card {
  background: #fff;
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  border: 1px solid #e8e8f0;
}
.card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }
.mb { margin-bottom: 1.25rem; }

/* bar chart */
.chart-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 160px;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}
.bar-label-top { font-size: 0.72rem; color: #666; height: 18px; }
.bar-outer {
  flex: 1;
  width: 100%;
  background: #f0f0f8;
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.bar-inner {
  width: 100%;
  background: #1a1a2e;
  border-radius: 6px 6px 0 0;
  min-height: 2px;
  transition: height 0.5s ease;
}
.bar-label { font-size: 0.7rem; color: #888; margin-top: 4px; }

/* leaderboard */
.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #aaa;
  padding: 0.5rem 0.75rem;
  border-bottom: 1.5px solid #f0f0f8;
}
.leaderboard-table td {
  padding: 0.6rem 0.75rem;
  font-size: 0.92rem;
  border-bottom: 1px solid #f8f8fc;
}
.leaderboard-table tr:last-child td { border-bottom: none; }
.rank-num { font-weight: 800; color: #4f46e5; width: 30px; }

/* ── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 0.75rem 1rem; gap: 0.5rem; }
  .topbar-right { flex-wrap: wrap; }
  .search-input { width: 100%; }
  .kids-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ── CROP MODAL ─────────────────────────────────────────────────────────── */
.modal-crop { width: 90vw; max-width: 500px; }
.crop-container {
  width: 100%;
  height: 350px;
  background: #000;
  overflow: hidden;
}
.crop-container img { display: block; max-width: 100%; }

/* ── OVERVIEW ATTENDANCE ─────────────────────────────────────────────────── */
.overview-bar-btn { cursor: pointer; transition: transform .15s; }
.overview-bar-btn:hover { transform: scaleY(1.04); }
.overview-bar-btn.bar-active .bar-inner { background: #4f46e5 !important; }
.chart-hint { font-size:.78rem; color:#aaa; text-align:center; margin-top:.5rem; }
.section-hint { font-size:.85rem; color:#888; margin-bottom:.75rem; }

.month-detail-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:.5rem; margin-bottom:1rem; }

.attendance-list { display:flex; flex-direction:column; gap:.4rem; }
.attendance-item { display:flex; align-items:center; gap:.75rem; padding:.5rem .75rem; background:#f8f8fc; border-radius:10px; }
.att-avatar { width:36px; height:36px; border-radius:50%; overflow:hidden; flex-shrink:0; }
.att-avatar img { width:100%; height:100%; object-fit:cover; }
.att-initials { width:36px; height:36px; border-radius:50%; background:linear-gradient(135deg,#667eea,#764ba2); color:#fff; font-weight:700; font-size:.85rem; display:flex; align-items:center; justify-content:center; }
.att-name { flex:1; font-weight:600; font-size:.9rem; }
.att-points { font-size:.82rem; color:#888; white-space:nowrap; }

.streak-controls { display:flex; align-items:center; gap:.75rem; flex-wrap:wrap; }
.streak-controls label { font-weight:600; font-size:.9rem; }
