:root {
  --ink: #15211b;
  --muted: #68736d;
  --paper: #f4f1e8;
  --card: #fcfaf4;
  --line: #d9d7ce;
  --green: #264f3c;
  --green-soft: #7ea18e;
  --coral: #e4775c;
  --white: #fff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 3%, rgba(126, 161, 142, .18), transparent 25rem),
    var(--paper);
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 72px 0 52px;
}

.hero { max-width: 790px; margin-bottom: 44px; }
.eyebrow, .step {
  margin: 0 0 12px;
  color: var(--coral);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .16em;
}

h1, h2 { margin: 0; letter-spacing: -.04em; }
h1 { font-family: Georgia, serif; font-size: clamp(2.75rem, 7vw, 5.6rem); font-weight: 500; line-height: .98; }
h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
.intro { max-width: 650px; margin: 22px 0 0; color: var(--muted); font-size: 1.16rem; line-height: 1.65; }

.card {
  border: 1px solid rgba(21, 33, 27, .1);
  border-radius: 22px;
  background: rgba(252, 250, 244, .84);
  box-shadow: 0 18px 50px rgba(35, 47, 40, .07);
}

.controls { padding: 30px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.section-heading > p { margin: 0; color: var(--muted); font-size: .9rem; }
.step { margin-bottom: 6px; }

.control-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
label span { display: block; margin: 0 0 9px; font-size: .84rem; font-weight: 750; }
label small { display: block; margin-top: 2px; color: var(--muted); font-size: .7rem; font-weight: 500; }
select {
  width: 100%;
  min-height: 48px;
  padding: 0 38px 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--white);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
select:focus { outline: 3px solid rgba(38, 79, 60, .16); border-color: var(--green); }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin: 15px 0; }
.stat { min-height: 164px; padding: 26px; border: 1px solid rgba(21, 33, 27, .1); border-radius: 18px; background: #e9e5d9; }
.stat-dark { color: var(--white); background: var(--green); }
.stat p { margin: 0 0 18px; color: var(--muted); font-size: .78rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.stat-dark p, .stat-dark span { color: rgba(255, 255, 255, .65); }
.stat strong { display: block; margin-bottom: 7px; font-family: Georgia, serif; font-size: clamp(1.7rem, 3.5vw, 2.5rem); font-weight: 500; letter-spacing: -.04em; }
.stat span { color: var(--muted); font-size: .82rem; }

.chart-card { padding: 30px 30px 22px; }
.chart-heading { align-items: center; }
.legend { display: flex; gap: 20px; color: var(--muted); font-size: .82rem; font-weight: 650; }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; }
.income-dot { background: var(--green); }
.cost-dot { background: var(--coral); }
.chart-wrap { width: 100%; overflow-x: auto; }
#chart { display: block; min-width: 820px; width: 100%; height: auto; }
.chart-hint { margin: 12px 0 0; color: var(--muted); font-size: .76rem; text-align: center; }
.grid-line { stroke: #dfddd5; stroke-width: 1; }
.axis-label { fill: #7b827e; font-size: 11px; }
.rate-label { fill: #39433e; font-size: 12px; font-weight: 650; }
.income-bar { fill: var(--green); }
.cost-bar { fill: var(--coral); }
.chart-bar { transition: opacity .18s ease; }
.chart-bar:hover { opacity: .75; }

.assumptions { display: grid; grid-template-columns: 150px 1fr; gap: 22px; margin: 26px 5px 0; padding-top: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; line-height: 1.6; }
.assumptions strong { color: var(--ink); }
.assumptions p { margin: 0; }
.error { position: fixed; right: 20px; bottom: 20px; max-width: 520px; padding: 16px 20px; border-radius: 12px; color: white; background: #9d382c; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .control-grid { grid-template-columns: repeat(2, 1fr); }
  .summary { grid-template-columns: 1fr; }
  .stat { min-height: 0; }
}

@media (max-width: 600px) {
  .page-shell { width: min(100% - 24px, 1180px); padding-top: 42px; }
  .hero { margin-bottom: 30px; }
  .controls, .chart-card { padding: 21px 18px; border-radius: 16px; }
  .control-grid { grid-template-columns: 1fr; }
  .section-heading, .chart-heading { align-items: flex-start; flex-direction: column; }
  .section-heading > p { display: none; }
  .legend { flex-wrap: wrap; }
  .assumptions { grid-template-columns: 1fr; gap: 7px; }
}
