:root {
  --ink: #172d4c;
  --muted: #687387;
  --paper: #f2f5f7;
  --white: #ffffff;
  --green: #172d4c;
  --green-soft: #e8eef5;
  --mint: #9fe0bb;
  --red: #cc2933;
  --line: #dbe1e8;
  --shadow: 0 28px 80px rgba(23, 45, 76, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 12%, rgba(204, 41, 51, 0.045), transparent 28%),
    linear-gradient(rgba(23, 45, 76, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 45, 76, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 100%, 44px 44px, 44px 44px;
  font-family: "Instrument Sans", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1240px, calc(100% - 48px));
  margin: 0 auto;
}

.topbar {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(23, 45, 76, 0.15);
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  font-family: "Bricolage Grotesque", sans-serif;
  letter-spacing: -0.02em;
}

.brand-logo-frame {
  width: 178px;
  height: 68px;
  display: grid;
  place-items: center;
  padding: 6px 12px;
  background: var(--green);
  border-radius: 12px;
  box-shadow: 0 9px 24px rgba(23, 45, 76, 0.18);
  overflow: hidden;
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button {
  min-height: 42px;
  padding: 0 17px;
  border: 0;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button:active {
  transform: translateY(0) scale(0.98);
}

.button:focus-visible,
input:focus-visible,
.brand:focus-visible {
  outline: 3px solid rgba(204, 41, 51, 0.28);
  outline-offset: 3px;
}

.button-quiet {
  color: var(--ink);
  background: transparent;
}

.button-quiet:hover {
  background: rgba(23, 45, 76, 0.08);
}

.button-dark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--white);
  background: var(--green);
}

.button-dark:hover {
  background: #24415f;
}

.button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  align-items: end;
  gap: 80px;
  padding: 76px 0 48px;
}

.eyebrow,
.step,
.section-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 700;
}

.eyebrow {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: -52px;
  color: var(--green);
}

.eyebrow span {
  width: 27px;
  height: 2px;
  background: var(--green);
}

h1,
h2 {
  margin: 0;
  font-family: "Bricolage Grotesque", sans-serif;
}

h1 {
  max-width: 760px;
  font-size: clamp(50px, 6vw, 88px);
  line-height: 0.92;
  letter-spacing: -0.065em;
  font-weight: 600;
  text-wrap: balance;
}

.brand-accent {
  position: relative;
  color: var(--green);
  white-space: nowrap;
}

.brand-accent::after {
  content: "";
  position: absolute;
  left: 0.04em;
  right: 0;
  bottom: -0.06em;
  height: 0.08em;
  background: var(--red);
  border-radius: 999px;
}

.intro-copy {
  max-width: 360px;
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.calculator {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(400px, 0.9fr);
  background: var(--white);
  border: 1px solid rgba(23, 45, 76, 0.12);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 600ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.input-panel {
  padding: 42px 46px 44px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 38px;
}

.step {
  margin-bottom: 9px;
  color: #7c8782;
}

.step-light {
  color: rgba(255, 255, 255, 0.54);
}

h2 {
  font-size: 28px;
  letter-spacing: -0.04em;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  padding: 7px 10px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.live-pill i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2f865f;
  box-shadow: 0 0 0 4px rgba(47, 134, 95, 0.12);
}

.form-section {
  padding: 0 0 26px;
  margin: 0 0 26px;
  border-bottom: 1px solid var(--line);
}

.form-section-last {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: 0;
}

.section-label {
  margin-bottom: 13px;
  color: #818a87;
  font-size: 10px;
}

.section-label-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.linked-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #7b8581;
  font-size: 10px;
}

.linked-note svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  min-width: 0;
  display: block;
}

.field > span:first-child {
  display: block;
  margin-bottom: 8px;
  color: #535e5a;
  font-size: 12px;
  font-weight: 500;
}

.field > span:first-child em {
  margin-left: 5px;
  padding: 3px 5px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 5px;
  font-size: 8px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field-calculated .input-wrap {
  background: var(--green-soft);
  border-color: rgba(23, 45, 76, 0.12);
}

.field-calculated input {
  color: var(--green);
  cursor: default;
}

.input-wrap {
  min-width: 0;
  height: 54px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: #f4f6f8;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.input-wrap:focus-within {
  background: var(--white);
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 45, 76, 0.09);
}

.field-featured .input-wrap {
  height: 64px;
  border-color: #c7cec9;
  background: var(--white);
}

input {
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.field-featured input {
  font-size: 28px;
}

.input-wrap b {
  flex: 0 0 auto;
  margin-left: 8px;
  color: #7a8580;
  font-size: 11px;
  letter-spacing: 0.06em;
}

input::-webkit-inner-spin-button,
input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.result-panel {
  display: flex;
  flex-direction: column;
  padding: 42px 46px 44px;
  color: var(--white);
  background:
    radial-gradient(circle at 88% 5%, rgba(204, 41, 51, 0.18), transparent 27%),
    radial-gradient(circle at 12% 94%, rgba(159, 224, 187, 0.10), transparent 34%),
    var(--green);
  overflow: hidden;
}

.result-top {
  position: relative;
  padding-bottom: 32px;
}

.result-top::after {
  content: "";
  position: absolute;
  top: -90px;
  right: -80px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}

.result-label {
  margin: 26px 0 3px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

.result-amount {
  margin: 0;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: clamp(48px, 5.5vw, 74px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
}

.result-amount small {
  color: var(--mint);
  font-size: 17px;
  letter-spacing: 0.04em;
}

.result-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 15px 0 0;
  color: var(--mint);
  font-size: 12px;
  font-weight: 600;
}

.result-status span {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  color: var(--green);
  background: var(--mint);
  border-radius: 50%;
  font-size: 11px;
}

.result-status.loss {
  color: #f5a5aa;
}

.result-status.loss span {
  color: var(--green);
  background: #f5a5aa;
}

.breakdown {
  padding: 25px 0 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 0;
}

.breakdown-row > div {
  min-width: 0;
}

.breakdown-row span {
  display: block;
  font-size: 13px;
  font-weight: 500;
}

.breakdown-row small {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.48);
  font-size: 10px;
}

.breakdown-row b {
  flex: 0 0 auto;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.breakdown-row b.positive {
  color: var(--mint);
}

.breakdown-row b.negative {
  color: #f5a5aa;
}

.divider {
  height: 1px;
  margin: 10px 0;
  background: rgba(255, 255, 255, 0.1);
}

.subtotal-row {
  margin: 11px 0;
  padding: 15px 14px;
  background: rgba(255, 255, 255, 0.08);
  border-left: 2px solid var(--mint);
}

.formula-box {
  margin-top: auto;
  padding: 16px 18px;
  color: var(--ink);
  background: var(--mint);
}

.formula-box span {
  display: block;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 9px;
  font-weight: 700;
  opacity: 0.66;
}

.formula-box code {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.calculation-note {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  max-width: 690px;
  margin: 24px 0 0 auto;
  padding: 18px 20px;
  color: #5f6b7c;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 45, 76, 0.11);
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.55;
}

.calculation-note p {
  margin: 0;
}

.note-number {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--green);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 11px;
  font-style: italic;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 32px 0 40px;
  color: #7d8582;
  font-size: 10px;
  letter-spacing: 0.04em;
}

footer p {
  margin: 0;
}

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 24px;
  padding: 11px 17px;
  color: var(--white);
  background: var(--ink);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  font-size: 12px;
  font-weight: 600;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 920px) {
  .page-shell {
    width: min(100% - 32px, 720px);
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-top: 58px;
  }

  .eyebrow {
    margin-bottom: 0;
  }

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

  .result-panel {
    min-height: 660px;
  }
}

@media (max-width: 600px) {
  .page-shell {
    width: min(100% - 20px, 520px);
  }

  .topbar {
    height: 74px;
  }

  .button-quiet {
    display: none;
  }

  .brand-logo-frame {
    width: 146px;
    height: 56px;
    padding: 6px 10px;
  }

  .button {
    min-height: 38px;
    padding: 0 12px;
  }

  .intro {
    padding: 44px 4px 34px;
  }

  h1 {
    font-size: clamp(44px, 15vw, 64px);
  }

  .intro-copy {
    font-size: 14px;
  }

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

  .panel-heading {
    margin-bottom: 32px;
  }

  .live-pill {
    display: none;
  }

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

  .result-panel {
    min-height: 630px;
  }

  .result-amount {
    font-size: clamp(48px, 16vw, 68px);
  }

  .breakdown-row {
    gap: 14px;
  }

  .breakdown-row b {
    font-size: 13px;
  }

  .calculation-note {
    margin-top: 14px;
  }

  footer {
    flex-direction: column;
    gap: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
