/* ==========================================================================
   Финансы — редизайн: верхний блок (Краткий вывод + чарт) и секция
   «Компания на фоне ниши» (данные /api/v1/stats). Классы с префиксом fnsx-,
   чтобы не пересекаться с остальным report_stub.html. Токены — scg_tokens.css.
   ========================================================================== */

.fnsx-root .fnsx-up   { color: var(--status-success); }
.fnsx-root .fnsx-down { color: var(--status-warning); }
.fnsx-root .fnsx-bad  { color: var(--status-danger); }

/* ---- верхний ряд: краткий вывод + чарт ---- */
.fnsx-midrow { display: grid; grid-template-columns: 1fr 1.3fr; gap: 20px; align-items: stretch; }
.fnsx-summary { background: linear-gradient(180deg,#F1F1FA,#F7F7FC); border: 1px solid var(--ink-100); border-radius: var(--radius-lg); padding: 28px 30px; display: flex; flex-direction: column; }
.fnsx-summary h3 { font-size: 18px; font-weight: 600; margin: 0 0 12px; letter-spacing: -.01em; color: var(--fg-1); }
.fnsx-summary p { font-size: 15px; line-height: 1.65; color: var(--fg-2); margin: 0; }
.fnsx-kpis { display: flex; gap: 30px; margin-top: auto; padding-top: 22px; flex-wrap: wrap; }
.fnsx-kpis .fnsx-k .fnsx-v { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.fnsx-kpis .fnsx-k .fnsx-l { font-size: 13px; color: var(--fg-3); margin-top: 3px; max-width: 22ch; }

.fnsx-chart { background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius-lg); padding: 22px 26px 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.fnsx-chart .fnsx-ch-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.fnsx-chart .fnsx-ch-head h3 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -.01em; color: var(--fg-1); }
.fnsx-chart .fnsx-ch-head .fnsx-unit { font-size: 12px; color: var(--fg-3); margin-top: 3px; }
.fnsx-legend { display: flex; flex-direction: column; gap: 6px; }
.fnsx-legend .fnsx-li { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--fg-2); white-space: nowrap; }
.fnsx-legend .fnsx-sw { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.fnsx-legend .fnsx-sw.fnsx-line { height: 0; border-top: 2px dashed var(--scg-cyan); width: 16px; border-radius: 0; }

/* ============ секция: компания vs ниша ============ */
.fnsx-niche-sec { margin-top: 40px; padding-top: 34px; border-top: 1px solid var(--ink-300); }
/* general-режим (ИП/без БФО): секция идёт первой, верхняя линия не нужна */
.fnsx-niche-sec.fnsx-general { margin-top: 0; padding-top: 4px; border-top: none; }
.fnsx-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--scg-magenta-700); margin: 0 0 8px; }
.fnsx-niche-sec h2 { font-size: 24px; font-weight: 500; letter-spacing: -.01em; margin: 0 0 12px; color: var(--fg-1); }
.fnsx-lede { font-size: 15px; line-height: 1.65; color: var(--fg-2); margin: 0 0 14px; max-width: 92ch; }
.fnsx-meta { font-size: 13px; color: var(--fg-3); margin: 0 0 24px; }
.fnsx-meta b { color: var(--fg-2); font-weight: 500; }

/* вердикт */
.fnsx-verdict { display: flex; gap: 16px; background: var(--scg-navy); color: #fff; border-radius: var(--radius-lg); padding: 24px 28px; margin-bottom: 26px; }
.fnsx-verdict .fnsx-vi { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; background: rgba(115,215,238,.16); display: grid; place-items: center; }
.fnsx-verdict .fnsx-vi svg { color: var(--scg-cyan); }
.fnsx-verdict .fnsx-vt { font-family: var(--font-serif); font-size: 18px; line-height: 1.55; font-weight: 400; }
.fnsx-verdict .fnsx-vt b { font-weight: 700; color: var(--scg-cyan); font-family: var(--font-sans); }

/* подзаголовок */
.fnsx-subh { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-3); margin: 30px 0 14px; }

/* ---- полосы-перцентили (lanes) ---- */
.fnsx-lanes { display: flex; flex-direction: column; gap: 14px; }
.fnsx-lane { display: flex; gap: 34px; align-items: center; background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius-lg); padding: 26px 32px; box-shadow: var(--shadow-sm); }
.fnsx-lane-head { flex: 0 0 232px; }
.fnsx-lane-head .fnsx-eb { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--fg-3); margin-bottom: 8px; }
.fnsx-lane-head .fnsx-val { font-size: 28px; font-weight: 600; letter-spacing: -.02em; color: var(--scg-navy); }
.fnsx-vpill { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; font-weight: 600; padding: 6px 13px; border-radius: var(--radius-pill); }
.fnsx-vpill.fnsx-up { color: var(--status-success); background: rgba(14,159,110,.1); }
.fnsx-vpill.fnsx-down { color: var(--status-warning); background: rgba(224,164,59,.15); }
.fnsx-lane-plot { flex: 1; min-width: 0; }

/* split bar */
.fnsx-splitbar { position: relative; padding-top: 54px; }
.fnsx-sb-track { position: relative; height: 16px; border-radius: 8px; background: var(--ink-100); overflow: visible; }
.fnsx-sb-fill { position: absolute; top: 0; bottom: 0; left: 0; width: var(--split); background: var(--scg-navy); border-radius: 8px 0 0 8px; }
.fnsx-sb-marker { position: absolute; top: 0; left: var(--split); width: 0; }
.fnsx-sb-pin { position: absolute; top: -5px; left: -13px; width: 26px; height: 26px; border-radius: 50%; background: var(--scg-cyan); border: 4px solid var(--white); box-shadow: var(--shadow-md); }
.fnsx-sb-me { position: absolute; top: 24px; left: 0; transform: translateX(-50%); font-size: 12px; font-weight: 700; color: var(--scg-navy); white-space: nowrap; }
.fnsx-sb-brace { position: absolute; top: 26px; height: 12px; border-top: 1.5px solid var(--ink-300); }
.fnsx-sb-brace::before, .fnsx-sb-brace::after { content: ""; position: absolute; top: 0; width: 1.5px; height: 7px; background: var(--ink-300); }
.fnsx-sb-brace::before { left: 0; } .fnsx-sb-brace::after { right: 0; }
.fnsx-sb-brace.fnsx-below { left: 0; width: var(--split); }
.fnsx-sb-brace.fnsx-above { left: var(--split); right: 0; }
.fnsx-sb-cap { position: absolute; top: -20px; white-space: nowrap; font-size: 12px; color: var(--fg-3); }
.fnsx-sb-brace.fnsx-below .fnsx-sb-cap { left: 0; }
.fnsx-sb-brace.fnsx-above .fnsx-sb-cap { right: 0; }
.fnsx-sb-cap b { color: var(--fg-1); font-weight: 600; }
.fnsx-sb-ends { display: flex; justify-content: space-between; margin-top: 26px; font-size: 12px; color: var(--fg-4); }

.fnsx-explore { display: inline-flex; align-items: center; gap: 8px; margin-top: 20px; font-size: 13.5px; font-weight: 600; color: var(--scg-navy); background: transparent; border: 1px solid var(--ink-300); border-radius: var(--radius-md); padding: 9px 16px; cursor: pointer; }
.fnsx-explore:hover { background: var(--ink-50); border-color: var(--scg-navy); }

/* ---- сравнение с медианой ---- */
.fnsx-median-note { font-size: 13px; line-height: 1.55; color: var(--fg-3); margin: -6px 0 18px; max-width: 88ch; }
.fnsx-cmp { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.fnsx-cgroup { grid-column: 1/-1; padding-top: 6px; border-top: 1px solid var(--ink-200); }
.fnsx-crow { background: var(--ink-50); border: 1px solid var(--ink-100); border-radius: var(--radius-md); padding: 18px 20px; }
.fnsx-crow .fnsx-cl { font-size: 13px; color: var(--fg-3); margin-bottom: 12px; }
.fnsx-crow .fnsx-cv { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.fnsx-crow .fnsx-you { font-size: 26px; font-weight: 600; letter-spacing: -.02em; color: var(--scg-navy); white-space: nowrap; }
.fnsx-crow .fnsx-med { font-size: 13.5px; color: var(--fg-3); }
.fnsx-crow .fnsx-cd { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--ink-100); }
.fnsx-crow .fnsx-cd.fnsx-up { color: var(--status-success); }
.fnsx-crow .fnsx-cd.fnsx-down { color: var(--status-warning); }

/* ---- структура рынка ---- */
.fnsx-panel { background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius-lg); padding: 22px 26px; box-shadow: var(--shadow-sm); }
.fnsx-mkt-lead { font-size: 14px; line-height: 1.6; color: var(--fg-2); margin: 0 0 20px; max-width: 92ch; }
.fnsx-mkt-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 32px; align-items: start; }
.fnsx-barwrap { margin: 2px 0 14px; }
.fnsx-barlab { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--fg-3); margin-bottom: 7px; }
.fnsx-bar { display: flex; height: 34px; border-radius: var(--radius-sm); overflow: hidden; background: var(--ink-100); }
.fnsx-bar .fnsx-top10 { background: var(--scg-navy); display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 600; min-width: 34px; }
.fnsx-bar .fnsx-rest { flex: 1; display: grid; place-items: center; color: var(--fg-3); font-size: 12px; text-align: center; padding: 0 8px; }
.fnsx-mverdict { display: inline-flex; align-items: flex-start; gap: 8px; font-size: 13px; font-weight: 600; color: var(--scg-navy); background: var(--ink-100); padding: 8px 14px; border-radius: var(--radius-md); }
.fnsx-mverdict .fnsx-d { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--scg-navy); margin-top: 5px; }
.fnsx-mstats { display: flex; flex-direction: column; gap: 18px; }
.fnsx-mstats .fnsx-ms .fnsx-msv { font-size: 22px; font-weight: 600; letter-spacing: -.01em; color: var(--scg-navy); }
.fnsx-mstats .fnsx-ms .fnsx-msl { font-size: 12px; color: var(--fg-3); margin-top: 2px; }
.fnsx-mstats .fnsx-ms .fnsx-msn { font-size: 12.5px; color: var(--fg-3); line-height: 1.5; margin-top: 3px; }

.fnsx-footnote { font-size: 12px; color: var(--fg-4); margin-top: 26px; line-height: 1.5; }

/* ---- заметка в блоке рынка: два среза роста (ФНС vs рынок) ---- */
.market-fns-note { background: var(--ink-50); border: 1px solid var(--ink-100); border-radius: var(--radius-md); padding: 16px 20px; margin: 0 0 20px; }
.market-fns-note.hidden { display: none; }
.market-fns-note-text { font-size: 14px; line-height: 1.6; color: var(--fg-2); margin: 0 0 12px; }
.market-cmp-table-wrap { overflow-x: auto; }
.market-cmp-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 540px; }
.market-cmp-table th, .market-cmp-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--ink-100); vertical-align: top; color: var(--fg-2); }
.market-cmp-table thead th { color: var(--fg-1); font-weight: 600; border-bottom: 2px solid var(--ink-200); }
.market-cmp-table tbody td:first-child { color: var(--fg-3); font-weight: 600; white-space: nowrap; }

/* ---- модалка ниши ---- */
.fnsx-modal-scrim { position: fixed; inset: 0; background: rgba(18,16,84,.42); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; padding: 32px; z-index: 1000; }
.fnsx-modal-scrim.fnsx-open { display: flex; }
.fnsx-modal { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-width: 720px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 34px 38px 38px; }
.fnsx-modal .fnsx-mh { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 8px; }
.fnsx-modal h3 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin: 0; color: var(--fg-1); }
.fnsx-modal .fnsx-close { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--ink-200); background: var(--white); color: var(--fg-2); cursor: pointer; display: grid; place-items: center; }
.fnsx-modal .fnsx-close:hover { border-color: var(--ink-300); }
.fnsx-modal .fnsx-lead { font-size: 14.5px; line-height: 1.65; color: var(--fg-2); margin: 0 0 24px; }
.fnsx-modal h4 { font-size: 15px; font-weight: 700; margin: 26px 0 10px; color: var(--fg-1); }
.fnsx-modal p { font-size: 14px; line-height: 1.65; color: var(--fg-2); margin: 0 0 12px; }
.fnsx-modal .fnsx-def { background: var(--ink-50); border: 1px solid var(--ink-100); border-radius: var(--radius-md); padding: 16px 20px; margin: 0 0 8px; }
.fnsx-modal .fnsx-def b { color: var(--fg-1); }

/* распределение в модалке — на подложке (карточка) */
.fnsx-pscale { background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius-lg); padding: 24px 26px 20px; box-shadow: var(--shadow-sm); margin-bottom: 26px; }
.fnsx-trow { display: flex; align-items: flex-start; }
.fnsx-trow .fnsx-glab { flex: 0 0 110px; box-sizing: border-box; text-align: right; padding-right: 16px; font-size: 12px; line-height: 1.3; color: var(--fg-3); font-weight: 500; }
.fnsx-trow .fnsx-tka { position: relative; flex: 1; min-width: 0; }
.fnsx-trow.fnsx-track { padding-top: 34px; align-items: center; }
.fnsx-ps-track { position: relative; height: 12px; border-radius: 6px; background: var(--ink-100); margin: 0 6px; }
.fnsx-ps-corridor { position: absolute; top: 0; bottom: 0; left: 25%; right: 25%; background: rgba(18,16,84,.12); border-radius: 6px; }
.fnsx-ps-median { position: absolute; top: -6px; bottom: -6px; left: 50%; width: 2px; background: var(--scg-navy); opacity: .45; transform: translateX(-1px); }
.fnsx-ps-marker { position: absolute; top: 6px; width: 0; }
.fnsx-ps-pin { position: absolute; top: -9px; left: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--scg-navy); border: 3px solid var(--white); box-shadow: var(--shadow-sm); }
.fnsx-ps-flag { position: absolute; bottom: 16px; left: 0; transform: translateX(-50%); background: var(--scg-navy); color: #fff; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: var(--radius-pill); white-space: nowrap; }
.fnsx-trow.fnsx-vals { margin-top: 16px; }
.fnsx-trow.fnsx-vals .fnsx-tka { height: 18px; }
.fnsx-trow.fnsx-vals .fnsx-tk { font-size: 13.5px; font-weight: 600; color: var(--fg-1); }
.fnsx-trow.fnsx-pcts { margin-top: 8px; }
.fnsx-trow.fnsx-pcts .fnsx-tka { height: 16px; }
.fnsx-trow.fnsx-pcts .fnsx-tk { font-size: 12px; color: var(--fg-4); }
.fnsx-trow .fnsx-tk { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.fnsx-trow .fnsx-tk.fnsx-med { color: var(--scg-navy); font-weight: 700; }

@media (max-width: 860px) {
  .fnsx-midrow, .fnsx-cmp, .fnsx-mkt-grid { grid-template-columns: 1fr; }
  .fnsx-lane { flex-direction: column; align-items: stretch; gap: 20px; }
  .fnsx-lane-head { flex-basis: auto; }
}

/* Модалка распределения на мобилке: подписи 10/25/50/75/90 налезают при
   абсолютном позиционировании — раскладываем в равномерную flex-строку. */
@media (max-width: 640px) {
  .fnsx-modal { padding: 24px 16px 26px; }
  .fnsx-pscale { padding: 16px 10px 14px; }
  .fnsx-trow .fnsx-glab { display: none; }
  .fnsx-trow.fnsx-vals .fnsx-tka,
  .fnsx-trow.fnsx-pcts .fnsx-tka { display: flex; justify-content: space-between; gap: 4px; height: auto; }
  .fnsx-trow.fnsx-vals .fnsx-tk,
  .fnsx-trow.fnsx-pcts .fnsx-tk { position: static; transform: none; white-space: normal;
    text-align: center; line-height: 1.2; flex: 1 1 0; min-width: 0; }
  .fnsx-trow.fnsx-vals .fnsx-tk { font-size: 12px; font-weight: 600; }
  .fnsx-trow.fnsx-pcts .fnsx-tk { font-size: 10.5px; }
}
