/* ============================================================
   Beely — hoja de estilo única.
   Paleta crema/verde y tipografía Instrument Serif + Archivo:
   las cifras se leen como cifras, la interfaz se aparta.
   Diseño comprometido con un solo modo (claro): el color es marca.
   ============================================================ */
:root {
  color-scheme: light;

  /* Superficies e interfaz */
  --bg: #F2F0E8;
  --ink: #232A20;
  --ink-2: #3F4A38;
  --ink-3: #5F675A;
  --muted: #7C8474;
  --faint: #9A9686;
  --line: #EAE8DE;
  --line-2: #DDDBD0;
  --line-3: #E6E4D9;
  --panel: #E7E9DD;
  --panel-line: #D5D9C9;
  --field: #FAF8F0;

  /* Verde de marca (bloque principal, botones) */
  --green: #414F38;
  --green-700: #36422E;
  --green-pill: #2A3226;
  --on-green: #F2F0E8;
  --on-green-dim: #A8B69B;
  --on-green-faint: #8B9483;
  --on-green-soft: #C7CFBC;
  --green-bar: #5E6B53;
  --green-up: #A9C48E;

  /* Datos: teja / azul / oliva. Validados para daltonismo. */
  --p0: #CC5C1F;
  --p1: #2A6FB0;
  --joint: #6F7D18;
  --danger: #B03A2B;
  --danger-soft: rgba(176, 58, 43, .10);
  --ok: #5B7A46;

  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --sans: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  --r-lg: 16px;
  --r: 12px;
  --r-sm: 10px;
  --pill: 999px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow: 0 10px 40px rgba(35, 42, 32, .16);
  --shadow-sm: 0 2px 10px rgba(35, 42, 32, .07);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 16px; color: var(--ink); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
[hidden] { display: none !important; }
::selection { background: rgba(204, 92, 31, .18); }

/* Las <i> se usan como piezas de gráfico, no como énfasis. */
.hero i, .split-bar i, .track i, .legend i, .chart i { font-style: normal; }

/* Cifras: siempre serif, siempre tabulares. */
.fig { font-family: var(--serif); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ============================================================
   BLOQUE PRINCIPAL — portada y navegación a la vez
   ============================================================ */
.hero {
  background: var(--green);
  color: var(--on-green);
  padding: calc(var(--safe-top) + 10px) 24px 20px;
  touch-action: pan-y;
  user-select: none;
}
/* Lo que falta por configurar: se ve, no estorba y se puede descartar. */
.setup-strip {
  margin: 14px 20px 0; padding: 12px 8px 12px 16px; display: flex; align-items: center; gap: 10px;
  background: var(--field); border: 1px solid var(--line-2); border-radius: var(--r);
}
.setup-strip .ss-text { flex: 1; min-width: 0; }
.setup-strip .ss-main { font-size: 14px; font-weight: 500; }
.setup-strip .ss-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.setup-strip .ss-go { padding: 9px 14px; background: var(--green); color: var(--on-green); border-radius: var(--pill); font-size: 13px; font-weight: 500; flex: 0 0 auto; }
.setup-strip .ss-x { width: 34px; height: 34px; border-radius: var(--pill); color: var(--faint); flex: 0 0 auto; font-size: 12px; }
.setup-strip .ss-x:active { background: var(--line); }

.hero-dots { display: flex; gap: 5px; padding-top: 6px; }
.hero-dots i { flex: 1; height: 3px; border-radius: 2px; background: var(--green-bar); transition: background .2s; }
.hero-dots i.on { background: var(--on-green); }

/* El mes va centrado en el ancho del bloque; el engranaje flota a la
   derecha para no descolocarlo. */
.hero-nav { position: relative; display: flex; align-items: center; justify-content: center; height: 44px; margin-top: 4px; }
.hero-month { display: flex; align-items: center; gap: 14px; }
.hero-month span { font-size: 15px; font-weight: 500; min-width: 96px; text-align: center; }
.hero-arrow { width: 30px; height: 40px; display: grid; place-items: center; color: var(--on-green-dim); }
.hero-arrow[disabled] { color: var(--green-bar); }
.hero-gear { position: absolute; right: -8px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center; color: var(--on-green-soft); }

.hero-stage { position: relative; }
.hero-panel { transition: opacity .18s ease; }
.hero-panel.fading { opacity: 0; }
.hero-label { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--on-green-dim); margin-top: 10px; }
.hero-amount { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.hero-fig { display: flex; align-items: baseline; }
/* El aire entre cifra y símbolo lo pone el lado en el que cae. */
[data-pos="after"] { margin-left: .3em; }
[data-pos="before"] { margin-right: .08em; }
.hero-figure { font-family: var(--serif); font-size: 58px; line-height: .95; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.hero-figure.sm { font-size: 40px; }
.hero-cur { font-family: var(--serif); font-size: 25px; color: var(--on-green-dim); }
.hero-side { font-size: 14px; color: var(--green-up); margin-left: 4px; }
.hero-delta { display: flex; align-items: center; gap: 7px; margin-top: 6px; font-size: 13.5px; color: var(--green-up); min-height: 20px; }
.hero-delta.down { color: #E7A98A; }
.hero-delta.flat { color: var(--on-green-soft); }

.hero-bars { display: flex; align-items: flex-end; gap: 9px; height: 52px; margin-top: 18px; }
.hero-bars i { flex: 1; background: var(--green-bar); border-radius: 3px 3px 0 0; min-height: 3px; }
.hero-bars i.now { background: var(--on-green); }

.hero-split { display: flex; height: 30px; margin-top: 18px; border-radius: 5px; overflow: hidden; gap: 2px; }
.hero-split i:first-child { background: var(--p0); }
.hero-split i:last-child { background: var(--green-up); }

.hero-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; min-height: 24px; }
.hero-foot small { font-size: 11.5px; color: var(--on-green-faint); }
.hero-detail { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--on-green-soft); padding: 6px 0 6px 12px; }

/* ============================================================
   CONFIRMAR UN INGRESO — la app pregunta, no inventa
   ============================================================ */
.confirm-strip {
  margin: 14px 20px 0; padding: 14px 16px;
  background: var(--field); border: 1px solid var(--line-2); border-radius: var(--r);
}
.cs-top { display: flex; align-items: center; gap: 10px; }
.cs-mark { width: 3px; height: 30px; border-radius: 2px; opacity: .45; flex: 0 0 3px; }
.cs-text { flex: 1; min-width: 0; }
.cs-main { font-size: 14px; font-weight: 500; }
.cs-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.cs-actions { display: flex; gap: 8px; margin-top: 12px; }
.cs-actions button {
  flex: 1; height: 44px; border-radius: var(--pill); font-size: 14px; font-weight: 500;
  transition: transform .08s ease;
}
.cs-actions button:active { transform: scale(.98); }
.cs-yes { background: var(--green); color: var(--on-green); font-weight: 600; }
.cs-no { border: 1px solid var(--line-2); color: var(--ink-3); }

/* ============================================================
   FILA DE SALDAR CUENTAS
   ============================================================ */
.settle-row {
  margin: 16px 20px 0; display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: var(--panel); border-radius: var(--r); min-height: 44px;
}
.sr-text { flex: 1; min-width: 0; font-size: 14.5px; }
.sr-text .fig { font-size: 19px; }
.sr-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.sr-btn { padding: 10px 16px; background: var(--green); border-radius: var(--pill); color: var(--on-green); font-size: 13.5px; font-weight: 500; flex: 0 0 auto; }
.sr-btn:active { background: var(--green-700); }

/* ============================================================
   LISTA DE GASTOS
   ============================================================ */
.recent { padding: 18px 20px 0; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 2px; }
.sec-kicker { font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.sec-link { font-size: 13px; color: var(--p0); font-weight: 500; padding: 4px 0 4px 10px; }

.row { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.row:last-child { border-bottom: none; }
.row:active { opacity: .55; }
.row-mark { width: 3px; height: 34px; flex: 0 0 3px; border-radius: 2px; background: var(--muted); }
.row-mid { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amount { font-family: var(--serif); font-size: 19px; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.row-amount .sub { display: block; font-family: var(--sans); font-size: 11px; color: var(--muted); text-align: right; margin-top: 1px; }
.row-amount.pos { color: var(--ok); }
.row-main { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; text-align: left; padding: 0; }
.row-main:active { opacity: .55; }
.row-chevron { color: var(--line-2); flex: 0 0 auto; display: grid; place-items: center; }
.row-edit { width: 36px; height: 36px; border-radius: var(--pill); display: grid; place-items: center; color: var(--faint); flex: 0 0 auto; margin-left: 6px; }
.row-edit:active { background: var(--line); color: var(--ink); }
.row.pending .row-title, .row.pending .row-amount { color: var(--faint); }
.row.pending .row-mark { opacity: .45; }

.empty { text-align: center; color: var(--muted); padding: 54px 20px; }
.empty .fig { display: block; font-size: 44px; color: var(--line-2); margin-bottom: 6px; }

.month-group { margin-top: 22px; }
.month-head { display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 6px; }
.month-head b { font-size: 14px; font-weight: 600; }
.month-head span { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ============================================================
   BARRA INFERIOR DE ENTRADA RÁPIDA (sustituye al "+")
   ============================================================ */
.quickbar { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 20px calc(20px + var(--safe-bottom)); background: linear-gradient(to bottom, rgba(242,240,232,0), var(--bg) 34%); z-index: 20; }
.qb { display: flex; align-items: center; gap: 10px; background: var(--green-pill); border-radius: var(--pill); padding: 0 8px 0 22px; height: 56px; box-shadow: var(--shadow-sm); }
/* El orden lo fija el sitio del símbolo en cada moneda (lo pone el JS
   en .qb-cur): 0 delante del importe, 2 detrás — nunca tras el botón. */
.qb-cur { font-family: var(--serif); font-size: 22px; color: var(--on-green-faint); }
.qb input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 16px; color: var(--on-green); order: 1; }
.qb input::placeholder { color: var(--on-green-faint); }
.qb-go { width: 42px; height: 42px; border-radius: var(--pill); background: var(--p0); display: grid; place-items: center; flex: 0 0 auto; transition: transform .1s; order: 3; }
.qb-go:active { transform: scale(.92); }

#app { padding-bottom: calc(96px + var(--safe-bottom)); }

/* ============================================================
   PANTALLAS DE ANÁLISIS (Tendencias · Ahorro · Lo que entra · Historial)
   ============================================================ */
.screen { position: fixed; inset: 0; z-index: 60; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; animation: screenin .24s cubic-bezier(.2,.8,.3,1); }
@keyframes screenin { from { opacity: 0; transform: translateY(14px); } }
.screen-head { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-top) + 20px) 24px 0; height: calc(var(--safe-top) + 46px); }
.screen-kicker { font-size: 12.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.screen-close { width: 44px; height: 44px; display: grid; place-items: center; margin-right: -12px; color: var(--muted); }
.screen-body { padding-bottom: calc(48px + var(--safe-bottom)); }

.sec { padding: 30px 24px 0; }
.sec:first-child { padding-top: 20px; }
.sec-title { font-size: 16px; font-weight: 600; }
.sec-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }

.big-figure { display: flex; align-items: baseline; margin-top: 4px; }
.big-figure .n { font-family: var(--serif); font-size: 56px; line-height: .95; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.big-figure .u { font-family: var(--serif); font-size: 26px; color: var(--muted); }
.big-figure .aside { font-size: 14px; color: var(--ink-3); margin-left: 4px; }

.range-row { display: flex; gap: 8px; padding: 18px 24px 0; }
.range-row button { padding: 9px 15px; border-radius: var(--pill); border: 1px solid var(--line-2); font-size: 13px; color: var(--ink-3); }
.range-row button.on { background: var(--green); border-color: var(--green); color: var(--on-green); font-weight: 500; }

/* Dos lecturas del mismo gráfico, en un control pequeño. */
.mini-seg { display: inline-flex; gap: 3px; margin-top: 10px; background: var(--panel); border-radius: var(--pill); padding: 3px; }
.mini-seg button { padding: 7px 14px; border-radius: var(--pill); font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.mini-seg button.on { background: var(--bg); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }

/* Lo puesto frente a lo que toca: de ahí sale la deuda. */
.acct-grid { display: grid; grid-template-columns: 1fr auto auto; gap: 10px 18px; align-items: baseline; margin-top: 20px; }
.acct-grid .h { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: right; }
.acct-grid .n { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-3); }
.acct-grid .n i { width: 3px; height: 15px; border-radius: 2px; flex: 0 0 3px; }
.acct-grid .fig { font-size: 17px; text-align: right; }

.settle-row.flush { margin: 14px 0 0; }

.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; }
.legend div { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }

/* Gráfico con eje: la columna de valores se queda quieta y solo se
   desplazan las barras. */
.chart-area { display: flex; gap: 10px; margin-top: 18px; }
.chart-axis { position: relative; flex: 0 0 auto; min-width: 34px; }
.chart-axis span {
  position: absolute; right: 0; transform: translateY(-50%);
  font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chart-scroll { flex: 1; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-inner { width: 100%; }
.chart { position: relative; height: 158px; }
.chart .grid { position: absolute; left: 0; right: 0; height: 1px; background: var(--line-3); }
.chart .grid.base { bottom: 0; background: var(--line-2); }
.chart .bars { position: absolute; left: 0; right: 0; bottom: 1px; display: flex; align-items: flex-end; gap: 12px; height: 157px; }
.chart .bars > div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.chart .bars i { display: block; }
.chart .bars i:first-child { border-radius: 4px 4px 0 0; }
.chart-labels { display: flex; gap: 12px; margin-top: 8px; }
.chart-labels span { flex: 1; text-align: center; font-size: 11.5px; color: var(--faint); }
.chart-labels span.now { color: var(--ink); font-weight: 600; }

/* La media, cruzando las barras: dice si este mes se sale de lo normal. */
/* La opacidad iba en el elemento y se llevaba por delante el rótulo:
   va en el color de la línea, para que la etiqueta quede opaca. */
.avg-line { position: absolute; left: 0; right: 0; border-top: 1px dashed rgba(124, 132, 116, .75); }
.avg-line span {
  position: absolute; right: 0; top: -15px; font-size: 10.5px; color: var(--muted);
  background: var(--bg); padding: 0 3px; font-variant-numeric: tabular-nums;
}

/* Barras con signo: lo ahorrado hacia arriba, los meses en rojo hacia abajo. */
.signed-bars { position: relative; display: flex; gap: 12px; }
.signed-bars .zero { position: absolute; left: 0; right: 0; height: 1px; background: var(--line-2); }
.signed-bars .col { flex: 1; display: flex; flex-direction: column; }
.signed-bars .half { display: flex; }
.signed-bars .half.up { align-items: flex-end; }
.signed-bars .half.dn { align-items: flex-start; }
.signed-bars i { display: block; width: 100%; border-radius: 3px 3px 0 0; }
.signed-bars .half.dn i { border-radius: 0 0 3px 3px; }

.bars-list { display: flex; flex-direction: column; gap: 16px; margin-top: 18px; }
.bars-list .b-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.bars-list .b-head span { font-size: 14px; }
.bars-list .b-head .fig { font-size: 16px; }
.track { height: 8px; background: var(--line-3); border-radius: 4px; overflow: hidden; }
.track i { display: block; height: 100%; background: var(--green); border-radius: 4px; }
.b-note { display: block; font-size: 12px; color: var(--muted); margin-top: 6px; }
.b-note.up { color: var(--p0); }
.b-note.down { color: var(--ok); }

.split-bar { display: flex; height: 46px; margin-top: 14px; border-radius: 6px; overflow: hidden; gap: 2px; }
.split-bar i { display: flex; align-items: center; padding-left: 13px; font-size: 13px; color: var(--on-green); font-weight: 600; white-space: nowrap; overflow: hidden; }
.split-bar .out { background: var(--p0); }
.split-bar .keep { background: var(--green); }

.kv { display: flex; align-items: center; justify-content: space-between; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-top: 10px; }
.kv:last-child { border-bottom: none; padding-bottom: 0; }
.kv span { font-size: 14px; color: var(--ink-3); }
.kv .fig { font-size: 17px; }
.kv .fig.neg { color: var(--p0); }

.tiles { display: flex; gap: 10px; padding: 26px 24px 0; }
.tile { flex: 1; padding: 16px; background: var(--panel); border-radius: var(--r); }
.tile .fig-line { display: flex; align-items: baseline; }
.tile .n { font-family: var(--serif); font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.tile .u { font-family: var(--serif); font-size: 18px; color: var(--muted); }
.tile .l { font-size: 12.5px; color: #59634F; margin-top: 6px; line-height: 1.35; }

.insight { margin: 30px 24px 0; padding: 16px 18px; background: var(--panel); border-radius: var(--r); font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.insight b { font-weight: 600; }
.note { margin: 16px 24px 0; padding: 14px 16px; border: 1px dashed #D6D3C6; border-radius: var(--r); font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.contrib { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.contrib span.n { width: 60px; font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contrib .track { flex: 1; }
.contrib .fig { font-size: 15px; }

.chart-line { display: block; width: 100%; height: 130px; }
.chart-line-labels { display: flex; justify-content: space-between; margin-top: 4px; }
.chart-line-labels span { font-size: 11px; color: var(--faint); }
.chart-line-labels span.now { color: var(--ink); font-weight: 600; }

/* Lo que entra */
.inc-state { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12.5px; }
.inc-state.ok { color: var(--ok); }
.inc-state.wait { color: var(--faint); }
.add-line { display: flex; align-items: center; gap: 10px; padding: 15px 0; min-height: 44px; width: 100%; color: var(--p0); font-size: 15px; font-weight: 500; }

.invest { margin-top: 14px; padding: 18px; background: var(--panel); border-radius: var(--r-lg); }
.invest-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.invest-lab { font-size: 12.5px; color: #59634F; }
.invest-fig { display: flex; align-items: baseline; margin-top: 4px; }
.invest-fig .n { font-family: var(--serif); font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.invest-fig .u { font-family: var(--serif); font-size: 18px; color: var(--muted); }
.invest-btn { padding: 10px 15px; background: var(--green); border-radius: var(--pill); color: var(--on-green); font-size: 13px; font-weight: 500; min-height: 40px; flex: 0 0 auto; }
.invest-delta { display: flex; align-items: center; gap: 7px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--panel-line); font-size: 13px; color: var(--ink-2); }
.invest-x { margin-top: 12px; font-size: 12.5px; color: var(--muted); text-decoration: underline; }

/* ============================================================
   HOJAS (sheets) Y PANTALLAS DE ALTA
   ============================================================ */
.sheet { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(35, 42, 32, .42); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: fade .2s ease; }
.sheet-body {
  position: relative; width: 100%; max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-radius: 24px 24px 0 0; padding: 6px 22px calc(26px + var(--safe-bottom));
  box-shadow: var(--shadow); animation: slideup .26s cubic-bezier(.2,.85,.3,1);
}
@media (min-width: 560px) {
  .sheet { align-items: center; justify-content: center; padding: 24px; }
  .sheet-body { max-width: 440px; border-radius: 24px; }
}
.sheet-handle { width: 40px; height: 5px; background: var(--line-2); border-radius: 3px; margin: 8px auto 14px; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-header h2 { font-size: 20px; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--pill); display: grid; place-items: center; color: var(--muted); font-size: 16px; margin-right: -8px; }
.icon-btn:active { background: var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(100%); } }

.ob-screen { position: fixed; inset: 0; z-index: 80; background: var(--bg); display: grid; place-items: center; padding: 22px; overflow-y: auto; }
.ob-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.ob-steps { display: flex; gap: 6px; }
.ob-steps i { width: 18px; height: 3px; border-radius: 2px; background: var(--line-2); }
.ob-steps[data-step="0"] i:nth-child(1),
.ob-steps[data-step="1"] i:nth-child(-n+2),
.ob-steps[data-step="2"] i { background: var(--green); }

.ob-back {
  display: grid; place-items: center; width: 40px; height: 40px;
  margin-left: -12px; color: var(--muted); border-radius: var(--pill); flex: 0 0 auto;
}
.ob-back:active { background: var(--line); }
.ob-screen .sheet-body { border-radius: 20px; max-width: 420px; animation: none; box-shadow: none; background: none; padding: 20px 4px; }
.ob-screen h2 { font-size: 30px; font-weight: 400; font-family: var(--serif); letter-spacing: -.01em; margin-bottom: 10px; line-height: 1.12; }
.ob-screen .muted { font-size: 15px; line-height: 1.5; }
.ob-mark { font-family: var(--serif); font-size: 34px; color: var(--green); margin-bottom: 6px; }

/* Campos */
.field { display: flex; flex-direction: column; gap: 7px; margin: 16px 0; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field input, .field select, .add-row input, .auth-fields input, .card-add input {
  background: var(--field); border: 1.5px solid var(--line-2); border-radius: var(--r-sm);
  padding: 13px 14px; width: 100%; outline: none; transition: border-color .15s, background .15s;
}
.field input:focus, .field select:focus, .auth-fields input:focus, .card-add input:focus { border-color: var(--green); }
input[type="date"] { -webkit-appearance: none; appearance: none; min-height: 48px; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.field.inline > span { font-size: 15px; color: var(--ink); }

.amount-row { display: flex; gap: 10px; align-items: stretch; margin: 6px 0 4px; }
.amount-input {
  flex: 1; min-width: 0; font-family: var(--serif); font-size: 40px; font-variant-numeric: tabular-nums;
  background: var(--field); border: 1.5px solid var(--line-2); border-radius: var(--r); padding: 10px 16px; outline: none;
}
.amount-input:focus { border-color: var(--green); }
.amount-input::placeholder { color: var(--line-2); }
.currency-select { flex: 0 0 auto; background: var(--field); border: 1.5px solid var(--line-2); border-radius: var(--r); padding: 0 12px; font-size: 14px; outline: none; }
.currency-select.wide { padding: 13px 14px; width: 100%; }
.convert-row { display: flex; justify-content: space-between; align-items: center; margin: 4px 2px 8px; }
.rate-row { margin: 4px 0 10px; background: var(--panel); border-radius: var(--r-sm); padding: 10px 12px; }
.rate-input { width: 116px; background: var(--bg); border: 1.5px solid var(--line-2); border-radius: 10px; padding: 8px 10px; text-align: right; }

.seg-label { font-size: 13px; color: var(--muted); font-weight: 500; margin: 18px 0 9px; }
.sel {
  width: 100%; background: var(--field); border: 1.5px solid var(--line-2); border-radius: var(--r-sm);
  padding: 13px 40px 13px 14px; font-size: 15px; outline: none;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%237C8474' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
.sel:focus { border-color: var(--green); }

.toggle-row { display: flex; gap: 4px; margin-top: 16px; background: var(--panel); border-radius: var(--r); padding: 4px; }
.toggle-opt { flex: 1; padding: 11px; border-radius: var(--r-sm); font-weight: 500; color: var(--ink-3); font-size: 14.5px; transition: .12s; }
.toggle-opt.active { background: var(--bg); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }

.split-block { margin-top: 16px; }
.split-head { display: flex; justify-content: space-between; align-items: center; }
.split-control { margin-top: 12px; }
.split-labels { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-variant-numeric: tabular-nums; }
#btnSplitToggle { color: var(--green); font-weight: 600; font-size: 13.5px; background: var(--panel); padding: 6px 13px; border-radius: var(--pill); }
input[type=range] { width: 100%; accent-color: var(--green); height: 28px; }

.exp-hint { font-size: 13px; color: var(--ink-3); background: var(--panel); border-radius: var(--r-sm); padding: 11px 13px; margin: 12px 0 0; line-height: 1.45; }

.sheet-actions { display: flex; gap: 10px; margin-top: 24px; }
.link-btn { color: var(--p0); font-weight: 500; font-size: 14px; }

.btn-primary, .btn-secondary, .btn-danger {
  border-radius: var(--pill); padding: 15px 20px; font-size: 15.5px; font-weight: 600;
  flex: 1; min-height: 50px; transition: transform .08s ease, background .15s;
}
.btn-primary { background: var(--green); color: var(--on-green); width: 100%; }
.btn-primary:active { transform: scale(.985); background: var(--green-700); }
.btn-secondary { background: var(--panel); color: var(--ink); }
.btn-secondary:active { background: var(--line-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger.wide, .btn-primary.wide, .btn-secondary.wide { width: 100%; }
.btn-primary[disabled], .btn-secondary[disabled] { opacity: .55; }

.btn-apple {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  background: var(--ink); color: #fff; border-radius: var(--pill); padding: 15px 20px;
  font-size: 15.5px; font-weight: 600; min-height: 50px;
}
.btn-apple:active { transform: scale(.985); opacity: .88; }
.or-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--muted); font-size: 12.5px; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }
.auth-fields { display: flex; flex-direction: column; gap: 10px; }
.auth-error { color: var(--danger); font-size: 13.5px; text-align: center; }
.btn-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.btn-stack > button { width: 100%; margin: 0; }
.invite-banner { background: var(--panel); border-radius: var(--r-sm); padding: 12px 14px; font-size: 13.5px; color: var(--ink-2); margin-top: 14px; }

/* Ajustes */
.settings-group { padding: 20px 0; border-bottom: 1px solid var(--line); }
.settings-group h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.settings-actions { display: flex; gap: 10px; }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row input { flex: 1; }
.add-row .btn-secondary { flex: 0 0 auto; width: auto; }
.ca-field { display: flex; flex-direction: column; gap: 6px; }
.ca-lab { font-size: 12px; color: var(--muted); font-weight: 500; }
.ca-seg { display: flex; gap: 6px; }
.ca-opt { flex: 1; padding: 11px 6px; border: 1.5px solid var(--line-2); border-radius: var(--r-sm); background: var(--field); color: var(--muted); font-weight: 500; font-size: 13px; }
.ca-opt.active { background: var(--panel); color: var(--green); border-color: var(--green); }

.fold { border: 1px solid var(--line-2); border-radius: var(--r); background: var(--field); margin-top: 18px; overflow: hidden; }
.fold > summary { padding: 15px 16px; font-weight: 600; font-size: 14px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "⌄"; color: var(--muted); font-size: 18px; transition: transform .2s; }
.fold[open] > summary::after { transform: rotate(180deg); }
.fold[open] > summary { border-bottom: 1px solid var(--line); }
.fold > div, .fold > .settings-group { padding: 16px; }
.fold > .settings-group:last-child { border-bottom: none; }
#syncStatus { color: var(--ok); font-weight: 600; margin-bottom: 12px; }
#syncStatus:empty { display: none; }
.danger-list { display: flex; flex-direction: column; gap: 6px; }
.danger-list p { margin: 0 0 14px; }

/* Modal de confirmación */
.modal { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(35, 42, 32, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade .18s ease; }
.modal-card { position: relative; width: 100%; max-width: 340px; background: var(--bg); border-radius: 20px; padding: 24px 22px 18px; box-shadow: var(--shadow); animation: popin .22s cubic-bezier(.2,.9,.3,1.2); }
/* El título de la ficha del espacio se toca para renombrarlo. */
#spaceSheetTitle { cursor: pointer; }
#spaceSheetTitle::after { content: " ✎"; font-size: 13px; color: var(--faint); }

#confirmInput {
  width: 100%; background: var(--field); border: 1.5px solid var(--line-2); border-radius: var(--r-sm);
  padding: 13px 14px; outline: none; margin-bottom: 18px;
}
#confirmInput:focus { border-color: var(--green); }
.modal-card p { margin-bottom: 20px; font-size: 15.5px; line-height: 1.5; text-align: center; }
.modal-actions { display: flex; gap: 10px; }
@keyframes popin { from { opacity: 0; transform: scale(.92); } }

/* Tirar para sincronizar */
.ptr { position: fixed; top: calc(var(--safe-top) + 8px); left: 50%; transform: translateX(-50%) scale(0); width: 34px; height: 34px; border-radius: 50%; background: var(--bg); box-shadow: var(--shadow-sm); display: grid; place-items: center; z-index: 40; transition: transform .18s ease; font-size: 15px; color: var(--muted); }
.ptr.show { transform: translateX(-50%) scale(1); }
.ptr.spin { animation: ptrspin .8s linear infinite; }
@keyframes ptrspin { to { transform: translateX(-50%) scale(1) rotate(360deg); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%);
  background: var(--green-pill); color: var(--on-green); padding: 12px 20px; border-radius: var(--pill);
  font-size: 14px; font-weight: 500; z-index: 100; box-shadow: var(--shadow); animation: toastin .2s ease;
  max-width: 88%; text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } }

.invest-when { font-size: 12px; color: var(--muted); margin-top: 5px; }
.invest-none { font-size: 15px; color: var(--muted); margin-top: 6px; }

/* Filas de patrimonio: saldo a la derecha, acciones debajo. */
.wrow { display: grid; grid-template-columns: 1fr auto; align-items: baseline;
  gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line-3); }
.wrow:last-child { border-bottom: none; }
.wrow-fig { font-family: var(--serif); font-size: 21px; font-variant-numeric: tabular-nums; }
.wrow-mid .row-meta .up { color: var(--ok); }
.wrow-mid .row-meta .down { color: var(--p0); }
.wrow-acts { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.wrow-btn { padding: 7px 13px; background: var(--green); border-radius: var(--pill);
  color: var(--on-green); font-size: 12.5px; font-weight: 500; min-height: 34px; }
.wrow-link { font-size: 12.5px; color: var(--muted); text-decoration: underline; }

.wrow-mid .row-meta:only-child { padding-top: 2px; }

/* Las notas explicativas se pueden cerrar. */
.note { position: relative; padding-right: 34px; }
.note-x { position: absolute; top: 7px; right: 7px; padding: 6px; color: var(--faint);
  line-height: 0; border-radius: 50%; min-height: 0; }
.note-x:active { color: var(--muted); }
