/* Save Up Money · estilos */
:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --line: #e2e5df;
  --ink: #111512;
  --ink-2: #4b544d;
  --ink-3: #7f8981;
  --accent: #0e8f5f;
  --accent-ink: #ffffff;
  --accent-soft: #dff3ea;
  --danger: #c4372f;
  --danger-soft: #fbe6e4;
  --track: #e3e7e2;
  --shadow: 0 1px 2px rgba(17, 21, 18, .05), 0 8px 24px rgba(17, 21, 18, .06);
  --radius: 20px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0c0b;
    --surface: #151816;
    --surface-2: #1d211e;
    --line: #262b27;
    --ink: #f1f4f1;
    --ink-2: #b4bdb6;
    --ink-3: #7c867e;
    --accent: #34d399;
    --accent-ink: #062418;
    --accent-soft: #10291f;
    --danger: #f2766d;
    --danger-soft: #2c1513;
    --track: #262b27;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0c0b;
  --surface: #151816;
  --surface-2: #1d211e;
  --line: #262b27;
  --ink: #f1f4f1;
  --ink-2: #b4bdb6;
  --ink-3: #7c867e;
  --accent: #34d399;
  --accent-ink: #062418;
  --accent-soft: #10291f;
  --danger: #f2766d;
  --danger-soft: #2c1513;
  --track: #262b27;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  transition: background .25s ease, color .25s ease;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.hidden { display: none !important; }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 32px);
}

/* ---------- logo ---------- */
.logo {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 12.5px;
  letter-spacing: -0.02em;
  flex: none;
}
.logo.lg { width: 76px; height: 76px; border-radius: 22px; font-size: 26px; }

/* ---------- barra superior ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 6px 0 14px; }
.topbar h1 { font-size: 17px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -0.01em; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--ink-2);
  box-shadow: var(--shadow);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(.95); }

/* ---------- chip de tasa ---------- */
.rate-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-radius: 999px;
  padding: 8px 8px 8px 14px; margin-bottom: 14px;
  font-size: 13.5px; color: var(--ink-2);
  box-shadow: var(--shadow);
}
.rate-chip strong { color: var(--ink); font-weight: 650; }
.rate-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.rate-chip .dot.stale { background: #d8a106; }
.rate-chip .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate-chip button { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-3); }
.rate-chip button svg { width: 16px; height: 16px; }
.rate-chip button.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tarjetas ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.hero { padding: 22px 20px; margin-bottom: 22px; }
.label { font-size: 13px; color: var(--ink-3); font-weight: 550; text-transform: uppercase; letter-spacing: .04em; }
.big { font-size: 40px; font-weight: 750; letter-spacing: -0.035em; line-height: 1.1; margin: 6px 0 2px; }
.sub { font-size: 15px; color: var(--ink-2); }
.hero .meta-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-3); margin-top: 8px; }

.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; margin-top: 16px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); width: 0; transition: width .6s cubic-bezier(.2,.8,.2,1); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 10px; }
.section-head h2 { font-size: 20px; margin: 0; letter-spacing: -0.02em; }

.goal-list { display: grid; gap: 10px; }
.goal {
  display: block; width: 100%; text-align: left;
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.goal:active { transform: scale(.985); }
.goal-top { display: flex; align-items: center; gap: 12px; }
.emoji {
  width: 44px; height: 44px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-size: 22px;
  background: var(--surface-2);
}
.goal-name { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-amounts { font-size: 14px; color: var(--ink-2); }
.goal-amounts b { color: var(--ink); font-weight: 650; }
.pct { margin-left: auto; font-weight: 700; font-size: 15px; color: var(--accent); }
.goal .bar { margin-top: 12px; height: 6px; }
.goal-bs { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }
.done-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); margin-left: 6px; vertical-align: 2px; }

.empty { text-align: center; padding: 34px 20px; color: var(--ink-2); }
.empty .emoji { margin: 0 auto 12px; width: 60px; height: 60px; font-size: 30px; border-radius: 18px; }
.empty h3 { margin: 0 0 4px; color: var(--ink); font-size: 17px; }
.empty p { margin: 0 0 16px; font-size: 14.5px; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 50px; padding: 0 20px; border-radius: 15px;
  font-weight: 650; font-size: 16px;
  background: var(--accent); color: var(--accent-ink);
  transition: transform .1s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; }
.btn.block { width: 100%; }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { height: 36px; padding: 0 14px; font-size: 14.5px; border-radius: 11px; }
.btn svg { width: 18px; height: 18px; }

/* ---------- detalle de meta ---------- */
.detail-head { display: flex; align-items: center; gap: 10px; padding: 6px 0 16px; }
.detail-head h1 { flex: 1; font-size: 17px; margin: 0; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ring-wrap { position: relative; width: 200px; height: 200px; margin: 4px auto 14px; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-wrap .ring-track { stroke: var(--track); }
.ring-wrap .ring-fill { stroke: var(--accent); transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-center .e { font-size: 34px; line-height: 1; }
.ring-center .p { font-size: 30px; font-weight: 750; letter-spacing: -0.03em; margin-top: 6px; }
.ring-center .t { font-size: 12.5px; color: var(--ink-3); }

.detail-amount { text-align: center; }
.detail-amount .big { font-size: 36px; }
.remaining { text-align: center; font-size: 14px; color: var(--ink-3); margin: 8px 0 18px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }

.chart-card { margin-bottom: 18px; padding: 16px 14px 10px; }
.chart-card .label { padding: 0 4px; }
.chart { position: relative; margin-top: 10px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: 170px; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis-t { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .area { fill: var(--accent); opacity: .12; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .target { stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .target-t { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.tip {
  position: absolute; top: -6px; pointer-events: none;
  background: var(--ink); color: var(--bg);
  font-size: 12px; padding: 6px 9px; border-radius: 9px; white-space: nowrap;
  transform: translateX(-50%); opacity: 0; transition: opacity .12s;
}
.tip.on { opacity: 1; }
.chart-empty { font-size: 14px; color: var(--ink-3); text-align: center; padding: 26px 0; }

.history { padding: 6px 0; }
.history .label { padding: 12px 18px 4px; }
.mov { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); }
.mov:first-of-type { border-top: 0; }
.mov-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.mov-ic svg { width: 18px; height: 18px; }
.mov-ic.in { background: var(--accent-soft); color: var(--accent); }
.mov-ic.out { background: var(--danger-soft); color: var(--danger); }
.mov-body { flex: 1; min-width: 0; }
.mov-t { font-weight: 600; font-size: 15px; }
.mov-s { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mov-amt { text-align: right; font-weight: 650; font-size: 15px; }
.mov-amt small { display: block; font-weight: 500; font-size: 12px; color: var(--ink-3); }
.mov-amt.out { color: var(--danger); }
.mov-del { color: var(--ink-3); width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; }
.mov-del svg { width: 16px; height: 16px; }

/* ---------- formularios ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin: 0 2px 6px; }
.input {
  width: 100%; height: 52px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface-2);
  padding: 0 14px; font-size: 17px; outline: none;
  transition: border-color .15s, background .15s;
}
.input:focus { border-color: var(--accent); background: var(--surface); }
.amount-input { height: 72px; font-size: 34px; font-weight: 700; text-align: center; letter-spacing: -0.02em; }
.convert { text-align: center; font-size: 15px; color: var(--ink-2); margin: -4px 0 16px; min-height: 21px; }
.convert b { color: var(--ink); }
.hint { font-size: 13px; color: var(--ink-3); margin: 6px 2px 0; }
.error { background: var(--danger-soft); color: var(--danger); padding: 11px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 14px; }

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface-2); padding: 4px; border-radius: 13px; margin-bottom: 14px;
}
.segmented button { height: 38px; border-radius: 10px; font-weight: 600; font-size: 14.5px; color: var(--ink-2); transition: background .15s, color .15s; }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.emoji-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px 10px; scrollbar-width: none; }
.emoji-row::-webkit-scrollbar { display: none; }
.emoji-row button { width: 46px; height: 46px; flex: none; border-radius: 14px; font-size: 22px; background: var(--surface-2); border: 2px solid transparent; }
.emoji-row button.on { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- autenticación ---------- */
.auth { min-height: calc(100dvh - 60px); display: flex; flex-direction: column; justify-content: center; padding: 20px 4px; }
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand h1 { font-size: 28px; margin: 16px 0 4px; letter-spacing: -0.03em; }
.auth-brand p { margin: 0; color: var(--ink-2); font-size: 15px; }
.link { color: var(--accent); font-weight: 600; }
.auth-switch { text-align: center; font-size: 14.5px; color: var(--ink-2); margin-top: 16px; }

/* ---------- hoja inferior (modal) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  opacity: 0; transition: opacity .25s; z-index: 40;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 520px; margin: 0 auto;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(env(safe-area-inset-bottom) + 20px);
  transform: translateY(100%); transition: transform .32s cubic-bezier(.2,.8,.2,1);
  max-height: 92dvh; overflow-y: auto;
}
.sheet.open { transform: translateY(0); }
.sheet-backdrop.open { opacity: 1; }
.grabber { width: 38px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { font-size: 20px; margin: 0 0 16px; letter-spacing: -0.02em; text-align: center; }
.sheet .row { display: flex; gap: 10px; }
.sheet .row > * { flex: 1; }
.settings-group { background: var(--surface-2); border-radius: 16px; margin-bottom: 14px; overflow: hidden; }
.settings-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-size: 15px; }
.settings-item + .settings-item { border-top: 1px solid var(--line); }
.settings-item span:last-child { color: var(--ink-3); }

/* ---------- aviso instalar ---------- */
.install {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--accent-soft); color: var(--ink);
  border-radius: 16px; padding: 12px 12px 12px 14px; margin-bottom: 14px; font-size: 13.5px;
}
.install p { margin: 0; flex: 1; }
.install button { color: var(--ink-3); width: 26px; height: 26px; display: grid; place-items: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--bg);
  padding: 11px 18px; border-radius: 99px; font-size: 14.5px; font-weight: 550;
  transition: opacity .2s, transform .25s; z-index: 60; pointer-events: none; white-space: nowrap;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.view { animation: fadein .28s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.loading { text-align: center; color: var(--ink-3); padding: 60px 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.credit { text-align: center; font-size: 12px; color: var(--ink-3); margin: 22px 0 0; }
