/* JOKER — светлая тема по умолчанию, тёмная — data-theme="dark" */
:root {
  --bg: #F3F4F7;
  --s1: #FFFFFF;
  --s2: #F4F5F8;
  --s3: #ECEEF2;
  --s4: #FFFFFF;
  --line: rgba(16, 18, 27, 0.07);
  --line-2: rgba(16, 18, 27, 0.10);
  --line-3: rgba(16, 18, 27, 0.18);
  --text: #12131A;
  --text-2: #4C4F5C;
  --muted: #858896;
  --accent: #6C55E0;
  --accent-2: #5B44D1;
  --accent-soft: rgba(108, 85, 224, 0.09);
  --accent-line: rgba(108, 85, 224, 0.32);
  --plus: #0E9F6E;
  --plus-soft: rgba(14, 159, 110, 0.10);
  --minus: #B4534F;
  --minus-text: #B4534F;
  --minus-soft: rgba(180, 83, 79, 0.10);
  --amber: #B7841C;
  --amber-soft: rgba(214, 170, 60, 0.14);
  --tint: rgba(16, 18, 27, 0.045);
  --header-bg: rgba(243, 244, 247, 0.82);
  --toast-bg: rgba(255, 255, 255, 0.98);
  --primary-grad: linear-gradient(180deg, #7C66EA, #6A52DE);
  --primary-text: #FFFFFF;
  --primary-glow: 0 8px 22px -10px rgba(108, 85, 224, .55);
  --glow-1: rgba(108, 85, 224, 0.07);
  --glow-2: rgba(14, 159, 110, 0.04);
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 18px;
  --shadow: 0 1px 2px rgba(16, 18, 27, 0.04), 0 10px 30px -18px rgba(16, 18, 27, 0.18);
  --ease: cubic-bezier(.2,.7,.2,1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #090A0C;
  --s1: #121318;
  --s2: #18191F;
  --s3: #1D1E25;
  --s4: #24252E;
  --line: rgba(255, 255, 255, 0.06);
  --line-2: rgba(255, 255, 255, 0.10);
  --line-3: rgba(255, 255, 255, 0.16);
  --text: #F4F4F7;
  --text-2: #A3A4B0;
  --muted: #6B6D7A;
  --accent: #9B87F5;
  --accent-2: #B4A5F8;
  --accent-soft: rgba(155, 135, 245, 0.12);
  --accent-line: rgba(155, 135, 245, 0.32);
  --plus: #32D6A0;
  --plus-soft: rgba(50, 214, 160, 0.12);
  --minus: #A35B58;
  --minus-text: #CE8A86;
  --minus-soft: rgba(163, 91, 88, 0.16);
  --amber: #E2BD5C;
  --amber-soft: rgba(214, 170, 60, 0.14);
  --tint: rgba(255, 255, 255, 0.05);
  --header-bg: rgba(9, 10, 12, 0.72);
  --toast-bg: rgba(29, 30, 37, 0.96);
  --primary-grad: linear-gradient(180deg, #A897F7, #8F79F0);
  --primary-text: #120E24;
  --primary-glow: 0 8px 24px -10px rgba(155,135,245,.7);
  --glow-1: rgba(155, 135, 245, 0.10);
  --glow-2: rgba(50, 214, 160, 0.04);
  --shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 20px 50px -20px rgba(0,0,0,0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--glow-1), transparent 60%),
    radial-gradient(700px 400px at 100% 0%, var(--glow-2), transparent 60%);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.plus { color: var(--plus); }
.minus { color: var(--minus-text); }
.muted { color: var(--muted); }
.sec { color: var(--text-2); }
.hidden { display: none !important; }
::selection { background: rgba(155,135,245,.35); }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 30;
  background: var(--header-bg);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1240px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 22px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(140deg, #B4A5F8 0%, #7C66E8 55%, #4B3BB0 100%);
  box-shadow: 0 6px 20px -6px rgba(155,135,245,.6), inset 0 1px 0 rgba(255,255,255,.35);
  font-weight: 800; font-size: 17px; color: #fff; letter-spacing: -0.02em;
}
.logo-word { font-weight: 700; letter-spacing: 0.26em; font-size: 14px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--s1); border: 1px solid var(--line-2); border-radius: 12px; }
.seg button {
  border: 0; background: transparent; padding: 7px 16px; border-radius: 9px; color: var(--text-2); font-weight: 500;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--s4); color: var(--text); box-shadow: 0 1px 0 var(--tint) inset, 0 2px 8px -3px rgba(0,0,0,.22); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.sync-pill {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 12px;
  background: var(--s1); border: 1px solid var(--line-2); border-radius: 12px; font-size: 12.5px; color: var(--text-2);
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--plus); box-shadow: 0 0 0 3px rgba(50,214,160,.15); }
.sync-dot.warn { background: #C9A227; box-shadow: 0 0 0 3px rgba(201,162,39,.15); }
.sync-dot.err { background: var(--minus-text); box-shadow: 0 0 0 3px var(--minus-soft); }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px;
  background: transparent; border: 1px solid transparent; color: var(--text-2); transition: all .2s var(--ease);
}
.icon-btn:hover { background: var(--s2); color: var(--text); border-color: var(--line-2); }
.sync-pill .icon-btn { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn.spinning svg { animation: sp 0.9s linear infinite; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: var(--s2); border-radius: 12px;
  padding: 9px 16px; white-space: nowrap; font-weight: 500;
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .1s;
}
.btn:hover { background: var(--s3); border-color: var(--line-3); }
.btn:active { transform: scale(.98); }
.btn.primary {
  background: var(--primary-grad); border-color: transparent; color: var(--primary-text); font-weight: 600;
  box-shadow: var(--primary-glow), inset 0 1px 0 rgba(255,255,255,.3);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--s2); color: var(--text); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Layout ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 26px 24px 80px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.025em; }
.page-head .spacer { flex: 1; }
.subnav { display: flex; gap: 4px; margin-bottom: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav button {
  position: relative; border: 0; background: transparent; padding: 10px 14px 13px; color: var(--text-2); font-weight: 500; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.subnav button:hover { color: var(--text); }
.subnav button.active { color: var(--text); }
.subnav button.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.subnav .count { font-size: 11px; padding: 1px 7px; border-radius: 20px; background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.subnav .count.warn { background: var(--amber-soft); color: var(--amber); }

/* Разобрать */
.review-hero {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 18px 20px;
  background: radial-gradient(500px 200px at 0% 0%, rgba(214,170,60,.12), transparent 70%), var(--s1);
  border-color: rgba(214,170,60,.28);
}
.review-hero .ico { background: var(--amber-soft); color: var(--amber); width: 44px; height: 44px; border-radius: 14px; }
.review-hero .t1 { font-weight: 600; font-size: 15.5px; }
.review-hero .t2 { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.review-hero .btn { margin-left: auto; }
.party {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; padding: 16px 0; border-top: 1px solid var(--line);
  transition: opacity .3s, transform .3s;
}
.party:first-child { border-top: 0; }
.party.done { opacity: 0; transform: translateX(20px); }
.party .ava { width: 44px; height: 44px; }
.party-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.party .name { font-weight: 600; font-size: 15px; }
.party .type { font-size: 12px; color: var(--muted); margin-left: 8px; font-weight: 500; }
.party .flows { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.party .flows b { color: var(--text); font-weight: 600; }
.party .flows .plus b { color: var(--plus); }
.party .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.party .actions .chip-btn { padding: 6px 11px; font-size: 12.5px; }
.party .actions .chip-btn svg { width: 14px; height: 14px; }
.party .hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-2); font-size: 12.5px; }
.link-btn:hover { color: #fff; }
.split-box { background: var(--s2); border: 1px solid var(--line-2); border-radius: 14px; padding: 14px; margin-top: 8px; }
.split-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 8px; align-items: center; margin-top: 8px; }
.split-row:first-child { margin-top: 0; }
.split-row .lbl { font-size: 12.5px; color: var(--text-2); }
.split-total { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.tag-split { border-color: var(--accent-line) !important; }

.month-pick { display: inline-flex; align-items: center; background: var(--s1); border: 1px solid var(--line-2); border-radius: 12px; height: 40px; }
.month-pick button { border: 0; background: transparent; width: 36px; height: 100%; color: var(--text-2); display: grid; place-items: center; border-radius: 10px; }
.month-pick button:hover:not(:disabled) { color: var(--text); background: var(--s2); }
.month-pick button:disabled { opacity: .3; cursor: default; }
.month-pick .label { min-width: 138px; text-align: center; font-weight: 600; font-size: 14px; }

.view { animation: fadeUp .45s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.stack { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.stack > *, .grid-2 > *, .grid-3 > *, .grid-main > * { min-width: 0; }
canvas { max-width: 100%; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent 40%), var(--s1);
  border: 1px solid var(--line-2); border-radius: var(--r-l); padding: 22px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.card-head h2 { margin: 0; font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }
.card-head .hint { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.card-head .link { margin-left: auto; font-size: 13px; color: var(--accent-2); background: none; border: 0; padding: 0; }
.card-head .link:hover { color: #fff; }

/* Hero */
.hero {
  position: relative; overflow: hidden; padding: 26px 26px 0;
  background:
    radial-gradient(600px 260px at 0% 0%, rgba(155,135,245,0.22), transparent 70%),
    radial-gradient(400px 200px at 100% 100%, rgba(155,135,245,0.10), transparent 70%),
    var(--s1);
  border-color: var(--accent-line);
}
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hero-label { color: var(--text-2); font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.hero-value { font-size: 44px; font-weight: 700; letter-spacing: -0.035em; line-height: 1.1; margin-top: 8px; }
.hero-value .kop { color: var(--text-2); font-weight: 600; font-size: 30px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 9px;
  background: var(--tint); border: 1px solid var(--line-2); font-size: 12.5px; color: var(--text-2);
}
.chip svg { width: 14px; height: 14px; }
.hero-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.hero-chart { height: 110px; margin: 14px -26px 0; }
.hero-range { display: flex; gap: 18px; }
.hero-range div { text-align: right; }
.hero-range .l { font-size: 12px; color: var(--muted); }
.hero-range .v { font-size: 15px; font-weight: 600; margin-top: 2px; }

/* Stat tiles */
.stat { padding: 20px; position: relative; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { color: var(--text-2); font-size: 13px; }
.ico {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent-2);
}
.ico svg { width: 18px; height: 18px; }
.ico.green { background: var(--plus-soft); color: var(--plus); }
.ico.red { background: var(--minus-soft); color: var(--minus-text); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; margin-top: 14px; }
.stat-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 7px; font-size: 12px; font-weight: 600;
  background: var(--tint); color: var(--text-2);
}
.pill.good { background: var(--plus-soft); color: var(--plus); }
.pill.bad { background: var(--minus-soft); color: var(--minus-text); }
.pill svg { width: 12px; height: 12px; }
.compare { height: 4px; border-radius: 4px; background: var(--s3); margin-top: 14px; position: relative; overflow: hidden; }
.compare i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; transition: width .8s var(--ease); }

.aside-row { display: flex; gap: 12px; flex-wrap: wrap; }
.aside {
  flex: 1; min-width: 220px; display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--s1); border: 1px solid var(--line-2); border-radius: var(--r-m);
}
.aside .t { font-size: 12.5px; color: var(--text-2); }
.aside .v { font-weight: 600; font-size: 15px; margin-top: 1px; }
.aside .ico { width: 32px; height: 32px; border-radius: 10px; background: var(--tint); color: var(--text-2); }
.aside .badge { margin-left: auto; }

/* Category list */
.donut-row { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: center; }
.donut-wrap { position: relative; width: 220px; height: 220px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center .v { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.donut-center .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cat-list { display: flex; flex-direction: column; }
.cat-item {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 10px; margin: 0 -10px; border-radius: 12px; cursor: pointer; transition: background .15s;
}
.cat-item:hover { background: var(--s2); }
.cat-item .ico { width: 36px; height: 36px; }
.cat-item .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item .meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.cat-item .amt { text-align: right; font-weight: 600; }
.cat-item .pct { font-size: 12px; color: var(--muted); text-align: right; margin-top: 1px; }
.cat-item .bar { grid-column: 2 / 4; height: 3px; border-radius: 3px; background: var(--s3); margin-top: -4px; overflow: hidden; }
.cat-item .bar i { display: block; height: 100%; border-radius: 3px; transition: width .8s var(--ease); }
.group-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 6px; font-weight: 600; }

.chart-box { position: relative; height: 280px; }
.legend { display: flex; gap: 16px; margin-left: auto; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; border-radius: 2px; width: 14px; }

/* Dynamics */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-bottom: 18px; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 10px; white-space: nowrap;
  background: var(--s2); border: 1px solid var(--line-2); color: var(--text-2); font-size: 13px; font-weight: 500; transition: all .15s;
}
.chip-btn:hover { color: var(--text); border-color: var(--line-3); }
.chip-btn.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.chip-btn .dot { width: 8px; height: 8px; border-radius: 3px; }
.dyn-stats { display: flex; gap: 28px; margin-bottom: 14px; flex-wrap: wrap; }
.dyn-stats .l { font-size: 12px; color: var(--muted); }
.dyn-stats .v { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }

.heat { width: 100%; border-collapse: separate; border-spacing: 0 4px; }
.heat th { font-weight: 500; color: var(--muted); font-size: 12px; text-align: right; padding: 4px 8px; white-space: nowrap; }
.heat th:first-child { text-align: left; }
.heat td { padding: 0; }
.heat td .cell { margin: 0 2px; padding: 8px 8px; border-radius: 8px; text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.heat td.name { position: sticky; left: 0; z-index: 1; background: var(--s1); padding-right: 8px; min-width: 170px; }
.heat td.name .in { display: flex; align-items: center; gap: 10px; padding: 4px 8px; border-radius: 10px; font-weight: 500; cursor: pointer; }
.heat td.name .in:hover { background: var(--s2); }
.heat tr.sel td.name .in { background: var(--accent-soft); }
.heat .ico { width: 28px; height: 28px; border-radius: 9px; }
.heat .ico svg { width: 15px; height: 15px; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -22px; padding: 0 22px; }

/* Leaks */
.insight { display: flex; flex-direction: column; }
.insight .head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.insight h3 { margin: 0; font-size: 15px; font-weight: 600; }
.insight .lead { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.insight .big { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.row-item { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.row-item:first-of-type { border-top: 0; }
.row-item .t1 { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .t2 { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.row-item .r { text-align: right; font-weight: 600; }
.row-item .r small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }
.empty-mini { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; padding: 12px 0; }
.empty-mini svg { width: 18px; height: 18px; color: var(--plus); }
.badge { display: inline-flex; align-items: center; font-size: 11px; padding: 2px 8px; border-radius: 7px; background: var(--tint); color: var(--text-2); font-weight: 500; white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent-2); }
.badge.bad { background: var(--minus-soft); color: var(--minus-text); }

/* Avatars */
.ava {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 600; font-size: 13.5px; letter-spacing: -0.01em; position: relative;
}
.ava.sm { width: 34px; height: 34px; font-size: 12px; }
.ava .mini {
  position: absolute; right: -3px; bottom: -3px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; border: 2px solid var(--s1);
}
.ava .mini svg { width: 10px; height: 10px; }

/* Transactions */
.tx-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-bottom: 12px; }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.input {
  width: 100%; height: 42px; background: var(--s2); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 0 14px; outline: none; min-width: 0; transition: border-color .15s, background .15s;
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--accent-line); background: var(--s3); }
.search .input { padding-left: 40px; }

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.filter-row .input { width: auto; height: 36px; font-size: 13px; border-radius: 10px; }
.select-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 10px; background: var(--s2); border: 1px solid var(--line-2); color: var(--text-2); font-size: 13px; font-weight: 500; }
.select-btn:hover { color: var(--text); border-color: var(--line-3); }
.select-btn.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.select-btn svg { width: 14px; height: 14px; }
.tx-summary { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; padding: 6px 2px 0; }

.day { margin-top: 18px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 6px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.day-head .num { font-weight: 500; color: var(--muted); font-size: 12.5px; }
.tx {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 11px 10px; margin: 0 -10px; border-radius: 14px; transition: background .15s;
}
.tx:hover { background: var(--s2); }
.tx .who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .what { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.tx .right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.tx .amt { font-weight: 600; font-size: 14.5px; }
.cat-tag {
  display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 3px 9px 3px 7px; border-radius: 8px;
  background: var(--tint); border: 1px solid transparent; font-size: 12px; color: var(--text-2); transition: all .15s;
}
.cat-tag:hover { border-color: var(--accent-line); color: var(--text); background: var(--accent-soft); }
.cat-tag .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.cat-tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-tag svg { width: 12px; height: 12px; opacity: .6; flex: none; }
.cat-tag.manual { border-color: var(--accent-line); }
.more { text-align: center; margin-top: 16px; }

/* Skeleton */
.sk { background: linear-gradient(90deg, var(--s2) 0%, var(--s3) 50%, var(--s2) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.loading .hero-value, .loading .stat-value { color: transparent; }
.loading .hero-value::after, .loading .stat-value::after { content: ""; }

/* ---------- Sheets (modals) ---------- */
.sheet-bg {
  position: fixed; inset: 0; background: rgba(4,4,6,0.66); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .2s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  background: var(--s1); border: 1px solid var(--line-2); border-radius: 22px; width: 100%; max-width: 560px;
  max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 40px 100px -20px rgba(0,0,0,.8);
  animation: pop .28s var(--ease) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 14px; }
.sheet-head h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.sheet-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.sheet-head .icon-btn { margin-left: auto; }
.sheet-body { padding: 4px 22px 18px; overflow-y: auto; }
.sheet-foot { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); }
.sheet .grab { display: none; }
.field-label { font-size: 12px; color: var(--muted); margin: 16px 0 6px; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; }
.field-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.pick-list { display: flex; flex-direction: column; gap: 2px; }
.pick {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 8px 10px; border-radius: 12px; border: 1px solid transparent; background: transparent; text-align: left; width: 100%;
}
.pick:hover { background: var(--s2); }
.pick.active { background: var(--accent-soft); border-color: var(--accent-line); }
.pick .ico { width: 34px; height: 34px; }
.pick .check { color: var(--accent); }
.pick .check svg { width: 18px; height: 18px; }
.edit-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 6px 0; }
.edit-row .ico { width: 34px; height: 34px; }
.edit-row .input { height: 38px; }
.rule-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.rule-row:first-child { border-top: 0; }
.rule-row .t2 { color: var(--muted); font-size: 12px; margin-top: 1px; }
.export-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.export-opt {
  display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 14px; text-align: left;
  background: var(--s2); border: 1px solid var(--line-2); transition: all .15s;
}
.export-opt:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.export-opt b { font-size: 15px; }
.export-opt span { font-size: 12px; color: var(--muted); }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--toast-bg); backdrop-filter: blur(14px); border: 1px solid var(--line-3); border-radius: 18px;
  padding: 16px 18px; width: calc(100% - 32px); max-width: 520px; box-shadow: 0 24px 60px -10px rgba(0,0,0,.7);
  animation: toastIn .3s var(--ease) both;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast .row { display: flex; gap: 12px; align-items: flex-start; }
.toast .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-m); margin-bottom: 16px; background: var(--s1); border: 1px solid var(--line-2); font-size: 13px; color: var(--text-2); }
.banner.err { border-color: rgba(206,138,134,.35); background: linear-gradient(0deg, var(--minus-soft), var(--minus-soft)), var(--s1); }
.banner svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

/* Placeholder (Клиенты) */
.soon { text-align: center; padding: 80px 24px; position: relative; overflow: hidden; }
.soon .ico { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 20px; }
.soon .ico svg { width: 28px; height: 28px; }
.soon h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: -0.02em; }
.soon p { margin: 0 auto; color: var(--text-2); max-width: 420px; }
.soon .features { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }

.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line-3); border-top-color: var(--accent); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 380px; padding: 34px 30px 30px; text-align: center; }
.login .logo-mark { width: 56px; height: 56px; border-radius: 17px; font-size: 26px; margin: 0 auto 18px; }
.login h1 { margin: 0; font-size: 22px; letter-spacing: 0.24em; font-weight: 700; }
.login .sub { color: var(--muted); margin: 6px 0 26px; font-size: 13.5px; }
.login .input { height: 48px; margin-bottom: 12px; font-size: 15px; text-align: left; }
.login .btn { width: 100%; height: 48px; font-size: 15px; }
.login .err { color: var(--minus-text); font-size: 13px; margin-bottom: 12px; background: var(--minus-soft); border-radius: 10px; padding: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .donut-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .donut-wrap { margin: 0 auto; }
  .logo-word { display: none; }
}
@media (max-width: 640px) {
  .top-in { padding: 10px 16px; gap: 10px; }
  .seg button { padding: 7px 11px; }
  .top-right { gap: 4px; }
  .sync-pill .txt { display: none; }
  .sync-pill { padding: 0 2px 0 9px; gap: 6px; }
  .subnav button { padding: 10px 10px 13px; }
  .subnav button.active::after { left: 6px; right: 6px; }
  main { padding: 18px 16px 90px; }
  .page-head h1 { font-size: 22px; }
  .page-head { gap: 10px; }
  .page-head .spacer { display: none; }
  .month-pick { width: 100%; justify-content: space-between; }
  .page-head .actions { display: flex; gap: 8px; width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .card { padding: 18px; border-radius: 16px; }
  .hero { padding: 20px 18px 0; }
  .hero-value { font-size: 34px; }
  .hero-value .kop { font-size: 22px; }
  .hero-chart { margin: 10px -18px 0; height: 90px; }
  .hero-range { width: 100%; justify-content: space-between; }
  .hero-range div { text-align: left; }
  .stat { padding: 16px 18px; }
  .stat-value { font-size: 22px; margin-top: 10px; }
  .scroll-x { margin: 0 -18px; padding: 0 18px; }
  .chart-box { height: 230px; }
  .tx { grid-template-columns: 40px minmax(0, 1fr); }
  .tx .right { grid-column: 2; flex-direction: row-reverse; justify-content: space-between; align-items: center; margin-top: -2px; }
  .cat-tag { max-width: 60%; }
  .tx-tools { grid-template-columns: minmax(0, 1fr); }
  .sheet-bg { align-items: flex-end; padding: 0; }
  .sheet { border-radius: 22px 22px 0 0; max-height: 90vh; animation: slideUp .3s var(--ease) both; }
  .sheet .grab { display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line-3); margin: 10px auto 0; }
  .sheet-head { padding-top: 12px; }
  .export-opts { grid-template-columns: 1fr; }
  .legend { margin-left: 0; width: 100%; }
  .card-head { flex-wrap: wrap; }
  .toast { bottom: 16px; }
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ================= Новые разделы ================= */
.seg.main { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.seg.main::-webkit-scrollbar { display: none; }
.seg.main button { white-space: nowrap; }
.bottom-nav { display: none; }

/* Деньги: всего / банк / наличные */
.money-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.money-box { background: var(--tint); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.money-box .l { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.money-box .v { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.money-box .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.money-box .acts .chip-btn { padding: 5px 10px; font-size: 12.5px; }
.money-box .acts svg, .money-box .l svg { width: 14px; height: 14px; }

/* Сегодня / подсказки */
.insight-row { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.insight-row:first-child { border-top: 0; }
.insight-row .ico { width: 34px; height: 34px; }
.ico.amber { background: var(--amber-soft); color: var(--amber); }
.goal-bar { height: 8px; border-radius: 8px; background: var(--s3); overflow: hidden; margin-top: 10px; }
.goal-bar i { display: block; height: 100%; border-radius: 8px; background: var(--accent); transition: width .8s var(--ease); }

/* Календарь */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .wd { text-align: center; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 4px 0; text-transform: uppercase; letter-spacing: .05em; }
.cal .day-cell { min-height: 84px; border-radius: 12px; border: 1px solid var(--line); background: var(--s1); padding: 6px; cursor: pointer; transition: border-color .15s, background .15s; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal .day-cell:hover { border-color: var(--accent-line); }
.cal .day-cell.other { opacity: .35; }
.cal .day-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal .day-cell.sel { background: var(--accent-soft); border-color: var(--accent-line); }
.cal .dn { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.cal .ev { font-size: 11px; line-height: 1.25; padding: 2px 5px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.payment, .ev.bank { background: var(--accent-soft); color: var(--accent-2); }
.ev.supply { background: var(--plus-soft); color: var(--plus); }
.ev.task { background: var(--amber-soft); color: var(--amber); }
.ev.done { text-decoration: line-through; opacity: .6; }
.cal .dots { display: none; gap: 3px; flex-wrap: wrap; }
.cal .dots i { width: 6px; height: 6px; border-radius: 50%; }

/* Универсальные строки списка */
.row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .t1 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .t2 { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.row .r { text-align: right; }
.row .r b { font-size: 15px; }
.row.click { cursor: pointer; border-radius: 12px; margin: 0 -10px; padding-left: 10px; padding-right: 10px; }
.row.click:hover { background: var(--s2); }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.mini-stat { background: var(--tint); border-radius: 12px; padding: 12px 14px; }
.mini-stat .l { font-size: 12px; color: var(--muted); }
.mini-stat .v { font-size: 18px; font-weight: 700; margin-top: 3px; letter-spacing: -0.01em; }
.subtabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.lbl { font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }

/* Мысли */
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 46px; max-height: 200px; resize: vertical; padding: 12px 14px; height: auto; line-height: 1.4; font: inherit; }
.thought { display: grid; grid-template-columns: 28px minmax(0,1fr) auto; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.thought:first-child { border-top: 0; }
.thought .txt { white-space: pre-wrap; word-break: break-word; }
.thought .meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.thought.done .txt { text-decoration: line-through; color: var(--muted); }
.check-btn { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line-3); background: transparent; display: grid; place-items: center; padding: 0; color: transparent; margin-top: 1px; }
.check-btn.on { background: var(--plus); border-color: var(--plus); color: #fff; }
.check-btn svg { width: 14px; height: 14px; }
.note-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-3); margin: 8px 0 0 8px; }

@media (max-width: 760px) {
  .top .seg.main { display: none; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--header-bg); backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: var(--muted); padding: 4px 0; font-weight: 500; }
  .bottom-nav button svg { width: 21px; height: 21px; }
  .bottom-nav button.active { color: var(--accent); }
  main { padding-bottom: 100px; }
  .toast { bottom: 84px; }
  .money-split { grid-template-columns: 1fr; }
  .cal { gap: 3px; }
  .cal .day-cell { min-height: 46px; padding: 4px; border-radius: 9px; align-items: center; }
  .cal .ev { display: none; }
  .cal .dots { display: flex; justify-content: center; }
  .form-grid { grid-template-columns: 1fr; }
}

.chip-btn svg { width: 15px; height: 15px; flex: none; }
.chip-btn input[type=checkbox] { accent-color: var(--accent); }
