/* ==========================================================================
   Saldo Libre PRO — estilos principales
   Identidad: índigo profundo + menta (progreso), superficies limpias,
   números grandes con cifras tabulares, sombras suaves.
   ========================================================================== */

/* ---------- Tokens de diseño ---------- */
:root {
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;

  --bg: #f1f6f3;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(34, 176, 116, 0.1), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f6faf8;
  --surface-3: #ebf3ef;
  --border: #dce8e2;
  --border-strong: #c4d7ce;
  --text: #0d2621;
  --text-2: #2c4841;
  --muted: #5c736b;
  --primary: #087a55;
  --primary-2: #1fae78;
  --primary-ink: #ffffff;
  --primary-soft: #e0f3ea;
  --success: #15803d;
  --success-2: #4cc97a;
  --success-soft: #e5f6ea;
  --warning: #c98100;
  --warning-soft: #fff4dc;
  --orange: #e8672a;
  --danger: #d9364c;
  --danger-soft: #fdebee;
  --info-soft: #e8f1fe;
  --mint: #5fdc8f;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(13, 38, 33, 0.05);
  --shadow: 0 1px 2px rgba(13, 38, 33, 0.04), 0 6px 20px -8px rgba(13, 38, 33, 0.13);
  --shadow-lg: 0 24px 60px -20px rgba(13, 38, 33, 0.35);
  --focus: 0 0 0 3px rgba(8, 122, 85, 0.35);

  --sidebar-w: 256px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #07110e;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(60, 207, 142, 0.12), transparent 60%);
  --surface: #0f1c18;
  --surface-2: #13231e;
  --surface-3: #1a2d27;
  --border: #213830;
  --border-strong: #2f4b41;
  --text: #eaf5f0;
  --text-2: #c3d8cf;
  --muted: #8ea79e;
  --primary: #3ccf8e;
  --primary-2: #74e3ad;
  --primary-ink: #06120e;
  --primary-soft: #0f3326;
  --success: #4ade80;
  --success-2: #86efac;
  --success-soft: #0f2e1b;
  --warning: #fbbf24;
  --warning-soft: #33280b;
  --orange: #fb8a4f;
  --danger: #ff6b7f;
  --danger-soft: #3a1520;
  --info-soft: #152441;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -10px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, 0.8);
  --focus: 0 0 0 3px rgba(60, 207, 142, 0.45);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s, color 0.3s;
}
body.has-modal { overflow: hidden; }

h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); letter-spacing: -0.01em; line-height: 1.2; }
p { margin: 0 0 0.6em; }
a { color: var(--primary); }
small { font-size: 0.82em; }
b, strong { font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
.tabular, .num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.center { text-align: center; }
.text-warn { color: var(--warning); font-weight: 600; }
.text-danger { color: var(--danger); }
.icon { flex: none; vertical-align: middle; }
.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; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 1000; background: var(--primary); color: var(--primary-ink); padding: 8px 14px; border-radius: 10px; }
.skip-link:focus { left: 8px; }
.noscript { padding: 24px; text-align: center; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; flex: none; }

/* ---------- Estructura ---------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; gap: 18px;
  padding: 22px 16px 18px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); padding: 4px 8px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text b { font-family: var(--font-display); font-size: 19px; letter-spacing: -0.01em; font-weight: 850; }
.brand-text b + b { color: var(--primary); font-size: 10.5px; letter-spacing: 0.45em; margin-top: 3px; }
.logo-mark { display: block; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(8, 122, 85, 0.22)); }
[data-theme="dark"] .logo-mark { filter: drop-shadow(0 2px 10px rgba(60, 207, 142, 0.25)); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--text-2); text-decoration: none; font-weight: 550;
  transition: background 0.18s, color 0.18s, transform 0.18s var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active { background: var(--primary-soft); color: var(--primary); }
.nav-link.is-active .icon { stroke-width: 2.2; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.privacy-badge {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--success-soft); color: var(--success); font-weight: 600; font-size: 13px; text-align: left;
}
.storage-status { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--muted); padding: 0 6px; }
.storage-status span { overflow-wrap: anywhere; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 32px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
}
.topbar-title h1 { font-size: 24px; font-weight: 750; }
.topbar-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar .menu-toggle { display: none; }

.save-status { font-size: 12.5px; color: var(--muted); white-space: nowrap; min-width: 84px; text-align: right; transition: color 0.2s; }
.save-status[data-status="saved"] { color: var(--success); }
.save-status[data-status="saving"] { color: var(--muted); }
.save-status[data-status="error"] { color: var(--danger); }

.theme-toggle { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); }
.theme-toggle button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--muted); transition: background 0.2s, color 0.2s;
}
.theme-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.folder-banner {
  margin: 0 32px 8px; padding: 10px 14px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--warning-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
}
.folder-banner span { display: flex; align-items: center; gap: 8px; }

.view { flex: 1; padding: 8px 32px 32px; width: 100%; max-width: 1480px; outline: none; }
.view > * + * { margin-top: 20px; }
.view.view-enter > * { animation: rise 0.45s var(--ease) both; }
.view.view-enter > *:nth-child(2) { animation-delay: 0.04s; }
.view.view-enter > *:nth-child(3) { animation-delay: 0.08s; }
.view.view-enter > *:nth-child(4) { animation-delay: 0.12s; }
.view.view-enter > *:nth-child(n + 5) { animation-delay: 0.16s; }

.app-footer { padding: 16px 32px 28px; color: var(--muted); font-size: 12px; max-width: 1480px; }
.app-footer p { margin: 0; max-width: 880px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Tarjetas y rejillas ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  min-width: 0;
}
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-wide-left { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.grid-wide-right { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }

.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head h2 { font-size: 17px; font-weight: 700; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.view > .section-head h2 { font-size: 22px; }
.section-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.sub-title { font-size: 14px; margin: 18px 0 10px; color: var(--text-2); }

/* ---------- Marca ---------- */
.wordmark { display: inline-flex; flex-direction: column; line-height: 0.95; font-family: var(--font-display); font-weight: 850; letter-spacing: -0.01em; color: var(--text); }
.wordmark span:last-child { color: var(--primary); font-size: 0.46em; letter-spacing: 0.45em; margin-top: 0.3em; }
.wordmark em, .brand-text em { font-style: normal; background: linear-gradient(135deg, #22b573, #087a55); -webkit-background-clip: text; background-clip: text; color: transparent; }
[data-theme="dark"] .wordmark em, [data-theme="dark"] .brand-text em { background-image: linear-gradient(135deg, #8ff0bd, #3ccf8e); }
.wordmark-lg { font-size: clamp(28px, 4vw, 44px); }
.dash-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dash-hero p { margin: 0; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 620; font-size: 14px; line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: transform 0.15s var(--ease), box-shadow 0.2s, background 0.2s, border-color 0.2s, color 0.2s;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn-primary { background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; box-shadow: 0 8px 18px -8px rgba(8, 122, 85, 0.7); }
[data-theme="dark"] .btn-primary { color: #fff; background: linear-gradient(135deg, #1fae78, #0a7d57); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 24px -8px rgba(8, 122, 85, 0.8); transform: translateY(-1px); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.05); box-shadow: 0 8px 20px -8px var(--danger); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 13px 22px; font-size: 15px; border-radius: 14px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-2);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); font-weight: 600; font-size: 13.5px; color: var(--text-2);
  transition: all 0.18s var(--ease);
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.is-active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); box-shadow: 0 6px 14px -6px rgba(8, 122, 85, 0.7); }
.chip-input { padding: 4px 6px 4px 14px; }
.chip-input input { width: 110px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 5px 10px; }

/* ---------- Badges y estados ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: var(--surface-3); color: var(--muted); margin: 4px 4px 0 0; }
.badge-warn { background: var(--warning-soft); color: var(--warning); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-upcoming { background: var(--info-soft); color: var(--primary); }
.status-paid { background: var(--success-soft); color: var(--success); }
.status-overdue { background: var(--danger-soft); color: var(--danger); }
.priority-pill { display: inline-block; min-width: 34px; padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12.5px; text-align: center; }

.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 14px; margin: 12px 0 0; }
.notice .icon { margin-top: 2px; }
.notice-warn { background: var(--warning-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); }
.notice-warn .icon { color: var(--warning); }
.notice-info { background: var(--info-soft); color: var(--text); }
.notice-info .icon { color: var(--primary); }
.notice-good { background: var(--success-soft); color: var(--text); }
.notice-good .icon { color: var(--success); }
.view > .notice { margin-top: 20px; }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { position: relative; overflow: hidden; transition: transform 0.2s var(--ease), box-shadow 0.2s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 12px 30px -16px rgba(8, 122, 85, 0.35); }
.kpi-head { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); }
.kpi-primary .kpi-icon { background: var(--primary-soft); color: var(--primary); }
.kpi-warn .kpi-icon { background: var(--warning-soft); color: var(--warning); }
.kpi-success .kpi-icon { background: var(--success-soft); color: var(--success); }
.kpi-value { margin-top: 14px; font-family: var(--font-display); font-size: clamp(22px, 2.3vw, 31px); font-weight: 780; letter-spacing: -0.02em; line-height: 1.1; overflow-wrap: anywhere; }
.kpi-value small { font-size: 0.5em; font-weight: 600; color: var(--muted); margin-left: 4px; }
.kpi-sub { margin-top: 6px; font-size: 13px; color: var(--muted); }
.kpi-primary::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%;
  background: radial-gradient(circle, rgba(60, 207, 142, 0.2), transparent 70%);
}

.flow-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.flow-card { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; text-decoration: none; color: var(--text); transition: border-color 0.2s, transform 0.2s var(--ease); }
.flow-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.flow-card span { color: var(--muted); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.flow-card b { font-size: 21px; font-weight: 750; }
.flow-card.is-negative b { color: var(--danger); }
.flow-card.is-accent { background: linear-gradient(135deg, var(--primary-soft), var(--surface)); }

/* ---------- Progreso ---------- */
.progress-card { background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 9%, var(--surface)), var(--surface) 55%); }
.progress-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.progress-text { margin: 6px 0 0; color: var(--text-2); }
.progress-pct { font-family: var(--font-display); font-size: clamp(34px, 5vw, 52px); font-weight: 820; letter-spacing: -0.03em; line-height: 1; color: var(--primary); }
.progress-bar { height: 12px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-bar.big { height: 18px; }
.progress-fill {
  height: 100%; width: var(--w); border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--mint));
  animation: grow 1.1s var(--ease) both; transform-origin: left;
}
@keyframes grow { from { width: 0; } }
.mini-progress { height: 4px; width: 90px; margin: 6px 0 0 auto; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.mini-progress span { display: block; height: 100%; width: var(--w); border-radius: inherit; }

/* ---------- Salud de deuda ---------- */
.health-body { display: flex; flex-direction: column; align-items: center; text-align: center; }
.gauge-wrap { width: 100%; max-width: 280px; }
.gauge { width: 100%; height: auto; display: block; }
.gauge-needle { transform-origin: 100px 100px; transform: rotate(var(--angle)); animation: needle 1.2s var(--ease) both; }
.gauge-needle line { stroke: var(--text); stroke-width: 3.5; stroke-linecap: round; }
.gauge-needle circle { fill: var(--text); }
@keyframes needle { from { transform: rotate(-90deg); } }
.health-level { font-family: var(--font-display); font-size: 26px; font-weight: 800; color: var(--c); margin-top: 4px; }
.health-msg { color: var(--text-2); margin: 6px 0 10px; }
.health-details { width: 100%; text-align: left; font-size: 13.5px; color: var(--text-2); border-top: 1px solid var(--border); padding-top: 10px; }
.health-details summary { cursor: pointer; font-weight: 650; color: var(--primary); }
.level-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; }
.level-list li { display: flex; align-items: center; gap: 4px; }
.level-list span:last-child { margin-left: auto; color: var(--muted); }

/* ---------- Gráficas ---------- */
.chart-box { position: relative; width: 100%; min-height: 200px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid line { stroke: var(--border); stroke-dasharray: 3 4; }
.chart-axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart-area { opacity: 0.08; }
.chart-line.is-animated:not(.is-dashed) { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.4s var(--ease) forwards; }
.chart-line.is-animated.is-dashed { animation: fade 0.8s ease both; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart-end { stroke: var(--surface); stroke-width: 2; }
.chart-guide { stroke: var(--border-strong); stroke-width: 1; }
.chart-tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 10px 12px; font-size: 12.5px;
}
.tt-title { font-weight: 700; margin-bottom: 6px; }
.tt-row { display: flex; align-items: center; gap: 4px; padding: 2px 0; color: var(--text-2); }
.tt-row b { margin-left: auto; padding-left: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-empty { display: grid; place-items: center; min-height: 160px; color: var(--muted); font-size: 14px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: -4px 0 10px; font-size: 13px; color: var(--text-2); }
.legend-chip { display: inline-flex; align-items: center; gap: 7px; }
.legend-chip .dot { width: 10px; height: 10px; margin: 0; background: var(--c); }
.legend-chip .dash { width: 18px; height: 0; border-top: 2.5px dashed var(--c); }

.donut { display: flex; align-items: center; gap: 24px; }
.donut-figure { position: relative; width: 190px; flex: none; }
.donut-figure svg { width: 100%; display: block; }
.donut-track { stroke: var(--surface-3); }
.donut-seg { transition: stroke-width 0.2s, opacity 0.2s; animation: fade 0.8s ease both; }
.donut-seg.is-hover { stroke-width: 20; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center span { font-size: 12px; color: var(--muted); }
.donut-center strong { font-size: 20px; font-weight: 800; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; flex: 1; min-width: 0; }
.donut-legend li { display: flex; align-items: center; gap: 4px; font-size: 14px; padding: 6px 10px; border-radius: 10px; transition: background 0.15s; }
.donut-legend li:hover { background: var(--surface-2); }
.lg-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-value { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

.hbars { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.hbar-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.hbar-label { display: flex; align-items: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-head b { font-variant-numeric: tabular-nums; }
.hbar-track { height: 10px; border-radius: 99px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.hbar-fill { height: 100%; width: var(--w); border-radius: inherit; animation: grow 1s var(--ease) both; }
.hbars small { color: var(--muted); }

/* ---------- Recomendaciones e hitos ---------- */
.insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.insight { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; }
.insight-icon { font-size: 18px; line-height: 1.3; }
.insight-warn { background: var(--warning-soft); border-color: transparent; }
.insight-good { background: var(--success-soft); border-color: transparent; }
.insight-tip { background: var(--primary-soft); border-color: transparent; }

.milestones { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.milestone { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--border-strong); color: var(--muted); }
.milestone .ms-icon { font-size: 22px; filter: grayscale(1); opacity: 0.5; }
.milestone small { margin-left: auto; white-space: nowrap; }
.milestone.is-hit { border-style: solid; border-color: transparent; background: var(--success-soft); color: var(--text); }
.milestone.is-hit .ms-icon { filter: none; opacity: 1; }
.milestones-lg .milestone { padding: 16px; }

/* ---------- Cálculo en curso ---------- */
.loading-card { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 160px; color: var(--muted); font-weight: 600; }
.loading-card.is-error { color: var(--danger); text-align: center; padding: 24px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Bienvenida / vacío ---------- */
.hero { padding: clamp(24px, 5vw, 48px); text-align: left; }
.hero-welcome { background: radial-gradient(700px 300px at 90% 0%, color-mix(in srgb, var(--primary) 16%, transparent), transparent), var(--surface); }
.hero-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.hero-brand .wordmark { font-size: 26px; }
.hero-brand p { margin: 4px 0 0; color: var(--muted); }
.hero h2 { font-size: clamp(24px, 3vw, 34px); }
.hero-text { max-width: 640px; color: var(--text-2); font-size: 16px; margin: 10px 0 24px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-privacy { display: flex; align-items: center; gap: 8px; color: var(--success); font-size: 13.5px; margin: 22px 0 0; }

.empty-state { text-align: center; padding: 28px 16px; }
.empty-icon { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); margin-bottom: 14px; }
.empty-state h3 { font-size: 18px; margin-bottom: 6px; }
.empty-state p { color: var(--muted); max-width: 460px; margin: 0 auto; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.fieldset { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px 16px; margin: 0; min-width: 0; }
.fieldset legend { padding: 0 6px; font-weight: 700; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { display: flex; align-items: center; gap: 6px; }
.field label, .inline-field { font-size: 13px; font-weight: 620; color: var(--text-2); }
.req { color: var(--danger); }
.input-wrap { position: relative; display: flex; align-items: center; }
.field input, .field select, .field textarea, .inline-field select, .search input {
  width: 100%; min-width: 0; padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .inline-field select:focus, .search input:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--focus);
}
.field input[readonly] { background: var(--surface-2); color: var(--muted); }
.input-wrap.has-prefix input { padding-left: 34px; }
.input-wrap.has-suffix input { padding-right: 58px; }
.affix { position: absolute; color: var(--muted); font-size: 13.5px; pointer-events: none; }
.affix.prefix { left: 12px; }
.affix.suffix { right: 12px; }
.field-hint, .field-note { color: var(--muted); font-size: 12.5px; }
.field-note { margin: 10px 0 0; }
.field-error { color: var(--danger); font-size: 12.5px; min-height: 0; }
.field-error:empty { display: none; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.field.has-warning input { border-color: var(--warning); }
.field.has-warning .field-error { color: var(--warning); }
.field-action { justify-content: flex-end; }
.form-helper { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); background: var(--surface-2); padding: 10px 12px; border-radius: 12px; margin: 12px 0 0; }
.form-helper:empty { display: none; }
.form-warning { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--warning-soft); font-size: 13.5px; font-weight: 600; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="color"] { width: 44px; height: 40px; padding: 3px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); flex: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); padding: 0; transition: transform 0.15s; }
.swatch:hover { transform: scale(1.15); }

.tip {
  display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--muted);
  font-size: 11px; font-weight: 800; line-height: 1; flex: none;
}
.tip:hover, .tip:focus-visible { color: var(--primary); border-color: var(--primary); }
.tooltip-bubble {
  position: fixed; z-index: 2000; max-width: 280px; padding: 8px 12px; border-radius: 10px;
  background: #151936; color: #f2f3fb; font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow-lg);
  pointer-events: none; animation: fade 0.15s ease;
}
[data-theme="dark"] .tooltip-bubble { background: #f2f3fb; color: #151936; }

.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; color: var(--text-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { position: relative; width: 38px; height: 22px; border-radius: 99px; background: var(--border-strong); transition: background 0.2s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.2s var(--ease); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }
.auto-split { align-self: end; padding-bottom: 10px; }

/* ---------- Toolbar y tablas ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; }
.inline-field select { width: auto; padding: 8px 10px; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 240px; max-width: 360px; color: var(--muted); }
.search .icon { position: absolute; left: 12px; }
.search input { padding-left: 36px; }

.table-card { padding: 18px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; }
.table-scroll.tall { max-height: 560px; overflow-y: auto; border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.data-table th, .data-table td { padding: 11px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.data-table tfoot th, .data-table tfoot td { border-bottom: 0; background: var(--surface-2); font-weight: 600; }
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .num { text-align: right; white-space: nowrap; }
.data-table td small { display: block; color: var(--muted); }
.data-table td.num small { display: inline; margin-left: 2px; }
.th-sort { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; }
.th-sort.is-active { color: var(--primary); }
.sort-ind { font-size: 10px; opacity: 0.7; }
tr.is-archived { opacity: 0.6; }
tr.is-paid td:first-child b { text-decoration: line-through; text-decoration-color: var(--success); }
.debt-cell { display: flex; align-items: center; gap: 12px; min-width: 180px; }
.debt-color { width: 12px; height: 38px; border-radius: 6px; flex: none; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.actions-cell { width: 1%; white-space: nowrap; }
.comment-cell { max-width: 220px; color: var(--text-2); }
.amort-table td:first-child { white-space: nowrap; }
.expand-btn { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: var(--surface-3); margin-right: 8px; color: var(--text-2); }
.amort-row.is-open { background: var(--primary-soft); }
.amort-sub td { background: var(--surface-2); font-size: 13px; color: var(--text-2); padding-top: 8px; padding-bottom: 8px; }

/* ---------- Estrategias ---------- */
.strategy-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.strategy-card { position: relative; display: flex; flex-direction: column; gap: 14px; border-top: 4px solid var(--accent); transition: transform 0.2s var(--ease), box-shadow 0.2s; }
.strategy-card:hover { transform: translateY(-3px); box-shadow: var(--shadow), 0 16px 34px -18px var(--accent); }
.strategy-card.is-selected { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.strategy-card header { display: flex; align-items: flex-start; gap: 12px; }
.strategy-card header .badge { margin-left: auto; }
.strategy-card h3 { font-size: 18px; }
.strategy-card header p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.strategy-emoji { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 16%, transparent); font-size: 20px; flex: none; }
.strategy-stats { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.strategy-stats dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.strategy-stats dd { margin: 2px 0 0; font-weight: 750; font-size: 16px; }
.strategy-desc { color: var(--text-2); font-size: 13.5px; margin: 0; }
.strategy-card footer { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.diff-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.diff-list li { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border-left: 4px solid var(--accent); font-size: 14px; }
.diff-title { font-weight: 700; font-size: 13px; color: var(--muted); }

.dnd-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dnd-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: grab; transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s; }
.dnd-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.dnd-item.is-dragging { opacity: 0.5; cursor: grabbing; }
.dnd-item.is-over { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); transform: translateY(2px); }
.dnd-grip { color: var(--muted); }
.dnd-pos { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: 13px; }
.dnd-item .debt-color { height: 26px; width: 8px; }
.dnd-name { display: flex; flex-direction: column; min-width: 0; }
.dnd-name small { color: var(--muted); }
.dnd-btns { margin-left: auto; display: flex; }
.custom-result { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 14px; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.steps li { display: flex; align-items: center; gap: 14px; padding: 10px 4px; border-bottom: 1px dashed var(--border); }
.steps li:last-child { border-bottom: 0; }
.steps li div { display: flex; flex-direction: column; min-width: 0; }
.steps li small { color: var(--muted); }
.steps li > span:last-child { margin-left: auto; text-align: right; font-weight: 650; white-space: nowrap; }
.steps li > span:last-child small { display: block; font-weight: 500; }
.step-num { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--c); color: #fff; font-weight: 800; flex: none; }

/* ---------- Simulador ---------- */
.sim-hero { background: radial-gradient(900px 400px at 0% 0%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 70%), var(--surface); }
.sim-hero-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.sim-hero-head h2 { font-size: clamp(22px, 3vw, 30px); margin: 4px 0; }
.sim-amount { display: flex; flex-direction: column; align-items: flex-end; }
.sim-amount span { font-size: 13px; color: var(--muted); font-weight: 600; }
.sim-amount output { font-family: var(--font-display); font-size: clamp(32px, 4.5vw, 46px); font-weight: 820; color: var(--primary); letter-spacing: -0.02em; line-height: 1.05; }
.sim-amount small { color: var(--muted); }
.slider-wrap { margin: 22px 0 16px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--mint)); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 4px solid var(--primary); box-shadow: 0 4px 14px rgba(8, 122, 85, 0.45); cursor: grab; transition: transform 0.15s; }
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.12); cursor: grabbing; }
input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 4px solid var(--primary); box-shadow: 0 4px 14px rgba(8, 122, 85, 0.45); cursor: grab; }
input[type="range"]:focus-visible { box-shadow: var(--focus); }
.slider-scale { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 12px; }
.compare-grid { display: grid; grid-template-columns: 1fr auto 1fr 1fr 1fr; gap: 12px; align-items: stretch; margin-top: 18px; }
.compare-cell { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.compare-cell span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.compare-cell b { font-size: 19px; font-weight: 780; overflow-wrap: anywhere; }
.compare-cell small { color: var(--muted); }
.compare-cell.is-after { border-color: var(--primary); background: var(--primary-soft); }
.compare-cell.is-highlight b { color: var(--success); }
.compare-arrow { display: grid; place-items: center; color: var(--muted); }
.sim-chart-row { margin-top: 18px; align-items: center; }
.sim-apply { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.sim-apply p { font-size: 15px; color: var(--text-2); margin: 0; }
.wi-actions { margin-top: 14px; }
#wi-form { margin-top: 16px; }
.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.saved-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.saved-list li div:first-child { display: flex; flex-direction: column; min-width: 0; }
.saved-list small { color: var(--muted); }
.refi-prefill { max-width: 360px; margin-bottom: 14px; }
.refi-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.refi-results { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.refi-result { padding: 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.refi-result + .refi-result { border-color: var(--primary); }
.refi-result h4 { font-size: 14px; margin-bottom: 10px; }
.refi-result dl { margin: 0; display: grid; gap: 8px; }
.refi-result dl div { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.refi-result dt { color: var(--muted); }
.refi-result dd { margin: 0; font-weight: 700; text-align: right; }

/* ---------- Pagos y calendario ---------- */
.due-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.due-item { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px 14px; padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.due-item .btn { grid-column: 2 / -1; justify-self: end; }
.due-item.is-overdue { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-soft); }
.due-item.is-paid { opacity: 0.75; }
.due-date { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 54px; height: 54px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); line-height: 1; }
.due-date b { font-size: 20px; font-weight: 800; }
.due-date span { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; margin-top: 3px; }
.due-info { display: flex; flex-direction: column; min-width: 0; }
.due-info small { color: var(--muted); }
.due-amount { font-weight: 750; }
.cal-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-head h3 { font-size: 18px; min-width: 150px; text-align: center; }
.cal-total { margin-left: auto; font-size: 13.5px; color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow { font-size: 11.5px; font-weight: 700; color: var(--muted); text-align: center; text-transform: uppercase; padding: 4px 0; }
.cal-cell { min-height: 82px; padding: 6px; border-radius: 10px; background: var(--surface-2); border: 1px solid transparent; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-cell.is-empty { background: transparent; }
.cal-cell.is-today { border-color: var(--primary); background: var(--primary-soft); }
.cal-day { font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-cell.is-today .cal-day { color: var(--primary); }
.cal-pill { display: block; width: 100%; padding: 2px 6px; border-radius: 6px; border: 0; border-left: 3px solid var(--c); background: var(--surface); font-size: 11px; font-weight: 650; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.cal-pill.is-paid { background: var(--success-soft); text-decoration: line-through; opacity: 1; }
.cal-pill.is-overdue { background: var(--danger-soft); color: var(--danger); }
.cal-pill:disabled { cursor: default; }
.cal-legend { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- Metas / flujo ---------- */
.flow-cols { display: grid; grid-template-columns: 1fr 1.6fr; gap: 16px; margin-bottom: 16px; }
.flow-cols .fieldset:first-child .form-grid { grid-template-columns: 1fr; }
.formula { display: flex; align-items: stretch; flex-wrap: wrap; gap: 10px; margin-top: 18px; padding: 16px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); }
.formula.compact { margin: 12px 0; }
.formula-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; min-width: 120px; flex: 1; }
.formula-item span { font-size: 12px; color: var(--muted); font-weight: 650; }
.formula-item b { font-size: 20px; font-weight: 780; }
.formula-item.is-result { background: var(--success-soft); border-radius: 12px; }
.formula-item.is-result b { color: var(--success); }
.formula-item.is-negative { background: var(--danger-soft); }
.formula-item.is-negative b { color: var(--danger); }
.formula-op { display: grid; place-items: center; font-size: 22px; font-weight: 700; color: var(--muted); }
.goal-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.goal-form .field { flex: 1 1 200px; }
.goal-result p { margin: 0 0 6px; }
.goal-amount { font-family: var(--font-display); font-size: clamp(30px, 4vw, 42px); font-weight: 820; color: var(--primary); letter-spacing: -0.02em; margin: 4px 0; }
.goal-amount small { font-size: 0.4em; color: var(--muted); margin-left: 6px; }
.goal-result .btn { margin-top: 12px; }

/* ---------- Configuración ---------- */
.storage-state { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.storage-state div { display: flex; flex-direction: column; min-width: 0; }
.storage-state small { color: var(--muted); overflow-wrap: anywhere; }
.storage-state.is-ok { background: var(--success-soft); border-color: transparent; }
.storage-state.is-ok .icon { color: var(--success); }
.storage-state.is-warn { background: var(--warning-soft); border-color: transparent; }
.details-box { margin-top: 14px; font-size: 13.5px; }
.details-box summary { cursor: pointer; color: var(--primary); font-weight: 650; }
.code-block { margin: 10px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-3); font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; overflow-x: auto; white-space: pre; }
.action-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.action-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); text-align: left; transition: border-color 0.2s, transform 0.2s var(--ease), box-shadow 0.2s; }
.action-tile:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.action-tile .icon { color: var(--primary); margin-bottom: 4px; }
.action-tile small { color: var(--muted); overflow-wrap: anywhere; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plain-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; flex-wrap: wrap; }
.plain-list li small { color: var(--muted); }
.check-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.check-list li::before { content: "✓"; color: var(--success); font-weight: 800; margin-right: 8px; }
.privacy-card { background: linear-gradient(135deg, var(--success-soft), var(--surface) 70%); }
.danger-card { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.about-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.about-brand .wordmark { font-size: 20px; }
.about-brand p { margin: 6px 0 0; }
.about-list { margin: 0; display: grid; gap: 6px; }
.about-list div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.about-list dt { color: var(--muted); }
.about-list dd { margin: 0; font-weight: 650; }

/* ---------- Modales ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(10, 12, 28, 0.5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; transition: opacity 0.2s ease;
}
.modal-backdrop.is-open { opacity: 1; }
.modal-backdrop.is-leaving { opacity: 0; }
.modal {
  width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(0.98); transition: transform 0.25s var(--ease);
}
.modal-backdrop.is-open .modal { transform: none; }
.modal-sm { max-width: 460px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 860px; }
.modal-xl { max-width: 980px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.confirm-msg { color: var(--text-2); }
.modal-body .field + .field { margin-top: 0; }
.modal-body > .field { margin-top: 12px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 550;
  animation: toast-in 0.35s var(--ease) both;
}
.toast.is-leaving { animation: toast-out 0.25s ease both; }
.toast-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-weight: 800; font-size: 13px; flex: none; }
.toast-success .toast-icon { background: var(--success-soft); color: var(--success); }
.toast-error .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast-warning .toast-icon { background: var(--warning-soft); color: var(--warning); }
.toast-info .toast-icon { background: var(--info-soft); color: var(--primary); }
.toast-msg { flex: 1; }
.toast-close { border: 0; background: none; color: var(--muted); padding: 4px; border-radius: 8px; display: grid; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ---------- Asistente ---------- */
.wizard-modal .modal-body { padding: 26px; }
.wizard-welcome { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 10px 0; }
.wizard-welcome .lead { font-size: 17px; color: var(--muted); margin: 0; }
.wizard-welcome > p { max-width: 560px; color: var(--text-2); }
.wizard-choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 10px; }
.wizard-folder { margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--border); width: 100%; max-width: 560px; display: flex; flex-direction: column; align-items: center; }
.wizard-steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 24px; }
.wizard-steps li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; color: var(--muted); font-size: 12px; font-weight: 650; }
.wizard-steps li::before { content: ""; position: absolute; top: 15px; left: calc(-50% + 18px); right: calc(50% + 18px); height: 2px; background: var(--border); }
.wizard-steps li:first-child::before { display: none; }
.wizard-steps li.is-done::before, .wizard-steps li.is-current::before { background: var(--primary); }
.wizard-steps span { position: relative; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--muted); font-weight: 800; transition: all 0.2s; }
.wizard-steps li.is-current span { background: var(--primary); color: var(--primary-ink); box-shadow: 0 0 0 5px var(--primary-soft); }
.wizard-steps li.is-done span { background: var(--success); color: #fff; }
.wizard-steps li.is-current small { color: var(--text); }
.wizard-body { min-height: 260px; animation: rise 0.35s var(--ease) both; }
.wizard-body h3 { font-size: 22px; margin-bottom: 6px; }
.wizard-body > .muted { margin-bottom: 18px; }
.wizard-nav { display: flex; justify-content: space-between; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.wizard-debts { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.wizard-debts li { display: grid; grid-template-columns: auto 1fr auto auto auto; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.wizard-debts .debt-color { height: 22px; width: 8px; }
.wizard-mini { padding: 16px; border: 1px dashed var(--border-strong); border-radius: 14px; }
.wizard-mini-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mini-strategies { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mini-strategy { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 14px; border: 1px solid var(--border); border-top: 4px solid var(--accent); background: var(--surface-2); }
.mini-strategy span { font-weight: 700; font-size: 13.5px; }
.mini-strategy b { font-size: 20px; }
.mini-strategy small { color: var(--muted); }

/* ---------- Momento "wow" ---------- */
.wow-modal .modal { background: radial-gradient(800px 400px at 50% 0%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 70%), var(--surface); }
.wow { position: relative; display: grid; grid-template-columns: 1fr 170px; grid-template-areas: "counter marks" "chart marks" "final final"; gap: 16px; }
.wow-counter { grid-area: counter; display: flex; flex-direction: column; }
.wow-label { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.wow-amount { font-family: var(--font-display); font-size: clamp(36px, 6vw, 60px); font-weight: 850; letter-spacing: -0.03em; line-height: 1.05; }
.wow-month { color: var(--muted); font-weight: 600; }
.wow-chart { grid-area: chart; height: 240px; }
.wow-chart svg { width: 100%; height: 100%; display: block; }
.wow-grid { stroke: var(--border); stroke-dasharray: 3 5; }
.wow-dot { filter: drop-shadow(0 0 10px var(--primary)); }
.wow-marks { grid-area: marks; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.wow-marks li { padding: 6px 12px; border-radius: 10px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); background: var(--surface-2); transition: all 0.35s var(--ease); text-align: right; }
.wow-marks li.is-done { color: var(--success); background: var(--success-soft); text-decoration: line-through; text-decoration-thickness: 2px; }
.wow-final { grid-area: final; text-align: center; padding: 18px; border-radius: 16px; background: linear-gradient(135deg, var(--success-soft), var(--primary-soft)); animation: rise 0.6s var(--ease) both; }
.wow-final-title { font-family: var(--font-display); font-size: clamp(24px, 4vw, 36px); font-weight: 850; letter-spacing: 0.04em; }
.wow-final-date { font-size: 17px; margin-top: 4px; }
.wow-final-sub { color: var(--muted); margin-top: 4px; font-size: 14px; }
.wow.is-finished .wow-amount { color: var(--success); }

/* ---------- Reporte (vista en pantalla) ---------- */
.report { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(20px, 4vw, 40px); }
.rp-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; padding-bottom: 20px; border-bottom: 2px solid var(--text); }
.rp-brand { display: flex; align-items: center; gap: 12px; }
.rp-brand .wordmark { font-size: 18px; }
.rp-brand small { color: var(--muted); }
.rp-title { text-align: right; }
.rp-title h2 { font-size: clamp(18px, 2.4vw, 24px); letter-spacing: 0.04em; }
.rp-title p { margin: 4px 0 0; color: var(--muted); }
.rp-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
.rp-summary div { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.rp-summary dt { font-size: 12px; color: var(--muted); font-weight: 650; }
.rp-summary dd { margin: 4px 0 0; font-weight: 750; font-size: 16px; }
.rp-section { margin-top: 24px; break-inside: avoid; }
.rp-section h3 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 12px; color: var(--primary); }
.rp-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.rp-steps li { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; border: 1px solid var(--border); }
.rp-step { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); font-weight: 800; flex: none; }
.rp-table tr.is-selected td { background: var(--primary-soft); font-weight: 650; }
.rp-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.toolbar-wrap { margin: 0; }

/* ---------- Accesibilidad: movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0s !important; transition-duration: 0.001ms !important; }
  .chart-line.is-animated:not(.is-dashed) { stroke-dashoffset: 0; }
}

/* Resultados comparativos dentro de tarjetas de media columna: 2 × 2 */
.grid-2 .compare-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2 .compare-arrow { display: none; }

/* ---------- Asistente de tasa ---------- */
.link-btn { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: var(--primary); font-size: 12.5px; font-weight: 650; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--primary-2); }
.rate-source-note { color: var(--muted); font-size: 12px; }
.rate-source-note:empty { display: none; }
.field-hint:has(.rate-source-note:empty) { display: none; }
.rate-help-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--primary) 40%, transparent);
  background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 700; white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.rate-help-btn:hover { background: var(--primary); color: var(--primary-ink); }
.rate-modes { margin: 14px 0 18px; }
.rate-submodes { margin-bottom: 14px; }
.rate-panel .field-note { display: flex; gap: 6px; align-items: flex-start; }
.rate-result { margin-top: 18px; }
.rate-result:empty { display: none; }
.rate-figure { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 16px 18px; border-radius: 14px; background: var(--primary-soft); }
.rate-figure span { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.rate-figure strong { font-family: var(--font-display); font-size: 34px; font-weight: 820; color: var(--primary); line-height: 1; }
.rate-figure small { color: var(--muted); }
.rate-explain { margin-top: 10px; font-size: 14px; color: var(--text-2); }
.rate-explain p { margin: 6px 0 0; }
.rate-balance { margin-top: 6px; align-items: flex-start; }
.rate-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 700; background: var(--info-soft); color: var(--primary); vertical-align: middle; }
.rate-badge.is-statement, .rate-badge.is-estimated { background: var(--warning-soft); color: var(--warning); }

/* ---------- Frecuencia de pago y edición ---------- */
.input-wrap.has-suffix input { padding-right: 96px; }
.pay-eq { color: var(--muted); font-size: 11.5px; }
.data-table td.num .pay-eq { display: block; margin: 2px 0 0; }
.rate-freq-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.rate-freq-label { font-size: 13px; font-weight: 650; color: var(--text-2); }
.debt-name-btn { padding: 0; border: 0; background: none; font: inherit; font-weight: 700; color: var(--text); text-align: left; cursor: pointer; }
.debt-name-btn:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
/* Acciones siempre visibles aunque la tabla tenga desplazamiento horizontal */
@media (min-width: 761px) {
  .responsive-table .actions-cell, .responsive-table thead th:last-child {
    position: sticky; right: 0; z-index: 2;
    background: var(--surface);
    box-shadow: -10px 0 14px -12px rgba(17, 21, 46, 0.35);
  }
  .responsive-table thead th:last-child { background: var(--surface-2); z-index: 3; }
  .responsive-table tfoot td:last-child { position: sticky; right: 0; background: var(--surface-2); }
}

.rate-fix { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--primary-soft); font-size: 14px; }

/* ---------- Licencia ---------- */
.license-banner {
  margin: 0 32px 8px; padding: 8px 12px 8px 14px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--primary-soft); color: var(--text); font-size: 14px; font-weight: 600;
}
.license-banner span { display: flex; align-items: center; gap: 8px; }
.license-banner.is-urgent { background: var(--warning-soft); }
.license-form { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.license-form label { font-size: 13px; font-weight: 650; color: var(--text-2); }
.license-form textarea {
  width: 100%; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--surface);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; word-break: break-all; resize: vertical;
}
.license-form textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.license-lock .modal { border-top: 4px solid var(--primary); }
.lock-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: var(--primary-soft); color: var(--primary); margin-bottom: 12px; }

/* ---------- Tabla de deudas compacta ---------- */
.data-table td .rate-badge { display: block; width: fit-content; margin: 3px 0 0 auto; }
.popover-menu {
  position: fixed; z-index: 2500; min-width: 190px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: fade 0.12s ease;
}
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none; font-size: 14px; font-weight: 550; color: var(--text); text-align: left; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); box-shadow: none; }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger:hover, .menu-item.is-danger:focus-visible { background: var(--danger-soft); }

/* ---------- Explicación de estrategias ---------- */
.strategy-help { padding: 0; }
.strategy-help summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 22px; cursor: pointer; list-style: none; font-weight: 700; font-size: 16px;
}
.strategy-help summary::-webkit-details-marker { display: none; }
.strategy-help summary span { display: flex; align-items: center; gap: 10px; color: var(--primary); }
.strategy-help summary small { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.strategy-help summary::after { content: "▾"; color: var(--muted); transition: transform 0.2s; }
.strategy-help[open] summary::after { transform: rotate(180deg); }
.strategy-help summary small { margin-left: auto; }
.strategy-help-body { padding: 0 22px 20px; display: grid; gap: 14px; font-size: 14.5px; color: var(--text-2); }
.strategy-help-body p { margin: 0; }
.help-steps { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.help-table td { vertical-align: top; }
.help-table td:first-child { white-space: nowrap; }
.help-subtitle { margin-top: 4px; }
.help-notes { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.help-notes li.is-warn { color: var(--text); background: var(--warning-soft); border-radius: 10px; padding: 8px 12px; list-style: none; margin-left: -20px; }

/* ---------- Actualizaciones ---------- */
.update-banner { margin-top: 8px; }
.update-banner .btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.about-update { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.update-notes { margin: 4px 0 10px; padding-left: 20px; }
.update-path { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; overflow-wrap: anywhere; }
.update-progress { font-weight: 650; color: var(--primary); }
.update-progress.is-error { color: var(--danger); }
