:root {
  --accent: #6C5CE7;
  --accent-2: #A29BFE;
  --bg-start: #F5F3FF;
  --bg-end: #ECE9FF;
  --positive: #00B894;
  --negative: #E17055;
  --text: #2D3436;
  --text-soft: #636E72;
  --card-bg: #FFFFFF;
  --radius: 18px;
  --shadow: 0 6px 20px rgba(108,92,231,0.15);
}

[data-dark="true"] {
  --bg-start: #14121f;
  --bg-end: #1c1830;
  --card-bg: #241f38;
  --text: #F1F0FB;
  --text-soft: #B8B3D6;
  --shadow: 0 6px 20px rgba(0,0,0,0.4);
}

/* Child themes (applied when viewing a child context) */
.theme-nino {
  --accent: #3B82F6;
  --accent-2: #60A5FA;
  --bg-start: #EAF3FF;
  --bg-end: #DCEBFF;
}
.theme-nina {
  --accent: #E85CB0;
  --accent-2: #F4A6DA;
  --bg-start: #FFEFFA;
  --bg-end: #FBE1F4;
}
.theme-neutro {
  --accent: #16A085;
  --accent-2: #63D2B8;
  --bg-start: #E9FBF6;
  --bg-end: #DAF7EC;
}
[data-dark="true"].theme-nino { --bg-start:#0f1b2e; --bg-end:#132238; }
[data-dark="true"].theme-nina { --bg-start:#2a1524; --bg-end:#341a2e; }
[data-dark="true"].theme-neutro { --bg-start:#0f2620; --bg-end:#123027; }

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  overscroll-behavior: none;
}
body {
  background: linear-gradient(160deg, var(--bg-start), var(--bg-end));
  min-height: 100vh;
  transition: background 0.4s ease;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* App bar */
#app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px calc(10px + env(safe-area-inset-top, 0px));
  padding-top: max(14px, env(safe-area-inset-top));
}
#app-bar h1 {
  font-size: 18px;
  margin: 0;
  color: var(--accent);
  font-weight: 800;
}
.icon-btn {
  background: var(--card-bg);
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
#btn-back { visibility: hidden; }
#btn-back.show { visibility: visible; }

#screens { flex: 1; padding: 4px 18px 100px; }

.screen { display: none; animation: fadeIn 0.25s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: translateY(0);} }

h2 { font-size: 22px; margin: 8px 0 4px; }
h3 { font-size: 16px; color: var(--text-soft); margin: 18px 0 8px; }
.subtitle, .hint { color: var(--text-soft); font-size: 14px; }

/* Welcome */
.welcome-hero { text-align: center; margin-top: 12vh; }
.welcome-logo { font-size: 64px; }
.welcome-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 40px; }

/* Buttons */
.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; box-shadow: var(--shadow); }
.btn-secondary { background: var(--card-bg); color: var(--accent); border: 2px solid var(--accent); }
.btn-outline { background: transparent; color: var(--accent); border: 2px dashed var(--accent-2); width: 100%; }
.btn-danger { background: #FDECEA; color: #D63031; }
.btn-lg { width: 100%; padding: 16px; font-size: 16px; border-radius: 16px; }
.link-btn { background: none; border: none; color: var(--text-soft); text-decoration: underline; font-size: 13px; cursor: pointer; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.form label { font-size: 13px; color: var(--text-soft); font-weight: 600; display: flex; flex-direction: column; gap: 6px; }
input[type="text"], input[type="number"], input[type="color"], input[type="date"], select, textarea {
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid #E0DBF5;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
}
textarea { min-height: 70px; resize: vertical; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.theme-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-swatch {
  border: 2px solid #E0DBF5; background: var(--card-bg); border-radius: 12px;
  padding: 8px 10px; font-size: 13px; cursor: pointer;
}
.theme-swatch.selected { border-color: var(--accent); background: var(--accent); color: white; }

.segmented { display: flex; gap: 8px; }
.seg-btn { flex:1; border: 2px solid #E0DBF5; background: var(--card-bg); border-radius: 12px; padding: 10px; cursor: pointer; font-weight: 700; }
.seg-btn.active[data-sign="positive"] { background: var(--positive); border-color: var(--positive); color: white; }
.seg-btn.active[data-sign="negative"] { background: var(--negative); border-color: var(--negative); color: white; }

.checkbox-row { flex-direction: row !important; align-items: center; gap: 8px !important; }

/* Parent home */
.parent-home-header { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.badge { background: var(--card-bg); box-shadow: var(--shadow); padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 700; color: var(--accent); }

.children-list { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.child-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); cursor: pointer;
  border-left: 6px solid var(--accent);
}
.child-card .avatar { font-size: 34px; }
.child-card .info { flex: 1; }
.child-card .info .name { font-weight: 800; font-size: 16px; }
.child-card .info .balance { color: var(--text-soft); font-size: 13px; }
.child-card .chevron { color: var(--text-soft); }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.qa-card {
  background: var(--card-bg); border: none; border-radius: 16px; padding: 16px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px;
  box-shadow: var(--shadow); cursor: pointer; font-weight: 700; color: var(--text);
  position: relative;
}
.qa-card span { font-size: 13px; }
.qa-badge {
  position: absolute; top: 8px; right: 8px; background: var(--negative); color: white;
  font-size: 11px; font-weight: 800; border-radius: 10px; min-width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.qa-badge.hidden { display: none; }

/* PIN */
.parent-select { display: flex; gap: 10px; margin: 14px 0; justify-content: center; }
.parent-chip {
  padding: 10px 16px; border-radius: 20px; border: 2px solid var(--accent); background: var(--card-bg);
  font-weight: 700; cursor: pointer; color: var(--accent);
}
.parent-chip.active { background: var(--accent); color: white; }
.pin-pad-wrap { display: flex; flex-direction: column; align-items: center; margin-top: 20px; }
.pin-dots { display: flex; gap: 14px; margin-bottom: 24px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent); display: inline-block; }
.pin-dots span.filled { background: var(--accent); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 70px); gap: 14px; }
.pin-pad button {
  width: 70px; height: 70px; border-radius: 50%; border: none; background: var(--card-bg);
  font-size: 20px; font-weight: 700; box-shadow: var(--shadow); cursor: pointer; color: var(--text);
}
.pin-error { color: var(--negative); font-weight: 700; height: 20px; }

/* Score flow */
.score-child-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-weight: 800; font-size: 17px; }
.score-child-header .avatar { font-size: 28px; }
.step { margin-top: 16px; }
.step.hidden { display: none; }
.step-label { font-weight: 800; margin-bottom: 8px; }
.sign-buttons { display: flex; gap: 12px; }
.sign-btn {
  flex: 1; border: none; border-radius: 18px; padding: 22px 10px; display: flex; flex-direction: column;
  align-items: center; gap: 8px; font-weight: 800; font-size: 15px; cursor: pointer; box-shadow: var(--shadow);
}
.sign-btn.positive { background: rgba(0,184,148,0.15); color: var(--positive); }
.sign-btn.negative { background: rgba(225,112,85,0.15); color: var(--negative); }
.sign-btn.selected.positive { background: var(--positive); color: white; }
.sign-btn.selected.negative { background: var(--negative); color: white; }
.sign-emoji { font-size: 30px; }

.points-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  padding: 10px 16px; border-radius: 20px; border: 2px solid var(--accent-2); background: var(--card-bg);
  font-weight: 700; cursor: pointer; color: var(--accent);
}
.chip.selected { background: var(--accent); color: white; border-color: var(--accent); }

#motivo-search { width: 100%; margin-bottom: 10px; }
.motivo-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.motivo-cat-label { font-size: 12px; font-weight: 800; color: var(--text-soft); text-transform: uppercase; margin-top: 6px; }
.motivo-item {
  text-align: left; padding: 12px 14px; border-radius: 14px; border: none; background: var(--card-bg);
  box-shadow: var(--shadow); cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; color: var(--text); width: 100%;
}
.motivo-item .fav { color: #FDCB6E; }
.motivo-item.selected { outline: 3px solid var(--accent); }
.motivo-item.personalizar { margin-top: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; font-weight: 700; justify-content: center; }
#personalizar-box { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
#personalizar-box.hidden { display: none; }
#custom-date-input.hidden { display: none; }
#custom-date-input { width: 100%; margin-top: 8px; }

.confirm-summary { background: var(--card-bg); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); text-align: center; margin-bottom: 16px; }
.confirm-summary .big-points { font-size: 40px; font-weight: 900; }
.confirm-summary .motivo-text { color: var(--text-soft); margin-top: 6px; }
.confirm-summary .who { margin-top: 10px; font-size: 13px; color: var(--text-soft); }

/* Concepts / rewards lists */
.concept-form-wrap { background: var(--card-bg); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin: 12px 0; }
.concept-form-wrap.hidden { display: none; }
.concepts-list, .rewards-list, .family-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.concept-row, .reward-row, .family-row {
  background: var(--card-bg); border-radius: 14px; padding: 12px 14px; display: flex; align-items: center;
  gap: 10px; box-shadow: var(--shadow);
}
.concept-row .sign-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.sign-dot.positive { background: var(--positive); }
.sign-dot.negative { background: var(--negative); }
.concept-row .cat { font-size: 11px; color: var(--text-soft); }
.concept-row .main, .reward-row .main, .family-row .main { flex: 1; }
.concept-row .points-pill { font-weight: 800; font-size: 13px; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { border: none; background: #F1EFFE; border-radius: 8px; padding: 6px 8px; cursor: pointer; }
.star-toggle { background: none; border: none; font-size: 16px; cursor: pointer; }

.reward-row .icon { font-size: 26px; }
.reward-row .cost { font-weight: 800; color: var(--accent); font-size: 13px; }

/* Tarjetas de premios (modo padres) */
.rewards-list {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px;
}
.rewards-list > .hint { grid-column: 1 / -1; }
.reward-card {
  background: var(--card-bg); border-radius: 18px; padding: 14px 10px 10px;
  box-shadow: var(--shadow); text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 4px; border: 2px solid transparent;
}
.reward-card.available { border-color: var(--positive); }
.reward-card-icon { font-size: 40px; line-height: 1.1; }
.reward-card-name { font-weight: 800; font-size: 14px; line-height: 1.25; }
.reward-card-desc { font-size: 11px; color: var(--text-soft); }
.reward-card-cost {
  background: var(--accent); color: white; font-weight: 800; font-size: 12px;
  padding: 4px 12px; border-radius: 20px; margin-top: 4px;
}
.reward-card-actions { display: flex; gap: 6px; margin-top: 8px; }
.reward-card-actions button {
  border: none; background: #F1EFFE; border-radius: 10px; padding: 6px 9px; cursor: pointer; font-size: 14px;
}
.reward-card-actions button[disabled] { opacity: 0.35; cursor: default; }
[data-dark="true"] .reward-card-actions button { background: rgba(255,255,255,0.08); }

/* Colores por categoría */
.cat-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.cat-tag {
  display: inline-block; color: white; font-size: 10px; font-weight: 800;
  padding: 2px 7px; border-radius: 8px; margin-right: 6px;
}

/* Reports */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row .label { width: 90px; font-size: 12px; color: var(--text-soft); }
.bar-track { flex: 1; background: #ECE9FF; border-radius: 10px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 10px; }
.bar-fill.positive { background: var(--positive); }
.bar-fill.negative { background: var(--negative); }
.report-summary-card { background: var(--card-bg); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.parent-split { display: flex; gap: 16px; margin-top: 10px; }
.parent-split div { flex: 1; text-align: center; }
.parent-split .num { font-size: 24px; font-weight: 900; color: var(--accent); }

/* Child select */
.child-select-list { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.child-select-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 20px; text-align: center;
  box-shadow: var(--shadow); cursor: pointer; border: 3px solid transparent;
}
.child-select-card .avatar { font-size: 44px; }
.child-select-card .name { font-weight: 800; font-size: 17px; margin-top: 6px; }

/* Child home */
.child-home-top { padding-top: 4px; }
.child-hero { text-align: center; margin-top: 6px; }
.child-avatar-big {
  font-size: 64px; width: 110px; height: 110px; border-radius: 50%; background: var(--card-bg);
  display: flex; align-items: center; justify-content: center; margin: 0 auto; box-shadow: var(--shadow);
}
.child-motivational { color: var(--text-soft); font-size: 13px; margin: 6px 0 14px; }
.balance-big { font-size: 56px; font-weight: 900; color: var(--accent); line-height: 1; }
.balance-label { color: var(--text-soft); margin-top: 2px; font-size: 13px; }

/* Tarjetas de objetivos (modo hijo/a) */
.goals-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.goal-card {
  background: var(--card-bg); border-radius: 18px; padding: 14px 10px 10px; box-shadow: var(--shadow);
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 2px solid transparent; position: relative;
}
.goal-card.unlocked { border-color: var(--positive); }
.goal-card-icon { font-size: 40px; line-height: 1.1; }
.goal-card-name { font-weight: 800; font-size: 13px; line-height: 1.25; }
.goal-card-progress { width: 100%; margin-top: 4px; }
.goal-card-points { font-size: 11px; color: var(--text-soft); font-weight: 700; margin-top: 4px; }
.goal-unlocked-tag {
  position: absolute; top: -8px; right: -4px; background: var(--positive); color: white;
  font-size: 10px; padding: 3px 8px; border-radius: 10px; font-weight: 800; box-shadow: var(--shadow);
}
.goal-request-row { margin-top: 8px; width: 100%; }
.btn-request {
  width: 100%; border: none; border-radius: 12px; padding: 9px 6px; font-weight: 700; font-size: 12px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; line-height: 1.2;
}
.btn-request[disabled] { background: #E3E0F5; color: var(--text-soft); cursor: default; }
[data-dark="true"] .btn-request[disabled] { background: rgba(255,255,255,0.08); }
.btn-request.rejected { background: var(--negative); }

/* Reward requests (parent screen) */
.request-row { flex-wrap: wrap; }
.request-row .req-info { flex: 1; min-width: 160px; }
.request-row .req-child { font-size: 12px; color: var(--text-soft); }
.request-row .req-actions { display: flex; gap: 8px; }
.btn-approve, .btn-reject {
  border: none; border-radius: 10px; padding: 8px 12px; font-weight: 800; font-size: 13px; cursor: pointer; color: white;
}
.btn-approve { background: var(--positive); }
.btn-reject { background: var(--negative); }
.request-status { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 10px; }
.request-status.approved { background: rgba(0,184,148,0.15); color: var(--positive); }
.request-status.rejected { background: rgba(225,112,85,0.15); color: var(--negative); }
.request-cost-input { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.request-cost-input input { width: 80px; padding: 8px; }
.request-locked-hint { font-size: 11px; color: var(--text-soft); margin: 8px 0 0; font-weight: 700; }

/* Custom reward request (child mode) */
.custom-request-card { background: var(--card-bg); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); margin-top: 16px; }
.custom-request-row { display: flex; gap: 8px; margin-bottom: 10px; }
.custom-request-row input#custom-request-icon { width: 60px; text-align: center; flex-shrink: 0; }
.custom-request-row input#custom-request-name { flex: 1; }
#custom-request-form.hidden { display: none; }
#custom-request-form { margin-top: 10px; }

/* Sincronización */
#sync-active-box.hidden { display: none; }
.sync-code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 24px; font-weight: 900; letter-spacing: 3px; text-align: center;
  color: var(--accent); background: rgba(108,92,231,0.10);
  border-radius: 12px; padding: 12px; margin: 6px 0 10px; word-break: break-all;
}
.sync-status { font-size: 13px; color: var(--text-soft); margin: 10px 0; }
.sync-status.ok { color: var(--positive); font-weight: 700; }
.sync-status.error { color: var(--negative); font-weight: 700; }

.history-header { display: flex; justify-content: space-between; align-items: center; }
.history-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.history-item { background: var(--card-bg); border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; }
.history-item .points-tag { font-weight: 900; font-size: 15px; min-width: 42px; text-align: center; }
.history-item .points-tag.positive { color: var(--positive); }
.history-item .points-tag.negative { color: var(--negative); }
.history-item .details { flex: 1; }
.history-item .details .motivo { font-size: 13px; font-weight: 600; }
.history-item .details .meta { font-size: 11px; color: var(--text-soft); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #2D3436; color: white; padding: 12px 20px; border-radius: 30px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3); z-index: 999; max-width: 90%; text-align: center;
}
.toast.hidden { display: none; }

/* Confetti */
#confetti-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 998; }
.confetti-piece { position: absolute; top: -10px; border-radius: 2px; animation: confettiFall linear forwards; }
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.3; }
}

@media (min-width: 480px) {
  #app { border-left: 1px solid rgba(0,0,0,0.05); border-right: 1px solid rgba(0,0,0,0.05); }
}
