/* module.css */
.fha-container-wrapper {
  width: 100%;
}

/* Core container */
.fha-container {
  max-width: 960px;
  margin: 40px auto;
  padding: 40px 56px;
  border-radius: 28px;
  background: radial-gradient(140% 140% at 0% 0%, #eef6ff 0%, #ffffff 45%, #eef6ff 100%);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.06);
  text-align: left;
  font-family: Gotham, Arial, Sans-serif !important;

  /* template-safe overflow protection */
  overflow: hidden;
}

.fha-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;

  /* template-safe overflow protection */
  min-width: 0;
}

.fha-container h2,
.fha-container h3,
.fha-container h4,
.fha-container p,
.fha-container label {
  font-family: Gotham, Arial, Sans-serif !important;
}

.fha-subhead {
  margin-top: 8px;
  margin-bottom: 18px;
  color: #4f566b;
  line-height: 1.5;
}

/* Form */
.fha-form {
  width: 100%;
  min-width: 0; /* overflow protection */
}

.fha-input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  align-items: start;
  background: #ffffff;
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.05);
  border: 1px solid #eceff6;

  /* overflow protection */
  min-width: 0;
}

/* IMPORTANT: prevent grid children from forcing overflow */
.fha-input-grid > * {
  min-width: 0;
}

.fha-field {
  width: 100%;
  min-width: 0;
}

.fha-label {
  display: block;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
}

.fha-input {
  width: 100%;
  height: 48px;
  border-radius: 25px !important;
  border: 1px solid #dde3ef;
  background: #ffffff;
  font-size: 16px;
  text-align: center;
  outline: none;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04);
  font-family: Gotham, Arial, Sans-serif !important;
  max-width: 100%;
  min-width: 0; /* overflow protection */
}

.fha-input::placeholder {
  color: #a0a7b8;
}

.fha-percent-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.fha-suffix {
  position: absolute;
  right: 16px;
  color: #4f566b;
  font-size: 14px;
  pointer-events: none;
}

.fha-inline-note {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.35;
  color: #4f566b;
  text-align: center;
}

/* Toggle */
.fha-toggle {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

.fha-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.fha-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 10px 14px;
  border-radius: 18px;
  border: 1px solid #dde3ef;
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04);
  min-width: 0;
}

.fha-toggle-pill {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  position: relative;
  background: #dbe7ff;
  flex: 0 0 auto;
}

.fha-toggle-pill::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: transform 160ms ease;
}

#fha_finance_ufmip:checked + .fha-toggle-label .fha-toggle-pill {
  background: #2f7cf6;
}
#fha_finance_ufmip:checked + .fha-toggle-label .fha-toggle-pill::after {
  transform: translateX(20px);
}

.fha-toggle-text {
  font-weight: 600;
  color: #2c3240;
}

/* CTA */
.fha-actions {
  text-align: center;
  margin-top: 12px;
}

.fha-cta {
  text-decoration: none !important;
  font-weight: 600;
}

/* Explanation */
.fha-explain {
  margin-top: 14px;
  border: 1px solid #eceff6;
  border-radius: 16px;
  padding: 10px 12px;
  background: #ffffff;
}
.fha-explain summary {
  cursor: pointer;
  font-weight: 700;
  color: #2c3240;
}
.fha-explain-body {
  margin-top: 10px;
  color: #4f566b;
  font-size: 13px;
  line-height: 1.5;
}
.fha-explain-body ul {
  margin: 0;
  padding-left: 18px;
}

/* Disclaimer */
.fha-disclaimer {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.5;
  color: #4f566b;
}

/* Results */
.fha-results-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.06);
  border: 1px solid #eceff6;

  /* template-safe overflow protection */
  overflow: hidden;
  min-width: 0;
}

.fha-results-top {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;

  min-width: 0;
}
.fha-results-top > * {
  min-width: 0;
}

.fha-big {
  border-radius: 18px;
  padding: 16px;
  background: #f5f9ff;
  border: 1px solid #e4eeff;
  min-width: 0;
}

.fha-big-label {
  font-size: 13px;
  color: #4f566b;
  margin-bottom: 6px;
  font-weight: 600;
}

.fha-big-value {
  font-size: 44px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;

  /* prevent overflow on tiny screens */
  word-break: break-word;
}

.fha-big-sub {
  margin-top: 8px;
  font-size: 13px;
  color: #4f566b;
  line-height: 1.4;
}

.fha-mini {
  border-radius: 18px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #eceff6;
  min-width: 0;
}

.fha-mini-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: #2c3240;
  padding: 6px 0;
  border-bottom: 1px dashed #eef2f7;
  min-width: 0;
}
.fha-mini-row span,
.fha-mini-row strong {
  min-width: 0;
}
.fha-mini-row:last-child {
  border-bottom: 0;
}

.fha-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;

  min-width: 0;
}
.fha-split > * {
  min-width: 0;
}

.fha-breakdown,
.fha-chart-card {
  border-radius: 18px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #eceff6;
  min-width: 0;
}

.fha-breakdown-title {
  margin: 0 0 10px 0;
  font-size: 16px;
}

.fha-breakdown-list {
  font-size: 14px;
  color: #2c3240;
  line-height: 1.5;
  min-width: 0;
}

.fha-break-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f1f4f9;
  min-width: 0;
}
.fha-break-row span,
.fha-break-row strong {
  min-width: 0;
}
.fha-break-row:last-child {
  border-bottom: 0;
}

.fha-chart-wrap {
  width: 100%;
  height: 320px;
  position: relative;
  min-width: 0;
}

.fha-chart-note {
  margin-top: 8px;
  font-size: 12px;
  color: #4f566b;
  line-height: 1.4;
}

/* Template-safe horizontal scrolling utility (for any future tables/rows) */
.fha-scroll-x {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Mobile */
@media (max-width: 767px) {
  .fha-container {
    padding: 28px 20px;
  }

  .fha-input-grid {
    grid-template-columns: 1fr;
  }

  .fha-results-top {
    grid-template-columns: 1fr;
  }

  .fha-big-value {
    font-size: 38px;
  }

  .fha-split {
    grid-template-columns: 1fr;
  }

  .fha-chart-wrap {
    height: 280px;
  }

  /* extra safety */
  .fha-container,
  .fha-results-card,
  .fha-input-grid {
    max-width: 100%;
  }

  /* -------- PROJECT MEMORY MOBILE CENTERING FIX -------- */
  .fha-container {
    display: inline-block;
    margin-left: auto;
    margin-right: auto;
  }

@media (max-width: 767px) {
  .fha-container {
    display: block;
    margin-left: auto;
    margin-right: auto;
  }
}
