/* Visual language: iOS grouped lists, system colors, color only where it carries meaning. */

:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --sheet: #f2f2f7;
  --sheet-group: #ffffff;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --sep: rgba(60, 60, 67, 0.18);
  --tint: #000000;
  --on-tint: #ffffff;
  --blue: #007aff;
  --red: #ff3b30;
  --green: #248a3d;
  --orange: #ff9500;
  --radius: 16px;
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1c1c1e;
    --sheet: #1c1c1e;
    --sheet-group: #2c2c2e;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.36);
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.55);
    --tint: #ffffff;
    --on-tint: #000000;
    --blue: #0a84ff;
    --red: #ff453a;
    --green: #30d158;
    --orange: #ff9f0a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --sheet: #1c1c1e;
  --sheet-group: #2c2c2e;
  --fill: rgba(118, 118, 128, 0.24);
  --fill-strong: rgba(118, 118, 128, 0.36);
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.6);
  --label-3: rgba(235, 235, 245, 0.3);
  --sep: rgba(84, 84, 88, 0.55);
  --tint: #ffffff;
  --on-tint: #000000;
  --blue: #0a84ff;
  --red: #ff453a;
  --green: #30d158;
  --orange: #ff9f0a;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }
.secondary-text { color: var(--label-2); }
.red { color: var(--red) !important; }
.green { color: var(--green) !important; }

.app {
  max-width: 540px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 8px) 16px calc(var(--tabbar-h) + var(--safe-b) + 32px);
  min-height: 100dvh;
}
.app.no-tabs { padding-bottom: calc(var(--safe-b) + 32px); }

/* ---------- navigation header ---------- */
.nav { display: flex; align-items: center; min-height: 44px; margin: 0 -8px; }
.nav .spacer { flex: 1; }
.nav-btn {
  height: 44px; min-width: 44px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  color: var(--blue); font-size: 17px;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn:active { opacity: 0.4; }
.nav-btn[disabled] { color: var(--label-3); pointer-events: none; }
.large-title { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: 0.01em; margin: 2px 0 2px; }
.title-sub { color: var(--label-2); font-size: 15px; margin-bottom: 18px; }
.period-switch { display: flex; align-items: center; gap: 4px; margin-bottom: 18px; }
.period-switch .title-sub { margin: 0; flex: 1; }
.round-btn {
  width: 32px; height: 32px; border-radius: 50%; background: var(--fill); display: grid; place-items: center; color: var(--label);
}
.round-btn svg { width: 16px; height: 16px; }
.round-btn:active { background: var(--fill-strong); }
.round-btn[disabled] { opacity: 0.35; pointer-events: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--fill); display: grid; place-items: center;
  font-size: 14px; font-weight: 600; color: var(--label-2);
}

/* ---------- groups (inset grouped lists) ---------- */
.group { background: var(--surface); border-radius: var(--radius); overflow: hidden; margin-bottom: 28px; }
.group.tight { margin-bottom: 10px; }
.group-header {
  display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px; margin: 0 0 8px;
}
.group-header h2 { font-size: 22px; line-height: 28px; font-weight: 700; margin: 0; letter-spacing: 0.005em; }
.group-header a, .group-header button { color: var(--blue); font-size: 17px; }
.group-caption { font-size: 13px; color: var(--label-2); text-transform: uppercase; letter-spacing: 0; padding: 0 16px; margin: 0 0 7px; }
.group-footer { font-size: 13px; color: var(--label-2); padding: 0 16px; margin: -20px 0 28px; line-height: 1.35; }

.cell {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 16px; width: 100%; text-align: left; position: relative;
}
.cell + .cell::before {
  content: ""; position: absolute; top: 0; right: 0; left: 16px; height: 0.5px; background: var(--sep);
}
.cell.with-icon + .cell::before, .cell + .cell.with-icon::before { left: 60px; }
button.cell:active, a.cell:active, .cell.tap:active { background: var(--fill); }
.cell .body { flex: 1; min-width: 0; }
.cell .t { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .s { font-size: 15px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.cell .v { color: var(--label-2); font-size: 17px; white-space: nowrap; flex: none; }
.cell .amt { font-size: 17px; white-space: nowrap; flex: none; font-variant-numeric: tabular-nums; }
.cell .amt.income { color: var(--green); }
.cell .chev { color: var(--label-3); flex: none; display: grid; }
.cell .chev svg { width: 14px; height: 14px; stroke-width: 2.6; }
.cell .progress { margin-top: 8px; }
.want-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--red); margin: 0 0 2px 6px; vertical-align: middle; }

.ci {
  width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; flex: none; color: #fff;
}
.ci svg { width: 19px; height: 19px; stroke-width: 2; }
.ci.lg { width: 44px; height: 44px; border-radius: 11px; }
.ci.lg svg { width: 26px; height: 26px; }
.ci.gray { background: #8e8e93; }
.ci.initials { background: var(--fill-strong); color: var(--label-2); font-size: 13px; font-weight: 600; border-radius: 50%; }

/* ---------- hero ---------- */
.hero { background: var(--surface); border-radius: 20px; padding: 18px 18px 16px; margin-bottom: 10px; }
.hero .caption { font-size: 15px; color: var(--label-2); }
.hero .big {
  font-family: var(--rounded); font-size: 52px; line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
}
.hero .big .cur { color: var(--label-3); font-weight: 600; font-size: 36px; margin-left: 4px; }
.hero .meta { font-size: 15px; color: var(--label-2); }
.hero .meta b { color: var(--label); font-weight: 600; }
.spend-bar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--fill); margin: 16px 0 8px; }
.spend-bar i { display: block; height: 100%; min-width: 2px; }
.hero .foot { display: flex; justify-content: space-between; font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; }

.triple { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border-radius: var(--radius); margin-bottom: 28px; }
.triple div { padding: 11px 14px; min-width: 0; position: relative; }
.triple div + div::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 0.5px; background: var(--sep); }
.triple .k { font-size: 13px; color: var(--label-2); }
.triple .v { font-size: 17px; font-weight: 600; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

.progress { height: 4px; border-radius: 2px; background: var(--fill); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 2px; background: var(--label); transition: width 0.4s ease; }
.progress.over i { background: var(--red); }

/* ---------- inputs ---------- */
.search {
  display: flex; align-items: center; gap: 6px; height: 36px; border-radius: 10px; background: var(--fill); padding: 0 8px; margin-bottom: 12px; color: var(--label-2);
}
.search svg { width: 17px; height: 17px; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 17px; color: var(--label); height: 100%; }
.search input::placeholder { color: var(--label-2); }
.search input::-webkit-search-cancel-button { display: none; }

.compose {
  display: flex; align-items: center; gap: 4px; min-height: 44px; border-radius: 22px; background: var(--surface);
  padding: 4px 4px 4px 16px; margin-bottom: 28px; border: 0.5px solid var(--sep);
}
.compose input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 17px; height: 34px; }
.compose input::placeholder { color: var(--label-3); }
.compose .icon { width: 34px; height: 34px; display: grid; place-items: center; color: var(--label-2); border-radius: 50%; }
.compose .icon svg { width: 22px; height: 22px; }
.compose .send { background: var(--tint); color: var(--on-tint); }
.compose .send svg { width: 18px; height: 18px; stroke-width: 2.6; }
.compose .send[disabled] { opacity: 0.3; }

.input-cell { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; position: relative; }
.input-cell + .input-cell::before, .cell + .input-cell::before, .input-cell + .cell::before {
  content: ""; position: absolute; top: 0; right: 0; left: 16px; height: 0.5px; background: var(--sep);
}
.input-cell label { flex: none; min-width: 110px; }
.input-cell input, .input-cell select {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; height: 44px; font-size: 17px; text-align: right; color: var(--label-2);
  -webkit-appearance: none; appearance: none;
}
.input-cell input:focus { color: var(--label); }
.input-cell.left input { text-align: left; color: var(--label); }
.input-cell input::placeholder { color: var(--label-3); }
.input-cell input[type="date"] { display: flex; justify-content: flex-end; }
.input-cell input[type="date"]::-webkit-date-and-time-value { text-align: right; }
.input-cell select { direction: rtl; }
.input-cell select option { direction: ltr; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill); border-radius: 9px; padding: 2px; margin-bottom: 16px; }
.segmented button { height: 28px; border-radius: 7px; font-size: 13px; font-weight: 500; }
.segmented button.on { background: var(--surface); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04); }
.sheet .segmented button.on { background: var(--sheet-group); }
:root[data-theme="dark"] .segmented button.on { background: #636366; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .segmented button.on { background: #636366; } }

.toggle { width: 51px; height: 31px; border-radius: 16px; background: var(--fill-strong); position: relative; flex: none; transition: background 0.2s; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); transition: transform 0.2s; }
.toggle.on { background: #34c759; }
.toggle.on::after { transform: translateX(20px); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 20px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 14px; border-radius: 16px; background: var(--surface); font-size: 15px; white-space: nowrap; }
.chip.on { background: var(--tint); color: var(--on-tint); }

.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 4px; padding: 16px 8px 14px; }
.cat { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; line-height: 1.15; text-align: center; color: var(--label-2); }
.cat .ci { transition: transform 0.15s, box-shadow 0.15s; }
.cat.on { color: var(--label); font-weight: 600; }
.cat.on .ci { box-shadow: 0 0 0 2.5px var(--sheet-group), 0 0 0 4.5px var(--label); }
.cat:active .ci { transform: scale(0.92); }

.amount-field { text-align: center; padding: 6px 0 18px; }
.amount-field input {
  width: 100%; border: 0; outline: 0; background: none; text-align: center; font-family: var(--rounded);
  font-size: 56px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; caret-color: var(--blue);
}
.amount-field input::placeholder { color: var(--label-3); }
.amount-field .hint { font-size: 15px; color: var(--label-2); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 50px; border-radius: 14px;
  background: var(--tint); color: var(--on-tint); font-size: 17px; font-weight: 600; transition: opacity 0.15s;
}
.btn:active { opacity: 0.7; }
.btn[disabled] { opacity: 0.3; }
.btn.gray { background: var(--fill); color: var(--label); }
.btn.plain { background: none; color: var(--blue); font-weight: 400; height: 44px; }
.btn.destructive { background: none; color: var(--red); font-weight: 400; height: 44px; }
.btn svg { width: 20px; height: 20px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.pill { height: 30px; padding: 0 12px; border-radius: 15px; background: var(--fill); color: var(--blue); font-size: 15px; font-weight: 600; flex: none; }
.pill:active { background: var(--fill-strong); }
.pill.dark { background: var(--tint); color: var(--on-tint); }

.error { color: var(--red); font-size: 15px; text-align: center; margin: -8px 0 16px; }
.stack > * + * { margin-top: 10px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 0.5px solid var(--sep);
}
.tabbar .inner { max-width: 540px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--tabbar-h); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; font-weight: 500; color: var(--label-3); letter-spacing: 0.01em; }
.tab svg { width: 25px; height: 25px; }
.tab.on { color: var(--label); }
.tab-add { display: grid; place-items: center; }
.tab-add span { width: 44px; height: 44px; border-radius: 50%; background: var(--tint); color: var(--on-tint); display: grid; place-items: center; transition: transform 0.15s; }
.tab-add:active span { transform: scale(0.9); }
.tab-add svg { width: 22px; height: 22px; stroke-width: 2.4; }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity 0.3s; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 560px; margin: 0 auto;
  background: var(--sheet); border-radius: 12px 12px 0 0; max-height: calc(100dvh - var(--safe-t) - 12px);
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}
.sheet.open { transform: none; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 5px auto 0; flex: none; }
.sheet header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 4px 8px 8px; flex: none; min-height: 50px; }
.sheet header h2 { font-size: 17px; font-weight: 600; margin: 0; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.sheet header .l { justify-self: start; }
.sheet header .r { justify-self: end; }
.sheet header .nav-btn.strong { font-weight: 600; }
.sheet .body { padding: 4px 16px calc(var(--safe-b) + 24px); overflow-y: auto; overscroll-behavior: contain; }
.sheet .group, .sheet .triple, .sheet .hero { background: var(--sheet-group); }
.sheet .group { margin-bottom: 22px; }
.sheet .group-footer { margin-top: -16px; margin-bottom: 22px; }
.sheet .fill-field { background: var(--sheet-group); }
@media (min-width: 620px) {
  .sheet { bottom: auto; top: 50%; border-radius: 14px; transform: translateY(-46%); opacity: 0; transition: transform 0.3s, opacity 0.2s; max-height: 86dvh; }
  .sheet.open { transform: translateY(-50%); opacity: 1; }
  .sheet .grab { visibility: hidden; }
}

/* ---------- AI chat ---------- */
.chat { display: flex; flex-direction: column; gap: 6px; padding-bottom: 72px; }
.msg { max-width: 82%; padding: 8px 13px; border-radius: 19px; font-size: 17px; line-height: 1.33; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--blue); color: #fff; }
.msg.assistant { align-self: flex-start; background: var(--surface); }
.msg + .msg.user, .msg + .msg.assistant { margin-top: 4px; }
.msg p { margin: 0 0 8px; }
.msg p:last-child, .msg ul:last-child { margin-bottom: 0; }
.msg ul { margin: 0 0 8px; padding-left: 20px; }
.msg li { margin: 3px 0; }
.typing { display: inline-flex; gap: 4px; padding: 13px 14px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--label-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.35; } 40% { opacity: 1; } }
.chat-dock {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b)); z-index: 15; padding: 8px 16px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
}
.chat-dock .compose { max-width: 508px; margin: 0 auto; }
.chat-intro { text-align: center; padding: 28px 16px 26px; }
.chat-intro .ci { margin: 0 auto 14px; background: var(--tint); color: var(--on-tint); }
.chat-intro h3 { font-size: 22px; margin: 0 0 6px; font-weight: 700; }
.chat-intro p { margin: 0; color: var(--label-2); font-size: 15px; line-height: 1.4; }

/* ---------- charts ---------- */
.ring-wrap { display: flex; align-items: center; gap: 20px; padding: 18px; }
.ring { width: 128px; height: 128px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .center b { font-family: var(--rounded); font-size: 19px; font-variant-numeric: tabular-nums; }
.ring .center small { font-size: 12px; color: var(--label-2); }
.ring-legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; font-size: 15px; }
.ring-legend div { display: flex; align-items: center; gap: 8px; }
.ring-legend i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ring-legend span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring-legend em { font-style: normal; color: var(--label-2); font-variant-numeric: tabular-nums; }

.chart { padding: 16px; }
.chart .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.chart .head .k { font-size: 13px; color: var(--label-2); }
.chart .head .v { font-family: var(--rounded); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bars { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 120px; }
.bars .b { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; }
.bars .b i { display: block; background: var(--label); border-radius: 2px; }
.bars .b i.w { background: var(--red); border-radius: 2px 2px 0 0; }
.bars .b i.w + i { border-radius: 0 0 2px 2px; }
.bars .b.future i { opacity: 0.15; }
.bars .b.empty::after { content: ""; display: block; height: 2px; border-radius: 1px; background: var(--fill-strong); }
.bars .limit { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--label-3); pointer-events: none; }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--label-2); margin-top: 6px; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--label-2); margin-top: 10px; }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--label); }
.legend .l-want::before { background: var(--red); }
.legend .l-light::before { background: var(--fill-strong); }

.split { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--fill); }
.split i { display: block; height: 100%; background: var(--label); }
.split i.w { background: var(--red); }

.months { display: flex; align-items: flex-end; gap: 8px; height: 130px; }
.months .col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.months .pair { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.months .pair i { width: 38%; max-width: 14px; border-radius: 3px; background: var(--label); }
.months .pair i.inc { background: var(--fill-strong); }
.months small { font-size: 12px; color: var(--label-2); }
.months .col.cur small { color: var(--label); font-weight: 600; }

.delta { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--label-2); }
.delta.up { color: var(--red); }
.delta.down { color: var(--green); }

/* ---------- auth ---------- */
.auth { min-height: calc(100dvh - 60px); display: flex; flex-direction: column; justify-content: center; max-width: 400px; margin: 0 auto; padding: 24px 0; }
.auth .logo { width: 72px; height: 72px; border-radius: 17px; margin: 0 auto 22px; display: block; }
.auth h1 { font-size: 30px; font-weight: 700; text-align: center; margin: 0 0 8px; letter-spacing: 0.005em; }
.auth .lead { color: var(--label-2); text-align: center; margin: 0 0 30px; font-size: 17px; line-height: 1.35; }
.auth .group { margin-bottom: 12px; }
.auth .input-cell label { min-width: 96px; }
.auth .input-cell input { text-align: left; color: var(--label); }
.auth .note { font-size: 13px; color: var(--label-2); padding: 0 16px; margin: 0 0 24px; }
.auth .alt { text-align: center; margin-top: 8px; }

/* ---------- misc ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); transform: translateX(-50%); z-index: 60;
  background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--label);
  backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
  padding: 12px 18px; border-radius: 26px; font-size: 15px; font-weight: 500;
  display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 32px); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  animation: toast-in 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.toast button { color: var(--blue); font-weight: 600; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px) scale(0.96); } }

.empty { text-align: center; padding: 48px 24px; }
.empty .ci { margin: 0 auto 14px; background: var(--fill-strong); color: var(--label-2); }
.empty h3 { font-size: 20px; margin: 0 0 6px; font-weight: 600; }
.empty p { margin: 0 0 18px; color: var(--label-2); font-size: 15px; line-height: 1.4; }
.empty .btn { width: auto; display: inline-flex; padding: 0 22px; height: 44px; border-radius: 22px; font-size: 15px; }

.goal-ring { width: 30px; height: 30px; flex: none; }
.goal-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }

.parsed { background: var(--sheet-group); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.parsed .top { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; }
.parsed .top input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-family: var(--rounded); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.parsed .top .cur { color: var(--label-3); font-size: 20px; font-weight: 600; }
.parsed .cell, .parsed .input-cell { min-height: 40px; }
.parsed .input-cell input, .parsed .input-cell select { height: 40px; font-size: 16px; }
.parsed .x { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--label-2); background: var(--fill); }
.parsed .x svg { width: 14px; height: 14px; stroke-width: 2.6; }

.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 30px; letter-spacing: 0.16em; font-weight: 600; text-align: center; padding: 22px; }
.link-box { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; padding: 12px 16px; word-break: break-all; color: var(--label-2); user-select: all; }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px 6px; padding: 14px; justify-items: center; }
.icon-grid button { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--label); background: var(--fill); }
.icon-grid button svg { width: 22px; height: 22px; }
.icon-grid button.on { background: var(--tint); color: var(--on-tint); }
.color-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; padding: 14px; justify-items: center; }
.color-row button { width: 32px; height: 32px; border-radius: 50%; }
.color-row button.on { box-shadow: 0 0 0 2.5px var(--sheet-group), 0 0 0 4.5px var(--label); }

.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; min-height: 60dvh; color: var(--label-3); }
.fade-in { animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } }
.mt { margin-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- mandatory payments & tips ---------- */
.orange { color: var(--orange) !important; }
.mandatory-head { padding: 14px 16px 12px; }
.mandatory-head .row { display: flex; justify-content: space-between; font-size: 15px; color: var(--label-2); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.mandatory-head .row b { color: var(--label); font-weight: 600; }
.mandatory-head + .cell::before { left: 0 !important; }
.cell.paid .t { color: var(--label-2); }
.cell.paid .ci svg { stroke-width: 3; }
.x-btn { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--label-3); flex: none; }
.x-btn svg { width: 14px; height: 14px; }
.x-btn:active { background: var(--fill); }
.suggestion .s, .tip .tip-text { white-space: normal; line-height: 1.3; }
.tip { align-items: flex-start; }
.tip .ci { margin-top: 2px; }
.tip .tip-title { display: block; white-space: normal; line-height: 1.25; font-weight: 500; }
.tip .tip-text { display: block; margin-top: 3px; }
.triple .v { font-size: 15px; }
.triple div { padding: 10px 12px; }
.cell.wrap .t, .cell.wrap .s { white-space: normal; line-height: 1.25; }

/* ---------- quick note & import ---------- */
.amount-field .note-input {
  font: inherit; font-size: 17px; font-family: inherit; font-weight: 400; letter-spacing: normal; margin-top: 2px;
  color: var(--label); caret-color: var(--blue);
}
.amount-field .note-input::placeholder { color: var(--label-3); }
.auto-hint { font-size: 13px; color: var(--blue); margin-top: 4px; }
.steps .step { width: 22px; height: 22px; border-radius: 50%; background: var(--fill); display: grid; place-items: center; font-size: 13px; font-weight: 600; flex: none; }
.steps .s { white-space: normal; color: var(--label); }
.steps .cell + .cell::before { left: 50px; }
.import-row.off .body, .import-row.off .amt, .import-row.off .cat-pick { opacity: 0.35; }
.check { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--label-3); display: grid; place-items: center; color: transparent; flex: none; }
.check svg { width: 13px; height: 13px; stroke-width: 3; }
.check.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.cat-pick { position: relative; flex: none; display: grid; }
.cat-pick select { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }
.import-row + .cell::before, .cell + .import-row::before { left: 98px !important; }
.auth .logo { box-shadow: 0 0 0 0.5px var(--sep); }

/* ---------- people ---------- */
.av {
  width: var(--s); height: var(--s); border-radius: 50%; background: var(--fill-strong); display: inline-grid; place-items: center;
  font-size: calc(var(--s) * 0.58); line-height: 1; flex: none; box-shadow: 0 0 0 2px var(--surface);
}
.av b { font-size: calc(var(--s) * 0.42); font-weight: 600; color: var(--label-2); }
.pair { display: inline-flex; align-items: center; }
.pair .av + .av { margin-left: -9px; }
.nav-btn.pair { padding-right: 0; }
.ci-wrap { position: relative; display: grid; flex: none; }
.ci-wrap .who { position: absolute; right: -7px; bottom: -6px; display: grid; }
.ci-wrap .who .av { font-size: 12px; }
.who-label { display: inline-flex; align-items: center; gap: 8px; }
.who-label .av { box-shadow: none; }
.partner { margin-bottom: 20px; }
.partner-head { display: flex; align-items: center; gap: 10px; padding: 10px 8px 6px 14px; }
.partner-head .body { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 15px; }
.partner-head .body span { color: var(--label-2); font-size: 13px; }
.partner-head .nav-btn { height: 36px; font-weight: 600; }
.cell.news { align-items: flex-start; }
.cell.news .av { margin-top: 2px; box-shadow: none; }
.cell.news + .cell::before, .partner-head + .cell::before { left: 58px !important; }
.reacts { display: flex; align-items: center; gap: 2px; margin: 6px 0 0 -6px; flex-wrap: wrap; }
.react { width: 32px; height: 30px; border-radius: 15px; font-size: 17px; line-height: 1; filter: grayscale(0.9); opacity: 0.55; transition: transform 0.15s, opacity 0.15s; }
.react:active { transform: scale(1.3); }
.react.on { filter: none; opacity: 1; background: var(--fill); }
.react-badge { font-size: 17px; height: 30px; padding: 0 8px; border-radius: 15px; background: color-mix(in srgb, var(--blue) 14%, transparent); display: inline-grid; place-items: center; margin-right: 4px; }
.profile-preview { display: grid; place-items: center; padding: 6px 0 22px; }
.profile-preview .av { box-shadow: none; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; padding: 10px; }
.emoji-grid button { aspect-ratio: 1; border-radius: 10px; font-size: 24px; display: grid; place-items: center; }
.emoji-grid button.on { background: var(--fill-strong); box-shadow: inset 0 0 0 2px var(--label); }
.cell.member .av { box-shadow: none; }
.note-suggest { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.suggest-chip { height: 32px; padding: 0 12px; border-radius: 16px; background: var(--sheet-group); font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.suggest-chip span { color: var(--label-2); font-variant-numeric: tabular-nums; }
.suggest-chip:active { background: var(--fill-strong); }

.partner { margin: -18px 0 28px; }
.partner-head { padding: 10px 8px 4px 14px; }
.partner-head .body { flex-direction: row; display: block; font-size: 15px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.partner-head .body b { color: var(--label); font-weight: 600; }
.partner .pair .av { box-shadow: 0 0 0 2px var(--surface); }
.cell.news { padding-top: 8px; padding-bottom: 8px; align-items: center; }
.cell.news + .cell::before, .partner-head + .cell::before { left: 14px !important; }
.react-line:empty { display: none; }
.react-line { display: inline-flex; gap: 4px; margin-top: 4px; }
.react-badge { height: 24px; padding: 0 6px; font-size: 14px; border-radius: 12px; margin: 0; }
.react-toggle { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--label-3); font-size: 20px; flex: none; }
.react-toggle svg { width: 22px; height: 22px; }
.react-toggle.on { background: var(--fill); }
.reacts { margin: 6px 0 2px -4px; }
.react { filter: none; opacity: 1; }
.more-row .t { color: var(--blue); font-size: 15px; }
.triple div { padding: 10px 9px 10px 12px; } .triple .v { letter-spacing: -0.03em; }

/* ---------- week envelope ---------- */
.week { padding: 12px 14px 10px; margin: -6px 0 10px; }
.week-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.week-head .k { font-size: 13px; color: var(--label-2); }
.week-head b { font-size: 20px; font-family: var(--rounded); font-weight: 700; }
.week-head > span:first-child { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.week-head > span:first-child .k:first-child { width: 100%; }
.week-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week-days .wd { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wbar { position: relative; width: 100%; max-width: 30px; height: 44px; border-radius: 6px; background: var(--fill); overflow: hidden; display: flex; align-items: flex-end; }
.wbar i { display: block; width: 100%; background: var(--label); border-radius: 6px 6px 0 0; }
.wd.over .wbar i { background: var(--red); }
.wd.future .wbar { opacity: 0.5; }
.wline { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--label-3); }
.wd small { font-size: 11px; color: var(--label-2); }
.wd.today small { color: var(--label); font-weight: 700; }
.wd.today .wbar { box-shadow: inset 0 0 0 1.5px var(--label); }

/* ---------- approvals ---------- */
.approval { align-items: flex-start; }
.approval .av { margin-top: 2px; box-shadow: none; }
.approve-row { display: flex; gap: 8px; margin-top: 10px; }
.small-btn { height: 36px; border-radius: 10px; font-size: 15px; }
.big-purchase { text-align: center; padding: 8px 8px 22px; }
.big-purchase .pair { justify-content: center; margin-bottom: 12px; }
.big-purchase .ci.lg { margin: 0 auto 12px; }
.big-purchase .amount { font-family: var(--rounded); font-size: 40px; font-weight: 700; margin-bottom: 6px; }
.big-purchase p { margin: 0; color: var(--label-2); font-size: 15px; line-height: 1.4; }

/* ---------- reports ---------- */
.report-hero { text-align: center; padding: 4px 0 18px; }
.report-hero .k { font-size: 13px; color: var(--label-2); }
.report-hero .big { font-family: var(--rounded); font-size: 44px; font-weight: 700; margin: 2px 0 8px; font-variant-numeric: tabular-nums; }
.chip-delta { display: inline-block; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 12px; }
.chip-delta.down { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.chip-delta.up { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.report-ai { display: flex; gap: 12px; padding: 14px 16px; align-items: flex-start; }
.report-ai .ci { background: var(--tint); color: var(--on-tint); }
.report-ai p { margin: 0; font-size: 15px; line-height: 1.45; }
.sheet .triple { margin-bottom: 22px; }

/* ---------- forecast ---------- */
.forecast svg { width: 100%; height: 150px; display: block; overflow: visible; }
.f-limit { stroke: var(--label-3); stroke-dasharray: 4 4; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.f-actual { fill: none; stroke: var(--label); stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.f-proj { fill: none; stroke: var(--label-3); stroke-width: 2.5; stroke-dasharray: 5 5; vector-effect: non-scaling-stroke; }
.f-proj.bad { stroke: var(--red); opacity: 0.7; }
.f-dot { fill: var(--label); }
.legend .l-limit::before { background: transparent; border: 1px dashed var(--label-3); width: 10px; height: 0; border-radius: 0; vertical-align: 3px; }
.forecast .axis span:nth-child(2) { color: var(--label); }

/* ---------- voice & misc ---------- */
.compose .mic.recording { background: var(--red); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 50%, transparent); } 50% { box-shadow: 0 0 0 8px transparent; } }
.transcript { margin: 0 0 12px; text-align: center; font-size: 15px; color: var(--label-2); font-style: italic; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; word-break: break-all; }
.week-head .right { white-space: nowrap; }
.f-axis { position: relative; } .f-today { position: absolute; transform: translateX(-50%); color: var(--label); }

/* ---------- want details & goal nudge ---------- */
.want-extra { padding: 4px 16px 12px; }
.reason-label { font-size: 13px; color: var(--label-2); margin-bottom: 8px; }
.reason-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-sm { height: 30px; padding: 0 12px; border-radius: 15px; background: var(--fill); font-size: 14px; }
.chip-sm.on { background: var(--red); color: #fff; }
.price-hint { font-size: 13px; color: var(--orange); margin-top: 4px; }
.goal-nudge { margin-bottom: 18px; }
.goal-card { display: flex; gap: 12px; align-items: center; padding: 10px; margin-bottom: 8px !important; }
.goal-card img, .goal-card-icon { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; flex: none; }
.goal-card-icon { display: grid; place-items: center; background: var(--fill); color: var(--label-2); }
.goal-card-icon svg { width: 30px; height: 30px; }
.goal-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.goal-card-body b { font-size: 17px; }
.goal-card-body .k { font-size: 13px; color: var(--label-2); }
.goal-thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; }
.cell .goal-thumb + .goal-ring { display: none; }
.main-badge { font-size: 11px; font-weight: 600; color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); padding: 1px 6px; border-radius: 6px; vertical-align: 2px; }

/* ---------- rescue & funds ---------- */
.rescue .cell.wrap .s { white-space: normal; }
.step { align-items: flex-start; }
.step .s { white-space: normal !important; line-height: 1.35; }
.step.done .t { color: var(--label-2); }
.step-btn { margin-top: 8px; }
.fund { align-items: flex-start; }
.fund .ci { margin-top: 2px; }
.fund .pill, .fund .x-btn { margin-top: 6px; }
.chev-btn svg { width: 14px; height: 14px; stroke-width: 2.6; }

/* ---------- health score ---------- */
.score-head { display: flex; gap: 16px; align-items: center; padding: 16px; }
.score-ring { position: relative; width: 80px; height: 80px; flex: none; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring b { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--rounded); font-size: 26px; }
.score-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.score-text b { font-size: 17px; }
.score-text span { font-size: 13px; color: var(--label-2); line-height: 1.35; }
.score-text .score-advice { color: var(--label); }
.score-head + .cell::before { left: 16px !important; }

/* ---------- heatmap ---------- */
.heat-grid { display: grid; grid-template-columns: 44px repeat(7, 1fr); gap: 4px; align-items: center; margin-top: 4px; }
.heat-grid small { font-size: 11px; color: var(--label-2); text-align: center; }
.heat-grid .row-label { text-align: left; }
.heat-grid i { display: block; aspect-ratio: 1.3; border-radius: 6px; background: var(--fill); position: relative; overflow: hidden; }
.heat-grid i::after { content: ""; position: absolute; inset: 0; background: var(--label); opacity: var(--a); }
.heat-grid i.w::after { background: var(--red); }
