:root {
  color-scheme: light;
  --ink: #182e28;
  --muted: #75817a;
  --green: #397a5c;
  --green-dark: #235942;
  --mint: #e6f0e9;
  --cream: #f4f6f1;
  --white: #fff;
  --line: #e8ece6;
  --coral: #e5856e;
  --yellow: #f5c967;
  --shadow: 0 12px 34px rgba(37, 57, 45, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Aptos', 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid #86b998; outline-offset: 3px; }
.app-shell { width: min(1160px, calc(100% - 44px)); margin: 0 auto; padding-bottom: max(60px, env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 4; height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(232, 236, 230, .72); background: rgba(244, 246, 241, .94); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 11px; font-size: 19px; font-weight: 800; letter-spacing: -.5px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--green); color: white; border-radius: 13px; font-size: 22px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.user-pill { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 700; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #f7dcad; color: #735529; font-size: 13px; font-weight: 800; }
.eyebrow { text-transform: uppercase; letter-spacing: 1.5px; color: var(--green); font-size: 11px; font-weight: 800; }
h1,h2,h3,p { margin-top: 0; }
h1 { margin-bottom: 9px; font-size: clamp(31px, 4vw, 45px); line-height: 1.11; letter-spacing: -1.9px; }
h2 { margin-bottom: 5px; font-size: 19px; letter-spacing: -.4px; }
h3 { margin-bottom: 5px; font-size: 16px; }
.subtle { color: var(--muted); }
.small { font-size: 12px; }
.hero { position: relative; overflow: hidden; display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin: 26px 0 28px; padding: 27px 28px; border: 1px solid #e7ecdf; border-radius: 22px; background: radial-gradient(ellipse at 95% 0%, rgba(220, 238, 218, .72), transparent 38%), linear-gradient(135deg, #fbfcf8, #f4f8ef); }
.hero p { margin-bottom: 0; color: var(--muted); }
.hero-badge { min-width: 190px; padding: 15px 18px; border: 1px solid #e5e9df; border-radius: 17px; background: #fbfcf8; }
.hero-badge strong { display: block; margin-top: 3px; font-size: 18px; }
.grid { display: grid; gap: 17px; }
.stats-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 19px; }
.two-col { grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); align-items: start; }
.card { background: var(--white); border: 1px solid rgba(225, 231, 224, .8); border-radius: 19px; padding: 21px; box-shadow: var(--shadow); transition: box-shadow .2s, border-color .2s; }
.card:hover { border-color: #dce7da; box-shadow: 0 14px 36px rgba(37, 57, 45, .1); }
.stat-card { min-height: 112px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-number { margin: 8px 0 0; font-size: 30px; letter-spacing: -1px; font-weight: 800; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.section-head p { margin-bottom: 0; }
.stack { display: grid; gap: 12px; }
.child-card { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 15px; border: 1px solid var(--line); background: #fdfefc; border-radius: 15px; }
.child-heading { display: flex; align-items: center; gap: 12px; }
.child-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.child-avatar { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 14px; background: #e8f2eb; font-size: 21px; }
.points { font-weight: 800; color: var(--green-dark); white-space: nowrap; }
.goal-card { padding: 16px 0; border-top: 1px solid var(--line); }
.goal-card:first-child { border-top: 0; padding-top: 0; }
.goal-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.goal-name { display: flex; gap: 10px; }
.goal-icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: #f0f4eb; flex-shrink: 0; }
.badge { padding: 5px 9px; border-radius: 100px; background: #f1f3ee; color: #5c6a5f; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; font-weight: 800; white-space: nowrap; }
.badge.pending { background: #fff4d9; color: #94702b; }
.badge.approved { background: #e7f2e9; color: #397a5c; }
.badge.rejected { background: #fce9e5; color: #aa5b4b; }
.goal-meta { margin: 8px 0 10px 44px; color: var(--muted); font-size: 12px; }
.progress-track { height: 7px; margin-left: 44px; background: #edf0eb; border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: #68a77c; border-radius: inherit; }
.goal-actions { margin: 11px 0 0 44px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 10px 14px; border: 0; border-radius: 12px; background: var(--green); color: white; font-size: 13px; font-weight: 800; text-decoration: none; transition: background .16s, transform .16s, box-shadow .16s; }
.btn:hover { background: var(--green-dark); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.secondary { background: #edf3ed; color: var(--green-dark); }
.btn.secondary:hover { background: #e1ece3; }
.btn.danger { background: #faece9; color: #a55446; }
.btn.tiny { min-height: 42px; padding: 9px 12px; font-size: 12px; }
.btn.text { padding: 7px 0; color: var(--green); background: transparent; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #52635a; font-size: 11px; font-weight: 800; }
.field input, .field textarea, .field select { width: 100%; min-height: 44px; border: 1px solid #e1e7df; border-radius: 12px; padding: 10px 12px; outline: 0; color: var(--ink); background: #fff; font-size: 16px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: #83b295; box-shadow: 0 0 0 3px #e9f3eb; }
.field textarea { min-height: 76px; resize: vertical; }
.form-actions { display: flex; align-items: center; gap: 9px; margin-top: 14px; }
.form-note { min-height: 16px; margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.empty-state { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13px; background: #fbfcfa; border: 1px dashed #dfe6dc; border-radius: 14px; }
.empty-icon { display: block; margin-bottom: 8px; font-size: 27px; }
.review-row, .history-row, .reward-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.review-row:first-child, .history-row:first-child, .reward-row:first-child { border-top: 0; padding-top: 0; }
.review-actions { display: flex; gap: 6px; }
.reward-cost { color: #9b752d; font-weight: 800; white-space: nowrap; }
.reward-row > div:last-child { display: flex; align-items: center; gap: 10px; }
.chart { display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 10px; min-height: 110px; padding-top: 10px; }
.chart-day { display: grid; height: 100%; grid-template-rows: 1fr auto; justify-items: center; gap: 8px; }
.bar-area { width: 100%; height: 76px; display: flex; align-items: flex-end; justify-content: center; }
.bar { width: min(25px, 70%); min-height: 4px; border-radius: 6px 6px 3px 3px; background: #8bb69a; }
.day-label { color: var(--muted); font-size: 10px; }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; gap: 7vw; align-items: center; max-width: 1050px; margin: auto; padding: 50px 30px; }
.auth-story { padding: 18px 0; }
.auth-story h1 { margin-top: 22px; max-width: 490px; }
.auth-story > p { max-width: 440px; color: var(--muted); line-height: 1.7; }
.feature-list { display: grid; gap: 13px; margin-top: 27px; color: #50645a; font-size: 13px; }
.feature-list span { display: flex; align-items: center; gap: 10px; }
.feature-check { width: 23px; height: 23px; display: grid; place-items: center; background: #e2eee5; color: var(--green); border-radius: 50%; font-size: 12px; font-weight: 900; }
.auth-card { padding: 30px; }
.auth-card h2 { font-size: 23px; margin-bottom: 5px; }
.auth-card form { margin-top: 22px; }
.auth-toggle { margin: 17px 0 0; color: var(--muted); text-align: center; font-size: 12px; }
.auth-toggle button { border: 0; background: none; color: var(--green); font-weight: 800; }
.notice { padding: 11px 13px; margin: 12px 0; border-radius: 10px; background: #fff4d9; color: #775f2d; font-size: 12px; line-height: 1.5; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .7px; }
.toast { position: fixed; z-index: 5; right: 22px; bottom: 22px; max-width: min(400px, calc(100% - 44px)); padding: 13px 17px; border-radius: 12px; background: #213c30; color: white; box-shadow: var(--shadow); font-size: 13px; opacity: 0; transform: translateY(9px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #9e4d3f; }
.loading-card { margin: 25vh auto; max-width: 440px; padding: 40px; text-align: center; background: white; border-radius: 22px; color: var(--muted); box-shadow: var(--shadow); }
.divider { height: 1px; background: var(--line); margin: 20px 0; }
.history-tools { display: flex; align-items: center; gap: 10px; }
.history-tools select { border: 1px solid var(--line); border-radius: 9px; padding: 8px; background: white; }
.inactive { opacity: .62; }
.goal-editor { width: min(640px, calc(100% - 32px)); max-width: none; max-height: min(90dvh, 900px); margin: auto; padding: 0; overflow: auto; border: 1px solid #e4e9e1; border-radius: 23px; color: var(--ink); background: #fbfcfa; box-shadow: 0 28px 100px rgba(22, 39, 30, .28); }
.goal-editor::backdrop { background: rgba(20, 38, 29, .48); backdrop-filter: blur(3px); }
.goal-editor form { padding: 25px; }
.editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.editor-head .eyebrow { margin-bottom: 6px; }
.editor-head h2 { font-size: 24px; margin-bottom: 5px; }
.editor-head p:last-child { margin-bottom: 0; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; color: var(--ink); background: #edf2ec; font-size: 27px; line-height: 1; }
.editor-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.editor-fields .field.full { grid-column: 1 / -1; }
.editor-fields [disabled] { color: #65746a; background: #f1f3ef; cursor: not-allowed; }
.editor-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; margin: 15px -25px -25px; padding: 14px 25px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(251, 252, 250, .96); }
.editor-note { color: #a55446; }
.reward-row { flex-wrap: wrap; }
.stat-card { background: linear-gradient(145deg, #fff, #fbfcf9); }
.kid-dashboard .stat-card:first-child { border-color: #dceade; }
.app-shell.kid-dashboard .hero { border-color: #dce9d5; background: radial-gradient(ellipse at 96% 4%, rgba(250, 223, 147, .48), transparent 34%), radial-gradient(ellipse at 2% 100%, rgba(205, 232, 209, .62), transparent 40%), linear-gradient(135deg, #fbfcf7, #f1f8ee); }
.app-shell.kid-dashboard .hero-badge { border-color: #e9dfbd; background: rgba(255, 253, 244, .9); }
.kid-dashboard .goal-icon { background: linear-gradient(145deg, #fff6d9, #eaf4e9); }
.kid-dashboard .progress-fill { background: linear-gradient(90deg, #78b28a, #9bc96e); animation: progress-arrive .55s ease-out both; }
@keyframes progress-arrive { from { width: 0; } }
.btn:active { transform: scale(.98); }

@media (max-width: 820px) {
  .app-shell { width: min(100% - 32px, 680px); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; max-width: 550px; gap: 25px; }
  .auth-story { padding-bottom: 0; }
  .auth-story h1 { font-size: 36px; }
  .hero { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 520px) {
  .app-shell { width: calc(100% - 24px); }
  .topbar { height: 64px; }
  .brand { font-size: 16px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 11px; }
  .top-actions { gap: 6px; }
  .user-label { display: none; }
  .top-actions .btn { min-height: 42px; padding: 8px 11px; }
  .hero { gap: 14px; margin: 15px 0 16px; padding: 20px 17px; border-radius: 18px; }
  .hero h1 { font-size: clamp(28px, 8vw, 35px); letter-spacing: -1.2px; }
  .hero-badge { min-width: 0; width: 100%; padding: 12px 14px; border-radius: 14px; }
  .hero-badge strong { font-size: 16px; }
  .card { padding: 16px; border-radius: 17px; }
  .stats-grid { gap: 9px; margin-bottom: 13px; }
  .stat-card { min-height: 91px; padding: 13px; border-radius: 14px; }
  .stat-label { font-size: 10px; letter-spacing: .35px; }
  .stat-number { margin-top: 5px; font-size: 24px; }
  .stat-card .small { font-size: 10px; }
  .form-grid, .editor-fields { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .editor-fields .field.full { grid-column: auto; }
  .section-head { align-items: flex-start; gap: 9px; }
  .section-head .btn { flex-shrink: 0; }
  .goal-card { padding: 17px 0; }
  .goal-name { min-width: 0; }
  .goal-name > div { min-width: 0; }
  .goal-name h3 { line-height: 1.3; overflow-wrap: anywhere; }
  .goal-top { gap: 8px; }
  .goal-meta { margin: 11px 0 10px; line-height: 1.5; }
  .progress-track { margin-left: 0; height: 9px; }
  .goal-actions { margin: 12px 0 0; gap: 8px; }
  .goal-actions .btn { flex: 1 1 auto; }
  .badge { white-space: normal; line-height: 1.35; }
  .child-heading { min-width: 0; }
  .points { font-size: 13px; }
  .reward-row { align-items: flex-start; flex-direction: column; padding: 14px 0; }
  .reward-row > div:last-child { width: 100%; justify-content: space-between; }
  .review-row { align-items: stretch; flex-direction: column; gap: 9px; padding: 14px 0; }
  .review-actions { width: 100%; }
  .review-actions .btn { flex: 1; }
  .history-row { align-items: flex-start; }
  .auth-wrap { min-height: 100svh; gap: 16px; padding: 18px 14px max(24px, env(safe-area-inset-bottom)); }
  .auth-story { padding-top: 0; }
  .auth-story > .brand { margin-bottom: 18px; }
  .auth-story > p.eyebrow { margin-top: 10px !important; }
  .auth-story h1 { margin-top: 9px; font-size: 32px; }
  .auth-story > p:not(.eyebrow) { font-size: 14px; margin-bottom: 0; }
  .feature-list { display: none; }
  .auth-card { padding: 20px; }
  .auth-card form { margin-top: 16px; }
  .form-actions .btn { width: 100%; }
  .goal-editor { position: fixed; inset: auto 0 0; width: 100%; max-width: none; max-height: 92dvh; margin: 0; border-radius: 23px 23px 0 0; border-bottom: 0; }
  .goal-editor form { padding: 20px 17px 0; }
  .editor-head { margin-bottom: 14px; }
  .editor-fields { gap: 11px; }
  .editor-actions { margin: 14px -17px 0; padding: 12px 17px max(12px, env(safe-area-inset-bottom)); }
  .editor-actions .btn { flex: 1; }
  .toast { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  th, td { padding: 10px 8px; }
}
@media (max-width: 360px) {
  .user-pill .avatar { width: 30px; height: 30px; }
  .app-shell { width: calc(100% - 18px); }
  .hero { padding: 17px 14px; }
  .card { padding: 14px; }
  .stats-grid { gap: 7px; }
  .stat-card { padding: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
