:root {
  color-scheme: light;
  --paper: #f4f2f8;
  --surface: #fff;
  --ink: #28213a;
  --muted: #655b75;
  --rule: #dcd5e8;
  --accent: #513585;
  --accent-light: #ece3fa;
  --green: #286c5e;
  --red: #a42742;
  --focus: #764bbc;
  --radius: 1rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper); }
a { color: var(--accent); text-underline-offset: .19em; }
a:hover { text-decoration-thickness: .13em; }
button, input, select { font: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: 2.75rem; padding: .52rem .9rem; border: 1px solid var(--rule);
  border-radius: .68rem; background: var(--surface); color: var(--accent);
  text-decoration: none; font-weight: 650; line-height: 1.2; cursor: pointer;
}
button:hover, .button:hover { background: var(--accent-light); }
button.primary, .button.primary { background: var(--accent); color: white; border-color: var(--accent); }
button.primary:hover, .button.primary:hover { background: #43276f; }
button:disabled { opacity: .57; cursor: default; }
button.danger { color: var(--red); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1, h2, h3, p, dl { margin-top: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
h1 { font-size: clamp(2.25rem, 6vw, 3.8rem); line-height: 1.04; letter-spacing: -.055em; margin-bottom: .5rem; overflow-wrap: anywhere; }
h2 { font-size: 1.65rem; line-height: 1.13; margin-bottom: .75rem; letter-spacing: -.026em; }
h3 { font-size: .97rem; margin-bottom: .85rem; }
p { margin-bottom: .8rem; }
.shell { width: min(100% - 2rem, 72rem); margin-inline: auto; }
.masthead { background: var(--surface); border-bottom: 1px solid var(--rule); }
.masthead-inner { display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 1.75rem; min-height: 4.25rem; }
.wordmark { display: inline-flex; align-items: center; gap: .2rem; color: var(--ink); font-family: Georgia, serif; font-size: 1.85rem; letter-spacing: -.07em; text-decoration: none; }
.wordmark span { color: var(--accent); margin-left: -.22rem; }
.wordmark svg { color: var(--accent); }
.masthead nav { display: flex; flex-wrap: wrap; gap: .3rem; }
.masthead nav a { padding: .55rem .8rem; color: var(--muted); text-decoration: none; font-weight: 600; border-radius: .55rem; }
.masthead nav a:hover, .masthead nav a[aria-current] { background: var(--accent-light); color: var(--accent); }
.logout button { padding-inline: .7rem; }
main.shell { padding-block: clamp(1.2rem, 4vw, 3rem) 2.5rem; min-height: 65vh; }
.footer { display: flex; justify-content: space-between; gap: .8rem; flex-wrap: wrap; padding-block: 1.1rem 1.75rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: .88rem; }
.page-heading { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.35rem; }
.page-heading p:last-child { margin-bottom: 0; }
.eyebrow { display: inline-block; color: var(--accent); font-size: .77rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; margin-bottom: .45rem; }
.muted, small { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.panel { min-width: 0; background: var(--surface); padding: clamp(.9rem, 2.4vw, 1.4rem); border: 1px solid var(--rule); border-radius: var(--radius); }
.panel > :last-child { margin-bottom: 0; }
.narrow { max-width: 39rem; }
.narrow h1 { margin-bottom: 1.25rem; }
.auth { width: min(100%, 28rem); margin: 2rem auto; padding: clamp(1.2rem, 4vw, 2.2rem); }
.auth form, .narrow form, .panel form:not(.logout) { margin-top: .75rem; }
.dashboard-grid, .chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.chart-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.analytics { margin-top: 1.35rem; }
.receipt {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px;
  padding: .7rem .5rem; margin-bottom: 1.15rem; border-radius: var(--radius);
  background: var(--ink); color: white; border-bottom: .32rem dotted #9984b2;
}
.receipt > div { min-width: 0; padding: .65rem clamp(.4rem, 2vw, 1.35rem); }
.receipt > div + div { border-left: 1px solid #5a4b70; }
.receipt dt { color: #e2d3fb; font-size: .84rem; font-weight: 600; }
.receipt dd { margin: .12rem 0 0; font-size: clamp(1.15rem, 3.15vw, 2.3rem); font-variant-numeric: tabular-nums; font-weight: 630; overflow-wrap: anywhere; }
.receipt .negative { color: #ffc0cf; }
.review-receipt { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.section-heading { display: flex; justify-content: space-between; align-items: start; gap: .6rem; flex-wrap: wrap; }
.section-heading a { font-size: .86rem; }
.lined-list { list-style: none; margin: 0; padding: 0; }
.lined-list li { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.lined-list li:last-child { border-bottom: 0; }
.lined-list li:first-child { padding-top: .35rem; }
.lined-list li > div { min-width: 0; }
.lined-list small { display: block; margin-top: .15rem; }
.money { flex-shrink: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list-total { border-top: 1px solid var(--rule); padding-top: .7rem; text-align: right; }
.bar-label { display: flex; justify-content: space-between; align-items: start; gap: .65rem; margin-top: .6rem; font-size: .87rem; overflow-wrap: anywhere; }
meter { display: block; width: 100%; height: .75rem; border: 0; background: none; }
meter::-webkit-meter-bar { border: 0; background: var(--accent-light); }
meter::-webkit-meter-optimum-value { background: var(--accent); }
meter::-moz-meter-bar { background: var(--accent); }
form > div:not(.actions):not(.batch-rows):not(.batch-footer):not(.entry-fields):not(.detail-fields) { margin-bottom: .75rem; }
label { display: block; color: var(--ink); font-size: .87rem; font-weight: 620; margin-bottom: .22rem; }
input:not([type=hidden]):not([type=checkbox]), select {
  display: block; width: 100%; min-width: 0; min-height: 2.8rem; border: 1px solid #c5bbd4;
  border-radius: .55rem; background: white; color: var(--ink); padding: .48rem .6rem;
}
input[type=checkbox] { accent-color: var(--accent); width: 1.15rem; height: 1.15rem; margin: 0; }
input[type=checkbox] + label, .check-line label { display: inline; margin: 0; }
.filters { display: flex; align-items: end; gap: .65rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters > div:not(.actions) { margin-bottom: 0 !important; }
.filters input, .filters select { min-width: 9.4rem !important; }
fieldset { margin: 0; }
.batch-rows { display: grid; gap: .7rem; }
.batch-row { position: relative; min-width: 0; }
.batch-row legend { font-weight: 700; color: var(--accent); font-size: .88rem; padding-inline: .32rem; }
.row-fields, .entry-fields, .detail-fields { display: grid; gap: .65rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row-fields { grid-template-columns: .75fr 1fr 1.1fr 1.65fr; }
.field { min-width: 0; }
.detail-fields { margin-top: .7rem; }
.batch-row details, .narrow details { margin-top: .65rem; }
summary { color: var(--accent); cursor: pointer; font-size: .9rem; font-weight: 650; padding: .3rem 0; }
.narrow form > button { margin-top: .65rem; }
.row-remove { position: absolute; top: -.15rem; right: .7rem; }
.text-button { background: none; border: 0; min-height: 2rem; font-size: .82rem; padding: .28rem .5rem; }
.batch-footer {
  position: sticky; bottom: 0; z-index: 1; margin-top: .6rem; padding: .65rem .8rem max(.65rem, env(safe-area-inset-bottom));
  background: var(--surface); border: 1px solid var(--rule); border-radius: .85rem .85rem 0 0;
  display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: .65rem;
}
.check-line { display: flex; align-items: center; gap: .45rem; margin-right: auto; }
.check-line label { padding: .35rem 0; }
.errorlist { color: var(--red); padding-left: 1.15rem; margin: .25rem 0 .55rem; font-size: .88rem; }
[aria-invalid=true] { border-color: var(--red) !important; }
.notice { background: #e2f1ec; border-left: .2rem solid var(--green); border-radius: .35rem; padding: .65rem .85rem; }
.notice.error { background: #fae7ec; border-color: var(--red); }
.review-list li { justify-content: start; }
.review-list li > form { margin: 0 !important; }
.review-list .item-details { flex: 1; }
.mark-button { width: 2.75rem; padding: 0; font-size: 1.2rem; }
.mark-button[aria-pressed=true] { background: #e2f1ec; color: var(--green); border-color: #95c7b6; }
.review-actions { display: flex; flex-wrap: wrap; align-items: start; gap: .85rem; margin-top: .85rem; }
.adjustment { margin-top: .85rem; }
.danger-zone summary { color: var(--red); }
.pagination { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: .8rem; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: absolute; z-index: 10; padding: .6rem; background: white; }

@media (max-width: 46rem) {
  .chart-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .row-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-receipt { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-receipt > div:nth-child(3) { border-left: 0; }
}
@media (max-width: 34rem) {
  .shell { width: calc(100% - 1.25rem); }
  .masthead-inner { grid-template-columns: 1fr auto; gap: .15rem .55rem; padding-block: .38rem .48rem; }
  .masthead nav { grid-column: 1 / -1; grid-row: 2; }
  .masthead nav a { padding: .52rem .64rem; font-size: .9rem; }
  .logout { grid-column: 2; grid-row: 1; }
  .logout button { min-height: 2.35rem; }
  .receipt dt { font-size: .72rem; }
  .receipt dd { font-size: clamp(.95rem, 4.2vw, 1.45rem); }
  .page-heading .actions { width: 100%; }
  .page-heading .actions > * { flex: 1 1 auto; }
  .batch-footer { justify-content: stretch; }
  .batch-footer .actions { flex: 1; }
  .batch-footer .actions button { flex: 1; }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters > div:has(input[type=month]) { grid-column: 1 / -1; }
  .filters input, .filters select { min-width: 0 !important; }
}
