/* ── Legado · estilos ──────────────────────────────────────────────
   Dirección de diseño: no es un dashboard financiero frío.
   Verde profundo (calma, crecimiento), papel cálido, acento "brasa"
   para el gusto. El gesto central: PARTIR un ingreso.

   Los colores viven en variables para soportar tema claro/oscuro.
   El tema se fija con [data-theme] en <html>.                    */

:root {
  /* Texto y marca */
  --ink: #23241F;
  --brand: #0E5240;
  --muted: #6B6A62;
  --faint: #8A897F;
  --fainter: #9A998E;
  --placeholder: #B6B2A4;

  /* Superficies */
  --page-bg: #EFEBE0;
  --card-bg: #FBF8F1;
  --surface: #F4F0E6;
  --surface-2: #F6F2E9;
  --pill-bg: #F0ECE1;
  --input-bg: #FFFDF8;

  /* Ancla "Mi legado" */
  --anchor-bg: #EAF1ED;
  --anchor-border: #D5E3DB;
  --anchor-text: #4E6B60;

  /* Bordes */
  --border: #EEE9DC;
  --border-strong: #E2DCCD;

  /* Botón principal */
  --primary-bg: #0E5240;
  --primary-text: #FBF8F1;

  /* Acento brasa (acciones destructivas, gusto) */
  --ember: #C2562B;

  --shell-shadow: 0 1px 0 rgba(0,0,0,.04), 0 24px 60px -24px rgba(40,50,40,.28);
}

[data-theme="dark"] {
  --ink: #ECE7DA;
  --brand: #7CC2A6;
  --muted: #AEAFA2;
  --faint: #94958A;
  --fainter: #7E7F74;
  --placeholder: #5C5E52;

  --page-bg: #0F1210;
  --card-bg: #1A1E18;
  --surface: #23271F;
  --surface-2: #21251D;
  --pill-bg: #262A21;
  --input-bg: #1E221A;

  --anchor-bg: #17241E;
  --anchor-border: #2C3F35;
  --anchor-text: #A6C2B6;

  --border: #2B2F26;
  --border-strong: #383C32;

  --primary-bg: #1F7D60;
  --primary-text: #F3F1E9;

  --ember: #DB7E54;

  --shell-shadow: 0 1px 0 rgba(0,0,0,.2), 0 24px 60px -24px rgba(0,0,0,.6);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; background: var(--page-bg); }

body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--ink);
}

.page {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--page-bg);
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  transition: background .25s ease;
}

.shell {
  width: 100%;
  max-width: 440px;
  background: var(--card-bg);
  border-radius: 24px;
  padding: 26px 24px 30px;
  box-shadow: var(--shell-shadow);
  align-self: flex-start;
  transition: background .25s ease;
}

/* Boot / carga */
.boot { text-align: center; padding: 60px 0; }
.boot-mark { font-family: 'Fraunces', Georgia, serif; font-size: 30px; font-weight: 600; color: var(--brand); }
.boot-sub { font-size: 13px; color: var(--fainter); margin-top: 8px; }

/* ── Header ── */
.header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 500; margin-bottom: 4px; }
.h1 { font-family: 'Fraunces', Georgia, serif; font-size: 34px; font-weight: 600; margin: 0; letter-spacing: -.01em; color: var(--brand); }

.header-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { border: 1px solid var(--border-strong); background: transparent; border-radius: 10px; padding: 6px 10px; cursor: pointer; font-family: inherit; color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--surface); }

/* ── Mi legado (ancla de propósito) ── */
.anchor-card { width: 100%; text-align: left; background: var(--anchor-bg); border: 1px solid var(--anchor-border); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px; cursor: pointer; font-family: inherit; }
.anchor-top { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; color: var(--brand); }
.anchor-label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); font-weight: 600; }
.anchor-empty { font-size: 14px; color: var(--anchor-text); line-height: 1.5; }
.dream-list { display: grid; gap: 6px; }
.dream-row { display: flex; gap: 8px; font-size: 14px; align-items: baseline; }
.dream-who { color: var(--anchor-text); min-width: 96px; font-weight: 500; }
.dream-what { color: var(--ink); }
.dream-more { font-size: 13px; color: var(--faint); margin-top: 2px; }

/* ── Botones ── */
.primary { width: 100%; display: flex; align-items: center; justify-content: center; gap: 9px; background: var(--primary-bg); color: var(--primary-text); border: none; border-radius: 14px; padding: 16px 18px; font-size: 16px; font-weight: 600; cursor: pointer; margin-bottom: 22px; font-family: inherit; }
.primary:disabled { cursor: default; }

.secondary, .danger { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; background: transparent; border: 1px solid var(--border-strong); border-radius: 14px; padding: 14px 18px; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; }
.secondary { color: var(--brand); }
.danger { color: var(--ember); }
.secondary:hover, .danger:hover { background: var(--surface); }
.btn-row { display: flex; gap: 10px; margin-top: 18px; }
.btn-row > * { flex: 1; margin-bottom: 0; }

/* ── Stats: racha / colchón / deuda ── */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 26px; }
.stat { background: var(--surface); border-radius: 14px; padding: 12px 12px 13px; }
.stat-top { display: flex; align-items: center; gap: 5px; margin-bottom: 7px; }
.stat-label { font-size: 11.5px; color: var(--faint); font-weight: 500; }
.stat-big { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 600; line-height: 1; color: var(--ink); }
.stat-sub { font-size: 11px; color: var(--fainter); margin-top: 3px; }

/* ── Histórico ── */
.hist-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.hist-title { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.hist-count { font-size: 12px; color: var(--fainter); background: var(--pill-bg); border-radius: 20px; padding: 1px 8px; }
.empty { font-size: 14px; color: var(--muted); line-height: 1.6; background: var(--surface-2); border-radius: 12px; padding: 16px; }

.entry-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.entry-row.clickable { cursor: pointer; }
.entry-row.clickable:hover { background: var(--surface); margin: 0 -10px; padding: 11px 10px; border-radius: 8px; border-bottom-color: transparent; }
.entry-amt { font-size: 15px; font-weight: 600; color: var(--ink); }
.entry-date { font-size: 12px; color: var(--fainter); margin-top: 2px; }
.entry-bar { display: flex; border-radius: 4px; overflow: hidden; max-width: 150px; margin-left: auto; gap: 1px; flex: 1; }
.entry-bar > div { height: 6px; }
.entry-chev { color: var(--placeholder); display: inline-flex; flex: none; }

.footnote { font-size: 12.5px; color: var(--fainter); line-height: 1.6; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); font-style: italic; }
.footnote-small { font-size: 12.5px; color: var(--fainter); line-height: 1.55; margin-top: 14px; text-align: center; }

/* ── Navegación atrás ── */
.back-btn { display: flex; align-items: center; gap: 4px; background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 0; margin-bottom: 18px; font-family: inherit; }

/* ── Entry (monto) ── */
.entry-wrap { padding-top: 8px; }
.amount-field { display: flex; align-items: center; gap: 6px; margin-top: 14px; padding-bottom: 14px; border-bottom: 2px solid var(--brand); }
.amount-cur { font-family: 'Fraunces', serif; font-size: 32px; color: var(--placeholder); }
.amount-input { flex: 1; border: none; outline: none; background: transparent; font-family: 'Fraunces', serif; font-size: 40px; font-weight: 600; color: var(--ink); width: 100%; }
.amount-preview { font-size: 14px; color: var(--faint); margin-top: 12px; min-height: 20px; }

/* ── Reveal (el gesto de partir) / detalle de movimiento ── */
.reveal-head { margin-bottom: 16px; }
.reveal-list { display: grid; gap: 8px; }
.reveal-row { display: flex; justify-content: space-between; align-items: center; background: var(--surface-2); border-radius: 0 12px 12px 0; padding: 13px 15px; opacity: 0; transform: translateX(-12px); transition: opacity .45s cubic-bezier(.2,.7,.2,1), transform .45s cubic-bezier(.2,.7,.2,1); }
.reveal-row.shown { opacity: 1; transform: translateX(0); }
.reveal-left { display: flex; align-items: center; gap: 11px; }
.reveal-label { font-size: 15px; font-weight: 600; color: var(--ink); }
.reveal-hint { font-size: 12.5px; color: var(--fainter); margin-top: 1px; }
.reveal-val { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 600; }

/* ── Detalle de movimiento ── */
.mv-amount { font-family: 'Fraunces', serif; font-size: 32px; font-weight: 600; color: var(--ink); line-height: 1.1; margin-top: 4px; }
.mv-date { font-size: 13px; color: var(--fainter); margin-top: 4px; }
.mv-edited { font-size: 12px; color: var(--faint); margin-top: 6px; font-style: italic; }
.confirm-box { margin-top: 18px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.confirm-text { font-size: 14px; color: var(--ink); line-height: 1.5; }
.confirm-box .btn-row { margin-top: 14px; }

/* ── Dreams / Settings ── */
.dreams-intro { font-size: 14px; color: var(--muted); line-height: 1.6; margin-top: 8px; }
.dream-edit { margin-bottom: 14px; }
.dream-edit-who { display: block; font-size: 12.5px; color: var(--brand); font-weight: 600; margin-bottom: 5px; letter-spacing: .03em; }
.dream-input { width: 100%; border: 1px solid var(--border-strong); border-radius: 10px; padding: 11px 13px; font-size: 15px; color: var(--ink); background: var(--input-bg); outline: none; font-family: inherit; }

.set-row { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--border); }
.set-left { display: flex; align-items: center; gap: 10px; }
.set-label { font-size: 15px; font-weight: 500; color: var(--ink); }
.set-right { display: flex; align-items: center; gap: 4px; }
.set-input { width: 56px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; font-size: 15px; text-align: right; font-family: inherit; color: var(--ink); background: var(--input-bg); outline: none; }
.set-pct { font-size: 15px; color: var(--fainter); }
.set-total { font-size: 14px; font-weight: 600; text-align: right; margin-top: 14px; }

/* ── Sign-in ── */
.signin-topbar { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.signin { text-align: center; padding: 8px 4px 10px; }
.signin-eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 500; margin-bottom: 8px; }
.signin-mark { font-family: 'Fraunces', serif; font-size: 44px; font-weight: 600; color: var(--brand); margin: 0 0 10px; letter-spacing: -.01em; }
.signin-copy { font-size: 15px; color: var(--muted); line-height: 1.6; margin: 0 auto 26px; max-width: 320px; }
.google-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--input-bg); color: var(--ink); border: 1px solid var(--border-strong); border-radius: 14px; padding: 14px 18px; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; }
.google-btn:hover { background: var(--surface); }
.signin-foot { font-size: 12.5px; color: var(--fainter); line-height: 1.55; margin-top: 22px; }

/* ── Banner / errores ── */
.banner { font-size: 13px; line-height: 1.5; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.banner-error { background: #FBEDE6; color: #9B3E1B; border: 1px solid #F0CDBC; }
.banner-info { background: var(--anchor-bg); color: var(--anchor-text); border: 1px solid var(--anchor-border); }
[data-theme="dark"] .banner-error { background: #3A2016; color: #E9A98C; border-color: #5A3322; }

.profile-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border); }
.profile-who { font-size: 12.5px; color: var(--fainter); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; font-family: inherit; text-decoration: underline; padding: 0; flex: none; }

/* ── Animaciones ── */
.fade { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.press:active { transform: scale(.985); }
.lift { transition: transform .2s, box-shadow .2s; }
.lift:active { transform: scale(.99); }
input::placeholder { color: var(--placeholder); }

@media (prefers-reduced-motion: reduce) {
  .fade { animation: none; }
  * { transition: none !important; }
  .reveal-row { opacity: 1; transform: none; }
}
