/* ==========================================================================
   Calculadora de alquilar o comprar vivienda en España - Estilos canónicos
   ========================================================================== */

: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-app: #080c14;
  --bg-card: #111827;
  --bg-card-elevated: #172033;
  --bg-input: #0b1220;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: #38bdf8;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-soft: #cbd5e1;

  --primary: #38bdf8;
  --primary-color: #38bdf8;
  --primary-light: rgba(56, 189, 248, 0.14);
  --primary-glow: rgba(56, 189, 248, 0.25);

  --buy-color: #38bdf8;
  --buy-bg: rgba(56, 189, 248, 0.14);
  --buy-border: rgba(56, 189, 248, 0.35);

  --rent-color: #10b981;
  --rent-bg: rgba(16, 185, 129, 0.14);
  --rent-border: rgba(16, 185, 129, 0.35);

  --cross-color: #f59e0b;
  --cross-bg: rgba(245, 158, 11, 0.14);
  --cross-border: rgba(245, 158, 11, 0.38);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 12px 28px -8px rgba(0, 0, 0, 0.45);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-elevated: #f8fafc;
  --bg-input: #ffffff;
  --bg-hover: rgba(15, 23, 42, 0.04);
  --border-color: #cbd5e1;
  --border-focus: #0284c7;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-soft: #334155;

  --primary: #0284c7;
  --primary-color: #0284c7;
  --primary-light: rgba(2, 132, 199, 0.1);
  --primary-glow: rgba(2, 132, 199, 0.18);

  --buy-color: #0284c7;
  --buy-bg: rgba(2, 132, 199, 0.1);
  --buy-border: rgba(2, 132, 199, 0.35);

  --rent-color: #059669;
  --rent-bg: rgba(5, 150, 105, 0.1);
  --rent-border: rgba(5, 150, 105, 0.35);

  --cross-color: #d97706;
  --cross-bg: rgba(217, 119, 6, 0.1);
  --cross-border: rgba(217, 119, 6, 0.35);

  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;

  --shadow-card: 0 8px 24px -6px rgba(15, 23, 42, 0.08);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  color-scheme: light;
}

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

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

h1, h2, h3, h4, h5, h6,
.brand-title,
.verdict-title {
  font-family: var(--font-heading);
}

.mono,
code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.tool-layout {
  margin-top: 1.25rem;
  margin-bottom: 3rem;
  flex: 1 0 auto;
}

/* ==========================================================================
   Barra rápida de presets y acciones
   ========================================================================== */
.tool-quick-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
}

.quick-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.quick-bar-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.btn-preset {
  appearance: none;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  min-height: 36px;
  font-family: var(--font-main);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-preset:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.btn-preset.is-active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.quick-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.segmented-control {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.38rem 0.75rem;
  min-height: 32px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--text-main);
}

.seg-btn.is-active {
  background: var(--primary);
  color: #ffffff;
}

.btn-ghost-sm {
  appearance: none;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.8rem;
  min-height: 36px;
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-ghost-sm:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-hover);
}

/* ==========================================================================
   Banner de veredicto principal
   ========================================================================== */
.verdict-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease;
}

.verdict-banner.is-buy {
  border-left-color: var(--buy-color);
  background: linear-gradient(135deg, var(--bg-card) 60%, var(--buy-bg) 100%);
}

.verdict-banner.is-rent {
  border-left-color: var(--rent-color);
  background: linear-gradient(135deg, var(--bg-card) 60%, var(--rent-bg) 100%);
}

.verdict-banner.is-tie {
  border-left-color: var(--cross-color);
  background: linear-gradient(135deg, var(--bg-card) 60%, var(--cross-bg) 100%);
}

.verdict-main {
  flex: 1 1 360px;
  min-width: 0;
}

.verdict-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--buy-border);
  margin-bottom: 0.55rem;
}

.verdict-banner.is-rent .verdict-pill {
  background: var(--rent-bg);
  color: var(--rent-color);
  border-color: var(--rent-border);
}

.verdict-banner.is-tie .verdict-pill {
  background: var(--cross-bg);
  color: var(--cross-color);
  border-color: var(--cross-border);
}

.verdict-title {
  margin: 0 0 0.35rem 0;
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-main);
}

.verdict-subtitle {
  margin: 0;
  font-size: 0.94rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.verdict-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
}

.breakeven-badge {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  min-width: 130px;
}

.breakeven-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.breakeven-value {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--cross-color);
  margin-top: 0.1rem;
}

.btn-share-card {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.7rem 1.15rem;
  min-height: 44px;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
  box-shadow: 0 6px 18px -4px var(--primary-glow);
  white-space: nowrap;
}

.btn-share-card:hover {
  transform: translateY(-1px);
  filter: brightness(1.07);
}

/* ==========================================================================
   KPIs principales (4 tarjetas)
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.05rem 1.15rem;
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.kpi-card.kpi-buy {
  border-top: 3px solid var(--buy-color);
}

.kpi-card.kpi-rent {
  border-top: 3px solid var(--rent-color);
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-buy {
  background: var(--buy-color);
  box-shadow: 0 0 10px var(--buy-color);
}

.dot-rent {
  background: var(--rent-color);
  box-shadow: 0 0 10px var(--rent-color);
}

.kpi-value {
  font-size: clamp(1.2rem, 1.8vw, 1.5rem);
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
  margin-bottom: 0.35rem;
  word-break: break-word;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* ==========================================================================
   Workspace bilateral: parámetros (izq) + resultados/gráfica (der)
   ========================================================================== */
.calc-workspace {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 1.35rem;
  align-items: start;
}

.params-column,
.results-column {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.3rem;
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.panel-buy {
  border-top: 3px solid var(--buy-color);
}

.panel-rent {
  border-top: 3px solid var(--rent-color);
}

.panel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.panel-card-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.horizon-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.tag-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-buy {
  background: var(--buy-bg);
  color: var(--buy-color);
  border: 1px solid var(--buy-border);
}

.badge-rent {
  background: var(--rent-bg);
  color: var(--rent-color);
  border: 1px solid var(--rent-border);
}

/* Formularios e inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  min-width: 0;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.9rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.form-row-2 .form-group,
.form-row-3 .form-group {
  margin-bottom: 0;
}

.form-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--text-soft);
}

.form-hint {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-muted);
}

.input-suffix-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.form-input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.5rem 2.6rem 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input-suffix {
  position: absolute;
  right: 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.5rem 40px 0.5rem 0.75rem;
  background-color: var(--bg-input);
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-select option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

/* Slider de horizonte */
.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: var(--border-color);
  outline: none;
  margin: 0.45rem 0 0.6rem;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.range-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.horizon-chips,
.return-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.horizon-chips {
  margin-bottom: 0.2rem;
}

.chip-btn {
  appearance: none;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.3rem 0.68rem;
  min-height: 32px;
  font-family: var(--font-main);
  font-size: 0.77rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.chip-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.chip-btn.is-active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.ccaa-tax-note {
  margin: 0.45rem 0 0;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  font-size: 0.79rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 0.35rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  font-size: 0.82rem;
  color: var(--text-soft);
  cursor: pointer;
  line-height: 1.4;
}

.checkbox-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}

/* ==========================================================================
   Gráfica interactiva Canvas 2D
   ========================================================================== */
.chart-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.chart-header h3 {
  margin: 0 0 0.2rem 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-main);
}

.chart-subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-soft);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.swatch-buy {
  background: var(--buy-color);
}

.swatch-rent {
  background: var(--rent-color);
}

.swatch-cross {
  background: var(--cross-color);
  border-radius: 50%;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 360px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  touch-action: pan-y;
}

#comparison-chart {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.chart-tooltip {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  pointer-events: none;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  min-width: 195px;
  max-width: 260px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  font-size: 0.79rem;
  color: var(--text-main);
}

.chart-tooltip[hidden] {
  display: none;
}

.tooltip-year {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.86rem;
  margin-bottom: 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.tooltip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.tooltip-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
}

.tooltip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.tooltip-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-main);
}

/* ==========================================================================
   Análisis de sensibilidad y desglose clave
   ========================================================================== */
.sensitivity-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.sens-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.sens-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.sens-val {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--primary);
}

.sens-note {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.breakdown-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.breakdown-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  min-width: 0;
}

.breakdown-box h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

.breakdown-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.breakdown-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  padding-bottom: 0.45rem;
  border-bottom: 1px dashed var(--border-color);
}

.breakdown-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.breakdown-list li strong {
  color: var(--text-main);
  font-weight: 700;
  white-space: nowrap;
}

.breakdown-list li.is-total {
  padding-top: 0.25rem;
  color: var(--text-main);
  font-weight: 700;
}

.breakdown-list li.is-total strong {
  color: var(--primary);
  font-size: 0.94rem;
}

/* ==========================================================================
   Tabla año a año
   ========================================================================== */
.table-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.9rem;
}

.table-header-bar h3 {
  margin: 0 0 0.2rem 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.table-scroll-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
  font-size: 0.84rem;
}

.data-table th,
.data-table td {
  padding: 0.68rem 0.8rem;
  text-align: right;
  border-bottom: 1px solid var(--border-color);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
  font-weight: 700;
}

.data-table th {
  background: var(--bg-card-elevated);
  color: var(--text-soft);
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  position: sticky;
  top: 0;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: var(--bg-hover);
}

.data-table tr.is-breakeven-row td {
  background: var(--cross-bg);
}

.diff-buy {
  color: var(--buy-color);
  font-weight: 700;
}

.diff-rent {
  color: var(--rent-color);
  font-weight: 700;
}

.year-tag-cross {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--cross-bg);
  color: var(--cross-color);
  border: 1px solid var(--cross-border);
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: middle;
}

/* ==========================================================================
   Modal accesible (sustituto de window.alert)
   ========================================================================== */
.tool-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.tool-modal-overlay.is-open {
  display: flex;
}

.tool-modal {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
  color: var(--text-main);
}

.tool-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.tool-modal-header h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.tool-modal-close {
  appearance: none;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-modal-close:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tool-modal-body {
  padding: 1.15rem 1.25rem;
  font-size: 0.91rem;
  line-height: 1.6;
  color: var(--text-soft);
}

.tool-modal-body p {
  margin: 0 0 0.75rem 0;
}

.tool-modal-body p:last-child {
  margin-bottom: 0;
}

.tool-modal-body ul {
  margin: 0.4rem 0 0.75rem 1.2rem;
  padding: 0;
}

.tool-modal-body li {
  margin-bottom: 0.35rem;
}

.tool-modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.85rem 1.25rem 1.15rem;
  border-top: 1px solid var(--border-color);
}

.btn-modal-primary {
  appearance: none;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.2rem;
  min-height: 40px;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-modal-primary:hover {
  filter: brightness(1.08);
}

/* ==========================================================================
   Adaptación responsiva (Tablet y Móvil)
   ========================================================================== */
@media (max-width: 1120px) {
  .calc-workspace {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .tool-quick-bar {
    padding: 0.85rem;
  }

  .quick-presets,
  .quick-controls {
    width: 100%;
  }

  .btn-preset,
  .btn-ghost-sm,
  .seg-btn,
  .chip-btn,
  .btn-share-card {
    min-height: 40px;
  }

  .quick-controls .segmented-control {
    width: 100%;
  }

  .quick-controls .seg-btn {
    flex: 1 1 0%;
  }

  .verdict-banner {
    padding: 1.1rem;
  }

  .verdict-actions {
    width: 100%;
  }

  .breakeven-badge {
    flex: 1 1 130px;
  }

  .btn-share-card {
    width: 100%;
  }

  .sensitivity-grid,
  .breakdown-cols {
    grid-template-columns: 1fr;
  }

  .chart-canvas-wrap {
    height: 300px;
  }
}

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

  .form-row-2,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

  .panel-card {
    padding: 1rem;
  }
}
