.compound-tool {
  max-width: 980px;
  margin-inline: auto;
}

.compound-tool > h2 {
  margin-top: 0;
}

.compound-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.1rem 1rem;
}

.compound-tool small {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  line-height: 1.45;
}

.optional-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.money-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.money-input:focus-within {
  border-color: var(--brand-strong);
  outline: 3px solid #facc15;
  outline-offset: 3px;
}

.money-input > span {
  padding-left: 0.85rem;
  color: var(--muted);
  font-weight: 700;
}

.money-input input {
  border: 0;
  background: transparent;
}

.money-input input:focus-visible {
  outline: 0;
}

.combined-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(125px, 0.55fr);
  gap: 0.55rem;
}

.compound-tool input[aria-invalid="true"],
.compound-tool .money-input:has(input[aria-invalid="true"]) {
  border-color: var(--danger);
}

.example-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.35rem 0 1rem;
  padding: 0;
  border: 0;
}

.example-options legend {
  width: 100%;
  margin-bottom: 0.45rem;
  font-weight: 800;
}

.example-button {
  min-height: 40px;
  padding-block: 0.55rem;
  font-size: 0.92rem;
}

.simulation-results {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.results-heading,
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.results-heading h2,
.section-row h3 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-narrative {
  max-width: 820px;
  margin: 1rem 0;
  color: var(--muted);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.result-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
}

.result-card--primary {
  border-color: var(--brand-strong);
  background: rgba(22, 133, 248, 0.1);
}

.result-card dt {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.result-card dd {
  margin: 0.35rem 0 0;
  color: var(--text);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.chart-section,
.table-section {
  margin-top: 1.8rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.chart-legend span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chart-legend i {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 999px;
}

.legend-balance {
  background: var(--success);
}

.legend-invested {
  background: var(--brand);
}

.chart-wrapper {
  margin-top: 0.75rem;
  padding: 0.8rem 0.8rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
}

#evolutionChart {
  display: block;
  width: 100%;
  height: clamp(210px, 34vw, 280px);
}

.chart-axis {
  stroke: var(--border);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart-line--balance {
  stroke: var(--success);
}

.chart-line--invested {
  stroke: var(--brand);
}

.chart-scale {
  display: flex;
  justify-content: space-between;
  padding-inline: 1.35rem 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.table-section h3 {
  margin-bottom: 0.2rem;
}

.table-description {
  margin: 0 0 0.7rem;
  color: var(--muted);
}

.table-wrapper {
  max-height: 430px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.table-wrapper:focus-visible {
  outline: 3px solid #facc15;
  outline-offset: 3px;
}

.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}

.table-wrapper th,
.table-wrapper td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

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

.table-wrapper thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-strong);
}

.table-wrapper tbody tr:last-child > * {
  border-bottom: 0;
}

.projection-note {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid #785d18;
  border-radius: 11px;
  background: rgba(251, 191, 36, 0.08);
}

.projection-note h3,
.projection-note p {
  margin: 0;
}

.projection-note p {
  margin-top: 0.35rem;
  color: var(--muted);
}

.compound-content .formula {
  max-width: 100%;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  overflow-x: auto;
}

.compound-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 820px) {
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .compound-form-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .combined-input {
    grid-template-columns: minmax(0, 1fr) 130px;
  }

  .results-heading,
  .section-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .results-heading button {
    width: 100%;
  }

  .chart-wrapper {
    padding-inline: 0.35rem;
  }

  .chart-scale {
    padding-inline: 0.7rem 0;
  }
}

@media (max-width: 390px) {
  .combined-input {
    grid-template-columns: 1fr;
  }
}
