html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  position: relative;
}

.topbar,
.hero,
.section,
.auth-shell,
.dashboard-shell,
.checkout-shell,
.user-layout,
.admin-layout,
.agent-layout,
.support-grid,
.planner,
.apply-layout,
.intro-strip {
  max-width: 100%;
}

@media (max-width: 720px) {
  body {
    width: 100%;
  }

  .topbar,
  .dashboard-page .topbar {
    max-width: 100vw;
    overflow: hidden;
  }

  .topbar .nav {
    flex-wrap: wrap;
    max-width: 100%;
    overflow-x: hidden;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  .topbar .nav a {
    flex: 0 1 auto;
  }

  body:not(.dashboard-page) .topbar .nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  body:not(.dashboard-page) .topbar .nav a {
    min-width: 0;
    padding: 6px 4px;
    text-align: center;
    white-space: nowrap;
  }

  .hero,
  .section,
  .auth-shell,
  .dashboard-shell,
  .checkout-shell,
  .user-layout,
  .admin-layout,
  .agent-layout,
  .support-grid,
  .planner,
  .apply-layout,
  .intro-strip {
    min-width: 0;
  }
}


/* plan term chips + period schedule (mobile-first polish) */
.term-options {
  align-items: stretch;
}

.term-options .term-segment-preview {
  grid-column: 1 / -1;
  display: grid;
  gap: 4px;
  margin-top: 2px;
  padding: 10px 12px;
  border: 1px solid #d7e2df;
  border-radius: 8px;
  background: #f8fbfa;
  color: #475569;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 600;
}

.term-options .term-segment-preview[hidden] {
  display: none !important;
}

.term-options .term-segment-label {
  color: #0f766e;
  font-weight: 900;
}

.term-options .term-segment-text {
  word-break: break-word;
}

.plan-result {
  min-width: 0;
  overflow: hidden;
}

.plan-result .plan-result-meta {
  display: block;
  line-height: 1.5;
  word-break: break-word;
}

.period-schedule-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  max-height: 240px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}

.period-schedule-row {
  display: grid;
  grid-template-columns: minmax(56px, 0.7fr) minmax(48px, 0.6fr) minmax(0, 1.4fr);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.period-schedule-row span {
  color: #d7e3ea;
  font-weight: 700;
}

.period-schedule-row .period-rate {
  color: #9fd6cf;
}

.period-schedule-row strong {
  color: #fff;
  font-size: 14px !important;
  line-height: 1.2 !important;
  text-align: right;
  word-break: break-word;
}

@media (max-width: 720px) {
  .calculator-panel {
    min-width: 0;
  }

  .down-payment-options,
  .term-options {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  /* 启用档较多时手机 4 列太挤；3 列更稳 */
  .term-options label {
    min-height: 44px;
    padding: 10px 4px;
    font-size: 13px;
  }

  .plan-result {
    padding: 16px;
  }

  .plan-result strong {
    font-size: clamp(28px, 9vw, 40px);
  }

  .period-schedule-list {
    max-height: 220px;
  }

  .period-schedule-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "no amount"
      "rate amount";
    gap: 2px 10px;
  }

  .period-schedule-row span:first-child {
    grid-area: no;
  }

  .period-schedule-row .period-rate {
    grid-area: rate;
    font-size: 12px;
  }

  .period-schedule-row strong {
    grid-area: amount;
    align-self: center;
  }
}

@media (max-width: 380px) {
  .down-payment-options,
  .term-options {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
