/* ═══════════════════════════════════════════════════════════
   X314 — умная бухгалтерия
   Палитра: тёплый беж + глубокая зелень + терракота
   Шрифты: Unbounded (толстый/тонкий) + Manrope (текст)
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #F4EFE5;
  --bg-soft: #EDE6D6;
  --surface: #FBF8F1;
  --surface-2: #F7F2E7;
  --ink: #1F1B16;
  --ink-soft: #4A4436;
  --muted: #8E8674;
  --line: #E3DAC7;
  --line-strong: #CFC4AB;
  --accent: #2E5C49;
  --accent-soft: #3D7560;
  --accent-tint: #E4EBE2;
  --terra: #C0653B;
  --green: #2F7A46;
  --red: #B4452F;
  --radius: 18px;
  --radius-sm: 12px;
  --font-display: "Unbounded", "Arial Black", sans-serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --shadow: 0 2px 6px rgba(31,27,22,.04), 0 16px 40px rgba(31,27,22,.07);
  --shadow-sm: 0 1px 3px rgba(31,27,22,.05), 0 6px 16px rgba(31,27,22,.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body); font-weight: 400;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(31,27,22,.055) 1px, transparent 1.4px);
  background-size: 26px 26px;
  color: var(--ink); min-height: 100vh;
  -webkit-font-smoothing: antialiased; line-height: 1.6;
}
::selection { background: var(--accent); color: var(--bg); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--red); font-size: 14px; margin-top: 10px; font-weight: 600; }
.pos { color: var(--green); }
.neg { color: var(--red); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─────────── логотип: X из растущей линии и монеты ───────────
   Знак читается как «X» и как график: тёмная плашка, кремовая нисходящая
   штриха, поверх — терракотовая восходящая линия с монетой на пике. */

.logo-mark {
  width: 28px; height: 28px; flex: none; display: inline-block;
  border-radius: 9px; position: relative;
  background:
    url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'>\
<g fill='none' stroke-linecap='round' stroke-linejoin='round'>\
<path d='M8.5 10.5 L23.5 23.5' stroke='%23F4EFE5' stroke-width='2.6' opacity='.55'/>\
<path d='M7.5 23.5 L14 17 L18 20.5 L24.5 9.5' stroke='%23C0653B' stroke-width='3'/>\
<circle cx='24.5' cy='9.5' r='2.9' fill='%23F4EFE5' stroke='none'/>\
</g></svg>") center / 100% 100% no-repeat,
    linear-gradient(150deg, #2A251E 0%, var(--ink) 55%, #14120F 100%);
  box-shadow: inset 0 1px 0 rgba(244, 239, 229, .14), 0 2px 8px rgba(31, 27, 22, .22);
}
.logo-mark.sm { width: 23px; height: 23px; border-radius: 7px; }
.logo:hover .logo-mark { transform: rotate(-4deg) scale(1.04); }
.logo-mark { transition: transform .25s ease; }
.logo-text { position: relative; }
.logo-text::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 2px;
  background: var(--terra); border-radius: 2px; transform: scaleX(0);
  transform-origin: left; transition: transform .25s ease;
}
.logo:hover .logo-text::after { transform: scaleX(1); }

/* ─────────── шапка ─────────── */

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px clamp(18px, 4vw, 40px);
  position: sticky; top: 0; z-index: 50;
  background: rgba(244,239,229,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo-text { font-family: var(--font-display); font-weight: 900; font-size: 20px; letter-spacing: .02em; }
.logo-text.sm { font-size: 15px; }
.topnav { display: flex; gap: 26px; }
.topnav a { color: var(--ink-soft); text-decoration: none; font-size: 14px; font-weight: 600; transition: color .2s; }
.topnav a:hover { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.usage {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px; white-space: nowrap;
}

/* ─────────── кнопки ─────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid transparent; border-radius: 999px; cursor: pointer;
  font-family: var(--font-body); font-size: 14px; font-weight: 700; letter-spacing: .01em;
  padding: 12px 26px; text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { background: var(--accent-soft); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(46,92,73,.25); }
.btn-primary:disabled { opacity: .55; cursor: wait; transform: none; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink); transform: translateY(-2px); }
.btn-cream { background: var(--bg); color: var(--ink); }
.btn-cream:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.18); }
.btn-sm { padding: 9px 20px; font-size: 13px; }
.btn-lg { padding: 15px 34px; font-size: 15px; }

/* ═══════════ ЛЕНДИНГ ═══════════ */

.hero { position: relative; max-width: 1160px; margin: 0 auto; padding: clamp(70px,11vh,130px) 24px 40px; }
.hero-inner { position: relative; z-index: 2; max-width: 780px; }
.overline { font-size: 12px; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; color: var(--terra); margin-bottom: 26px; }
h1 { line-height: 1.04; margin-bottom: 30px; }
.h1-thin, .h1-bold { display: block; }
.h1-thin { font-family: var(--font-display); font-weight: 300; font-size: clamp(30px,5.2vw,58px); color: var(--ink-soft); letter-spacing: -.01em; }
.h1-bold { font-family: var(--font-display); font-weight: 900; font-size: clamp(24px,4.4vw,52px); letter-spacing: -.02em; margin-top: 10px; white-space: nowrap; }
.h1-thin { font-size: clamp(24px,3.4vw,40px); line-height: 1.15; }
.quote-by { font-family: var(--font-display); font-weight: 800; font-size: 14px; color: var(--terra); letter-spacing: .1em; margin: -14px 0 26px; }
.sub { color: var(--ink-soft); font-size: clamp(15px,1.6vw,18px); max-width: 620px; line-height: 1.7; margin-bottom: 36px; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }

.hero-shapes, .cta-shapes { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.shape { position: absolute; display: block; }
.s-ring { width: 230px; height: 230px; border: 1.5px solid var(--line-strong); border-radius: 50%; top: 4%; right: -30px; animation: floatY 16s ease-in-out infinite; }
.s-ring::after { content: ""; position: absolute; inset: 34px; border: 1.5px dashed var(--line-strong); border-radius: 50%; animation: spin 60s linear infinite; }
.s-ring.small { width: 130px; height: 130px; top: -40px; right: 8%; opacity: .5; }
.s-ring.small::after { inset: 20px; }
.s-square { width: 110px; height: 110px; border: 1.5px solid var(--terra); border-radius: 20px; opacity: .5; bottom: 16%; right: 16%; animation: squareDrift 22s ease-in-out infinite; }
.s-plus { width: 34px; height: 34px; top: 22%; right: 34%; opacity: .8; animation: floatY 12s ease-in-out infinite reverse; }
.s-plus::before, .s-plus::after { content: ""; position: absolute; background: var(--accent); border-radius: 3px; }
.s-plus::before { left: 50%; top: 0; width: 3px; height: 100%; transform: translateX(-50%); }
.s-plus::after { top: 50%; left: 0; height: 3px; width: 100%; transform: translateY(-50%); }
.s-plus.small { transform: scale(.7); top: auto; bottom: 18%; left: 6%; right: auto; opacity: .55; }
.s-dots { width: 120px; height: 90px; background-image: radial-gradient(var(--line-strong) 1.8px, transparent 2px); background-size: 18px 18px; bottom: 4%; left: -10px; opacity: .9; animation: floatY 18s ease-in-out infinite; }
.s-coin { width: 16px; height: 16px; border-radius: 50%; background: var(--terra); opacity: .65; top: 42%; right: 8%; animation: floatY 9s ease-in-out infinite; }

@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-22px); } }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes squareDrift { 0%,100% { transform: rotate(8deg) translateY(0); } 50% { transform: rotate(16deg) translateY(-18px); } }

.strip { position: relative; z-index: 2; display: grid; grid-template-columns: repeat(3,1fr); margin-top: clamp(56px,9vh,96px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.strip-item { padding: 26px 30px; }
.strip-item + .strip-item { border-left: 1px solid var(--line); }
.strip-value { font-family: var(--font-display); font-weight: 800; font-size: clamp(18px,2.2vw,24px); color: var(--accent); margin-bottom: 6px; }
.strip-label { font-size: 13px; color: var(--muted); line-height: 1.5; }

.section { max-width: 1160px; margin: 0 auto; padding: clamp(70px,11vh,120px) 24px; }
.section-alt { max-width: none; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-alt > * { max-width: 1160px; margin-left: auto; margin-right: auto; }
.section-head { margin-bottom: clamp(40px,6vh,64px); }
.section-head .overline { margin-bottom: 14px; }
h2 { font-family: var(--font-display); font-weight: 800; font-size: clamp(26px,3.8vw,44px); line-height: 1.12; letter-spacing: -.01em; }

.features { display: grid; grid-template-columns: repeat(auto-fit,minmax(300px,1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px 28px; transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease; }
.card:hover { transform: translateY(-5px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.ficon { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; background: var(--accent-tint); border-radius: 14px; color: var(--accent); margin-bottom: 20px; }
.ficon svg { width: 24px; height: 24px; }
.card h3 { font-family: var(--font-display); font-weight: 800; font-size: 16px; margin-bottom: 10px; }
.card p { color: var(--ink-soft); font-size: 14px; line-height: 1.65; }

.steps { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 22px; align-items: start; }
.step-num { font-family: var(--font-display); font-weight: 900; font-size: clamp(40px,5vw,60px); color: transparent; -webkit-text-stroke: 1.5px var(--line-strong); line-height: 1; margin-bottom: 18px; transition: color .3s ease; }
.step:hover .step-num { color: var(--terra); -webkit-text-stroke-color: var(--terra); }
.step h3 { font-family: var(--font-display); font-weight: 800; font-size: 17px; margin-bottom: 10px; }
.step p { color: var(--ink-soft); font-size: 14px; line-height: 1.65; max-width: 300px; }
.step-arrow { color: var(--line-strong); padding-top: 14px; animation: nudge 2.6s ease-in-out infinite; }
.step-arrow svg { width: 26px; height: 26px; }
@keyframes nudge { 0%,100% { transform: translateX(0); } 50% { transform: translateX(6px); } }

.cta-section { padding-bottom: clamp(80px,12vh,140px); }
.cta-box { position: relative; background: var(--accent); color: var(--bg); border-radius: 28px; padding: clamp(50px,8vh,80px) clamp(28px,6vw,80px); text-align: center; overflow: hidden; box-shadow: 0 24px 60px rgba(46,92,73,.32); }
.cta-box h2 { color: var(--bg); margin-bottom: 14px; }
.cta-box .muted { color: rgba(244,239,229,.75); margin-bottom: 32px; font-size: 15px; }
.cta-box .s-ring { border-color: rgba(244,239,229,.25); }
.cta-box .s-ring::after { border-color: rgba(244,239,229,.18); }
.cta-box .s-plus::before, .cta-box .s-plus::after { background: rgba(244,239,229,.35); }

.footer { display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--muted); font-size: 13px; padding: 30px 24px 40px; border-top: 1px solid var(--line); }

.reveal { opacity: 0; transform: translateY(26px); transition: opacity .7s ease, transform .7s ease; }
.reveal.visible { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: .08s; } .reveal.d2 { transition-delay: .16s; }
.reveal.d3 { transition-delay: .26s; } .reveal.d4 { transition-delay: .36s; } .reveal.d5 { transition-delay: .46s; }

/* ═══════════ МОДАЛКИ ═══════════ */

.modal { position: fixed; inset: 0; z-index: 1000; background: rgba(31,27,22,.45); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 34px; width: 420px; max-width: 94vw; box-shadow: var(--shadow); animation: modalIn .3s ease; max-height: 90vh; overflow-y: auto; }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-logo { margin-bottom: 22px; }
.modal-box h2 { font-size: 22px; margin-bottom: 6px; }
.modal-box input, .modal-box select {
  width: 100%; padding: 12px 16px; background: var(--bg);
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  color: var(--ink); font-size: 15px; font-family: var(--font-body); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#code-input { margin-top: 20px; font-weight: 600; letter-spacing: .12em; font-size: 16px; }
.modal-box input:focus, .modal-box select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(46,92,73,.12); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }
.field { margin-top: 14px; }
.field label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* ═══════════ КАБИНЕТ ═══════════ */

.workspace {
  display: grid;
  grid-template-columns: minmax(520px, 42%) minmax(0, 1fr);
  gap: 20px;
  padding: 18px clamp(14px, 2.5vw, 30px);
  max-width: 1720px; margin: 0 auto;
  height: calc(100vh - 66px);
}

.main-area { display: flex; flex-direction: column; gap: 16px; min-height: 0; }

/* навигация: главные разделы + подразделы */
.nav-primary { display: flex; flex-wrap: wrap; gap: 6px; flex: none; }
.np-item {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 11px 18px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink-soft);
  font-family: var(--font-body); font-size: 13.5px; font-weight: 700;
  cursor: pointer; transition: background .18s, color .18s, border-color .18s;
}
.np-item svg { width: 18px; height: 18px; flex: none; }
.np-item:hover { border-color: var(--line-strong); color: var(--ink); }
.np-item.active { background: var(--accent); color: var(--bg); border-color: var(--accent); box-shadow: var(--shadow-sm); }

.nav-sub { display: flex; flex-wrap: wrap; gap: 4px; flex: none; margin-top: -6px; }
.nav-sub.hidden { display: none; }
.sub-item {
  padding: 7px 14px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--ink-soft);
  font-family: var(--font-body); font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s;
}
.sub-item:hover { background: var(--surface); color: var(--ink); }
.sub-item.active { background: var(--surface); color: var(--accent); border-color: var(--line); box-shadow: var(--shadow-sm); }

/* контент */
.content { overflow-y: auto; min-height: 0; padding-right: 6px; display: flex; flex-direction: column; gap: 16px; padding-bottom: 12px; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 2px; }
.section-title h1 { font-family: var(--font-display); font-weight: 800; font-size: 22px; }
.section-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* карточки-статы */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; transition: transform .2s, box-shadow .2s; }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.stat .label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.stat .value { font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.stat .stat-hint { font-size: 10.5px; color: var(--muted); margin-top: 5px; line-height: 1.35; }

/* пустое состояние вкладки (нет данных) */
.empty-hint {
  display: flex; gap: 14px; align-items: flex-start; padding: 20px 22px;
  background: var(--surface); border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  font-size: 13px; color: var(--ink-soft); line-height: 1.55;
}
.empty-hint strong { display: block; color: var(--ink); font-size: 14px; margin-bottom: 4px; }
.empty-hint p { margin: 0; max-width: 480px; }
.empty-hint-icon {
  flex-shrink: 0; width: 38px; height: 38px; display: grid; place-items: center;
  font-size: 18px; color: var(--accent); background: var(--accent-tint); border-radius: 11px;
}

/* заметка-подсказка под таблицей/блоком (формулы, пояснения) */
/* Пояснение к расчёту: по умолчанию свёрнуто в одну строку-ссылку, раскрывается по клику.
   Раньше на «Прогнозе» лежало пять таких абзацев подряд — они занимали больше места,
   чем сами цифры. */
.info-note {
  padding: 10px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--muted); line-height: 1.55;
}
details.info-note > summary {
  list-style: none; cursor: pointer; font-weight: 700; color: var(--ink-soft);
  display: flex; align-items: center; gap: 6px;
}
details.info-note > summary::-webkit-details-marker { display: none; }
details.info-note > summary::before {
  content: "?"; flex: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--line); color: var(--ink-soft); font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
}
details.info-note[open] > summary { margin-bottom: 8px; }
details.info-note > summary::after { content: "›"; margin-left: auto; font-size: 16px; transition: transform .15s; }
details.info-note[open] > summary::after { transform: rotate(90deg); }
details.info-note .note-body { color: var(--muted); }

/* строка таблицы: заголовок + мелкая подпись под ним (переносится между вкладками) */
.tbl .cell-main { font-weight: 600; line-height: 1.3; }
.tbl .cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
/* заметка к обязательству бывает в несколько строк — без min-width колонка схлопывается
   в столбик по одному слову и таблицу невозможно читать */
.tbl td.obl-name { min-width: 230px; }

/* блоки */
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.block-head h3 { font-family: var(--font-display); font-weight: 800; font-size: 14px; }
.block-total { font-family: var(--font-display); font-weight: 800; font-size: 15px; }

/* таблицы */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tr.clickable:hover { background: var(--surface-2); cursor: default; }
.amount-income { color: var(--green); font-weight: 700; }
.amount-expense { color: var(--red); font-weight: 700; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; cursor: pointer; color: var(--muted); transition: all .15s; }
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }
.icon-btn svg { width: 15px; height: 15px; }
.topbar-right .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
.topbar-right .icon-btn svg { width: 17px; height: 17px; }
.topbar-right .icon-btn:hover { color: var(--red); border-color: var(--red); }

.empty { color: var(--muted); font-size: 14px; padding: 6px 2px; }

/* фильтры / чипы */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 15px; border-radius: 999px; border: 1.5px solid var(--line-strong); background: transparent; color: var(--ink-soft); font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; }
.chip:hover { border-color: var(--ink); }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* столбчатая диаграмма (чистый CSS) */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 84px 1fr auto; gap: 12px; align-items: center; font-size: 13px; }
.bar-track { height: 22px; background: var(--bg-soft); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; border-radius: 6px; transition: width .6s ease; }
.bar-fill.inc { background: var(--green); }
.bar-fill.exp { background: var(--terra); }
.bar-label { color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-val { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }

.dual-bars { display: flex; flex-direction: column; gap: 12px; }
.dual-row { font-size: 13px; }
.dual-row .m { color: var(--muted); margin-bottom: 5px; display: flex; justify-content: space-between; }
.dual-track { display: flex; height: 14px; border-radius: 6px; overflow: hidden; background: var(--bg-soft); border: 1px solid var(--line); }
.dual-track .inc { background: var(--green); }
.dual-track .exp { background: var(--terra); }

/* чат */
.chat-panel { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-title-left { display: flex; align-items: center; gap: 10px; }
.panel-title-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.panel-title-right .icon-btn { width: 32px; height: 32px; border-radius: 9px; }
.panel-title-right .icon-btn:hover { color: var(--red); border-color: var(--red); }
.panel-title h2 { font-family: var(--font-display); font-weight: 800; font-size: 16px; }
.mood-tag { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }

.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 8px; }
.msg { max-width: 88%; padding: 12px 16px; border-radius: var(--radius); font-size: 14px; line-height: 1.55; word-break: break-word; animation: msgIn .25s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--bg); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.chat-warn { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: #fde8e4; color: var(--red); font-size: 13px; }

/* режим подтверждения: кнопки-операции под ответом ИИ */
.usage.stale { color: var(--red); font-weight: 700; }
.usage-click { cursor: pointer; }
.usage-click:hover { border-color: var(--accent, #4f8cff); color: var(--text, #e8edf5); }
.usage.low { color: var(--red); font-weight: 700; border-color: var(--red); }
.op-confirm { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.op-confirm-head { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 8px; }
.op-list { display: flex; flex-direction: column; gap: 6px; }
.op-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink);
  transition: all .15s;
}
.op-btn:hover:not(:disabled) { border-color: var(--accent); background: rgba(46,92,73,.06); }
.op-btn .op-mark { flex: 0 0 auto; width: 18px; height: 18px; display: inline-flex; align-items: center;
  justify-content: center; border-radius: 50%; font-weight: 700; font-size: 12px;
  background: var(--accent); color: #fff; }
.op-btn .op-label { flex: 1; }
.op-btn.loading { opacity: .6; cursor: progress; }
.op-btn.done { border-color: var(--accent); background: rgba(46,92,73,.1); color: var(--ink-soft); cursor: default; }
.op-btn.done .op-mark { background: var(--green, #4a7c59); }
.op-btn.err { border-color: var(--red); background: #fde8e4; }
.op-btn.err .op-mark { background: var(--red); }
.op-all {
  margin-top: 8px; padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
  background: var(--accent); color: #fff; border: none;
}
.op-all:hover:not(:disabled) { filter: brightness(1.06); }
.op-all:disabled { opacity: .5; cursor: default; }
.msg.typing { color: var(--muted); white-space: pre-wrap; }

/* живая траектория прогноза под ответом (эфемерная, стирается при новом сообщении) */
.msg-forecast { align-self: stretch; margin: 2px 0 6px; padding: 10px 12px; border: 1px dashed var(--line);
  border-radius: 12px; background: var(--surface-2); }
.msg-forecast .fc-head { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px; }
.msg-forecast .fc-gap { font-weight: 600; color: var(--red); font-size: 11px; }
.msg-forecast .fc-canvas { position: relative; width: 100%; height: 190px; }

/* markdown-разметка в ответах X314 */
.msg.assistant p { margin: 0 0 10px; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant strong { font-weight: 700; color: var(--ink); }
.msg.assistant em { font-style: italic; }
.msg.assistant h3, .msg.assistant h4, .msg.assistant h5, .msg.assistant h6 {
  font-family: var(--font-display); font-weight: 800; line-height: 1.3; margin: 14px 0 8px;
}
.msg.assistant h3:first-child, .msg.assistant h4:first-child,
.msg.assistant h5:first-child, .msg.assistant h6:first-child { margin-top: 0; }
.msg.assistant h3 { font-size: 16px; } .msg.assistant h4 { font-size: 15px; }
.msg.assistant h5, .msg.assistant h6 { font-size: 14px; }
.msg.assistant ul, .msg.assistant ol { margin: 0 0 10px; padding-left: 20px; }
.msg.assistant ul:last-child, .msg.assistant ol:last-child { margin-bottom: 0; }
.msg.assistant li { margin: 3px 0; }
.msg.assistant li::marker { color: var(--accent); }
.msg.assistant code { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 6px; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12.5px; }
.msg.assistant pre { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin: 0 0 10px; overflow-x: auto; }
.msg.assistant pre code { background: none; border: none; padding: 0; }
.msg.assistant blockquote { margin: 0 0 10px; padding: 2px 12px; border-left: 3px solid var(--accent);
  color: var(--ink-soft); }
.msg.assistant hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.msg.assistant .md-table-wrap { margin: 0 0 10px; overflow-x: auto; }
.msg.assistant .md-table-wrap:last-child { margin-bottom: 0; }
.msg.assistant table.md-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.msg.assistant table.md-table th, .msg.assistant table.md-table td {
  border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.msg.assistant table.md-table th { background: var(--bg-soft); font-weight: 700; color: var(--ink); }
.msg.assistant table.md-table tr:nth-child(even) td { background: rgba(31,27,22,.02); }
.dots { display: inline-flex; gap: 5px; align-items: center; height: 10px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: dotPulse 1.2s ease-in-out infinite; }
.dots span:nth-child(2) { animation-delay: .18s; } .dots span:nth-child(3) { animation-delay: .36s; }
@keyframes dotPulse { 0%,100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

/* строка ввода: скрепка + текст + отправить, всё одной высоты по нижней кромке */
.chat-input-row { display: flex; gap: 8px; margin-top: 14px; align-items: stretch; }
.chat-input-row textarea { flex: 1; resize: none; padding: 12px 14px; background: var(--bg); border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); color: var(--ink); font-size: 14px; font-family: var(--font-body); line-height: 1.5; outline: none; transition: border-color .2s, box-shadow .2s; min-width: 0; min-height: 48px; }
.model-select { flex: none; max-width: 128px; padding: 7px 10px; font-size: 12px; font-weight: 600; font-family: var(--font-body); background: var(--bg); border: 1.5px solid var(--line-strong); border-radius: 999px; color: var(--ink-soft); cursor: pointer; }
.model-select:focus { border-color: var(--accent); outline: none; }
.period-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.period-bar select { padding: 8px 12px; font-size: 13px; font-weight: 600; font-family: var(--font-body); background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 999px; color: var(--ink); cursor: pointer; }
.period-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.chat-input-row textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(46,92,73,.1); }
.btn-attach { flex: none; width: 48px; border-radius: var(--radius-sm); border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all .15s; align-self: stretch; }
.btn-attach:hover { color: var(--accent); border-color: var(--accent); }
.btn-attach svg { width: 20px; height: 20px; }

.attach-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.attach-preview.hidden { display: none; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 8px 10px 8px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-size: 13px; color: var(--ink-soft);
}
.attach-chip button {
  width: 22px; height: 22px; border: none; border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
}
.attach-chip button:hover { color: var(--red); background: rgba(180,60,50,.08); }
.btn-send { padding: 12px 16px; border-radius: var(--radius-sm); flex: none; align-self: stretch; }
.btn-send svg { width: 20px; height: 20px; }
.file-hint { margin-top: 10px; font-size: 12px; color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }

/* ═══════════ CFO-АНАЛИТИКА ═══════════ */

/* большое красное предупреждение о кассовом разрыве */
.alert-gap {
  background: var(--red); color: #FBF3EE;
  border-radius: var(--radius); padding: 18px 22px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: 0 10px 30px rgba(180,69,47,.35);
}
.alert-gap .alert-icon { font-size: 26px; line-height: 1; flex: none; }
.alert-gap .alert-title { font-family: var(--font-display); font-weight: 800; font-size: 15px; margin-bottom: 3px; }
.alert-gap .alert-text { font-size: 13.5px; opacity: .95; }
.alert-gap.warn { background: var(--terra); box-shadow: 0 10px 30px rgba(192,101,59,.3); }

/* сигналы / предупреждения */
.signals { display: flex; flex-direction: column; gap: 8px; }
.signal { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.5; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); }
.signal::before { content: ""; width: 9px; height: 9px; border-radius: 50%; flex: none; margin-top: 5px; background: var(--muted); }
.signal.red { border-color: rgba(180,69,47,.45); background: rgba(180,69,47,.07); }
.signal.red::before { background: var(--red); }
.signal.yellow { border-color: rgba(192,101,59,.4); background: rgba(192,101,59,.07); }
.signal.yellow::before { background: var(--terra); }
.signal.info::before { background: var(--accent); }

/* графики: одна высота у всех, чтобы вкладка не «дышала» блоками разного роста */
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box.tall { height: 330px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1400px) { .chart-grid { grid-template-columns: 1fr; } }

/* строки-призраки: план в будущих датах */
.tbl tr.ghost td { color: var(--muted); font-weight: 300; font-style: italic; }
.tbl tr.ghost .amount-income, .tbl tr.ghost .amount-expense { font-weight: 400; opacity: .75; }
.tbl tr.day-head td { background: var(--surface-2); font-weight: 700; font-size: 12px; color: var(--ink-soft); border-top: 1px solid var(--line-strong); }
.tbl tr.day-head td .day-total { float: right; font-variant-numeric: tabular-nums; }

/* ═══════════ сводка: пять главных цифр ═══════════ */
.stat-cards.five { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1500px) { .stat-cards.five { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .stat-cards.five { grid-template-columns: repeat(2, 1fr); } }
/* карточка-кнопка: баланс счетов ведёт в раздел «Счета» */
button.stat.clickable {
  font: inherit; text-align: left; cursor: pointer; width: 100%;
  color: inherit; position: relative;
}
button.stat.clickable::after {
  content: "→"; position: absolute; top: 14px; right: 16px;
  color: var(--muted); font-size: 14px; transition: transform .18s, color .18s;
}
button.stat.clickable:hover::after { transform: translateX(3px); color: var(--accent); }
button.stat.clickable:hover { border-color: var(--line-strong); }

/* ═══════════ панель фильтров раздела «Операции» ═══════════ */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.seg {
  display: inline-flex; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px; gap: 2px;
}
.seg-btn {
  border: none; background: transparent; cursor: pointer; padding: 7px 15px;
  border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  transition: background .15s, color .15s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--ink); color: var(--bg); }
.search { flex: 1 1 220px; min-width: 180px; }
.search input {
  width: 100%; padding: 9px 15px; border-radius: 999px; font: inherit; font-size: 13px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: border-color .18s, box-shadow .18s;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(46,92,73,.1); }

/* топ категорий за период — быстрые фильтры */
.cat-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-pill {
  display: inline-flex; align-items: baseline; gap: 8px; cursor: pointer;
  padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  transition: border-color .15s, color .15s;
}
.cat-pill b { font-family: var(--font-display); font-weight: 800; color: var(--ink); }
.cat-pill:hover { border-color: var(--line-strong); color: var(--ink); }
.cat-pill.active { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.cat-pill.active b { color: var(--bg); }

/* таблица операций: точка типа, колонки фиксированной ширины, кнопки не съезжают */
.tbl.ops td { vertical-align: top; }
.tbl.ops .op-cat { white-space: nowrap; font-weight: 600; }
.tbl.ops .op-desc { width: 100%; }
.tbl.ops .op-acc { white-space: nowrap; font-size: 12px; }
.tbl.ops .op-act { width: 78px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.dot.income { background: var(--green); }
.dot.expense { background: var(--terra); }
.tbl tr.day-head td .dh-date { font-size: 12.5px; }
.tbl tr.day-head td .dh-sums { float: right; display: inline-flex; gap: 12px; font-variant-numeric: tabular-nums; }
.tbl tr.day-head td .dh-net { color: var(--ink-soft); }

/* кнопки строки: два значка всегда в одну строку, колонка фиксированной ширины */
.row-actions { flex-wrap: nowrap; }
.tbl td.act, .tbl th.act { width: 78px; white-space: nowrap; }
/* широкую таблицу лучше прокрутить, чем ломать колонки переносами */
.tbl-wrap { width: 100%; overflow-x: auto; position: relative; }
.tbl-wrap > .tbl { min-width: 760px; }
/* колонка с кнопками прилипает к правому краю: при прокрутке широкой таблицы
   «изменить/удалить» всегда на месте, а не уезжают за границу экрана */
.tbl-wrap .tbl td.act, .tbl-wrap .tbl th.act {
  position: sticky; right: 0; background: var(--surface);
  box-shadow: -10px 0 10px -10px rgba(31,27,22,.25);
}

/* длинные суммы в карточках: цифра не должна разваливаться на две строки */
.stat { container-type: inline-size; }
.stat .value { white-space: nowrap; font-size: clamp(14px, 11cqw, 18px); }

/* бейджи */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .03em; border: 1px solid var(--line-strong); color: var(--ink-soft); white-space: nowrap; }
.badge.green { background: rgba(47,122,70,.1); color: var(--green); border-color: rgba(47,122,70,.35); }
.badge.red { background: rgba(180,69,47,.08); color: var(--red); border-color: rgba(180,69,47,.35); }
.badge.terra { background: rgba(192,101,59,.1); color: var(--terra); border-color: rgba(192,101,59,.35); }
.badge.grey { background: var(--surface-2); }
.cur-badge { font-size: 11px; font-weight: 700; color: var(--muted); margin-left: 5px; }

/* карточки коэффициентов */
.ratio-cards { display: grid; grid-template-columns: repeat(auto-fill,minmax(180px,1fr)); gap: 12px; }
/* подзаголовок смысловой группы метрик */
.sub-title {
  font-family: var(--font-display); font-weight: 800; font-size: 13px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-soft); margin: 6px 0 -4px;
}
.sub-title:first-of-type { margin-top: 0; }
.ratio { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.ratio .label { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
.ratio .value { font-family: var(--font-display); font-weight: 800; font-size: 17px; }
.ratio .hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.45; }

/* карточки рекламных кампаний */
.ad-list { display: grid; gap: 14px; }
.ad-list--single { grid-template-columns: 1fr; }
.ad-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.ad-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.ad-name { font-family: var(--font-display); font-weight: 800; font-size: 16px; line-height: 1.25; }
.ad-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.ad-card-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ad-metrics { display: grid; grid-template-columns: repeat(auto-fit,minmax(118px,1fr)); gap: 12px 14px; }
.ad-metric { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ad-metric .m-label { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ad-metric .m-val { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; white-space: nowrap; }
.ad-metric .m-val.pos { color: var(--green); } .ad-metric .m-val.neg { color: var(--red); }
/* подпись под значением (рубли под валютой, % освоения) — своей строкой,
   иначе валютные суммы наезжают на соседнюю колонку сетки */
.ad-metric .m-sub { display: block; font-weight: 400; color: var(--muted); font-size: 12px; white-space: normal; }
.ad-metric .m-sub:empty { display: none; }

/* сравнение нескольких кампаний */
.ad-compare-block { padding-bottom: 12px; }
.ad-compare-block .block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.ad-compare-block .block-head h2 { font-family: var(--font-display); font-size: 15px; font-weight: 800; margin: 0; }
.ad-compare-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.ad-compare { min-width: 520px; }
.ad-compare th, .ad-compare td { padding: 10px 8px; }
.ad-compare td:first-child { min-width: 140px; max-width: 220px; }
.ad-compare .badge { margin-top: 6px; }
.ad-compare .row-actions { justify-content: flex-end; }

/* серверы: компактная таблица с заголовком+подписью в ячейках */
.srv-tbl td:first-child { min-width: 150px; }
.srv-tbl .cell-sub + .cell-sub { margin-top: 1px; }

/* бизнес-модель: тарифы */
.bm-kpis { margin-bottom: 16px; }
.bm-block { margin-top: 0; }
.bm-list { display: grid; gap: 12px; }
.bm-list-empty { padding: 28px 16px; text-align: center; }
.bm-card {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px; transition: border-color .15s, box-shadow .15s;
}
.bm-card:focus-within { border-color: rgba(46,92,73,.35); box-shadow: 0 0 0 3px rgba(46,92,73,.08); }
.bm-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.bm-card-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; flex-wrap: wrap; }
.bm-chip {
  display: inline-flex; align-items: baseline; gap: 2px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent);
  background: rgba(46,92,73,.1); white-space: nowrap;
}
.bm-chip-sub { font-weight: 500; color: var(--muted); font-size: 11px; }
.bm-fields {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px 12px;
}
@media (max-width: 1100px) { .bm-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .bm-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bm-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.bm-field label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); line-height: 1.2;
}
.bm-inp {
  width: 100%; padding: 9px 11px; font-size: 14px; font-family: var(--font-body);
  font-variant-numeric: tabular-nums; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: 8px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.bm-inp::placeholder { color: var(--muted); opacity: .75; }
.bm-inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,92,73,.1); }
.bm-inp--name {
  flex: 1; min-width: 140px; font-family: var(--font-display); font-weight: 800; font-size: 15px;
  background: transparent; border: none; border-bottom: 1.5px solid transparent; border-radius: 0;
  padding: 2px 0 4px;
}
.bm-inp--name:focus { border-bottom-color: var(--accent); box-shadow: none; }
.bm-field--ltv { justify-content: flex-end; }
.bm-ltv-val {
  padding: 9px 11px; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 8px; text-align: right;
}
.bm-notes-wrap { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.bm-notes-label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
}
.bm-notes {
  width: 100%; padding: 11px 13px; font-size: 14px; font-family: var(--font-body); line-height: 1.5;
  color: var(--ink); background: var(--surface-2); border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm); resize: vertical; min-height: 56px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.bm-notes:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,92,73,.1); }
.bm-foot { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.bm-block .info-note { margin-top: 14px; }

/* курсы валют */
.fx-line { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--ink-soft); }
.fx-line b { font-variant-numeric: tabular-nums; }
.fx-line .stale { color: var(--terra); }

/* сценарии прогноза */
.scenario-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px; }
.scenario-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

/* подсказка управления масштабом под графиками (колесо/перетаскивание) */
.pan-hint {
  margin-top: 8px; font-size: 11.5px; color: var(--muted); text-align: center;
  user-select: none;
}

/* totals под таблицами */
.totals-row { display: flex; flex-wrap: wrap; gap: 10px 26px; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line-strong); font-size: 13px; }
.totals-row .t { color: var(--ink-soft); }
.totals-row .t b { font-variant-numeric: tabular-nums; }

/* сворачиваемый блок (предстоящие в расходах) */
details.collapsible > summary { list-style: none; cursor: pointer; margin-bottom: 0; }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary .summary-meta { font-size: 12px; color: var(--muted); font-weight: 600; }
details.collapsible > summary::after { content: "›"; margin-left: 6px; color: var(--muted); font-size: 18px; transition: transform .15s; }
details.collapsible[open] > summary::after { transform: rotate(90deg); }
details.collapsible[open] > summary { margin-bottom: 14px; }
details.collapsible > summary .summary-meta::after { content: " · показать"; }
details.collapsible[open] > summary .summary-meta::after { content: " · скрыть"; }
/* сворачиваемая часть ВНУТРИ блока (состав фонового расхода) */
.block > details.collapsible { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
/* сумма с приставкой «/день» — должна укладываться в одну строку целиком */
.stat .value.per-day { font-size: 16px; white-space: nowrap; }
.stat .value .per { font-size: 11px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.head-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.head-tools .btn-ghost { padding: 6px 12px; font-size: 12px; }

/* сворачиваемая секция на всю ширину вкладки (второй эшелон метрик в «Сводке») */
details.collapsible.wide {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px;
}
details.collapsible.wide > summary { font-weight: 700; font-size: 13px; color: var(--ink-soft); }
details.collapsible.wide[open] > summary { border-bottom: 1px solid var(--line); padding-bottom: 10px; }
details.collapsible.wide > .stat-cards,
details.collapsible.wide > .chart-grid,
details.collapsible.wide > .block { margin-top: 14px; }
details.collapsible.wide > .block { border: none; padding: 0; }

/* плотный набор карточек: второстепенные метрики и разбор расхода на ИИ */
.stat-cards.compact { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat-cards.compact .stat { padding: 12px 14px; }
.stat-cards.compact .value { font-size: 16px; }

/* ═══════════ напоминания ═══════════ */
.block.soft { background: var(--surface-2); }
.rem-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.rem-chip {
  display: flex; align-items: baseline; gap: 8px; padding: 9px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px;
}
.rem-chip.hot { border-color: var(--terra); background: rgba(192, 101, 59, .07); }
.rem-chip b { font-weight: 800; color: var(--ink); white-space: nowrap; }
.rem-chip span { color: var(--ink-soft); }
.rem-chip em { font-style: normal; font-weight: 700; color: var(--red); white-space: nowrap; }
.rem-chip em.pos { color: var(--green); }
.tbl tr.fresh td:first-child { box-shadow: inset 3px 0 0 var(--terra); }
.tbl td.rem-when { white-space: nowrap; width: 130px; }
/* переход к источнику события: ссылка в подписи вместо кнопки в каждой строке */
.link-act {
  background: none; border: none; padding: 0; cursor: pointer; font: inherit;
  color: var(--accent); border-bottom: 1px dashed currentColor;
}
.link-act:hover { color: var(--terra); }
.sub-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px;
  margin-left: 6px; padding: 0 5px; border-radius: 999px;
  background: var(--terra); color: #fff; font-size: 10.5px; font-weight: 800;
}

/* ═══════════ расход на ИИ ═══════════ */
.usage-click { cursor: pointer; }
.usage-click:hover { border-color: var(--accent); color: var(--ink); }
.usage-bars { display: flex; align-items: flex-end; gap: 6px; height: 130px; }
.ub-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  height: 100%; gap: 4px; }
.ub-col span { font-size: 9.5px; color: var(--muted); white-space: nowrap; }
.ub-fill { width: 100%; max-width: 28px; background: var(--accent); border-radius: 4px 4px 0 0;
  transition: background .15s; }
.ub-col:hover .ub-fill { background: var(--terra); }
.note-line { margin-top: 10px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.modal-box.wide { max-width: 760px; width: min(760px, 94vw); max-height: 88vh; overflow: auto; padding: 26px 28px; }
.modal-box.wide .block { margin-top: 14px; }
.modal-box.wide details.collapsible { margin-top: 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; }

/* ═══════════ календарь событий ═══════════ */
.cal-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-title { font-family: var(--font-display); font-weight: 800; font-size: 16px; min-width: 150px; text-transform: capitalize; }
.cal-legend { display: flex; gap: 14px; margin-left: auto; font-size: 12px; color: var(--ink-soft); align-items: center; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-grid.cal-head { margin-bottom: 6px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 4px 0; }
.cal-cell { min-height: 78px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 7px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; cursor: pointer; transition: border-color .12s, background .12s; }
.cal-cell.empty { background: transparent; border: none; cursor: default; }
.cal-cell.future { background: repeating-linear-gradient(135deg, transparent, transparent 7px, rgba(142,134,116,.06) 7px, rgba(142,134,116,.06) 14px); }
.cal-cell.has:hover { border-color: var(--ink-soft); }
.cal-cell.today { border-color: var(--terra); box-shadow: 0 0 0 1px var(--terra) inset; }
.cal-cell.sel { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.cal-cell.has { background-color: var(--surface-2); }
.cal-day { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.cal-cell.today .cal-day { color: var(--terra); }
.cal-net { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.cal-net.pos { color: var(--green); }
.cal-net.neg { color: var(--red); }
.cal-marks { font-size: 10.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 4px; }
.cal-bal { margin-top: auto; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-ev-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.cal-ev-dot.exp { background: var(--red); }
.cal-ev-dot.inc { background: var(--green); }
.cal-ev-dot.plan { background: var(--terra); }
.cal-panel { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.cal-panel-head { margin-bottom: 8px; font-size: 14px; }
.cal-panel .tbl { margin: 0; }

/* ═══════════ адаптив ═══════════ */

@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(380px, 36%) minmax(0,1fr); }
  .np-item span { display: none; }
  .np-item { justify-content: center; padding: 12px; }
}
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .np-item span { display: inline; }
  .np-item { flex: 1 1 auto; justify-content: center; }
  .sub-item { flex: 1 1 auto; text-align: center; }
  .chat-panel { height: 70vh; }
  .topnav { display: none; }
  .strip { grid-template-columns: 1fr; }
  .strip-item + .strip-item { border-left: none; border-top: 1px solid var(--line); }
  .steps { grid-template-columns: 1fr; }
  .step-arrow { transform: rotate(90deg); padding: 0; justify-self: start; margin-left: 10px; }
  .s-square { display: none; }
  .cal-cell { min-height: 58px; padding: 4px; }
  .cal-net { font-size: 12px; }
  .cal-bal { display: none; }
  .cal-legend { width: 100%; margin-left: 0; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}
