:root {
  --page: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #142033;
  --muted: #637083;
  --line: #dce3ec;
  --line-strong: #c9d3df;
  --primary: #1967d2;
  --primary-dark: #114fa5;
  --primary-soft: #eaf2ff;
  --scenario-a: #167c64;
  --scenario-a-soft: #eaf8f4;
  --scenario-b: #b45b18;
  --scenario-b-soft: #fff3e8;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(27, 39, 58, 0.09);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 11px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top left, rgba(25, 103, 210, 0.08), transparent 32rem),
    var(--page);
  color: var(--ink);
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

button,
a,
summary,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button,
summary,
select {
  cursor: pointer;
}

a {
  color: inherit;
}

.shell {
  width: min(1440px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(220, 227, 236, 0.82);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
}

.header-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  font-weight: 850;
}

.github-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: white;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 700;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.github-button:hover {
  transform: translateY(-1px);
  border-color: #9eabb9;
  box-shadow: 0 7px 20px rgba(25, 35, 50, 0.08);
}

.github-button svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.hero {
  padding-top: 52px;
  padding-bottom: 30px;
}

.hero-copy {
  max-width: 790px;
  margin-bottom: 30px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.15rem, 4.8vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.hero-copy > p:last-child {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.18rem);
}

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(430px, 0.84fr) minmax(560px, 1.16fr);
  gap: 22px;
  align-items: start;
}

.input-panel,
.results-panel {
  border: 1px solid rgba(201, 211, 223, 0.9);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input-panel {
  padding: 24px;
}

.results-panel {
  padding: 26px;
  min-width: 0;
}

.form-section {
  margin: 0;
}

.section-heading-row,
.chart-heading,
.table-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.section-heading-row h2,
.result-hero h2,
.chart-heading h3,
.table-heading h3,
.content-section h2,
.formula-section h2 {
  margin: 0;
  line-height: 1.18;
  letter-spacing: -0.03em;
}

.section-heading-row h2 {
  font-size: 1.3rem;
}

.text-button {
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 750;
}

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

.field-grid-global {
  margin-top: 20px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 0.84rem;
  font-weight: 680;
}

.input-shell {
  min-height: 46px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: white;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input-shell:focus-within,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(25, 103, 210, 0.13);
  outline: 0;
}

.input-shell input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 0;
  outline: 0;
  padding: 0 12px;
  color: var(--ink);
  background: transparent;
  font-weight: 690;
}

.input-prefix,
.input-suffix {
  color: var(--muted);
  font-weight: 650;
  font-size: 0.84rem;
  white-space: nowrap;
}

.input-prefix {
  padding-left: 12px;
}

.input-suffix {
  padding-right: 12px;
}

select {
  width: 100%;
  min-height: 46px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink);
  font-weight: 650;
}

.scenario-stack {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.scenario-card {
  min-width: 0;
  margin: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.scenario-card legend {
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 820;
}

.scenario-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--scenario-a);
}

.scenario-b .scenario-dot {
  background: var(--scenario-b);
}

.scenario-a {
  background: linear-gradient(180deg, var(--scenario-a-soft), white 70%);
}

.scenario-b {
  background: linear-gradient(180deg, var(--scenario-b-soft), white 70%);
}

.more-fees {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.more-fees summary {
  color: var(--primary);
  font-size: 0.84rem;
  font-weight: 760;
}

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

.form-error {
  min-height: 24px;
  margin: 12px 0 -4px;
  color: var(--danger);
  font-size: 0.86rem;
  font-weight: 650;
}

.result-hero {
  padding-bottom: 21px;
}

.result-hero h2 {
  max-width: 760px;
  font-size: clamp(1.7rem, 3vw, 2.55rem);
}

.result-detail {
  margin: 10px 0 0;
  color: var(--muted);
}

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

.headline-card {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.highlight-card {
  border-color: #bed3f3;
  background: var(--primary-soft);
}

.headline-card span,
.headline-card small {
  display: block;
  color: var(--muted);
}

.headline-card span {
  font-size: 0.78rem;
  font-weight: 720;
}

.headline-card strong {
  display: block;
  margin: 7px 0 3px;
  font-size: clamp(1.22rem, 2vw, 1.72rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

.headline-card small {
  font-size: 0.75rem;
}

.chart-card,
.table-card {
  margin-top: 16px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: white;
}

.chart-heading h3,
.table-heading h3 {
  font-size: 1.13rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px 14px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 650;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-line {
  width: 18px;
  height: 3px;
  border-radius: 99px;
  background: var(--ink);
}

.scenario-a-line {
  background: var(--scenario-a);
}

.scenario-b-line {
  background: var(--scenario-b);
}

.baseline-line {
  background: #7c8aa0;
}

.chart-wrap {
  position: relative;
  min-height: 300px;
  margin-top: 14px;
}

.chart-wrap canvas {
  width: 100%;
  height: 300px;
  display: block;
}

.table-note {
  max-width: 300px;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
}

.table-scroll {
  overflow-x: auto;
  margin-top: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

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

th:first-child,
td:first-child {
  padding-left: 0;
  text-align: left;
  white-space: normal;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

th {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.metric-help {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.action-button {
  min-height: 43px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: white;
  color: var(--ink);
  font-weight: 760;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.action-button:hover {
  transform: translateY(-1px);
  border-color: #9eabb9;
}

.primary-action {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.primary-action:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.action-status {
  min-height: 22px;
  margin: 8px 0 -6px;
  color: var(--scenario-a);
  font-size: 0.8rem;
  font-weight: 650;
}

.content-section,
.formula-section {
  padding-top: 42px;
  padding-bottom: 42px;
}

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

.content-grid article,
.formula-card {
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: white;
}

.content-section h2,
.formula-section h2 {
  font-size: clamp(1.45rem, 2.5vw, 2rem);
}

.content-section article p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.formula-card {
  display: grid;
  grid-template-columns: 0.72fr 1.28fr;
  gap: 36px;
  align-items: start;
}

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

.method-steps div {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: start;
  padding: 15px;
  border-radius: 14px;
  background: var(--surface-soft);
}

.method-steps span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--ink);
  color: white;
  font-size: 0.78rem;
  font-weight: 800;
}

.method-steps p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.site-footer .shell {
  padding-top: 28px;
  padding-bottom: 30px;
}

:focus-visible {
  outline: 3px solid rgba(25, 103, 210, 0.32);
  outline-offset: 3px;
}

@media (max-width: 1120px) {
  .calculator-layout {
    grid-template-columns: 1fr;
  }

  .results-panel {
    order: 2;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 24px, 1440px);
  }

  .site-header {
    position: static;
  }

  .header-inner {
    min-height: 62px;
  }

  .brand span:last-child {
    font-size: 0.9rem;
  }

  .github-button span {
    display: none;
  }

  .github-button {
    width: 42px;
    padding: 0;
  }

  .hero {
    padding-top: 34px;
  }

  .hero-copy {
    margin-bottom: 22px;
  }

  .input-panel,
  .results-panel {
    padding: 18px;
    border-radius: 19px;
  }

  .field-grid,
  .headline-grid,
  .content-grid,
  .formula-card,
  .method-steps {
    grid-template-columns: 1fr;
  }

  .headline-grid {
    gap: 10px;
  }

  .chart-heading,
  .table-heading {
    display: grid;
  }

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

  .table-note {
    max-width: none;
    text-align: left;
  }

  .chart-wrap,
  .chart-wrap canvas {
    min-height: 245px;
    height: 245px;
  }

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

  .action-button {
    width: 100%;
  }

  .content-section,
  .formula-section {
    padding-top: 24px;
    padding-bottom: 24px;
  }
}

@media (max-width: 420px) {
  .brand span:last-child {
    max-width: 170px;
    line-height: 1.1;
  }

  .section-heading-row {
    align-items: center;
  }

  .scenario-card {
    padding: 14px;
  }

  .chart-card,
  .table-card {
    padding: 15px;
  }
}

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

@media print {
  .site-header,
  .input-panel,
  .result-actions,
  .content-section,
  .formula-section,
  .site-footer {
    display: none !important;
  }

  body {
    background: white;
  }

  .hero {
    padding: 0;
  }

  .hero-copy {
    display: none;
  }

  .calculator-layout {
    display: block;
  }

  .results-panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}
