/* ==========================================================================
   FinCaroTur — design system
   1. Tokens  2. Reset/base  3. Layout  4. Components  5. Screens  6. Utils
   ========================================================================== */

/* --- 1. Tokens ----------------------------------------------------------- */
:root {
  --bg: #F6F3EE;
  --surface: #FFFFFF;
  --surface-2: #EFEBE4;
  --text: #1F1C18;
  --text-muted: #71695E;
  --border: #E4DED4;
  --accent: #B4532A;
  --accent-soft: #F3E2D9;
  --on-accent: #FFFFFF;
  --positive: #3D7A4E;
  --negative: #B03B2E;
  --warn: #C08A2D;
  --arthur: #456990;
  --carolina: #C08A2D;
  --split: #8A7B6E;

  --radius-card: 14px;
  --radius-input: 10px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 3px rgb(31 28 24 / .08);
  --gutter: 16px;

  --font: -apple-system, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-h: 52px;
  --tabbar-h: 56px;
}

:root.theme-dark,
:root[data-theme="dark"] {
  --bg: #15130F;
  --surface: #201D18;
  --surface-2: #2A261F;
  --text: #EDE8E0;
  --text-muted: #9C948A;
  --border: #363028;
  --accent: #D97A50;
  --accent-soft: #3A2A21;
  --on-accent: #1F1C18;
  --positive: #6FAE82;
  --negative: #E07B6E;
  --warn: #D9A94F;
  --arthur: #7FA3C7;
  --carolina: #D9A94F;
  --split: #A99A8B;
  --shadow-card: none;
}

/* --- 2. Reset / base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }
.icon { display: inline-block; vertical-align: middle; flex: none; }
.icon-sprite { display: none; }
:root { --tabnums: tabular-nums; }

/* Keyboard-only focus ring (a11y): visible on :focus-visible, silent on
   mouse/touch. More specific rules (e.g. .form-field__input:focus) still win
   the cascade, so this doesn't double up where a custom focus style exists. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

/* --- 3. Layout ----------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-header__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--header-h);
  padding: 0 var(--gutter);
}
.app-header__title { font-size: 17px; font-weight: 600; }

.app-main {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--gutter);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--border);
}
.tabbar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--text-muted);
  min-height: 44px;
  justify-content: center;
}
.tabbar__item.is-active { color: var(--accent); }
.tabbar__fab {
  justify-self: center;
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  margin-top: -14px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 4px 12px rgb(180 83 42 / .4);
}
.tabbar__fab:active { transform: scale(.94); }

/* --- 4. Components ------------------------------------------------------- */
.stack > * + * { margin-top: var(--gutter); }

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--gutter);
}
.card--pad-lg { padding: 20px; }
.card__title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: 16px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text);
  transition: transform .1s ease, opacity .1s ease;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--secondary { background: transparent; border-color: var(--border); }
.btn--danger { background: transparent; color: var(--negative); border-color: var(--border); }
.btn--block { width: 100%; }
.btn:disabled { opacity: .4; pointer-events: none; }

.form-field { display: block; margin-top: 14px; }
.form-field__label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-field__input,
.form-field select,
select.form-field__input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--text);
}
.form-field__input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form-field__error { color: var(--negative); font-size: 13px; margin-top: 6px; }

.money { display: inline-flex; flex-direction: column; align-items: flex-end; }
.money__cop { font-variant-numeric: var(--tabnums); font-weight: 600; }
.money__eur { font-size: 12px; color: var(--text-muted); font-variant-numeric: var(--tabnums); }
.money--hero .money__cop { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.money--lg .money__cop { font-size: 22px; }
.money--sm .money__cop { font-size: 14px; font-weight: 500; }
.money--md .money__cop { font-size: 17px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--split); }
.chip--arthur .chip__dot { background: var(--arthur); }
.chip--carolina .chip__dot { background: var(--carolina); }
.chip--split .chip__dot { background: var(--split); }

.icon-badge {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  color: var(--cat-color, var(--accent));
  background: color-mix(in srgb, var(--cat-color, var(--accent)) 16%, transparent);
  flex: none;
}

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper__btn {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  color: var(--text-muted);
}
.stepper__btn.is-disabled { opacity: .25; }
.stepper__label {
  min-width: 120px;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  text-transform: capitalize;
}

.progress {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
}
.progress__fill { height: 100%; border-radius: inherit; background: var(--accent); transition: width .3s ease; }
.progress--warn .progress__fill { background: var(--warn); }
.progress--over .progress__fill { background: var(--negative); }

/* List rows */
.list-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 0;
}
.card > .list-row + .list-row { border-top: 1px solid var(--border); }
.card.list-row { padding: 12px 16px; }
.list-row__body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-row__title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row__sub { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.list-row__end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.list-row__actions { display: flex; align-items: center; gap: 2px; }
.list-row.is-inactive { opacity: .5; }

.icon-btn {
  position: relative;
  display: grid; place-items: center;
  width: 40px; height: 40px;
  color: var(--text-muted);
  background: none; border: none;
  border-radius: 10px;
}
.icon-btn:active { background: var(--surface-2); }
/* Extend the tap target toward ~44px. Mostly vertical: these often sit
   side-by-side with only a couple px of gap (list-row__actions), so growing
   sideways would create overlapping hit zones between neighbors. */
.icon-btn::after { content: ""; position: absolute; inset: -4px -1px; }
.inline { display: inline; }
.btn--sm { min-height: 38px; padding: 0 14px; font-size: 14px; }

/* Pickers (icon grid + color swatches) */
.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.picker--icons .picker__opt {
  display: grid; place-items: center;
  width: 48px; height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  cursor: pointer;
}
.picker--icons .picker__opt.is-selected,
.picker--icons .picker__opt:has(input:checked) {
  border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
}
.picker input { position: absolute; opacity: 0; pointer-events: none; }
.picker--colors .picker__swatch {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--sw);
  cursor: pointer;
  box-shadow: inset 0 0 0 2px transparent;
  position: relative;
}
.picker--colors .picker__swatch.is-selected,
.picker--colors .picker__swatch:has(input:checked) {
  box-shadow: inset 0 0 0 2px var(--surface), 0 0 0 2px var(--text);
}

/* Segmented control */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
}
.segmented__opt {
  position: relative;
  display: grid; place-items: center;
  min-height: 40px;
  border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s ease;
}
.segmented__opt input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__opt.is-selected,
.segmented__opt:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.segmented--payer .seg--arthur:has(input:checked) { color: var(--arthur); }
.segmented--payer .seg--carolina:has(input:checked) { color: var(--carolina); }
.segmented--payer .seg--split:has(input:checked) { color: var(--split); }

/* Ratio slider */
.ratio { margin-top: 14px; }
.ratio__labels { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.ratio__labels b { color: var(--text); }
.ratio__input { width: 100%; accent-color: var(--accent); height: 28px; }

/* Toggle switch */
.switch {
  width: 46px; height: 28px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: none;
  position: relative;
  transition: background .2s ease;
}
.switch.is-on { background: var(--positive); }
.switch__knob {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / .3);
  transition: transform .2s ease;
}
.switch.is-on .switch__knob { transform: translateX(18px); }

/* Form actions */
.form-actions { display: flex; flex-direction: column; gap: 10px; }
.radio-row { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.radio-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.radio-row + .radio-row { border-top: 1px solid var(--border); }

/* Settings nav rows */
.nav-row { grid-template-columns: 1fr auto; }
.nav-row .row { gap: 10px; }
.nav-row .icon { color: var(--text-muted); }

/* Dashboard hero */
.hero { text-align: left; }
.hero__amount { margin: 4px 0; }
.hero__amount .money { align-items: flex-start; }
.hero__meta { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.delta { font-weight: 600; font-size: 13px; }
.delta--down { color: var(--positive); }
.delta--up { color: var(--negative); }
.link-muted { font-size: 13px; color: var(--accent); font-weight: 500; }

/* Payer stacked bar */
.payer-bar__track {
  display: flex; height: 14px; border-radius: var(--radius-pill);
  overflow: hidden; background: var(--surface-2);
}
.payer-bar__seg { height: 100%; }
.payer-bar__seg.seg--arthur { background: var(--arthur); }
.payer-bar__seg.seg--carolina { background: var(--carolina); }
.payer-bar__seg.seg--split { background: var(--split); }
.payer-bar__legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.payer-bar__key { font-size: 12px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 5px; }
.payer-bar__key b { color: var(--text); font-variant-numeric: var(--tabnums); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--split); }
.dot--arthur { background: var(--arthur); }
.dot--carolina { background: var(--carolina); }
.dot--split { background: var(--split); }
.dot-icon { color: var(--text-muted); display: inline-flex; }

/* Budget rows */
.budget-row { padding: 10px 0; }
.budget-row + .budget-row { border-top: 1px solid var(--border); }
.budget-row__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.budget-row__name { font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.budget-row__name .icon { color: var(--text-muted); }
.budget-row__num { font-size: 13px; font-weight: 600; font-variant-numeric: var(--tabnums); }
.budget-row__foot { font-size: 12px; margin-top: 5px; font-variant-numeric: var(--tabnums); }
#budget-list.is-dimmed { opacity: .4; pointer-events: none; }

/* Segmented view control (sticky under header) */
.segmented--view { position: sticky; top: calc(var(--header-h) + var(--safe-top)); z-index: 15; }
.segmented--view .segmented__opt { border: none; background: none; }
.segmented--view .segmented__opt.is-selected { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }

/* Fixed vs one-off split */
.split-bar { display: flex; height: 16px; border-radius: var(--radius-pill); overflow: hidden; background: var(--surface-2); }
.split-bar__seg { height: 100%; transition: width .35s cubic-bezier(.4,0,.2,1); }
.split-bar__seg--fixed { background: var(--accent); }
.split-bar__seg--oneoff { background: var(--carolina); }
.split-legend { display: flex; gap: 18px; margin-top: 12px; flex-wrap: wrap; }
.split-legend__item { font-size: 13px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.split-legend__item b { color: var(--text); font-variant-numeric: var(--tabnums); }
.dot--fixed { background: var(--accent); }
.dot--oneoff { background: var(--carolina); }

/* Type filter (all / fixed / one-off) */
.type-filter { display: inline-flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: var(--radius-pill); margin-bottom: 14px; }
.type-filter__btn {
  position: relative;
  border: none; background: none; border-radius: var(--radius-pill);
  padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--text-muted);
  transition: color .15s ease, background .15s ease;
}
.type-filter__btn.is-selected { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
/* 4px gap between buttons: keep horizontal growth small to avoid overlap,
   grow vertically toward ~44px. */
.type-filter__btn::after { content: ""; position: absolute; inset: -8px -1px; }

/* Discreet view switcher (in a card title) */
.view-switch { display: inline-flex; gap: 2px; }
.view-switch__btn {
  position: relative;
  display: grid; place-items: center;
  width: 30px; height: 26px;
  border: none; background: none; border-radius: 7px;
  color: var(--text-muted); opacity: .55;
  transition: opacity .15s ease, color .15s ease, background .15s ease;
}
.view-switch__btn:active { transform: scale(.92); }
/* These pack tightly (2px gap), so grow mostly vertically to approach 44px
   without overlapping the neighboring button's hit zone. */
.view-switch__btn::after { content: ""; position: absolute; inset: -9px -1px; }
.view-switch__btn.is-active { color: var(--accent); opacity: 1; background: var(--accent-soft); }

.catview { min-height: 40px; }

/* Ranked horizontal bars (magnitude view) */
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar__head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.hbar__name { font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 7px;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar__val { font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: var(--tabnums); flex: none; }
.hbar__val em { color: var(--text-muted); font-style: normal; font-weight: 500; margin-left: 2px; }
.hbar__track { height: 10px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; }
.hbar__fill { height: 100%; border-radius: var(--radius-pill); transition: width .35s cubic-bezier(.4,0,.2,1); }
/* Drill-down affordance: clickable category rows (bars + donut legend) */
.hbar.is-clickable { cursor: pointer; border-radius: 8px; margin: -4px; padding: 4px; transition: background .15s; }
.hbar.is-clickable:hover, .donut-legend__row.is-clickable:hover { background: var(--surface-2); }
.hbar.is-clickable:focus-visible, .donut-legend__row.is-clickable:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px;
}
.donut-legend__row.is-clickable:hover { border-radius: 8px; }

/* Donut */
.donut { display: flex; flex-direction: column; gap: 16px; }
.donut__canvas-wrap { position: relative; height: 220px; }
.donut__center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.donut__total { font-size: 20px; font-weight: 700; font-variant-numeric: var(--tabnums); }
.donut__eur { font-size: 12px; color: var(--text-muted); }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.donut-legend__row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 8px 0; font-size: 14px; cursor: pointer;
}
.donut-legend__row + .donut-legend__row { border-top: 1px solid var(--border); }
.donut-legend__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend__val { font-variant-numeric: var(--tabnums); font-weight: 500; }
.donut-legend__val em { color: var(--text-muted); font-style: normal; font-size: 12px; margin-left: 4px; }
.empty-inline { text-align: center; padding: 24px 0; }

/* Evolution */
.evolution { height: 200px; }
.chip-legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 14px; }
.chip-legend__item { font-size: 12px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }

/* Filters row */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip--filter { flex: none; border: 1px solid var(--border); background: var(--surface); }
.chip--filter.is-active { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip--filter.chip--arthur.is-active { color: var(--arthur); }
.chip--filter.chip--carolina.is-active { color: var(--carolina); }
.chip--filter.chip--split.is-active { color: var(--split); }

/* Day-grouped list */
.day-group__head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 4px 4px 8px;
}
.day-group__date { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: capitalize; }
.day-group__total { font-size: 13px; color: var(--text-muted); font-variant-numeric: var(--tabnums); }
.list-row--skipped { opacity: .45; }
.badge {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .03em;
}
.icon--muted { color: var(--text-muted); opacity: .7; }
a.list-row { color: inherit; }
a.list-row:active { background: var(--surface-2); }

/* Amount entry (new-expense hero) */
.amount-entry { text-align: center; padding: 16px 0 8px; }
.amount-entry__display {
  display: inline-flex; align-items: baseline; justify-content: center; gap: 4px;
  font-variant-numeric: var(--tabnums);
}
.amount-entry__currency { font-size: 28px; font-weight: 600; color: var(--text-muted); }
.amount-entry__input {
  border: none; background: none; outline: none;
  font-size: 44px; font-weight: 700; letter-spacing: -.02em;
  width: 100%; max-width: 6em; text-align: center;
  color: var(--text); padding: 0;
}
.amount-entry__input::placeholder { color: var(--border); }
.amount-entry__eur { min-height: 20px; margin-top: 4px; color: var(--text-muted); font-size: 15px; font-variant-numeric: var(--tabnums); }

/* Category grid */
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat-grid__opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 4px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); cursor: pointer;
  text-align: center;
}
.cat-grid__opt input { position: absolute; opacity: 0; pointer-events: none; }
.cat-grid__icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  color: var(--cat-color); background: color-mix(in srgb, var(--cat-color) 16%, transparent); }
.cat-grid__name { font-size: 11px; line-height: 1.2; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.cat-grid__opt:has(input:checked) { border-color: var(--cat-color); background: color-mix(in srgb, var(--cat-color) 8%, var(--surface)); }
.cat-grid__opt:has(input:checked) .cat-grid__name { color: var(--text); font-weight: 600; }

/* Date chips */
.date-chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip--date { position: relative; border: 1px solid var(--border); background: var(--surface); cursor: pointer; height: 34px; }
.chip--date.is-active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
/* ~44px tap target. Horizontal extension is capped at half the row's 8px
   gap so neighboring chips' hit zones meet without overlapping. */
.chip--date::after { content: ""; position: absolute; inset: -5px -4px; }
.date-input {
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 4px 12px; height: 34px; background: var(--surface); color: var(--text);
  font-size: 14px;
}

/* Form header with close button */
.app-header__inner--form { justify-content: space-between; }

/* Sticky save + expense form spacing */
.expense-form { display: flex; flex-direction: column; gap: var(--gutter); padding-bottom: 88px; }
.sticky-save {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px var(--gutter);
  padding-bottom: calc(12px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 25;
}
.sticky-save .btn { max-width: 640px; margin: 0 auto; }
.danger-zone { display: flex; flex-direction: column; gap: 8px; }

.toast-stack {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 6px 20px rgb(31 28 24 / .18);
  border: 1px solid var(--border);
  font-size: 14px;
  animation: toast-in .25s ease;
}
.toast--error { border-left: 3px solid var(--negative); }
.toast--success { border-left: 3px solid var(--positive); }
.toast.is-leaving { opacity: 0; transition: opacity .3s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .icon { color: var(--text-muted); opacity: .6; }
.empty-state h2 { color: var(--text); font-size: 20px; }

/* --- 5. Screens ---------------------------------------------------------- */
.login {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  max-width: 360px;
  margin: 0 auto;
  padding: 24px;
}
.login__brand { text-align: center; }
.login__logo {
  display: inline-grid; place-items: center;
  width: 72px; height: 72px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 12px;
}
.login__brand h1 { font-size: 24px; }
.login__avatars { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 4px; }
.avatar-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text);
  font-size: 14px; font-weight: 600;
}
.avatar-btn.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.avatar-btn:active { transform: scale(.97); }
.login__form { display: flex; flex-direction: column; gap: 4px; }
.login__form .btn { margin-top: 16px; }
.login__lang { text-align: center; color: var(--text-muted); display: flex; gap: 10px; justify-content: center; }
.login__lang a.is-active { color: var(--accent); font-weight: 600; }

/* --- 6. Utilities -------------------------------------------------------- */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.row { display: flex; align-items: center; gap: 12px; }
.row--between { justify-content: space-between; }
.mt-0 { margin-top: 0; }
.hidden { display: none !important; }
