:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #eef4f7;
  --text: #18211f;
  --muted: #66736f;
  --line: #d8e0dc;
  --accent: #0f7b6c;
  --accent-2: #1f5fa8;
  --warning: #b85c22;
  --shadow: 0 18px 45px rgba(32, 47, 43, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(15, 123, 108, 0.12), transparent 340px),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 26px 0 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(34px, 6vw, 58px);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

h3 {
  margin-bottom: 14px;
  font-size: 16px;
}

.lead {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(145px, 1fr));
  gap: 12px;
}

.hero-metrics div,
.panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-metrics div {
  padding: 16px;
}

.hero-metrics span,
.metric span,
.compare-row span,
label span,
.field-label,
.panel-title span {
  color: var(--muted);
  font-size: 13px;
}

.hero-metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 20px;
}

.panel-title {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label,
.field {
  display: grid;
  gap: 8px;
}

label small {
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fbfdfc;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 108, 0.14);
}

.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
}

.input-with-unit input {
  border-radius: 8px 0 0 8px;
}

.input-with-unit b {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: var(--surface-2);
  color: var(--muted);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segmented button.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(20, 36, 32, 0.1);
}

.controls {
  display: grid;
  gap: 18px;
}

.loan-block,
.early-box {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.custom-term-row {
  margin-top: 12px;
}

.hint {
  margin-bottom: 0;
  border-left: 3px solid var(--accent-2);
  padding: 9px 12px;
  background: #edf5fb;
  color: #31536e;
  font-size: 13px;
}

.toggle {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  margin-bottom: 12px;
}

.toggle input {
  width: 18px;
  min-height: 18px;
}

.toggle span {
  color: var(--text);
  font-weight: 700;
}

.muted {
  opacity: 0.55;
}

.results {
  display: grid;
  gap: 18px;
  position: sticky;
  top: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 22px;
}

.compare-panel h2 {
  margin-bottom: 16px;
}

.compare-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding: 13px 0;
}

.compare-row.highlight strong {
  color: var(--warning);
}

.schedule-panel {
  margin-top: 18px;
}

.schedule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  justify-content: flex-end;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f7faf8;
}

.load-size {
  width: 160px;
}

.schedule-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 13px;
  background: var(--surface);
  color: #46534f;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    color 0.15s ease;
}

.schedule-actions button.primary-action {
  border-color: rgba(15, 123, 108, 0.28);
  background: rgba(15, 123, 108, 0.08);
  color: var(--accent);
  font-weight: 800;
}

.schedule-actions button:hover:not(:disabled) {
  border-color: rgba(15, 123, 108, 0.36);
  background: #eef6f3;
  color: var(--accent);
}

.schedule-actions button.primary-action:hover:not(:disabled) {
  border-color: rgba(15, 123, 108, 0.42);
  background: rgba(15, 123, 108, 0.13);
}

.schedule-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: #eef4f7;
  color: var(--muted);
  font-size: 13px;
}

tr.early td {
  background: #fff5ec;
}

tbody tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 16px;
  }

  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero-metrics,
  .summary-grid,
  .field-grid,
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .results {
    position: static;
  }

  .segmented {
    grid-template-columns: 1fr;
  }

  .schedule-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .load-size {
    width: 100%;
  }
}
