:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #1a1d23;
  --muted: #5c6570;
  --line: #d5d9e0;
  --accent: #1a1d23;
  --due: #1d4ed8;
  --overdue: #c2410c;
  --paid: #166534;
  --income: #a16207;
  --income-paid: #0f766e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.35;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--due);
  outline-offset: 2px;
}

.boot { padding: 24px 16px; color: var(--muted); }

.wrap {
  max-width: 440px;
  margin: 0 auto;
  padding: calc(6px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
}

.kicker {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top h1 { margin: 0; font-size: 20px; line-height: 1; }
.top .sub { margin: 2px 0 0; font-size: 12px; line-height: 1.2; white-space: nowrap; }

.add, .primary, a.primary {
  background: var(--ink);
  color: #fff;
  border: 0;
  text-decoration: none;
}

.add {
  border-radius: 6px;
  min-height: 32px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 650;
  flex: none;
}

.primary, a.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  border-radius: 6px;
  font-weight: 650;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 8px 0 8px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  min-height: 32px;
  border-radius: 0;
  color: var(--muted);
  font-weight: 650;
}

.tabs button[aria-selected="true"] {
  background: transparent;
  color: var(--ink);
  border-bottom-color: var(--ink);
  box-shadow: none;
}

.summary {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px 8px;
  margin-bottom: 8px;
}

.summary .caption, .summary .fx { margin: 0; color: var(--muted); font-size: 12px; }
.summary .income-line { margin: 4px 0 0; color: var(--income); font-weight: 650; font-size: 13px; }
.summary .total {
  margin: 2px 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  color: var(--ink);
}

.list { display: flex; flex-direction: column; gap: 6px; }

.row {
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1px 10px;
  box-shadow: none;
}

.row .name { font-weight: 650; }
.row .amount { font-variant-numeric: tabular-nums; font-weight: 700; }
.row .meta { grid-column: 1 / -1; color: var(--muted); font-size: 12px; line-height: 1.25; }

.row.due { border-left-color: var(--due); }
.row.due .amount { color: var(--due); }
.row.overdue { border-left-color: var(--overdue); }
.row.overdue .amount, .row.overdue .meta { color: var(--overdue); }
.row.paid { border-left-color: var(--paid); }
.row.paid .amount { color: var(--paid); }
.row.skipped { border-left-color: #9aa1ab; }
.row.skipped .name, .row.skipped .amount, .row.skipped .meta { color: var(--muted); }
.row.skipped .amount { text-decoration: line-through; }

.row.income.due { border-left-color: var(--income); }
.row.income.due .amount { color: var(--income); }
.row.income.overdue { border-left-color: #9a3412; }
.row.income.overdue .amount, .row.income.overdue .meta { color: #9a3412; }
.row.income.paid { border-left-color: var(--income-paid); }
.row.income.paid .amount { color: var(--income-paid); }

.filter-toggle {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  min-height: 22px;
}
.filter-toggle.open { color: var(--ink); }
.filter-panel { margin-bottom: 6px; }
.filters.kinds { margin-bottom: 6px; }

.filters {
  display: flex;
  gap: 6px;
  margin: 0 0 6px;
}
.filter {
  flex: 1;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.filter.on.due, .filter.on.expense { color: var(--due); border-color: var(--due); background: #fff; }
.filter.on.overdue { color: var(--overdue); border-color: var(--overdue); background: #fff; }
.filter.on.paid { color: var(--paid); border-color: var(--paid); background: #fff; }
.filter.on.income { color: var(--income); border-color: var(--income); background: #fff; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 99px;
  display: inline-block;
  margin-right: 6px;
  background: currentColor;
}
.row.due .dot { background: var(--due); }
.row.overdue .dot { background: var(--overdue); }
.row.paid .dot { background: var(--paid); }
.row.skipped .dot { background: #9aa1ab; }
.row.income.due .dot { background: var(--income); }
.row.income.overdue .dot { background: #9a3412; }
.row.income.paid .dot { background: var(--income-paid); }

.empty { color: var(--muted); text-align: center; padding: 12px 8px; margin: 0; }

.banner {
  background: #fff;
  color: var(--overdue);
  border: 1px solid #f0c7b8;
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0 0 8px;
}

.monthbar {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  margin-bottom: 6px;
}
.monthbar strong { display: block; text-align: center; font-size: 16px; }
.monthbar > button {
  width: 36px;
  height: 32px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  font-size: 22px;
  line-height: 1;
}
.linkish, .textback {
  background: none;
  border: 0;
  color: var(--due);
  font-weight: 650;
  padding: 0;
}
.linkish { display: block; margin: 2px auto 0; min-height: 24px; }
.textback { min-height: 32px; margin-bottom: 2px; }

.field { margin: 12px 0; }
.field span, .hint { display: block; }
.field > span { margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 650; }
.hint { margin-top: 4px; color: var(--muted); font-size: 12px; }

input[type="text"], input[type="date"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 42px;
}
textarea { min-height: 72px; resize: vertical; }

.segment { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segment.four { grid-template-columns: 1fr 1fr; }
.segment button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  min-height: 40px;
}
.segment button[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-weight: 650;
}

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 20px;
}
.stepper strong { min-width: 2ch; text-align: center; font-size: 16px; }
.stepper.wide strong { flex: 1; font-size: 15px; font-weight: 650; }

.ghost, .danger {
  width: 100%;
  min-height: 42px;
  border-radius: 6px;
  margin-top: 8px;
}
.ghost { background: #fff; border: 1px solid var(--line); }
.danger {
  background: #fff;
  color: var(--overdue);
  border: 1px solid #f0c7b8;
  margin-top: 12px;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 24, 0.45);
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 10px 10px 0 0;
  padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(17, 20, 24, 0.12);
}
.sheet h2 { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.sheet .amount { margin: 0; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sheet .notes { white-space: pre-wrap; }
.sheet-actions { margin-top: 12px; }

.gate { padding-top: 18vh; }
.gate a.primary { margin-top: 18px; }
