/* =====================================================================
   app.css — SplitKar app-specific styles that extend (never override)
   base.css. base.css owns the design system + tokens; this file adds the
   app-shell chrome the design system doesn't already ship: the bottom tab
   bar, the group/emoji/color pickers, the row overflow menu, the sample
   banner, member chips, and the "you" badge. All colors come from tokens
   so both themes stay correct.
   ===================================================================== */

/* Leave room above the bottom tab bar so the FAB and content never hide
   behind it. Applied only inside a group (body[data-view="group"]). */
body[data-view="group"] .content {
  padding-bottom: calc(64px + var(--sp-6) + env(safe-area-inset-bottom, 0px));
}

/* Topbar icon buttons (back arrow, overflow, theme) — square 44px taps. */
.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  flex: 0 0 auto;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: var(--r-input);
  cursor: pointer;
}
.iconbtn:hover { background: var(--accent-soft); }
.iconbtn svg { width: 22px; height: 22px; display: block; }
@media (prefers-reduced-motion: no-preference) {
  .iconbtn { transition: background-color var(--dur-fast) var(--ease); }
  .iconbtn:active { transform: scale(0.94); }
}

.topbar .title.title--truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Home brand lockup — split logo mark + wordmark (mirrors Kagaz's .brand). */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text);
  text-decoration: none;
  border-radius: var(--r-input);
  padding: var(--sp-1) var(--sp-1);
}
.brand svg { display: block; }
.brand__word {
  font-size: var(--fs-20);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------------
   Bottom tab bar — Expenses / Balances / Analytics / Group.
   Only rendered inside a group.
   --------------------------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 25;
  width: 100%;
  max-width: var(--content-max);
  display: flex;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar__tab {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: var(--sp-2) var(--sp-1);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.tabbar__tab svg { width: 24px; height: 24px; display: block; }
.tabbar__tab[aria-selected="true"] { color: var(--accent); }
.tabbar__tab[aria-selected="true"] .tabbar__label { font-weight: 700; }
@media (prefers-reduced-motion: no-preference) {
  .tabbar__tab { transition: color var(--dur-fast) var(--ease); }
  .tabbar__tab:active { transform: scale(0.94); }
}

/* When the tab bar is present, lift the FAB above it. */
body[data-view="group"] .fab {
  bottom: calc(64px + var(--sp-3) + env(safe-area-inset-bottom, 0px));
}

/* ---------------------------------------------------------------------
   Group avatar — emoji on a colored tile (color from the 8 avatar hues).
   --------------------------------------------------------------------- */
.gavatar {
  --gav-h: 240;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  flex: 0 0 auto;
  border-radius: var(--r-input);
  font-size: var(--fs-20);
  line-height: 1;
  background: hsl(var(--gav-h) 70% 90%);
}
.gavatar--lg { width: 56px; height: 56px; font-size: var(--fs-24); border-radius: var(--r-card); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .gavatar { background: hsl(var(--gav-h) 40% 24%); }
}
:root[data-theme="dark"] .gavatar { background: hsl(var(--gav-h) 40% 24%); }

/* ---------------------------------------------------------------------
   Page section headers + "you" badge + meta pills.
   --------------------------------------------------------------------- */
.section-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-6) 0 var(--sp-2);
  font-size: var(--fs-13);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text-faint);
}
.section-head:first-child { margin-top: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px var(--sp-2);
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
}
.pill--muted { background: var(--gray-100); color: var(--text-muted); }

/* ---------------------------------------------------------------------
   Row overflow menu (per-group / per-member kebab).
   --------------------------------------------------------------------- */
.menu {
  position: fixed;
  z-index: 55;
  min-width: 180px;
  padding: var(--sp-1);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  box-shadow: var(--shadow-2);
}
.menu__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-3);
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-15);
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
}
.menu__item:hover { background: var(--accent-soft); }
.menu__item svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--text-muted); }
.menu__item--danger { color: var(--danger); }
.menu__item--danger svg { color: var(--danger); }
.menu__item--danger:hover { background: var(--danger-bg); }

/* ---------------------------------------------------------------------
   Emoji + color pickers (create/edit group sheet).
   --------------------------------------------------------------------- */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--sp-2);
}
.emoji-grid__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-input);
  font-size: var(--fs-20);
  cursor: pointer;
}
.emoji-grid__btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

.color-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.color-dot {
  width: var(--tap);
  height: var(--tap);
  border: 2px solid transparent;
  border-radius: 50%;
  background: hsl(var(--dot-h) 70% 55%);
  cursor: pointer;
  padding: 0;
}
.color-dot[aria-pressed="true"] {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px hsl(var(--dot-h) 70% 55%);
}

/* Live preview inside the group sheet. */
.group-preview {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-card);
  margin-bottom: var(--sp-4);
}

/* ---------------------------------------------------------------------
   Member chip / row bits.
   --------------------------------------------------------------------- */
.member-upi {
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------
   Sample banner (first-run onboarding).
   --------------------------------------------------------------------- */
.banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--r-card);
  font-size: var(--fs-13);
}
.banner .banner__text { flex: 1 1 auto; }
.banner .banner__close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap); height: var(--tap); /* >=44px touch target (was 32px) */
  margin: calc(var(--sp-1) * -1) calc(var(--sp-2) * -1) calc(var(--sp-1) * -1) 0; /* absorb the extra size so banner height is unchanged */
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 50%;
  cursor: pointer;
}
.banner .banner__close:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.banner .banner__close svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------------
   Sheet footer action row (sticky-feeling submit area).
   --------------------------------------------------------------------- */
.sheet-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-6);
}
.sheet-actions .btn { flex: 1 1 0; }

/* Group/member rows that pair a navigating button with a trailing kebab: the wrapper
   carries the divider so the last one drops it, matching .list-row:last-child. */
.list--card > .list-row-wrap:last-child { border-bottom: none !important; }

/* Trailing chevron glyph for list rows that navigate. */
.chev { color: var(--text-faint); }
.chev svg { width: 20px; height: 20px; display: block; }

/* Small helper: right-aligned trailing metadata (member count etc). */
.list-row .trail .count { color: var(--text-muted); font-size: var(--fs-13); }

/* Home header greeting */
.home-hero { margin-bottom: var(--sp-4); }
.home-hero .home-title { font-size: var(--fs-24); font-weight: 700; letter-spacing: -0.01em; }
.home-hero .home-sub { color: var(--text-muted); font-size: var(--fs-15); }

/* Group settings: stacked cards spacing */
.settings-block + .settings-block { margin-top: var(--sp-6); }

/* =====================================================================
   A3 — Expenses feed + add/edit expense form.
   ===================================================================== */

/* ---- Sticky summary header (Total spent + count + filter button) ---- */
.exp-summary {
  position: sticky;
  top: 56px; /* under the app topbar */
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  margin: calc(var(--sp-4) * -1) calc(var(--sp-4) * -1) var(--sp-4);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.exp-summary__label { font-size: var(--fs-13); color: var(--text-muted); font-weight: 600; }
.exp-summary__amt { font-size: var(--fs-24); font-weight: 700; letter-spacing: -0.01em; }
.exp-summary__count { grid-column: 1 / 2; font-size: var(--fs-13); margin-top: -2px; }
.filter-btn {
  grid-row: 1 / 3;
  grid-column: 2;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-13);
  font-weight: 600;
  cursor: pointer;
}
.filter-btn.is-active { border-color: var(--accent); color: var(--accent-soft-text); background: var(--accent-soft); }
.filter-btn svg { width: 18px; height: 18px; }

/* ---- Active filter chips row ---- */
.filter-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); align-items: center; }
.active-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: var(--fs-13);
  font-weight: 600;
}
.active-chip__x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border: none;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: inherit;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}
.active-chip__x svg { width: 14px; height: 14px; }
.chip-clear {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-13);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  min-height: 32px;
  padding: 0 var(--sp-2);
}

/* ---- Day-grouped feed ---- */
.exp-feed { display: flex; flex-direction: column; gap: var(--sp-2); }
.day-head {
  margin: var(--sp-4) 0 var(--sp-1);
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.day-head:first-child { margin-top: 0; }

.exp-row { align-items: center; }
.cat-lead { color: var(--accent-soft-text); }
.cat-lead svg { width: 22px; height: 22px; }
.exp-row__right { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.exp-row__amt { font-size: var(--fs-15); font-weight: 700; font-variant-numeric: tabular-nums; }
.inv-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--sp-2);
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.inv-chip--lent { background: var(--success-bg); color: var(--on-success); }
.inv-chip--owed { background: var(--danger-bg);  color: var(--on-danger); }

/* ---- Detail sheet ---- */
.detail-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.detail-block { margin-top: var(--sp-4); }
.detail-label {
  font-size: var(--fs-13);
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-2);
}
.detail-row { cursor: default; gap: var(--sp-3); }
.detail-row__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-row__amt { flex: 0 0 auto; font-weight: 700; }
.detail-note { color: var(--text-muted); font-size: var(--fs-15); }

/* =====================================================================
   Expense form.
   ===================================================================== */
.exp-form { padding-bottom: var(--sp-2); }
.field-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-1); }
.field-head .label { margin-bottom: 0; }
.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: var(--fs-13);
  font-weight: 700;
  cursor: pointer;
  padding: var(--sp-1) var(--sp-2);
  border-radius: 8px;
  min-height: 32px;
}
.link-btn:hover { background: var(--accent-soft); }

/* Single-payer picker button (tap to change) */
.payer-picker {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-input);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.payer-picker__name { flex: 1 1 auto; font-weight: 600; }
.payer-picker__amt { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.payer-picker .chev { color: var(--text-faint); display: inline-flex; }

/* Single-select picker sheet list */
.picker-list { display: flex; flex-direction: column; gap: 2px; }
.picker-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-3);
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  border-radius: var(--r-input);
  cursor: pointer;
}
.picker-item:hover { background: var(--accent-soft); }
.picker-item.is-selected { background: var(--accent-soft); }
.picker-item__name { flex: 1 1 auto; text-align: left; font-weight: 600; }
.picker-item__check { color: var(--accent); display: inline-flex; }

/* Split / payer member rows */
.split-list { display: flex; flex-direction: column; }
.split-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 52px;
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border);
}
.split-list > .split-row:last-child { border-bottom: none; }
.split-row.is-off { opacity: 0.5; }
.split-row__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.split-row__amt { flex: 0 0 auto; color: var(--text-muted); font-variant-numeric: tabular-nums; font-weight: 600; min-width: 72px; text-align: right; }
.row-check { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }

/* Mini amount / percent inputs inside split rows */
.input-amount--mini { flex: 0 0 auto; width: 108px; min-height: 40px; }
.input-amount--mini > .prefix { font-size: var(--fs-15); padding: 0 2px 0 var(--sp-2); }
.mini-amount {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  border: none;
  background: transparent;
  padding: var(--sp-1) var(--sp-2) var(--sp-1) 2px;
  font-size: var(--fs-15);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: right;
}
.mini-amount:focus { outline: none; }
.mini-amount:disabled { color: var(--text-faint); }
.input-amount--pct { width: 84px; padding-right: 0; }
.input-amount--pct > .mini-amount { text-align: right; padding-right: 2px; }
.input-amount--pct > .suffix { padding: 0 var(--sp-2) 0 0; color: var(--text-muted); font-weight: 600; }

/* Shares stepper */
.stepper { display: inline-flex; align-items: center; gap: var(--sp-2); flex: 0 0 auto; }
.stepper__btn {
  width: var(--tap); height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  font-size: var(--fs-20);
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.stepper__btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.stepper__val { min-width: 20px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Reconcile indicator (remaining / balanced / over) */
.reconcile {
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-input);
  font-size: var(--fs-13);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--gray-100);
  color: var(--text-muted);
}
.reconcile--ok  { background: var(--success-bg); color: var(--on-success); }
.reconcile--bad { background: var(--warn-bg);    color: var(--on-warn); }

/* Category chip row (form + filter sheet) */
.chip-row { display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: var(--sp-1); -webkit-overflow-scrolling: touch; }
.chip-row--wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-13);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chip svg { width: 16px; height: 16px; color: var(--text-muted); }
.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-soft-text);
}
.chip[aria-pressed="true"] svg { color: var(--accent-soft-text); }

@media (prefers-reduced-motion: no-preference) {
  .chip, .stepper__btn, .filter-btn, .payer-picker { transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
  .stepper__btn:active { transform: scale(0.9); }
}

/* =====================================================================
   A4 — Balances + settle-up.
   ===================================================================== */

/* ---- Balance rows (per-member net) ---- */
.bal-row { align-items: center; }
.bal-row .body { min-width: 0; }
.bal-row__phrase { font-size: var(--fs-13); color: var(--text-muted); }
.bal-row__amt {
  flex: 0 0 auto;
  font-size: var(--fs-17);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 84px;
}
.bal-row__amt.is-settled { font-size: var(--fs-13); font-weight: 600; color: var(--text-faint); }
/* Highlight the "you" row subtly with the accent. */
.bal-row--me {
  background: color-mix(in srgb, var(--accent-soft) 60%, transparent);
  border-left: 3px solid var(--accent);
  padding-left: calc(var(--sp-3) - 3px);
}
.bal-row--me .row-title { color: var(--accent-soft-text); }

/* ---- Suggested-settlement hint + rows ---- */
.settle-hint { margin: 0 0 var(--sp-2); }
.settle-row { align-items: center; gap: var(--sp-3); }
.settle-row__avatars { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 2px; }
.settle-row__arrow { display: inline-flex; align-items: center; color: var(--text-faint); }
.settle-row__arrow svg { width: 16px; height: 16px; }
.settle-row__text { font-weight: 500; }
.settle-row__text strong { font-weight: 700; }
.settle-row .body { flex: 1 1 auto; min-width: 0; }
.settle-btn { flex: 0 0 auto; min-height: var(--tap); padding: 0 var(--sp-4); font-size: var(--fs-13); }

/* ---- Settle sheet ---- */
.settle-sheet { padding-bottom: var(--sp-2); }
.settle-head {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
.settle-head__party {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 0 1 auto;
  text-align: center;
  min-width: 0;
}
.settle-head__name { font-weight: 700; font-size: var(--fs-15); max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settle-head__arrow { align-self: center; color: var(--accent); display: inline-flex; padding-top: 18px; }
.settle-head__arrow svg { width: 22px; height: 22px; }

.settle-pay { margin-top: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.settle-upi-link { text-decoration: none; }
.settle-over { margin-top: var(--sp-2); }

/* QR block — always light so it scans regardless of theme. */
.settle-qr-toggle { align-self: center; }
.settle-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.settle-qr .qr-svg { width: 200px; height: 200px; display: block; }
.settle-qr__cap { text-align: center; }

.settle-noupi {
  padding: var(--sp-4);
  background: var(--warn-bg);
  color: var(--text);
  border-radius: var(--r-card);
}
.settle-mark { margin-top: var(--sp-4); }

/* ---- Settlement rows in the Expenses feed (distinct from expenses) ---- */
.settle-feed-row { align-items: center; }
.settle-feed-lead { color: var(--on-success); }
.settle-feed-lead svg { width: 22px; height: 22px; }
.settle-feed-row .row-title { font-weight: 500; }
.settle-feed-row .row-title strong { font-weight: 700; }
.settle-feed-amt { color: var(--on-success); }

/* =====================================================================
   A5 — Analytics, share, import, export.
   All colors from tokens; both themes correct; motion guarded.
   ===================================================================== */

/* ---- Analytics: stat cards ---- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-3);
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--sp-4);
}
.stat-card__label {
  font-size: var(--fs-13);
  color: var(--text-muted);
  margin-bottom: var(--sp-1);
}
.stat-card__value {
  font-size: var(--fs-20);
  font-weight: 700;
  color: var(--text);
}

/* ---- Analytics: donut ---- */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
}
.donut-ring {
  position: relative;
  width: 200px;
  height: 200px;
}
.donut-svg { display: block; width: 200px; height: 200px; }
.donut-hole {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.donut-hole__label { font-size: var(--fs-13); color: var(--text-muted); }
.donut-hole__amt { font-size: var(--fs-20); font-weight: 700; color: var(--text); }

.donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-1);
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}
.legend-item:last-child { border-bottom: none; }
.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--swatch, var(--accent));
  flex: 0 0 auto;
}
.legend-icon { display: inline-flex; color: var(--text-muted); flex: 0 0 auto; }
.legend-name { flex: 1 1 auto; min-width: 0; font-size: var(--fs-15); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-amt { font-size: var(--fs-15); font-weight: 600; color: var(--text); }
.legend-pct { font-size: var(--fs-13); min-width: 4ch; text-align: right; }

/* ---- Analytics: member comparison bars ---- */
.member-bars {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.member-bar-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--sp-4);
}
.member-bar-block.is-me { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.member-bar-head { margin-bottom: var(--sp-3); }
.member-bar-name { font-weight: 700; font-size: var(--fs-15); color: var(--text); }
.bar-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.bar-row + .bar-row { margin-top: var(--sp-2); }
.bar-label {
  flex: 0 0 auto;
  width: 4.5ch;
  font-size: var(--fs-13);
  color: var(--text-muted);
}
.bar-track {
  flex: 1 1 auto;
  height: 14px;
  border-radius: 999px;
  background: var(--gray-100, color-mix(in srgb, var(--border) 60%, transparent));
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 500ms cubic-bezier(.2,.8,.2,1);
}
.bar-fill--paid { background: var(--accent); }
.bar-fill--share { background: var(--border-strong); }
.bar-amt {
  flex: 0 0 auto;
  min-width: 7ch;
  text-align: right;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text);
}

/* ---- Share sheet ---- */
.share-sheet .share-url-row {
  display: flex;
  gap: var(--sp-2);
  align-items: stretch;
}
.share-url {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-13);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
.share-hint {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  padding: var(--sp-3);
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  border-radius: var(--r-input);
  font-size: var(--fs-13);
  line-height: var(--lh);
}
.share-hint svg { flex: 0 0 auto; margin-top: 1px; }

/* ---- "How sharing works" — empty-state note, link-style button, explainer sheet ---- */
.empty-note {
  margin-top: var(--sp-5);
  max-width: 40ch;
  font-size: var(--fs-13);
  line-height: var(--lh);
  color: var(--text-muted);
  text-align: center;
}
/* A button that reads as an inline text link (accent, underline on hover). */
.linklike {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.linklike:hover { text-decoration: underline; text-underline-offset: 2px; }
.linklike:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.how-share__p { line-height: 1.55; color: var(--text-muted); }
.how-share__p strong { color: var(--text); }

/* ---- Share/export action stack (Group tab) ---- */
.share-export-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* ---- Import screen ---- */
.import-wrap { display: flex; flex-direction: column; gap: var(--sp-4); }
.import-loading { padding: var(--sp-8) 0; text-align: center; }
.import-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.import-head__body { min-width: 0; }
.import-head__name {
  font-size: var(--fs-20);
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.import-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.import-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--sp-4);
}
.import-stat__label { font-size: var(--fs-13); color: var(--text-muted); margin-bottom: 2px; }
.import-stat__value { font-size: var(--fs-17); font-weight: 700; color: var(--text); }
.import-members {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.import-member-chip {
  padding: 4px var(--sp-3);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: var(--fs-13);
  font-weight: 600;
}
.import-conflict {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--warn-bg);
  color: var(--text);
  border-radius: var(--r-input);
  font-size: var(--fs-13);
  line-height: var(--lh);
}
.import-conflict svg { flex: 0 0 auto; margin-top: 1px; color: var(--warn); }
.import-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.import-error { padding-top: var(--sp-8); }

/* ---------------------------------------------------------------------
   Privacy & data sheet (L1) — reassurance copy + an opt-out toggle.
   --------------------------------------------------------------------- */
.privacy-sheet { display: flex; flex-direction: column; gap: var(--sp-4); }
.privacy-copy {
  margin: 0;
  font-size: var(--fs-15);
  line-height: var(--lh);
  color: var(--text);
}
.privacy-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  cursor: pointer;
}
.privacy-toggle__label { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.privacy-toggle__title { font-size: var(--fs-15); font-weight: 600; color: var(--text); }
.privacy-toggle__sub { font-size: var(--fs-13); line-height: var(--lh); }
/* Visually-hidden native checkbox drives state + focus; the track/thumb render it. */
.privacy-toggle__input {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}
.privacy-toggle__track {
  flex: 0 0 auto;
  position: relative;
  width: 44px; height: 26px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 160ms ease;
}
.privacy-toggle__thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 160ms ease;
}
.privacy-toggle__input:checked ~ .privacy-toggle__track { background: var(--accent-solid); }
.privacy-toggle__input:checked ~ .privacy-toggle__track .privacy-toggle__thumb { transform: translateX(18px); }
.privacy-toggle__input:focus-visible ~ .privacy-toggle__track {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

/* ---- Reduced motion: no bar/donut animation ---- */
@media (prefers-reduced-motion: reduce) {
  .bar-fill { transition: none; }
  .donut-svg path { transition: none !important; }
  .privacy-toggle__track, .privacy-toggle__thumb { transition: none; }
}

/* ---------------------------------------------------------------------
   Credit UI (Phase L3) — DORMANT at launch. These styles only apply when
   credits.js CONFIG.CREDITS_ENABLED is true (the JS returns null otherwise,
   so nothing carrying these classes is ever inserted while dormant). All
   colors come from tokens so both themes stay correct.
   --------------------------------------------------------------------- */

/* Top-bar meter: a subtle coin glyph + the balance count. */
.credit-meter {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  height: 32px;
  padding: 0 var(--sp-2);
  margin-right: var(--sp-1);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: var(--fs-13);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.credit-meter__icon { display: inline-flex; }
.credit-meter__icon svg { width: 18px; height: 18px; display: block; }
/* Low balance: shift the meter to the warn accent so it reads as a gentle heads-up. */
.credit-meter--low {
  background: var(--warn-bg);
  color: var(--warn);
}

/* Home-screen low-balance nudge — a dismissible CARD (never a modal, never mid-task). */
.credit-nudge {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  background: var(--warn-bg);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-radius: var(--r-card);
  font-size: var(--fs-13);
}
.credit-nudge__icon { flex: 0 0 auto; color: var(--warn); display: inline-flex; }
.credit-nudge__icon svg { width: 22px; height: 22px; }
.credit-nudge__body { flex: 1 1 auto; min-width: 0; }
.credit-nudge__title { font-size: var(--fs-15); font-weight: 700; }
.credit-nudge__sub { color: var(--text-muted); margin-top: 2px; }
.credit-nudge__actions { margin-top: var(--sp-2); }
.credit-nudge__close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap); height: var(--tap); /* >=44px touch target */
  margin: calc(var(--sp-1) * -1) calc(var(--sp-2) * -1) calc(var(--sp-1) * -1) 0;
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 50%;
  cursor: pointer;
}
.credit-nudge__close:hover { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.credit-nudge__close svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------------
   Family footer (L4) — small, muted, centered; HOME view only. Wraps
   gracefully at 375px. Brand links use the accent + underline-on-hover.
   Tokens only; light/dark parity is automatic.
   --------------------------------------------------------------------- */
/* Sticky footer — home is the only screen with a footer; make its content a flex column so
   the footer pins to the bottom of the viewport rather than floating under a short list.
   Scoped via :has so no other screen's layout changes. */
.content:has(.app-footer) {
  display: flex;
  flex-direction: column;
  /* Reserve room for the bottom-right FAB ("+ New group") so the pinned footer's
     right-side links don't sit underneath it. */
  padding-bottom: calc(var(--sp-8) + 3.5rem + env(safe-area-inset-bottom, 0px));
}
.app-footer {
  margin-top: auto; /* push to the bottom of the flex column; collapses to 0 when content is long */
  padding: var(--sp-6) var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--border);
  text-align: center;
}
.app-footer__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1) var(--sp-2);
  font-size: var(--fs-13);
  line-height: 1.6;
  color: var(--text-faint);
}
.app-footer__text { color: var(--text-faint); white-space: nowrap; }
.app-footer__sep { color: var(--text-faint); opacity: 0.6; user-select: none; }
/* Links + link-styled buttons share one look so the row reads as one line. */
.app-footer__link {
  display: inline;
  padding: 2px 1px;
  margin: 0;
  font: inherit;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: var(--r-input);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.app-footer__link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.app-footer__link--brand { color: var(--accent); font-weight: 600; }
.app-footer__link--brand:hover { color: var(--accent-hover, var(--accent)); text-decoration: underline; text-underline-offset: 2px; }
.app-footer__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
   Subscribe opt-in sheet (L4) — email opt-in opened from the footer.
   Reuses the shared .field / .input / .btn components; just the layout.
   --------------------------------------------------------------------- */
.subscribe-sheet { display: flex; flex-direction: column; gap: var(--sp-4); }
.subscribe-copy {
  margin: 0;
  font-size: var(--fs-15);
  line-height: var(--lh);
  color: var(--text);
}
.subscribe-consent {
  margin: 0;
  font-size: var(--fs-13);
  line-height: var(--lh);
}
