:root {
  color-scheme: light;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(21, 127, 95, 0.16), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(201, 123, 74, 0.12), transparent 26%),
    linear-gradient(135deg, rgba(239, 244, 239, 0.92), rgba(255, 255, 255, 0.82)),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

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

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: var(--fw-regular);
  letter-spacing: var(--tracking-tight);
}

h1 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(2.15rem, 5vw, 4.65rem);
  line-height: 0.98;
}

h2 {
  font-size: var(--fs-h2);
  line-height: var(--lh-heading);
}

.overline {
  font-size: var(--fs-overline);
  letter-spacing: var(--tracking-overline);
  text-transform: uppercase;
  font-weight: var(--fw-medium);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: var(--fs-overline);
  font-weight: 800;
  letter-spacing: var(--tracking-overline);
}

.lede {
  max-width: 700px;
  margin-bottom: 0;
  color: var(--ink-2);
}

.intro-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  min-height: 170px;
}

.brand-mark {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: var(--radius-md);
  background: var(--brand-deep);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  flex-shrink: 0;
}

.brand-mark span {
  position: absolute;
  bottom: 18px;
  width: 16px;
  border-radius: 4px 4px 0 0;
}

.brand-mark span:nth-child(1) {
  left: 22px;
  height: 32px;
  background: var(--accent);
}

.brand-mark span:nth-child(2) {
  left: 42px;
  height: 52px;
  background: var(--accent-soft);
}

.brand-mark span:nth-child(3) {
  left: 62px;
  height: 68px;
  background: var(--brand-soft);
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
}

.controls {
  position: sticky;
  top: 18px;
  padding: 24px;
}

.control-group {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: var(--space-2);
  color: var(--ink-2);
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-medium);
}

.money-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-2);
  overflow: hidden;
}

.money-input:focus-within {
  border-color: var(--accent);
}

.money-input > .money-prefix {
  padding-left: 14px;
  color: var(--ink-3);
  font-weight: 700;
}

.money-input.percent {
  grid-template-columns: 1fr auto;
}

.money-input.percent > input {
  padding-right: 6px;
}

.money-input.percent > .money-prefix {
  padding-left: 0;
  padding-right: 14px;
}

.money-input > input {
  border: 0;
  border-radius: 0;
  padding: 0 14px 0 6px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: transparent;
}

.money-input > input:focus {
  outline: none;
}

input,
select {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-2);
  color: var(--ink);
  padding: 0 14px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

input:focus,
select:focus {
  border-color: var(--brand);
  background: var(--paper-2);
  box-shadow: 0 0 0 4px rgba(21, 127, 95, 0.12);
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 10px;
  align-items: center;
}

input[type="range"] {
  min-height: 30px;
  padding: 0;
  accent-color: var(--brand);
}

.range-value {
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--paper-3);
  color: var(--brand-deep);
  font-weight: var(--fw-medium);
  font-size: var(--fs-body-sm);
  border: 1px solid var(--line);
}

.assumption {
  margin-top: 18px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--paper-3);
  color: var(--ink-2);
  font-size: var(--fs-body-sm);
  line-height: 1.55;
  border: 1px solid var(--line);
}

.main {
  display: grid;
  gap: 20px;
}

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

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

.metric {
  padding: 18px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  transition: transform 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.metric:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
}

.metric-label {
  color: var(--ink-2);
  font-size: var(--fs-overline);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-overline);
}

.metric-value {
  margin-top: 8px;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  font-weight: var(--fw-medium);
  line-height: 1.1;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: var(--font-display);
}

.metric-note {
  margin-top: 6px;
  color: var(--ink-2);
  font-size: var(--fs-body-sm);
}

.chart-panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper-2);
  box-shadow: var(--shadow-pop);
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--ink-2);
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-medium);
}

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

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--brand);
}

.chart-wrap {
  width: 100%;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(239, 244, 239, 0.92) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

svg {
  display: block;
  width: 100%;
  height: 420px;
}

.axis text {
  fill: var(--ink-2);
  font-size: var(--fs-caption);
  font-family: var(--font-sans);
}

.axis line,
.axis path,
.grid line {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.grid line {
  stroke-dasharray: 4 6;
}

.fund-area {
  fill: color-mix(in srgb, var(--brand) 12%, transparent);
}

.fund-line {
  fill: none;
  stroke: var(--brand);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.depletion-line {
  stroke: var(--danger);
  stroke-width: 2;
  stroke-dasharray: 5 5;
}

.tooltip {
  position: fixed;
  display: none;
  z-index: 5;
  max-width: 260px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-deep);
  color: var(--ink);
  font-size: var(--fs-body-sm);
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.table-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper-2);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.table-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.table-note {
  color: var(--ink-2);
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-medium);
}

.table-wrap {
  overflow: auto;
  max-height: 420px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  font-size: var(--fs-body-sm);
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper-3);
  color: var(--ink);
  font-size: var(--fs-overline);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--brand) 6%, transparent);
}

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

.depleted {
  color: var(--danger);
  font-weight: var(--fw-medium);
}

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

  .controls {
    position: static;
  }

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

  .assumption {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app {
    padding: 18px 0;
  }

  .intro-panel,
  .chart-head,
  .table-head {
    align-items: start;
    flex-direction: column;
  }

  .control-group,
  .metrics {
    grid-template-columns: 1fr;
  }

  .brand-mark {
    width: 72px;
    height: 72px;
  }

  .brand-mark span:nth-child(1) { left: 16px; height: 26px; }
  .brand-mark span:nth-child(2) { left: 32px; height: 42px; }
  .brand-mark span:nth-child(3) { left: 48px; height: 54px; }

  .chart-wrap,
  svg {
    min-height: 340px;
    height: 340px;
  }

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