:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --ink: #111827;
  --muted: #647084;
  --line: #d9dee8;
  --accent: #2563eb;
  --accent-strong: #1744a7;
  --warn: #a75b00;
  --bad: #b42318;
  --good: #087443;
  --shadow: 0 16px 38px rgba(22, 31, 48, 0.1);
}

* {
  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.45;
}

button,
input {
  font: inherit;
}

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

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

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

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

nav {
  display: flex;
  gap: 14px;
  align-items: center;
}

nav a {
  text-decoration: none;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 16px;
}

.intro > div:first-child,
.summary-card,
.panel,
.notes > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.intro > div:first-child {
  padding: 20px;
}

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

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.3rem, 5vw, 4.2rem);
  line-height: 0.98;
  letter-spacing: 0;
}

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

h3 {
  margin-bottom: 10px;
  font-size: 0.98rem;
}

.lede {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 650;
}

.summary-card {
  display: grid;
  gap: 5px;
  padding: 20px;
  background: linear-gradient(135deg, #ffffff 0%, #edf4ff 100%);
}

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

.summary-card strong {
  align-self: center;
  color: var(--accent-strong);
  font-size: clamp(2.4rem, 5vw, 3.5rem);
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(390px, 0.72fr);
  gap: 16px;
  align-items: start;
}

.workspace > *,
.notes > * {
  min-width: 0;
}

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

.results {
  position: sticky;
  top: 14px;
}

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

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

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

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

.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: 44px;
  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: 42px;
  border: 0;
  outline: 0;
  padding: 0 10px;
  color: var(--ink);
  background: transparent;
  font-weight: 850;
}

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

.section-title {
  margin: 18px 0 10px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 900;
}

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

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

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

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

.segmented span {
  display: grid;
  min-width: 76px;
  min-height: 38px;
  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: 10px;
}

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

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

.bars {
  display: grid;
  gap: 11px;
  margin-top: 18px;
}

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

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

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

#feesBar {
  background: #b45309;
}

#costsBar {
  background: #4f6f8f;
}

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

.callout {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #bed3ff;
  border-radius: 8px;
  background: #eef4ff;
  color: var(--accent-strong);
  font-weight: 850;
}

.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: 16px;
}

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

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

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

.planner {
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  background: #f8fafc;
}

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

.notes > div {
  padding: 18px;
}

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

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

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

  .results {
    position: static;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1240px);
    padding-top: 14px;
  }

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

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

  h1 {
    font-size: 2.7rem;
  }

  .inputs,
  .results,
  .notes > div,
  .intro > div:first-child,
  .summary-card {
    padding: 15px;
  }

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

  .ghost {
    width: 100%;
  }
}
