/* Simulador de hipoteca inversa y nuda propiedad */
:root,
[data-theme="dark"] {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-page: #0b0f17;
  --bg-surface: #131b2e;
  --bg-surface-2: #192338;
  --bg-input: #0f1626;
  --border-color: #26334d;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-page: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --accent: #0284c7;
  --accent-strong: #0369a1;
  --accent-soft: rgba(2, 132, 199, 0.1);
  --emerald: #059669;
  --emerald-soft: rgba(5, 150, 105, 0.1);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.1);
  --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

[data-theme="dark"] .app-header { background: #131b2e !important; border-bottom: 1px solid #1e293b !important; }
[data-theme="dark"] .brand-title { color: #f8fafc !important; }
[data-theme="light"] .app-header { background: #ffffff !important; border-bottom: 1px solid #cbd5e1 !important; }
[data-theme="light"] .brand-title { color: #0f172a !important; }

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

body {
  font-family: var(--font-main);
  background: var(--bg-page);
  color: var(--text-main);
  margin: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6, .brand-title, .section-title { font-family: var(--font-heading); }
.mono, code { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.tool-layout { max-width: 1200px; width: 100%; margin: 1.5rem auto 3rem; padding: 0 1rem; flex: 1 0 auto; }
.tool-with-sidebar { display: flex; gap: 2rem; align-items: flex-start; width: 100%; }
.tool-main-content { flex: 1 1 0%; min-width: 0; width: 100%; }

.hi-card {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: 16px; padding: 1.4rem; box-shadow: var(--shadow-card); margin-bottom: 1.5rem;
}

.hero-pills { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.hero-pill {
  padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(56, 189, 248, 0.25);
}
.hero-title { margin: 0 0 0.5rem; font-size: 1.4rem; font-weight: 700; line-height: 1.28; }
.hero-desc { margin: 0; font-size: 0.94rem; line-height: 1.55; color: var(--text-muted); }

.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.section-title { margin: 0 0 0.85rem; font-size: 1.2rem; font-weight: 700; }
.section-head .section-title { margin-bottom: 0; }
.section-sub { margin: 0.25rem 0 0; font-size: 0.88rem; color: var(--text-muted); }

.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.95rem; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.3rem; }
.field input, .field select, .field-inline input {
  width: 100%; max-width: 100%; min-width: 0; min-height: 42px; padding: 0.5rem 0.8rem;
  border-radius: 10px; border: 1px solid var(--border-color);
  background-color: var(--bg-input); color: var(--text-main);
  font-size: 0.9rem; font-family: var(--font-main);
}
.field select {
  padding-right: 40px; color-scheme: dark light; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center;
}
.field select option { background-color: var(--bg-surface); color: var(--text-main); }

.checks-row { display: flex; flex-wrap: wrap; gap: 0.85rem; align-items: center; margin-top: 1rem; }
.check-pill {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.9rem;
  border-radius: 10px; background: var(--bg-surface-2); border: 1px solid var(--border-color);
  cursor: pointer; font-size: 0.88rem; min-height: 40px;
}
.check-pill input { accent-color: var(--accent); width: 16px; height: 16px; }
.field-inline { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.field-inline label { font-size: 0.84rem; color: var(--text-muted); }
.field-inline input { width: 160px; }

.status-banner {
  margin-top: 0.95rem; padding: 0.85rem 1rem; border-radius: 11px;
  font-size: 0.88rem; line-height: 1.5; border: 1px solid var(--border-color);
}
.status-banner.ok { background: var(--emerald-soft); border-color: var(--emerald); }
.status-banner.warn { background: var(--amber-soft); border-color: var(--amber); }

.split-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.15rem; }
.subpanel {
  background: var(--bg-surface-2); border: 1px solid var(--border-color);
  border-radius: 14px; padding: 1.1rem;
}
.subpanel h3 { margin: 0 0 0.9rem; font-size: 1.02rem; }
.hint-note { margin: 0.75rem 0 0; font-size: 0.82rem; color: var(--text-muted); line-height: 1.45; }
.fiscal-usufructo-box {
  margin-top: 0.85rem; padding: 0.75rem 0.9rem; border-radius: 10px;
  background: var(--bg-surface); border: 1px solid var(--border-color);
  font-size: 0.84rem; line-height: 1.5;
}

.btn-secondary {
  min-height: 42px; padding: 0.55rem 1.05rem; border-radius: 10px;
  background: var(--bg-surface-2); color: var(--text-main); border: 1px solid var(--border-color);
  font-weight: 600; font-size: 0.9rem; cursor: pointer; font-family: var(--font-main);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.compare-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.1rem; }
.result-card {
  background: var(--bg-surface-2); border: 1px solid var(--border-color);
  border-radius: 14px; padding: 1.15rem;
}
.result-card.hi-accent { border-top: 3px solid var(--accent); }
.result-card.np-accent { border-top: 3px solid var(--emerald); }
.rc-tag {
  display: inline-block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 0.22rem 0.6rem; border-radius: 999px; margin-bottom: 0.5rem;
  background: var(--accent-soft); color: var(--accent);
}
.np-accent .rc-tag { background: var(--emerald-soft); color: var(--emerald); }
.result-card h3 { margin: 0 0 0.85rem; font-size: 1.15rem; }
.rc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.65rem; }
.rc-grid > div {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: 10px; padding: 0.6rem 0.75rem;
}
.rc-grid span { display: block; font-size: 0.74rem; color: var(--text-muted); margin-bottom: 0.2rem; }
.rc-grid strong { font-size: 0.96rem; }
.positive-txt { color: var(--emerald); }
.warn-txt { color: var(--amber); }

.footnote { margin: 0.85rem 0 0; font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }
.verdict-banner {
  margin-top: 0.9rem; padding: 1rem 1.15rem; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  font-size: 0.92rem; line-height: 1.55;
}

.legend-inline { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; font-size: 0.83rem; color: var(--text-muted); }
.leg-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot-home { background: #38bdf8; }
.dot-debt { background: #f59e0b; }
.dot-np { background: #10b981; }

.chart-wrap { width: 100%; margin: 0.5rem 0 1.2rem; }
#hi-chart { width: 100%; height: 310px; display: block; border-radius: 12px; background: var(--bg-surface-2); border: 1px solid var(--border-color); }

.table-responsive { overflow-x: auto; border: 1px solid var(--border-color); border-radius: 12px; max-height: 400px; overflow-y: auto; }
.hi-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.hi-table th, .hi-table td { padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--border-color); text-align: left; white-space: nowrap; }
.hi-table thead th { position: sticky; top: 0; background: var(--bg-surface-2); color: var(--text-muted); font-weight: 700; z-index: 1; }
.hi-table td.num, .hi-table th.num { text-align: right; font-family: var(--font-mono); }

.faq-list { display: flex; flex-direction: column; gap: 0.65rem; }
.faq-item { border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-surface-2); overflow: hidden; }
.faq-item summary { padding: 0.85rem 1rem; font-weight: 600; cursor: pointer; list-style: none; color: var(--text-main); }
.faq-item p { margin: 0; padding: 0 1rem 0.95rem; font-size: 0.9rem; line-height: 1.55; color: var(--text-muted); }

@media (max-width: 960px) {
  .form-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .split-2, .compare-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .form-grid-3, .form-grid-2, .rc-grid { grid-template-columns: 1fr; }
  .btn-secondary { width: 100%; }
  .field-inline, .field-inline input { width: 100%; }
}

@media print {
  .app-header, .tools-ad-banner-section, .tool-ad-sidebar, .tools-related-section, .fijate-footer, .no-print {
    display: none !important;
  }
  body { background: #ffffff !important; color: #0f172a !important; }
  .hi-card { box-shadow: none !important; border: 1px solid #cbd5e1 !important; background: #ffffff !important; color: #0f172a !important; break-inside: avoid; }
  .table-responsive { max-height: none !important; overflow: visible !important; }
}
