/* Comfort Ledger — critical path: shell, coach, inputs, overlays (#9 audit; load before charts) */

/* Skip link (keyboard / screen reader) */
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link:focus {
  position: fixed;
  left: 12px;
  top: max(12px, env(safe-area-inset-top));
  z-index: 9999;
  width: auto;
  height: auto;
  margin: 0;
  padding: 10px 14px;
  clip: auto;
  overflow: visible;
  white-space: normal;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
}

:root {
  /* Midnight / OLED-adjacent dark (tendencia UI 2025–26): void blue-black + teal */
  --bg: #05070d;
  --bg-warm: #080b12;
  --bg-grid: rgba(100, 116, 139, 0.045);
  --surface: #0e131d;
  --surface-2: #121a27;
  --text: #f1f5f9;
  --text-soft: #94a3b8;
  --border: rgba(148, 163, 184, 0.14);
  --accent: #2dd4bf;
  --accent-soft: rgba(45, 212, 191, 0.14);
  --accent-line: linear-gradient(180deg, #5eead4, #0f766e);
  --positive: #34d399;
  --positive-soft: rgba(52, 211, 153, 0.14);
  --alert: #fb923c;
  --alert-soft: rgba(251, 146, 60, 0.14);
  --negative: #fb7185;
  --negative-glow: 0 0 0 1px rgba(251, 113, 133, 0.35);
  --negative-soft: rgba(251, 113, 133, 0.12);
  --ink-deep: #f8fafc;
  --navy-deep: #7dd3fc;
  --holo-cyan: #22d3ee;
  --holo-cyan-dim: rgba(34, 211, 238, 0.28);
  --holo-glow: 0 12px 40px rgba(0, 0, 0, 0.42);
  --holo-glow-strong: 0 24px 64px rgba(0, 0, 0, 0.55);
  --holo-scan: linear-gradient(
    90deg,
    transparent 0%,
    rgba(45, 212, 191, 0.05) 45%,
    rgba(45, 212, 191, 0.12) 50%,
    rgba(45, 212, 191, 0.05) 55%,
    transparent 100%
  );
  --holo-panel: linear-gradient(165deg, #0f141c 0%, #121a28 48%, #0c1018 100%);
  --holo-rail: var(--accent-line);
  --donut-exp: #22d3ee;
  --donut-debt: #fb7185;
  --donut-free: #2dd4bf;
  --coach-bg: linear-gradient(165deg, #0d121c 0%, #111827 50%, #0a0e16 100%);
  --coach-border: rgba(45, 212, 191, 0.22);
  --coach-accent: #99f6e4;
  --coach-accent-soft: rgba(13, 148, 136, 0.2);
  --radius: 12px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  /* Neon / glossy accents (revert by removing uses below) */
  --neon-border: rgba(94, 234, 212, 0.22);
  --neon-border-strong: rgba(94, 234, 212, 0.3);
  --neon-outer: 0 0 0 1px rgba(34, 211, 238, 0.07), 0 0 36px rgba(34, 211, 238, 0.1);
  --neon-inset: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --neon-rail: 0 0 16px rgba(94, 234, 212, 0.85), 4px 0 28px rgba(34, 211, 238, 0.28);
  --input-bg: #0c121c;
  --track-bg: #1e293b;
  --font-sans: "Plus Jakarta Sans", "Noto Sans SC", system-ui, sans-serif;
  --font-display: "Outfit", "Noto Sans SC", system-ui, sans-serif;
  font-family: var(--font-sans);
}

html {
  color-scheme: dark light;
}

/* Light palette — toggled via `[data-theme="light"]` on `<html>` (audit #32) */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e9eef6;
  --bg-warm: #e4e9f2;
  --bg-grid: rgba(15, 23, 42, 0.038);
  --surface: #ffffff;
  --surface-2: #f4f7fb;
  --text: #0f172a;
  --text-soft: #64748b;
  --border: rgba(15, 23, 42, 0.12);
  --input-bg: #f8fafc;
  --track-bg: #e2e8f0;
  --holo-glow: 0 12px 40px rgba(15, 23, 42, 0.08);
  --holo-glow-strong: 0 22px 56px rgba(15, 23, 42, 0.1);
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.1);
  --neon-border: rgba(13, 148, 136, 0.22);
  --neon-border-strong: rgba(13, 148, 136, 0.32);
  --neon-outer: 0 0 0 1px rgba(15, 23, 42, 0.06), 0 10px 28px rgba(15, 23, 42, 0.07);
  --neon-inset: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --holo-panel: linear-gradient(165deg, #f8fafc 0%, #f1f5f9 48%, #e8eef4 100%);
  --coach-bg: linear-gradient(165deg, #f1f5f9 0%, #eef2f7 52%, #e8eef4 100%);
  --coach-border: rgba(13, 148, 136, 0.25);
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  /* Photo layer + dark wash so panels/type stay readable; path vs COMFORT-LEDGER-abrir-aqui.html */
  background-image:
    radial-gradient(ellipse 130% 90% at 50% -30%, rgba(45, 212, 191, 0.09), transparent 58%),
    radial-gradient(ellipse 70% 55% at 100% 0%, rgba(14, 165, 233, 0.06), transparent 50%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(99, 102, 241, 0.04), transparent 45%),
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px),
    linear-gradient(180deg, rgba(5, 7, 13, 0.76) 0%, rgba(5, 7, 13, 0.84) 45%, rgba(5, 7, 13, 0.9) 100%),
    url("assets/page-background.png");
  background-size: auto, auto, auto, 32px 32px, 32px 32px, auto, cover;
  background-position: center, center, center, 0 0, 0 0, center, center;
  background-repeat: no-repeat, no-repeat, no-repeat, repeat, repeat, no-repeat, no-repeat;
  background-attachment: fixed, fixed, fixed, fixed, fixed, fixed, fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:root[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 115% 75% at 50% -25%, rgba(45, 212, 191, 0.12), transparent 52%),
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px),
    linear-gradient(180deg, #dfe7f3 0%, #f1f5f9 50%, #e9eef6 100%);
  background-size: auto, 32px 32px, 32px 32px, auto;
  background-position: center, 0 0, 0 0, center;
  background-repeat: no-repeat, repeat, repeat, no-repeat;
  background-attachment: fixed, fixed, fixed, fixed;
}

:root[data-theme="light"] .brand h1 {
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  -webkit-text-fill-color: unset;
  color: var(--text);
}

:root[data-theme="light"] .pill-trust--muted {
  background: rgba(248, 250, 252, 0.85);
  border-color: rgba(15, 23, 42, 0.1);
}

@media (max-width: 900px) {
  /* iOS often paints fixed backgrounds poorly; scroll attachment is safer on small viewports */
  body {
    background-attachment: scroll;
  }
  :root[data-theme="light"] body {
    background-attachment: scroll, scroll, scroll, scroll;
  }
}

body.lang-zh {
  font-family: "Noto Sans SC", "Source Sans 3", system-ui, sans-serif;
}

body.lang-zh .brand h1,
body.lang-zh .panel h2,
body.lang-zh .panel h3,
body.lang-zh .dash-tactical-title {
  font-family: "Noto Sans SC", "Outfit", system-ui, sans-serif;
}

.app-shell {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, #1e3a5f, #0e7490 28%, #5eead4 50%, #0e7490 72%, #1e3a5f);
  box-shadow:
    0 0 12px rgba(45, 212, 191, 0.55),
    0 0 28px rgba(34, 211, 238, 0.35);
  z-index: 50;
  pointer-events: none;
}


.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px max(16px, env(safe-area-inset-left)) 48px max(16px, env(safe-area-inset-right));
}

/* Landing hero: masthead only (look) */
.masthead {
  position: relative;
  margin-bottom: 28px;
  padding: clamp(20px, 3.6vw, 30px) clamp(18px, 2.6vw, 28px) clamp(22px, 3.6vw, 32px);
  border-radius: clamp(16px, 2.8vw, 22px);
  border: 1px solid var(--neon-border);
  background: linear-gradient(
    165deg,
    rgba(12, 17, 26, 0.82) 0%,
    rgba(10, 14, 22, 0.58) 52%,
    rgba(8, 11, 18, 0.44) 100%
  );
  backdrop-filter: blur(18px) saturate(1.12);
  -webkit-backdrop-filter: blur(18px) saturate(1.12);
  box-shadow:
    var(--shadow),
    var(--neon-outer),
    0 0 100px rgba(45, 212, 191, 0.045),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.masthead::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 95% 75% at 14% 0%, rgba(45, 212, 191, 0.11), transparent 58%),
    radial-gradient(ellipse 50% 42% at 92% 6%, rgba(56, 189, 248, 0.08), transparent 52%);
  pointer-events: none;
}

.masthead::after {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(94, 234, 212, 0.38) 18%,
    rgba(56, 189, 248, 0.28) 50%,
    rgba(94, 234, 212, 0.38) 82%,
    transparent
  );
  pointer-events: none;
}

.masthead-grid {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  flex: 1;
  min-width: min(100%, 260px);
}

.brand-mark-img {
  width: auto;
  height: clamp(48px, 10vw, 62px);
  max-width: clamp(58px, 12vw, 74px);
  aspect-ratio: 221 / 188;
  border-radius: 0;
  object-fit: contain;
  object-position: center;
  flex-shrink: 0;
  background: transparent;
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.35));
}

.brand-copy {
  flex: 1;
  min-width: 180px;
}

.brand-eyebrow {
  margin: 0 0 4px;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 28px rgba(45, 212, 191, 0.28);
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.95rem, 4.6vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.04;
  color: #ecfeff;
}

@supports ((-webkit-background-clip: text) and ((-webkit-text-fill-color: transparent) or (color: transparent))) {
  .brand h1 {
    background: linear-gradient(118deg, #f8fafc 6%, #e0fdfa 38%, #5eead4 68%, #7dd3fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
}

.tagline {
  margin: 10px 0 0;
  max-width: 38ch;
  color: rgba(148, 163, 184, 0.96);
  font-size: clamp(0.9rem, 1.5vw, 1.02rem);
  font-weight: 500;
  line-height: 1.45;
}

.masthead-aside {
  max-width: 26rem;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.lang-switch,
.theme-switch {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.lang-switch-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.lang-switch-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.lang-btn {
  min-width: 44px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(94, 234, 212, 0.14);
  background: rgba(15, 23, 42, 0.5);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.lang-btn:hover {
  border-color: rgba(45, 212, 191, 0.45);
  color: var(--accent);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.lang-btn--active {
  border-color: rgba(45, 212, 191, 0.55);
  background: linear-gradient(165deg, rgba(45, 212, 191, 0.18) 0%, rgba(45, 212, 191, 0.08) 100%);
  color: var(--text);
  box-shadow: 0 0 20px rgba(45, 212, 191, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.pill-trust {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: linear-gradient(165deg, rgba(45, 212, 191, 0.14) 0%, rgba(45, 212, 191, 0.06) 100%);
  border: 1px solid rgba(94, 234, 212, 0.32);
  padding: 6px 13px;
  border-radius: 999px;
  box-shadow: 0 0 22px rgba(45, 212, 191, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.pill-trust--muted {
  color: var(--text-soft);
  background: rgba(15, 23, 42, 0.45);
  border-color: rgba(148, 163, 184, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Trial countdown pill — amber/warning tone */
.pill-trust--trial {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
:root[data-theme="light"] .pill-trust--trial {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(202, 138, 4, 0.4);
  color: #92400e;
}

/* ── Onboarding step progress bar ── */
.onboarding-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
}
.onboarding-progress-steps {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}
.onboarding-step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.25);
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  transition: background 0.25s, border-color 0.25s;
}
.onboarding-step-dot.active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.4);
}
.onboarding-step-dot.done {
  background: rgba(45, 212, 191, 0.55);
  border-color: rgba(45, 212, 191, 0.7);
}
.onboarding-step-line {
  width: 28px;
  height: 1.5px;
  background: rgba(148, 163, 184, 0.2);
  transition: background 0.25s;
}
.onboarding-step-line.done {
  background: rgba(45, 212, 191, 0.45);
}
.onboarding-progress-label {
  font-size: 0.72rem;
  color: var(--text-soft);
  letter-spacing: 0.03em;
}

/* Step group visibility — JS sets data-onboarding-step on the form */
.onboarding-step-group { display: none; }
.onboarding-step-group.active { display: block; }

/* ── Post-onboarding welcome card ── */
.comfort-welcome-card {
  max-width: 420px;
}
.welcome-tips {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.welcome-tips li {
  padding: 10px 14px;
  background: rgba(45, 212, 191, 0.06);
  border: 1px solid rgba(45, 212, 191, 0.15);
  border-radius: 10px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text);
}
.welcome-tips li strong {
  color: var(--accent);
}

/* ── Coach side-by-side examples ── */
.coach-example-compare {
  margin: 14px 0 0;
  padding: 14px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 12px;
}
:root[data-theme="light"] .coach-example-compare {
  background: rgba(248, 250, 252, 0.7);
  border-color: rgba(148, 163, 184, 0.22);
}
.coach-example-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 0 0 10px;
}
.coach-example-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 520px) {
  .coach-example-grid { grid-template-columns: 1fr; }
}
.coach-example-card {
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.15);
}
.coach-example-card--ai {
  background: rgba(45, 212, 191, 0.06);
  border-color: rgba(45, 212, 191, 0.2);
}
.coach-example-mode {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin: 0 0 6px;
}
.coach-example-card--ai .coach-example-mode {
  color: var(--accent);
}
.coach-example-text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text);
  border: none;
  padding: 0;
  font-style: italic;
}

.backup-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 8px;
}

.backup-toolbar .btn-ghost {
  font-size: 0.78rem;
  padding: 0.38rem 0.7rem;
}

.comfort-backup-status {
  width: 100%;
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-soft);
  line-height: 1.35;
  text-align: right;
}

.comfort-backup-status--ok {
  color: var(--positive);
}

.comfort-backup-status--err {
  color: var(--negative);
}

.host-profile {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.host-profile[hidden] {
  display: none !important;
}

.host-profile-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.host-profile-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.host-profile-note {
  font-size: 0.74rem;
  color: var(--text-soft);
}

@media (max-width: 640px) {
  .app {
    padding-top: 22px;
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }

  .masthead-grid {
    flex-direction: column;
    align-items: stretch;
  }

  .masthead-aside {
    text-align: left;
    max-width: none;
    align-items: stretch;
  }

  .lang-switch {
    align-items: stretch;
  }

  .lang-switch-btns {
    justify-content: flex-start;
  }

  .trust-row {
    justify-content: flex-start;
  }

  .backup-toolbar {
    justify-content: flex-start;
  }

  .comfort-backup-status {
    text-align: left;
  }

  .host-profile {
    justify-content: flex-start;
  }

  .host-profile-copy {
    align-items: flex-start;
  }

  .donut-wrap {
    justify-content: center;
  }

  .panel {
    padding: 16px 14px;
  }
}

@media (max-width: 480px) {
  .app {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .section-head {
    flex-wrap: wrap;
  }

  .section-head .btn-ghost {
    width: 100%;
    text-align: center;
    margin-top: 4px;
  }

  .inputs-card {
    min-height: 0;
    max-height: none;
  }

  .inputs-card .list-scroll {
    min-height: 200px;
    max-height: min(52vh, 420px);
  }

  .coach-thread {
    max-height: min(38vh, 220px);
  }

  .btn-ghost,
  .btn-coach,
  .lang-btn {
    min-height: 44px;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--neon-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow), var(--neon-outer), var(--neon-inset);
}

.panel h2,
.panel h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink-deep);
}

.panel h2 {
  font-size: 1.2rem;
  letter-spacing: 0.01em;
}

.sub {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--text-soft);
  line-height: 1.4;
}

.health {
  margin-bottom: 16px;
  background: linear-gradient(135deg, #0f141c 0%, #121a28 55%, #0c1018 100%);
  border-color: var(--neon-border-strong);
  box-shadow:
    var(--shadow),
    var(--neon-outer),
    0 0 48px rgba(45, 212, 191, 0.07),
    var(--neon-inset);
}

.goals-panel {
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(165deg, #0e131d 0%, #121a27 52%, #0a0e16 100%);
  border-color: var(--neon-border-strong);
  box-shadow:
    var(--shadow),
    var(--neon-outer),
    0 0 44px rgba(34, 211, 238, 0.08),
    var(--neon-inset);
}

.goals-panel > * {
  position: relative;
  z-index: 1;
}

.goals-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse 90% 55% at 100% 0%, rgba(20, 184, 166, 0.12), transparent 55%);
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
}

.goals-panel-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Altura fija (~mitad del bloque anterior); el scroll va dentro */
  height: min(170px, 21vh);
  max-height: min(170px, 21vh);
  overflow: hidden;
}

.goals-panel-body .post-dash-summary--dark {
  margin-top: 4px;
  flex-shrink: 0;
}

/* Sobrescribe .post-dash-scroll: sin min-height:0 el flex no encoge y la caja crece con cada fila */
.goals-panel-body > .post-dash-scroll.goals-scroll-wrap {
  flex: 1 1 0%;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.goals-list {
  margin-top: 0;
}

.goals-empty {
  margin: 0;
  padding: 2px 0 6px;
  max-width: 72ch;
}

.goal-row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(96px, 120px) 76px minmax(92px, 104px) 44px;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.goal-row:last-child {
  border-bottom: none;
}

.goal-apart {
  text-align: right;
  padding: 4px 0;
}

.goal-apart-hint {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 2px;
}

.goal-apart strong {
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

@media (max-width: 720px) {
  .goal-row {
    grid-template-columns: 1fr 1fr 44px;
    grid-template-rows: auto auto auto;
  }

  .goal-row label:nth-child(1) {
    grid-column: 1 / -1;
  }

  .goal-row label:nth-child(2) {
    grid-column: 1;
  }

  .goal-row label:nth-child(3) {
    grid-column: 2;
  }

  .goal-apart {
    grid-column: 1 / -1;
    text-align: left;
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
  }

  .goal-apart-hint {
    display: inline;
    margin-bottom: 0;
  }

  .goal-row .row-remove {
    grid-row: 1 / span 3;
    grid-column: 3;
    align-self: start;
    justify-self: center;
  }
}

.post-dash-wrap {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.post-dash-global-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.post-dash-hint {
  margin: 0;
  max-width: 72ch;
}

.post-dash-notify-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.post-dash-notify-status {
  font-size: 0.86rem;
  color: var(--text-soft);
}

.post-dash-today {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 176, 80, 0.45);
  background: linear-gradient(135deg, rgba(255, 176, 80, 0.14), rgba(255, 176, 80, 0.05));
  margin: 0 0 14px 0;
  font-size: 0.94rem;
}

.post-dash-today[data-tone="due"] {
  border-color: rgba(255, 120, 120, 0.55);
  background: linear-gradient(135deg, rgba(255, 120, 120, 0.18), rgba(255, 120, 120, 0.06));
}

.post-dash-today-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.98rem;
}

.post-dash-today-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.post-dash-today-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-soft);
}

.post-dash-today-list li strong {
  color: var(--text);
}

.post-dash-budgets {
  max-height: none;
  margin-bottom: 14px;
}

.post-dash-budget-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  row-gap: 6px;
  column-gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.06));
  background: rgba(255, 255, 255, 0.015);
  margin-bottom: 10px;
}

.post-dash-budget-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  grid-column: 1 / 2;
}

.post-dash-budget-head select,
.post-dash-budget-head input[type="text"] {
  min-width: 140px;
}

.post-dash-budget-head .post-dash-budget-amt {
  display: flex;
  align-items: center;
  gap: 6px;
}

.post-dash-budget-head .post-dash-budget-amt input {
  width: 110px;
}

.post-dash-budget-row .post-dash-row-delete {
  grid-column: 2 / 3;
  justify-self: end;
}

.post-dash-budget-meta {
  grid-column: 1 / 3;
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--text-soft);
}

.post-dash-budget-meta strong {
  color: var(--text);
}

.post-dash-budget-bar {
  grid-column: 1 / 3;
  height: 8px;
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  overflow: hidden;
}

.post-dash-budget-bar > i {
  display: block;
  height: 100%;
  background: #14b8a6;
  transition: width 280ms ease;
}

.post-dash-budget-bar[data-tone="warn"] > i {
  background: #f59e0b;
}

.post-dash-budget-bar[data-tone="over"] > i {
  background: #ef4444;
}

.post-dash-budget-empty {
  padding: 18px 10px;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.post-dash-weekly {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(88, 160, 255, 0.4);
  background: linear-gradient(135deg, rgba(88, 160, 255, 0.12), rgba(88, 160, 255, 0.04));
  margin: 0 0 14px 0;
  font-size: 0.94rem;
}

.post-dash-weekly-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.post-dash-weekly-title {
  margin: 0;
  font-weight: 600;
}

.post-dash-weekly-dismiss {
  background: transparent;
  border: 0;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 0.86rem;
  padding: 2px 8px;
  border-radius: 6px;
}

.post-dash-weekly-dismiss:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.post-dash-weekly-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px 14px;
}

.post-dash-weekly-grid dt {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin: 0;
}

.post-dash-weekly-grid dd {
  font-size: 1.02rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.post-dash-weekly-top {
  margin: 4px 0 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.post-dash-weekly-top li strong {
  color: var(--text);
}

.post-dash-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .post-dash-split {
    grid-template-columns: 1fr;
  }
}

.post-dash-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(440px, 52vh);
  padding-bottom: 12px;
}

.post-dash-card > .section-head,
.post-dash-card > .post-dash-card-lede,
.post-dash-card > .post-dash-summary--dark {
  flex-shrink: 0;
}

.post-dash-card-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0;
  line-height: 1.15;
}

.post-dash-card-lede {
  margin: 0 0 8px;
  font-size: 0.86rem;
  line-height: 1.45;
  max-width: none;
}

.post-dash-summary--dark {
  flex-shrink: 0;
  margin: 0 0 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: linear-gradient(165deg, #14161c 0%, #1a1c24 42%, #12141a 100%);
  color: #e8e4dc;
  border: 1px solid var(--neon-border-strong);
  font-size: 0.88rem;
  line-height: 1.45;
  box-shadow:
    var(--neon-inset),
    0 0 28px rgba(34, 211, 238, 0.1);
}

.post-dash-summary--dark strong {
  color: #99f6e4;
  font-weight: 600;
}

.post-dash-summary-muted {
  color: rgba(232, 228, 220, 0.62);
}

.post-dash-scroll {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.post-dash-utility-row,
.post-dash-sub-row {
  padding: 12px 12px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.post-dash-utility-row--cancelled,
.post-dash-sub-row--cancelled {
  opacity: 0.55;
}

.post-dash-utility-row.post-dash-highlight,
.post-dash-sub-row.post-dash-highlight {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  transition: outline-color 0.35s ease;
}

.post-dash-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}

@media (max-width: 520px) {
  .post-dash-row-grid {
    grid-template-columns: 1fr;
  }
}

.post-dash-utility-row label span,
.post-dash-sub-row label span {
  display: block;
  font-size: 0.72rem;
  color: var(--text-soft);
  margin-bottom: 3px;
  line-height: 1.25;
  word-break: break-word;
}

.post-dash-utility-meta,
.post-dash-sub-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-soft);
  line-height: 1.35;
}

.post-dash-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 2px;
}

.post-dash-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-dash-unsub {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.82rem;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid rgba(20, 184, 166, 0.45);
  background: linear-gradient(165deg, #1a1c24 0%, #14161c 100%);
  color: #ccfbf1;
  text-shadow: 0 0 12px rgba(45, 212, 191, 0.55), 0 0 28px rgba(6, 182, 212, 0.35);
  box-shadow: 0 8px 22px rgba(18, 20, 26, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  max-width: 100%;
  word-break: break-word;
}

.btn-dash-unsub:hover {
  color: #f0fdfa;
  border-color: rgba(45, 212, 191, 0.65);
}

.post-dash-sub-row .row-remove,
.post-dash-utility-row .row-remove {
  font-size: 0.95rem;
  position: relative;
  z-index: 3;
}

.health-score {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 10px;
}

.health-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 6px solid var(--border);
}

.health-ring.positive {
  border-color: var(--positive);
  background: var(--positive-soft);
}

.health-ring.alert {
  border-color: var(--alert);
  background: var(--alert-soft);
}

.health-ring.negative {
  border-color: var(--negative);
  box-shadow: var(--negative-glow);
  background: var(--negative-soft);
}

.health-copy {
  flex: 1;
  min-width: 0;
}

.health-copy strong {
  display: block;
  font-size: 1.02rem;
  margin-bottom: 4px;
  line-height: 1.25;
}

.health-copy p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.88rem;
  max-width: 62ch;
  line-height: 1.45;
}

.health-metrics {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.health-metrics li {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.8rem;
  color: var(--text-soft);
  word-break: break-word;
}

.health-metrics li strong {
  display: block;
  color: var(--text);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 14px;
  margin-bottom: 14px;
  /* Alinea por arriba: la columna del coach + relojes no se estira hasta el fondo de los gráficos */
  align-items: start;
}

@media (max-width: 900px) {
  .grid-main {
    grid-template-columns: 1fr;
  }
}

.coach-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.coach-column .coach {
  flex: 0 0 auto;
}

.coach {
  position: relative;
  overflow: hidden;
  background: var(--coach-bg);
  border-color: var(--neon-border-strong);
  box-shadow:
    var(--shadow),
    var(--neon-outer),
    0 0 48px rgba(45, 212, 191, 0.07),
    var(--neon-inset);
}

.coach > * {
  position: relative;
  z-index: 1;
}

.coach::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  background: radial-gradient(ellipse 80% 70% at 100% 0%, rgba(20, 184, 166, 0.1), transparent 65%);
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
}

.coach-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.coach-badge {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(14, 116, 144, 0.22);
  padding: 4px 10px;
  border-radius: 999px;
}

.coach-settings-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.coach-settings-btn:hover {
  color: var(--text);
  border-color: var(--text-soft);
  background: var(--surface-2);
}

.coach-mode-fieldset {
  border: none;
  padding: 0;
  margin: 0 0 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.coach-mode-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.coach-mode-option:has(input:checked) {
  border-color: rgba(14, 116, 144, 0.5);
  background: rgba(14, 116, 144, 0.08);
}
.coach-mode-option input[type="radio"] {
  margin-top: 0.25rem;
  accent-color: var(--accent);
}
.coach-mode-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.coach-mode-body strong {
  font-size: 0.92rem;
  color: var(--text);
}
.coach-mode-body span {
  font-size: 0.82rem;
  color: var(--text-soft);
  line-height: 1.45;
}
.coach-openai-setup {
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}
.coach-openai-hint {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.8rem;
  color: var(--text-soft);
  line-height: 1.5;
}
.coach-openai-hint a {
  color: var(--accent);
  text-decoration: underline;
}
.coach-openai-warn {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  color: var(--negative);
}

.coach-intro {
  font-size: 0.84rem;
  color: var(--text-soft);
  margin: 8px 0 10px;
  line-height: 1.45;
}

.coach-thread {
  min-height: 100px;
  max-height: 240px;
  overflow-y: auto;
  padding: 10px;
  border-radius: 10px;
  background: rgba(8, 12, 20, 0.65);
  border: 1px solid var(--coach-border);
  margin-bottom: 10px;
  font-size: 0.84rem;
}

.coach-msg {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  line-height: 1.45;
}

.coach-msg.user {
  background: var(--coach-accent-soft);
  color: #ccfbf1;
  margin-left: 12px;
}

.coach-msg.bot {
  background: var(--surface-2);
  color: var(--text-soft);
  margin-right: 12px;
  border: 1px solid var(--border);
}

.coach-form textarea {
  width: 100%;
  border: 1px solid var(--coach-border);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  resize: vertical;
  min-height: 64px;
  background: var(--input-bg);
  color: var(--text);
  margin-bottom: 8px;
}

.coach-form textarea:focus {
  outline: 2px solid rgba(13, 148, 136, 0.35);
  outline-offset: 1px;
}

.btn-coach {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
  cursor: pointer;
  background: linear-gradient(165deg, #0e7490 0%, #14b8a6 50%, #2dd4bf 100%);
  color: #f0fdfa;
  box-shadow: 0 8px 28px rgba(13, 148, 136, 0.35);
}

.btn-coach:hover {
  filter: brightness(1.06);
}

.coach-status {
  margin: 6px 0 0;
  font-size: 0.76rem;
  color: var(--text-soft);
}

.coach-clocks {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px 12px;
  border-radius: var(--radius);
  background: linear-gradient(165deg, #1a1c22 0%, #12141a 55%, #0a0b0e 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.neo-clock {
  position: relative;
  width: 108px;
  height: 108px;
  flex: 0 0 auto;
}

.neo-clock-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from 210deg,
    #ef4444 0deg,
    #f97316 36deg,
    #eab308 72deg,
    #a3e635 108deg,
    #22c55e 144deg,
    #14b8a6 180deg,
    #06b6d4 216deg,
    #818cf8 252deg,
    rgba(30, 30, 36, 0.35) 252deg 360deg
  );
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.neo-clock-face {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: radial-gradient(120% 100% at 35% 18%, #2e323c 0%, #101218 52%, #050508 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.45);
}

.neo-clock-city {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(245, 243, 238, 0.55);
  margin-bottom: 2px;
}

.neo-clock-time {
  font-family: "Courier New", Courier, "Liberation Mono", ui-monospace, monospace;
  font-size: 1.42rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #f5f3ee;
  line-height: 1.05;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  font-synthesis: weight;
}

.neo-clock-date {
  margin-top: 4px;
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(232, 228, 220, 0.55);
  letter-spacing: 0.02em;
}

@media (max-width: 320px) {
  .neo-clock {
    width: 96px;
    height: 96px;
  }

  .neo-clock-time {
    font-size: 1.22rem;
  }
}

.grid-inputs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: stretch;
}

@media (min-width: 1180px) {
  .grid-inputs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: none;
    gap: 14px;
  }
}

.inputs-card {
  container-type: inline-size;
  container-name: inputcard;
  display: flex;
  flex-direction: column;
  min-height: 460px;
  max-height: 620px;
  min-width: 0;
}

.inputs-card .list-scroll {
  flex: 1;
  min-height: 260px;
  max-height: 380px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  -webkit-overflow-scrolling: touch;
}

.inputs-card > .sub {
  flex-shrink: 0;
  margin-bottom: 8px;
  line-height: 1.5;
}

.inputs-card .field-tight {
  flex-shrink: 0;
  margin-top: 8px;
  margin-bottom: 0;
}

.inputs-card .field {
  display: block;
  margin-bottom: 10px;
}

.inputs-card .field span {
  display: block;
  font-size: 0.82rem;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.income-list input[type="date"],
.income-list input,
.inputs-card input,
.debt-list input,
.expense-list input,
.debt-list select,
.expense-list select,
.income-list select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font: inherit;
  background: var(--input-bg);
  color: var(--text);
}

.income-list input[type="date"]:focus,
.income-list input:focus,
.inputs-card input:focus,
.debt-list input:focus,
.expense-list input:focus,
.debt-list select:focus,
.expense-list select:focus,
.income-list select:focus {
  outline: 2px solid rgba(13, 148, 136, 0.28);
  outline-offset: 1px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.section-head h2 {
  margin: 0;
}

.btn-ghost {
  border: 1px solid rgba(45, 212, 191, 0.35);
  background: rgba(148, 163, 184, 0.08);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--accent);
}

.btn-ghost:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.income-row {
  display: grid;
  grid-template-columns: 156px minmax(0, 1.25fr) 108px 44px;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.income-row input[type="date"] {
  padding: 8px 6px;
  font-size: 0.78rem;
  min-width: 0;
}

.income-row:last-child,
.expense-row:last-child,
.debt-row:last-child {
  border-bottom: none;
}

.expense-row {
  display: grid;
  grid-template-columns: minmax(104px, 1fr) minmax(0, 1.25fr) 92px 104px 44px;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.debt-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1.25fr) 92px 92px 44px;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

@container inputcard (max-width: 720px) {
  .expense-row {
    grid-template-columns: 1fr 1fr 44px;
    grid-template-rows: auto auto auto;
  }

  .expense-row label:nth-child(1) {
    grid-column: 1 / -1;
  }

  .expense-row label:nth-child(2) {
    grid-column: 1 / -1;
  }

  .expense-row label:nth-child(3) {
    grid-column: 1;
  }

  .expense-row label:nth-child(4) {
    grid-column: 2;
  }

  .expense-row .row-remove {
    grid-row: 1 / span 3;
    grid-column: 3;
    align-self: center;
    justify-self: center;
  }

  .debt-row {
    grid-template-columns: 1fr 1fr 44px;
  }

  .debt-row label:nth-child(1) {
    grid-column: 1 / -1;
  }

  .debt-row label:nth-child(2) {
    grid-column: 1 / -1;
  }

  .debt-row label:nth-child(3) {
    grid-column: 1;
  }

  .debt-row label:nth-child(4) {
    grid-column: 2;
  }

  .debt-row .row-remove {
    grid-row: 1 / span 3;
    grid-column: 3;
    align-self: center;
    justify-self: center;
  }

  .income-row {
    grid-template-columns: 1fr 44px;
    grid-template-rows: auto auto auto;
  }

  .income-row label:nth-child(1) {
    grid-column: 1;
  }

  .income-row label:nth-child(2) {
    grid-column: 1;
  }

  .income-row label:nth-child(3) {
    grid-column: 1;
  }

  .income-row .row-remove {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: start;
    justify-self: center;
  }
}

@media (max-width: 720px) {
  .expense-row {
    grid-template-columns: 1fr 1fr 44px;
    grid-template-rows: auto auto auto;
  }

  .expense-row label:nth-child(1) {
    grid-column: 1 / -1;
  }

  .expense-row label:nth-child(2) {
    grid-column: 1 / -1;
  }

  .expense-row label:nth-child(3) {
    grid-column: 1;
  }

  .expense-row label:nth-child(4) {
    grid-column: 2;
  }

  .expense-row .row-remove {
    grid-row: 1 / span 3;
    grid-column: 3;
    align-self: center;
    justify-self: center;
  }

  .debt-row {
    grid-template-columns: 1fr 1fr 44px;
  }

  .debt-row label:nth-child(1) {
    grid-column: 1 / -1;
  }

  .debt-row label:nth-child(2) {
    grid-column: 1 / -1;
  }

  .debt-row label:nth-child(3) {
    grid-column: 1;
  }

  .debt-row label:nth-child(4) {
    grid-column: 2;
  }

  .debt-row .row-remove {
    grid-row: 1 / span 3;
    grid-column: 3;
    align-self: center;
    justify-self: center;
  }

  .income-row {
    grid-template-columns: 1fr 44px;
    grid-template-rows: auto auto auto;
  }

  .income-row label:nth-child(1) {
    grid-column: 1;
  }

  .income-row label:nth-child(2) {
    grid-column: 1;
  }

  .income-row label:nth-child(3) {
    grid-column: 1;
  }

  .income-row .row-remove {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: start;
    justify-self: center;
  }
}

.expense-row label,
.debt-row label,
.income-row label {
  font-size: 0.74rem;
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.inputs-card .expense-category,
.inputs-card select {
  max-width: 100%;
}

.row-remove {
  border: none;
  background: var(--negative-soft);
  color: var(--negative);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
  align-self: center;
  justify-self: center;
}

.row-remove:hover {
  background: rgba(255, 23, 68, 0.18);
}

/* Native `<dialog>` shell (audit #35) — replaces full-viewport overlay div layout */
dialog.comfort-beta-overlay-shell {
  border: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  background: transparent;
}

dialog.comfort-beta-overlay-shell::backdrop {
  background: rgba(26, 29, 36, 0.55);
  backdrop-filter: blur(6px);
}

dialog.comfort-beta-overlay-shell[open] {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1rem, 4vh, 3rem) 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

dialog.comfort-beta-overlay-shell:not([open]) {
  display: none;
}

:root[data-theme="light"] dialog.comfort-beta-overlay-shell::backdrop {
  background: rgba(15, 23, 42, 0.38);
}

.comfort-beta-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1rem, 4vh, 3rem) 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(26, 29, 36, 0.55);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}
.comfort-beta-overlay--hidden {
  display: none !important;
}
.comfort-beta-card {
  width: min(100%, 400px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.35rem 1.35rem 1.15rem;
  box-shadow: var(--holo-glow-strong);
  margin: auto;
}
.comfort-beta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 1.25rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-soft);
}
.empty-state p {
  margin: 0;
  color: var(--text);
  font-weight: 600;
  font-size: 0.98rem;
}
.empty-state span {
  font-size: 0.88rem;
  line-height: 1.45;
}
.empty-state button {
  margin-top: 0.45rem;
}
.empty-state--ok {
  border-color: rgba(62, 207, 142, 0.32);
  background: rgba(62, 207, 142, 0.06);
}

/* Saved indicator (discreto arriba a la derecha) */
.comfort-saved-indicator {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 99500;
  padding: 6px 10px;
  background: rgba(62, 207, 142, 0.14);
  color: #3ecf8e;
  border: 1px solid rgba(62, 207, 142, 0.35);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.comfort-saved-indicator--visible {
  opacity: 1;
  transform: translateY(0);
}
.comfort-saved-indicator::before {
  content: "✓";
  margin-right: 0.35rem;
}

/* Undo toast */
.comfort-undo-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 99600;
  transform: translate(-50%, 20px);
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.65rem 0.9rem 0.65rem 1rem;
  background: rgba(20, 22, 28, 0.96);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  max-width: calc(100vw - 32px);
}
.comfort-undo-toast--visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.comfort-undo-action {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--accent, #8ab4ff);
  font-weight: 600;
  cursor: pointer;
  font: inherit;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.comfort-undo-action:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* KPI hero (arriba de todo dentro de la app) */
.kpi-hero {
  margin: 0 0 1.25rem;
  padding: 1.25rem 1.4rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
  overflow: hidden;
}
.kpi-hero[data-tone="ok"] {
  background: linear-gradient(135deg, rgba(62, 207, 142, 0.08), rgba(62, 207, 142, 0.02) 70%);
  border-color: rgba(62, 207, 142, 0.3);
}
.kpi-hero[data-tone="tight"] {
  background: linear-gradient(135deg, rgba(247, 201, 72, 0.08), rgba(247, 201, 72, 0.02) 70%);
  border-color: rgba(247, 201, 72, 0.3);
}
.kpi-hero[data-tone="warn"] {
  background: linear-gradient(135deg, rgba(244, 114, 154, 0.08), rgba(244, 114, 154, 0.02) 70%);
  border-color: rgba(244, 114, 154, 0.3);
}
.kpi-hero[data-tone="empty"] {
  background: var(--surface);
  border-style: dashed;
}
.kpi-hero-label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-soft);
}
.kpi-hero-value {
  margin: 0;
  font-family: var(--font-display), system-ui, sans-serif;
  font-size: clamp(1.75rem, 4.5vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--text);
}
.kpi-hero[data-tone="ok"] .kpi-hero-value { color: #3ecf8e; }
.kpi-hero[data-tone="tight"] .kpi-hero-value { color: #f7c948; }
.kpi-hero[data-tone="warn"] .kpi-hero-value { color: #f4729a; }
.kpi-hero-status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-soft);
  line-height: 1.5;
}
.kpi-hero-status strong { color: var(--text); }

/* Mobile polish */
@media (max-width: 720px) {
  .coach-clocks { display: none; }
  .kpi-hero { padding: 1rem 1.05rem; }
  .empty-state { padding: 1rem 0.9rem; }
  .row-remove {
    min-width: 40px;
    min-height: 40px;
  }
  .comfort-undo-toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    transform: translate(0, 20px);
    border-radius: 14px;
    justify-content: space-between;
  }
  .comfort-undo-toast--visible { transform: translate(0, 0); }
  .comfort-saved-indicator { top: 10px; right: 10px; }
}
@media (max-width: 400px) {
  .kpi-hero-value { font-size: 1.6rem; }
}
.comfort-beta-card h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display), system-ui, sans-serif;
  font-size: 1.55rem;
  color: var(--ink-deep);
}
.comfort-beta-card .beta-lede {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text-soft);
  line-height: 1.45;
}
.comfort-beta-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-soft);
}
.comfort-beta-field input,
.comfort-beta-field textarea,
.comfort-beta-field select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font: inherit;
  background: var(--surface-2);
  color: var(--text);
}
.comfort-beta-field textarea {
  min-height: 84px;
  resize: vertical;
}
.comfort-beta-err {
  color: var(--negative);
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}
.comfort-beta-note {
  margin: 0 0 0.8rem;
  font-size: 0.82rem;
  color: var(--text-soft);
}
.comfort-beta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.comfort-beta-actions .btn-coach {
  flex: 1;
  min-width: 120px;
}
.comfort-beta-demo {
  position: fixed;
  z-index: 99990;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.35rem 0.75rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #ecfeff;
  background: linear-gradient(90deg, #0f172a, #134e4a, #0f172a);
  border-bottom: 1px solid rgba(45, 212, 191, 0.25);
}
.comfort-beta-demo--hidden {
  display: none !important;
}
body.comfort--hosted .app {
  padding-top: 1.65rem;
}

/*
 * Same-document View Transitions (audit #33): gated modals / dismissible overlays use
 * document.startViewTransition in JS — smooth root cross-fade where supported (Chromium, Safari 18+).
 */
@supports (view-transition-name: none) {
  @media (prefers-reduced-motion: no-preference) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
      animation-duration: 0.2s;
      animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    }
  }
  @media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
      animation-duration: 1ms;
    }
  }
}

