/* =========================================================================
   Семейный портал — iOS-style UI (system font, grouped lists, large titles,
   translucent bars). Light by default; dark follows the system unless the
   user picked a theme in Settings (data-theme on <html>).
   ========================================================================= */
:root {
  --bg: #f2f2f7;              /* systemGroupedBackground */
  --card: #ffffff;            /* secondarySystemGroupedBackground */
  --card-2: #f2f2f7;          /* fields inside cards */
  --text: #000000;
  --muted: #6c6c70;           /* secondaryLabel (accessible) */
  --faint: #aeaeb2;
  --line: #d8d8dc;            /* opaque separator */
  --fill: rgba(118,118,128,.12);
  --accent: #0071e3; --accent-soft: rgba(0,113,227,.12); --on-accent: #fff;
  --danger: #e0352b; --ok: #248a3d; --warn: #c93400;
  --destructive: #ff3b30; --on-destructive: #fff;
  --tip-bg: #1c1c1e; --tip-text: #fff;
  --bar: rgba(249,249,249,.88);
  --radius: 12px; --shadow: none; --tcard: #ffffff; --sheet-bg: #f2f2f7; --sheet-field: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #000000; --card: #1c1c1e; --card-2: #2c2c2e; --text: #ffffff; --muted: #98989f; --faint: #636366;
  --line: #38383a; --fill: rgba(118,118,128,.24);
  --accent: #0a84ff; --accent-soft: rgba(10,132,255,.18); --on-accent: #fff;
  --danger: #ff453a; --ok: #30d158; --warn: #ff9f0a; --destructive: #ff453a; --on-destructive: #fff;
  --tip-bg: #e5e5ea; --tip-text: #000; --bar: rgba(22,22,24,.88); --tcard: #2c2c2e; --sheet-bg: #1c1c1e; --sheet-field: #2c2c2e; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --card: #1c1c1e; --card-2: #2c2c2e; --text: #ffffff; --muted: #98989f; --faint: #636366;
  --line: #38383a; --fill: rgba(118,118,128,.24);
  --accent: #0a84ff; --accent-soft: rgba(10,132,255,.18); --on-accent: #fff;
  --danger: #ff453a; --ok: #30d158; --warn: #ff9f0a; --destructive: #ff453a; --on-destructive: #fff;
  --tip-bg: #e5e5ea; --tip-text: #000; --bar: rgba(22,22,24,.88); --tcard: #2c2c2e; --sheet-bg: #1c1c1e; --sheet-field: #2c2c2e; color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
svg { display: block; }
h1 { font-size: 28px; margin: 0 0 16px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 20px; margin: 0 0 12px; line-height: 1.25; font-weight: 600; }
b, strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.pos { color: var(--ok); } .neg { color: var(--danger); }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.wrap-row { flex-wrap: wrap; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 32px; }
.wrap.wide { max-width: 1320px; }
.wrap.fx-wrap { max-width: 1040px; }
.large-title { font-size: 34px; line-height: 1.2; font-weight: 700; letter-spacing: -0.025em; margin: 4px 0 16px; }

/* ---------- nav bar (collapses large title on scroll) ---------- */
.navbar { position: sticky; top: 0; z-index: 9; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 44px; padding: env(safe-area-inset-top) 8px 0; background: var(--bg); border-bottom: 1px solid transparent;
  transition: background-color 200ms cubic-bezier(0,0,.2,1), border-color 200ms cubic-bezier(0,0,.2,1); }
.navbar.scrolled { background: var(--bar); border-bottom-color: var(--line);
  -webkit-backdrop-filter: saturate(1.8) blur(20px); backdrop-filter: saturate(1.8) blur(20px); }
.nb-title { font-size: 17px; font-weight: 600; opacity: 0; transition: opacity 150ms cubic-bezier(0,0,.2,1); white-space: nowrap; }
.navbar.scrolled .nb-title { opacity: 1; }
.nb-side { display: flex; align-items: center; } .nb-side.end { justify-content: flex-end; }
.nb-btn { width: 44px; height: 44px; border: 0; background: none; color: var(--accent); display: grid; place-items: center; border-radius: 22px; }
.nb-btn svg { width: 24px; height: 24px; }
.nb-btn:active { opacity: .4; }
.nb-btn.spin svg { animation: spin .8s linear infinite; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around;
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); background: var(--bar); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(1.8) blur(20px); backdrop-filter: saturate(1.8) blur(20px); }
.tab { flex: 1; max-width: 120px; min-height: 48px; border: 0; background: none; color: var(--muted); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 500; letter-spacing: 0; }
.tab svg { width: 26px; height: 26px; }
.tab.on { color: var(--accent); }
.tab:active { opacity: .5; }

/* ---------- grouped lists ---------- */
.ios-group { margin: 0 0 24px; }
.ios-h { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: .02em;
  color: var(--muted); margin: 0 16px 8px; line-height: 1.3; }
.ios-f { font-size: 13px; color: var(--muted); margin: 8px 16px 0; line-height: 1.4; }
.ios-list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.ios-list.pad { padding: 8px; }
.ios-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 8px 16px; border: 0; background: none;
  text-align: left; position: relative; color: var(--text); text-decoration: none; }
.ios-row + .ios-row::before { content: ''; position: absolute; top: 0; right: 0; left: 16px; height: 1px; background: var(--line); transform: scaleY(.6); transform-origin: top; }
.ios-row:has(.tile) + .ios-row::before, .ios-row:has(.avatar) + .ios-row::before { left: 60px; }
button.ios-row:active, a.ios-row:active { background: var(--fill); }
.ios-row.static { cursor: default; }
.ios-row.center { justify-content: center; text-align: center; }
.ios-row.dim { opacity: .55; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-title.big { font-size: 20px; font-weight: 600; }
.row-sub { font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-detail { color: var(--muted); font-size: 17px; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.row-detail.small { font-size: 15px; }
.amt-col { flex-direction: column; align-items: flex-end; gap: 0; }
.chev { width: 8px; height: 14px; color: var(--faint); flex: none; }
.danger-text, .danger-text .row-title { color: var(--destructive); }
.accent-text, .accent-text .row-title { color: var(--accent); }
.tile { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-size: 18px; color: #fff; flex: none; position: relative; }
.tile.sm { width: 28px; height: 28px; font-size: 15px; border-radius: 7px; }
.tile-letter { font-size: 15px; font-weight: 600; color: #fff; }
.profile { min-height: 76px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 15px; flex: none; }
.avatar.lg { width: 60px; height: 60px; font-size: 26px; }
.avatar.xs { width: 24px; height: 24px; font-size: 12px; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card-head { margin-bottom: 8px; } .card-head h2 { margin: 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 12px; }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .val { font-size: 20px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.02em; }

/* ---------- segmented control, month switch ---------- */
.seg { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; min-height: 32px; padding: 4px 8px; border-radius: 7px; font-size: 14px; font-weight: 500; color: var(--text); letter-spacing: 0; }
.seg button.on { background: var(--card); font-weight: 600; box-shadow: 0 3px 8px rgba(0,0,0,.06), 0 0 0 .5px rgba(0,0,0,.04); }
:root[data-theme="dark"] .seg button.on { background: #636366; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button.on { background: #636366; } }
.seg button:disabled { opacity: .5; }
.nav-seg { margin-bottom: 12px; }
.nav-seg button, .theme-seg button { min-height: 36px; }
.seg.exp button.on[data-v=expense] { color: var(--danger); }
.seg.exp button.on[data-v=income] { color: var(--ok); }
.status-seg { flex-wrap: wrap; } .status-seg button { flex: 1 1 40%; }
.status-seg button.on { color: var(--text); }
.status-seg button.on::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: 1px; }
.month-switch { display: flex; align-items: center; justify-content: space-between; margin: 0 -4px 16px; }
.month-switch button { width: 44px; height: 44px; border: 0; background: none; color: var(--accent); display: grid; place-items: center; border-radius: 22px; }
.month-switch button svg { width: 10px; height: 18px; }
.month-switch .m { font-weight: 600; font-size: 17px; text-transform: capitalize; }

/* ---------- buttons, links, forms ---------- */
.btn { border: 0; border-radius: 12px; min-height: 50px; padding: 12px 20px; background: var(--accent); color: var(--on-accent); font-size: 17px; font-weight: 600; }
.btn:active { opacity: .7; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: var(--fill); color: var(--text); }
.btn.danger { background: var(--card); color: var(--destructive); }
.btn.destructive { background: var(--destructive); color: var(--on-destructive); }
.btn.block { width: 100%; display: block; }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; color: var(--accent); padding: 0; font-size: 17px; }
.link.small { font-size: 15px; }
label.f { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); margin: 24px 16px 8px; }
.input { width: 100%; min-height: 48px; padding: 12px 16px; border-radius: 10px; border: 0; background: var(--card); outline: none; font-size: 17px; }
.input:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
textarea.input { resize: vertical; min-height: 48px; line-height: 1.4; }
.amount-input { font-size: 34px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.title-input { font-size: 17px; font-weight: 600; }
.err { color: var(--danger); font-size: 15px; margin: 8px 16px 0; min-height: 1em; }
.field-err { color: var(--danger); font-size: 15px; margin: 8px 16px 0; }
.field-err:empty { display: none; }
.form-list .form-row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; position: relative; }
.form-list .form-row + .form-row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--line); transform: scaleY(.6); }
.form-row span { width: 72px; flex: none; }
.form-row input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 12px 0; font-size: 17px; }

/* chips (filters) */
.chips { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  /* full-bleed scroll row (iOS style): chips scroll edge to edge, vertical padding keeps the 44px hit areas inside so the row can't wobble vertically */
  margin: 0 -16px 8px; padding: 5px 16px; scroll-padding-inline: 16px; scrollbar-width: none; }
.chips > * { flex: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 0; background: var(--card); border-radius: 999px; min-height: 34px; padding: 6px 14px; font-size: 15px; white-space: nowrap; color: var(--text); }
.chip.on { background: var(--accent); color: var(--on-accent); }
.wrap-chips { flex-wrap: wrap; overflow: visible; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }

/* search field */
.search { display: flex; align-items: center; gap: 8px; background: var(--fill); border-radius: 10px; padding: 0 10px; margin-bottom: 12px; min-height: 40px; }
.search:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.search-ic { color: var(--muted); } .search-ic svg { width: 18px; height: 18px; }
.search-name { display: none; }
@media (min-width: 700px) { .search-name { display: inline; color: var(--muted); font-size: 15px; } }
.search input { flex: 1; border: 0; background: transparent; outline: none; padding: 8px 0; min-width: 0; font-size: 17px; }

/* ---------- transactions ---------- */
.tx .tile { font-size: 17px; }
.tx .who { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--card); }
.tx .amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 17px; }
.tx .amt .sub { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }

/* limits */
.limit { margin-bottom: 16px; } .limit:last-child { margin-bottom: 0; }
.bar { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: #34c759; border-radius: 3px; }
.bar > i.warn { background: #ff9500; } .bar > i.over { background: #ff3b30; }

/* charts */
.chart-box { position: relative; height: 220px; }
.legend { display: grid; gap: 0; margin-top: 12px; }
.legend .li { display: flex; align-items: center; gap: 8px; font-size: 15px; min-height: 36px; border-top: 1px solid var(--line); }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend .li .v { margin-left: auto; font-variant-numeric: tabular-nums; }

/* category picker & receipt */
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.cat { border: 0; background: var(--card); border-radius: 12px; padding: 12px 4px; text-align: center; font-size: 13px; line-height: 1.25; color: var(--text); }
.cat .ic { font-size: 24px; display: block; margin-bottom: 4px; }
.cat.on { box-shadow: 0 0 0 2px var(--accent) inset; color: var(--accent); font-weight: 600; }
.photo-btn { display: flex; align-items: center; gap: 12px; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--card); width: 100%; text-align: left; }
.photo-btn img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; }
.photo-btn .ph { width: 52px; height: 52px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; font-size: 24px; }
.receipt-full { width: 100%; border-radius: 12px; margin-top: 8px; }
.draft-note { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }

/* ---------- sheets (iOS modal sheet; centered form sheet on wide screens) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--sheet-bg); width: 100%; max-width: 620px; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow-y: auto; overscroll-behavior: contain;
  border-radius: 12px 12px 0 0; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); animation: up 300ms cubic-bezier(.2,.9,.3,1); }
.sheet .handle { width: 36px; height: 5px; border-radius: 3px; background: var(--faint); margin: 6px auto 0; opacity: .6; }
@media (min-width: 700px) {
  .sheet-bg { align-items: center; }
  .sheet { max-width: 540px; border-radius: 14px; max-height: min(86vh, 820px); }
  .sheet .handle { display: none; }
}
.sheet-nav { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 52px;
  margin: 0 -16px 8px; padding: 0 8px; background: var(--sheet-bg); }
.sheet-nav h2 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50vw; }
.nb-text { border: 0; background: none; color: var(--accent); font-size: 17px; min-height: 44px; padding: 0 8px; justify-self: start; }
.nb-text.strong { font-weight: 600; justify-self: end; }
.nb-text:disabled { opacity: .4; }
.nb-spacer { display: block; }
.sheet > .row.between:first-child, .sheet .card { background: var(--card); }
@keyframes up { from { transform: translateY(40px); opacity: .3; } to { transform: none; opacity: 1; } }

/* iOS alert for destructive confirmation */
.dialog-bg { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.4); display: grid; place-items: center; padding: 16px; }
.dialog { background: var(--bar); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); border-radius: 14px; width: 100%; max-width: 300px;
  text-align: center; overflow: hidden; animation: pop 200ms cubic-bezier(0,0,.2,1); border: 1px solid var(--line); }
.dialog h2 { font-size: 17px; font-weight: 600; margin: 20px 16px 4px; }
.dialog p { font-size: 13px; margin: 0 16px 20px; color: var(--text); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.dialog-actions .btn { border-radius: 0; background: none; min-height: 44px; font-size: 17px; font-weight: 400; color: var(--accent); padding: 8px; }
.dialog-actions .btn + .btn { border-left: 1px solid var(--line); }
.dialog-actions .btn.ghost { font-weight: 600; }
.dialog-actions .btn.destructive { color: var(--destructive); background: none; }
@keyframes pop { from { transform: scale(1.1); opacity: 0; } to { transform: none; opacity: 1; } }

/* toast (HUD) */
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--tip-bg); color: var(--tip-text);
  padding: 10px 16px; border-radius: 999px; font-size: 15px; z-index: 90; max-width: calc(100% - 32px); text-align: center; }

/* login */
.login { max-width: 400px; margin: 0 auto; padding: calc(10vh + env(safe-area-inset-top)) 16px 32px; }
.login .logo { display: grid; place-items: center; margin-bottom: 16px; }
.login .logo img { border-radius: 16px; }

/* misc */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty-state { background: var(--card); border-radius: var(--radius); padding: 32px 16px; text-align: center; margin-bottom: 16px; }
.empty-state b { display: block; font-size: 20px; }
.empty-state p { margin: 8px auto 16px; max-width: 46ch; }
.empty-state.inline { text-align: left; display: grid; gap: 4px; justify-items: start; padding: 16px; }
.empty-state.inline p { margin: 0 0 8px; max-width: none; }
.live { width: 8px; height: 8px; border-radius: 50%; background: #34c759; display: inline-block; margin-right: 4px; }
.live.off { background: var(--faint); }
.spinner { width: 20px; height: 20px; border: 2px solid var(--fill); border-top-color: var(--muted); border-radius: 50%; display: inline-block; vertical-align: middle;
  opacity: 0; animation: spin .8s linear infinite, appear 0s 120ms forwards; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes appear { to { opacity: 1; } }
.list-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-head { display: flex; gap: 8px; padding: 0 0 4px; align-items: center; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 0; background: transparent; color: var(--muted); font-size: 18px; display: grid; place-items: center; flex: none; }
.icon-btn:active { background: var(--fill); }
#cl .input { background: var(--card-2); }
#cl { background: var(--card); border-radius: var(--radius); padding: 8px 12px; }
.hint { text-align: center; margin-top: 16px; font-size: 13px; }

/* ---------- task board ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 12px; align-items: start;
  overflow-x: auto; margin: 0 -16px; padding: 0 16px 8px; scroll-snap-type: x mandatory; scroll-padding: 0 16px; }
@media (max-width: 1040px) { .board { grid-template-columns: repeat(4, min(84vw, 320px)); } }
.col { background: var(--fill); border-radius: 14px; padding: 8px; scroll-snap-align: start; min-width: 0; border: 2px solid transparent; }
.col.drop-target { border-color: var(--accent); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 8px 8px; }
.col-head b { font-size: 15px; }
.cdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-add { margin: -8px -4px -8px auto; border: 0; background: transparent; color: var(--accent); font-size: 22px; width: 44px; height: 44px; border-radius: 22px; }
.col-body { display: flex; flex-direction: column; gap: 8px; min-height: 64px; }
.col-empty { font-size: 15px; color: var(--muted); text-align: center; padding: 16px 8px; border: 1.5px dashed var(--line); border-radius: 10px; }
.tcard { background: var(--card); border-radius: 10px; padding: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.05);
  cursor: grab; position: relative; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overflow: hidden; }
.tcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: transparent; }
.tcard.prio-high::before { background: #ff3b30; } .tcard.prio-low::before { background: var(--faint); }
.tcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tc-title { font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.tc-desc { font-size: 13px; color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.tc-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.tcard.is-done .tc-title { text-decoration: line-through; color: var(--muted); }
.tcard.is-done { opacity: .75; }
.prio { font-weight: 600; }
.due { white-space: nowrap; }
.due.overdue { color: var(--danger); font-weight: 600; } .due.today { color: var(--warn); font-weight: 600; } .due.soon { color: var(--accent); }
.empty-av { background: var(--fill) !important; color: var(--muted); }
.tcard.drag-src { opacity: .35; box-shadow: none; outline: 1.5px dashed var(--faint); }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; box-shadow: 0 12px 28px rgba(0,0,0,.08); cursor: grabbing; opacity: .97; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }

/* ---------- currency converter ---------- */
.fx-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 840px) { .fx-grid { grid-template-columns: 1fr 1fr; } }
.fx-card { margin: 0; }
.fx-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 4px; }
.fx-card label.f { margin-left: 0; }
.fx-card .input { background: var(--card-2); }
.fx-amount { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fx-pair { display: flex; align-items: flex-end; gap: 8px; }
.fx-pair .grow { min-width: 0; }
.fx-pair select.input { padding-right: 8px; }
.fx-swap { margin-bottom: 2px; font-size: 20px; color: var(--accent); }
.fx-result { margin-top: 16px; padding: 16px; border-radius: 10px; background: var(--card-2); display: grid; gap: 4px; }
.fx-big { font-size: 28px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; letter-spacing: -0.02em; }

/* ---------- accessibility helpers ---------- */
button:focus-visible, a:focus-visible, [role=button]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip, .link { position: relative; }
.chip::before, .link::before { content: ''; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%); }
:where([data-tip]) { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--tip-bg); color: var(--tip-text); font-size: 13px; font-weight: 400; line-height: 1.4; padding: 4px 8px; border-radius: 8px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 100ms cubic-bezier(0,0,.2,1); }
[data-tip][data-tip-pos=top]::after { top: auto; bottom: calc(100% + 8px); }
[data-tip][data-tip-align=start]::after { left: 0; transform: none; }
[data-tip][data-tip-align=end]::after { left: auto; right: 0; transform: none; }
@media (hover: hover) { [data-tip]:hover::after { opacity: 1; } }
[data-tip]:focus-visible::after { opacity: 1; }
html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after { transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; transition-delay: 0ms !important; }
  .spinner { animation: appear 0s 120ms forwards !important; border-top-color: var(--accent); }
}

/* fields inside sheets use the elevated surface (matters in dark mode) */
.sheet .input, .sheet .photo-btn, .sheet .cat, .sheet .chip:not(.on), .sheet .ios-list, .sheet .card, .sheet #cl { background: var(--sheet-field); }
.sheet #cl .input { background: var(--sheet-bg); }
.tcard { background: var(--tcard); }

/* ---------- analytics ---------- */
:root { --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s-other: #a8a8ad; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s-other: #636366; } }
:root[data-theme="dark"] { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s-other: #636366; }
.wrap.an-wrap { max-width: 1200px; }
.an-filters { display: grid; gap: 8px; margin-bottom: 8px; }
.an-filters .chips { margin-bottom: 0; }
.an-custom { display: flex; gap: 8px; flex-wrap: wrap; }
.an-custom label { display: flex; align-items: center; gap: 8px; flex: 1 1 160px; }
.an-custom label span { color: var(--muted); font-size: 15px; width: 20px; }
.an-gran { max-width: 420px; }
.an-period { margin: 8px 0 16px; font-size: 15px; }
.an-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
@media (min-width: 700px) { .an-kpis { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.kpi.hero .val { font-size: 28px; }
.kpi-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.an-grid { display: grid; gap: 16px; align-items: start; }
@media (min-width: 900px) { .an-grid { grid-template-columns: minmax(320px, 5fr) 7fr; } }
.an-grid .card { margin-bottom: 0; }
.an-charts { display: grid; gap: 16px; }
.an-chart { height: 240px; }
.an-stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; margin: 4px 0 12px; background: var(--card); }
.an-stack i { min-width: 2px; }
.an-bars { display: grid; }
.an-bar { display: grid; gap: 4px; width: 100%; text-align: left; border: 0; background: none; padding: 10px 8px; margin: 0 -8px; width: calc(100% + 16px); border-radius: 10px; color: var(--text); }
.an-bar + .an-bar { border-top: 1px solid var(--line); border-radius: 0; }
.an-bar:hover, .an-bar.on { background: var(--fill); border-radius: 10px; }
.an-bar-top { display: flex; align-items: center; gap: 8px; }
.an-bar .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.an-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
.an-val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-share { width: 44px; text-align: right; color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.an-track { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; margin-left: 18px; }
.an-track i { display: block; height: 100%; border-radius: 3px; }
.an-meta { font-size: 13px; margin-left: 18px; }
.an-pick select { min-height: 36px; padding: 6px 10px; font-size: 15px; background: var(--card-2); max-width: 220px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.an-body > .ios-group { margin-top: 24px; }
/* category drop-down table */
.an-item + .an-item { border-top: 1px solid var(--line); }
.an-bar + .an-bar { border-top: 0; }
.an-meta { display: flex; align-items: center; gap: 4px; }
.an-caret { width: 12px; height: 8px; margin-left: auto; color: var(--faint); transition: transform 200ms cubic-bezier(0,0,.2,1); flex: none; }
.an-bar[aria-expanded="true"] .an-caret { transform: rotate(180deg); color: var(--accent); }
.an-det { margin: 4px 0 12px; background: var(--card-2); border-radius: 10px; padding: 4px 12px 8px; animation: up 200ms cubic-bezier(0,0,.2,1); }
.an-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.an-table th { font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); text-align: left; padding: 8px 4px 6px; }
.an-table td { padding: 7px 4px; vertical-align: top; border-top: 1px solid var(--line); }
.an-table tbody tr[data-tx] { cursor: pointer; }
.an-table tbody tr[data-tx]:hover td { background: var(--fill); }
.an-table tr[data-tx]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.an-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.an-table .dt { white-space: nowrap; width: 64px; color: var(--text); }
.an-table .wd, .an-table .orig { display: block; font-size: 12px; color: var(--muted); }
.an-table .who-n { font-size: 13px; color: var(--muted); }
.an-table .who-n::before { content: ' · '; }
.an-table .ds { overflow-wrap: anywhere; }
.an-table tr.subtotal td { border-top: 0; padding-top: 0; font-size: 13px; color: var(--muted); }
.an-table tfoot th, .an-table tfoot td { border-top: 1.5px solid var(--line); padding-top: 10px; font-weight: 600; font-size: 15px; color: var(--text); text-transform: none; letter-spacing: 0; }
.an-more { display: block; margin: 8px auto 0; font-size: 15px; }

/* ---------- app shell: fixed full-screen frame, content scrolls inside (stable on iOS Safari) ---------- */
html, body { overscroll-behavior: none; }
#app.shell { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
#app.shell .navbar { position: relative; flex: none; }
#app.shell .tabbar { position: relative; flex: none; }
.scroller { flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; }
/* sheets scroll only vertically: nothing may pan sideways under a swipe (iOS) */
.sheet { overflow-x: hidden; touch-action: pan-y; overscroll-behavior: contain; }
.sheet > *, .sheet .row > * { min-width: 0; max-width: 100%; }
.sheet .input, .sheet input, .sheet select, .sheet textarea { max-width: 100%; min-width: 0; }
/* iOS renders date inputs with an intrinsic min-width that overflows narrow containers */
input[type="date"].input { -webkit-appearance: none; appearance: none; display: block; min-width: 0; text-align: left; }
input[type="date"].input::-webkit-date-and-time-value { text-align: left; }
.sheet .cats { grid-template-columns: repeat(auto-fill, minmax(min(96px, 100%), 1fr)); }
.sheet-bg { overscroll-behavior: contain; touch-action: none; }
.sheet-bg > .sheet { touch-action: pan-y; }

/* ---------- voice dictation ---------- */
.nb-side.end { gap: 0; }
.v-mic-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 8px 0 16px; }
.v-mic { width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,113,227,.28); transition: transform .15s, background .2s; }
.v-mic svg { width: 38px; height: 38px; }
.v-mic:active { transform: scale(.94); }
.v-mic:disabled { background: var(--fill); color: var(--muted); box-shadow: none; }
.v-mic.on { background: var(--destructive, #ff3b30); box-shadow: 0 0 0 0 rgba(255,59,48,.45); animation: micPulse 1.4s ease-out infinite; }
@keyframes micPulse { 0% { box-shadow: 0 0 0 0 rgba(255,59,48,.45); } 100% { box-shadow: 0 0 0 22px rgba(255,59,48,0); } }
@media (prefers-reduced-motion: reduce) { .v-mic.on { animation: none; } }
.v-card { background: var(--card); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; border-left: 4px solid var(--accent); }
.v-card.inc { border-left-color: #34C759; }
.v-card .input { background: var(--card-2); min-height: 44px; padding: 10px 12px; font-size: 16px; }
.v-top { display: flex; gap: 8px; align-items: center; }
.v-top .v-amt { flex: 1 1 auto; font-size: 20px; font-weight: 600; }
.v-top .v-cur { flex: 0 0 84px; width: 84px; }
.v-row { display: grid; grid-template-columns: minmax(0, 140px) minmax(0, 1fr); gap: 8px; }
.v-del { flex: 0 0 44px; width: 44px; height: 44px; border: 0; border-radius: 22px; background: none; color: var(--muted); font-size: 18px; }
.v-del:active { background: var(--fill); }
.v-card .field-err { margin: 0 4px; }

/* ---------- wish list ---------- */
.tab { min-width: 0; }
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, calc(50% - 6px)), 1fr)); gap: 12px; }
.wish { position: relative; background: var(--card); border-radius: var(--radius); overflow: hidden; min-width: 0; }
.wish-open { display: flex; flex-direction: column; width: 100%; border: 0; padding: 0; background: none; text-align: left; color: var(--text); }
.wish-open:active { opacity: .7; }
.wish-img { position: relative; display: block; aspect-ratio: 1; background: #fff; overflow: hidden; }
.wish-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.wish-ph { position: absolute; inset: 0; display: grid; place-items: center; background: var(--card-2); color: var(--faint); }
.wish-ph svg { width: 44px; height: 44px; }
.wish-flag { position: absolute; left: 8px; top: 8px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: #FF9500; color: #fff; }
.wish-flag.ok { background: #34C759; }
.wish-body { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px 12px; min-width: 0; }
.wish-title { font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.wish-price { font-size: 17px; font-weight: 600; }
.wish-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.wish-meta .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.wish-link { position: absolute; right: 6px; top: 6px; width: 36px; height: 36px; border-radius: 18px; display: grid; place-items: center; background: rgba(255,255,255,.92); color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.wish-link::after { content: ""; position: absolute; inset: -4px; }
.wish-link svg { width: 18px; height: 18px; }
.wish.bought .wish-img img, .wish.bought .wish-title { opacity: .55; }
.wish-prev { display: flex; align-items: center; gap: 12px; margin: 8px 0 4px; padding: 0 4px; }
.wish-prev img { width: 88px; height: 88px; object-fit: contain; background: #fff; border-radius: 12px; }
.dialog-actions:has(.strong) .btn.ghost { font-weight: 400; }
.dialog-actions .btn.strong { font-weight: 600; }
@media (min-width: 700px) { .wish-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
@media (max-width: 440px) { .tabbar { padding-left: 2px; padding-right: 2px; } .tab { font-size: 10.5px; } }
@media (max-width: 360px) { .tab { font-size: 9.5px; letter-spacing: -.2px; } .tab svg { width: 24px; height: 24px; } }
@media (max-width: 340px) { .tabbar { padding-left: 0; padding-right: 0; } .tab { font-size: 9px; letter-spacing: -.3px; } }
.v-top .v-title { flex: 1 1 auto; font-weight: 600; }
.v-row .v-pri { min-width: 0; }
.v-entry { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; border-radius: 12px; padding: 10px 12px 10px 10px; margin: 4px 0 8px; background: var(--card); color: var(--text); text-align: left; }
.v-entry:active { background: var(--fill); }
.v-entry-ic { flex: none; width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); }
.v-entry-ic svg { width: 22px; height: 22px; }
.v-entry-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.v-entry-t b { font-size: 16px; font-weight: 600; }
.v-entry-t span { font-size: 13px; color: var(--muted); }
.v-entry .chev { flex: none; width: 8px; height: 14px; color: var(--faint); }

/* ---------- rate history ---------- */
.fx-hist { margin-top: 16px; }
.fx-hist .input { background: var(--card-2); }
.fx-hist label.f { margin-left: 0; }
.fx-hist-sum { margin: 14px 0 6px; display: grid; gap: 6px; min-height: 24px; }
.fx-hist-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.fx-hist-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; align-self: center; }
.fx-hist-row .grow { flex: 1 1 auto; min-width: 60px; }
.fx-chart { height: 240px; margin-top: 4px; }
.fx-hist .fx-pair { margin-top: 4px !important; }

/* ---------- training ---------- */
:root { --ill-body: #3a3a3c; --ill-eq: #8e8e93; --ill-text: #3a3a3c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ill-body: #d1d1d6; --ill-eq: #8e8e93; --ill-text: #e5e5ea; } }
:root[data-theme="dark"] { --ill-body: #d1d1d6; --ill-eq: #8e8e93; --ill-text: #e5e5ea; }
.tr-next .tr-next-t { font-size: 22px; font-weight: 700; margin: 2px 0 4px; }
.tr-up { color: var(--ok); font-weight: 600; }
.tr-text { padding: 4px 16px; }
.tr-text p { margin: 10px 0; line-height: 1.4; }
.tr-steps, .tr-list { margin: 0; padding: 10px 16px 10px 36px; line-height: 1.45; }
.tr-steps li, .tr-list li { margin: 6px 0; }
.tr-list.ok li::marker { content: '✓  '; color: var(--ok); }
.tr-list.bad li::marker { content: '✕  '; color: var(--danger); }
.tr-ills { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px 12px; padding: 0 16px 4px; overscroll-behavior-x: contain; touch-action: pan-x pan-y; }
.sheet .tr-ills { overflow-x: auto; }
.tr-ill { flex: 0 0 86%; max-width: 360px; scroll-snap-align: center; margin: 0; background: var(--card); border-radius: var(--radius); padding: 8px 10px 12px; }
.tr-ill svg { width: 100%; height: auto; display: block; }
.tr-ill figcaption { font-size: 14px; line-height: 1.35; margin-top: 4px; }
.tr-ill-b { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin: 0 6px 4px 0; }
.tr-ill-b.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.tr-ill-b.bad { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.tr-ill-b.info { background: var(--accent-soft); color: var(--accent); }
.tr-chart { height: 200px; padding: 0 12px 12px; }
.tr-w { display: block; width: 100%; text-align: left; border: 0; color: var(--text); }
.tr-w:active { opacity: .7; }
.tr-w-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tr-badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.tr-w-r { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 3px 0; }
.tr-w-r span:last-child { text-align: right; }
.wk-ex { padding: 12px; margin: 12px 0 0; }
.wk-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wk-name { font-size: 17px; font-weight: 600; text-align: left; }
.wk-sets { display: grid; gap: 6px; margin: 8px 0 4px; }
.wk-set { display: flex; align-items: center; gap: 6px; }
.wk-set .input { min-height: 44px; padding: 8px 10px; background: var(--card-2); font-size: 17px; flex: 1 1 0; min-width: 0; text-align: center; }
.wk-n { width: 20px; flex: none; color: var(--muted); font-weight: 600; text-align: center; }
.wk-u { flex: none; color: var(--muted); font-size: 14px; }
.seg.nav-seg button { padding-left: 4px; padding-right: 4px; }
.tr-star { color: #FF9500; margin-right: 4px; font-weight: 700; }
.ios-row.tr-base { background: color-mix(in srgb, #FF9500 9%, var(--card)); }
.ios-row.tr-base .row-title { font-weight: 600; }
.tr-base-t { color: #c45f00; font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tr-base-t { color: #FF9F0A; } }
:root[data-theme="dark"] .tr-base-t { color: #FF9F0A; }
.tr-base-badge { display: inline-block; font-size: 13px; font-weight: 700; color: #c45f00; background: color-mix(in srgb, #FF9500 16%, transparent); padding: 3px 10px; border-radius: 999px; margin: 0 0 8px; }
.ios-row.dim .row-title { color: var(--muted); }
