/* =================================================================
   CalcTitan — Design System v2
   Clean, light, Notion-inspired. Mobile-first.
================================================================= */

/* ─── TOKENS ─── */
:root {
  --accent:          #7C3AED;
  --accent-dark:     #6D28D9;
  --accent-deeper:   #5B21B6;
  --accent-bg:       #F5F3FF;
  --accent-border:   #EDE9FE;
  --accent-border-2: #DDD6FE;
  --text-primary:    #111827;
  --text-secondary:  #374151;
  --text-muted:      #6B7280;
  --text-faint:      #9CA3AF;
  --text-placeholder:#D1D5DB;
  --border:          #E5E7EB;
  --border-subtle:   #F3F4F6;
  --bg:              #F9FAFB;
  --surface:         #FFFFFF;
  --red-bg:          #FEF2F2;
  --red-border:      #FECACA;
  --red-text:        #DC2626;
  --radius-card:     14px;
  --radius-input:    10px;
  --radius-btn:      9px;
  --shadow-card:     0 1px 2px rgba(0,0,0,0.05), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-hover:    0 4px 20px rgba(0,0,0,0.09), 0 1px 3px rgba(0,0,0,0.05);
  --ease-spring:     cubic-bezier(0.16, 1, 0.3, 1);
  --t:               150ms;
}

/* ─── BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--surface);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Remove number spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* ─── LAYOUT ─── */
.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ─── SITE HEADER ─── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}

.site-header .container {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ─── LOGO ─── */
.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity var(--t) ease;
}

.logo:hover {
  opacity: 0.85;
}

.logo-img {
  height: 72px;
  width: auto;
  display: block;
}

.logo-icon {
  width: 29px;
  height: 29px;
  flex-shrink: 0;
  border-radius: 8px;
  background: linear-gradient(140deg, #8B5CF6 0%, #6D28D9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(109, 40, 217, 0.22), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: box-shadow var(--t) ease, transform var(--t) var(--ease-spring);
}

.logo:hover .logo-icon {
  box-shadow: 0 4px 16px rgba(109, 40, 217, 0.35), inset 0 1px 0 rgba(255,255,255,0.15);
  transform: translateY(-1px);
}

.logo-wordmark {
  font-size: 15px;
  letter-spacing: -0.04em;
  line-height: 1;
  transition: opacity var(--t) ease;
}

.logo:hover .logo-wordmark {
  opacity: 0.85;
}

.logo-calc {
  font-weight: 400;
  color: var(--text-muted);
}

.logo-titan {
  font-weight: 800;
  color: var(--text-primary);
}

/* Back navigation link (calculator pages) */
.nav-back {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px 0;
  transition: color var(--t) ease;
}

.nav-back:hover {
  color: var(--text-primary);
}

/* ─── SITE FOOTER ─── */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.site-footer .container {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-footer span {
  font-size: 12px;
  color: var(--text-faint);
}

/* ─── CONTENT SECTIONS (SEO / FAQ) ─── */

.calc-content {
  padding: 48px 0 64px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 16px;
}

.content-body {
  max-width: 720px;
  margin: 0 auto;
}

.content-body h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px;
  letter-spacing: -0.2px;
}

.content-body h2:not(:first-child) {
  margin-top: 40px;
}

.content-body p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0 0 14px;
}

/* FAQ accordion */
.faq {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.faq-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-item summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  background: var(--bg-card);
  transition: background 0.15s;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: '+';
  font-size: 18px;
  font-weight: 400;
  color: var(--accent);
  flex-shrink: 0;
  transition: transform 0.2s var(--ease-spring);
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item summary:hover {
  background: var(--bg-subtle, #f8f8fa);
}

.faq-a {
  padding: 0 18px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
  background: var(--bg-card);
  margin: 0 !important;
}

/* Ad slots */
.ad-slot {
  width: 100%;
  background: var(--bg-subtle, #f8f8fa);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ad-slot--leaderboard {
  height: 90px;
  margin: 32px 0;
}

.ad-slot--in-content {
  height: 250px;
  margin: 36px 0;
}

/* Affiliate CTA */
.affiliate-cta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--accent-bg) 0%, #FDFCFF 100%);
  border: 1px solid var(--accent-light, #e0d9ff);
  border-radius: var(--radius-md);
  margin: 32px 0;
  text-decoration: none;
  transition: box-shadow 0.18s, transform 0.18s;
}

.affiliate-cta:hover {
  box-shadow: 0 4px 16px rgba(109,86,252,0.12);
  transform: translateY(-1px);
}

.affiliate-cta-text {
  flex: 1;
}

.affiliate-cta-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 2px;
}

.affiliate-cta-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.affiliate-cta-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.affiliate-cta-arrow {
  font-size: 18px;
  color: var(--accent);
  flex-shrink: 0;
}

/* ─── HUB PAGE ─── */
.hub-main {
  flex: 1;
  padding: 36px 0 72px;
}

.hub-heading {
  margin-bottom: 24px;
}

.hub-heading h1 {
  font-size: 21px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.035em;
  margin-bottom: 5px;
  line-height: 1.25;
}

.hub-heading p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Calculator card grid */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 540px) {
  .calc-grid {
    grid-template-columns: 1fr 1fr;
  }
}

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

/* Hub card links */
.calc-card-link {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 18px;
  transition:
    border-color var(--t) ease,
    box-shadow var(--t) ease,
    transform var(--t) var(--ease-spring);
  position: relative;
  overflow: hidden;
}

.calc-card-link::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-bg) 0%, transparent 55%);
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}

.calc-card-link:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.calc-card-link:hover::after {
  opacity: 1;
}

.calc-card-link:active {
  transform: translateY(0);
  box-shadow: none;
  border-color: var(--accent-border-2);
}

.card-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  padding: 2px 8px;
  border-radius: 100px;
  margin-bottom: 10px;
  width: fit-content;
  position: relative;
  z-index: 1;
}

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 5px;
  line-height: 1.3;
  position: relative;
  z-index: 1;
}

.card-description {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  flex: 1;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}

.card-cta {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 3px;
  position: relative;
  z-index: 1;
  transition: gap var(--t) ease;
}

.calc-card-link:hover .card-cta {
  gap: 6px;
}

/* ─── FEATURED CARD ─── */
.featured-card {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  text-decoration: none;
  border-radius: var(--radius-card);
  background: linear-gradient(135deg, #92400E 0%, #B45309 40%, #D97706 100%);
  padding: 28px 32px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  transition:
    box-shadow var(--t) ease,
    transform var(--t) var(--ease-spring);
}

.featured-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 80% 50%, rgba(255,255,255,0.08) 0%, transparent 60%);
  pointer-events: none;
}

.featured-card:hover {
  box-shadow: 0 8px 32px rgba(146,64,14,0.35);
  transform: translateY(-2px);
}

.featured-card:active {
  transform: translateY(0);
}

.featured-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 1;
  flex: 1;
}

.featured-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #FEF3C7;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 3px 9px;
  border-radius: 100px;
  width: fit-content;
}

.featured-title {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.04em;
  line-height: 1.2;
  margin: 0;
}

.featured-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.82);
  line-height: 1.6;
  max-width: 480px;
  margin: 0;
}

.featured-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.featured-pill {
  font-size: 11px;
  font-weight: 500;
  color: #FEF3C7;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 3px 10px;
  border-radius: 100px;
}

.featured-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #92400E;
  background: #ffffff;
  padding: 8px 18px;
  border-radius: 100px;
  width: fit-content;
  transition: gap 0.15s ease, background 0.15s ease;
}

.featured-card:hover .featured-cta {
  background: #FEF3C7;
  gap: 10px;
}

.featured-visual {
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0.18;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

@media (min-width: 540px) {
  .featured-visual {
    display: flex;
  }
}

/* ─── CALCULATOR PAGE ─── */
.calc-main {
  flex: 1;
  padding: 28px 0 72px;
}

/* The calculator form card */
.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 26px;
  box-shadow: var(--shadow-card);
  animation: fadeUp 0.28s var(--ease-spring) both;
}

@media (max-width: 480px) {
  .calc-card {
    padding: 18px;
    border-radius: 12px;
  }
}

/* ─── DESKTOP TWO-COLUMN LAYOUT ─── */
@media (min-width: 860px) {
  .calc-card {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    padding: 0;
    overflow: hidden;
  }

  .calc-panel-left {
    flex: 0 0 52%;
    padding: 32px;
    border-right: 1px solid var(--border-subtle);
    min-width: 0;
  }

  .calc-panel-right {
    flex: 1;
    padding: 32px;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    min-width: 0;
    align-self: flex-start;
  }
}

.calc-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
}

.calc-panel-empty-icon {
  font-size: 32px;
  opacity: 0.25;
  line-height: 1;
}

.calc-panel-empty p {
  font-size: 13px;
  color: var(--text-faint);
  line-height: 1.5;
}

/* Hide empty state once a sibling result is visible */
.calc-panel-empty:has(~ :not(.hidden)) {
  display: none;
}

/* Card header */
.calc-card-header {
  margin-bottom: 22px;
}

/* Badge atop each card */
.calc-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  padding: 2px 8px;
  border-radius: 100px;
  margin-bottom: 10px;
}

.calc-card-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.035em;
  margin-bottom: 6px;
  line-height: 1.25;
}

.calc-card-header p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Form fields */
.fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Kept for backward compat with JS-generated cashflow HTML */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label,
.input-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}

.field-unit,
.input-unit {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-faint);
}

/* ─── INPUT ─── */
.calc-input {
  width: 100%;
  padding: 9px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  outline: none;
  transition:
    border-color var(--t) ease,
    background var(--t) ease,
    box-shadow var(--t) ease;
  -webkit-appearance: none;
  appearance: none;
}

.calc-input::placeholder {
  color: var(--text-placeholder);
}

.calc-input:hover {
  border-color: #C4B5FD;
  background: var(--surface);
}

.calc-input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.10);
}

/* ─── ACTIONS ROW ─── */
.actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

/* ─── BUTTONS ─── */

/* Primary — Compute */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: -0.01em;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition:
    background var(--t) ease,
    transform var(--t) var(--ease-spring),
    box-shadow var(--t) ease;
  -webkit-appearance: none;
}

.btn-primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
  background: var(--accent-deeper);
}

.btn-primary:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* Ghost — Reset */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: all var(--t) ease;
  -webkit-appearance: none;
}

.btn-ghost:hover {
  background: var(--bg);
  border-color: #D1D5DB;
  color: var(--text-secondary);
}

.btn-ghost:active {
  background: #F3F4F6;
}

.btn-ghost:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* Add cash flow */
.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1.5px solid var(--accent-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--t) ease;
  -webkit-appearance: none;
}

.btn-add:hover {
  background: var(--accent-border);
  border-color: var(--accent-border-2);
}

/* Remove cash flow */
.btn-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-faint);
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t) ease;
  -webkit-appearance: none;
}

.btn-remove:hover {
  color: var(--red-text);
  border-color: var(--red-border);
  background: var(--red-bg);
}

/* ─── CASH FLOW ROWS ─── */
.cashflow-row {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  animation: slideIn 0.18s var(--ease-spring) both;
}

/* Add row hint */
.add-row-hint {
  display: flex;
  align-items: center;
  gap: 10px;
}

.add-row-shortcut {
  font-size: 11.5px;
  color: var(--text-faint);
}

/* ─── ERROR BANNER ─── */
.error-banner {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 10px 13px;
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: 9px;
  font-size: 13px;
  color: var(--red-text);
  line-height: 1.45;
}

.error-banner::before {
  content: '⚠';
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 1.5px;
}

/* ─── RESULT CARD ─── */
.result-card {
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--accent-bg) 0%, #FDFCFF 100%);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  animation: resultReveal 0.3s var(--ease-spring) both;
}

.result-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #A78BFA;
  margin-bottom: 5px;
}

.result-value {
  font-size: 34px;
  font-weight: 800;
  color: var(--accent-dark);
  letter-spacing: -0.04em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
  .result-value {
    font-size: 28px;
  }
}

/* ─── INPUT SECTIONS (Rent vs. Buy grouping) ─── */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fields > .input-section + .input-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: 20px;
  margin-top: 4px;
}

.input-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  padding-left: 10px;
  border-left: 2.5px solid var(--accent);
  margin-bottom: 4px;
}

/* Live computed display (implied CAGR, marginal rate) */
.field-computed {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  padding: 6px 10px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 7px;
  line-height: 1.4;
}

/* ─── SELECT (state dropdown) ─── */
.calc-select {
  width: 100%;
  padding: 9px 36px 9px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L2 4h8z' fill='%239CA3AF'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  outline: none;
  cursor: pointer;
  transition: border-color var(--t) ease, background-color var(--t) ease, box-shadow var(--t) ease;
  -webkit-appearance: none;
  appearance: none;
}

.calc-select:hover {
  border-color: #C4B5FD;
  background-color: var(--surface);
}

.calc-select:focus {
  border-color: var(--accent);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.10);
}

/* ─── RENT VS. BUY RESULTS ─── */
.mortgage-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent-bg) 0%, #FDFCFF 100%);
  border: 1px solid var(--accent-light, #e0d9ff);
  border-radius: var(--radius-md);
  animation: fadeUp 0.25s var(--ease-spring) both;
}
.mortgage-preview-main {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}
.mortgage-preview-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 2px;
}
.mortgage-preview-split {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.rvb-result {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeUp 0.3s var(--ease-spring) both;
}

.breakeven-card {
  padding: 20px 22px;
  background: linear-gradient(135deg, var(--accent-bg) 0%, #FDFCFF 100%);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
}

.breakeven-card.no-breakeven {
  background: linear-gradient(135deg, #FEF3C7 0%, #FFFDF5 100%);
  border-color: #FDE68A;
}

.breakeven-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #A78BFA;
  margin-bottom: 5px;
}

.breakeven-card.no-breakeven .breakeven-label {
  color: #B45309;
}

.breakeven-year {
  font-size: 34px;
  font-weight: 800;
  color: var(--accent-dark);
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.breakeven-card.no-breakeven .breakeven-year {
  color: #92400E;
}

.breakeven-sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Break-even row in table */
.amort-table tbody tr.row-breakeven td {
  background: var(--accent-bg) !important;
}

.amort-table tbody tr.row-breakeven td:first-child {
  color: var(--accent);
  font-weight: 700;
}

/* Advantage cell text */
.adv-buy  { color: var(--accent-dark); font-weight: 600; }
.adv-rent { color: var(--text-muted); }
.adv-even { color: var(--accent); font-weight: 700; }

/* Footnote */
.rvb-footnote {
  padding: 18px 20px;
  margin-top: 8px;
  background: var(--bg-subtle, #f8f8fa);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent);
}
.rvb-footnote-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 10px;
}
.rvb-footnote-terms {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.rvb-footnote-term {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.rvb-footnote-term .term-icon {
  font-size: 11px;
  width: 16px;
  flex-shrink: 0;
  text-align: center;
  color: var(--accent);
  font-weight: 700;
}
.rvb-footnote-term.subtract .term-icon {
  color: #16a34a;
}
.rvb-footnote-sub {
  display: block;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.5;
}

/* ─── DOWN PAYMENT TOGGLE ─── */
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dp-toggle {
  display: flex;
  background: var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.dp-toggle-btn {
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all var(--t) ease;
  -webkit-appearance: none;
}

.dp-toggle-btn.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.09);
}

.field-hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 4px;
}

/* ─── MORTGAGE SUMMARY GRID ─── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 480px) {
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }
  .summary-grid .summary-card:first-child {
    grid-column: span 2;
  }
}

.summary-card {
  background: linear-gradient(135deg, var(--accent-bg) 0%, #FDFCFF 100%);
  border: 1px solid var(--accent-border);
  border-radius: 11px;
  padding: 14px 16px;
}

.summary-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #A78BFA;
  margin-bottom: 5px;
}

.summary-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-dark);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

@media (max-width: 480px) {
  .summary-value { font-size: 17px; }
}

/* ─── AMORTIZATION TABLE ─── */
.amort-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.amort-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.amort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.amort-table thead th {
  background: var(--bg);
  padding: 9px 14px;
  text-align: right;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.amort-table thead th:first-child { text-align: left; }

.amort-table tbody td {
  padding: 9px 14px;
  text-align: right;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.amort-table tbody td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
}

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

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

/* Equation operators: = and + */
.col-eq, .col-plus {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.55;
  letter-spacing: 0;
}

/* Balance column separator */
.amort-table th.col-balance,
.amort-table td.col-balance {
  border-left: 1.5px solid var(--border);
}

/* Compact table variant for RVB (narrower right panel) */
#rvb-table-body ~ * ,
#rvb-result .amort-table thead th,
#rvb-result .amort-table tbody td {
  padding: 7px 10px;
  font-size: 12px;
}

#rvb-result .amort-table {
  table-layout: fixed;
  width: 100%;
}

#rvb-result .amort-table thead th:nth-child(1),
#rvb-result .amort-table tbody td:nth-child(1) { width: 20%; }
#rvb-result .amort-table thead th:nth-child(2),
#rvb-result .amort-table tbody td:nth-child(2) { width: 25%; }
#rvb-result .amort-table thead th:nth-child(3),
#rvb-result .amort-table tbody td:nth-child(3) { width: 25%; }
#rvb-result .amort-table thead th:nth-child(4),
#rvb-result .amort-table tbody td:nth-child(4) { width: 30%; white-space: normal; }

/* ─── MORTGAGE RESULT SECTION ─── */
.mortgage-result {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeUp 0.3s var(--ease-spring) both;
}

/* ─── UTILITY ─── */
.hidden { display: none !important; }

/* ─── KEYFRAME ANIMATIONS ─── */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes resultReveal {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-5px); }
  40%       { transform: translateX(5px); }
  60%       { transform: translateX(-3px); }
  80%       { transform: translateX(3px); }
}

/* Shake trigger on error */
.error-banner.shake {
  animation: shake 0.4s ease-out;
}

/* ═══════════════════════════════════════════════════════════
   OPTIONS PAYOUT VISUALIZER
═══════════════════════════════════════════════════════════ */

/* Wide-right layout: 38% inputs / 62% chart */
@media (min-width: 860px) {
  .calc-card--wide-right .calc-panel-left  { flex: 0 0 38%; }
  .calc-card--wide-right .calc-panel-right { flex: 1; }
}

/* Chart panel — no sticky, no max-height clip */
.calc-panel-right--chart {
  position: static !important;
  max-height: none !important;
  overflow: visible !important;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 460px;
  min-height: 320px;
}

@media (max-width: 860px) {
  .chart-container { height: 320px; }
}

/* Strategy preset pills */
.preset-bar {
  margin-bottom: 20px;
}

.preset-bar-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-btn {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 4px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  line-height: 1.5;
}

.preset-btn:hover {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}

.preset-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Legs section */
.legs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.legs-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

#legs-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.no-legs-hint {
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
  padding: 20px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

/* Individual leg row */
.leg-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s;
}

.leg-card:hover { border-color: var(--accent-border); }

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

.leg-type-select {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  padding: 5px 28px 5px 10px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23aaa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s, background-color 0.15s;
}

.leg-type-select:hover {
  border-color: var(--accent-border);
  background-color: var(--accent-bg);
}

.leg-type-select:focus {
  border-color: var(--accent);
  background-color: var(--accent-bg);
}

.leg-qty-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.leg-qty-x {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1;
  user-select: none;
}

.leg-qty-input {
  width: 44px !important;
  padding: 5px 6px !important;
  font-size: 12px !important;
  text-align: center !important;
  flex-shrink: 0;
}

.leg-strike-label {
  font-size: 10.5px;
  color: var(--text-faint);
  flex-shrink: 0;
  white-space: nowrap;
}

.leg-qty-hint {
  font-size: 9.5px;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.leg-strike-input {
  width: 68px !important;
  padding: 5px 8px !important;
  font-size: 12.5px !important;
  flex-shrink: 0;
}

.leg-remove-btn {
  background: none;
  border: none;
  font-size: 17px;
  line-height: 1;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.leg-remove-btn:hover { color: #ef4444; }

/* Price range row */
.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.range-input {
  flex: 1;
  min-width: 0;
}

.range-sep {
  font-size: 12px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 13px;
  color: var(--text-faint);
}

/* ─── ROI CALCULATOR ─── */
.summary-grid--2 {
  grid-template-columns: 1fr 1fr;
}

.summary-card--positive .summary-label { color: #16a34a; }
.summary-card--positive .summary-value  { color: #15803d; }
.summary-card--positive {
  background: linear-gradient(135deg, #f0fdf4 0%, #fafffe 100%);
  border-color: #bbf7d0;
}

.summary-card--negative .summary-label { color: #dc2626; }
.summary-card--negative .summary-value  { color: #b91c1c; }
.summary-card--negative {
  background: linear-gradient(135deg, #fff1f2 0%, #fffbfc 100%);
  border-color: #fecdd3;
}

.roi-pair {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
}

.roi-pair-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.roi-pair-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.roi-field { margin: 0 !important; }

.roi-secondary {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
}

.roi-secondary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  font-size: 13.5px;
}

.roi-secondary-item + .roi-secondary-item {
  border-top: 1px solid var(--border-subtle);
}

.roi-secondary-label {
  color: var(--text-secondary);
}

.roi-secondary-value {
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ─── STYLED SELECT (compound frequency etc.) ─── */
.calc-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23aaa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px !important;
  cursor: pointer;
}

.calc-select:focus {
  border-color: var(--accent);
}

/* ─── COMPOUND INTEREST — RANGE ROW ─── */
.ci-range-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 9px;
}

.ci-range-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

.ci-range-values {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}

.ci-range-sep {
  color: var(--text-faint);
  font-weight: 400;
}
