/* ==========================================================================
   Finanzas — tema oscuro puro estilo iOS
   ========================================================================== */

:root {
  --bg: #000000;
  --card: #121212;
  --card-2: #1f1f1f;
  --card-3: #333333;
  --sep: rgba(84, 84, 88, 0.55);

  --text: #ffffff;
  --text-2: #8e8e93;
  --text-3: #636366;

  --accent: #ffffff;          /* interfaz: blanco sobre negro */
  --accent-dim: rgba(255, 255, 255, 0.08);
  --green: #32d74b;           /* solo ingresos / positivo */
  --red: #ff453a;
  --red-dim: rgba(255, 69, 58, 0.16);
  --orange: #ff9f0a;
  --blue: #0a84ff;

  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 12px;

  --tabbar-h: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --gutter: 16px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-num: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* ---------- Layout ---------------------------------------------------- */

.view {
  padding: calc(var(--safe-top) + 12px) var(--gutter)
           calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
  max-width: 560px;
  margin: 0 auto;
  outline: none;
}

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; margin: 8px 0 18px;
}
.page-header h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; margin: 0; }
.page-header .eyebrow { color: var(--text-2); font-size: 14px; font-weight: 500; }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 20px; font-weight: 700; letter-spacing: -0.02em;
  margin: 28px 2px 12px;
}
.section-title a { font-size: 15px; font-weight: 500; color: var(--accent); }

/* ---------- Cards ----------------------------------------------------- */

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.card + .card { margin-top: 12px; }

.hero .label { color: var(--text-2); font-size: 14px; font-weight: 500; }
.hero .amount { font-size: 40px; font-weight: 700; margin: 4px 0 16px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pill-stat { background: var(--card-2); border-radius: var(--radius); padding: 12px 14px; }
.pill-stat .label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.pill-stat .value { font-size: 19px; font-weight: 600; margin-top: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--text-2); }

/* ---------- Presupuestos circulares ---------------------------------- */

.rings {
  display: grid; grid-auto-flow: column; grid-auto-columns: 104px;
  gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 4px;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
}
.rings::-webkit-scrollbar { display: none; }
.ring-card {
  background: var(--card); border-radius: var(--radius-lg);
  padding: 14px 8px 12px; text-align: center; scroll-snap-align: start;
}
.ring-wrap { position: relative; width: 64px; height: 64px; margin: 0 auto 8px; }
.ring { width: 64px; height: 64px; }
.ring-track { fill: none; stroke: var(--card-3); stroke-width: 7; }
.ring-bar { fill: none; stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring-icon { position: absolute; inset: 0; display: grid; place-items: center; }
.ring-icon .ico { width: 22px; height: 22px; }
.ring-card .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring-card .sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ---------- Listas tipo iOS ------------------------------------------ */

.list { background: var(--card); border-radius: var(--radius-lg); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; min-height: 60px; position: relative; width: 100%; text-align: left;
}
.row + .row::before {
  content: ""; position: absolute; top: 0; right: 0; left: 68px;
  border-top: 0.5px solid var(--sep);
}
.row .icon {
  width: 42px; height: 42px; border-radius: 50%; flex: none; color: var(--text);
  display: grid; place-items: center; font-size: 20px; background: var(--card-2);
}
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .subtitle { font-size: 13px; color: var(--text-2); margin-top: 1px; }
.row .trail { font-weight: 600; white-space: nowrap; }
.list-day { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; margin: 20px 4px 8px; letter-spacing: .02em; }

.empty {
  text-align: center; color: var(--text-2); padding: 28px 16px; font-size: 15px;
}
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* ---------- Formularios --------------------------------------------- */

.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  margin: 4px 0 16px; min-height: 44px;
}
.topbar .left { justify-self: start; color: var(--accent); font-size: 17px; }
.topbar h2 { margin: 0; font-size: 17px; font-weight: 600; }

.segmented {
  display: grid; grid-template-columns: 1fr 1fr; background: var(--card);
  border-radius: 12px; padding: 3px; margin-bottom: 20px;
}
.segmented button {
  padding: 8px 0; border-radius: 9px; font-size: 15px; font-weight: 600; color: var(--text-2);
}
.segmented button[aria-pressed="true"] { background: var(--card-3); color: var(--text); }

.amount-input {
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  margin: 8px 0 6px;
}
.amount-input input {
  width: 100%; max-width: 280px; background: none; border: 0; outline: none;
  text-align: right; font-size: 56px; font-weight: 700; letter-spacing: -0.03em;
  font-family: var(--font-num); caret-color: var(--accent);
}
.amount-input input::placeholder { color: var(--text-3); }
.amount-input .currency { font-size: 34px; font-weight: 600; color: var(--text-2); }

.prefill-badge {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: fit-content; margin: 0 auto 18px; padding: 6px 12px;
  background: var(--accent-dim); color: var(--accent); border-radius: 999px;
  font-size: 13px; font-weight: 600;
}

.field-group { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.field {
  display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 50px; position: relative;
}
.field + .field::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep);
}
.field label { width: 96px; flex: none; color: var(--text-2); font-size: 16px; }
.field input, .field select {
  flex: 1; min-width: 0; background: none; border: 0; outline: none;
  font-size: 16px; /* ≥16px evita el zoom automático de iOS */
  padding: 14px 0; text-align: right;
}
.field input[type="date"] { -webkit-appearance: none; appearance: none; color: var(--text); }
.field select { -webkit-appearance: none; appearance: none; direction: rtl; }

.cat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px; }
.cat {
  background: none; border-radius: var(--radius); padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--text-2);
  transition: color .15s;
}
.cat-ico { width: 40px; height: 40px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; color: var(--text); }
.cat[aria-pressed="true"] .cat-ico { background: var(--text); color: #000; }
.cat span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.cat[aria-pressed="true"] { color: var(--text); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; border-radius: var(--radius);
  font-size: 17px; font-weight: 600; background: var(--card-2);
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:disabled { background: var(--card-2); color: var(--text-3); }
.btn-danger { color: var(--red); }
.btn + .btn { margin-top: 10px; }
.btn:active:not(:disabled) { transform: scale(0.98); }

.save-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px var(--gutter) calc(12px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.save-bar .btn { max-width: 528px; margin: 0 auto; }

.hint { font-size: 13px; color: var(--text-2); margin: -12px 4px 20px; }

/* ---------- TabBar --------------------------------------------------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(18, 18, 18, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 10px; font-weight: 500;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--accent); }
.tab-add-btn {
  width: 46px; height: 46px; border-radius: 50%; background: var(--accent);
  display: grid; place-items: center; box-shadow: 0 4px 16px rgba(255, 255, 255, 0.15);
}
.tab-add-btn svg { stroke: #000; stroke-width: 2.6; }

/* Vista modal (Nuevo gasto): ocultamos la TabBar */
body.is-modal .tabbar { display: none; }
body.is-modal .view { padding-bottom: calc(96px + var(--safe-bottom)); }

/* ---------- Toast ---------------------------------------------------- */

.toast {
  position: fixed; left: 50%; z-index: 50;
  top: calc(var(--safe-top) + 10px);
  transform: translate(-50%, -140%);
  background: var(--card-2); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: 15px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.2);
  pointer-events: none; white-space: nowrap;
}
.toast.show { transform: translate(-50%, 0); }

/* ---------- Varios --------------------------------------------------- */

.tag {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 6px;
  background: var(--card-2); color: var(--text-2);
}
.bar { height: 6px; border-radius: 3px; background: var(--card-3); overflow: hidden; display: flex; margin: 14px 0 10px; }
.bar > span { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

details.add-form summary {
  list-style: none; color: var(--accent); font-weight: 600; padding: 14px 4px; cursor: pointer;
}
details.add-form summary::-webkit-details-marker { display: none; }

@media (min-width: 700px) {
  .view { padding-top: 32px; }
}

/* ---------- Iconos de línea (js/icons.js) ---------------------------- */
.ico {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.prefill-badge .ico { width: 15px; height: 15px; }

/* ---------- Inversiones / ETF espejo -------------------------------- */
.link-btn { font-size: 14px; font-weight: 500; color: var(--text-2); }
.link-btn:disabled { opacity: .6; }
.trail-stack { text-align: right; white-space: nowrap; }
.trail-sub { font-size: 13px; font-weight: 500; margin-top: 2px; }
.kv .row { min-height: 48px; font-size: 15px; }
.kv .row + .row::before { left: 16px; }
.kv .main { color: var(--text-2); }

.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input {
  flex: 1; min-width: 0; background: var(--card-2); border: 0; outline: none;
  border-radius: var(--radius); padding: 0 14px; font-size: 16px; min-height: 52px;
}
.inline-form .btn { width: auto; padding: 0 18px; margin: 0; }

/* ---------- Bottom sheet -------------------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0);
  display: flex; align-items: flex-end; justify-content: center;
  transition: background .25s;
}
.sheet-backdrop.open { background: rgba(0, 0, 0, .6); }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: #0d0d0d; border-top: 0.5px solid var(--sep);
  border-radius: 24px 24px 0 0;
  padding: 8px var(--gutter) calc(20px + var(--safe-bottom));
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .9, .3, 1);
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--card-3); margin: 0 auto 14px; }
.sheet-title { text-align: center; font-size: 18px; font-weight: 700; margin: 0 0 16px; }
.sheet .field-group { background: var(--card); }

/* ---------- Pegar pago (portapapeles) -------------------------------- */
.pill-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 6px;
  padding: 8px 14px; border-radius: 999px; background: var(--card-2);
  font-size: 14px; font-weight: 600; color: var(--text);
}
.pill-btn .ico { width: 16px; height: 16px; }
.paste-btn { border: 0; cursor: pointer; }

/* ==========================================================================
   v0.2 · Mejoras (privacidad, buscador, etiquetas, gráficas, huchas…)
   ========================================================================== */

/* ---------- #1 Modo privacidad --------------------------------------- */
body.privacy .num:not(input),
body.privacy .bar-val {
  filter: blur(7px);
  transition: filter .2s;
  user-select: none;
}
.header-actions { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; background: var(--card-2);
  display: grid; place-items: center; color: var(--text); flex: none;
}
.icon-btn .ico { width: 19px; height: 19px; }
.pill-btn { margin-bottom: 0; }

/* ---------- #2 Selector de mes --------------------------------------- */
.month-select { position: relative; display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); }
.month-select select {
  -webkit-appearance: none; appearance: none; background: none; border: 0; outline: none;
  color: var(--text-2); font-size: 14px; font-weight: 600; padding: 2px 0; cursor: pointer;
}
.month-select .ico { width: 14px; height: 14px; pointer-events: none; }
.month-select select option { color: #000; }

/* ---------- #3 Buscador ---------------------------------------------- */
.search {
  display: flex; align-items: center; gap: 8px; background: var(--card);
  border-radius: 12px; padding: 0 12px; margin-bottom: 10px; color: var(--text-2);
}
.search .ico { width: 18px; height: 18px; }
.search input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 16px; padding: 11px 0;
  -webkit-appearance: none; appearance: none;
}
.search input::-webkit-search-cancel-button { filter: invert(1) opacity(.5); }
.segmented.small { margin-bottom: 8px; }
.segmented.small button { padding: 6px 0; font-size: 13px; }
.segmented.four { grid-template-columns: repeat(4, 1fr); }
.result-summary { font-size: 13px; color: var(--text-2); margin: 12px 4px 0; }

/* ---------- #9 Etiquetas --------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.chip {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; background: var(--card-2); color: var(--text-2); line-height: 1.5;
}
.tag-suggestions { margin: -10px 2px 20px; gap: 6px; }
.tag-suggestions .chip { font-size: 13px; padding: 5px 10px; }

/* ---------- Formulario: divisa, compartido ---------------------------- */
.amount-input .currency { background: none; border: 0; padding: 0 4px; border-radius: 8px; color: var(--text-2); }
.amount-input .currency:active { background: var(--card-2); }
.amount-hint { text-align: center; font-size: 13px; color: var(--text-2); min-height: 18px; margin: -2px 0 10px; }
.amount-hint strong { color: var(--text); }
.field-note { flex: 1; text-align: right; color: var(--text-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field[hidden] { display: none; }

/* Interruptor iOS a partir de un checkbox */
.switch {
  -webkit-appearance: none; appearance: none; flex: none !important;
  width: 51px; height: 31px; border-radius: 31px; background: var(--card-3);
  position: relative; cursor: pointer; transition: background .2s; padding: 0 !important; margin: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; transition: transform .2s; box-shadow: 0 2px 4px rgba(0,0,0,.3);
}
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }

/* ---------- #10 Gráficas --------------------------------------------- */
.donut { position: relative; flex: none; }
.donut svg { width: 100%; height: 100%; display: block; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; font-size: 12px;
}
.donut-center .num { font-size: 19px; font-weight: 700; margin-top: 2px; }
.donut-card { display: flex; align-items: center; gap: 16px; }
.donut-legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.legend-row .legend-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 360px) { .donut-card { flex-direction: column; } .donut-legend { width: 100%; } }

.line-chart svg { width: 100%; height: 140px; display: block; overflow: visible; }
.line-chart-axis { display: flex; justify-content: space-between; font-size: 12px; margin-top: 8px; }
.chart-empty { font-size: 14px; text-align: center; padding: 26px 8px; }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar-fill { width: 100%; max-width: 34px; border-radius: 6px 6px 3px 3px; background: var(--card-3); }
.bar-fill.hl { background: var(--text); }
.bar-val { font-size: 10.5px; color: var(--text-2); margin-bottom: 4px; white-space: nowrap; }
.bar-label { font-size: 11.5px; color: var(--text-2); margin-top: 6px; text-transform: capitalize; }

.progress { height: 6px; border-radius: 3px; background: var(--card-3); overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; border-radius: 3px; transition: width .4s ease; }
.mini-bar { height: 3px; border-radius: 2px; background: var(--card-2); overflow: hidden; margin-top: 6px; }
.mini-bar > span { display: block; height: 100%; background: var(--text-2); }

.range-tabs { display: flex; gap: 2px; background: var(--card); border-radius: 9px; padding: 2px; }
.range-tabs button { font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 7px; color: var(--text-2); letter-spacing: 0; }
.range-tabs button[aria-pressed="true"] { background: var(--card-3); color: var(--text); }

.hero-change { font-size: 14px; font-weight: 600; margin: -10px 0 6px; }
.hero-extra { border-top: 0.5px solid var(--sep); margin-top: 14px; padding-top: 12px; display: grid; gap: 6px; font-size: 14px; }
.hero-extra > div { display: flex; justify-content: space-between; gap: 10px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-grid .value { font-size: 17px; }
.pill-stat .label .ico { width: 15px; height: 15px; }

/* ---------- Huchas, recurrentes, configuración ------------------------ */
.goal-row .main { padding-right: 4px; }
.goal-hero { text-align: center; margin-bottom: 8px; }
.goal-hero .progress { height: 8px; margin: 14px 0 4px; }
.inline-form .btn + .btn { margin-top: 0; }
.row.is-paused { opacity: .5; }
.area-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 10px 4px 6px; }
.area {
  width: 100%; background: var(--card); border: 0; outline: none; border-radius: var(--radius);
  padding: 12px 14px; font-size: 16px; resize: vertical; line-height: 1.4;
}
.btn .ico { width: 18px; height: 18px; }
.section-title .link-btn { font-size: 15px; color: var(--text); font-weight: 500; }
a.donut-card { color: inherit; }

/* Selector − n + (gasto compartido) */
.stepper { display: flex; align-items: center; gap: 2px; background: var(--card-2); border-radius: 10px; padding: 2px; flex: none; }
.stepper button { width: 32px; height: 30px; border-radius: 8px; font-size: 20px; line-height: 1; color: var(--text); }
.stepper button:active { background: var(--card-3); }
.stepper-val { min-width: 22px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Pagado por papi */
.papi-tag { color: var(--orange); font-weight: 600; }
.papi-sub { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.papi-sub .ico { width: 13px; height: 13px; }
.field label.wide { width: auto; white-space: nowrap; }

/* Anillos de presupuesto pulsables */
button.ring-card { width: 100%; color: inherit; font: inherit; }
button.ring-card:active { transform: scale(0.97); }

/* Autorreparación (index.html) */
.rescue {
  position: fixed; left: 16px; right: 16px; top: calc(env(safe-area-inset-top, 0px) + 40px); z-index: 100;
  background: #1f1f1f; border-radius: 18px; padding: 20px; text-align: center; color: #fff;
  font: 15px/1.4 -apple-system, system-ui, sans-serif; box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.rescue[hidden] { display: none; }
.rescue p { margin: 0 0 16px; color: #8e8e93; }
.rescue strong { color: #fff; }
.rescue button { width: 100%; min-height: 50px; border-radius: 14px; border: 0; background: #fff; color: #000; font: 600 17px -apple-system, system-ui, sans-serif; }

/* ---------- v11: dos gráficas (tú / papi) ------------------------------ */
.donut-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; color: inherit; }
.donut-col { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.donut-col + .donut-col { border-left: 0.5px solid var(--sep); padding-left: 14px; }
.donut-col-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; align-self: flex-start; }
.donut-col .donut-legend { width: 100%; margin-top: 12px; gap: 5px; }
.donut-col .legend-row { font-size: 12.5px; gap: 6px; }
.donut-col .donut-center .num { font-size: 16px; }
.donut-none { height: 118px; display: grid; place-items: center; font-size: 13px; }

/* ---------- v11: selector − n + ----------------------------------------- */
.stepper { display: flex; align-items: center; gap: 10px; background: none; padding: 0; border-radius: 0; flex: none; }
.stepper button {
  width: 30px; height: 30px; border-radius: 50%; padding: 0;
  display: grid; place-items: center; background: var(--card-3); color: var(--text);
  transition: transform .1s, opacity .15s;
}
.stepper button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.stepper button:active:not(:disabled) { transform: scale(0.9); background: var(--text); color: #000; }
.stepper button:disabled { opacity: .3; }
.stepper-val { min-width: 18px; text-align: center; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- v13: "Lo paga", Me deben y Notas -------------------------- */
.pill-choice { display: flex; gap: 6px; flex: 1; justify-content: flex-end; flex-wrap: wrap; padding: 8px 0; }
.pill-choice button {
  padding: 6px 12px; border-radius: 999px; background: var(--card-2); color: var(--text-2);
  font-size: 14px; font-weight: 600; transition: background .15s, color .15s;
}
.pill-choice button[aria-pressed="true"] { background: var(--text); color: #000; }
.note-preview { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.note-row .main { padding-right: 6px; }
.note-date { font-size: 12.5px; font-weight: 500; align-self: flex-start; margin-top: 2px; }
.note-area { min-height: 180px; font-size: 16px; }
.row.is-paused .trail { color: var(--text-2); }

/* ---------- v14: mapa de gastos ---------------------------------------- */
.map-box {
  position: relative; height: 380px; border-radius: var(--radius-lg); overflow: hidden;
  background: #0d0d0d; isolation: isolate;
}
.map-loading { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; }
.map-box .leaflet-container { background: #0d0d0d; font: inherit; }
.map-box .leaflet-control-attribution {
  background: rgba(0, 0, 0, .55) !important; color: #8e8e93 !important; font-size: 9.5px; border-radius: 6px 0 0 0;
}
.map-box .leaflet-control-attribution a { color: #8e8e93 !important; }
.map-cta { display: flex; align-items: center; gap: 12px; margin: 12px 0 0; color: inherit; padding: 14px 16px; }
.map-cta .icon { width: 42px; height: 42px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; flex: none; }
.map-cta .main { flex: 1; min-width: 0; }
.map-cta .title { font-weight: 600; }
.map-cta .subtitle { font-size: 13px; color: var(--text-2); margin-top: 1px; }
.map-cta .ico { width: 20px; height: 20px; }
.map-link { color: var(--blue); }
body.privacy .map-box { filter: blur(10px); }

/* Mapa base de OpenStreetMap en modo oscuro (el calor y los puntos no se ven afectados) */
.map-box .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.35); }

/* ---------- v15: calendario de gasto (Informes) ------------------------ */
.cal-card { padding: 14px 12px 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal-head { margin-bottom: 6px; }
.cal-head div { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-3); }
.cal-cell {
  aspect-ratio: 1 / 1.08; border-radius: 10px; background: transparent;
  display: flex; flex-direction: column; justify-content: space-between; align-items: stretch;
  padding: 5px 4px 4px; color: var(--text); text-align: left; min-width: 0;
  border: 1px solid var(--card-2); transition: transform .1s;
}
.cal-cell.blank { border: 0; }
.cal-cell:active:not(.blank) { transform: scale(0.94); }
.cal-num { font-size: 11px; font-weight: 600; color: var(--text-2); line-height: 1; }
.cal-amt { font-size: 11px; font-weight: 700; text-align: right; line-height: 1; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; }
.cal-cell.dark-text { color: #000; border-color: transparent; }
.cal-cell.dark-text .cal-num { color: rgba(0, 0, 0, .6); }
.cal-cell.today { outline: 2px solid var(--text); outline-offset: 1px; }
.cal-cell.future { opacity: .35; }
.cal-legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 12px; font-size: 11px; color: var(--text-2); }
.cal-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.cal-legend span:first-child { margin-right: 2px; }
.cal-legend span:last-child { margin-left: 2px; }
.stat-grid .pill-stat .value .muted { font-weight: 500; }

/* ---------- v15: colores de categoría ----------------------------------- */
.color-trail { display: inline-flex; align-items: center; gap: 10px; }
.color-trail .hex { font-size: 12.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.swatch { width: 22px; height: 22px; border-radius: 50%; display: inline-block; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.color-preview { display: flex; align-items: center; justify-content: center; gap: 14px; margin: -4px 0 18px; }
.color-preview .icon { width: 52px; height: 52px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; }
.color-preview .icon .ico { width: 24px; height: 24px; }
.dot-lg { width: 52px; height: 52px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.swatch-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.swatch-btn { aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); transition: transform .1s; }
.swatch-btn.selected { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); transform: scale(0.92); }
.color-input { -webkit-appearance: none; appearance: none; width: 44px !important; height: 30px; flex: none !important; padding: 0 !important; border: 0; background: none; border-radius: 8px; }
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 0; border-radius: 8px; }

.pill-btn { white-space: nowrap; }

/* ---------- v16: revisión de movimientos ------------------------------- */
.review-banner {
  display: flex; align-items: center; gap: 12px; margin: -4px 0 14px; padding: 14px 16px;
  border-radius: var(--radius-lg); background: var(--text); color: #000; font-weight: 600; font-size: 15px;
}
.review-banner .main { flex: 1; min-width: 0; line-height: 1.3; }
.review-banner .ico { width: 18px; height: 18px; flex: none; }
.review-count {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 15px; background: #000; color: #fff;
  display: grid; place-items: center; font-size: 15px; font-weight: 700; flex: none;
}
.review-tag { color: var(--text); font-weight: 600; background: var(--card-3); padding: 0 6px; border-radius: 5px; }
.review-step { justify-self: end; font-size: 14px; font-variant-numeric: tabular-nums; }
.review-progress { margin: -6px 0 16px; height: 4px; }
.review-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 6px; }
.review-meta .chip { font-size: 12.5px; padding: 4px 10px; display: inline-flex; align-items: center; gap: 4px; }
.review-meta .chip .ico { width: 12px; height: 12px; }
.review-missing { font-size: 12.5px; font-weight: 600; color: #000; background: var(--text); padding: 2px 8px; border-radius: 999px; letter-spacing: 0; }
.review-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }
.review-actions .btn { max-width: none; margin: 0; }
.review-actions .btn .ico { width: 18px; height: 18px; }
.review-actions .btn-danger { background: var(--card-2); }
.review-done { min-height: 70dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; }
.review-done h2 { font-size: 28px; margin: 14px 0 2px; letter-spacing: -0.02em; }
.review-done p { margin: 0 0 24px; }
.review-done .btn { max-width: 260px; }
.review-done-icon {
  width: 84px; height: 84px; border-radius: 50%; background: var(--text); color: #000;
  display: grid; place-items: center; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
.review-done-icon .ico { width: 42px; height: 42px; stroke-width: 2.4; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- v17: buzón automático --------------------------------------- */
.steps { margin: -4px 0 16px; padding-left: 20px; color: var(--text-2); font-size: 14px; line-height: 1.45; }
.steps li + li { margin-top: 6px; }
.steps b { color: var(--text); font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--text); user-select: all; }

#mb-token { font-size: 14px; }

/* ---------- v21 ------------------------------------------------------------ */
/* Modo privacidad más fuerte: el desenfoque crece con el tamaño del texto. */
body.privacy .num:not(input),
body.privacy .bar-val,
body.privacy .cal-amt {
  filter: blur(9px);
  opacity: .85;
}
/* Cifras grandes: más desenfoque para que no se adivinen */
body.privacy .hero .amount,
body.privacy .donut-center .num,
body.privacy .goal-hero .num,
body.privacy .pill-stat .value { filter: blur(16px); }

/* Reparto por persona */
#nt-people[hidden] { display: none; }
.person-row { gap: 8px; }
.person-row .p-name { flex: 1.4; text-align: left !important; }
.person-row .p-amt { flex: 1; max-width: 110px; text-align: right; font-weight: 600; }
.person-row .p-amt::placeholder { color: var(--text-3); font-weight: 500; }
.person-row .p-cur { color: var(--text-2); font-size: 15px; }
.people-hint { font-size: 12.5px; color: var(--text-2); margin: 0; padding: 4px 16px 12px; line-height: 1.4; }
.people-hint b { color: var(--text); }

/* Selector de icono de categoría */
.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin-bottom: 6px; }
.icon-pick {
  aspect-ratio: 1; border-radius: 50%; background: var(--card-2); color: var(--text-2);
  display: grid; place-items: center; transition: background .15s, color .15s;
}
.icon-pick .ico { width: 18px; height: 18px; }
.icon-pick.selected { background: var(--text); color: #000; }
.color-trail .ico { width: 16px; height: 16px; color: var(--text-3); }

/* ---------- v23: revisar en lista -------------------------------------- */
.review-list .row { align-items: flex-start; }
.review-list .row .icon { margin-top: 2px; }
.review-list .subtitle .ico { width: 12px; height: 12px; vertical-align: -1px; }
.review-list .trail { margin-top: 2px; }
.review-missing.small { font-size: 11px; padding: 1px 7px; }
button.left { background: none; color: var(--accent); font-size: 17px; justify-self: start; padding: 0; }

/* ---------- Guía paso a paso (buzón + atajos) ------------------------ */
.guide-progress { height: 4px; border-radius: 2px; background: var(--card-2); margin: 0 0 18px; overflow: hidden; }
.guide-progress span { display: block; height: 100%; background: var(--text); transition: width .25s; }
.guide-kicker { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 0 4px 4px; }
.guide-title { font-size: 26px; font-weight: 700; margin: 0 4px 16px; letter-spacing: -0.02em; }
.guide-body { padding-bottom: 110px; }
.guide-body > p { color: var(--text-2); font-size: 15px; margin: 0 4px 14px; }
.guide-body > p b { color: var(--text); }
.guide-body .steps { margin: 0 0 16px; }
.guide-body .steps li { margin-top: 8px; }
.guide-hero { width: 72px; height: 72px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; margin: 4px auto 18px; }
.guide-hero svg { width: 34px; height: 34px; }
.guide-hero.ok { background: var(--green); color: #000; }
.guide-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; gap: 10px;
  padding: 12px var(--gutter) calc(12px + var(--safe-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.guide-nav .btn { margin: 0; flex: 1; }
.guide-nav .btn:disabled { opacity: .4; }
.guide-copy { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }
.guide-copy + .guide-copy { margin-top: 8px; }
.guide-copy code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Menlo, monospace; font-size: 13px; color: var(--text); }
.guide-copy .link-btn, .guide-table .link-btn, .steps .link-btn { color: var(--blue); font-size: 13px; font-weight: 600; }
.guide-table { background: var(--card); border-radius: var(--radius-sm); overflow: hidden; font-size: 13px; }
.guide-table > div { display: grid; grid-template-columns: 82px 1fr; gap: 10px; padding: 9px 12px; border-top: 0.5px solid var(--sep); align-items: center; }
.guide-table > div:first-child { border-top: 0; }
.guide-table .gt-head { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.guide-table code { font-family: ui-monospace, Menlo, monospace; color: var(--text); }
.guide-table span { word-break: break-all; }
.var { display: inline-block; background: rgba(10, 132, 255, .18); color: #64b5ff; border-radius: 6px; padding: 1px 6px; font-weight: 600; word-break: normal; }

/* Dibujos de pantallas */
.mock { position: relative; border-radius: 14px; overflow: hidden; margin: 0 0 16px; font-size: 11.5px; line-height: 1.4; }
.mk-desk { background: #fff; color: #202124; min-height: 170px; font-family: Roboto, Arial, sans-serif; box-shadow: 0 0 0 1px #2a2a2a; }
.mk-titlebar { display: flex; align-items: center; gap: 5px; background: #f1f3f4; padding: 7px 10px; color: #5f6368; }
.mk-titlebar i { width: 8px; height: 8px; border-radius: 50%; background: #dadce0; }
.mk-titlebar span { margin-left: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-menu, .mk-toolbar { padding: 8px 10px; border-bottom: 1px solid #e8eaed; white-space: nowrap; overflow: hidden; }
.mk-toolbar { display: flex; align-items: center; gap: 8px; }
.mk-sp { flex: 1; }
.mk-blue { color: #1a73e8; font-weight: 500; }
.mk-grid { height: 70px; background-image: linear-gradient(#e8eaed 1px, transparent 1px), linear-gradient(90deg, #e8eaed 1px, transparent 1px); background-size: 48px 18px; }
.mk-dropdown { position: absolute; top: 64px; z-index: 1; background: #fff; border-radius: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.25); padding: 4px 0; min-width: 150px; }
.mk-dropdown > * { display: block; padding: 5px 12px; }
.mk-dropdown.inline { position: static; box-shadow: 0 1px 6px rgba(0,0,0,.2); margin-top: 6px; }
.mk-code { margin: 0; padding: 10px 12px; font: 11px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; color: #188038; }
.mk-code s { color: #c5221f; display: block; }
.mk-code em { font-style: normal; }
.mk-dialog { margin: 12px; padding: 12px; border-radius: 8px; box-shadow: 0 1px 8px rgba(0,0,0,.2); background: #fff; }
.mk-dialog p { margin: 6px 0; color: #5f6368; }
.mk-row { padding: 6px 0; color: #5f6368; }
.mk-field { display: flex; justify-content: space-between; gap: 10px; padding: 7px 8px; border: 1px solid #dadce0; border-radius: 4px; margin-top: 7px; }
.mk-field span { color: #5f6368; }
.mk-field b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-field.hot { border: 2px solid #34a853; box-shadow: 0 0 0 4px rgba(52,168,83,.25); }
.mk-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 10px; color: #1a73e8; }
.mk-tap { display: inline-block; position: relative; border-radius: 6px; padding: 1px 6px; margin: -1px -2px; background: rgba(52,168,83,.16); color: #0b6b2b; font-weight: 600;
  outline: 2px solid #34a853; animation: mk-pulse 1.6s ease-out infinite; }
.mk-tap.mk-line { display: block; margin: 2px 4px; }
.mk-tap.blue { background: #1a73e8; color: #fff; padding: 4px 12px; }
.mk-tap.link { background: none; color: #1a73e8; }
@keyframes mk-pulse { 0% { box-shadow: 0 0 0 0 rgba(52,168,83,.55); } 100% { box-shadow: 0 0 0 9px rgba(52,168,83,0); } }
.mk-phone { background: #1c1c1e; color: #fff; max-width: 260px; margin: 0 auto 16px; border-radius: 30px; padding: 26px 12px 14px; box-shadow: 0 0 0 5px #2c2c2e; font-family: var(--font); font-size: 12.5px; }
.mk-notch { position: absolute; top: 8px; left: 50%; width: 70px; height: 9px; border-radius: 6px; background: #000; transform: translateX(-50%); }
.mk-ios-title { font-weight: 700; font-size: 16px; margin: 2px 4px 10px; }
.mk-action { background: #2c2c2e; border-radius: 10px; padding: 8px 10px; margin-top: 6px; color: #d1d1d6; }
.mk-action b { color: #fff; font-weight: 600; }
.mk-action.hot { outline: 2px solid var(--green); }
.mk-phone .mk-tap { background: rgba(50,215,75,.18); color: var(--green); outline-color: var(--green); }
.guide-warn { border: 1px solid rgba(255, 159, 10, .45); font-size: 14px; margin-top: 6px; }
.guide-warn > b { color: var(--orange); }
.guide-warn code { font-family: ui-monospace, Menlo, monospace; color: var(--text); }

/* ---------- Secciones reordenables ----------------------------------- */
.block { display: contents; }
.order-link { display: block; margin: 28px auto 8px; padding: 10px 16px; font-size: 14px; color: var(--text-2); border-radius: 999px; background: var(--card); }
.order-list .row { min-height: 52px; }
.order-btns { display: flex; gap: 6px; }
.order-btns .icon-btn { width: 36px; height: 36px; font-size: 17px; }
.order-btns .icon-btn:disabled { opacity: .25; }
.block ~ .block > .hero:first-child { margin-top: 28px; }
