@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("fonts/manrope-cyr.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("fonts/manrope-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("fonts/manrope-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- tokens ---------- */
:root {
  color-scheme: light dark;
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --sunk: #EDEFF2;
  --line: #E3E6EB;
  --line-strong: #CDD2D9;
  --text: #0E1116;
  --muted: #5B6270;
  --faint: #6F7682;
  --main: #0E1116;
  --on-main: #FFFFFF;
  --ok: #1B6E3F; --ok-bg: #DDF3E6;
  --warn: #7F4C00; --warn-bg: #FFF0D1;
  --bad: #B42318; --bad-bg: #FDE4E1;
  --r: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-sheet: cubic-bezier(.22, 1, .36, 1);
  --shadow: 0 1px 2px rgb(14 17 22 / .04), 0 6px 20px rgb(14 17 22 / .05);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 70px; /* 10 + 50 + 10: значки и подписи по центру; полоска жестов добавляется снизу */
  --brand: #1E242C;
  --brand-deep: #161A20;
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%235B6270' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1115; --surface: #181B21; --sunk: #12151A; --line: #262B33; --line-strong: #39404B;
    --text: #ECEEF2; --muted: #A3AAB6; --faint: #8C93A0;
    --main: #ECEEF2; --on-main: #0F1115;
    --ok: #6AD497; --ok-bg: #12301E; --warn: #F2B54A; --warn-bg: #33270C; --bad: #FF8F80; --bad-bg: #3A1714;
    --shadow: none;
    --brand: #C9CED6;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%23A3AAB6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

/* direction colours: plate / text on plate / solid mark */
.c-blue   { --c-bg: #DCEAFE; --c-fg: #123A7A; --c-solid: #2F6FE0; }
.c-orange { --c-bg: #FFE6D2; --c-fg: #7A3A0E; --c-solid: #E8772E; }
.c-yellow { --c-bg: #FFF2BF; --c-fg: #5E4800; --c-solid: #D9A900; }
.c-green  { --c-bg: #D7F2E0; --c-fg: #13562D; --c-solid: #2E9E5B; }
.c-violet { --c-bg: #ECE3FF; --c-fg: #45237E; --c-solid: #7B4FD6; }
.c-pink   { --c-bg: #FCE1EC; --c-fg: #7A1F45; --c-solid: #D2467F; }
.c-gray   { --c-bg: var(--sunk); --c-fg: var(--muted); --c-solid: #8A919D; }
@media (prefers-color-scheme: dark) {
  .c-blue   { --c-bg: #15284A; --c-fg: #B4D0FF; --c-solid: #5B93F0; }
  .c-orange { --c-bg: #3A2414; --c-fg: #FFC9A1; --c-solid: #F08A45; }
  .c-yellow { --c-bg: #352D0B; --c-fg: #FFE485; --c-solid: #E6BC1F; }
  .c-green  { --c-bg: #12301E; --c-fg: #A6E6BE; --c-solid: #43B670; }
  .c-violet { --c-bg: #2A1E45; --c-fg: #D6C4FF; --c-solid: #9670E6; }
  .c-pink   { --c-bg: #3A1626; --c-fg: #FFC1D8; --c-solid: #E0659A; }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; overflow-x: clip; overscroll-behavior: none; touch-action: manipulation; }
body {
  margin: 0; min-height: 100dvh; overflow-x: clip;
  background: var(--bg); color: var(--text);
  font: 500 16px/1.45 Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
/* как в приложении: кнопки, плитки и меню не выделяются и не дают «меню ссылки» при долгом нажатии */
button, a, label, .tab, .rail-link, .tile, .row, .chip, .seg, .pill, .brand, .page-head, .sec, .kpi, .hero, .day-head, .bar-row, .sheet-head, dt {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
input, textarea, select { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img, svg { -webkit-user-drag: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
svg.i { width: 22px; height: 22px; flex: none; }
.num, .money { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid #2F6FE0; outline-offset: 2px; }
[hidden] { display: none !important; }

/* calm moving background: two soft lights, transform only */
/* Переливание фона: четыре мягких пятна цветов направлений и фирменного зелёного медленно плывут
   и по очереди то проявляются, то гаснут. Только transform и opacity, без перерисовки. */
/* Слой фона выходит за края экрана: на iPhone в режиме «с экрана Домой» нижняя часть под полоской жестов
   иначе оставалась без переливов и выглядела отдельной полосой. */
.ambient { position: fixed; top: -80px; left: 0; right: 0; height: calc(var(--fullh, 100lvh) + 240px); z-index: -1; overflow: hidden; pointer-events: none; contain: strict; }
.ambient i { position: absolute; width: 90vmax; height: 90vmax; border-radius: 50%; will-change: transform, opacity; opacity: 0; }
.ambient i:nth-child(1) { left: -42vmax; top: -48vmax; background: radial-gradient(closest-side, rgb(47 111 224 / .16), transparent 70%); animation: drift-a 58s ease-in-out infinite alternate, glow 46s ease-in-out infinite alternate; }
.ambient i:nth-child(2) { right: -46vmax; top: 6vh; background: radial-gradient(closest-side, rgb(46 158 91 / .14), transparent 70%); animation: drift-b 64s ease-in-out infinite alternate, glow 52s ease-in-out -17s infinite alternate; }
.ambient i:nth-child(3) { left: -30vmax; bottom: -52vmax; background: radial-gradient(closest-side, rgb(123 79 214 / .12), transparent 70%); animation: drift-c 70s ease-in-out infinite alternate, glow 40s ease-in-out -29s infinite alternate; }
.ambient i:nth-child(4) { right: -36vmax; bottom: -40vmax; background: radial-gradient(closest-side, rgb(232 119 46 / .10), transparent 70%); animation: drift-a 76s ease-in-out -30s infinite alternate-reverse, glow 56s ease-in-out -8s infinite alternate; }
@keyframes drift-a { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(18vmax, 14vmax, 0) scale(1.12); } }
@keyframes drift-b { from { transform: translate3d(0, 0, 0) scale(1.08); } to { transform: translate3d(-16vmax, 18vmax, 0) scale(.94); } }
@keyframes drift-c { from { transform: translate3d(0, 0, 0) scale(.96); } to { transform: translate3d(14vmax, -16vmax, 0) scale(1.1); } }
@keyframes glow { from { opacity: .25; } to { opacity: 1; } }
@media (prefers-color-scheme: dark) { .ambient { opacity: .7; } }
html.scrolling .ambient i { animation-play-state: paused; }
/* Экраны без меню (вход, первый запуск, установка): нижняя часть фона ровная, без цветных пятен.
   Так у нижнего края экрана нечему образовать полосу, даже если слой фона там кончается. */
body.is-gate .ambient i:nth-child(n+3) { display: none; }
body.is-gate .ambient i:nth-child(2) { top: -12vh; }

/* ---------- shell ---------- */
.net {
  margin-left: auto; min-height: 36px; padding: 0 12px; border-radius: 99px;
  background: var(--warn-bg); color: var(--warn); font-size: 13px; font-weight: 800; white-space: nowrap;
  max-width: 60vw; overflow: hidden; text-overflow: ellipsis;
}
.rail .net { margin: 0 8px; min-height: 40px; }
.shell { min-height: 100dvh; }
.rail { display: none; }
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 16px) 8px calc(var(--sal) + 16px);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; min-height: 44px; }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand-sub:empty { display: none; }
.brand-sub { display: block; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text { min-width: 0; line-height: 1.2; }
.logo { width: 34px; height: 34px; flex: none; color: var(--brand); }
.gate .logo { width: 44px; height: 44px; }
/* Аватарка: тонкий контур и инициалы, без заливки. Строго и одинаково в обеих темах. */
.avatar-btn, .avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .06em;
  background: transparent; border: 1.5px solid var(--line-strong); color: var(--text);
  transition: border-color .2s var(--ease);
}
.avatar-btn { width: 44px; height: 44px; }
.avatar-btn:active { border-color: var(--text); }
.main { padding: 4px calc(var(--sar) + 16px) calc(var(--tabbar-h) + var(--sab) + 32px) calc(var(--sal) + 16px); max-width: 1120px; margin: 0 auto; outline: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  /* Сверху 10 px. Снизу 10 px, а на iPhone с полоской жестов отступ до края на 12 px меньше системного:
     так подписи стоят ниже, а расстояние от них до полоски равно отступу сверху. */
  padding: 10px calc(var(--sar) + 4px) max(10px, calc(var(--sab) - 12px)) calc(var(--sal) + 4px);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 50px;
  text-decoration: none; color: var(--faint); font-size: 12px; font-weight: 700; min-width: 0;
  transition: color .2s var(--ease);
}
.tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab[aria-current="page"] { color: var(--text); }
.tab:active svg { transform: scale(.92); }
.tab svg { transition: transform .15s var(--ease); }
@media (max-width: 359px) { .tab { font-size: 11px; letter-spacing: -.01em; } }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .top, .tabbar { display: none; }
  .rail {
    display: flex; flex-direction: column; gap: 24px;
    position: sticky; top: 0; height: 100dvh; padding: 24px 16px;
    border-right: 1px solid var(--line);
    background: var(--bg); background: color-mix(in srgb, var(--surface) 55%, transparent);
  }
  .rail .brand { padding: 0 8px; }
  .rail-nav { display: grid; gap: 4px; }
  .rail-link {
    display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
    border-radius: 12px; text-decoration: none; font-weight: 700; color: var(--muted);
    transition: background-color .2s var(--ease), color .2s var(--ease);
  }
  .rail-link[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--line); }
  .rail-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; min-height: 56px; }
  .rail-user .avatar { width: 40px; height: 40px; }
  .rail-user small { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }
  .main { padding: 32px 40px 56px; }
}

/* ---------- page parts ---------- */
.enter > * { animation: rise .5s var(--ease) both; }
.enter > *:nth-child(2) { animation-delay: .05s; }
.enter > *:nth-child(3) { animation-delay: .1s; }
.enter > *:nth-child(4) { animation-delay: .15s; }
.enter > *:nth-child(n+5) { animation-delay: .2s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 16px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(26px, 7vw, 34px); line-height: 1.1; font-weight: 800; letter-spacing: -.02em; }
.eyebrow { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.sec { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 10px; }
.sec h2 { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.sec small, .hint { font-size: 14px; color: var(--muted); font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.stack { display: grid; gap: 12px; }

/* shift hero */
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px 18px 16px; box-shadow: var(--shadow); }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 14px; }
.hero-sum { display: block; font-size: clamp(38px, 12vw, 56px); font-weight: 800; letter-spacing: -.03em; line-height: 1.05; margin: 6px 0 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hero-split { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-weight: 600; font-size: 14px; }
.hero-split b { color: var(--text); font-weight: 800; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  min-height: 112px; padding: 14px; border-radius: var(--r);
  background: var(--c-bg); color: var(--c-fg);
  transition: transform .16s var(--ease);
  overflow: hidden;
}
.tile:active { transform: scale(.97); }
.tile-name { font-weight: 800; font-size: 15px; line-height: 1.2; overflow-wrap: break-word; hyphens: auto; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile-sum { min-width: 0; font-weight: 800; font-size: clamp(18px, 5.6vw, 22px); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tile-kind { display: block; font-size: 12px; font-weight: 700; opacity: .8; }
.tile-plus { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--c-solid); color: #fff; }
.tile-plus svg { width: 18px; height: 18px; }

.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }

@media (min-width: 720px) {
  .tiles { grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); }
  .tile { min-height: 132px; }
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--r);
  font-weight: 700; white-space: nowrap; text-decoration: none;
  transition: transform .14s var(--ease), background-color .2s var(--ease), opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 20px; height: 20px; }
.btn-main { background: var(--main); color: var(--on-main); }
.btn-ghost { background: var(--surface); border: 1px solid var(--line-strong); }
.btn-soft { background: var(--sunk); }
.btn-danger { color: var(--bad); }
.btn-wide { width: 100%; }
.btn-sm { min-height: 44px; padding: 0 14px; font-size: 15px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; flex: none; }
.icon-btn:active { background: var(--sunk); }

/* lists */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px;
  padding: 10px 14px; border-top: 1px solid var(--line); text-decoration: none;
  transition: background-color .2s var(--ease);
}
.row:first-child { border-top: 0; }
button.row:active, a.row:active { background: var(--sunk); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c-solid); flex: none; }
.row-main { flex: 1; min-width: 0; }
.row-title, .row-sub { display: block; }
.row-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 14px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { text-align: right; flex: none; }
.row-amt { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-amt.minus { color: var(--bad); }
.row-amt.muted { color: var(--muted); }
.day-head { display: flex; justify-content: space-between; gap: 12px; padding: 18px 2px 8px; font-weight: 800; }
.day-head span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-weight: 600; }
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 700; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.c { background: var(--c-bg); color: var(--c-fg); }

/* forms */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .label { font-size: 14px; color: var(--muted); font-weight: 700; }
input:not([type="radio"]):not([type="checkbox"]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 16px; font-weight: 600; outline: none;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
::placeholder { color: var(--faint); font-weight: 500; opacity: 1; }
input[type="date"] { -webkit-appearance: none; appearance: none; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
select {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  padding-right: 44px; text-overflow: ellipsis; white-space: nowrap;
  background-image: var(--chevron); background-repeat: no-repeat;
  background-position: right 14px center; background-size: 18px 18px;
}
select::-ms-expand { display: none; }
select:focus-visible { outline: none; }
textarea { min-height: 104px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 10%, transparent); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.err { color: var(--bad); font-size: 14px; font-weight: 700; min-height: 0; }
.err:empty { display: none; }

.amount { display: flex; align-items: baseline; gap: 6px; border-bottom: 2px solid var(--line-strong); transition: border-color .2s; }
.amount:focus-within { border-color: var(--text); }
.amount input { border: 0 !important; box-shadow: none !important; background: none !important; padding: 0 !important; border-radius: 0 !important; font-size: 44px !important; font-weight: 800 !important; letter-spacing: -.02em; min-height: 64px !important; font-variant-numeric: tabular-nums; }
.amount span { font-size: 28px; font-weight: 800; color: var(--muted); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; background: var(--sunk); border-radius: 13px; border: 0; margin: 0; }
.seg label { position: relative; min-width: 0; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 8px; border-radius: 10px; font-weight: 700; font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background-color .2s var(--ease), color .2s var(--ease); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
.seg input:focus-visible + span { outline: 2px solid #2F6FE0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 99px; background: var(--sunk); font-weight: 700; font-size: 15px; transition: transform .14s var(--ease), background-color .2s; }
.chip:active { transform: scale(.96); }
label.chip { position: relative; }
label.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
label.chip:has(input:checked) { background: var(--main); color: var(--on-main); }
label.chip:has(input:focus-visible) { outline: 2px solid #2F6FE0; outline-offset: 2px; }
.chip .x { margin-left: 6px; opacity: .7; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi:first-child { grid-column: 1 / -1; }
.kpi .lbl { font-size: 14px; color: var(--muted); font-weight: 700; }
.kpi .val { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi:first-child .val { font-size: clamp(30px, 9vw, 40px); }
.kpi .delta { font-size: 13px; font-weight: 700; color: var(--muted); }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--bad); }
@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:first-child { grid-column: auto; }
  .kpi:first-child .val { font-size: 30px; }
}

/* bars */
.bars { padding: 4px 16px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: baseline; }
.bar-row:first-child { border-top: 0; }
.bar-row .name { font-weight: 700; min-width: 0; overflow-wrap: break-word; }
.bar-row .name small { white-space: nowrap; }
.bar-row .name small { color: var(--muted); font-weight: 600; font-size: 13px; margin-left: 6px; }
.bar-row .sum { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--c-solid); transform-origin: left; animation: grow .8s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }

/* chart */
.chart { padding: 16px 16px 12px; }
.chart svg { display: block; width: 100%; height: 170px; }
.chart rect { fill: var(--c-solid); }
.chart-axis { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.filters select { width: auto; min-width: 0; flex: 1 1 140px; }
.scroller { display: flex; flex-wrap: wrap; gap: 8px; }
.scroller > * { flex: none; }
.search { position: relative; display: block; margin-bottom: 12px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--faint); pointer-events: none; }
.search input[type="search"] { padding-left: 42px; }
.daynav { display: flex; align-items: center; gap: 4px; }
.daynav .icon-btn { background: var(--surface); border: 1px solid var(--line); }

/* orders */
.order { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; text-align: left; }
.order .no { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }

dl.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 0; margin: 0 0 16px; }
dl.facts dt { color: var(--muted); font-weight: 600; }
dl.facts dd { margin: 0; padding-left: 16px; font-weight: 700; text-align: right; overflow-wrap: break-word; min-width: 0; }
dl.facts dd a { white-space: nowrap; }
dl.facts .total { padding-top: 10px; border-top: 1px solid var(--line); }
.diff { padding: 12px 14px; border-radius: 12px; font-weight: 800; text-align: center; }
.diff.ok { background: var(--ok-bg); color: var(--ok); }
.diff.warn { background: var(--warn-bg); color: var(--warn); }
.diff.bad { background: var(--bad-bg); color: var(--bad); }

/* settings */
.set-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.set-row:first-child { border-top: 0; padding-top: 0; }
.set-row .more { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.mini { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--muted); }
.mini input[type="number"] { width: 72px; text-align: center; }
.swatch { width: 44px; height: 44px; border-radius: 12px; background: var(--c-bg); border: 2px solid var(--c-solid); flex: none; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-weight: 700; }
.switch input { width: 44px; height: 26px; appearance: none; -webkit-appearance: none; border-radius: 99px; background: var(--line-strong); position: relative; cursor: pointer; transition: background-color .2s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .22s var(--ease); box-shadow: 0 1px 2px rgb(0 0 0 / .2); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(18px); }
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.user-row:first-child { border-top: 0; padding-top: 0; }
.user-row .row-main { flex: 1 1 140px; }
.user-row .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.settings-grid { display: grid; gap: 16px; }
@media (min-width: 1100px) { .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }
.settings-grid h2 { font-size: 18px; font-weight: 800; margin-bottom: 12px; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; background: var(--sunk); padding: 2px 8px; border-radius: 6px; }

/* ---------- sheet ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgb(8 10 14 / .45); opacity: 0; transition: opacity .3s var(--ease); }
.scrim.on { opacity: 1; }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 0 16px calc(20px + var(--sab));
  transform: translateY(100%); transition: transform .42s var(--ease-sheet);
}
.sheet.on { transform: none; }
.sheet.dragging { transition: none !important; }
.sheet > * { max-width: 100%; }
.sheet > .sheet-head { max-width: none; }
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px;
  margin: 0 -16px 8px; padding: 14px 8px 10px 16px; background: var(--surface);
}
.sheet-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 99px; background: var(--line-strong); }
.sheet-head h2 { flex: 1; min-width: 0; font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.sheet-head .pill { flex: none; }
.sheet .sub { color: var(--muted); font-weight: 600; margin: -4px 0 16px; }
.sheet-actions { display: grid; gap: 10px; margin-top: 4px; }
.msg-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: min(540px, calc(100vw - 48px)); max-height: min(88dvh, 820px);
    border-radius: 22px; padding: 0 24px 24px;
    transform: translate(-50%, -47%) scale(.98); opacity: 0;
    transition: transform .36s var(--ease-sheet), opacity .24s var(--ease);
    box-shadow: 0 24px 64px rgb(0 0 0 / .18);
  }
  .sheet.on { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-head { margin: 0 -24px 8px; padding: 18px 12px 10px 24px; }
  .sheet-head::before { display: none; }
}

/* toast */
.toast {
  position: fixed; left: 0; right: 0; margin: 0 auto; width: fit-content; bottom: calc(var(--tabbar-h) + var(--sab) + 16px); z-index: 60;
  max-width: min(440px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 14px;
  background: var(--main); color: var(--on-main); font-weight: 700; text-align: center;
  transform: translateY(16px); opacity: 0; pointer-events: none;
  transition: transform .35s var(--ease), opacity .25s var(--ease);
}
.toast.on { transform: none; opacity: 1; }
html.sheet-open .toast { bottom: auto; top: calc(var(--sat) + 12px); transform: translateY(-16px); }
html.sheet-open .toast.on { transform: none; }
@media (min-width: 960px) { .toast { bottom: 32px; } }

/* ---------- gate ---------- */
body.is-gate .shell { display: block; }
body.is-gate .rail, body.is-gate .top, body.is-gate .tabbar { display: none; }
body.is-gate .main { padding: 0 calc(var(--sar) + 16px) 0 calc(var(--sal) + 16px); }
.gate { min-height: 100dvh; display: grid; place-items: center; padding: calc(var(--sat) + 24px) 0 calc(var(--sab) + 24px); }
.gate-card { width: min(420px, 100%); }
.gate .brand { margin-bottom: 28px; }
.gate h1 { font-size: clamp(28px, 8vw, 36px); font-weight: 800; letter-spacing: -.02em; margin-bottom: 6px; }
.gate .lead { color: var(--muted); font-weight: 600; margin-bottom: 24px; }
.demo { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.demo p { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.demo .chips .chip { background: var(--surface); border: 1px solid var(--line-strong); }

/* hover only for mouse */
@media (hover: hover) and (pointer: fine) {
  .btn-ghost:hover, .btn-soft:hover { background: var(--sunk); }
  .btn-main:hover { opacity: .88; }
  button.row:hover, a.row:hover { background: color-mix(in srgb, var(--sunk) 70%, transparent); }
  .tile:hover { transform: translateY(-2px); }
  .rail-link:hover { color: var(--text); }
  .icon-btn:hover, .rail-user:hover { background: var(--sunk); }
  .chip:hover { background: var(--line); }
  .tab:hover { color: var(--text); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .ambient i { animation: none; opacity: .6; }
}

/* ---------- на весь экран (приложение с экрана «Домой») ----------
   Содержимое заходит под строку состояния и вырез. Буквы в строке состояния iPhone в этом режиме
   всегда белые, поэтому в светлой теме шапка становится фирменной тёмно-зелёной: время и заряд читаются. */
@media (display-mode: standalone) {
  .top { background: var(--bg); }
}
@media (display-mode: standalone) and (prefers-color-scheme: light) {
  :root { --brand-on: #E4E8EC; }
  .top { background: var(--brand-deep); color: #F2F4F6; }
  .top .logo { color: var(--brand-on); }
  .top .brand-sub { color: rgb(242 244 246 / .7); }
  .top .avatar-btn { border-color: rgb(255 255 255 / .35); color: #F2F4F6; }
  body.is-gate::before { content: ""; position: fixed; inset: 0 0 auto; height: var(--sat); background: var(--brand-deep); z-index: 20; }
}

/* ---------- заставка при запуске ----------
   Знак проявляется, название выезжает из-под маски, затем всё мягко растворяется. Всего около 1,2 с. */
.splash { display: none; }
html.splash-on .splash {
  display: grid; place-items: center; position: fixed; inset: 0; z-index: 100;
  background: var(--bg); transition: opacity .32s var(--ease), visibility 0s linear .32s;
}
html.splash-out .splash { opacity: 0; visibility: hidden; }
.splash-in { display: grid; justify-items: center; gap: 14px; }
.splash-logo { width: 72px; height: 72px; color: var(--brand); animation: splash-logo .6s var(--ease) both; }
.splash-mask { overflow: hidden; padding: 2px 4px; }
.splash-name { display: block; font-size: 26px; font-weight: 800; letter-spacing: .02em; animation: splash-name .55s var(--ease) .18s both; }
@keyframes splash-logo { from { opacity: 0; transform: scale(.9); } }
@keyframes splash-name { from { transform: translateY(110%); } }

/* ---------- установка на экран «Домой» ---------- */
.install-card h1 { margin-bottom: 6px; }
.install-btn { margin: 4px 0 14px; }
.install-tabs { margin-bottom: 16px; }
.isteps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; counter-reset: s; }
.istep { display: flex; gap: 12px; align-items: flex-start; counter-increment: s; }
.istep-ico { position: relative; flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.istep-ico svg { width: 22px; height: 22px; }
.istep-ico .logo { width: 28px; height: 28px; }
.istep-ico::after { content: counter(s); position: absolute; top: -7px; left: -7px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--main); color: var(--on-main); }
.istep-text { flex: 1; min-width: 0; font-size: 15px; line-height: 1.45; padding-top: 2px; }
.istep-text b { font-weight: 800; }
.inote { margin-top: 18px; padding: 12px 14px; border-radius: 14px; background: var(--sunk); font-size: 14px; line-height: 1.45; }
.inote ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.install-skip { display: block; margin: 16px auto 0; min-height: 44px; padding: 0 12px; color: var(--muted); font-weight: 700; }
.install-link { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; margin-top: 18px; padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); font-weight: 700; text-align: left; }
.install-link svg { color: var(--muted); }
.install-link small { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- уведомления в профиле ---------- */
.push-box { display: grid; gap: 10px; margin: 0 0 18px; padding: 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }
.push-box:empty { display: none; }
.push-text { font-size: 14px; color: var(--muted); font-weight: 600; }
.push-text b, .push-switch b { display: block; color: var(--text); font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.push-switch small { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.push-box .btn { justify-self: start; }

.app-version { margin-top: 14px; text-align: center; font-size: 12px; color: var(--faint); font-weight: 600; }

/* С экрана «Домой»: страница и экраны без меню всегда во весь экран, а не во «окно без строки состояния». */
html.standalone body, html.standalone .shell, html.standalone .gate { min-height: var(--fullh, 100lvh); }

.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; font-weight: 600; color: var(--muted); line-height: 1.4; cursor: pointer; }
.consent input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--main); }
.consent a, .app-version a { color: inherit; }
