:root {
  color-scheme: light;
  font: 16px/1.5 "Avenir Next", system-ui, sans-serif;
  color: #172d28;
  background: #f2f5ef;
  --accent: #14634d;
  --line: #d9e2d9;
}
* { box-sizing: border-box; }
body { margin: 0; }
a, .link { color: var(--accent); text-underline-offset: .23em; }
a:hover, .link:hover { color: #0b4635; }
.shell { width: min(1100px, calc(100% - 40px)); margin-inline: auto; }
.top { background: #fff; border-bottom: 1px solid var(--line); }
.bar, .bar nav, .pagehead, .weeks { display: flex; align-items: center; gap: 16px; }
.bar, .pagehead { justify-content: space-between; }
.bar { min-height: 68px; }
.brand { font-weight: 800; color: #172d28; text-decoration: none; white-space: nowrap; }
.brand span { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: #d7efe1; color: #14634d; margin-right: 5px; }
.bar nav { font-size: .88rem; }
main { padding-block: 38px 60px; }
h1, h2, p { margin: 0 0 12px; }
h1 { font-size: clamp(1.9rem, 4vw, 2.85rem); letter-spacing: -.045em; line-height: 1.1; }
h2 { font-size: 1.22rem; letter-spacing: -.025em; }
.muted, .description small, .empty { color: #52675e; }
.pagehead { margin-bottom: 16px; flex-wrap: wrap; }
.weeks { gap: 5px; background: white; border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.weeks a { padding: 6px 10px; text-decoration: none; font-weight: 650; }
.summary { display: grid; grid-template-columns: 1.65fr 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.balance, .stat, .panel { border-radius: 17px; padding: 22px; }
.balance, .stat { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.balance { background: #143c31; color: #f5fff6; }
.balance a, .balance small { color: #c5ead5; }
.stat, .panel { border: 1px solid var(--line); background: white; }
.summary strong { font-size: clamp(1.5rem, 4vw, 2.5rem); line-height: 1.12; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
progress { width: 100%; height: 10px; accent-color: #bcebc8; }
progress::-webkit-progress-bar { background: #376256; border-radius: 10px; }
progress::-webkit-progress-value { background: #bcebc8; border-radius: 10px; }
.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 18px; align-items: start; }
.settings { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-block: 20px; }
.narrow, .category-panel { max-width: 490px; }
.narrow { margin-inline: auto; }
.narrow h1 { margin-block: 12px 22px; }
.stack, label { display: grid; gap: 6px; }
.stack { gap: 15px; }
label { font-weight: 650; font-size: .88rem; min-width: 0; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
input, select, button { font: inherit; border-radius: 8px; min-height: 44px; }
input, select { width: 100%; border: 1px solid #b9cbc0; background: #fbfdfb; color: inherit; padding: 7px 9px; }
button { font-weight: 700; cursor: pointer; border: 1px solid transparent; background: var(--accent); color: white; padding: 7px 13px; }
button:hover { background: #0d4e3c; }
button.secondary { background: #eaf3ec; color: #184e3d; }
button.link { color: var(--accent); background: transparent; padding: 0; text-decoration: underline; }
:focus-visible { outline: 3px solid #277f64; outline-offset: 3px; }
.filter { display: flex; gap: 10px; align-items: end; margin-bottom: 13px; }
.filter label { flex: 1; }
.transactions { list-style: none; padding: 0; margin: 0; }
.transactions li { display: flex; gap: 14px; align-items: center; border-top: 1px solid var(--line); padding: 12px 0; }
.description { display: grid; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.money { font-weight: 750; white-space: nowrap; font-variant-numeric: tabular-nums; }
.money.income { color: var(--accent); }
.empty, .notice { background: #edf4ee; border-radius: 8px; padding: 12px; }
.notice { border: 1px solid #c8decf; }
@media (max-width: 740px) {
  .columns { grid-template-columns: 1fr; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .balance { grid-column: span 2; }
  .balance, .stat, .panel { padding: 17px; }
}
@media (max-width: 390px) {
  .shell { width: calc(100% - 24px); }
  .bar, .bar nav { gap: 9px; }
  .transactions li { gap: 8px; }
}

.projection { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.section-gap { margin-top: 20px; }
.checkbox { display: flex; align-items: center; }
.checkbox input { width: auto; min-height: auto; }
details { margin-bottom: 14px; }
summary { color: var(--accent); cursor: pointer; }
details form { margin-top: 14px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; }
td { white-space: nowrap; }
.decision, .decision form { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 740px) {
  .projection { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .projection .balance { grid-column: auto; }
  .projection > * { overflow-wrap: anywhere; }
}

.deletion-alert {
  margin-bottom: 22px;
  border-color: #b87929;
  border-inline-start-width: 5px;
  background: #fff7e6;
}
.deletion-alert h2 { color: #774407; }
.envelopes-panel { margin-bottom: 22px; }
.envelopes-panel a { display: inline-block; margin-top: 8px; }
.pending-status {
  justify-self: start;
  border-radius: 6px;
  padding: 2px 6px;
  background: #ffe4ab;
  color: #774407;
  font-size: .82rem;
  font-weight: 700;
}

.page-actions { display: flex; gap: 16px; flex-wrap: wrap; margin: -8px 0 22px; }
.projection-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.table-scroll { overflow-x: auto; }
.low-point { background: #fff1d2; }
.low-point td:last-child { font-weight: 750; color: #774407; }
.history-filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.history-filter label { flex: 1 1 130px; }
@media (max-width: 740px) {
  .projection-results .balance { grid-column: auto; }
  .bar, .bar nav { flex-wrap: wrap; }
}

.next-income-form { margin-bottom: 0; }
.next-income-form form { gap: 8px; }
.next-income-form button { overflow-wrap: anywhere; }

.activity-table td:last-child {
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 180px;
}

.monthly-card { margin-bottom: 14px; }
.monthly-card h2 { margin: 0; }
.monthly-total { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.15; font-variant-numeric: tabular-nums; }
.monthly-breakdown { margin: 6px 0; }
.monthly-breakdown div {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 5px 0;
}
.monthly-breakdown dd { margin: 0; font-variant-numeric: tabular-nums; }

.savings-section { margin-bottom: 22px; }
.savings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; }
.savings-card { border-top: 3px solid #63917b; min-width: 0; overflow-wrap: anywhere; }
.savings-card h3 { margin: 0 0 6px; }
.savings-value strong { font-size: clamp(1.35rem, 3vw, 2rem); font-variant-numeric: tabular-nums; }
.savings-card progress { height: 12px; }
.savings-card progress::-webkit-progress-bar { background: #e7efea; }
.savings-card progress::-webkit-progress-value { background: #39866b; }
.savings-card progress::-moz-progress-bar { background: #39866b; }
.savings-milestone { font-weight: 650; color: var(--accent); }
@keyframes savings-progress {
  from { clip-path: inset(0 100% 0 0 round 6px); }
  to { clip-path: inset(0 0 0 0 round 6px); }
}
@keyframes savings-halo {
  45% { box-shadow: 0 0 18px 4px #bcd7ae; }
}
@media (prefers-reduced-motion: no-preference) {
  .savings-updated progress::-webkit-progress-value { animation: savings-progress .45s ease-out both; }
  .savings-updated progress::-moz-progress-bar { animation: savings-progress .45s ease-out both; }
  .savings-celebrate { animation: savings-halo .7s ease-out; }
}

:root {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  background: #f3f5ef;
  --curve: 16px;
  --panel-space: clamp(16px, 2.5vw, 24px);
}
.shell { width: min(1120px, calc(100% - 36px)); }
.panel, .stat, .balance { border-radius: var(--curve); padding: var(--panel-space); }
.panel, .stat { box-shadow: 0 2px 6px #19392a08; }
.pagehead h2, .pagehead h1 { margin-bottom: 0; }
h3 { font-size: 1.08rem; line-height: 1.3; }
.bar { display: flex; justify-content: space-between; gap: 8px; }
.bar .main-nav { display: flex; align-items: center; gap: 4px; }
.main-nav a, .account-menu summary, .account-links button {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 9px;
  border-radius: 8px;
  font-weight: 650;
  text-decoration: none;
}
.main-nav a:hover, .main-nav a[aria-current="page"], .account-menu[open] summary { background: #e6efe7; }
.main-nav a[aria-current="page"] { box-shadow: inset 0 -2px var(--accent); }
.account-menu { position: relative; margin: 0; }
.account-menu summary { list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary::after { content: ""; border: solid currentColor; border-width: 0 1.5px 1.5px 0; padding: 3px; margin: -4px 0 0 8px; transform: rotate(45deg); }
.account-menu[open] summary::after { margin-top: 3px; transform: rotate(225deg); }
.account-links {
  position: absolute;
  z-index: 2;
  inset: calc(100% + 6px) 0 auto auto;
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: 0 6px 20px #17372b1e;
}
.account-links form { margin: 0; }
.account-links button { width: 100%; }
.account-links button:hover { background: #e6efe7; }
.skip-link { position: absolute; inset: 4px auto auto 12px; transform: translateY(-160%); z-index: 1; background: white; padding: 8px 12px; }
.skip-link:focus { transform: none; }
.dashboard-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; }
.weeks a { display: inline-grid; min-width: 40px; min-height: 40px; place-content: center; }
.weeks a:hover { background: #edf4ee; border-radius: 6px; }
.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}
.button:hover { background: #0d4e3c; color: #fff; }
.monthly-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px 26px;
  border-radius: var(--curve);
  padding: clamp(20px, 4vw, 38px);
  color: #f4fcf6;
  background: linear-gradient(132deg, #123d32, #1d5b47);
}
.monthly-unconfigured { grid-template-columns: 1fr; }
.monthly-headline { display: grid; align-content: center; justify-items: start; gap: 10px; min-width: 0; }
.monthly-card h2 { font-size: clamp(1.05rem, 2vw, 1.35rem); }
.monthly-total { font-size: clamp(2.4rem, 7vw, 4.65rem); letter-spacing: -.05em; }
.monthly-card a { color: #dcedde; }
.monthly-card .monthly-breakdown { margin: 0; border-inline-start: 1px solid #ffffff38; padding-inline-start: 22px; }
.monthly-card .monthly-breakdown div + div { border-top: 1px solid #ffffff24; }
.monthly-card dd { font-weight: 700; white-space: nowrap; }
.over-budget { color: #ffe0ad; }
.envelope-grid { display: grid; gap: 14px; margin-bottom: 26px; }
.envelope-grid-paired { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.envelope-grid .envelopes-panel { margin: 0; }
.envelope-grid .pagehead { margin-bottom: 10px; }
.envelope-amount { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
.envelope-amount > strong { font-size: 1.28rem; }
.envelope-meter { margin-top: 8px; }
.envelope-meter::-webkit-progress-bar { background: #e7efea; }
.envelope-meter::-webkit-progress-value { background: var(--accent); }
.envelope-meter::-moz-progress-bar { background: var(--accent); }
.envelope-grid .monthly-breakdown div + div { border-top: 1px solid var(--line); }
.cash-heading { margin-top: 18px; }
.projection .stat, .projection .balance { justify-content: flex-start; }
.projection .stat > span, .projection .balance > span { font-weight: 650; }
.projection strong { font-size: clamp(1.28rem, 3.2vw, 2.1rem); }
.transactions li > a { display: inline-grid; align-content: center; min-height: 44px; }
.transactions.ledger-list li { display: grid; grid-template-columns: minmax(0, 1fr) max-content; align-items: start; gap: 6px 12px; }
.ledger-list .description { min-width: 0; }
.ledger-list .description > strong, .ledger-link, .ledger-list .money { padding-top: 3px; }
.ledger-link { display: flex; align-items: center; min-height: 36px; font-weight: 750; width: fit-content; }
.ledger-list .money { margin-top: 3px; }
.transaction-form:has(select[name="kind"] option:checked:not([value="expense"])) .budget-scope-field { display: none; }
button, .button, .weeks a, summary { touch-action: manipulation; }
[id] { scroll-margin-block-start: 12px; }
@media (max-width: 740px) {
  main { padding-block-start: 20px; }
  .bar { min-height: 56px; padding-block: 3px; flex-wrap: nowrap; }
  .bar .main-nav { flex-wrap: nowrap; }
  .dashboard-heading { gap: 8px; }
  .dashboard-heading .dashboard-controls { justify-content: space-between; width: 100%; gap: 8px; }
  .dashboard-heading .button { padding-inline: 10px; }
  .weeks a { min-width: 44px; min-height: 44px; }
  .weeks { gap: 2px; padding: 0; }
  input, select { font-size: 16px; }
  .projection .stat:has(details[open]) { grid-column: 1 / -1; }
  .ledger-link { min-height: 44px; }
  .ledger-list .money { margin-top: 10px; }
  .monthly-card, .envelope-grid-paired { grid-template-columns: 1fr; }
  .monthly-card .monthly-breakdown { border-inline-start: 0; padding: 10px 0 0; border-top: 1px solid #ffffff38; }
  .transactions li { flex-wrap: wrap; }
  .transactions li .description { min-width: min(100%, 135px); }
}
@media (max-width: 390px) {
  .shell { width: calc(100% - 24px); }
  .main-nav a, .account-menu summary { padding-inline: 5px; }
  .brand span { width: 28px; height: 28px; margin-right: 2px; }
  .dashboard-heading .weeks a { padding-inline: 6px; }
  .dashboard-heading .button { font-size: .88rem; }
  .dashboard-controls { width: 100%; }
  .pair, .savings-grid { grid-template-columns: 1fr; }
}
