:root {
  color-scheme: light;
  --ink: #1b3028;
  --muted: #52665d;
  --line: #dce4dc;
  --paper: #fff;
  --canvas: #f3f5ef;
  --forest: #123b32;
  --green: #21654f;
  --lime: #d0ea9a;
  --error: #9d3030;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; color: var(--ink); background: var(--canvas); }
a { color: var(--green); text-underline-offset: .24em; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .64; }
:focus-visible { outline: 3px solid #568825; outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2.15rem, 4vw, 3.5rem); font-weight: 760; letter-spacing: -.06em; line-height: 1.08; }
h2 { font-size: 1.14rem; letter-spacing: -.025em; }
small { font-size: .875rem; }
.skip { position: fixed; z-index: 3; top: .6rem; left: .6rem; transform: translateY(-160%); padding: .8rem; color: var(--forest); background: var(--paper); }
.skip:focus { transform: none; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 15rem; padding: 2rem 1.25rem;
  display: flex; flex-direction: column; gap: 2.75rem; background: var(--forest); color: white;
}
.brand { display: inline-flex; align-items: center; gap: .65rem; color: inherit; font-weight: 780; font-size: 1.65rem; line-height: 1.08; letter-spacing: -.055em; text-decoration: none; }
.sidebar .brand { align-self: flex-start; padding-left: .65rem; font-size: 1.25rem; }
.brand img { flex: 0 0 auto; border-radius: .55rem; }
.sidebar nav { display: grid; gap: .35rem; }
.sidebar nav a { padding: .78rem .85rem; border-radius: .65rem; font-size: .94rem; color: #e0eae3; text-decoration: none; }
.sidebar nav a:hover, .sidebar nav a[aria-current] { color: #fff; background: #285247; }
.sidebar nav a[aria-current] { box-shadow: inset 3px 0 var(--lime); font-weight: 650; }
.sidebar :focus-visible { outline-color: var(--lime); }
.logout { margin-top: auto; }
.button-ghost { color: #e0eae3; background: transparent; border-color: #719188; }

.workspace { max-width: 103rem; margin-left: 15rem; padding: clamp(1.4rem, 4vw, 4rem); }
.page-header { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 2rem; }
.page-header p { margin-top: .65rem; color: var(--muted); line-height: 1.5; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.button {
  min-height: 2.8rem; padding: .65rem .95rem; border: 1px solid transparent; border-radius: .65rem;
  display: inline-flex; align-items: center; justify-content: center; font-size: .9rem;
  font-weight: 670; line-height: 1.25; text-decoration: none; white-space: nowrap;
}
.primary { color: white; background: var(--forest); }
.primary:hover { background: var(--green); }
.secondary { color: var(--ink); background: var(--paper); border-color: var(--line); }
.secondary:hover { border-color: var(--green); }
.month-switch {
  display: flex; align-items: center; justify-content: space-between; gap: .28rem;
  min-height: 2.8rem; border: 1px solid var(--line); border-radius: .65rem;
  background: var(--paper); white-space: nowrap; font-size: .885rem; font-weight: 630;
}
.month-switch a { display: grid; place-items: center; width: 2.55rem; min-height: 2.65rem; border-radius: .55rem; font-size: 1.55rem; text-decoration: none; }
.month-switch a:hover { background: #ecf2e7; }
.summary { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); gap: .85rem; margin-bottom: 1.15rem; }
.metric, .panel { background: var(--paper); border: 1px solid var(--line); border-radius: .95rem; }
.metric { display: grid; gap: .65rem; padding: 1.2rem; min-width: 0; }
.metric > span { font-size: .9rem; font-weight: 670; }
.metric > strong { font-variant-numeric: tabular-nums; font-weight: 760; font-size: clamp(1.3rem, 2.1vw, 2.1rem); line-height: 1.12; letter-spacing: -.055em; overflow-wrap: anywhere; }
.metric small { font-size: .82rem; color: var(--muted); align-self: end; }
.metric.net { background: var(--forest); border-color: var(--forest); color: #fff; }
.metric.net strong { color: var(--lime); }
.metric.net small { color: #d3e5da; }
.positive { color: var(--green); }
.dashboard-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 1.15rem; }
.goal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); gap: 1.15rem; }
.panel { padding: clamp(1rem, 2.25vw, 1.5rem); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .7rem; margin-bottom: 1.05rem; }
.panel-head > a { font-size: .9rem; font-weight: 650; }
.recent { margin-top: 1.15rem; }
.empty { padding: .85rem 0; color: var(--muted); line-height: 1.6; }
.empty p { margin-bottom: .35rem; }
.account-note { margin-top: .85rem; color: var(--muted); line-height: 1.6; font-size: .875rem; }
.muted, .bar-list small, .record-list small { color: var(--muted); }
.muted { line-height: 1.5; }
.record-list, .bar-list { list-style: none; padding: 0; margin: 0; }
.record-list li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .84rem 0; border-top: 1px solid var(--line); }
.record-list li > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.record-list strong { font-variant-numeric: tabular-nums; }
.record-list li:last-child { padding-bottom: .25rem; }
.record-list small { display: block; margin-top: .3rem; line-height: 1.35; }
.record-name { color: var(--ink); font-weight: 680; }
.record-amount { text-align: right; flex-shrink: 0; max-width: 45%; overflow-wrap: anywhere; }
.bar-list li + li { margin-top: 1.05rem; }
.bar-list li > div { display: flex; justify-content: space-between; gap: .65rem; align-items: center; margin-bottom: .35rem; }
progress { width: 100%; display: block; appearance: none; height: .52rem; border: 0; border-radius: 1rem; overflow: hidden; background: #e4ece3; }
progress::-webkit-progress-bar { background: #e4ece3; }
progress::-webkit-progress-value { background: var(--green); border-radius: 1rem; }
progress::-moz-progress-bar { background: var(--green); border-radius: 1rem; }
progress.over::-webkit-progress-value { background: var(--error); }
progress.over::-moz-progress-bar { background: var(--error); }
.goal progress { margin: .75rem 0; }
.goal .muted { font-size: .875rem; }
.filters { display: flex; gap: .65rem; flex-wrap: wrap; align-items: end; margin-bottom: 1.05rem; }
.filters label { min-width: min(100%, 9rem); flex: 1; }
label { display: block; font-weight: 650; font-size: .9rem; }
input:not([type="hidden"]), select {
  display: block; width: 100%; min-height: 2.8rem; padding: .55rem .7rem; margin-top: .32rem;
  border: 1px solid #aabbb2; border-radius: .55rem; color: var(--ink); background: white; font-size: 1rem;
}
select { appearance: none; padding-right: 2.1rem; background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2352665d' stroke-width='2'/%3E%3C/svg%3E") no-repeat right .73rem center / .6rem; }
:disabled { color: var(--muted); }
.stack-form { display: grid; gap: 1rem; }
.stack-form .button { justify-self: start; }
.form-panel { max-width: 35rem; }
.form-panel > p { margin-bottom: .8rem; }
.errorlist, .error { color: var(--error) !important; }
.errorlist { padding-left: 1.25rem; margin: .25rem 0; }
.alert { padding: .8rem 1rem; margin-bottom: .75rem; border-radius: .6rem; border: 1px solid var(--line); background: #e8f2e1; }
.alert.error { background: #fff1ed; }
.text-button { background: transparent; color: var(--error); border: 0; min-height: 2.75rem; font-size: .9rem; padding: .25rem .1rem; text-decoration: underline; text-underline-offset: .22em; }
.delete-form { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.pagination { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 1rem; padding-top: .8rem; font-size: .9rem; }
.sign-in { padding: 1.25rem; min-height: 100dvh; display: grid; place-items: center; background: radial-gradient(ellipse at 70% 65%, #dbe8cf, var(--canvas) 70%); }
.login-panel { width: min(100%, 26rem); padding: 2rem; }
.login-brand { color: var(--forest); margin-bottom: 1.7rem; }
.login-panel p { margin: .65rem 0 1.25rem; }

@media (max-width: 1140px) {
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-header { align-items: start; flex-direction: column; }
}
@media (max-width: 800px) {
  .sidebar { position: static; width: auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .65rem; padding: max(.75rem, env(safe-area-inset-top)) 1rem .65rem; }
  .sidebar .brand { padding: 0; }
  .sidebar nav { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; gap: .15rem .3rem; }
  .sidebar nav a { display: flex; align-items: center; min-height: 2.75rem; padding: .5rem .65rem; font-size: .875rem; }
  .sidebar nav a[aria-current] { box-shadow: inset 0 -2px var(--lime); }
  .logout { grid-column: 2; grid-row: 1; }
  .workspace { margin: 0; padding-bottom: max(1.4rem, env(safe-area-inset-bottom)); }
}
@media (max-width: 520px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .page-header { margin-bottom: 1.4rem; }
  .summary { gap: .55rem; }
  .metric { padding: .8rem; gap: .55rem; }
  .metric small { font-size: .79rem; }
  .metric strong { font-size: 1.32rem; }
  .actions .month-switch { flex: 1 0 auto; }
  .record-list li { gap: .6rem; }
  .record-amount { max-width: 42%; }
}
