:root {
  --gold: #d4af37;
  --gold-light: #f4e4a6;
  --gold-dark: #b8941f;
  --black: #1a1a1a;
  --black-light: #2d2d2d;
  --black-muted: #404040;
  --green: #10b981;
  --green-light: #d1fae5;
  --green-dark: #059669;
  --text-primary: #1a1a1a;
  --text-secondary: #404040;
  --text-muted: #666666;
  --bg-primary: #ffffff;
  --bg-secondary: #f8f8f8;
  --bg-tertiary: #f0f0f0;
  --border: #e0e0e0;
  --border-dark: #cccccc;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.1);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.15), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.15), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #f8f8f8 0%, #e8e8e8 100%);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  text-align: center;
  margin-bottom: 40px;
  padding: 20px 0;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--black);
  margin: 0 0 8px 0;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header .date {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0;
}

.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}

@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr;
    gap: 30px;
  }
}

.calculator-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  background: var(--black);
  color: white;
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: white;
  margin: 0;
}

.card-body {
  padding: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-light);
}

.form-group input:hover,
.form-group select:hover {
  border-color: var(--border-dark);
}

.form-group input:invalid,
.form-group select:invalid {
  border-color: #dc2626;
}

.form-group input:invalid:focus,
.form-group select:invalid:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

.radio-group {
  display: flex;
  gap: 20px;
  margin-top: 8px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.radio-option input[type="radio"] {
  width: auto;
  margin: 0;
}

.radio-option label {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.expandable-link {
  color: var(--gold);
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
}

.expandable-link:hover {
  text-decoration: underline;
}

.expandable-content {
  display: none;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.expandable-content.show {
  display: block;
}

.btn-calculate {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--black);
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 24px;
}

.btn-calculate:hover {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-calculate:active {
  transform: translateY(0);
}

.btn-calculate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.calculation-status {
  text-align: center;
  margin: 16px 0;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  display: none;
}

.calculation-status.show {
  display: block;
}

.calculation-status.success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success);
}

.calculation-status.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.results-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.monthly-payment {
  text-align: center;
  padding: 32px 24px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  border-bottom: 1px solid var(--border);
}

.monthly-payment .amount {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--black);
  margin: 0;
}

.monthly-payment .label {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 8px 0 0 0;
}

.results-details {
  padding: 24px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.result-item:last-child {
  border-bottom: none;
}

.result-item .label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.result-item .value {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1.1rem;
}


.digit-wrapper {
  display: inline-block;
  width: 1ch;
  height: 1em;
  line-height: 1em;
  vertical-align: bottom;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  position: relative;
}

.digit-symbol {
  display: inline-block;
  height: 1em;
  line-height: 1em;
  vertical-align: bottom;
  font-variant-numeric: tabular-nums;
}

.digits {
  display: block;
  will-change: transform;
}

.digit {
  display: block;
  height: 1em;
  line-height: 1em;
}

.chart-section {
  padding: 20px 40px; /* extra horizontal space so external tooltips fit */
  border-top: 1px solid var(--border);
}

.chart-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 20px 0;
  text-align: center;
}

.pie-chart {
  width: 100%;
  max-width: 260px; /* prevent chart from dominating the card */
  min-width: 200px; /* avoid the chart collapsing on small screens */
  margin: 0 auto 20px;
  position: relative;
  aspect-ratio: 1 / 1;
}

.pie-chart canvas {
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  /* Keep canvas square; section padding + max-width leave room so external tooltips aren't clipped */
}

.pie-chart canvas.bounce {
  animation: chart-bounce 1s ease;
}

@keyframes chart-bounce {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.lead-section {
  background: var(--black);
  color: white;
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: 24px;
  text-align: center;
}

.lead-section h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: white;
  margin: 0 0 16px 0;
}

.lead-section p {
  color: #e0e0e0;
  margin: 0 0 20px 0;
  font-size: 1rem;
}

.lead-section .disclaimer {
  color: var(--text-secondary);
  margin-top: 12px;
  font-size: 0.875rem;
}

.lead-features {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.feature {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e0e0e0;
  font-size: 0.9rem;
}

.feature::before {
  content: '✓';
  color: var(--success);
  font-weight: bold;
}

.btn-lead {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--black);
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-lead:hover {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.amortization-link {
  color: var(--gold);
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.amortization-link:hover {
  text-decoration: underline;
}

.footer {
  text-align: center;
  margin-top: 40px;
  padding: 20px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Lead Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-header {
  background: var(--black);
  color: white;
  padding: 24px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  position: relative;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-body {
  padding: 32px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.2s ease;
  resize: vertical;
  min-height: 80px;
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-light);
}

.btn-submit {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 24px;
}

.btn-submit:hover {
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.success-message {
  text-align: center;
  padding: 32px;
  color: var(--success);
}

.success-message h4 {
  margin: 0 0 16px 0;
  font-size: 1.5rem;
  color: var(--success);
}

.success-message p {
  margin: 0;
  color: var(--text-secondary);
}

.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 640px) {
  .container {
    padding: 16px;
  }
  
  .header h1 {
    font-size: 2rem;
  }
  
  .main-content {
    gap: 20px;
  }
  
  .monthly-payment .amount {
    font-size: 2rem;
  }
  
  .lead-features {
    flex-direction: column;
    align-items: center;
  }
}
