:root {
  --bg: #f4ede1;
  --bg-soft: #fbf7f1;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-muted: #f8f3eb;
  --border: rgba(22, 35, 54, 0.1);
  --border-strong: rgba(22, 35, 54, 0.18);
  --text: #172338;
  --muted: #5f6c7d;
  --accent: #0f8b8d;
  --accent-deep: #0d5b61;
  --accent-soft: rgba(15, 139, 141, 0.1);
  --accent-warm: #f58a56;
  --accent-warm-soft: rgba(245, 138, 86, 0.14);
  --accent-gold: #f3c55c;
  --principal: #0f8b8d;
  --interest: #f58a56;
  --fee: #f3c55c;
  --shadow-lg: 0 32px 70px rgba(27, 40, 61, 0.14);
  --shadow-md: 0 16px 34px rgba(27, 40, 61, 0.09);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 139, 141, 0.16), transparent 28%),
    radial-gradient(circle at 100% 10%, rgba(245, 138, 86, 0.16), transparent 24%),
    linear-gradient(180deg, #f7f1e7 0%, #eee4d5 48%, #f5eee4 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
  box-shadow: none;
}

.page-shell {
  position: relative;
  overflow: hidden;
}

.ambient {
  position: absolute;
  border-radius: 999px;
  filter: blur(22px);
  pointer-events: none;
}

.ambient-one {
  top: 5rem;
  left: -5rem;
  width: 18rem;
  height: 18rem;
  background: rgba(15, 139, 141, 0.14);
}

.ambient-two {
  top: 16rem;
  right: -4rem;
  width: 16rem;
  height: 16rem;
  background: rgba(245, 138, 86, 0.16);
}

.ambient-three {
  bottom: 3rem;
  left: 32%;
  width: 20rem;
  height: 20rem;
  background: rgba(243, 197, 92, 0.12);
}

.app {
  width: min(1280px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.4rem 0 2.2rem;
  position: relative;
  z-index: 1;
}

.panel-card {
  position: relative;
  padding: 1.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.82)),
    linear-gradient(135deg, rgba(15, 139, 141, 0.04), rgba(245, 138, 86, 0.05));
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-lg);
}

.eyebrow,
.badge,
.loan-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(15, 139, 141, 0.1);
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-banner {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 1.4rem;
  align-items: stretch;
}

.hero-copy {
  padding: 1.1rem 0.2rem 0.3rem;
}

.hero-copy h1,
.panel-heading h2,
.results-heading h2,
.section-head h2,
.hero-side-card h2,
.loan-type-card h3 {
  margin: 0.9rem 0 0;
  font-family: "Space Grotesk", sans-serif;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.hero-copy h1 {
  font-size: clamp(2.4rem, 4.2vw, 4.9rem);
  max-width: 11ch;
}

.hero-text,
.hero-side-card p,
.section-note,
.loan-description,
.results-note,
.table-hint {
  color: var(--muted);
  line-height: 1.72;
}

.hero-text {
  max-width: 56ch;
  margin: 1rem 0 0;
  font-size: 1.02rem;
}

.hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.hero-pills span {
  padding: 0.8rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 139, 141, 0.12);
  background: rgba(255, 255, 255, 0.7);
  font-weight: 700;
}

.hero-side {
  display: grid;
  gap: 1rem;
}

.hero-side-card,
.hero-mini-card,
.loan-type-card,
.input-card,
.summary-tile,
.breakdown-card,
.impact-card,
.schedule-section,
.table-wrap {
  border: 1px solid rgba(22, 35, 54, 0.08);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.hero-side-card {
  padding: 1.2rem;
  background:
    linear-gradient(145deg, rgba(15, 139, 141, 0.1), rgba(255, 255, 255, 0.95)),
    #fff;
}

.hero-side-card h2 {
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.hero-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.hero-mini-card {
  padding: 1rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.82);
}

.hero-mini-card strong {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.4rem;
}

.hero-mini-card span {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.loan-type-section {
  margin-top: 1.35rem;
}

.section-head,
.results-topbar,
.schedule-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.section-head h2,
.results-heading h2 {
  font-size: clamp(1.7rem, 2.3vw, 2.4rem);
}

.section-note,
.table-hint,
.results-note {
  margin: 0;
  max-width: 42ch;
}

.loan-type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.2rem;
}

.loan-type-card {
  display: grid;
  gap: 1rem;
  padding: 1.2rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(248, 243, 235, 0.95)),
    #fff;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.loan-type-card:hover,
.loan-type-card.active {
  transform: translateY(-3px);
  border-color: rgba(15, 139, 141, 0.26);
  box-shadow: var(--shadow-md);
}

.loan-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.loan-mark {
  display: inline-grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(15, 139, 141, 0.16), rgba(245, 138, 86, 0.14));
  color: var(--accent-deep);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.loan-type-card h3 {
  font-size: 1.55rem;
}

.loan-description {
  margin: 0;
}

.loan-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.loan-meta-grid div {
  padding: 0.85rem;
  border-radius: 16px;
  background: var(--surface-muted);
}

.loan-meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}

.loan-meta-grid strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
}

.preset-btn,
.primary-btn,
.secondary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.35rem;
  border-radius: 999px;
  padding: 0.9rem 1.3rem;
  font-weight: 800;
  border: 1px solid transparent;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.preset-btn {
  width: 100%;
  background: linear-gradient(135deg, rgba(15, 139, 141, 0.12), rgba(245, 138, 86, 0.14));
  color: var(--text);
}

.preset-btn:hover,
.preset-btn.active,
.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.preset-btn.active {
  border-color: rgba(15, 139, 141, 0.25);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
  gap: 1.35rem;
  margin-top: 1.35rem;
  align-items: stretch;
}

.calculator-card,
.results-card,
.schedule-section {
  min-width: 0;
}

.calculator-card,
.results-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.panel-heading h2,
.results-heading h2 {
  margin-top: 0.8rem;
}

.panel-heading h2 {
  font-size: clamp(1.55rem, 2.1vw, 2.2rem);
}

.panel-heading.compact h2 {
  font-size: clamp(1.3rem, 1.9vw, 1.8rem);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
  flex: 1 1 auto;
  align-content: start;
}

.span-2 {
  grid-column: span 2;
}

.input-card {
  padding: 1rem;
}

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.9rem;
  margin-bottom: 0.8rem;
}

.field-row label {
  font-weight: 800;
  font-size: 1rem;
}

.field-note {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.input-shell,
.select-shell {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 3.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0 1rem;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.input-shell:focus-within,
.select-shell:focus-within {
  border-color: rgba(15, 139, 141, 0.4);
  box-shadow: 0 0 0 4px rgba(15, 139, 141, 0.11);
}

.input-shell input,
.select-shell select {
  width: 100%;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}

.prefix,
.suffix {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tenure-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 0.75rem;
}

.month-shell input {
  text-transform: uppercase;
}

input[type="range"] {
  width: 100%;
  margin-top: 0.95rem;
  accent-color: var(--accent);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  box-shadow: 0 18px 28px rgba(13, 91, 97, 0.22);
}

.secondary-btn {
  background: rgba(15, 139, 141, 0.08);
  color: var(--accent-deep);
}

.ghost-btn {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.form-message {
  flex: 1 1 220px;
  margin: 0;
  color: var(--accent-warm);
  font-weight: 700;
}

.results-heading {
  min-width: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1.2rem;
}

.summary-tile {
  padding: 1rem;
}

.accent-tile {
  background: linear-gradient(145deg, rgba(245, 138, 86, 0.12), rgba(255, 255, 255, 0.96));
}

.tile-label,
.legend-row p,
.impact-item span {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.summary-tile h3 {
  margin: 0.65rem 0 0.25rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.2rem, 1.65vw, 1.95rem);
  line-height: 1.06;
}

.tile-footnote {
  color: var(--muted);
  font-size: 0.84rem;
}

.insights-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.breakdown-card,
.impact-card {
  padding: 1.2rem;
  width: 100%;
}

.breakdown-layout {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: center;
  margin-top: 1rem;
}

.ring-chart {
  --principal-angle: 65%;
  display: grid;
  place-items: center;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background:
    conic-gradient(
      var(--principal) 0 var(--principal-angle),
      var(--interest) var(--principal-angle) calc(var(--principal-angle) + var(--interest-angle, 0%)),
      var(--fee) calc(var(--principal-angle) + var(--interest-angle, 0%)) 100%
    );
  box-shadow: inset 0 8px 28px rgba(255, 255, 255, 0.38);
}

.ring-inner {
  width: 136px;
  height: 136px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #f6efe3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(22, 35, 54, 0.06);
}

.ring-inner strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 2rem;
}

.ring-inner span {
  color: var(--muted);
  font-size: 0.84rem;
}

.breakdown-legend,
.impact-list {
  display: grid;
  gap: 0.8rem;
}

.legend-row,
.impact-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.legend-row {
  justify-content: flex-start;
}

.impact-list {
  margin-top: 1rem;
}

.legend-row strong,
.impact-item strong {
  display: block;
  margin-top: 0.15rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.04rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex-shrink: 0;
  margin-top: 0.25rem;
}

.legend-swatch.principal {
  background: var(--principal);
}

.legend-swatch.interest {
  background: var(--interest);
}

.legend-swatch.fee {
  background: var(--fee);
}

.insight-text {
  margin: 1rem 0 0;
  padding: 1rem 1.05rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(15, 139, 141, 0.1), rgba(245, 138, 86, 0.14));
  line-height: 1.72;
}

.schedule-section {
  margin-top: 1.35rem;
}

.site-footer {
  position: relative;
  z-index: 1;
  width: min(1280px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 0 0 2rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.site-footer a {
  color: var(--accent-deep);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 180ms ease, border-color 180ms ease;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--accent);
  border-color: currentColor;
}

.table-wrap {
  margin-top: 1rem;
  overflow: auto;
  max-height: 620px;
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eaf2f1;
}

th,
td {
  padding: 0.98rem 1rem;
  border-bottom: 1px solid rgba(22, 35, 54, 0.08);
  text-align: left;
}

th {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

th:nth-child(n + 3),
td:nth-child(n + 3) {
  text-align: right;
}

tbody tr:nth-child(even) {
  background: rgba(248, 243, 235, 0.7);
}

tbody tr:hover {
  background: rgba(234, 242, 241, 0.8);
}

.empty-state {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .hero-banner,
  .workspace,
  .insights-grid {
    grid-template-columns: 1fr;
  }

  .loan-type-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .breakdown-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

@media (max-width: 860px) {
  .app {
    width: min(100% - 1rem, 1280px);
    padding-top: 0.9rem;
  }

  .site-footer {
    width: min(100% - 1rem, 1280px);
    padding-bottom: 1.5rem;
  }

  .panel-card {
    padding: 1rem;
    border-radius: 24px;
  }

  .section-head,
  .results-topbar,
  .schedule-topbar,
  .field-row,
  .form-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .loan-type-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .loan-meta-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

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

  .field-note {
    text-align: left;
  }

  .tenure-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .hero-copy h1 {
    font-size: clamp(2rem, 10vw, 3rem);
  }

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

  .hero-pills {
    gap: 0.6rem;
  }

  .hero-pills span {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .legend-row,
  .impact-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .ring-chart {
    width: 184px;
    height: 184px;
  }

  .ring-inner {
    width: 116px;
    height: 116px;
  }

  .ghost-btn,
  .primary-btn,
  .secondary-btn,
  .preset-btn {
    width: 100%;
  }

  .table-wrap {
    max-height: 520px;
  }
}
