/* ── Токены ─────────────────────────────────────────────────────────── */
:root {
  --bg: #F4F3EF;
  --surface: #FFFFFF;
  --surface-2: #EEECE6;
  --line: rgba(20, 20, 18, .07);
  --line-2: rgba(20, 20, 18, .14);
  --text: #121211;
  --text-2: #5E5D59;
  --text-3: #9A9893;
  --accent: #A57C2C;
  --accent-2: #C9A55A;
  --accent-soft: rgba(165, 124, 44, .11);
  --pos: #22885A;
  --neg: #C24A3F;
  --bar: #E4E1D9;
  --ink: #121211;
  --ink-text: #FFFFFF;
  --shadow: 0 1px 1px rgba(0, 0, 0, .02), 0 8px 28px -12px rgba(0, 0, 0, .10);
  --overlay: rgba(10, 10, 10, .34);
  --glass: rgba(244, 243, 239, .82);

  --r: 22px;
  --nav-h: 64px;
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-t: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0A0A0B;
  --surface: #131315;
  --surface-2: #1C1C1F;
  --line: rgba(255, 255, 255, .06);
  --line-2: rgba(255, 255, 255, .12);
  --text: #F3F2EF;
  --text-2: #A3A29E;
  --text-3: #6C6B68;
  --accent: #D8B46A;
  --accent-2: #F0D59A;
  --accent-soft: rgba(216, 180, 106, .13);
  --pos: #5DCB94;
  --neg: #F08277;
  --bar: #252528;
  --ink: #F3F2EF;
  --ink-text: #0A0A0B;
  --shadow: none;
  --overlay: rgba(0, 0, 0, .6);
  --glass: rgba(10, 10, 11, .78);
  color-scheme: dark;
}

/* ── База ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; font-weight: 650; letter-spacing: -.028em; line-height: 1.12; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
.muted { color: var(--text-3); }
.money, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money .cur { color: var(--text-3); font-weight: 500; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.boot { min-height: 100dvh; display: grid; place-items: center; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Каркас ─────────────────────────────────────────────────────────── */
.shell { min-height: 100dvh; }
.main {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 18px) 16px calc(var(--nav-h) + var(--safe-b) + 28px);
}
.side { display: none; }

.top {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  margin: 4px 2px 18px;
}
.eyebrow { font-size: 13px; color: var(--text-3); margin-bottom: 4px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
  font-size: 15px; font-weight: 600; overflow: hidden;
  border: 1px solid var(--line);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-2); background: var(--surface); border: 1px solid var(--line);
  transition: background .2s, color .2s, transform .15s;
}
.icon-btn:hover { color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn .icon { width: 18px; height: 18px; }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper-label { min-width: 54px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Нижняя навигация (телефон, мини-приложение) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 0 8px var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 500; color: var(--text-3);
  padding: 8px 0; transition: color .2s;
}
.tab .icon { width: 23px; height: 23px; }
.tab.on { color: var(--text); }
.tab-add { display: grid; place-items: center; }
.tab-add span {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: var(--ink-text);
  box-shadow: 0 6px 20px -6px rgba(0, 0, 0, .35);
  transition: transform .15s var(--ease);
}
.tab-add:active span { transform: scale(.92); }
.tab-add .icon { stroke-width: 2.1; }

/* ── Карточки ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head .sub { font-size: 13px; color: var(--text-3); }
.link { color: var(--text-2); font-size: 14px; font-weight: 500; }
.link:hover { color: var(--text); }
.link.accent { color: var(--accent); }

/* minmax(0, …): колонки не растягиваются под длинные неразрывные строки */
.grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.grid > .card + .card { margin-top: 0; }

/* ── Главный блок ───────────────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  padding: 24px 22px 22px;
  background:
    radial-gradient(120% 130% at 100% 0%, var(--accent-soft), transparent 58%),
    var(--surface);
}
.hero-label { font-size: 14px; color: var(--text-2); }
.hero-amount {
  margin: 10px 0 20px;
  font-size: clamp(42px, 12.5vw, 64px);
  font-weight: 650; letter-spacing: -.045em; line-height: .95;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.hero-amount .cur { font-size: .48em; color: var(--text-3); font-weight: 500; margin-left: .12em; letter-spacing: -.02em; }
.hero-amount.sm { font-size: clamp(34px, 9vw, 46px); margin-bottom: 16px; }

.progress { position: relative; height: 6px; border-radius: 99px; background: var(--surface-2); }
.progress > i {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0; transition: width 1s var(--ease);
}
.progress > b {
  position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px;
  border-radius: 2px; background: var(--text-3); opacity: .7;
}
.progress.thin { height: 4px; }
.progress.done > i { background: linear-gradient(90deg, var(--pos), var(--pos)); }

.hero-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 12px; font-size: 14px; color: var(--text-2); }
.hero-row b { color: var(--text); font-weight: 600; }
.hero-note { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--text-2); }
.hero-note.plain { border-top: 0; padding-top: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hero-note .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: 1px; }
.hero-note .dot.ok { background: var(--pos); }

/* ── Показатели ─────────────────────────────────────────────────────── */
.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { padding: 16px 16px 15px; }
.kpi-label { font-size: 12.5px; color: var(--text-3); }
.kpi-value { margin-top: 8px; font-size: 19px; font-weight: 650; letter-spacing: -.025em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-value .cur { color: var(--text-3); font-weight: 500; font-size: .8em; }
.kpi-sub { margin-top: 3px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── График по месяцам ──────────────────────────────────────────────── */
.chart-cap { min-height: 42px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.chart-cap .v { font-size: 22px; font-weight: 650; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.chart-cap .v .cur { color: var(--text-3); font-size: .72em; font-weight: 500; }
.chart-cap .l { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.chart-cap .link { flex: none; white-space: nowrap; }
.chart {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px;
  height: 168px; align-items: end;
}
.col { position: relative; height: 100%; display: flex; align-items: flex-end; cursor: pointer; }
.col .b {
  width: 100%; min-height: 3px; border-radius: 7px 7px 3px 3px;
  background: var(--bar);
  transition: height .8s var(--ease), background .2s;
}
.col:hover .b { background: var(--line-2); }
.col.cur .b { background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.col.sel .b { background: var(--ink); }
.col.sel.cur .b { background: linear-gradient(180deg, var(--accent-2), var(--accent)); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent); }
.col .g { position: absolute; left: -3px; right: -3px; height: 0; border-top: 1.5px dashed var(--text-3); opacity: .65; pointer-events: none; }
.col.hit::after {
  content: ''; position: absolute; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%;
  background: var(--pos); bottom: calc(var(--h) + 6px);
}
.chart-x { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; margin-top: 9px; }
.chart-x span { text-align: center; font-size: 11px; color: var(--text-3); }
.chart-x span.cur { color: var(--text); font-weight: 600; }
.chart-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--text-2); }
.chart-foot b { color: var(--text); font-weight: 600; }

/* ── Списки ─────────────────────────────────────────────────────────── */
.list { margin: -6px 0; }
.row {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  transition: opacity .2s;
}
.row:last-child { border-bottom: 0; }
.row:active { opacity: .6; }
.row-ava {
  width: 38px; height: 38px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
  font-size: 14px; font-weight: 600;
}
.row-main { flex: 1; min-width: 0; }
.row-main b { display: block; font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main small { display: block; margin-top: 1px; color: var(--text-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -.01em; }
.row-amt.neg { color: var(--neg); }

.group .row:last-child { border-bottom: 0; }
.day-head { display: flex; justify-content: space-between; padding: 18px 2px 6px; font-size: 12.5px; color: var(--text-3); }
.day-head:first-child { padding-top: 2px; }
.day-head b { font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; }

.empty { padding: 36px 12px; text-align: center; color: var(--text-3); font-size: 14px; }
.empty b { display: block; color: var(--text); font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty .btn { margin-top: 18px; width: auto; padding: 0 22px; }

/* Записи: сводка месяца и поиск */
.month-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.month-card .big { font-size: 30px; font-weight: 650; letter-spacing: -.035em; font-variant-numeric: tabular-nums; line-height: 1.05; white-space: nowrap; }
.month-card .big .cur { color: var(--text-3); font-size: .62em; font-weight: 500; }
.month-card .meta { font-size: 13px; color: var(--text-2); margin-top: 6px; }
.ring { width: 58px; height: 58px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.ring.done .fg { stroke: var(--pos); }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.search {
  position: relative; margin: 12px 0;
}
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.search input { padding-left: 42px; background: var(--surface); border: 1px solid var(--line); }
.search input:focus { border-color: var(--line-2); }

/* ── Цели ───────────────────────────────────────────────────────────── */
.goal-row {
  width: 100%; text-align: left;
  display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 8px 14px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.goal-row:last-child { border-bottom: 0; }
.goal-row:active { opacity: .6; }
.goal-m { font-weight: 500; }
.goal-row.cur .goal-m { color: var(--accent); font-weight: 600; }
.goal-row.future .goal-m { color: var(--text-2); }
.goal-v { text-align: right; font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.goal-v small { color: var(--text-3); }
.goal-v .set { color: var(--text-3); }
.goal-row .progress { grid-column: 2; }
.goal-p { font-size: 12px; font-weight: 600; color: var(--text-2); margin-left: 6px; }
.goal-p.ok { color: var(--pos); }
.goal-p.miss { color: var(--neg); }

/* ── Статистика ─────────────────────────────────────────────────────── */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 14px; margin: 0 -2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 15px; border-radius: 99px;
  font-size: 14px; font-weight: 500; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line);
  transition: background .2s, color .2s;
}
.chip.on { background: var(--ink); color: var(--ink-text); border-color: transparent; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; margin-top: 4px; }
.stat-grid small { display: block; font-size: 12.5px; color: var(--text-3); }
.stat-grid b { display: block; margin-top: 4px; font-size: 18px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-grid b .cur { color: var(--text-3); font-weight: 500; font-size: .8em; }

.facts .fact { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.facts .fact:last-child { border-bottom: 0; padding-bottom: 0; }
.facts .fact:first-child { padding-top: 0; }
.fact > span { flex: none; color: var(--text-2); font-size: 14px; }
.fact > div { min-width: 0; text-align: right; }
.fact b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fact small { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hbar-row { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; padding: 10px 0; }
.hbar-row:first-child { padding-top: 0; }
.hbar-name { font-weight: 500; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-name small { color: var(--text-3); font-weight: 400; margin-left: 6px; font-size: 12.5px; }
.hbar-val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-val small { font-weight: 500; font-size: 12px; margin-left: 6px; }
.hbar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar i { display: block; height: 100%; border-radius: inherit; background: var(--text-2); width: 0; transition: width .9s var(--ease); }
.hbar-row.top .hbar i { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.stack { display: flex; height: 10px; border-radius: 99px; overflow: hidden; gap: 2px; margin-bottom: 14px; }
.stack i { display: block; height: 100%; }
.legend { display: grid; gap: 9px; }
.legend div { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .nm { flex: 1; color: var(--text-2); }
.legend .vl { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend .pc { width: 42px; text-align: right; color: var(--text-3); font-size: 13px; }

.matrix { display: grid; grid-template-columns: 38px repeat(12, 1fr); gap: 4px; align-items: center; }
.matrix .yl { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.matrix .ml { font-size: 10.5px; color: var(--text-3); text-align: center; padding-bottom: 2px; }
.cell { position: relative; aspect-ratio: 1; border-radius: 6px; background: var(--surface-2); overflow: hidden; cursor: default; }
.cell i { position: absolute; inset: 0; background: var(--accent); }
.cell.empty-cell { background: transparent; border: 1px dashed var(--line); }
.matrix-cap { margin-top: 12px; font-size: 13px; color: var(--text-2); min-height: 19px; }

/* ── Кнопки и поля ──────────────────────────────────────────────────── */
.btn {
  height: 52px; width: 100%; border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--ink); color: var(--ink-text);
  font-size: 16px; font-weight: 600; letter-spacing: -.01em;
  transition: transform .15s var(--ease), opacity .2s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--neg); font-weight: 500; height: 44px; }
.btn .icon { width: 20px; height: 20px; stroke-width: 2; }

.field { display: block; margin-top: 14px; min-width: 0; }
.field > span { display: block; font-size: 12.5px; color: var(--text-3); margin: 0 0 6px 2px; }
input, select {
  width: 100%; min-width: 0;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent; border-radius: 14px;
  padding: 13px 14px; outline: none;
  -webkit-appearance: none; appearance: none;
  transition: border-color .2s, background .2s;
}
input:focus, select:focus { border-color: var(--line-2); background: var(--surface); }
input::placeholder { color: var(--text-3); }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239A9893' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
  padding-right: 36px;
}
input[type="date"] { min-height: 49px; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.amount-field { display: flex; align-items: baseline; gap: 6px; margin: 6px 0 4px; border-bottom: 1px solid var(--line); }
.amount-field input {
  flex: 1; background: transparent; border: 0; border-radius: 0; padding: 6px 0 12px;
  font-size: 44px; font-weight: 650; letter-spacing: -.04em; font-variant-numeric: tabular-nums;
}
.amount-field input:focus { background: transparent; }
.amount-field span { font-size: 26px; color: var(--text-3); font-weight: 500; }
.amount-field.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.seg { display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); border-radius: 14px; padding: 4px; }
.seg button { flex: 1; min-width: 72px; height: 40px; border-radius: 11px; font-size: 14.5px; font-weight: 500; color: var(--text-2); transition: background .2s, color .2s; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.check { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 14.5px; color: var(--text-2); cursor: pointer; }
.check input { width: 20px; height: 20px; padding: 0; border-radius: 6px; border: 1.5px solid var(--line-2); background: transparent; flex: none; display: grid; place-items: center; }
.check input:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after { content: ''; width: 10px; height: 6px; border: 2px solid var(--ink-text); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }

.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.quick button { height: 32px; padding: 0 12px; border-radius: 99px; font-size: 13px; color: var(--text-2); background: var(--surface-2); font-variant-numeric: tabular-nums; }
.quick button:active { opacity: .6; }

/* ── Шторка ─────────────────────────────────────────────────────────── */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: var(--overlay); opacity: 0; transition: opacity .25s;
}
.sheet-wrap.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(20px + var(--safe-b));
  transform: translateY(100%); transition: transform .34s var(--ease);
  border: 1px solid var(--line); border-bottom: 0;
}
.sheet-wrap.open .sheet { transform: none; }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 auto 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.sheet-actions { display: grid; gap: 6px; margin-top: 22px; }
.sheet-meta { margin-top: 8px; text-align: center; font-size: 12px; color: var(--text-3); }

.menu-user { display: flex; align-items: center; gap: 14px; padding: 6px 0 18px; border-bottom: 1px solid var(--line); }
.menu-user b { display: block; font-size: 16px; font-weight: 600; }
.menu-user small { display: block; color: var(--text-3); font-size: 13px; margin-top: 2px; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 15px 2px; border-bottom: 1px solid var(--line); font-size: 15.5px; text-align: left; }
.menu-item:last-child { border-bottom: 0; }
.menu-item .icon { width: 20px; height: 20px; color: var(--text-3); }
.menu-item.danger { color: var(--neg); }
.menu-item.danger .icon { color: var(--neg); }
.menu-hint { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--surface-2); font-size: 13.5px; color: var(--text-2); }
.menu-hint code { font: 500 13px ui-monospace, "SF Mono", Menlo, monospace; color: var(--text); }

/* ── Уведомление ────────────────────────────────────────────────────── */
.toast {
  position: fixed; z-index: 60; left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px;
  max-width: calc(100% - 32px);
  padding: 12px 16px; border-radius: 16px;
  background: var(--ink); color: var(--ink-text);
  font-size: 14.5px; font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4);
  transition: opacity .25s, transform .3s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.err { background: var(--neg); color: #fff; }
.toast button { color: var(--accent-2); font-weight: 600; }
:root:not([data-theme="dark"]) .toast button { color: #E8C987; }

/* ── Вход ───────────────────────────────────────────────────────────── */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px calc(32px + var(--safe-b)); }
.login-card { width: 100%; max-width: 360px; }
.login-mark { width: 52px; height: 52px; margin-bottom: 26px; }
.login-mark svg { width: 100%; height: 100%; }
.login-card h1 { font-size: 32px; }
.login-card > p { margin-top: 8px; color: var(--text-2); }
.login-card form { margin-top: 26px; }
.login-card .btn { margin-top: 22px; }
.login-err { min-height: 20px; margin-top: 12px; font-size: 14px; color: var(--neg); text-align: center; }
.login-hint { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--text-3); line-height: 1.5; }

.logo { width: 28px; height: 28px; flex: none; }
.logo .track { stroke: var(--line-2); }
.logo .arc { stroke: var(--accent); }

/* ── Широкий экран ──────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .chart { height: 200px; gap: 10px; }
  .chart-x { gap: 10px; }
  .two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 26px; border-bottom: 1px solid var(--line); padding-bottom: 22px; transform: translateY(24px) scale(.98); opacity: 0; transition: transform .3s var(--ease), opacity .25s; }
  .sheet-wrap.open .sheet { opacity: 1; }
  .grabber { display: none; }
  .sheet-head { margin-top: 6px; }
}

@media (min-width: 980px) {
  .tabbar { display: none; }
  .shell { display: grid; grid-template-columns: 248px 1fr; }
  .side {
    display: flex; flex-direction: column; gap: 6px;
    position: sticky; top: 0; height: 100dvh;
    padding: 28px 18px 22px;
    border-right: 1px solid var(--line);
  }
  .brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 26px; font-size: 18px; font-weight: 650; letter-spacing: -.02em; }
  .side-link {
    display: flex; align-items: center; gap: 12px;
    height: 42px; padding: 0 12px; border-radius: 12px;
    color: var(--text-2); font-weight: 500; text-align: left;
    transition: background .2s, color .2s;
  }
  .side-link:hover { color: var(--text); background: var(--surface-2); }
  .side-link.on { color: var(--text); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
  .side-link .icon { width: 20px; height: 20px; }
  .side-add { margin-top: 18px; height: 46px; border-radius: 14px; font-size: 15px; }
  .side-user { margin-top: auto; display: flex; align-items: center; gap: 11px; padding: 10px; border-radius: 14px; text-align: left; transition: background .2s; }
  .side-user:hover { background: var(--surface-2); }
  .side-user .avatar { width: 34px; height: 34px; font-size: 13px; }
  .side-user b { display: block; font-size: 14px; font-weight: 600; }
  .side-user small { display: block; font-size: 12px; color: var(--text-3); }
  .main { max-width: 1080px; width: 100%; padding: 44px 48px 64px; }
  .top { margin-bottom: 26px; }
  .top .avatar { display: none; }
  h1 { font-size: 32px; }
  .ov-top { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: stretch; }
  .ov-top .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-top .hero { display: flex; flex-direction: column; justify-content: space-between; }
  .ov-bottom { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
  .toast { bottom: 28px; }
}

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