:root {
  --ink: #241c14;
  --muted: #6f6256;
  --paper: #f3ecdf;
  --card: #fffaf3;
  --line: #e4d7c4;
  --green: #0d6b4c;
  --green-soft: #e5f4ec;
  --amber: #8a5a12;
  --amber-soft: #fff1d6;
  --red: #8d2f2f;
  --red-soft: #fde8e4;
  --sidebar: #1c1712;
  --sidebar-text: #f4eadc;
  --shadow: 0 18px 50px rgba(60, 40, 16, 0.08);
  --sans: "Outfit", "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

.topbar, .hero, .auth-wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 0;
}
.brand { font-family: var(--serif); font-size: 28px; text-decoration: none; letter-spacing: -0.03em; }
.brand span { color: var(--green); }
.nav-links { display: flex; gap: 10px; align-items: center; }
.nav-links a { text-decoration: none; }

.btn, button, .btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 10px 16px;
  text-decoration: none;
  cursor: pointer;
  background: var(--green);
  color: white;
}
button.google {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: white;
  color: var(--ink);
  border-color: var(--line);
  margin-bottom: 4px;
}
.auth-or {
  margin: 14px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.btn.secondary, button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn.ghost { background: transparent; color: var(--sidebar-text); border-color: transparent; }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--red); border-color: #efc7c1; }

.hero { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 48px; align-items: center; padding: 28px 0 72px; }
.kicker { letter-spacing: 0.14em; text-transform: uppercase; font-size: 12px; color: var(--green); font-weight: 600; }
h1, h2, h3 { font-family: var(--serif); font-weight: 560; letter-spacing: -0.03em; margin: 0 0 12px; }
h1 { font-size: clamp(42px, 6vw, 72px); line-height: 0.95; }
h2 { font-size: 32px; }
.lede { font-size: 18px; color: var(--muted); max-width: 46ch; }
.hero-actions { display: flex; gap: 12px; margin-top: 22px; }

body.marketing {
  background:
    radial-gradient(900px 420px at 8% -10%, #e5f6ee, transparent 60%),
    radial-gradient(720px 380px at 100% 0%, #fff3d4, transparent 55%),
    #f7f4ee;
}
.btn-lg { padding: 14px 22px; font-size: 17px; }
.fine { color: var(--muted); font-size: 14px; margin-top: 14px; }
.chat-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 32px;
  padding: 22px 18px 26px;
  box-shadow: var(--shadow);
}
.chat-label { margin: 0 0 8px; color: var(--muted); font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
.bubble {
  background: #f6f1e7;
  border-radius: 18px;
  padding: 14px 16px;
  margin: 10px 0;
  white-space: pre-line;
}
.bubble.me { background: #d9f3e6; margin-left: 48px; }
.bubble small { display: block; color: var(--muted); margin-bottom: 6px; }
.landing { width: min(1120px, calc(100% - 32px)); margin: 0 auto 28px; }
.section-lead { color: var(--muted); margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.info-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
}
.info-card p { color: var(--muted); margin: 0; }
.emoji { font-size: 32px; display: block; margin-bottom: 8px; }
.tone-green { background: #f3fbf6; }
.tone-amber { background: #fff8ea; }
.tone-red { background: #fff5f3; }
.cta-band {
  width: min(1120px, calc(100% - 32px));
  margin: 10px auto 64px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 32px;
  padding: 36px 28px;
  text-align: center;
  box-shadow: var(--shadow);
}
.cta-band p { color: var(--muted); }

.auth-wrap { max-width: 460px; padding-bottom: 64px; }
.card, .auth-card, .stat, .panel-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.auth-card, .card { padding: 22px; }
form p { margin: 0 0 14px; }
label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 10px 12px;
}
.helptext, .errorlist { color: var(--red); font-size: 13px; padding-left: 18px; }
.flash { margin: 0 0 14px; padding: 12px 14px; border-radius: 14px; background: var(--green-soft); }
.flash.error { background: var(--red-soft); }
.flash.warning { background: var(--amber-soft); }

.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.side-nav { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.nav-toggle, .nav-open, .nav-close { display: none; }
.sidebar a { text-decoration: none; }
.side-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  color: #eadfD2;
}
.side-link.active, .side-link:hover { background: #2c261f; }
.badge {
  background: #efb15a;
  color: #2a1c08;
  border-radius: 99px;
  padding: 0 7px;
  font-size: 12px;
}
.sidebar .grow { flex: 1; }
.sidebar form { margin: 0; }
.content { padding: 28px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1, .page-head p { overflow-wrap: anywhere; }
.amount { font-family: var(--serif); font-size: clamp(32px, 8vw, 42px); line-height: 1; }
.muted { color: var(--muted); }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(3, 1fr); }
.stat { padding: 16px 18px; }
.stat b { display: block; font-family: var(--serif); font-size: 30px; letter-spacing: -0.03em; }
.split { grid-template-columns: 1.3fr 0.7fr; }
.panel-card { padding: 18px; min-width: 0; max-width: 100%; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.row:last-child { border-bottom: 0; }
.trail { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.crumb { background: #efe4d4; border-radius: 999px; padding: 4px 10px; font-weight: 600; }
.crumb-child { background: var(--green-soft); color: var(--green); }
.crumb-sep { color: var(--muted); font-size: 18px; line-height: 1; }
.spend { padding: 12px 0; border-bottom: 1px solid var(--line); }
.spend:last-of-type { border-bottom: 0; }
.spend-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  list-style: none;
}
.spend summary { cursor: pointer; }
.spend summary::-webkit-details-marker { display: none; }
.spend-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.spend-meta { display: inline-flex; align-items: center; gap: 8px; }
.chev {
  width: 22px;
  height: 22px;
  border-radius: 99px;
  background: #efe4d4;
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
}
.chev::before { content: "›"; }
.spend details[open] .chev::before { transform: rotate(90deg); }
.spend-kids {
  list-style: none;
  margin: 10px 0 2px;
  padding: 2px 0 2px 12px;
  border-left: 2px solid #efe4d4;
}
.spend-kids li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 14px;
}
.spend-kids em { color: var(--muted); font-style: normal; margin-right: 8px; }
.bar { height: 8px; background: #efe4d4; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar span { display: block; height: 100%; background: var(--green); }
.bar.in { background: #d5ebe8; }
.bar.in span { background: #1d6a8a; }
.money.in { color: #1d6a8a; }
.split-title { margin-top: 22px; font-size: 22px; }
.bar.warn span { background: #d0892b; }
.bar.over span { background: var(--red); }

.todo { background: var(--amber-soft); border-color: #efd29f; margin-bottom: 14px; }
.todo h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.todo-lead { margin: 0 0 6px; }
.todo-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  padding: 12px 0;
  border-top: 1px solid #efd29f;
  align-items: center;
}
.todo-what { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.todo-what .muted { font-size: 13px; }
.todo-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.todo-actions form { margin: 0; }
.todo-pick { display: flex; gap: 8px; flex: 1 1 260px; min-width: 0; }
.todo-pick select { flex: 1; min-width: 0; padding: 6px 10px; }
.todo-note { margin: 0 0 14px; padding: 10px 14px; border-radius: 14px; background: var(--amber-soft); }

.chart {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 160px;
  padding-top: 8px;
  border-bottom: 1px solid var(--line);
}
.chart-col { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.chart-col span { display: block; width: 100%; min-height: 2px; background: #9cc9b5; border-radius: 4px 4px 0 0; }
.chart-col.today span { background: var(--green); }
.chart-col.future span { background: transparent; }
.chart-col:hover span { background: var(--green); }
.chart-avg { position: absolute; left: 0; right: 0; border-top: 1px dashed #c08a3e; pointer-events: none; }
.chart-days { display: flex; gap: 3px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.chart-days span { flex: 1; text-align: center; min-width: 0; }
.chart-days .today { color: var(--green); font-weight: 600; }

.pill { border-radius: 99px; padding: 3px 8px; font-size: 12px; background: var(--amber-soft); color: var(--amber); }
.pill.high { background: var(--green-soft); color: var(--green); }
.pill.unknown, .pill.pending { background: var(--red-soft); color: var(--red); }
.pill.confirmed { background: var(--green-soft); color: var(--green); }
.pill.in { background: #e7f0ff; color: #214e8a; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
th, td { padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sheet { margin-top: 14px; overflow-x: auto; }
.pattern { padding: 14px 0; border-bottom: 1px solid var(--line); }
.pattern:last-child { border-bottom: 0; padding-bottom: 0; }
.pattern p { margin: 6px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input { width: min(360px, 100%); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
label.check input { width: auto; }
.filters a { text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; background: white; }
.filters a.on { background: var(--ink); color: white; border-color: var(--ink); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 28px 8px; color: var(--muted); }
.tree { list-style: none; padding: 0; margin: 0; }
.tree ul { list-style: none; padding-left: 18px; }
.tree > li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.tree > li:last-child { border-bottom: 0; }
.cat-line { display: flex; gap: 8px; align-items: center; }
.cat-edit { display: flex; flex: 1; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.cat-edit input, .cat-edit select { width: auto; flex: 1 1 140px; min-width: 0; margin: 0; }
.cat-edit input.emoji { flex: 0 0 64px; width: 64px; text-align: center; }
.cat-line > form:last-child { flex: 0 0 auto; }
.pager { display: flex; gap: 12px; margin-top: 16px; }
code, .code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  background: #f6efe4;
  padding: 2px 6px;
  border-radius: 6px;
  word-break: break-all;
}

a.row { text-decoration: none; border-radius: 12px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
.row > :first-child { min-width: 0; }
.pair { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.pair > :first-child { min-width: 0; overflow-wrap: anywhere; }
.who a, .cat, .pattern b, .row span { overflow-wrap: anywhere; }

@media (prefers-reduced-motion: no-preference) {
  .content { animation: rise 0.35s ease both; }
  .side-link, .filters a, .btn, button, a.row {
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
  }
  a.row:hover { background: #f6efe4; }
  .filters a:hover { transform: translateY(-1px); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 900px) {
  .hero, .split, .shell, .cards { grid-template-columns: minmax(0, 1fr); }
  .shell { width: 100%; max-width: 100%; overflow-x: clip; align-content: start; grid-auto-rows: max-content; }
  .stats { grid-template-columns: 1fr 1fr; }
  .topbar, .hero-actions { flex-wrap: wrap; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 4;
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 0;
    overflow: visible;
    align-self: start;
    height: auto;
  }
  .side-top { padding: 12px 14px; }
  .sidebar .brand { font-size: 22px; }
  .sidebar .grow { display: none; }
  .nav-open {
    display: inline-flex;
    align-items: center;
    border: 1px solid #3a332c;
    background: #2c261f;
    color: var(--sidebar-text);
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
  }
  .side-nav { display: none; padding: 0 10px 12px; }
  .nav-toggle:checked ~ .side-nav { display: flex; }
  .nav-toggle:checked ~ .side-top .nav-word { display: none; }
  .nav-toggle:checked ~ .side-top .nav-close { display: inline; }
  .side-link { width: auto; padding: 10px 12px; }
  .content { padding: 16px 14px 96px; max-width: 100%; }
  .content h1 { font-size: clamp(32px, 9vw, 44px); }
  .bubble.me { margin-left: 16px; }
}

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; }
  .ledger thead { display: none; }
  .ledger, .ledger tbody { display: block; }
  .ledger tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }
  .ledger tr:last-child { border-bottom: 0; }
  .ledger td { display: block; border: 0; padding: 0; }
  .ledger .when { grid-column: 1; grid-row: 1; color: var(--muted); font-size: 13px; }
  .ledger .money { grid-column: 2; grid-row: 1; align-self: center; }
  .ledger .who { grid-column: 1 / -1; grid-row: 2; font-weight: 600; }
  .ledger .cat { grid-column: 1 / -1; grid-row: 3; }
  .ledger .state { grid-column: 1; grid-row: 4; }
  .sheet { overflow-x: visible; }
}
