@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Spline+Sans:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --surface: #fbf8f1;
  --surface-raised: #fffdf8;
  --sidebar: #ede8da;
  --ink: #2b2925;
  --ink-soft: #6b665c;
  --ink-faint: #9a9386;
  --line: #e2dcce;
  --line-strong: #d4cbb8;
  --coral: #d85a30;
  --coral-bg: #faece7;
  --coral-ink: #993c1d;
  --sage: #5dcaa5;
  --sage-bg: #e1f5ee;
  --sage-ink: #0f6e56;
  --brick: #a32d2d;
  --brick-bg: #fcebeb;
  --brick-ink: #791f1f;
  --ochre: #d8a255;
  --moss: #76815f;
  --slate: #596678;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-soft: 0 18px 48px rgba(43, 41, 37, 0.1);
  --shadow-pop: 0 30px 80px rgba(43, 41, 37, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.82), rgba(245, 241, 232, 0) 340px),
    linear-gradient(90deg, rgba(43, 41, 37, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(43, 41, 37, 0.028) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 48px 48px, 48px 48px, auto;
  font-family: "Spline Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
summary {
  font: inherit;
}

button {
  letter-spacing: 0;
}

button:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 3px;
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 0.33fr);
  gap: 26px;
  align-items: end;
  padding: clamp(18px, 4vw, 34px) 0 26px;
  border-bottom: 1px solid var(--line-strong);
}

.kicker {
  margin: 0 0 10px;
  color: var(--coral-ink);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(2.45rem, 7vw, 5.8rem);
  line-height: 0.92;
}

h2 {
  font-size: clamp(1.35rem, 3vw, 2.35rem);
  line-height: 1;
}

.lede {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.7vw, 1.18rem);
  line-height: 1.55;
}

.hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.72);
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 600;
}

.pill.performance {
  color: var(--sage-ink);
  background: var(--sage-bg);
  border-color: rgba(15, 110, 86, 0.18);
}

.hero-stat {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 247, 0.86);
  box-shadow: var(--shadow-soft);
}

.stat-label {
  display: block;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.hero-stat strong {
  display: block;
  margin: 10px 0 6px;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 500;
  line-height: 0.95;
}

.hero-stat span:last-child {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.snapshot {
  margin-top: 18px;
  padding: 4px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.summary-metrics {
  margin-top: 14px;
}

.settings {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(251, 248, 241, 0.9);
  box-shadow: 0 1px 0 rgba(43, 41, 37, 0.04);
}

.settings summary {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 15px 16px;
  cursor: pointer;
  list-style: none;
}

.settings summary::-webkit-details-marker {
  display: none;
}

.settings summary span {
  color: var(--coral-ink);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.settings summary strong {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.period-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 16px;
}

.period-button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.period-button[aria-pressed="true"] {
  color: #fffdf8;
  background: var(--ink);
  border-color: var(--ink);
}

.window-controls {
  display: grid;
  gap: 12px;
  padding: 0 16px 16px;
}

.source-body {
  display: grid;
  gap: 8px;
  padding: 0 16px 16px;
}

.source-row {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 247, 0.72);
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.42;
}

.source-row::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--coral);
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segment-button,
.tab-button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.segment-button[aria-pressed="true"],
.tab-button[aria-selected="true"] {
  color: #fffdf8;
  background: var(--ink);
  border-color: var(--ink);
}

.month-menu {
  width: min(100%, 760px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 247, 0.72);
}

.month-menu[hidden] {
  display: none;
}

.month-menu summary {
  padding: 12px;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.month-menu summary::-webkit-details-marker {
  display: none;
}

.detail-disclosure {
  display: block;
}

.detail-disclosure summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.detail-disclosure summary::-webkit-details-marker {
  display: none;
}

.detail-disclosure summary strong {
  display: block;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.25rem, 2.5vw, 1.9rem);
  font-weight: 500;
  line-height: 1;
}

.detail-disclosure summary em {
  color: var(--ink-soft);
  font-style: normal;
  font-weight: 800;
}

.detail-disclosure .table-wrap {
  margin-top: 14px;
}

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

.month-check {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}

.month-check input {
  accent-color: var(--coral);
}

.tabbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding: 10px 0;
  background: rgba(245, 241, 232, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(43, 41, 37, 0.1);
}

.tab-panel {
  margin-top: 4px;
}

.insight-card,
.chart-section,
.panel {
  min-width: 0;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(251, 248, 241, 0.92);
  box-shadow: 0 1px 0 rgba(43, 41, 37, 0.04);
}

.insight-card {
  display: grid;
  grid-template-columns: 0.32fr 1fr;
  gap: 18px;
  padding: 20px;
}

.insight-list {
  display: grid;
  gap: 8px;
}

.insight {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 247, 0.58);
  color: var(--ink-soft);
  line-height: 1.38;
}

.insight::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--sage);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.metric {
  min-height: 126px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.metric:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-soft);
}

.metric-label {
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 12px;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.45rem, 2.4vw, 2.35rem);
  font-weight: 500;
  line-height: 1;
}

.metric-value.positive {
  color: var(--sage-ink);
}

.metric-value.negative {
  color: var(--brick-ink);
}

.metric-sub {
  margin-top: 9px;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.35;
}

.chart-section,
.panel {
  padding: 18px;
}

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

.section-head > * {
  min-width: 0;
}

.section-head.compact {
  margin-bottom: 12px;
}

.section-head span {
  color: var(--ink-soft);
  font-weight: 700;
  text-align: right;
}

.sankey-stage {
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.92), rgba(251, 248, 241, 0.8)),
    var(--surface);
}

.sankey-wrap {
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: clamp(10px, 2vw, 22px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(237, 232, 218, 0.42)),
    #fffdf8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), var(--shadow-pop);
}

.sankey-wrap svg {
  min-width: 880px;
}

.compact-sankey {
  padding: 10px;
  box-shadow: none;
}

.compact-sankey svg {
  min-width: 620px;
}

.driver-chart-wrap {
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  display: grid;
  align-items: center;
}

.driver-chart-wrap svg {
  min-width: 620px;
}

.driver-label {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.driver-value {
  fill: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}

.driver-value.increase {
  fill: var(--brick-ink);
}

.driver-value.decrease {
  fill: var(--sage-ink);
}

.driver-track {
  fill: rgba(43, 41, 37, 0.08);
}

.driver-bar {
  cursor: pointer;
  filter: drop-shadow(0 8px 10px rgba(43, 41, 37, 0.12));
}

svg {
  display: block;
  width: 100%;
  overflow: hidden;
}

.sankey-link {
  cursor: pointer;
  mix-blend-mode: multiply;
  transition: opacity 150ms ease, filter 150ms ease, stroke-width 150ms ease;
}

.sankey-link:hover {
  opacity: 0.92;
  filter: drop-shadow(0 16px 14px rgba(43, 41, 37, 0.24));
}

.sankey-node rect {
  filter: drop-shadow(0 12px 16px rgba(43, 41, 37, 0.2));
}

.sankey-node text {
  fill: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.sankey-node .node-value {
  fill: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: 18px;
  align-items: stretch;
  min-width: 0;
}

.dashboard-grid > .panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-width: 0;
}

.net-worth-layout {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.net-worth-trend-panel {
  min-height: clamp(560px, 72vh, 760px);
}

.net-worth-trend-panel .trend-wrap {
  flex: 1;
  display: grid;
  align-items: center;
}

.net-worth-trend-panel svg {
  min-width: 960px;
}

.leaderboard {
  display: grid;
  gap: 9px;
}

.leader-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 247, 0.72);
}

.rank {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--coral-bg);
  color: var(--coral-ink);
  font-weight: 800;
}

.leader-label {
  min-width: 0;
  font-weight: 800;
}

.leader-track {
  height: 8px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(43, 41, 37, 0.08);
}

.leader-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--bar, var(--coral));
}

.leader-value {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.25rem;
  font-weight: 500;
  white-space: nowrap;
}

.trend-wrap,
.table-wrap {
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

.compact-table {
  max-height: 450px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.trend-wrap svg {
  min-width: 820px;
}

.trend-axis {
  stroke: rgba(43, 41, 37, 0.16);
}

.trend-line {
  fill: none;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.axis-label {
  fill: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 11px 12px;
  border-top: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td:last-child,
th:last-child {
  text-align: right;
}

.note-list {
  display: grid;
  gap: 9px;
}

.note-row {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 247, 0.72);
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.42;
}

footer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.42;
}

.tooltip {
  position: fixed;
  z-index: 50;
  top: 0;
  left: 0;
  max-width: min(320px, calc(100vw - 24px));
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: rgba(43, 41, 37, 0.96);
  color: #fffdf8;
  box-shadow: var(--shadow-pop);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(14px, 14px);
}

.tooltip.is-visible {
  opacity: 1;
}

@media (max-width: 920px) {
  .hero,
  .insight-card,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

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

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

  footer {
    grid-template-columns: 1fr;
  }
}

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

  .hero {
    padding: 20px 0 22px;
  }

  .settings summary,
  .section-head {
    align-items: start;
    flex-direction: column;
  }

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

  .leader-row {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .month-grid {
    grid-template-columns: 1fr;
  }

  .leader-value {
    grid-column: 2;
    font-size: 1.1rem;
  }
}
