:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --surface: #ffffff;
  --surface-alt: #f3f7f2;
  --ink: #1c2521;
  --muted: #66736d;
  --line: #d9dfd8;
  --accent: #1f7a5b;
  --accent-strong: #12583f;
  --warn: #b45309;
  --bad: #b42318;
  --good: #087443;
  --shadow: 0 18px 50px rgba(39, 49, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

a {
  color: var(--accent-strong);
  font-weight: 700;
}

.tool-link {
  display: inline-block;
  margin-bottom: 18px;
  text-decoration: none;
}

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

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(2.4rem, 6vw, 5.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.lede {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.06rem;
}

.summary-card {
  display: grid;
  gap: 3px;
  min-height: 150px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-label,
.summary-card span:last-child,
.result-grid span,
.planner span,
.bar-row span,
label,
legend {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.summary-card strong {
  align-self: center;
  color: var(--accent-strong);
  font-size: 2.8rem;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.78fr);
  gap: 20px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.inputs,
.results {
  padding: 22px;
}

.panel-header {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.ghost {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.ghost:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.grid {
  display: grid;
  gap: 14px;
}

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

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
}

.money-field,
.percent-field {
  display: flex;
  align-items: center;
  min-height: 46px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.money-field span,
.percent-field span {
  display: grid;
  width: 34px;
  height: 100%;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
}

input[type="number"] {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 0;
  outline: 0;
  padding: 0 10px;
  color: var(--ink);
  background: transparent;
  font-weight: 800;
}

input[type="number"]:focus {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.section-title {
  margin: 22px 0 12px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

.segmented legend {
  width: 100%;
  margin-bottom: 4px;
}

.segmented label {
  display: block;
  color: var(--ink);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-width: 84px;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-weight: 900;
}

.segmented input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

.result-grid article {
  min-height: 110px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.result-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 1.75rem;
  line-height: 1;
}

.bars {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.bar-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 48px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ebe6;
}

.bar-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

#feesBar {
  background: #8f5a27;
}

#costsBar {
  background: #4f6f8f;
}

.bar-row strong {
  font-size: 0.86rem;
  text-align: right;
}

.callout {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid #cbd9ce;
  border-radius: 8px;
  background: #f1f8f4;
  color: var(--accent-strong);
  font-weight: 800;
}

.callout.bad {
  border-color: #efc8c4;
  background: #fff4f3;
  color: var(--bad);
}

.callout.warn {
  border-color: #eed2a7;
  background: #fff8eb;
  color: var(--warn);
}

.detail-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.detail-list div,
.planner div {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.detail-list span:first-child,
.planner span {
  color: var(--muted);
}

.detail-list strong,
.planner strong {
  font-size: 1rem;
}

.planner {
  margin-top: 22px;
  padding: 16px;
  border-radius: 8px;
  background: #f6f1e7;
}

.notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.notes > div {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.notes p {
  margin-bottom: 10px;
  color: var(--muted);
}

.notes p:last-child {
  margin-bottom: 0;
}

@media (max-width: 920px) {
  .intro,
  .workspace,
  .notes {
    grid-template-columns: 1fr;
  }

  .summary-card {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 18px 0;
  }

  .grid.two,
  .grid.three,
  .result-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.6rem;
  }

  .inputs,
  .results,
  .notes > div {
    padding: 16px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .ghost {
    width: 100%;
  }
}
