:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --soft: #eef3f4;
  --ink: #172126;
  --muted: #65747c;
  --line: #d9e1e4;
  --accent: #176f79;
  --accent-dark: #0f5962;
  --rent: #915f12;
  --home: #176f79;
  --cash: #286f3c;
  --shares: #2f5f9d;
  --retirement: #6b529b;
  --equity: #008c8a;
  --obligation: #a43f3f;
  --shadow: 0 12px 34px rgba(36, 48, 54, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 28px clamp(14px, 3vw, 36px) 32px;
  background:
    linear-gradient(180deg, rgba(23, 111, 121, 0.11), transparent 285px),
    var(--bg);
}

.top-band {
  display: grid;
  grid-template-columns: minmax(250px, 0.9fr) minmax(480px, 1.3fr);
  gap: 18px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.3;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5.4vw, 4.5rem);
  line-height: 0.98;
}

.current-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(118px, 1fr));
  gap: 10px;
}

.current-strip span {
  min-height: 82px;
  padding: 12px;
  display: grid;
  align-content: space-between;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  box-shadow: var(--shadow);
}

.current-strip strong {
  display: block;
  color: var(--ink);
  font-size: 1.45rem;
}

.scenario-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  margin: 20px -4px 14px;
  padding: 8px 4px;
  overflow-x: auto;
  background: rgba(245, 247, 248, 0.92);
  backdrop-filter: blur(10px);
}

.tab-button {
  flex: 0 0 auto;
  display: grid;
  align-content: center;
  gap: 3px;
  width: min(74vw, 260px);
  min-height: 78px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: left;
  white-space: normal;
}

.tab-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tab-title {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.1;
}

.tab-desc {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-button.active .tab-title,
.tab-button.active .tab-desc {
  color: #fff;
}

.scenario-shell {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.scenario-hero,
.control-panel,
.visual-panel,
.metric,
.source-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.scenario-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, auto);
  gap: 20px;
  align-items: end;
  padding: clamp(16px, 2.4vw, 24px);
  border-top: 5px solid var(--accent);
  min-width: 0;
  overflow: hidden;
}

.scenario-copy {
  min-width: 0;
}

.scenario-mode {
  display: inline-flex;
  margin: 0 0 10px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.scenario-copy h2 {
  margin: 0;
  max-width: 15ch;
  font-size: clamp(1.7rem, 3.5vw, 3.2rem);
  line-height: 1;
}

.scenario-line {
  margin: 14px 0 0;
  max-width: min(80ch, 100%);
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.16rem);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.hero-number {
  display: grid;
  gap: 6px;
  text-align: right;
}

.hero-number span {
  color: var(--muted);
}

.hero-number strong {
  font-size: clamp(2.2rem, 6vw, 5.2rem);
  line-height: 0.95;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.control-panel {
  position: sticky;
  top: 72px;
  align-self: start;
  max-height: calc(100vh - 86px);
  overflow: auto;
  padding: 16px;
  min-width: 0;
}

.panel-heading,
.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.panel-heading h2,
.section-heading h2 {
  margin: 0;
  font-size: 1.1rem;
}

.panel-heading p,
.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

#reset-button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 800;
}

.control-group {
  margin-top: 17px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.control-group h3 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.range-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  align-items: center;
  margin-bottom: 13px;
}

.range-field span {
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 760;
}

.range-field output {
  color: var(--ink);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.range-field input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
}

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

.summary-grid,
.visual-grid {
  display: grid;
  gap: 12px;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.metric {
  min-height: 96px;
  padding: 13px;
  display: grid;
  align-content: space-between;
  border-top: 4px solid var(--accent);
}

.metric span {
  color: var(--muted);
  font-size: 0.88rem;
}

.metric strong {
  font-size: clamp(1.15rem, 2.2vw, 1.9rem);
  line-height: 1;
}

.visual-panel {
  min-width: 0;
  padding: 16px;
}

.section-heading {
  align-items: baseline;
  margin-bottom: 12px;
}

.section-heading p {
  text-align: right;
}

.year-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(128px, 1fr));
  gap: 10px;
}

.year-card {
  min-height: 138px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.year-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.15rem, 2vw, 1.6rem);
}

.year-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.badge {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 5px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.badge.warn {
  color: var(--obligation);
}

.line-chart {
  width: 100%;
  height: 310px;
  display: block;
  overflow: visible;
  border-radius: 6px;
  background:
    linear-gradient(var(--line), var(--line)) left 25% / 100% 1px no-repeat,
    linear-gradient(var(--line), var(--line)) left 50% / 100% 1px no-repeat,
    linear-gradient(var(--line), var(--line)) left 75% / 100% 1px no-repeat,
    var(--soft);
}

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

.asset-stack,
.cash-bars {
  display: grid;
  gap: 12px;
}

.asset-line,
.cash-line {
  display: grid;
  gap: 6px;
}

.row-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.stack-track,
.cash-track {
  height: 34px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--soft);
}

.stack-track {
  display: flex;
}

.segment {
  height: 100%;
}

.seg-cash {
  background: var(--cash);
}

.seg-sharesies {
  background: var(--shares);
}

.seg-intandem {
  background: var(--retirement);
}

.seg-equity {
  background: var(--equity);
}

.cash-track {
  position: relative;
}

.cash-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--w);
  min-width: 2px;
  background: var(--accent);
}

.cash-fill.negative {
  background: var(--obligation);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: top;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.status-cell {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.lifestyle-panel {
  border-top: 4px solid var(--accent);
}

.lifestyle-blocks {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 10px;
}

.lifestyle-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.life-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.life-top strong {
  font-size: 1.2rem;
  line-height: 1;
  text-align: right;
}

.life-status {
  margin: 10px 0 12px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 780;
  line-height: 1.35;
}

.life-items {
  display: grid;
  gap: 10px;
}

.life-items div {
  min-width: 0;
}

.life-items span {
  display: block;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
}

.life-items p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.source-strip {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
}

.source-strip div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
}

.source-strip strong,
.source-strip span {
  font-size: 0.88rem;
}

.source-strip span {
  color: var(--muted);
}

@media (max-width: 1120px) {
  .top-band,
  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
    max-height: none;
  }

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

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

  .control-group {
    margin: 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .scenario-tabs {
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
    max-width: calc(100vw + 24px);
  }

  .current-strip,
  .scenario-hero,
  .summary-grid,
  .visual-grid,
  .controls {
    grid-template-columns: 1fr;
  }

  .hero-number {
    text-align: left;
  }

  .panel-heading {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
  }

  #reset-button {
    max-width: 92px;
    white-space: normal;
    line-height: 1.05;
  }

  .year-cards {
    grid-template-columns: 1fr;
  }

  .range-field {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .range-field output {
    justify-self: start;
  }

  .section-heading {
    display: grid;
    gap: 4px;
  }

  .section-heading p {
    text-align: left;
  }

  .line-chart {
    height: 240px;
  }

  .lifestyle-blocks {
    grid-template-columns: 1fr;
  }

  .source-strip div {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}
