/* Metas de ahorro */
.gl-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 560px) {
  .gl-summary { grid-template-columns: 1fr 1fr; }
  .gl-summary .stat:last-child { grid-column: 1 / -1; }
}

.gl-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }

.gl-card {
  display: grid; gap: 14px; align-content: start; min-width: 0; padding: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.gl-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.gl-ico { width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--g); color: #fff; box-shadow: 0 10px 22px -12px var(--glow); }
.gl-ico .icon { width: 22px; height: 22px; }
.gl-card.theme-noir .gl-ico { border: 1px solid var(--line); }
.gl-card.is-done .gl-ico { background: var(--mint); color: #04332E; box-shadow: none; }
.gl-name { min-width: 0; display: grid; gap: 2px; }
.gl-name b { font-family: var(--font-display); font-size: 17px; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-name span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gl-figures { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.gl-money { min-width: 0; display: grid; gap: 2px; }
.gl-money b { font-family: var(--font-display); font-size: clamp(22px, 4vw, 28px); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-money > span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-pct { flex: none; font-family: var(--font-display); font-weight: 650; font-size: 18px; font-variant-numeric: tabular-nums; }

.gl-card .meter > i { background: var(--g); }
.gl-card.theme-noir .meter > i { background: var(--muted); }
.gl-card.is-done .meter > i { background: var(--mint); }

.gl-due { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); min-width: 0; }
.gl-due .icon { width: 16px; height: 16px; }
.gl-due span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-due b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.gl-due.is-overdue { color: var(--amber); }
:root[data-theme='light'] .gl-due.is-overdue { color: #9A6200; }
.gl-done { justify-self: start; background: rgba(24, 227, 160, 0.16); color: var(--pos); }
:root[data-theme='light'] .gl-done { color: #0B7F57; }

.gl-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding-top: 2px; }
.gl-tools { display: inline-flex; gap: 2px; }

.gl-history { display: grid; gap: 2px; max-height: min(52vh, 420px); overflow-y: auto; margin: 0 -6px; }
.gl-history-sum { color: var(--muted); }
.gl-history-sum b { color: var(--text); }
.gl-history-empty { padding: 22px 6px; text-align: center; color: var(--muted); }
.gl-amt { font-family: var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.gl-amt.pos { color: var(--pos); }
.gl-amt.neg { color: var(--neg); }

@media (max-width: 380px) {
  .gl-card { padding: 16px; }
  .gl-actions .btn { flex: 1 1 100%; justify-content: center; }
  .gl-tools { margin-inline: auto; }
}

/* Asistente de metas (gw-) */
.gw-stack { display: grid; gap: 16px; min-width: 0; align-content: start; }
.gw-stack > [hidden], .gw-group[hidden] { display: none; }
.gw-group { display: grid; gap: 10px; min-width: 0; }
.gw-group .chips { gap: 8px; }
.gw-checks { display: grid; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--input-bg); }

.gw-amount.amount-input { padding-inline: 48px 52px; }
.gw-amount.gw-sm { font-size: 26px; min-height: 58px; border-radius: 16px; }
.gw-sm + .cur { font-size: 20px; }
@container (max-width: 480px) {
  .gw-amount.amount-input { font-size: 34px; min-height: 64px; }
  .gw-amount.gw-sm { font-size: 24px; min-height: 54px; }
}

.gw-result {
  margin: 0; padding: 14px 16px; border-radius: var(--radius-sm); font-size: 15px; line-height: 1.5;
  background: rgba(139, 92, 246, 0.12); border: 1px solid rgba(139, 92, 246, 0.4);
}
.gw-result:empty { display: none; }
.gw-result b { font-family: var(--font-display); font-size: 17px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.gw-warn, .gw-tip {
  display: flex; align-items: flex-start; gap: 10px; margin: 0; font-size: 13.5px; line-height: 1.5;
}
.gw-warn:empty { display: none; }
.gw-warn { color: var(--amber); font-weight: 600; }
:root[data-theme='light'] .gw-warn { color: #9A6200; }
.gw-tip { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--input-bg); color: var(--muted); }
.gw-tip[hidden] { display: none; }
.gw-tip.is-ok { color: var(--pos); border-color: rgba(24, 227, 160, 0.4); }
:root[data-theme='light'] .gw-tip.is-ok { color: #0B7F57; }
.gw-warn .icon, .gw-tip .icon { width: 17px; height: 17px; flex: none; margin-top: 2px; }
.gw-tip .amt { color: var(--text); font-weight: 650; }

.gw-chart { display: grid; gap: 4px; min-width: 0; }
.gw-chart .chart-key { margin: 0; flex-wrap: wrap; gap: 6px 16px; }
@container (min-width: 820px) { .gw-inline-chart { display: none; } }

.gw-summary { display: grid; grid-template-columns: minmax(84px, max-content) minmax(0, 1fr); gap: 0; margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--input-bg); overflow: hidden; }
.gw-summary dt, .gw-summary dd { margin: 0; padding: 12px 16px; border-top: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.gw-summary dt { color: var(--muted); font-size: 13.5px; }
.gw-summary dd { font-weight: 600; font-variant-numeric: tabular-nums; }
.gw-summary dt:first-of-type, .gw-summary dt:first-of-type + dd { border-top: 0; }
.gw-sum-name { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.gw-sum-name > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.gw-dot { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--g); color: #fff; }
.gw-dot .icon { width: 15px; height: 15px; }
@container (max-width: 400px) {
  .gw-summary { grid-template-columns: minmax(0, 1fr); }
  .gw-summary dt { padding-bottom: 0; border-top: 1px solid var(--line); }
  .gw-summary dd { padding-top: 2px; border-top: 0; }
  .gw-summary dt:first-of-type { border-top: 0; }
}

/* Tarjeta de simulación en vivo */
.gw-preview { gap: 16px; }
.gw-rows { display: grid; gap: 0; margin: 0; }
.gw-rows > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.gw-rows dt { color: var(--muted); }
.gw-rows dd { margin: 0; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 380px) {
  .gw-checks { padding: 12px; }
}

/* Selector de modo: dos mitades que parten el texto si no cabe */
.gw-stack .seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
.gw-stack .seg button { height: auto; min-height: 40px; padding: 6px 10px; justify-content: center; text-align: center; white-space: normal; line-height: 1.25; }

/* Los botones del asistente se quedan a la vista dentro del modal */
.gw-modal .wz-nav {
  position: sticky; bottom: -24px; z-index: 3; margin: 0 -24px -24px;
  padding: 18px 24px calc(22px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent 0, var(--surface) 16px);
}
@container (max-width: 559px) {
  .gw-modal .wz-nav { gap: 8px; padding-top: 14px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .gw-modal .wz-nav .btn-ghost { flex: 1 1 0; min-width: 0; padding-inline: 10px; }
  .gw-modal .wz-nav .btn-primary { flex: 1 1 100%; }
}
@container (min-width: 820px) {
  .gw-modal .wz-nav { position: static; margin: 0; padding: 4px 0 0; background: none; }
}
