/* Family Bank — playful, big-target styles for kids and parents */

:root {
  --bg: #faf6ef;
  --ink: #2d2a3e;
  --muted: #8a8699;
  --card: #ffffff;
  --line: #ece6da;
  --primary: #7c5cff;
  --good: #2db870;
  --bad: #e0526b;
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", "Comic Sans MS", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
}

main { max-width: 880px; margin: 0 auto; padding: 16px 16px 64px; }

h1 { font-size: 1.7rem; margin: 16px 0 8px; }
h2 { font-size: 1.25rem; margin: 4px 0 12px; }
h3 { font-size: 1.05rem; margin: 18px 0 6px; }

.muted { color: var(--muted); font-size: 0.9em; }

/* ------------------------------------------------------------- top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 2px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.15rem; text-decoration: none; color: var(--ink); }
.topbar nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar nav a { color: var(--ink); text-decoration: none; font-weight: 600; }
.topbar nav a:hover { color: var(--primary); }

/* -------------------------------------------------------------- flashes */
.flashes { max-width: 880px; margin: 12px auto 0; padding: 0 16px; }
.flash {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 8px;
  background: #fff6d9; border: 2px solid #f0dd9a; font-weight: 600;
}
.flash.yay { background: #e6f9ee; border-color: #9fe3bd; }
.flash.error { background: #fdebee; border-color: #f3b3c0; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--card); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 24px; margin-top: 24px;
}
.card.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.card.center { text-align: center; }

.panel {
  background: var(--card); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin: 20px 0;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px;
}

/* -------------------------------------------------------------- welcome */
.welcome { text-align: center; padding-top: 32px; }
.kid-cards { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }
.kid-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 170px; padding: 28px 16px;
  background: var(--card);
  border: 3px solid var(--kid-color, var(--line));
  border-radius: var(--radius);
  text-decoration: none; color: var(--ink);
  transition: transform 0.1s ease;
}
.kid-card:hover { transform: scale(1.05); }
.kid-emoji { font-size: 3rem; }
.kid-name { font-weight: 800; font-size: 1.2rem; }
.parent-card { border-color: var(--muted); }
.big-emoji { font-size: 4rem; margin-top: 8px; }

/* avatars (photo or emoji), sized by class */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle; line-height: 1;
}
img.avatar { border-radius: 50%; object-fit: cover; border: 3px solid var(--line); }
.avatar-xl { font-size: 4.5rem; } img.avatar-xl { width: 104px; height: 104px; }
.avatar-lg { font-size: 3rem; }   img.avatar-lg { width: 72px; height: 72px; }
.avatar-md { font-size: 1.9rem; } img.avatar-md { width: 42px; height: 42px; }
.avatar-sm { font-size: 1.3rem; } img.avatar-sm { width: 28px; height: 28px; }
.avatar-preview { margin: 8px 0 4px; }
.avatar-link { text-decoration: none; }

/* dashboard header with avatar + name + change-picture */
.dash-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dash-head h1 { margin: 0; }

/* emoji picker grid on the avatar page */
.emoji-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px; margin: 10px 0 4px;
}
.emoji-pick {
  font-size: 1.8rem; padding: 8px; line-height: 1;
  background: var(--card); border: 2px solid var(--line); border-radius: 12px;
  cursor: pointer;
}
.emoji-pick:hover { border-color: var(--primary); transform: scale(1.08); }
.emoji-pick.chosen { border-color: var(--kid-color, var(--primary)); background: #f3eeff; }

/* saved-chore picker on the chore form */
.template-picker {
  background: #f7f4ff; border: 2px solid #e0d8ff; border-radius: 12px;
  padding: 12px 14px; margin-bottom: 12px;
}

/* kid picture shortcuts on the settings page */
.settings-kids { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.settings-kid {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 16px; border: 2px solid var(--kid-color, var(--line));
  border-radius: var(--radius); text-decoration: none; color: var(--ink);
}
.settings-kid:hover { transform: scale(1.04); }

/* ------------------------------------------------------- account cards */
.account-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px; margin: 18px 0;
}
.account-card {
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px; border-radius: var(--radius);
  background: var(--card);
  border: 3px solid var(--acct-color);
  text-decoration: none; color: var(--ink);
  transition: transform 0.1s ease;
}
.account-card:hover { transform: scale(1.03); }
.acct-emoji { font-size: 1.8rem; }
.acct-label { font-weight: 700; color: var(--acct-color); }
.acct-balance { font-size: 1.6rem; font-weight: 800; }
.acct-hint { font-size: 0.8rem; color: var(--muted); }

/* ---------------------------------------------------------------- goals */
.goal { padding: 12px 0; border-top: 1px dashed var(--line); }
.goal:first-of-type { border-top: 0; }
.goal-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.goal-name { font-weight: 700; }
.goal-amounts { font-weight: 600; }
.goal-reached { background: #f3fbf6; border-radius: 12px; padding: 12px; }
.goal-actions { display: flex; gap: 6px; align-items: center; }
.progress {
  height: 18px; border-radius: 9px; background: var(--line);
  overflow: hidden; margin: 6px 0;
}
.progress-fill {
  height: 100%; border-radius: 9px;
  background: linear-gradient(90deg, #3d8bff, #7c5cff);
  transition: width 0.3s ease;
}
.trophy-list, .cause-list, .give-list { padding-left: 20px; }
.trophy-list li, .give-list li { margin: 4px 0; }
.cause-list li { margin: 4px 0; display: flex; align-items: center; gap: 8px; }
.mode-label { font-size: 0.9rem; }

/* --------------------------------------------------------------- chores */
.chore, .approval {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  padding: 12px 0; border-top: 1px dashed var(--line);
}
.chore:first-of-type, .approval:first-of-type { border-top: 0; }
.chore-pay {
  display: inline-block; margin-left: 8px;
  background: #fff1e3; color: #c46a1b;
  padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: 0.9rem;
}
.chore-actions, .approval-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.return-note {
  background: #fff6d9; border-radius: 10px; padding: 6px 10px;
  margin-top: 4px; font-size: 0.9rem;
}
.badge {
  display: inline-block; background: var(--line); border-radius: 999px;
  padding: 3px 12px; font-size: 0.85rem; font-weight: 600; margin-top: 4px;
}
.status-open { background: #e6f0ff; color: #2456a8; }
.status-claimed { background: #fff1e3; color: #c46a1b; }
.status-submitted { background: #f1e8ff; color: #6a3fc4; }
.status-approved { background: #e6f9ee; color: #1d7a4a; }
.count-badge {
  display: inline-block; background: var(--bad); color: white;
  border-radius: 999px; padding: 1px 10px; font-size: 0.9rem; margin-left: 6px;
}

/* chore-approval cheer banner on the kid dashboard */
.cheer {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(90deg, #fff6d9, #e6f9ee);
  border: 2px solid #9fe3bd; border-radius: var(--radius);
  padding: 14px 18px; margin: 12px 0;
}
.cheer-emoji { font-size: 2rem; }
.cheer-text { flex: 1; min-width: 180px; }

/* -------------------------------------------------------------- buttons */
.btn {
  display: inline-block;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--line); border-radius: 12px;
  padding: 9px 16px; font-size: 1rem; font-weight: 700;
  font-family: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary {
  background: var(--primary); color: white; border-color: var(--primary);
}
.btn.primary:hover { filter: brightness(1.1); color: white; }
.btn.big { width: 100%; padding: 14px; font-size: 1.1rem; margin-top: 12px; }
.btn.small { padding: 5px 12px; font-size: 0.9rem; }
.btn.tiny { padding: 3px 8px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
button.link {
  background: none; border: none; color: var(--ink); font: inherit;
  font-weight: 600; cursor: pointer; padding: 0;
}
button.link:hover { color: var(--primary); }
.inline { display: inline-flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------------- forms */
form label { display: block; margin: 14px 0 4px; font-weight: 700; }
form label .muted { font-weight: 400; }
input, select {
  width: 100%; padding: 10px 12px; font-size: 1rem; font-family: inherit;
  border: 2px solid var(--line); border-radius: 12px; background: white;
  margin-top: 4px;
}
input:focus, select:focus { outline: none; border-color: var(--primary); }
fieldset { border: 2px solid var(--line); border-radius: 12px; margin: 14px 0; }
legend { font-weight: 700; padding: 0 8px; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
label.check input { width: auto; margin: 0; }
.row-form { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row-form input, .row-form select { width: auto; flex: 1; margin: 0; }
.pin-input {
  font-size: 1.6rem; text-align: center; letter-spacing: 0.4em;
  max-width: 240px; margin: 12px auto; display: block;
}

/* --------------------------------------------------------------- tables */
.ledger { width: 100%; border-collapse: collapse; margin: 10px 0; }
.ledger th, .ledger td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.ledger .num { text-align: right; white-space: nowrap; }
.pos { color: var(--good); font-weight: 700; }
.neg { color: var(--bad); font-weight: 700; }
.balance-line { font-size: 1.2rem; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.tab {
  padding: 7px 14px; border-radius: 999px; text-decoration: none;
  color: var(--ink); border: 2px solid var(--line); font-weight: 600; font-size: 0.92rem;
}
.tab.active { background: var(--acct-color, var(--primary)); border-color: var(--acct-color, var(--primary)); color: white; }

/* --------------------------------------------------------------- payday */
.payday-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.payday-card {
  flex: 1; min-width: 200px; text-align: center;
  border: 3px solid var(--kid-color, var(--line)); border-radius: var(--radius);
  padding: 18px;
}
.payday-card .kid-name { font-size: 1.1rem; }
.cash-due { font-size: 2rem; font-weight: 800; margin: 6px 0 2px; }
.payday-card form { margin-top: 12px; }
.quick-links { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------ celebrate */
.celebrate { text-align: center; padding-top: 40px; position: relative; }
.earned-line { font-size: 1.3rem; }
.cash-line { font-size: 1.7rem; }
.celebrate .btn { margin: 8px 6px 0; width: auto; display: inline-block; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute; top: -20px;
  left: calc(var(--i) * 4.16%);
  width: 10px; height: 14px;
  background: hsl(calc(var(--i) * 47), 85%, 60%);
  border-radius: 2px;
  animation: fall 3.2s linear infinite;
  animation-delay: calc(var(--i) * -0.27s);
}
@keyframes fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0.7; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .account-grid { grid-template-columns: repeat(2, 1fr); }
  .chore, .approval { flex-direction: column; align-items: stretch; }

  /* Wide tables (settle-up, chore board) stack into labeled cards on phones */
  .stack-mobile thead { display: none; }
  .stack-mobile, .stack-mobile tbody, .stack-mobile tr, .stack-mobile td {
    display: block; width: 100%;
  }
  .stack-mobile tr {
    border: 2px solid var(--line); border-radius: var(--radius);
    padding: 8px 12px; margin-bottom: 12px;
  }
  .stack-mobile td {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; text-align: right; border: 0;
    border-bottom: 1px solid var(--line); padding: 8px 0;
  }
  .stack-mobile td::before {
    content: attr(data-label); font-weight: 700; text-align: left;
    color: var(--muted);
  }
  .stack-mobile td.cell-title {
    display: block; text-align: left; font-size: 1.05rem;
    border-bottom: 1px solid var(--line); padding-bottom: 8px;
  }
  .stack-mobile td.cell-title::before { content: ""; display: none; }
  .stack-mobile td.cell-action {
    border-bottom: 0; justify-content: flex-end; flex-wrap: wrap;
  }
  .stack-mobile td.cell-action::before { content: ""; }
}
