/* ТОЛК — оформление по макету: тёплый фон, зелёный акцент, мягкие белые карточки. */

:root {
  --bg: #F6F4EE;            /* светлее и теплее, уходим от серого */
  --surface: #FFFFFF;
  --surface-2: #F0EEE6;
  --text: #16150F;
  --text-soft: #55534A;
  --text-muted: #6B6A62;
  --border: #E5E2D8;
  --brand: #1F4A3D;         /* глубокий насыщенный зелёный: кнопки, активный таб */
  --brand-ink: #FFFFFF;     /* текст на брендовой заливке */
  --accent: var(--brand);   /* алиас: старые правила не ломаются */
  --accent-soft: rgba(31, 74, 61, 0.10);
  --logo-accent: #1F4A3D;   /* буква Л на фоне страницы; в тёмной теме переопределяется */
  --logo-accent-plate: #1F4A3D; /* буква Л на брендовой плашке — зелёный в обеих темах */
  --green: #2F9E73;         /* только статус «норма» */
  --amber: #C77B14;
  --red: #C4341F;
  --amber-bg: #FBF0DC;
  --amber-ink: #8A5709;
  --green-bg: #EDF6F2;
  --green-ink: #23795A;
  --red-bg: #FBE9E6;
  --red-ink: #992A19;
  --f-display: 'Onest', -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  --f-text: 'Golos Text', -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  --radius: 20px;
  --radius-lg: 22px;
  --gap: 14px;
  --shadow: 0 1px 2px rgba(22, 21, 15, 0.04), 0 8px 24px rgba(22, 21, 15, 0.05);
  --shadow-sm: 0 1px 3px rgba(22, 21, 15, 0.05);
  --nav-h: 64px;
}

body[data-tg-theme='dark'] {
  --bg: #141311;
  --surface: #1E1D1A;
  --surface-2: #26241F;
  --text: #F4F2EC;
  --text-soft: #C4C2B8;
  --text-muted: #9A988E;
  --border: #302E29;
  --brand: #D7E5DD;         /* светло-зеленоватый интерфейсный цвет на тёмном */
  --brand-ink: #16150F;     /* тёмный текст на светлой брендовой заливке */
  --accent: var(--brand);
  --accent-soft: rgba(228, 225, 216, 0.12);
  --logo-accent: #7FD3B0;   /* на тёмном фоне Л должна остаться зелёной и читаемой */
  --logo-accent-plate: #1F4A3D;
  --green: #35B083;
  --amber: #E0973B;
  --red: #E06A54;
  --amber-bg: #3A2E17;
  --amber-ink: #F0C079;
  --green-bg: #16302A;
  --green-ink: #7FD3B0;
  --red-bg: #3A211C;
  --red-ink: #F0A594;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { overflow-x: hidden; max-width: 100%; }

body {
  font-family: var(--f-text);
  font-weight: 400;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; overflow-x: hidden; }

/* Защита от горизонтального переполнения: flex/grid-элементы могут «распирать»
   контейнер длинным контентом, если у них min-width: auto. */
.grid > *, .card, .block, .status-card { min-width: 0; }
.card__value, .card__num, .status-card__title, .attention__title, .attention__msg,
.wf__label, .kv__v, .toplist__val { overflow-wrap: anywhere; word-break: break-word; }
canvas, img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 13.5px; }
.neg { color: var(--red); }
.pos { color: var(--green); }
.link { background: none; border: none; color: var(--brand); font-size: 14px; font-weight: 600; cursor: pointer; }
.tnum { font-variant-numeric: tabular-nums; }

.tone-green { color: var(--green); }
.tone-red { color: var(--red); }
.tone-amber { color: var(--amber); }
.tone-muted { color: var(--text-muted); }

/* ── Header ── */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  padding: max(14px, env(safe-area-inset-top)) 18px 12px 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.app-header__brand { display: flex; align-items: center; gap: 12px; }
.app-header__logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  display: flex; align-items: center; justify-content: center;
}
.app-header__name { font-family: var(--f-display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }
.app-header__sub { color: var(--accent); font-size: 13px; opacity: .8; }
.app-header__switches { display: flex; gap: 10px; }
.switch {
  flex: 1; appearance: none; -webkit-appearance: none;
  background: var(--surface); color: var(--text);
  border: none; border-radius: 13px; box-shadow: var(--shadow-sm);
  padding: 11px 32px 11px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B6A62' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

/* ── Фирменный знак «реплика» (гайд «Логотип и цветовая гамма», вариант 3a) ──
   Геометрия в em от font-size: рамка 6% высоты прописной, радиус 35.7%,
   поля 26.2 / 40.5 / 31%, хвостик — 42.9 x 31%. Цвета из переменных темы. */
.tolk-logo {
  --logo-ink: var(--text);
  --logo-paper: var(--surface);
  position: relative; display: inline-flex; align-items: center;
  background: var(--logo-paper);
  border: 0.0595em solid var(--logo-ink);
  border-radius: 0.357em;
  padding: 0.262em 0.405em 0.31em;
  line-height: 1;
}
.tolk-logo__word {
  font-family: var(--f-display); font-weight: 800; font-size: 1em;
  letter-spacing: -0.045em; line-height: 1; color: var(--logo-ink);
  display: flex;
}
.tolk-logo__l { color: var(--logo-accent); }

/* Хвостик реплики: внешний треугольник цвета контура и внутренний — цвета
   плашки; вместе читаются как продолжение обводки облака. */
.tolk-logo--tail::before,
.tolk-logo--tail::after { content: ''; position: absolute; clip-path: polygon(0 0, 100% 0, 4% 100%); }
.tolk-logo--tail::before { left: 0.476em; bottom: -0.31em;  width: 0.429em; height: 0.31em;  background: var(--logo-ink); }
.tolk-logo--tail::after  { left: 0.512em; bottom: -0.202em; width: 0.357em; height: 0.262em; background: var(--logo-paper); }

/* Версия для брендовой заливки: светлая рамка и светлая Л (моно-инверсия). */
.tolk-logo--invert { --logo-ink: var(--brand-ink); --logo-paper: var(--brand); }
.tolk-logo--invert .tolk-logo__l { color: var(--brand-ink); }

/* Мелкий кегль (плашка 38px в шапке): em-рамка стала бы тоньше пикселя —
   переходим на целые значения из гайда. */
.tolk-logo--tight { border-width: 1px; border-radius: 4px; padding: 3px 3px 4px; }
.tolk-logo--tight.tolk-logo--tail::before { left: 4px; bottom: -4px; width: 6px; height: 4px; clip-path: polygon(0 0, 100% 0, 6% 100%); }
.tolk-logo--tight.tolk-logo--tail::after  { left: 5px; bottom: -3px; width: 5px; height: 3px; clip-path: polygon(0 0, 100% 0, 6% 100%); }

/* Плашка в шапке. В тёмной теме гайд требует обратного хода: плашка светлеет
   (#D7E5DD = --brand), а знак внутри становится тёмным — так бренд не тонет в
   почти чёрном интерфейсе. */
.app-header__logo .tolk-logo__l { color: var(--logo-accent-plate); }
body[data-tg-theme='dark'] .app-header__logo { background: var(--brand); box-shadow: none; }
body[data-tg-theme='dark'] .app-header__logo .tolk-logo {
  --logo-ink: var(--brand-ink);
  --logo-paper: var(--brand);
}

/* Подпись внизу экрана «Ещё»: знак и номер сборки. */
.more-signature { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px 0 4px; opacity: .75; }
.more-signature__build { letter-spacing: 0.02em; }

/* ── Screen layout ── */
.screen { padding: 4px 18px calc(var(--nav-h) + 28px) 18px; display: flex; flex-direction: column; gap: var(--gap); }
.grid { display: grid; gap: var(--gap); }
.grid--2 { grid-template-columns: 1fr 1fr; }

/* ── Cards ── */
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card--clickable { cursor: pointer; transition: transform .1s; }
.card--clickable:active { transform: scale(0.98); }
.card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.card__title { color: var(--text-soft); font-size: 14px; font-weight: 500; }
.card__value { font-family: var(--f-display); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.card__num { font-size: 26px; }
.card__unit { font-size: 14px; font-weight: 600; color: var(--text-soft); }
.card__value--big { letter-spacing: -0.03em; }
.card__value--big .card__num { font-size: 36px; }
.card__value:not(.card__value--big) .card__num { font-size: 26px; }
.card__sub { color: var(--text-soft); font-size: 13.5px; margin-top: 8px; line-height: 1.45; }
.card__note { font-size: 13px; margin-top: 10px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card__note-label { color: var(--text-muted); font-weight: 400; }
.note-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.note-dot--amber { background: var(--amber); }
.note-dot--red { background: var(--red); }

/* Значок статуса в углу карточки */
.card__sym { font-size: 14px; font-weight: 800; line-height: 1; flex: none; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.card__sym--green { color: var(--green); }
.card__sym--amber { color: var(--amber); }
.card__sym--red { color: var(--red); }
.card__sym--neutral { color: var(--text-muted); }

/* ── Status card (Pulse) ── */
.status-card { background: var(--surface); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow); }
.status-card__eyelet { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--text-muted); text-transform: uppercase; }
.status-card__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); }
.status-card__dot--green { background: var(--green); }
.status-card__dot--amber { background: var(--amber); }
.status-card__dot--red { background: var(--red); }
.status-card__title { font-family: var(--f-display); font-size: 25px; font-weight: 700; line-height: 1.22; letter-spacing: -0.02em; margin: 14px 0 10px; }
.status-card__msg { font-size: 15px; line-height: 1.5; color: var(--text-soft); }
.status-card__footer { display: flex; align-items: center; gap: 8px; margin-top: 18px; font-size: 14px; color: var(--text-soft); }
.status-card__warn--amber { color: var(--amber); }
.status-card__warn--red { color: var(--red); }
.status-card__warn--green { color: var(--green); }

/* ── Banner (уведомления импорта) ── */
.banner { position: relative; margin: 4px 18px 0; padding: 14px 38px 14px 16px; border-radius: 14px; box-shadow: var(--shadow); background: var(--surface); border-left: 4px solid var(--accent); }
.banner--success { border-left-color: var(--green); }
.banner--error { border-left-color: var(--red); }
.banner--info { border-left-color: var(--accent); }
.banner__title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.banner__body { display: flex; flex-direction: column; gap: 4px; }
.banner__line { font-size: 13px; color: var(--text-soft); line-height: 1.4; }
.banner__close { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border: none; background: var(--surface-2); border-radius: 8px; color: var(--text-muted); font-size: 14px; cursor: pointer; }
.banner__checks { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.banner__subtitle { font-weight: 700; font-size: 13px; margin-bottom: 4px; }

/* ── Blocks ── */
.block { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.block--flush { background: transparent; box-shadow: none; padding: 0; }
.block__title { font-family: var(--f-display); font-size: 16px; font-weight: 600; margin-bottom: 12px; letter-spacing: -0.01em; }
.block__title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.block__title-row .block__title { margin-bottom: 0; }
.block__hint { margin: -6px 0 12px; }

/* ── Attention ── */
.attention-section { display: flex; flex-direction: column; gap: 12px; }
.attention__bar { display: flex; justify-content: space-between; align-items: baseline; }
.attention__bar .block__title { margin-bottom: 0; }
.attention__count { color: var(--text-muted); font-weight: 700; }
.attention { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.attention__item { width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--border); padding: 16px 18px; display: grid; grid-template-columns: 24px 1fr 14px; align-items: center; gap: 12px; cursor: pointer; color: var(--text); }
.attention__item:last-child { border-bottom: none; }
.attention__item:active { background: var(--surface-2); }
.attention__sym { font-weight: 800; font-size: 18px; text-align: center; }
.attention__sym--red { color: var(--red); }
.attention__sym--amber { color: var(--amber); }
.attention__sym--green { color: var(--green); }
.attention__body { min-width: 0; }
.attention__title { font-weight: 600; font-size: 15px; margin-bottom: 3px; }
.attention__msg { font-size: 13.5px; color: var(--text-soft); line-height: 1.45; }
.attention__chev { color: var(--text-muted); font-size: 18px; }

.pulse-footer { text-align: center; color: var(--text-muted); font-size: 13px; line-height: 1.6; padding: 6px 0 2px; }
.pulse-footer__lock { color: var(--text-muted); }

.flows-note { padding: 0 4px; }

/* ── Safe balance bar ── */
.bar { margin-top: 4px; }
.bar__track { height: 12px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.bar__fill { height: 100%; border-radius: 8px; transition: width .4s; }
.bar__fill--green { background: var(--green); }
.bar__fill--amber { background: var(--amber); }
.bar__fill--red { background: var(--red); }
.bar__fill--neutral { background: var(--text-muted); }
.bar__legend { display: flex; justify-content: space-between; font-size: 12px; margin-top: 8px; font-variant-numeric: tabular-nums; }

/* ── Top lists ── */
.toplist { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.toplist__row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; }
.toplist__name { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.toplist__name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toplist__val { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag { font-size: 10px; color: var(--text-muted); background: var(--surface-2); border-radius: 6px; padding: 2px 6px; }

/* ── Waterfall / bridge ── */
.wf { display: flex; flex-direction: column; }
.wf__row { display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 8px 0; font-size: 14px; border-bottom: 1px solid var(--border); }
.wf__row:last-child { border-bottom: none; }
.wf__row--total { font-weight: 800; }
.wf__val { font-variant-numeric: tabular-nums; }

/* ── Toggle (Debt) ── */
.toggle { display: flex; background: var(--surface-2); border-radius: 13px; padding: 3px; gap: 3px; box-shadow: var(--shadow-sm); }
.toggle__btn { flex: 1; min-height: 44px; border: none; background: transparent; color: var(--text-muted); padding: 10px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.toggle__btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.debt-body { display: flex; flex-direction: column; gap: var(--gap); }

/* ── Insights ── */
.insights { display: flex; flex-direction: column; gap: 12px; }
.insight { display: flex; gap: 9px; font-size: 14px; line-height: 1.45; align-items: flex-start; color: var(--text-soft); }
.insight__dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--text-muted); }
.insight--positive .insight__dot { background: var(--green); }
.insight--warning .insight__dot { background: var(--red); }

/* ── Key-value (More) ── */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv__k { color: var(--text-muted); }
.kv__v { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.regime-select { font: inherit; font-weight: 600; color: var(--brand); text-align: right; text-align-last: right;
  border: none; background: transparent; padding: 2px 0; cursor: pointer; max-width: 100%; }
.regime-select:focus { outline: none; }

/* ── Charts ── */
.chart-wrap { position: relative; height: 200px; }
.chart-wrap--short { height: 120px; }
.chart { width: 100% !important; }

/* ── Bottom nav ── */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tabbar__btn { flex: 1; min-height: 44px; background: none; border: none; padding: 9px 0 8px; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
.tabbar__btn--more { flex: 0 0 52px; }
.tabbar__btn.is-active { color: var(--brand); }
.tabbar__icon { height: 22px; display: flex; align-items: center; justify-content: center; }
.tabbar__icon svg { width: 22px; height: 22px; display: block; }
.tabbar__label { font-size: 11px; font-weight: 600; }

/* Шапка прячется при скролле вниз, возвращается при скролле вверх (4.1). */
.app-header { transition: transform .25s ease; }
.app-header--hidden { transform: translateY(-100%); }

/* ── Loader screen ── */
.loader-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.loader-screen__logo { display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.loader-screen__lead { color: var(--text-muted); font-size: 15px; max-width: 280px; margin-bottom: 8px; }
.loader-screen__error { color: var(--red); font-size: 14px; }
.btn { border: none; border-radius: 14px; padding: 14px 22px; font-size: 15px; font-weight: 700; cursor: pointer; width: 100%; max-width: 300px; }
.btn + .btn { margin-top: 4px; }
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--ghost { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.btn--danger { background: none; color: var(--red); }
.btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn--ok { background: var(--green-bg); color: var(--green-ink); }
.block .btn { max-width: none; margin-top: 8px; }

/* Модалка-инструкция «какие отчёты выгрузить из 1С» (стартовый экран). */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.45); }
.modal__card { position: relative; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: var(--shadow); }
.modal__close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border: none; background: var(--surface-2); border-radius: 10px; color: var(--text-muted); font-size: 16px; cursor: pointer; }
.modal__title { font-size: 20px; font-weight: 800; margin: 0 36px 6px 0; }
.modal__lead { margin: 0 0 14px; line-height: 1.45; }
.modal__actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; position: sticky; bottom: 0; background: var(--surface); padding-top: 10px; }
.modal__actions .btn { max-width: none; margin: 0; }
.report-list { list-style: none; margin: 0; padding: 0; counter-reset: rep; display: flex; flex-direction: column; gap: 10px; }
.report-list__item { position: relative; padding: 12px 12px 12px 44px; background: var(--surface-2); border-radius: 14px; counter-increment: rep; }
.report-list__item::before { content: counter(rep); position: absolute; left: 12px; top: 12px; width: 24px; height: 24px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.report-list__title { font-size: 14px; font-weight: 600; line-height: 1.35; }
.report-list__meta { margin-top: 3px; }


/* Пояснение к безопасному остатку: значок «i» у заголовка + скрытый серый текст. */
.block__title--info { display: flex; align-items: center; gap: 8px; }
.info-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--text-muted, #6B6A62);
  color: var(--text-muted, #6B6A62); background: transparent;
  font-size: 11px; font-style: italic; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; flex: 0 0 auto;
}
.info-dot--on { background: var(--text-muted, #6B6A62); color: #fff; }
.safe-explain { margin-top: 10px; line-height: 1.45; }
.safe-explain__short { margin-bottom: 6px; }
.safe-explain__full { margin: 0; }

/* Безопасный остаток: чип зоны ликвидности + лестница уровней (MVP-градации) */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1.4;
  color: #fff; white-space: nowrap;
}
.badge--green { background: var(--green); }
.badge--amber { background: var(--amber); }
.badge--red { background: var(--red); }
.badge--critical { background: #b3271a; }
.badge--neutral { background: var(--text-muted); }
.zone-block { margin: 6px 0 12px; }
.zone-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.tiers { margin-top: 10px; line-height: 1.5; }
.tiers > div { margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════════════
   Редизайн ТОЛК (MVP) — токены/типографика выше, компоненты ниже.
   ═══════════════════════════════════════════════════════════════════ */

/* ── 2.2 Тач-цели 44×44: визуальный размер прежний, зона нажатия — псевдоэлемент ── */
.info-dot, .banner__close { position: relative; }
.info-dot::after, .banner__close::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 44px; height: 44px; transform: translate(-50%, -50%);
}

/* ── 2.3 Система статусов: форма + слово (без эмодзи и иконочных шрифтов) ── */
.chip {
  display: inline-flex; gap: 7px; align-items: center;
  border-radius: 999px; padding: 5px 11px;
  font-size: 12px; font-weight: 700; line-height: 1.2; white-space: nowrap;
}
.chip--green   { background: var(--green-bg); color: var(--green-ink); }
.chip--amber   { background: var(--amber-bg); color: var(--amber-ink); }
.chip--red     { background: var(--red-bg);   color: var(--red-ink); }
.chip--neutral { background: var(--surface-2); color: var(--text-muted); }
.shape { flex: none; display: inline-block; }
.shape--green   { width: 11px; height: 11px; border-radius: 50%; background: var(--green); }
.shape--amber   { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 11px solid var(--amber); }
.shape--red     { width: 10px; height: 10px; background: var(--red); transform: rotate(45deg); }
.shape--neutral { width: 11px; height: 2px; background: var(--text-muted); }

/* ── 2.4 Экран «Сегодня» ── */
.today-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* Текстовый блок между знаком и аватаром: min-width: 0 нужен, чтобы длинное
   название компании обрезалось многоточием, а не распирало шапку. */
.today-head__text { flex: 1; min-width: 0; }
.today-head__company { font-family: var(--f-display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em;
  background: none; border: none; padding: 0; color: var(--text); cursor: pointer; text-align: left; display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%; }
.today-head__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-head__caret { color: var(--text-muted); font-weight: 500; }
.today-head__meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.today-head__refresh { background: none; border: none; padding: 0; cursor: pointer;
  color: var(--brand); font: inherit; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--border); }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; background: var(--surface-2);
  color: var(--text-soft); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }

.verdict { background: var(--surface); border-radius: 22px; padding: 22px; box-shadow: var(--shadow); }
.verdict--green { background: var(--green-bg); }
.verdict--amber { background: var(--amber-bg); }
.verdict--red { background: var(--red-bg); }
.verdict__tail { font-size: 13.5px; line-height: 1.4; color: var(--green-ink); margin-top: 8px; }
.verdict__trend { font-size: 13.5px; line-height: 1.4; color: var(--text-soft); margin-top: 8px; }
.verdict__title { font-family: var(--f-display); font-weight: 700; font-size: 25px; line-height: 1.22; letter-spacing: -0.02em; margin: 14px 0 0; }
.verdict__sub { font-size: 15px; line-height: 1.5; color: var(--text); margin-top: 10px; }
.verdict__sub b { font-weight: 600; font-variant-numeric: tabular-nums; }
.verdict__actions { display: flex; gap: 10px; margin-top: 16px; }
.verdict__cta { flex: 1; height: 46px; border: none; border-radius: 14px; background: var(--brand); color: var(--brand-ink);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.verdict__more { width: 48px; height: 46px; border: none; border-radius: 14px; background: var(--surface-2);
  color: var(--text-soft); font-size: 20px; line-height: 1; cursor: pointer; }

/* KPI строчным списком (вместо сетки 2×2) */
.kpi-list { background: var(--surface); border-radius: var(--radius); padding: 0 18px; box-shadow: var(--shadow); }
.kpi-row { width: 100%; text-align: left; background: none; border: none; cursor: pointer; color: var(--text);
  height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--bg); }
.kpi-row:last-child { border-bottom: none; }
.kpi-row:active { background: var(--surface-2); }
.kpi-row__label { font-size: 14px; color: var(--text-soft); }
.kpi-row__val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 6px; }
.kpi-row__arrow { font-weight: 700; }
/* KPI: статус-точка и подпись-интерпретация (раньше движок их считал, а рендер выбрасывал) */
.kpi-row { height: auto; min-height: 46px; padding: 6px 0; }
.kpi-row__dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.kpi-row__dot--green { background: var(--green); }
.kpi-row__dot--amber { background: var(--amber); }
.kpi-row__dot--red { background: var(--red); }
.kpi-row__main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.kpi-row__note { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-row__note.tone-red { color: var(--red); }
.kpi-row__note.tone-green { color: var(--green); }
.kpi-row__note.tone-amber { color: var(--amber); }

/* Сигналы «Три шага на эту неделю» */
.steps-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.steps-title { font-family: var(--f-display); font-weight: 700; font-size: 16px; margin: 2px 0 0; }
.steps-caption { background: none; border: none; padding: 0; cursor: pointer; font: inherit;
  font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.signal__sent { font-size: 13px; line-height: 1.4; color: var(--green-ink); margin-top: 10px; }
.signal { background: var(--surface); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow); }
.signal__head { display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%;
  background: none; border: none; padding: 0; cursor: pointer; color: var(--text); }
.signal__shape { margin-top: 4px; }
.signal__title { font-weight: 600; font-size: 15px; line-height: 1.35; }
.signal__desc { font-size: 13.5px; color: var(--text-soft); line-height: 1.45; margin-top: 3px; }
.signal__actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.signal__btn { min-height: 40px; border: none; border-radius: 11px; padding: 9px 14px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.signal__btn--primary { background: var(--green-bg); color: var(--green-ink); }
.signal__btn--secondary { background: var(--surface-2); color: var(--text); }
.signals-all { align-self: flex-start; }

/* Плашка «что идёт хорошо» — одна строка */
.good-strip { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: var(--green-bg); border: none; border-radius: 14px; padding: 13px 16px; cursor: pointer; }
.good-strip__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); flex: none; }
.good-strip__text { font-size: 13.5px; color: var(--green-ink); line-height: 1.4; }
.good-strip--static { cursor: default; }
.good-strip__link { background: none; border: none; padding: 0; cursor: pointer; font: inherit;
  font-size: 13.5px; font-weight: 600; color: var(--green-ink); text-decoration: underline; }

.today-footer { text-align: center; padding-top: 2px; }
.today-footer__btn { background: none; border: none; cursor: pointer; font: inherit; font-size: 13px; color: var(--text-muted); }

/* Мягкий баннер устаревших данных над вердиктом */
.stale-banner { background: var(--amber-bg); color: var(--amber-ink); border-radius: 14px; padding: 12px 16px; font-size: 13.5px; line-height: 1.4;
  display: flex; align-items: center; gap: 8px; }
.stale-banner__link { margin-left: auto; font-weight: 600; text-decoration: underline; cursor: pointer; white-space: nowrap; }

/* ── 3.1 Шторка «сигнал → действие» ── */
.sheet-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(22, 21, 15, 0.42);
  display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; background: var(--surface); border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); box-shadow: var(--shadow);
  max-height: 88vh; overflow-y: auto; animation: sheet-up .22s ease; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet__handle { width: 40px; height: 4px; border-radius: 2px; background: #DAD7CD; margin: 0 auto 16px; }
.sheet__title { font-family: var(--f-display); font-weight: 700; font-size: 21px; line-height: 1.25; letter-spacing: -0.01em; }
.sheet__body { font-size: 15px; line-height: 1.5; color: var(--text-soft); margin-top: 10px; }
.sheet__draft { background: var(--surface-2); border-radius: 16px; padding: 16px; margin-top: 16px;
  font-size: 14px; line-height: 1.55; color: var(--text); }
.sheet__actions { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }
.sheet__btn { border: none; border-radius: 15px; height: 48px; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.sheet__btn--primary { background: var(--brand); color: var(--brand-ink); }
.sheet__btn--secondary { background: var(--surface-2); color: var(--text); }
.sheet__snooze { background: none; border: none; padding: 13px; font: inherit; font-size: 14px; color: var(--text-muted); cursor: pointer; }
.sheet__sub { font-family: var(--f-display); font-weight: 600; font-size: 15px; margin: 18px 0 6px; }
.sheet__sub:first-of-type { margin-top: 8px; }
.sheet__p { font-size: 14px; line-height: 1.55; color: var(--text-soft); margin: 0; }

/* ── 3.2 Экран «Деньги» v2 ── */
.balance-exact { font-size: 13.5px; color: var(--text-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.hr { height: 1px; background: var(--bg); margin: 16px 0; border: none; }
.balance-gap { font-size: 15px; line-height: 1.5; color: var(--text); margin-top: 10px; }
.balance-gap b { font-weight: 600; font-variant-numeric: tabular-nums; }
.balance-bar { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.balance-bar__track { flex: 1; height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.balance-bar__fill { height: 100%; border-radius: 6px; }
.balance-bar__cap { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }

.flows-row { display: flex; justify-content: space-between; align-items: center; }
.flows-row__cell { display: flex; flex-direction: column; gap: 3px; }
.flows-row__cell--end { text-align: right; }
.flows-row__label { font-size: 13px; color: var(--text-muted); }
.flows-row__val { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.flows-row__arrow { color: var(--border); }

.spend { display: flex; flex-direction: column; gap: 12px; }
.spend__row { display: flex; flex-direction: column; gap: 6px; }
.spend__line { display: flex; justify-content: space-between; font-size: 14px; }
.spend__val { font-weight: 600; font-variant-numeric: tabular-nums; }
.spend__track { height: 6px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.spend__fill { height: 100%; border-radius: 4px; background: var(--brand); }

.row-link { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  background: var(--surface); border: none; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  cursor: pointer; color: var(--text); text-align: left; }
.row-link__title { font-family: var(--f-display); font-weight: 700; font-size: 16px; }
.row-link__sub { font-size: 13.5px; color: var(--text-soft); margin-top: 3px; }
.row-link__chev { color: var(--text-muted); font-size: 18px; }
.method-btn { width: 100%; background: var(--surface-2); border: none; border-radius: 16px; padding: 15px 18px;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--brand); cursor: pointer; text-align: left;
  display: flex; justify-content: space-between; align-items: center; }
.block__period { font-size: 13px; color: var(--text-soft); font-weight: 400; }

/* Тост (копирование черновика при недоступности Telegram inline). */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%) translateY(8px);
  z-index: 70; background: var(--brand); color: var(--brand-ink); border-radius: 12px; padding: 11px 18px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast--on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Шторка выбора компании и периода (заголовок экрана открывает её, ТЗ 4.1). */
.picker__group { margin-bottom: 18px; }
.picker__label { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.picker__opt { width: 100%; text-align: left; background: var(--surface-2); border: none; border-radius: 12px;
  padding: 13px 16px; font: inherit; font-size: 15px; color: var(--text); cursor: pointer; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center; }
.picker__opt.is-active { color: var(--brand); font-weight: 600; }
.picker__opt.is-active::after { content: '✓'; }
.segments { display: flex; flex-wrap: wrap; gap: 8px; }
.segment { background: var(--surface-2); border: none; border-radius: 10px; padding: 9px 14px; min-height: 40px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text-soft); cursor: pointer; }
.segment.is-active { background: var(--brand); color: var(--brand-ink); }

/* ── ТЗ «Актуальность»: статусы периода, последующие события, единый вывод ── */

/* Ряд чипов в вердикте: статус финансов + режим периода. */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Контекст-строка над вердиктом: «Актуальная картина…» / «Исторический срез…». */
.today-context { text-align: center; font-size: 12.5px; color: var(--text-muted); }

/* Единый управленческий вывод раздела (вывод + риск + рекомендация + детали). */
.conclusion__summary { font-size: 15px; font-weight: 600; line-height: 1.45; }
.conclusion__action { font-size: 14px; line-height: 1.5; color: var(--text-soft); margin-top: 8px; }
.conclusion__action b { font-weight: 600; color: var(--text); }
.conclusion__details { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--bg); }

/* Последующие события на «Долгах»: строка должника + чип статуса + динамика. */
.event-row { padding: 10px 0; border-bottom: 1px solid var(--bg); }
.event-row:last-child { border-bottom: none; padding-bottom: 0; }
.event-row__top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.event-row__name { font-size: 14px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-row__delta { font-size: 13px; color: var(--text-muted); margin-top: 3px; font-variant-numeric: tabular-nums; }

/* ── Экран «Деньги»: блоки задачи dengi-potok-sxoditsya ──────────────────────
   Добавлено по замечанию независимой приёмки З-15: все 19 классов ниже
   выходили к человеку без единого правила оформления. Без `display:flex`
   подпись и сумма шли подряд, без промежутка. Раскладка та же, что у соседнего
   блока `.flows-row`, — подпись слева, сумма справа.
   Отдельная забота — ДЛИННЫЕ подписи: «С вкладов снято больше, чем отложено»,
   «На другие свои счета ушло больше, чем вернулось», «Движение на остальных
   счетах — его нет в выписке». На экране шириной 390 точек они в строку не
   помещаются, поэтому подпись переносится по словам (`min-width: 0`), а сумма
   не переносится и не сжимается (`flex: none; white-space: nowrap`): число
   обязано остаться целым и стоять у правого края. */

/* Разложение остатка на четыре группы. */
.balance-groups { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.balance-group { display: flex; flex-direction: column; gap: 3px; }
.balance-group__line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; }
.balance-group__line > span:first-child { min-width: 0; }
.balance-group__val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }
/* Оговорка про подавленный признак (З-13, решение D-20260820-88): стоит прямо
   под цифрой «можно распорядиться сегодня», отделена тонкой чертой, чтобы её не
   прочитали как продолжение пояснения к строке. */
.balance-group__note { display: block; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--bg); line-height: 1.45; }

/* Сверка движения денег с изменением остатка. */
.recon { display: flex; flex-direction: column; gap: 8px; }
.recon__diff { font-size: 15px; line-height: 1.45; color: var(--text); margin-bottom: 2px; }
.recon__diff b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.recon__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; color: var(--text-soft); }
.recon__row > span:first-child { min-width: 0; }
.recon__val { font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; color: var(--text); }
/* Итоговая строка «Изменение остатка на счетах» — отделена чертой и жирная. */
.recon__row--total { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--bg); font-weight: 600; color: var(--text); }
.recon__row--total .recon__val { font-weight: 600; }
.recon .muted.small { margin-top: 4px; line-height: 1.45; }

/* Переводы на свои счета — куда они делись. */
.transfers { display: flex; flex-direction: column; gap: 12px; }
.transfers__row { display: flex; flex-direction: column; gap: 3px; }
.transfers__line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; }
.transfers__line > span:first-child { min-width: 0; }
.transfers__val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }
.transfers > .muted.small { margin-top: 2px; padding-top: 10px; border-top: 1px solid var(--bg); line-height: 1.45; }

/* Карточка догадки «этот счёт — кошелёк посредника» и подтверждение одним нажатием. */
.guess { border: 1px solid var(--border); }
.guess__text { font-size: 14px; line-height: 1.5; color: var(--text-soft); margin: 8px 0 0; }
/* Кнопки в один ряд, обе одинаковой ширины. На узком экране «Нет, это наш счёт»
   в одну строку не влезает рядом с «Да, верно» — тогда ряд переносится, и
   кнопки встают одна под другой во всю ширину, а не обрезаются. */
.guess__row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.guess__btn { flex: 1 1 140px; border: none; border-radius: 14px; padding: 13px 16px;
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; text-align: center; }
.guess__btn--yes { background: var(--brand); color: var(--brand-ink); }
.guess__btn--no { background: var(--surface-2); color: var(--text); }

/* Оговорка про счёт платёжного сервиса под цифрой «Деньги» на экране «Сегодня»
   (замечание приёмки З-23). Вынесена из кнопки-строки наружу, чтобы чтение не
   превращалось в случайный переход на другой экран. */
.kpi-row__wrap { display: flex; flex-direction: column; }
.kpi-row__caveat { padding: 0 4px 10px 22px; line-height: 1.45; }
