:root {
  color-scheme: light dark;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --health: #1baf7a;
  --zus: #eb6834;
  --pit: #2a78d6;
  --focus: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --line: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --health: #199e70;
    --zus: #d95926;
    --pit: #3987e5;
    --focus: #3987e5;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.wrap { max-width: 44rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.head { margin-bottom: 1.25rem; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
.lead { color: var(--ink-2); margin: 0; }
p, li { color: var(--ink-2); }
a { color: inherit; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1rem;
  margin-bottom: 1rem;
}

/* --- inputs --- */
.period { display: flex; gap: .25rem; border: 1px solid var(--line); border-radius: 8px; padding: .25rem; margin-bottom: 1rem; }
.period label {
  flex: 1; text-align: center; padding: .4rem .5rem; border-radius: 6px; cursor: pointer;
  color: var(--ink-2); font-weight: 500;
}
.period label:has(input:checked) { background: var(--ink); color: var(--surface); }
.period input { position: absolute; opacity: 0; width: 0; height: 0; }
.period label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }

.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field small { display: block; color: var(--muted); font-size: .85rem; margin-top: .3rem; }
.money { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--page); }
.money:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.money input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 1.15rem; padding: .55rem .75rem; font-variant-numeric: tabular-nums;
}
.money input:focus { outline: none; }
.money input::-webkit-outer-spin-button, .money input::-webkit-inner-spin-button { -webkit-appearance: none; }
.money input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.money span { padding: 0 .75rem; color: var(--muted); }
.presets { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.presets button {
  font: inherit; font-size: .82rem; line-height: 1.2; padding: .3rem .6rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.presets button b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.presets button:hover { border-color: var(--muted); }
.presets button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); }
.presets button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.opts { display: flex; flex-direction: column; gap: .25rem; margin-top: .5rem; font-size: .9rem; color: var(--ink-2); }
.opts label { display: flex; gap: .5rem; align-items: baseline; cursor: pointer; }
.opts input { accent-color: var(--zus); margin: 0; }

/* --- receipt --- */
.total { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.total-label { color: var(--ink-2); }
.total-value { font-size: 2rem; font-weight: 600; line-height: 1.1; }
.stack { display: flex; gap: 2px; height: 14px; margin: 1rem 0 .6rem; background: var(--surface); }
.stack span { display: block; height: 100%; min-width: 0; transition: flex-basis .2s; }
.stack span:first-child { border-radius: 4px 0 0 4px; }
.stack span:last-child { border-radius: 0 4px 4px 0; }
.stack span:only-child { border-radius: 4px; }
.stack .health { background: var(--health); }
.stack .zus { background: var(--zus); }
.stack .pit { background: var(--pit); }
.legend { list-style: none; margin: 0 0 .5rem; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; font-size: .9rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: .4rem; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .sw.health { background: var(--health); }
.legend .sw.zus { background: var(--zus); }
.legend .sw.pit { background: var(--pit); }

.section { border-top: 1px solid var(--line); padding-top: .9rem; margin-top: .9rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.section-head h3 { font-size: 1rem; margin: 0; display: flex; align-items: center; gap: .5rem; }
.section-head .sw { width: 10px; height: 10px; border-radius: 3px; }
.section-head .amt { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.badge { font-size: .72rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; padding: .1rem .45rem; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }
.badge.estimated { border-style: dashed; }
.section-note { font-size: .85rem; color: var(--muted); margin: 0 0 .6rem; }

.rows { display: flex; flex-direction: column; gap: .5rem; }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name val" "bar bar";
  column-gap: .75rem; row-gap: .25rem; align-items: center;
}
.row .name { grid-area: name; color: var(--ink); font-size: .95rem; line-height: 1.25; }
.row .name small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.3; }
.row .val { grid-area: val; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .95rem; }
.row .val small { display: block; color: var(--muted); font-size: .78rem; }
.row .bar { grid-area: bar; height: 8px; }
details.row { display: block; }
details.row > summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name val" "bar bar";
  column-gap: .75rem; row-gap: .25rem; align-items: center; cursor: pointer; list-style: none; position: relative;
}
details.row > summary::-webkit-details-marker { display: none; }
details.row > summary .name::before {
  content: "▸"; display: inline-block; width: .9em; color: var(--muted); font-size: .8em; transition: transform .15s;
}
details.row[open] > summary .name::before { transform: rotate(90deg); }
details.row > summary .name small { padding-left: .9em; }
details.row > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sub { list-style: none; margin: .3rem 0 .4rem; padding: 0 0 0 .9em; border-left: 2px solid var(--line); }
.sub li { display: flex; justify-content: space-between; gap: .75rem; font-size: .82rem; color: var(--ink-2); padding: .1rem 0 .1rem .5rem; }
.sub li span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.row .bar i { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.section.health .bar i { background: var(--health); }
.section.zus .bar i { background: var(--zus); }
.section.pit .bar i { background: var(--pit); }
.section.estimated .bar i { opacity: .85; }
.empty { color: var(--muted); font-size: .9rem; margin: 0; }

/* --- methodology --- */
.method ul { padding-left: 1.2rem; margin: .4rem 0 .8rem; }
.method li { margin-bottom: .35rem; }
.method p { margin: 0 0 .75rem; }
details { margin-top: .5rem; }
summary { cursor: pointer; font-weight: 600; color: var(--ink); }
#sources li { word-break: break-word; }
.foot { color: var(--muted); font-size: .85rem; text-align: center; margin-top: 1.5rem; }

@media (min-width: 560px) {
  .row, details.row > summary { grid-template-columns: minmax(0, 1fr) 12rem 7.5rem; grid-template-areas: "name bar val"; }
  details.row { display: block; }
}
