:root {
  color-scheme: dark;
  --bg: #121612;
  --ink: #e8f0e4;
  --muted: #b7c4b6;
  --line: #2c382c;
  --accent: #c6f135;
  --accent-text: #d6f26a;
  --save: #7ddea0;
  --save-text: #b8f5c8;
  --spend: #ff8f78;
  --spend-text: #ffc2b3;
  --track: #0c0f0c;
  --serif: "iA Writer Quattro S", "Liberation Serif", "Nimbus Roman", Georgia, serif;
  --sans: "Adwaita Sans", "Noto Sans", "Liberation Sans", sans-serif;
  --mono: "iA Writer Mono S", "Liberation Mono", ui-monospace, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f0e6;
    --ink: #1a1f16;
    --muted: #3e493c;
    --line: #ddd4c2;
    --accent: #d4ee6a;
    --accent-text: #3d5c12;
    --save: #1f7a3a;
    --save-text: #176b34;
    --spend: #c2412d;
    --spend-text: #9f2d1c;
    --track: #e7e1d2;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(880px 380px at 0% -8%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 62%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

body::before {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--save));
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 72px;
}

h1, h2, h3 { font-weight: 700; }

h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 4.2vw, 3.35rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0 0 14px;
}

.kicker {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.lede {
  margin: 0;
  max-width: 38rem;
  color: var(--muted);
}

.mono { font-family: var(--mono); font-size: 0.92em; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 28px 48px;
  align-items: start;
}

#overall h2, #tasks > h2 {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}

#tasks { margin-top: 28px; }

#tasks > h2 { margin-top: 0; }

.note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.meter + .meter { margin-top: 16px; }

.meter-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  min-width: 0;
}

.meter h3 {
  margin: 0;
  min-width: 0;
  flex: 1;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delta {
  margin: 0;
  flex: none;
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.save { color: var(--save-text); }
.spend { color: var(--spend-text); }
.flat { color: var(--muted); }

.track {
  height: 10px;
  margin-top: 6px;
  border-radius: 99px;
  background: var(--track);
  overflow: hidden;
}

.fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--ink);
}

.fill.save { background: var(--save); }
.fill.spend { background: var(--spend); }
.fill.base { background: var(--ink); }

.num {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.num strong {
  margin-right: 8px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
}

.num .bad { font-weight: 400; }

.controls { margin-top: 28px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

button, .file, select {
  font: inherit;
  min-height: 40px;
}

button, .file {
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--accent);
  color: #1a2208;
  font-weight: 600;
  cursor: pointer;
}

button.ghost, .file {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 500;
}

button.ghost:hover, .file:hover { border-color: var(--ink); }

.file { position: relative; display: inline-flex; align-items: center; }

.file input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.file input:focus-visible { outline: none; }

.baseline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
}

select {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--bg);
  color: var(--ink);
}

summary {
  width: fit-content;
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

summary:hover { color: var(--ink); }

textarea {
  display: block;
  width: 100%;
  min-height: 9.5rem;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 78%, black);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}

.status {
  min-height: 1.2em;
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.alert {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--spend) 55%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--spend) 14%, var(--bg));
  color: var(--ink);
}

.empty {
  margin: 0;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
}

.task {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.task h3 {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 400;
}

.callouts {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.callouts li {
  margin: 0;
  padding: 3px 0;
  font-size: 15px;
}

.table-wrap {
  overflow-x: auto;
  margin-inline: -4px;
  padding-inline: 4px;
}

.swipe {
  display: none;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

caption.sr { /* positioned below */ }

th, td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: bottom;
}

th:first-child, td:first-child, th[scope="row"] {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--bg);
}

th {
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: normal;
}

th[scope="row"] {
  color: var(--ink);
  font-size: 12.5px;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  font-weight: 400;
}

td { white-space: nowrap; }

td.total, th.total { color: var(--ink); font-weight: 700; }

.bad { color: var(--spend-text); font-weight: 700; }

footer {
  margin-top: 36px;
  max-width: 40rem;
  color: var(--muted);
  font-size: 13px;
}

footer p { margin: 0; }

a { color: var(--accent-text); }

.miss {
  max-width: 36rem;
  margin: 12vh auto;
  padding: 0 20px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus { outline: none; }

:focus-visible, .file:focus-within {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

@media (max-width: 840px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .baseline { margin-left: 0; }
}

@media (max-width: 840px) {
  .swipe { display: block; }
}

@media (max-width: 640px) {
  main { padding: 20px 16px 48px; }
  h1 { font-size: 1.85rem; }
  .baseline, .baseline select { width: 100%; }
  textarea { font-size: 16px; }
  .callouts li { font-size: 14.5px; }
}

@media (prefers-color-scheme: light) {
  textarea { background: #fffdf8; }
  button, .file { color: #1a2208; }
  button.ghost { color: var(--ink); }
}
