@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/ibm-plex-serif-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Serif";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/ibm-plex-serif-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Serif";
  font-style: italic;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/ibm-plex-serif-latin-600-italic.woff2") format("woff2");
}

:root {
  --paper: #f4f1ea;
  --paper-ink: #ece7dc;
  --card: #fbfaf6;
  --ink: #1c1915;
  --muted: #5e584f;
  --faint: #8a8378;
  --line: #d4cec2;
  --line-strong: #b9b1a3;
  --income: #1f4e45;
  --income-soft: #d9e6e1;
  --income-mid: #3d7a6d;
  --capital: #1b2a4a;
  --capital-soft: #d5dbe8;
  --capital-mid: #3c5278;
  --jane: #8a4b2f;
  --jane-soft: #f0e2d8;
  --down: #8f3d32;
  --up: #2c5c3c;
  --warn: #7a3b2e;
  --shadow: 0 1px 2px rgba(28, 25, 21, 0.06);
  --radius: 12px;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}
body.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
}
h1 { font-size: 1.85rem; line-height: 1.2; }
h2 { font-size: 1.25rem; margin-bottom: 0.4rem; }
p { margin: 0; }
button, input, select { font: inherit; }
a { color: var(--income); }

#app, .login-card { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
#app { padding: 28px 0 72px; }

.kicker {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 500;
  margin-bottom: 0.35rem;
}
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 0.9rem; }
.error { color: var(--warn); font-size: 0.95rem; margin: 0.4rem 0 0; }

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 32px 32px;
  box-shadow: var(--shadow);
  max-width: 420px;
  width: min(420px, calc(100% - 32px));
}
.login-card h1 { margin-bottom: 0.4rem; }
.login-card form { margin-top: 1.5rem; display: grid; gap: 0.5rem; }
.login-card label { font-size: 0.85rem; font-weight: 500; }
.login-card input[type="password"] {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.login-card input:focus, .btn:focus-visible, input[type="range"]:focus-visible, .month-tick:focus-visible {
  outline: 2px solid var(--income);
  outline-offset: 2px;
}
.login-card button[type="submit"] {
  margin-top: 0.6rem;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-weight: 500;
  cursor: pointer;
}
.login-card button[type="submit"]:hover { background: #2a2622; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.meta { font-size: 0.8rem; color: var(--faint); }
.btn {
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn:hover { background: var(--paper-ink); }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.inline { display: inline; margin: 0; }
.status { color: var(--muted); margin: 8px 0 20px; min-height: 1.4em; }
.status.error { color: var(--warn); }

.primer {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 0.98rem;
}
.primer strong { color: var(--ink); font-weight: 500; }

.totals {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
}
.stat .label { font-size: 0.75rem; color: var(--faint); letter-spacing: 0.02em; }
.stat .value {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
  margin-top: 4px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat .hint { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.stat.income { border-top: 3px solid var(--income); }
.stat.capital { border-top: 3px solid var(--capital); }
.stat.jane { border-top: 3px solid var(--jane); }

.scrubber {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  padding: 10px 0 12px;
  margin: 0 -4px 8px;
}
.scrubber-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.month-name {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 500;
}
input[type="range"] {
  width: 100%;
  margin: 8px 0 0;
  accent-color: var(--ink);
}
.ticks {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  margin-top: 2px;
}
.month-tick {
  background: none;
  border: 0;
  color: var(--faint);
  padding: 4px 0;
  cursor: pointer;
  font-size: 0.78rem;
  text-align: center;
}
.month-tick[aria-current="true"] {
  color: var(--ink);
  font-weight: 600;
}

.caption {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  margin: 8px 0 22px;
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.55;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 12px;
  box-shadow: var(--shadow);
}
.card header { margin-bottom: 8px; }
.card .lede { color: var(--muted); font-size: 0.88rem; margin-bottom: 10px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--sans); fill: var(--faint); font-size: 10px; }
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 8px;
}
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
}
.panel { margin-bottom: 16px; }
.flow { min-height: 280px; }
.flow svg { width: 100%; height: auto; display: block; }
.flow text { font-family: var(--sans); }
.flow .node-label { font-size: 11px; fill: var(--ink); }
.flow .node-val { font-size: 10px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.flow path.link { opacity: 0.72; transition: d 400ms ease, opacity 200ms; }

.jane-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.jane-grid .item {
  background: var(--paper);
  border-radius: 8px;
  padding: 10px 12px;
}
.jane-grid .item .label { font-size: 0.75rem; color: var(--faint); }
.jane-grid .item .value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  margin-top: 2px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.cal-month {
  background: var(--paper);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 10px 8px;
  min-height: 8rem;
  cursor: pointer;
  text-align: left;
  color: inherit;
  width: 100%;
}
.cal-month[aria-current="true"] {
  background: #fff;
  border-color: var(--ink);
}
.cal-month .name { font-weight: 600; font-size: 0.78rem; margin-bottom: 6px; }
.bill {
  font-size: 0.75rem;
  line-height: 1.3;
  margin-bottom: 5px;
  color: var(--ink);
}
.bill .amt { font-variant-numeric: tabular-nums; display: block; color: var(--muted); }
.bill.income { border-left: 2px solid var(--income); padding-left: 5px; }
.bill.capital { border-left: 2px solid var(--capital); padding-left: 5px; }
.cal-empty { color: var(--faint); font-size: 0.7rem; }

.footnote {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.85rem;
}
.footnote p { margin-bottom: 0.6rem; }
details.assumptions {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
details.assumptions summary { cursor: pointer; font-weight: 500; }
table.assumptions-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 0.82rem;
}
table.assumptions-table th, table.assumptions-table td {
  text-align: left;
  vertical-align: top;
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--line);
}
table.assumptions-table th { color: var(--faint); font-weight: 500; }
.num { font-variant-numeric: tabular-nums; }


.chart-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 10px 0 2px;
}
.chart.axis-x { height: 24px; }
.statement {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.statement .col {
  background: var(--paper);
  border-radius: 10px;
  padding: 14px 14px 12px;
  border-top: 3px solid var(--line);
}
.statement .income-col { border-top-color: var(--income); }
.statement .jane-col { border-top-color: var(--jane); }
.statement .capital-col { border-top-color: var(--capital); }
.statement h3 {
  font-size: 1.05rem;
  margin-bottom: 10px;
}
.statement ul { list-style: none; margin: 0; padding: 0; }
.statement li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.statement li:last-of-type { border-bottom: 0; }
.statement .rval { font-weight: 500; white-space: nowrap; }
.statement li.in .rval { color: var(--up); }
.statement li.out .rval { color: var(--down); }
.statement li.total {
  margin-top: 6px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 0;
  font-weight: 600;
  padding-top: 8px;
}
.statement li.subtotal { font-weight: 500; }
.statement li.balance { color: var(--muted); }
.statement .settle {
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 900px) {
  .totals { grid-template-columns: repeat(2, 1fr); }
  .totals .stat:last-child { grid-column: span 2; }
  .grid-2 { grid-template-columns: 1fr; }
  .jane-grid { grid-template-columns: repeat(2, 1fr); }
  .calendar { grid-template-columns: repeat(2, 1fr); }
  .statement { grid-template-columns: 1fr; }
  h1 { font-size: 1.55rem; }
  .top { flex-direction: column; }
  .top-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
  #app { width: min(100% - 24px, 1120px); padding-top: 18px; }
  .calendar { grid-template-columns: repeat(2, 1fr); }
  .stat .value { font-size: 1.2rem; }
}
