*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --parent: #6C5CE7;
  --parent-dark: #5a4bd1;
  --kid: #00B894;
  --kid-dark: #00a381;
  --reward: #FD79A8;
  --reward-dark: #e8669a;
  --danger: #D63031;
  --text: #2D3436;
  --text-light: #636e72;
  --bg: #f0f2f5;
  --card: #ffffff;
  --border: #dfe6e9;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem 1.2rem;
  transition: opacity 0.15s, transform 0.1s;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary   { background: var(--parent); color: #fff; }
.btn-kid       { background: var(--kid); color: #fff; }
.btn-reward    { background: var(--reward); color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-outline   { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-sm        { font-size: 0.85rem; padding: 0.35rem 0.8rem; }
.btn-lg        { font-size: 1.2rem; padding: 0.9rem 1.8rem; }
.btn-full      { width: 100%; }

input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--parent); }

label { font-size: 0.875rem; font-weight: 600; color: var(--text-light); display: block; margin-bottom: 0.3rem; }

.field { margin-bottom: 1rem; }

/* ── Layout ── */
.header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header h1 { font-size: 1.25rem; font-weight: 700; }
.header .back { font-size: 1.5rem; cursor: pointer; }

.main { padding: 1.5rem; max-width: 800px; margin: 0 auto; }

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.75rem; }

/* ── Home page ── */
.home-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.home-logo { font-size: 4rem; }
.home-title { font-size: 2.5rem; font-weight: 800; color: #fff; text-align: center; }
.home-subtitle { color: rgba(255,255,255,0.8); font-size: 1.1rem; text-align: center; }
.home-buttons { display: flex; flex-direction: column; gap: 1rem; width: 100%; max-width: 320px; }
.home-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 1.5rem;
  border-radius: var(--radius);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.home-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0,0,0,0.25); }
.home-btn-icon { font-size: 2rem; }
.home-btn.parent { background: #fff; color: var(--parent); }
.home-btn.kid    { background: var(--kid); color: #fff; }
.home-btn.reward { background: var(--reward); color: #fff; }

/* ── PIN modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 2rem;
  width: min(400px, 90vw);
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
.modal h2 { margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* ── Tabs ── */
.tabs { display: flex; gap: 0.25rem; margin-bottom: 1.5rem; overflow-x: auto; padding-bottom: 0.25rem; }
.tab-btn {
  background: transparent;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-light);
  border: 2px solid transparent;
}
.tab-btn.active { background: var(--parent); color: #fff; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Kid selector ── */
.kid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; }
.kid-card-btn {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.5rem; padding: 1.5rem 1rem;
  border-radius: var(--radius);
  border: 3px solid transparent;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
}
.kid-card-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.15); }
.kid-card-btn .kid-avatar { font-size: 2.5rem; }

/* ── Day picker ── */
.day-nav { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.25rem; margin-bottom: 1rem; }
.day-btn {
  display: flex; flex-direction: column; align-items: center;
  min-width: 52px; padding: 0.5rem 0.4rem;
  border-radius: 10px; border: 2px solid var(--border);
  background: #fff; color: var(--text-light);
  font-size: 0.75rem; font-weight: 600;
  cursor: pointer;
}
.day-btn .day-num { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.day-btn.today { border-color: var(--kid); }
.day-btn.selected { background: var(--kid); border-color: var(--kid); color: #fff; }
.day-btn.selected .day-num { color: #fff; }
.day-btn.has-completions::after {
  content: ''; display: block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--kid); margin-top: 2px;
}
.day-btn.selected.has-completions::after { background: rgba(255,255,255,0.7); }

/* ── Activity list ── */
.activity-list { display: flex; flex-direction: column; gap: 0.6rem; }
.activity-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: #fff; border-radius: 10px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.activity-item.done { background: #e8f8f5; border-color: var(--kid); }
.activity-checkbox {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.activity-item.done .activity-checkbox { background: var(--kid); border-color: var(--kid); color: #fff; }
.activity-name { flex: 1; font-weight: 600; }
.activity-points { font-size: 0.85rem; font-weight: 700; color: var(--kid); background: #e8f8f5; padding: 0.2rem 0.6rem; border-radius: 20px; }
.activity-item.done .activity-name { text-decoration: line-through; color: var(--text-light); }

/* ── Points banner ── */
.points-banner {
  background: linear-gradient(135deg, var(--kid), var(--kid-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.points-total { font-size: 2.5rem; font-weight: 800; }
.points-label { font-size: 0.9rem; opacity: 0.85; }
.points-breakdown { font-size: 0.8rem; opacity: 0.75; text-align: right; }

/* ── Parent list items ── */
.list-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item-name { flex: 1; font-weight: 600; }
.list-item-meta { font-size: 0.8rem; color: var(--text-light); }
.list-actions { display: flex; gap: 0.4rem; }

/* ── Forms ── */
.form-row { display: flex; gap: 0.75rem; align-items: flex-end; }
.form-row .field { margin-bottom: 0; flex: 1; }

/* ── Color picker ── */
.color-swatches { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: border-color 0.15s;
}
.swatch.selected { border-color: var(--text); }

/* ── Reward items ── */
.reward-card {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  transition: border-color 0.15s;
}
.reward-card.available { border-color: var(--reward); }
.reward-card.unavailable { opacity: 0.5; }
.reward-card-name { flex: 1; font-weight: 700; }
.reward-cost { font-size: 1rem; font-weight: 700; color: var(--reward); white-space: nowrap; }
.reward-type-badge {
  font-size: 0.7rem; font-weight: 600; padding: 0.15rem 0.5rem;
  border-radius: 20px; background: #f8f8f8; color: var(--text-light);
  border: 1px solid var(--border); white-space: nowrap;
}

/* ── Session UI ── */
.session-hero {
  background: linear-gradient(135deg, var(--reward), var(--reward-dark));
  border-radius: var(--radius);
  padding: 1.5rem;
  color: #fff;
  text-align: center;
  margin-bottom: 1rem;
}
.session-hero h2 { font-size: 1.6rem; }
.session-hero p { opacity: 0.85; margin-top: 0.25rem; }

.kid-points-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 0.5rem;
  border: 2px solid var(--border);
  background: #fff;
  transition: border-color 0.15s;
}
.kid-points-row.current-turn { border-color: var(--reward); background: #fff5f9; }
.kid-points-row.done-turn { opacity: 0.45; }
.kid-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.kid-points-name { flex: 1; font-weight: 700; }
.kid-points-val { font-size: 1.4rem; font-weight: 800; color: var(--reward); }
.turn-badge { font-size: 0.75rem; font-weight: 700; background: var(--reward); color: #fff; padding: 0.15rem 0.6rem; border-radius: 20px; }
.done-badge { font-size: 0.75rem; font-weight: 700; background: var(--border); color: var(--text-light); padding: 0.15rem 0.6rem; border-radius: 20px; }

.action-bar {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  background: #fff; border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

/* ── Bank modal ── */
.bank-slider { width: 100%; margin: 1rem 0; }

/* ── Kid view toggle ── */
.kid-view-toggle {
  display: flex; gap: 0.25rem;
  background: var(--border); border-radius: 10px; padding: 3px;
  margin-bottom: 1rem;
}
.kid-toggle-btn {
  flex: 1; padding: 0.45rem; border-radius: 8px;
  font-weight: 600; font-size: 0.95rem;
  background: transparent; color: var(--text-light);
  border: none;
}
.kid-toggle-btn.active { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

/* ── Activity week grid ── */
.activity-grid-wrap { display: flex; flex-direction: column; gap: 0.35rem; }
.grid-row { display: flex; align-items: center; gap: 0.5rem; }
.grid-header { margin-bottom: 0.1rem; }
.grid-act-name {
  flex: 1; font-size: 0.875rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.grid-header .grid-act-name { font-size: 0.75rem; color: var(--text-light); font-weight: 400; }
.grid-cells { display: flex; gap: 3px; flex-shrink: 0; }
.grid-day-hdr {
  width: 28px; text-align: center; font-size: 0.7rem;
  font-weight: 700; color: var(--text-light); text-transform: uppercase;
}
.grid-day-hdr.today { color: var(--kid); }
.grid-cell {
  width: 28px; height: 28px; border-radius: 6px;
  border: 2px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: transparent;
  flex-shrink: 0;
}
.grid-cell:not(.future) { cursor: pointer; }
.grid-cell:not(.future):hover { border-color: var(--kid); }
.grid-cell.done { background: var(--kid); border-color: var(--kid); color: #fff; }
.grid-cell.future { background: #fafafa; border-color: #eee; }
.grid-pts {
  width: 36px; text-align: right; font-size: 0.8rem;
  font-weight: 700; color: var(--kid); flex-shrink: 0;
}

/* ── Kid purchases list ── */
.kid-purchase-item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.85rem 1rem;
  background: #fff; border-radius: 10px;
  border: 2px solid var(--reward);
  margin-bottom: 0.5rem;
}
.kid-purchase-item.redeemed {
  border-color: var(--border); opacity: 0.7;
}
.kid-purchase-icon { font-size: 1.3rem; flex-shrink: 0; }
.kid-purchase-name {
  flex: 1; font-weight: 700;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kid-purchase-item.redeemed .kid-purchase-name { text-decoration: line-through; color: var(--text-light); }
.kid-purchase-status { font-size: 0.8rem; font-weight: 600; color: var(--text-light); white-space: nowrap; }
.kid-purchase-item:not(.redeemed) .kid-purchase-status { color: var(--reward); }
.kid-purchase-cost { font-size: 0.8rem; color: var(--text-light); white-space: nowrap; flex-shrink: 0; }

/* ── Purchases log ── */
.purchase-log { display: flex; flex-direction: column; gap: 0.4rem; }
.purchase-entry {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.875rem; padding: 0.5rem;
  background: #fafafa; border-radius: 8px;
}
.purchase-entry .kid-dot { width: 10px; height: 10px; }

/* ── Redeem checkbox ── */
.redeem-checkbox {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  border: 2.5px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700; color: #fff;
  transition: all 0.15s;
  padding: 0;
}
.purchase-row.redeemed .redeem-checkbox { background: var(--kid); border-color: var(--kid); }
.purchase-row.redeemed .purchase-name { text-decoration: line-through; color: var(--text-light); }
.purchase-row.redeemed { opacity: 0.7; }

/* ── Week badge ── */
.week-badge {
  display: inline-block;
  font-size: 0.8rem; font-weight: 600;
  padding: 0.2rem 0.7rem; border-radius: 20px;
  background: #f0edff; color: var(--parent);
}
.week-badge.active-week { background: var(--parent); color: #fff; }

/* ── Empty state ── */
.empty { text-align: center; padding: 2rem; color: var(--text-light); }
.empty .empty-icon { font-size: 3rem; }
.empty p { margin-top: 0.5rem; }

/* ── Section title ── */
.section-title {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-light);
  margin: 1.25rem 0 0.5rem;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: #2D3436; color: #fff;
  padding: 0.75rem 1.5rem; border-radius: 30px;
  font-weight: 600; font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  z-index: 200;
  animation: toast-in 0.3s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Utility ── */
.hidden { display: none !important; }
.flex { display: flex; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-light); font-size: 0.875rem; }
.font-bold { font-weight: 700; }

@media (max-width: 480px) {
  .main { padding: 1rem; }
  .home-title { font-size: 2rem; }
  .form-row { flex-direction: column; }
}
