:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #63717d;
  --line: #dbe3e8;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #e3f4f1;
  --warning: #b45309;
  --warning-soft: #fff5df;
  --navy: #22324a;
  --shadow: 0 18px 45px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 1.1rem;
  letter-spacing: 0;
}

.quick-total {
  min-width: 210px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.quick-total span,
.metric span,
.projection span,
.hero-result span,
.section-heading span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.quick-total strong {
  display: block;
  margin-top: 6px;
  color: var(--accent);
  font-size: 1.55rem;
  line-height: 1.1;
}

.calculator-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.98fr) minmax(0, 1.02fr);
  gap: 22px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.input-panel,
.result-panel {
  padding: 24px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.section-heading span {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
}

.field span,
.field legend {
  color: var(--navy);
  font-size: 0.92rem;
  font-weight: 800;
}

.field small {
  color: var(--muted);
  font-size: 0.82rem;
}

fieldset {
  padding: 0;
  border: 0;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
  color: var(--ink);
  padding: 0 14px;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input:focus,
select:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf2f5;
}

.segment {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.segment.is-active {
  background: var(--panel);
  color: var(--accent-strong);
  box-shadow: 0 7px 18px rgba(23, 33, 43, 0.1);
}

.money-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
  overflow: hidden;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.money-input:focus-within {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.money-input span {
  display: grid;
  width: 46px;
  align-self: stretch;
  place-items: center;
  background: #eef4f6;
  color: var(--muted);
}

.money-input input {
  min-height: 46px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

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

.advanced {
  margin-top: 2px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.advanced summary {
  color: var(--navy);
  cursor: pointer;
  font-weight: 900;
}

.advanced-grid {
  margin-top: 16px;
}

.advanced .field {
  margin-bottom: 0;
}

.hero-result {
  padding: 24px;
  border-radius: 8px;
  background: var(--navy);
  color: #ffffff;
}

.hero-result span,
.hero-result p {
  color: rgba(255, 255, 255, 0.72);
}

.hero-result strong {
  display: block;
  margin: 8px 0;
  font-size: clamp(2.1rem, 5vw, 4rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-result p {
  font-size: 0.95rem;
  font-weight: 700;
}

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

.metric {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  line-height: 1.15;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

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

.projection div {
  padding: 16px;
  border-radius: 8px;
  background: var(--accent-soft);
}

.projection strong {
  display: block;
  margin-top: 8px;
  color: var(--accent-strong);
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.insight {
  margin-top: 14px;
  padding: 16px;
  border-radius: 8px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 24px, 620px);
    padding: 28px 0;
  }

  .title-row,
  .calculator-grid {
    grid-template-columns: 1fr;
  }

  .title-row {
    display: grid;
    align-items: stretch;
  }

  .quick-total {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .input-panel,
  .result-panel {
    padding: 18px;
  }

  .duration-group,
  .advanced-grid,
  .metric-grid,
  .projection {
    grid-template-columns: 1fr;
  }

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