:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --line: #334155;
  --accent: #4f46e5;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 16px;
  --nav-h: 64px;
}

* { box-sizing: border-box; }

/* Money-mask wrapper: transparent to layout so the visible field keeps its own styling */
.mask { display: contents; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

.container {
  max-width: 560px;
  margin: 0 auto;
  /* Respect iOS safe areas so the top toggle clears the notch/Dynamic Island
     (and side insets in landscape) when installed as a standalone PWA. */
  padding:
    calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
    24px calc(16px + env(safe-area-inset-left));
}

a { color: inherit; text-decoration: none; }

/* ---------- Icons ---------- */
/* Sized off the surrounding font-size and painted with currentColor, so an icon
   drops into any context the emoji used to sit in without extra rules. */
.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.125em; flex-shrink: 0; }

/* ---------- Lane toggle (exactly 2 lanes) ---------- */
.lane-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 99px; padding: 4px; margin: 0 0 14px;
}
.lane-toggle__opt {
  text-align: center; padding: 11px 12px; border-radius: 99px;
  font-weight: 600; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  transition: background .2s ease, color .2s ease;
}
.lane-toggle__opt--active { background: var(--accent); color: #fff; }

/* ---------- Lane switcher (3+ lanes, dropdown fallback) ---------- */
.lane-switcher { margin: 0 0 12px; }
.lane-switcher__select {
  width: 100%; padding: 12px 14px; font-size: 1rem; font-weight: 600;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center;
}

/* Small pill showing which lane a category/expense belongs to */
.stats__lane, .history__lane {
  font-size: 0.72rem; color: var(--muted); background: var(--surface-2);
  padding: 1px 7px; border-radius: 99px; margin-left: 6px; white-space: nowrap;
}
.stats__heading { font-size: 0.95rem; color: var(--muted); margin: 18px 0 8px; }
.stats__heading:first-of-type { margin-top: 0; }
/* A cycle overspent its allocation */
.stats .neg { color: #fca5a5; }

/* ---------- Cycles ---------- */
.cycle__period { display: block; font-weight: 400; font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

/* Category picker + Adicionar, side by side on an audit row. The picker is a
   pill that sizes to the category it holds instead of claiming the whole row.
   It appears both in the bulk bar and inline on every row of the list. */
.audit__add { display: flex; gap: 8px; align-items: center; }
.audit__add select, .audit__actions select {
  flex: 0 1 auto; width: auto; max-width: 58%;
  padding: 7px 32px 7px 13px; font: inherit; font-size: 0.85rem; font-weight: 600;
  color: var(--text); background-color: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
  text-overflow: ellipsis; cursor: pointer;
}
.audit__add select:focus-visible,
.audit__actions select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* A picker filled in from what this merchant got last time, not the page default */
.audit__actions select.audit__guess { border-color: var(--accent); }
/* Square-ish icon buttons so the check and the close read as a pair */
.btn--icon { padding: 7px 0; min-width: 40px; font-size: 1rem; line-height: 1.2; }

/* A decision is a radio wearing a button: taken instantly, applied on Salvar.
   The accept choice takes the row's leftover width so it sits next to the close. */
.decision { display: inline-flex; }
.decision--accept { flex: 1; }
.decision__input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.decision__btn { width: 100%; text-align: center; cursor: pointer; user-select: none; }
.decision--add .decision__btn, .decision--split .decision__btn, .decision--ignore .decision__btn {
  min-width: 44px; background: transparent; border: 1px solid var(--line); color: var(--text);
}
.decision__input:checked + .decision__btn--accept { background: var(--good); color: #04210f; }
.decision__input:checked + .decision__btn--add,
.decision__input:checked + .decision__btn--split { background: var(--accent); color: #fff; border-color: transparent; }
.decision__input:checked + .decision__btn--ignore { background: var(--bad); color: #fff; border-color: transparent; }
.decision__input:focus-visible + .decision__btn { outline: 2px solid var(--accent); outline-offset: 2px; }
/* A decided row steps back so the undecided ones stand out */
.audit__card:has(.decision__input:checked) { opacity: 0.72; border-color: var(--surface-2); }

.audit__save {
  position: sticky; bottom: calc(var(--nav-h) + 8px); z-index: 5;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.audit__save__go { flex: 1; }
.audit__save__go:disabled { opacity: 0.45; }
.audit__credit { color: var(--good); }
.audit__accept-all { gap: 6px; margin-bottom: 12px; }

.audit__batch { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.audit__batch li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; color: var(--muted); }

/* Conferência rows: everything visible, nothing to open. */
.audit__card { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; }
.audit__card .hint, .audit__card .history__meta { margin: 0; }
.audit__line { display: flex; align-items: center; gap: 10px; }
.audit__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.audit__actions form { margin: 0; }
.audit__actions .audit__add { flex: 1; min-width: 180px; }
.audit__bulk {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}

/* ---------- Top bar ---------- */
.topbar { margin: 8px 0 20px; }
.topbar__total { font-size: 2.4rem; font-weight: 800; margin: 0; letter-spacing: -0.02em; }
.topbar__sub { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }

/* ---------- Cards / buckets ---------- */
.cards { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
}
.card--over { border-left-color: var(--bad); }

.card__head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.card__name { font-size: 1.05rem; font-weight: 600; }
.card__balance { font-size: 1.35rem; font-weight: 800; }
.card--over .card__balance { color: var(--bad); }

.bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  margin: 12px 0 6px;
  overflow: hidden;
}
.bar__fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s ease; }
.card--over .bar__fill { background: var(--bad); }

/* Overall budget bar in the header (only shown when fully allocated) */
.bar--total { height: 10px; margin: 14px 0 0; }
.bar--total .bar__fill { background: var(--good); }          /* > 30% remaining */
.bar--total.bar--warning .bar__fill { background: var(--warn); }  /* ≤ 30% */
.bar--total.bar--critical .bar__fill { background: var(--bad); }  /* ≤ 10% / overspent */

.card__meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.85rem; }
.card__over { color: var(--bad); font-weight: 600; }

/* ---------- Inline quick-spend ---------- */
.spend { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.spend[hidden] { display: none; }
.spend__row { display: flex; gap: 8px; }
.spend__amount {
  flex: 1 1 0;
  min-width: 0;            /* allow the input to shrink instead of overflowing the card */
  width: 100%;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
.btn--spend { flex-shrink: 0; }   /* keep the Spend button at its natural size */
.spend__note {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
/* Secondary actions under the quick-spend form, tinted with the category. */
.spend__actions {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  padding-top: 12px; border-top: 1px solid var(--line);
}
.spend__action {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 10px; border-radius: 12px; text-align: center;
  font-size: 0.85rem; font-weight: 600; color: var(--text); line-height: 1.2;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  transition: background 0.15s, transform 0.1s;
}
.spend__action .icon { color: var(--accent); width: 1.1em; height: 1.1em; }
.spend__action:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.spend__action:active { transform: scale(0.97); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 12px; cursor: pointer;
  font: inherit; font-weight: 600; padding: 12px 16px; color: var(--text);
  background: var(--surface-2);
}
.btn--primary { background: var(--accent); }
.btn--spend { background: var(--good); color: #06280f; padding: 12px 20px; font-size: 1.1rem; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; border: 1px solid var(--line); }
.btn--danger { background: var(--bad); }
.btn--tiny { padding: 6px 12px; font-size: 0.85rem; }
.btn--add { background: var(--surface); border: 1px dashed var(--line); width: 100%; list-style: none; }
.btn--add::-webkit-details-marker { display: none; }

/* ---------- Add category ---------- */
.addcat { margin-top: 16px; }
.addcat__form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.addcat__form input[type=text], .addcat__form input[type=number] {
  padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }

/* ---------- Color swatches ---------- */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--c); border: 3px solid transparent; }
.swatch input:checked + span { border-color: var(--text); }

/* ---------- Quick-add FAB + bottom sheet ---------- */
.fab {
  position: fixed; right: 18px; z-index: 40;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--good); color: #06280f; font-size: 2rem; font-weight: 700; line-height: 1;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); cursor: pointer;
}
/* The mic mirrors the "+": same size, same height, opposite corner — a thumb
   for each, and neither one the other's little sibling. It is held down to
   talk, so it must not come with a long-press menu or a drag-scroll. */
.fab--mic {
  left: 18px; right: auto; width: 56px; height: 56px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 1.6rem;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.fab--mic[hidden] { display: none; }
/* Held down: the bubble breathes and throws two sonar rings on the off-beat. */
.fab--listening { animation: breathe 1.4s ease-in-out infinite; }
.fab--listening::before, .fab--listening::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--accent); pointer-events: none;
  animation: sonar 1.4s ease-out infinite;
}
.fab--listening::after { animation-delay: 0.7s; }
/* 1.6 is as wide as a ring can get before the screen edge clips it. */
@keyframes sonar { from { transform: scale(1); opacity: 0.7; } to { transform: scale(1.6); opacity: 0; } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
/* Let go: still working on it, no longer listening. */
.fab--waiting { opacity: 0.7; animation: breathe 1.4s ease-in-out infinite; }
.voicehint {
  position: fixed; z-index: 40; left: 18px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 84px);
  margin: 0; padding: 8px 12px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 0.85rem;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.voicehint[hidden] { display: none; }

.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet__panel {
  width: 100%; max-width: 560px; margin: 0 auto;
  background: var(--surface); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet__head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 12px; }
.sheet__close { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.sheet__amount {
  width: 100%; font-size: 2rem; font-weight: 800; text-align: center; padding: 12px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.sheet__note {
  width: 100%; margin-top: 10px; padding: 11px 12px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.sheet .check { margin-top: 10px; }
.sheet__hint { color: var(--muted); font-size: 0.85rem; margin: 14px 0 8px; }
.sheet__cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-height: 40vh; overflow-y: auto; }
.sheet__cat {
  text-align: left; padding: 14px; border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  background: var(--bg); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* What the dictation matched. It is picked out, never pressed: the tap on it is
   the confirmation that the phrase was understood right. */
.sheet__cat--suggested { border-color: var(--accent); background: rgba(79,70,229,.18); box-shadow: 0 0 0 1px var(--accent); }
/* The confirm pair a dictation puts up. The recording button borrows the
   category's own colour, so what it will do is legible before it is read. */
.sheet__confirm { display: grid; gap: 8px; margin-top: 14px; }
.sheet__confirm[hidden], .sheet__confirm [hidden] { display: none; }
.sheet__confirm .btn { gap: 8px; padding: 14px 16px; font-size: 1.02rem; }
.sheet__confirm .btn--primary { color: #fff; }
.sheet__confirm .icon { width: 1.05em; height: 1.05em; }
/* The raw phrase, so a mishearing is caught before it is saved. */
.sheet__heard { margin: -4px 0 12px; color: var(--muted); font-size: 0.85rem; font-style: italic; }
.sheet__heard[hidden] { display: none; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: 0.7rem; }
.tab--active { color: var(--text); }
.tab__icon { font-size: 1.3rem; }

/* ---------- Login ---------- */
.login { max-width: 340px; margin: 18vh auto 0; text-align: center; }
/* Larger than the emoji it replaced: the drawn mark uses less of its box. */
.login__logo { font-size: 4.6rem; }
.login__title { font-size: 1.8rem; font-weight: 800; margin: 4px 0; }
.login__sub { color: var(--muted); margin-bottom: 24px; }
.login__form { display: flex; flex-direction: column; gap: 12px; }
.login__input { padding: 14px; font-size: 1.1rem; text-align: center; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); }

/* ---------- Ranges / chips ---------- */
.ranges { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 14px; }
.lanes { padding-bottom: 10px; }
.chip { white-space: nowrap; padding: 8px 14px; border-radius: 99px; background: var(--surface);
  border: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.chip--active { background: var(--accent); color: var(--text); border-color: var(--accent); }

/* A collapsed row that names what it holds: the report's lane + period chips,
   a cycle's expense lists. */
.filters, .fold { margin-bottom: 14px; }
.filters__summary, .fold__summary {
  display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none;
  padding: 10px 14px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); color: var(--muted); font-size: 0.9rem;
}
.filters__summary::-webkit-details-marker, .fold__summary::-webkit-details-marker { display: none; }
.filters__summary::after, .fold__summary::after { content: "›"; margin-left: auto; transition: transform 0.15s; }
.filters[open] .filters__summary, .fold[open] .fold__summary { margin-bottom: 12px; }
.filters[open] .filters__summary::after, .fold[open] .fold__summary::after { transform: rotate(90deg); }
.filters__label, .fold__label { font-weight: 600; color: var(--text); }
.filters__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The total sits on the right, next to the chevron. */
.fold__value { margin-left: auto; font-variant-numeric: tabular-nums; }
.fold__summary::after { margin-left: 4px; }

/* ---------- Custom date range ---------- */
.custom-range {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 16px;
}
.custom-range .field { flex: 1 1 130px; gap: 4px; }
.custom-range input[type=date] {
  padding: 11px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; width: 100%;
}
.custom-range__apply { flex: 1 1 100%; }

/* ---------- Relatórios: sub-navigation + insight blocks ---------- */
/* Segmented bar picking one of the tab's screens; the range chips sit below. */
.subnav {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 99px; padding: 4px; margin: 0 0 14px;
}
.subnav__opt {
  text-align: center; padding: 10px 6px; border-radius: 99px;
  font-weight: 600; font-size: 0.9rem; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.subnav__opt--active { background: var(--accent); color: #fff; }

.insight { margin-bottom: 18px; }
.insight__line { margin: 10px 0 0; line-height: 1.45; }
.insight__line strong { color: var(--text); }
.insight__big { font-size: 2rem; font-weight: 800; margin: 0; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.pos { color: #86efac; }
.neg { color: #fca5a5; }

/* Two thin bars: how much of the month is gone vs how much of the budget. */
.meter__label { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--muted); margin: 10px 0 4px; }
.meter__label:first-of-type { margin-top: 0; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter__fill { height: 100%; border-radius: 99px; background: var(--muted); transition: width .3s ease; }
.meter__fill--good { background: var(--good); }
.meter__fill--bad { background: var(--bad); }

/* Category rows with a status on the right (dias até zerar, quem estoura). */
.runway { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.runway__item {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.runway__name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runway__status { font-size: 0.85rem; color: var(--muted); text-align: right; white-space: nowrap; }
.runway__item--tight .runway__status { color: #fcd34d; }
.runway__item--over .runway__status { color: #fca5a5; font-weight: 600; }

/* Biggest expenses of the window. */
.toplist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.toplist__item {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.toplist__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.toplist__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toplist__meta { font-size: 0.8rem; color: var(--muted); }
.toplist__amount { font-weight: 700; font-variant-numeric: tabular-nums; }

.delta--up { color: #fca5a5; }
.delta--down { color: #86efac; }
.delta__pct { color: var(--muted); font-size: 0.8rem; }

/* Day heat-map, Monday first; darker cells are pricier days. */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal__dow { text-align: center; font-size: 0.7rem; color: var(--muted); padding-bottom: 2px; }
.cal__day {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px;
  font-size: 0.8rem; font-variant-numeric: tabular-nums;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
}
.cal__day--l1 { background: color-mix(in srgb, var(--accent) 25%, var(--surface)); }
.cal__day--l2 { background: color-mix(in srgb, var(--accent) 50%, var(--surface)); }
.cal__day--l3 { background: color-mix(in srgb, var(--accent) 75%, var(--surface)); }
.cal__day--l4 { background: var(--accent); color: #fff; }
.cal__day--out { opacity: 0.25; }
.cal__day--future { opacity: 0.35; border-style: dashed; }

/* ---------- Chart + stats table ---------- */
/* Room for the donut plus its legend underneath. */
.chart { height: 320px; }
.chartcard__caption { margin: 10px 0 0; }
.chartcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 18px; }
.stats { width: 100%; border-collapse: collapse; }
.stats th, .stats td { padding: 12px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.stats th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.stats .num { text-align: right; font-variant-numeric: tabular-nums; }
.stats tfoot td { font-weight: 700; border-bottom: none; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 8px; }

/* ---------- History (collapsible rows) ---------- */
.history { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.history__item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.history__summary {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer;
  list-style: none;
}
.history__summary::-webkit-details-marker { display: none; }
.history__cat { flex: 1; font-weight: 600; }
.history__amount { font-weight: 700; font-variant-numeric: tabular-nums; }
/* chevron affordance that rotates when the row is open */
.history__summary::after {
  content: "›"; color: var(--muted); font-size: 1.2rem; line-height: 1;
  transition: transform .15s ease;
}
.history__item details[open] .history__summary::after { transform: rotate(90deg); }
.history__detail {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px 12px; border-top: 1px solid var(--line); margin-top: -1px; padding-top: 12px;
}
.history__meta { color: var(--muted); font-size: 0.85rem; }
.history__actions { display: flex; gap: 8px; flex-shrink: 0; }
/* Ignored expenses: tracked but not counted — dim them and strike the amount */
.history__item--ignored { opacity: 0.5; }
.history__item--ignored .history__amount { text-decoration: line-through; }

/* ---------- History search bar (always-visible pill) ---------- */
.searchbar { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; margin-bottom: 12px; }
.searchbar:focus-within { border-color: var(--accent); }
.searchbar__icon { color: var(--muted); font-size: 1rem; line-height: 1; }
.searchbar__input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
  color: var(--text); font: inherit; }
.searchbar__input::placeholder { color: var(--muted); }
/* clear the native WebKit search decorations so the field stays flat */
.searchbar__input::-webkit-search-decoration,
.searchbar__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.searchbar__clear { flex-shrink: 0; color: var(--muted); text-decoration: none;
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--surface-2); font-size: 0.85rem; }

/* ---------- History pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 16px; }
.pagination__status { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.pagination__disabled { opacity: 0.4; pointer-events: none; }

/* Inline checkbox rows (quick-spend "don't count", expense edit) */
.spend__ignore, .check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.spend__ignore input, .check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* A settings choice: the radio stays, with room for a line explaining it. */
.choice { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; cursor: pointer; }
.choice + .choice { border-top: 1px solid var(--line); }
.choice input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.choice__text { display: flex; flex-direction: column; gap: 2px; }
.choice__text small { color: var(--muted); font-size: 0.85rem; }

/* ---------- Panels / settings ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; }
.panel__title { margin: 0 0 12px; font-size: 1.05rem; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.field input { padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.hint { color: var(--muted); font-size: 0.85rem; }
.catlist { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.catlist__item { display: flex; align-items: center; gap: 10px; }
.catlist__name { flex: 1; font-weight: 600; }
.catlist__budget { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; }
.flash--notice { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid rgba(34,197,94,.3); }
.flash--alert { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }

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