/* Light is the base; dark applies with the iPhone setting or when forced in Settings. */
:root {
  --bg: #f4f4f8;
  --card: #ffffff;
  --card-2: #ececf2;
  --text: #121218;
  --muted: #6f6f7a;
  --line: #e4e4ec;
  --accent: #5e5ce6;
  --accent-2: #a35cf0;
  --masha: #ff5f97;
  --maks: #2fa8ff;
  --ok: #24b35a;
  --warn: #f0a20c;
  --bad: #ff4639;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .04), 0 6px 20px rgba(20, 20, 40, .06);
  --edge: transparent;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0b10;
  --card: #18181f;
  --card-2: #25252e;
  --text: #f4f4f7;
  --muted: #9a9aa6;
  --line: rgba(255, 255, 255, .08);
  --accent: #7d7aff;
  --accent-2: #b67cff;
  --shadow: none;
  --edge: rgba(255, 255, 255, .06);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b10;
    --card: #18181f;
    --card-2: #25252e;
    --text: #f4f4f7;
    --muted: #9a9aa6;
    --line: rgba(255, 255, 255, .08);
    --accent: #7d7aff;
    --accent-2: #b67cff;
    --shadow: none;
    --edge: rgba(255, 255, 255, .06);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 100px);
}

.top { display: flex; align-items: center; gap: 4px; padding: 8px 0 14px; }
.top h1 { flex: 1; margin: 0; text-align: center; font-size: 20px; font-weight: 700; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--card); font-size: 22px; line-height: 1;
}
.settings-btn { font-size: 18px; margin-left: 4px; }

.segmented {
  display: flex; padding: 3px; gap: 3px;
  background: var(--card-2); border-radius: 12px; margin-bottom: 10px;
}
.segmented button {
  flex: 1; padding: 8px 6px; border-radius: 9px;
  font-size: 15px; font-weight: 600; color: var(--muted);
}
.segmented button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.15); }

.chips { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 14px; scrollbar-width: none; }
.chips button {
  flex: none; padding: 6px 14px; border-radius: 999px;
  background: var(--card); color: var(--muted); font-size: 14px; font-weight: 600;
}
.chips button.active { background: var(--text); color: var(--bg); }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }

.summary .label { color: var(--muted); font-size: 14px; }
.summary .total { font-size: 34px; font-weight: 800; letter-spacing: -0.5px; margin: 2px 0 12px; }
.split-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--card-2); margin-bottom: 10px; }
.split-bar span { display: block; height: 100%; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.stat .k { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.stat .v { font-weight: 700; font-size: 17px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.balance { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.balance .k { color: var(--muted); font-size: 13px; }
.balance .v { font-weight: 700; }
.pill-btn { padding: 8px 14px; border-radius: 999px; background: var(--card-2); font-size: 14px; font-weight: 600; color: var(--accent); flex: none; }

.tabs { margin-top: 6px; }

.cat-row {
  display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 2px 12px;
  background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; width: 100%; text-align: left;
}
.cat-row .emoji { grid-row: span 2; font-size: 26px; text-align: center; }
.cat-row .name { font-weight: 600; }
.cat-row .sum { font-weight: 700; text-align: right; }
.cat-row .meta { color: var(--muted); font-size: 13px; text-align: right; }
.cat-row .bar { grid-column: 2 / 4; height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; margin-top: 6px; }
.cat-row .bar span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.cat-row .bar span.warn { background: var(--warn); }
.cat-row .bar span.over { background: var(--bad); }

.day { color: var(--muted); font-size: 14px; font-weight: 600; margin: 16px 4px 8px; display: flex; justify-content: space-between; }
.swipe { position: relative; margin-bottom: 6px; border-radius: 14px; overflow: hidden; }
.swipe-del {
  position: absolute; inset: 0 0 0 auto; width: 120px; padding-left: 28px; background: var(--bad); color: #fff; font-weight: 700; font-size: 14px;
}
.entry {
  position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  display: grid; cursor: pointer; grid-template-columns: 40px 1fr auto; align-items: center; gap: 0 12px;
  width: 100%; text-align: left; background: var(--card); padding: 12px 14px;
}
.entry .emoji { font-size: 24px; text-align: center; }
.entry .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .sub { color: var(--muted); font-size: 13px; }
.entry .amt { font-weight: 700; text-align: right; }
.entry .amt small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.entry.settlement .amt, .entry.income .amt { color: var(--ok); }
.tag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--card-2); color: var(--muted); margin-left: 4px; }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }



.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 480px;
  max-height: 92vh; border-radius: 22px 22px 0 0; background: var(--bg); color: var(--text);
}
.sheet::backdrop { background: rgba(0,0,0,.5); }
.sheet form {
  display: flex; flex-direction: column; max-height: 92vh; max-height: 92dvh;
  padding: 14px 16px calc(env(safe-area-inset-bottom) + 12px);
}
.sheet-body { overflow-y: auto; flex: 1 1 auto; min-height: 0; padding-bottom: 8px; }
.sheet-head { display: grid; grid-template-columns: 80px 1fr 80px; align-items: center; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; text-align: center; font-size: 17px; }
.link { color: var(--accent); font-size: 16px; text-align: left; }
.link.strong { font-weight: 700; text-align: right; }
.amount-display { text-align: center; padding: 4px 0 10px; cursor: text; }
#amount-expr { font-size: 44px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.1; word-break: break-all; }
#amount-expr.placeholder { color: var(--muted); }
#amount-result { color: var(--muted); font-size: 17px; font-weight: 600; min-height: 22px; }

.keypad {
  flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding-top: 10px;
}
.keypad button {
  height: 50px; border-radius: 12px; background: var(--card); font-size: 24px; font-weight: 500;
  user-select: none; -webkit-user-select: none;
}
.keypad button:active { background: var(--card-2); }
.keypad button.op { background: var(--card-2); color: var(--accent); font-weight: 600; }
.keypad button.eq { grid-row: span 2; background: var(--accent); color: #fff; height: auto; }
.keypad { display: none; }
.sheet.calc-open .keypad { display: grid; }

.pair { display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; }
.pair .segmented { margin-bottom: 0; }
.pair .segmented button { font-size: 14px; padding: 8px 2px; }

.text-input {
  width: 100%; border: 0; border-radius: 12px; background: var(--card); color: var(--text);
  font: inherit; padding: 12px 14px; outline: none; margin-bottom: 6px; min-height: 46px;
}
.field-label { display: block; color: var(--muted); font-size: 13px; font-weight: 600; margin: 12px 4px 6px; }
.cat-grid {
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, auto); grid-auto-columns: 74px;
  gap: 6px; overflow-x: auto; margin-top: 6px; scrollbar-width: none;
}
.cat-grid button {
  background: var(--card); border-radius: 12px; padding: 8px 2px; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; border: 2px solid transparent;
}
.cat-grid button .e { font-size: 22px; }
.cat-grid button.active { border-color: var(--accent); color: var(--text); }
.danger { width: 100%; margin-top: 18px; padding: 12px; border-radius: 12px; background: var(--card); color: var(--bad); font-weight: 600; }

.limit-row { display: grid; grid-template-columns: 28px 1fr 120px; align-items: center; gap: 10px; margin-bottom: 6px; }
.limit-row .e { font-size: 20px; text-align: center; }
.limit-row input { margin: 0; text-align: right; }

.actions { padding: 10px 16px calc(env(safe-area-inset-bottom) + 14px); background: transparent; }
.actions h2 {
  margin: 0; padding: 14px; text-align: center; font-size: 14px; font-weight: 600; color: var(--muted);
  background: var(--card); border-radius: 14px 14px 0 0; border-bottom: 1px solid var(--line);
}
.actions button { display: block; width: 100%; padding: 16px; background: var(--card); color: var(--accent); font-size: 18px; }
.actions button[data-action=delete] { border-radius: 0 0 14px 14px; border-top: 1px solid var(--line); }
.actions button[data-action=edit][hidden] + .danger-text { border-radius: 0 0 14px 14px; border-top: 0; }
.actions .danger-text { color: var(--bad); }
.actions .cancel { margin-top: 8px; border-radius: 14px; font-weight: 700; }

.toast {
  position: fixed; left: 16px; right: 16px; max-width: 448px; margin: 0 auto;
  bottom: calc(env(safe-area-inset-bottom) + 84px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-radius: 14px; background: var(--text); color: var(--bg); font-size: 15px;
}
.toast[hidden] { display: none; }
.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button { color: var(--accent); font-weight: 700; flex: none; }

.plus { color: var(--ok); }
.minus { color: var(--bad); }
.income-strip {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.income-strip .k { color: var(--muted); font-size: 13px; }
.income-strip .v { font-weight: 700; font-size: 17px; }
.cat-row .bar span.income { background: var(--ok); }
.tag.income { color: var(--ok); }
.sheet.income #amount-expr:not(.placeholder) { color: var(--ok); }
#type-pick { margin-bottom: 8px; }

.muted { color: var(--muted); }
.loan-fields { display: none; }
.sheet.loan .loan-fields { display: block; }
.sheet.loan #cat-grid { display: none; }
.debts-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.debts-head .k { color: var(--muted); font-size: 13px; }
.debt { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.debt-top { display: grid; grid-template-columns: 32px 1fr auto; gap: 0 10px; align-items: center; width: 100%; text-align: left; }
.debt-top .emoji { font-size: 22px; text-align: center; }
.debt .title { font-weight: 600; }
.debt .sub { color: var(--muted); font-size: 13px; }
.debt .amt { font-weight: 700; text-align: right; }
.debt .amt small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.debt-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; align-items: center; }
.debt-actions .text-input { margin: 0; background: var(--card-2); }
#debts-list details summary { color: var(--muted); font-weight: 600; font-size: 14px; padding: 12px 4px; cursor: pointer; }

.top.nested .titles { flex: 1; text-align: center; min-width: 0; }
.top.nested h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top.nested .sub { color: var(--muted); font-size: 13px; }
.icon-btn.spacer { visibility: hidden; }
.chev { color: var(--muted); font-size: 22px; font-weight: 400; line-height: 1; margin-left: 6px; }
.total-btn { display: block; width: 100%; text-align: left; }
.total-btn .label { display: block; color: var(--muted); font-size: 14px; }
.total-btn .total { display: flex; align-items: center; justify-content: space-between; }
.summary.compact .total { margin-bottom: 8px; }
.link-row {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 11px 0; text-align: left;
  border-top: 1px solid var(--line);
}
.link-row .name { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 500; }
.link-row .val { font-weight: 700; }
.note { color: var(--muted); font-size: 13px; padding-top: 10px; border-top: 1px solid var(--line); }
.section-title { font-size: 20px; font-weight: 700; margin: 22px 4px 10px; }
button.card.debts { display: block; width: 100%; text-align: left; }
.debts-head .chev { margin: 0; }

/* pace & comparison */
.pace { display: block; width: 100%; text-align: left; margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line); }
section.card > .pace:first-child { border-top: 0; }
.pace-bar { position: relative; height: 10px; border-radius: 5px; background: var(--card-2); margin: 4px 0 10px; }
.pace-bar .fill { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: var(--ok); }
.pace-bar .fill.warn { background: var(--warn); }
.pace-bar .fill.over { background: var(--bad); }
.pace-bar .marker { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--text); }
.pace-text { font-size: 14px; line-height: 1.4; }
.pace-text .muted { display: block; font-size: 13px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.cmp .k { color: var(--muted); font-size: 12px; }
.cmp .v { font-weight: 700; }
.cmp .v span { font-size: 13px; }
.pace-more { color: var(--accent); font-size: 14px; font-weight: 600; margin-top: 10px; }

/* trend */
.bars { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 180px; margin-top: 12px; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.bar-col .bar-fill { width: 100%; max-width: 36px; border-radius: 6px 6px 2px 2px; background: var(--card-2); min-height: 2px; max-height: 78%; }
.bar-col.current .bar-fill { background: var(--accent); }
.bar-col .bar-val { font-size: 11px; color: var(--muted); }
.bar-col .bar-label { font-size: 12px; color: var(--muted); height: 16px; }
.bar-col.current .bar-label, .bar-col.current .bar-val { color: var(--text); font-weight: 700; }
.avg-line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--muted); opacity: .6; pointer-events: none; }
.cmp-row { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--card); border-radius: 14px; padding: 10px 14px; margin-bottom: 6px; }
.cmp-row .emoji { font-size: 22px; text-align: center; }
.cmp-row .name { font-weight: 600; }
.cmp-row small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.cmp-row .val { font-weight: 700; text-align: right; }
.note.plain { border-top: 0; padding: 0 4px 8px; }
.label.muted { color: var(--muted); font-size: 14px; }

/* donut */
.donut-wrap { position: relative; width: 220px; max-width: 70%; margin: 4px auto 12px; aspect-ratio: 1; }
.donut { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { cursor: pointer; transition: stroke-width .15s, opacity .15s; }
.donut-center { position: absolute; inset: 22%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.donut-center .k { color: var(--muted); font-size: 12px; }
.donut-center .v { font-size: 22px; font-weight: 800; }
.legend-row { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 9px 4px; border-top: 1px solid var(--line); transition: opacity .15s; }
.legend-row .pct { color: var(--muted); font-size: 13px; }
.legend-row .val { font-weight: 700; min-width: 76px; text-align: right; }
.legend-row.dim { opacity: .35; }
.legend-row.selected { font-weight: 700; }

/* goals */
.section-title.row { display: flex; align-items: baseline; justify-content: space-between; }
.section-title.row .link { font-size: 16px; font-weight: 600; }
.card.hint { display: block; width: 100%; text-align: left; color: var(--muted); font-size: 14px; line-height: 1.4; border: 1.5px dashed var(--line); background: transparent; }
.link-row.plain { border-top: 0; padding: 6px 4px; color: var(--muted); }
.link-row.static { cursor: default; }
.link-row.static:first-child { border-top: 0; }
.goal-budget { margin-bottom: 12px; }
.goal-budget .bar { display: block; height: 8px; border-radius: 4px; background: var(--card-2); overflow: hidden; margin-bottom: 6px; }
.goal-budget .bar span { display: block; height: 100%; background: var(--accent); }
.goal-budget .bar span.warn { background: var(--warn); }
.goal-budget .bar span.over { background: var(--bad); }
.goal-budget .note.plain { padding: 0; }
.tag.goal { color: var(--accent); }
.goal-field .chips { margin-bottom: 0; }
.sheet.income .goal-field, .sheet.loan .goal-field { display: none; }
.emoji-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 6px 0; }
.emoji-pick button { font-size: 24px; padding: 8px 0; border-radius: 12px; background: var(--card); border: 2px solid transparent; }
.emoji-pick button.active { border-color: var(--accent); }
.check { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent); }
.check small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.plain-danger { color: var(--accent); }
div.cat-row { cursor: default; }

/* cumulative line chart */
.line-chart { width: 100%; height: auto; margin-top: 8px; overflow: visible; }
.line-chart .grid { stroke: var(--line); stroke-width: 1; }
.line-chart .axis { fill: var(--muted); font-size: 10px; }
.line-chart .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.line-chart .line.cur { stroke: var(--accent); stroke-width: 3; }
.line-chart .line.prev { stroke: var(--muted); opacity: .8; }
.line-chart .line.avg { stroke: var(--muted); stroke-dasharray: 4 4; opacity: .7; }
.line-chart .dot-cur { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.line-legend { display: grid; gap: 6px; margin-top: 8px; font-size: 14px; }
.line-legend .muted { font-size: 12px; }
.line-legend .lg { display: flex; align-items: center; gap: 8px; }
.line-legend .lg b { margin-left: auto; }
.line-legend .sw { width: 18px; height: 0; border-top: 3px solid var(--muted); flex: none; }
.line-legend .sw.cur { border-color: var(--accent); }
.line-legend .sw.avg { border-top-style: dashed; }
.cmp-row { transition: opacity .15s; }
.cmp-row.dim { opacity: .4; }
.cmp-row.selected { outline: 2px solid var(--accent); }
.toast button[hidden] { display: none; }

.net-box { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 4px; border-top: 1px solid var(--line); }
.net-box .k { color: var(--muted); font-size: 12px; }
.net-box .v { font-weight: 700; }
.cat-row .meta b { font-weight: 700; color: var(--text); }
.cat-row .meta b.plus { color: var(--ok); }

/* tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr 1fr 72px 1fr 1fr; align-items: end;
  max-width: 480px; margin: 0 auto;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tabbar [data-tab] { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; }
.tabbar [data-tab] .ti { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabbar [data-tab].active { color: var(--accent); font-weight: 600; }
.tabbar [data-tab].active .ti { filter: none; opacity: 1; }
.fab {
  justify-self: center; width: 56px; height: 56px; margin-top: -22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 32px; font-weight: 300; line-height: 1;
  box-shadow: 0 6px 18px rgba(10,132,255,.45);
}
.tab-title { text-align: left !important; font-size: 30px !important; font-weight: 800 !important; }

/* analytics */
.period-nav { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; }
.period-title { font-weight: 700; font-size: 17px; }
.person-chips { justify-content: center; }
.vs { font-size: 14px; margin-top: 4px; }
.vs.muted { color: var(--muted); }
.delta { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 6px; margin-left: 6px; background: var(--card-2); color: var(--muted); }
.delta.up { color: var(--bad); background: color-mix(in srgb, var(--bad) 15%, transparent); }
.delta.down { color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); }
.donut-wrap { width: 240px; }
.donut .seg { cursor: pointer; stroke-width: 12px; transition: stroke-width .15s, opacity .15s; }
.donut .seg.off { opacity: .28; }
.donut .seg.on { stroke-width: 15px; }
.donut .seg.hover { stroke-width: 17px; opacity: 1; }
.donut .ring { pointer-events: none; }
.pick-row {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left;
  padding: 9px 4px; border-top: 1px solid var(--line); transition: opacity .15s, background .15s; border-radius: 8px;
}
.pick-row .check {
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--c); display: grid; place-items: center;
  font-size: 13px; font-weight: 800; color: #fff;
}
.pick-row.selected .check { background: var(--c); }
.pick-row.selected .name { font-weight: 700; }
.pick-row .name small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.pick-row .val { font-weight: 700; text-align: right; white-space: nowrap; }
.pick-row .val .delta { display: block; width: fit-content; margin: 2px 0 0 auto; }
.pick-row.dim { opacity: .45; }
.pick-row.hover { background: var(--card-2); opacity: 1; }
.chart-wrap { touch-action: pan-y; cursor: crosshair; user-select: none; -webkit-user-select: none; }
.line-chart .scrub { visibility: hidden; pointer-events: none; }
.line-chart .scrub-line { stroke: var(--text); stroke-width: 1; opacity: .5; }
.line-chart .scrub-dot { stroke: var(--card); stroke-width: 2; fill: var(--muted); }
.line-chart .scrub-dot.cur { fill: var(--accent); }
.line-legend .lg.diff { color: var(--muted); }
.line-legend .lg.diff:empty { display: none; }
.hint-line { padding-top: 8px; font-size: 12px; }
.net-box { grid-template-columns: 1fr 1fr; border-top: 0; padding: 0; }

/* savings */
.cat-row .bar span.saving, .goal-budget .bar span.saving { background: var(--ok); }
.op-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.op-buttons .pill-btn { padding: 12px; font-size: 15px; }
.op-row { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; background: var(--card); padding: 12px 14px; border-radius: 14px; margin-bottom: 6px; }
.op-row .title { font-weight: 600; }
.op-row .sub { color: var(--muted); font-size: 13px; }
.op-row .amt { font-weight: 700; }
.link-row.first { border-top: 0; }
.amount-input { width: 100%; border: 0; background: none; color: var(--text); text-align: center; font: 800 40px/1.2 inherit; padding: 8px 0; outline: none; }

/* attachments */
.files { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.files:empty { display: none; }
.file-chip { position: relative; background: var(--card); border-radius: 12px; overflow: hidden; aspect-ratio: 1; }
.file-open { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 0; }
.file-open img { width: 100%; height: 100%; object-fit: cover; }
.file-open .file-icon { font-size: 30px; }
.file-open img + .file-name { display: none; }
.file-name { font-size: 11px; color: var(--muted); padding: 0 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-remove { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 1; }
.attach-btn { display: block; text-align: center; padding: 12px; margin-top: 8px; border-radius: 12px; background: var(--card); color: var(--accent); font-weight: 600; cursor: pointer; }
.entry .amt .clip { font-style: normal; font-size: 13px; margin-right: 4px; }
.viewer { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100%; height: 100%; }
.viewer::backdrop { background: rgba(0,0,0,.9); }
.viewer[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.viewer-body { max-width: 92vw; max-height: 78vh; display: grid; place-items: center; }
.viewer-body img { max-width: 92vw; max-height: 78vh; border-radius: 10px; object-fit: contain; }
.viewer-doc { color: #fff; text-align: center; font-size: 56px; }
.viewer-doc div { font-size: 16px; margin-top: 8px; }
.viewer-doc small { font-size: 13px; opacity: .7; }
.viewer-actions { display: flex; gap: 10px; }
.viewer-actions .pill-btn { text-decoration: none; background: #2c2c2e; color: #fff; }
.link-row .val.muted { font-weight: 500; font-size: 13px; }

/* compact donut centre */
.donut-wrap { width: 210px; max-width: 64%; margin: 0 auto 6px; }
.donut-center { inset: 24%; gap: 1px; overflow: hidden; }
.donut-center .k { font-size: 11px; line-height: 1.25; max-width: 100%; }
.donut-center .k.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.donut-center .v { font-size: 20px; line-height: 1.15; font-weight: 800; white-space: nowrap; }
.donut-center .v.long { font-size: 16px; }
.note.center { text-align: center; padding-bottom: 10px; }

/* category tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tile {
  position: relative; display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0 6px;
  text-align: left; padding: 8px 10px 8px 12px; border-radius: 12px; background: var(--card-2);
  border-left: 4px solid var(--c); transition: opacity .15s, background .15s, transform .15s; min-width: 0;
}
.tile .t-name { grid-column: 1 / 3; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 14px; }
.tile .t-val { font-size: 15px; font-weight: 800; }
.tile .t-meta { font-size: 11px; color: var(--muted); display: flex; align-items: center; justify-content: flex-end; white-space: nowrap; }
.tile .t-meta .delta { margin-left: 4px; font-size: 10px; padding: 0 4px; }
.tile .t-check {
  position: absolute; top: 6px; right: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--c); color: #fff; font-size: 10px; font-weight: 800; display: grid; place-items: center;
}
.tile.selected { background: color-mix(in srgb, var(--c) 22%, var(--card)); }
.tile.dim { opacity: .45; }
.tile.hover { opacity: 1; transform: scale(1.02); }
.legend-more { grid-column: 1 / 3; padding: 8px; color: var(--accent); font-weight: 600; font-size: 14px; }

/* ================= design layer ================= */
html, body { font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
.card, .group, .tile, .op-row, .debt { box-shadow: var(--shadow); border: 1px solid var(--edge); }
.card { border-radius: var(--radius); }
.section-title { font-size: 19px; letter-spacing: -0.2px; }

/* headers */
.home-top { align-items: flex-end; justify-content: space-between; }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.tab-title .year { color: var(--muted); font-weight: 600; }
.month-switch { display: flex; gap: 8px; padding-bottom: 4px; }
.icon-btn { box-shadow: var(--shadow); border: 1px solid var(--edge); color: var(--text); }

/* hero card on the overview */
.card.hero {
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff; border: 0; box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 35%, transparent);
}
.hero .label, .hero .muted, .hero .pace-text .muted, .hero .cmp .k { color: rgba(255, 255, 255, .78); }
.hero .chev { color: rgba(255, 255, 255, .7); }
.hero .split-bar { background: rgba(255, 255, 255, .22); }
.hero .link-row, .hero .pace { border-top-color: rgba(255, 255, 255, .18); }
.hero .dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }
.hero .pace-bar { background: rgba(255, 255, 255, .22); }
.hero .pace-bar .marker { background: #fff; }
.hero .pace-more { color: #fff; }
.hero .delta { background: rgba(255, 255, 255, .2); color: #fff; }
.hero .plus { color: #b9ffcf; }

/* badges for categories, projects and piggy banks */
.badge {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 19px;
  background: color-mix(in srgb, var(--c) 18%, transparent);
}
.cat-row .badge { grid-row: span 2; }

/* grouped lists (iOS inset-grouped style) */
.group { background: var(--card); border-radius: 18px; overflow: hidden; margin-bottom: 8px; }
.group > .swipe, .group > .cat-row, .group > button.cat-row, .group > div.cat-row {
  margin: 0; border-radius: 0; box-shadow: none; border: 0; background: var(--card);
}
.group > * + * { border-top: 1px solid var(--line) !important; }
.group .swipe { border-radius: 0; }
.group .entry { border-radius: 0; }
.cat-row .bar span { background: var(--c, var(--accent)); }
.cat-row .bar span.warn { background: var(--warn); }
.cat-row .bar span.over { background: var(--bad); }
.entry .title { font-size: 15.5px; }
.day { margin: 18px 6px 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }

/* chips & segmented */
.segmented { background: var(--card-2); }
.segmented button.active { box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.chips button { border: 1px solid var(--edge); box-shadow: var(--shadow); }
.chips button.active { background: var(--accent); color: #fff; }

/* tab bar with line icons */
.tabbar [data-tab] svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.tabbar [data-tab] svg .thin { stroke-width: 1.3; opacity: .7; }
.tabbar [data-tab] svg .fill { fill: none; }
.tabbar [data-tab].active svg path, .tabbar [data-tab].active svg rect { fill: color-mix(in srgb, var(--accent) 22%, transparent); }
.tabbar [data-tab].active svg .fill { fill: var(--accent); }
.tabbar [data-tab] { transition: color .15s, transform .15s; }
.tabbar [data-tab]:active { transform: scale(.92); }
.fab { background: linear-gradient(140deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 45%, transparent); }
.fab:active { transform: scale(.94); }
.pill-btn { color: var(--accent); }
.link, .pace-more, .legend-more, .attach-btn { color: var(--accent); }
.tile { box-shadow: none; }

/* compact keypad, shown only after tapping the amount */
.keypad { gap: 6px; padding-top: 8px; }
.keypad button { height: 42px; font-size: 20px; border-radius: 10px; }
.keypad button.eq { font-size: 22px; font-weight: 700; }
.amount-display { border-radius: 14px; margin: 0 auto 6px; padding: 6px 12px 8px; transition: background .15s; }
.amount-display::after { content: "нажмите, чтобы ввести сумму"; display: block; color: var(--muted); font-size: 12px; }
.sheet.calc-open .amount-display { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.sheet.calc-open .amount-display::after { content: "✓ — готово"; color: var(--accent); }
#amount-expr { font-size: 38px; }

/* no clipped tiles: categories wrap into rows */
.cat-grid { grid-auto-flow: row; grid-template-rows: none; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-columns: auto; overflow: visible; }
.cat-grid button { font-size: 10px; padding: 6px 2px; gap: 1px; min-width: 0; }
.cat-grid button .e { font-size: 20px; }
.sheet .chips { flex-wrap: wrap; overflow: visible; }
.tile .t-name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.2; }

/* operations */
.search input {
  width: 100%; border: 1px solid var(--edge); border-radius: 12px; background: var(--card-2); color: var(--text);
  font: inherit; padding: 10px 14px; outline: none; margin-bottom: 4px;
}
.month-head { display: flex; justify-content: space-between; font-size: 20px; font-weight: 800; margin: 22px 4px 0; }
.month-head span:last-child { color: var(--muted); font-weight: 700; font-size: 16px; }
.swipe.flash .entry { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { background: color-mix(in srgb, var(--accent) 28%, var(--card)); } 100% { background: var(--card); } }
.icon-btn.gear svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.icon-btn.gear { display: grid; place-items: center; }

/* limits */
.limit-line { margin: 2px 0 12px; }
.lbar { position: relative; height: 8px; border-radius: 4px; background: var(--card-2); }
.lbar span { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--ok); }
.lbar span.warn { background: var(--warn); }
.lbar span.over { background: var(--bad); }
.lbar i { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 1px; opacity: .7; }
.ltext { font-size: 13px; margin-top: 6px; color: var(--muted); }
.hero .lbar { background: rgba(255, 255, 255, .22); }
.hero .lbar span { background: #b9ffcf; }
.hero .lbar span.warn { background: #ffd66b; }
.hero .lbar span.over { background: #ff9a92; }
.hero .lbar i { background: #fff; }
.hero .ltext { color: rgba(255, 255, 255, .85); }
.link-row .val small { color: var(--muted); font-weight: 500; }
.hero .link-row .val small { color: rgba(255, 255, 255, .7); }
.warn-text { color: var(--warn); }
.limit-row .dot { display: inline-block; }

/* currencies */
.cur-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 2px 8px; }
.cur-line .muted { color: var(--muted); font-size: 13px; font-weight: 600; }
#cur-select {
  font: inherit; font-size: 15px; font-weight: 600; color: var(--text); background: var(--card);
  border: 1px solid var(--edge); border-radius: 10px; padding: 7px 10px; max-width: 70%;
}
.fx-box, .exch-box { display: none; background: var(--card); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; }
.sheet.foreign .fx-box, .sheet.exchange .exch-box { display: block; }
.fx-box .segmented { margin-bottom: 8px; }
.fx-rate { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.fx-rate input {
  flex: 1; min-width: 0; font: inherit; font-weight: 700; color: var(--text); background: var(--card-2);
  border: 0; border-radius: 10px; padding: 8px 10px; outline: none; text-align: right;
}
#fx-refresh { width: 36px; height: 36px; border-radius: 10px; background: var(--card-2); color: var(--accent); font-size: 18px; }
.fx-note { color: var(--muted); font-size: 12px; margin-top: 6px; }
.sheet.exchange #cat-grid, .sheet.exchange .goal-field, .sheet.exchange .pair > div:last-child, .sheet.loan .cur-line { display: none; }
.sheet.exchange .pair { grid-template-columns: 1fr; }
.entry .amt small { white-space: nowrap; }
.wallet-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.wallet-row:first-of-type { border-top: 0; }
.wallet-row .flag { font-size: 20px; }
.wallet-row .name { font-weight: 700; }
.wallet-row .val { font-size: 13px; color: var(--muted); }
.cat-grid button { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.home-top .tab-title { white-space: nowrap; font-size: 28px !important; }
.home-top > div:first-child { min-width: 0; }
.month-switch { flex: none; }

/* activity calendar */
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head span { text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) var(--lvl, 0%), var(--card-2)); padding: 0; line-height: 1.1;
  transition: transform .12s;
}
.cal-cell:active { transform: scale(.92); }
.cal-cell.empty { background: transparent; }
.cal-cell .n { font-size: 13px; font-weight: 700; }
.cal-cell .s { font-size: 9px; opacity: .85; }
.cal-cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-cell.future { opacity: .4; }
.day-nav { display: flex; justify-content: space-between; margin-bottom: 10px; }
.cal-cell.hot { color: #fff; }

/* import */
label.link-row { cursor: pointer; }
.imp-map { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; background: var(--card); border-radius: 14px; padding: 12px; }
.imp-map span { color: var(--muted); font-size: 13px; }
.imp-map select { font: inherit; font-size: 14px; color: var(--text); background: var(--card-2); border: 0; border-radius: 8px; padding: 7px 8px; min-width: 0; }
.imp-preview { background: var(--card); border-radius: 14px; overflow: hidden; }
.imp-row { display: grid; grid-template-columns: 54px 1fr auto; gap: 8px; padding: 9px 12px; font-size: 14px; border-top: 1px solid var(--line); }
.imp-row:first-child { border-top: 0; }
.imp-row span:first-child { color: var(--muted); }
.imp-row span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#import-go:disabled { opacity: .4; }

.ops-top { justify-content: space-between; }
.cal-toggle { font-size: 18px; display: grid; place-items: center; }
.cal-toggle.on { background: color-mix(in srgb, var(--accent) 22%, var(--card)); }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-nav .icon-btn { width: 32px; height: 32px; font-size: 18px; }
.cal-cell.picked { outline: 2px solid var(--text); outline-offset: 1px; transform: scale(1.04); }

/* sticky month bar on the operations tab */
.ops-sticky {
  position: fixed; top: 0; left: 0; right: 0; z-index: 4; max-width: 480px; margin: 0 auto;
  display: grid; grid-template-columns: 36px 1fr 36px 36px 36px; gap: 8px; align-items: center;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-bottom: 1px solid var(--line);
}
.ops-sticky[hidden] { display: none; }
.ops-sticky b { text-align: center; font-size: 16px; }
.ops-sticky .icon-btn { width: 36px; height: 36px; font-size: 18px; display: grid; place-items: center; }
.ops-sticky .icon-btn .bicon { width: 19px; height: 19px; }
.ops-sticky .icon-btn.on { color: var(--accent); }
.ops-sticky b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.calendar { touch-action: pan-y; user-select: none; -webkit-user-select: none; }

/* sign-in */
.login { border: 0; padding: 0; width: 100%; height: 100%; max-width: none; max-height: none; background: var(--bg); color: var(--text); }
.login::backdrop { background: var(--bg); }
.login[open] { display: grid; place-items: center; }
.login form { width: min(360px, calc(100% - 32px)); display: grid; gap: 10px; text-align: center; }
.login-logo { width: 84px; height: 84px; border-radius: 20px; margin: 0 auto 4px; box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 40%, transparent); }
.login h1 { margin: 0; font-size: 26px; }
.login .muted { color: var(--muted); font-size: 14px; margin: 0 0 6px; }
.login .text-input { margin: 0; }
.login-btn { padding: 14px; border-radius: 14px; background: linear-gradient(140deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700; font-size: 17px; }
.login .link { text-align: center; padding: 6px; }
.login-error { color: var(--bad); font-size: 14px; min-height: 20px; }
.cloud-card .cloud-line { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.pill-btn.wide { width: 100%; margin-top: 10px; padding: 12px; }

/* Every screen is at least as tall as the viewport: on iPhone Safari a short page (Projects)
   made the toolbar re-expand, and the fixed tab bar jumped up with it. */
html { height: 100%; }
.app { min-height: 100vh; min-height: 100dvh; }

/* Apple Pay auto-capture */
.tag.review { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.tag.place { color: var(--muted); }
.review-card { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left;
  background: color-mix(in srgb, var(--warn) 14%, var(--card)); }
.review-card .muted { color: var(--muted); font-size: 14px; }
.key-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all;
  background: var(--card-2); border-radius: 10px; padding: 10px 12px; user-select: all; -webkit-user-select: all; }
.steps ol { margin: 0; padding-left: 20px; display: grid; gap: 10px; font-size: 15px; line-height: 1.4; }
.steps ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; }
.copy-btn { margin-left: 4px; padding: 4px 10px; font-size: 13px; }
.pill-btn[disabled] { opacity: .4; }

/* read-only record card */
.view .view-body { padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px); overflow-y: auto; max-height: 92dvh; }
.v-head { display: flex; gap: 12px; align-items: center; }
.v-head .badge { width: 46px; height: 46px; font-size: 24px; border-radius: 14px; }
.v-title { font-size: 19px; font-weight: 700; }
.v-head .muted { color: var(--muted); font-size: 14px; }
.v-amount { font-size: 38px; font-weight: 800; letter-spacing: -0.5px; margin: 14px 0 10px; }
.v-review { background: color-mix(in srgb, var(--warn) 16%, var(--card)); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; }
.v-rows { padding: 4px 14px; }
.v-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.v-row:first-child { border-top: 0; }
.v-row span { color: var(--muted); flex: none; }
.v-row b { text-align: right; font-weight: 600; }
.v-row a { color: var(--accent); text-decoration: none; }
.v-row .muted { color: var(--muted); font-weight: 400; font-size: 13px; }
.v-files { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.v-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.v-actions .pill-btn { padding: 12px 6px; font-size: 15px; }
.v-actions .ok { background: color-mix(in srgb, var(--ok) 18%, var(--card-2)); color: var(--ok); }
.v-actions .danger-text { color: var(--bad); }
.close-view { display: block; width: 100%; text-align: center; margin-top: 10px; }

/* Overview: per person "paid" vs "real expenses" */
.people-table { margin: 4px 0 2px; }
.people-table .pt-head, .people-table .pt-row {
  display: grid; grid-template-columns: 1fr 96px 96px 14px; align-items: center; gap: 6px; width: 100%; text-align: left;
}
.people-table .pt-head { color: var(--muted); font-size: 12px; font-weight: 600; padding: 2px 0 4px; }
.people-table .pt-head span, .people-table .pt-row .val { text-align: right; }
.people-table .pt-row { padding: 10px 0; border-top: 1px solid var(--line); }
.people-table .pt-row .name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.people-table .pt-row .val { font-weight: 700; white-space: nowrap; }
.people-table .pt-row .val.muted { color: var(--muted); font-weight: 600; }
.people-table .pt-row .val small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }
.people-table .chev { color: var(--muted); }
.summary .total.small { font-size: 24px; }
.basis-pick { margin-top: 8px; }
.note b { color: var(--text); }

/* Wish list */
.url-line, .price-line { display: flex; gap: 8px; align-items: center; }
.url-line .text-input, .price-line .text-input { flex: 1; min-width: 0; margin: 0; }
.price-line select { padding: 12px 10px; border-radius: 12px; background: var(--card); color: var(--text); border: 1px solid var(--line); font: inherit; }
#wish-status { padding: 8px 4px 4px; }
#wish-status.ok { color: var(--ok); }
.wish-preview:empty { display: none; }
.wish-preview { display: flex; justify-content: center; margin: 6px 0 10px; }
.wish-preview img { max-height: 160px; max-width: 100%; border-radius: 12px; background: #fff; object-fit: contain; }
.chips.wrap { flex-wrap: wrap; }
#wish-actions[hidden] { display: none; }
.wish-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 4px 12px; align-items: center; width: 100%; text-align: left; padding: 10px 14px; }
.wish-row .thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: contain; background: #fff; grid-row: span 2; }
.wish-row .badge { grid-row: span 2; }
.wish-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.wish-row .sum { font-weight: 700; text-align: right; white-space: nowrap; }
.wish-row .meta { grid-column: 2 / 4; color: var(--muted); font-size: 13px; }
.wish-row .meta .down { color: var(--ok); }
.wish-row .meta .up { color: var(--bad); }
.wish-row.bought { opacity: .55; }
.wish-row.bought .name { text-decoration: line-through; }
.group > .wish-row + .wish-row { border-top: 1px solid var(--line); }
.wish-total { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; padding: 6px 4px 0; }
.wish-total b { color: var(--text); }
#wish-actions { grid-template-columns: repeat(3, 1fr); }
.hero .people-table .pt-head, .hero .people-table .pt-row .val.muted, .hero .people-table .val small { color: rgba(255, 255, 255, .78); }
.hero .people-table .pt-row { border-top-color: rgba(255, 255, 255, .18); }
.hero .people-table .chev { color: rgba(255, 255, 255, .7); }

/* Who owes whom, several transfers */
.balance-list .k { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.balance-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.balance-row + .balance-row { border-top: 1px solid var(--line); }
.balance-row .v { font-weight: 700; }

/* Several people: payer / for whom stacked, per-person amounts */
.pair.stacked { display: block; }
.split-box:empty { display: none; }
.split-box { margin-top: 6px; }
.split-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.split-row > span { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.split-row .text-input { width: 130px; margin: 0; text-align: right; }
.split-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; padding: 2px 4px; }
.split-foot .minus { color: var(--bad); }

/* Members */
.member-row { display: grid; grid-template-columns: 34px 1fr auto 14px; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 14px; }
.group > .member-row + .member-row { border-top: 1px solid var(--line); }
.member-row .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; }
.member-row .name { font-weight: 600; }
.member-row .meta { color: var(--muted); font-size: 13px; }
.color-pick { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.color-pick button { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; }
.color-pick button.active { border-color: var(--text); }
#member-invite[hidden], #member-delete[hidden] { display: none; }
#member-invite { margin-top: 12px; }
.login .small { font-size: 12px; }
#start-invite, #start-create { display: grid; gap: 10px; }
#start-invite[hidden], #start-create[hidden], #start-cancel[hidden], #start-signout[hidden] { display: none; }

/* Categories editor */
.member-row .badge { width: 34px; height: 34px; }
.member-row.dim { opacity: .5; }
.cat-edit-line { display: flex; gap: 8px; }
.cat-edit-line .text-input { margin: 0; }
.cat-edit-line .emoji-input { width: 64px; flex: none; text-align: center; font-size: 22px; }
#cat-hide[hidden], #cat-delete[hidden] { display: none; }
#cat-hide { margin-top: 12px; }

/* Sign in with Google / Apple */
.oauth { display: grid; gap: 8px; }
.oauth:empty { display: none; }
.oauth-btn { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 13px; border-radius: 14px; font-weight: 600; font-size: 16px; background: var(--card); color: var(--text); border: 1px solid var(--line); }
.oauth-btn svg { width: 20px; height: 20px; }
.oauth-btn.apple { background: var(--text); color: var(--bg); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 4px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Account */
.danger-row .name { color: var(--bad); }
a.link-row { color: inherit; text-decoration: none; }
.small-link { font-size: 13px; text-decoration: none; }

/* Shared trip card in a project */
.trip-card .cloud-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 600; }
.trip-card .note { margin-top: 6px; }
.balance-row .small { font-size: 12px; margin-top: 2px; }
#login-resend[hidden] { display: none; }

/* Waiting for a link from an email / Google */
.busy { display: grid; place-items: center; gap: 12px; text-align: center; }
.busy .login-logo { animation: busy-pulse 1.2s ease-in-out infinite; }
@keyframes busy-pulse { 50% { opacity: .45; transform: scale(.96); } }
.ops-top + .search { margin-bottom: 12px; }

/* Double counting check with a shared trip */
.tc-pair .tc-ours { display: grid; gap: 2px; }
.tc-pair .tc-ours span, .tc-pair .tc-trip { color: var(--muted); font-size: 13px; }
.tc-pair .tc-trip { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.tc-pair .op-buttons { margin-top: 10px; }
.warn-btn { margin-top: 10px; color: var(--warn); }

/* Sorting categories by taps */
.sort-card { text-align: center; display: grid; gap: 6px; }
.sort-card .sort-title { font-size: 20px; font-weight: 700; }
.sort-card .sort-amount { font-size: 28px; font-weight: 800; }
.sort-card .small { font-size: 12px; }
.sort-all { margin: 6px auto 0; padding: 8px 14px; border-radius: 999px; background: var(--card-2); color: var(--muted); font-weight: 600; }
.sort-all.on { color: var(--accent); }
.sort-grid { margin-top: 12px; }
.budget-switch { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; display: inline-flex; gap: 4px; align-items: center; }
.budget-switch .caret { font-size: 10px; }
.sort-grid button .n { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.15; font-size: 11px; text-align: center; }
/* Sorting grid: bigger tiles, full names on up to two lines */
.cat-grid.sort-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cat-grid.sort-grid button { white-space: normal; overflow: visible; padding: 10px 4px; min-height: 72px; justify-content: flex-start; }
.cat-grid.sort-grid button .e { font-size: 26px; }
.sort-grid button .n { width: 100%; white-space: normal; word-break: break-word; font-size: 11.5px; }
.sort-grid button .n { word-break: normal; overflow-wrap: normal; hyphens: auto; -webkit-hyphens: auto; font-size: 11px; letter-spacing: -0.1px; }
.sync-problem span:first-child { color: var(--warn); }
/* Sorting grid: three columns, whole words, no hyphenation */
.cat-grid.sort-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sort-grid button .n { hyphens: none; -webkit-hyphens: none; font-size: 12px; }
.keep-btn { margin-top: 12px; padding: 13px; font-size: 16px; }
.sort-links { display: flex; justify-content: center; gap: 24px; margin-top: 10px; font-size: 14px; }
#goal-who[hidden] { display: none; }

/* Which budget is open: a pill on top of every tab */
.budget-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; margin-bottom: 4px; border-radius: 999px;
  background: color-mix(in srgb, var(--b) 16%, transparent); color: var(--text); font-size: 13px; font-weight: 700; max-width: 70vw; }
.budget-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--b); flex: none; }
.budget-pill .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budget-pill .caret { font-size: 9px; color: var(--muted); }
.tab-top { display: block; }
.home-top .budget-pill { margin-bottom: 2px; }
.budget-pill { font-size: 15px; padding: 6px 14px 6px 10px; gap: 8px; margin-bottom: 6px; }
.budget-pill .dot { width: 11px; height: 11px; }
.budget-pill .caret { font-size: 11px; }

/* Step-by-step double counting check */
.tc-step { text-align: center; color: var(--muted); font-size: 13px; font-weight: 600; margin: 6px 0; }
.tc-q h3 { margin: 0 0 12px; font-size: 18px; text-align: center; }
.tc-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tc-cols.one { grid-template-columns: 1fr; }
.tc-col { display: grid; gap: 3px; background: var(--card-2); border-radius: 12px; padding: 10px; font-size: 14px; align-content: start; }
.tc-col span { color: var(--muted); font-size: 13px; }
.tc-col .tc-amt { color: var(--text); font-size: 18px; font-weight: 800; }
.tc-col .tc-amt small { color: var(--muted); font-size: 11px; font-weight: 600; }
.tc-where { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--accent); }
.tc-match { color: var(--ok) !important; font-weight: 700; }
.tc-yes { margin-top: 12px; background: var(--accent); color: #fff; }
.tc-q + .pill-btn, .tc-q ~ .pill-btn { margin-top: 10px; }
.sort-links { flex-wrap: wrap; } .sort-links .link { white-space: nowrap; }
/* Transfer between people: who -> whom, no categories or projects */
.sheet.transfer #cat-grid, .sheet.transfer .goal-field, .sheet.transfer #for-pick [data-for="all"] { display: none; }
#type-pick { flex-wrap: wrap; }
.cat-add { border: 1.5px dashed var(--line) !important; color: var(--accent) !important; }
/* Sign-in / start / password screens: clear of the notch and the home bar, scroll when the keyboard is up */
.login { box-sizing: border-box; padding: calc(env(safe-area-inset-top) + 16px) 0 calc(env(safe-area-inset-bottom) + 16px); overflow-y: auto; }
.login[open] { place-items: safe center; }
.login form:focus { outline: none; }

/* Budget switcher: one card with a coloured letter per budget, "new budget" below it. */
#budgets-sheet { background: var(--bg); border-radius: 22px 22px 0 0; padding-top: 8px; }
#budgets-sheet h2 { border-radius: 14px; border-bottom: 0; margin-bottom: 4px; padding: 8px 0 8px; background: transparent; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.budget-list { background: var(--card); border-radius: 16px; overflow: hidden; }
#budgets-sheet .budget-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 64px; background: transparent; color: var(--text); text-align: left; font-size: 17px; position: relative; }
.budget-list .budget-row + .budget-row::before { content: ""; position: absolute; top: 0; left: 64px; right: 0; border-top: 1px solid var(--line); }
.budget-row .badge { width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center; background: var(--b); color: #fff; font-weight: 700; font-size: 18px; }
.budget-row .text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.budget-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.budget-row .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); margin-top: 2px; }
.budget-row .tick { color: var(--accent); font-weight: 700; font-size: 18px; }
.budget-row .chev { color: var(--muted); font-size: 22px; }
#budgets-sheet .budget-row.current { background: color-mix(in srgb, var(--b) 12%, transparent); }
#budgets-sheet .budget-row.add { margin-top: 8px; background: var(--card); border-radius: 16px; min-height: 56px; color: var(--accent); }
.budget-row.add .badge { background: transparent; color: var(--accent); border: 1.5px dashed currentColor; font-weight: 400; }

/* Light text on the purple overview card. */
.hero .note { color: rgba(255, 255, 255, .8); border-top-color: rgba(255, 255, 255, .18); }
.hero .note b { color: #fff; }
/* Debts: the same people's debt in a linked budget under the main line; other linked debts as one line. */
.linked-row { width: 100%; background: none; color: var(--text); text-align: left; }
.linked-row .nm { font-weight: 600; }
.linked-row .small { line-height: 1.4; }
.linked-row .chev { color: var(--muted); font-size: 20px; }

/* "Open in Safari / Chrome" when the site is opened inside Telegram, Instagram… */
.open-outside .outside-box { width: min(360px, calc(100% - 32px)); display: grid; gap: 12px; text-align: center; }
.open-outside .login-btn { display: block; text-decoration: none; }

/* Budget look: emoji instead of the letter / dot, quick emoji picks, preview. */
.bicon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.budget-pill .pill-icon { width: 20px; height: 20px; border-radius: 6px; background: var(--b); color: #fff; display: grid; place-items: center; flex: none; }
.budget-pill .pill-icon .bicon { width: 14px; height: 14px; stroke-width: 2; }
#budgets-sheet .budget-look-link { margin-top: 10px; background: none; color: var(--accent); font-size: 15px; padding: 8px; }
.icon-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 4px 0 6px; }
.icon-pick button { aspect-ratio: 1; border-radius: 12px; background: var(--card); color: var(--muted); display: grid; place-items: center; padding: 0; font-weight: 700; font-size: 18px; }
.icon-pick button.active { color: #fff; }
.budget-preview { display: flex; justify-content: center; margin: 4px 0 12px; }
.budget-preview .budget-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: 16px; background: color-mix(in srgb, var(--b) 14%, var(--card)); font-size: 17px; }
