/* ============================================================================
   Сравнительная таблица 091 (svod091-compare.js, window.S91X; Жоогазын 23.11.2026, Izi.CRM #5131 п. 3.5–3.7):
   «Расчёт 091» → «Документы» в карточке и «Свод 091» → «Все документы». Цвета групп как в кабинете 2.0 (выписка — зелёная,
   ККМ — фиолетовая, ЭСФ — малиновая), что вошло в сумму 091 — тёмная цифра на фоне группы, остальное — серым для сверки.
   Шапка в 2 ряда липкая, таблица широкая — прокрутка внутри блока, первый столбец закреплён.
   ============================================================================ */
.s91x-card, .sv91 { --g-bank: #2f7a43; --g-bank-bg: #eaf6ee; --g-bank-soft: #f3faf5;
    --g-kkm: #5b4a9c; --g-kkm-bg: #efecf9; --g-kkm-soft: #f7f6fd;
    --g-esf: #a23e6b; --g-esf-bg: #fbecf3; --g-esf-soft: #fdf5f9;
    --g-sum: #f5f8ff; --g-sum-h: #eaf0fb; --s91x-ok: var(--success-color); --s91x-warn: #b45309; --s91x-err: var(--danger-color);
    --s91x-zero: #c3cad6; --s91x-err-bg: #fff4f3; }
body[data-theme="dark"] .s91x-card, body[data-theme="dark"] .sv91 { --g-bank: #6ccf8a; --g-bank-bg: rgba(52,211,153,.13); --g-bank-soft: rgba(52,211,153,.07);
    --g-kkm: #b3a4f0; --g-kkm-bg: rgba(167,139,250,.15); --g-kkm-soft: rgba(167,139,250,.07);
    --g-esf: #f08cb8; --g-esf-bg: rgba(244,114,182,.14); --g-esf-soft: rgba(244,114,182,.07);
    --g-sum: rgba(74,158,255,.07); --g-sum-h: rgba(74,158,255,.14); --s91x-warn: #fbbf24; --s91x-zero: #4b5563; --s91x-err-bg: rgba(248,113,113,.08); }

.s91x-card { display: flex; flex-direction: column; gap: 12px; }
.s91x-head { display: flex; align-items: flex-start; gap: 12px; }
.s91x-title { display: flex; align-items: flex-start; gap: 10px; min-width: 0; flex: 1; }
.s91x-title > svg { color: var(--primary-color); margin-top: 2px; }
.s91x-title b { display: block; font-size: 14.5px; color: var(--text-color); }
.s91x-title span { display: block; color: var(--text-muted); font-size: 12.5px; line-height: 1.45; margin-top: 2px; }

.s91x-scroll { overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border-light); border-radius: 12px; background: var(--card-bg); box-shadow: var(--shadow); max-height: 72vh; }
.s91x-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-color); }
.s91x-table--card { min-width: 1600px; table-layout: fixed; }
.s91x-table th { position: sticky; top: 0; z-index: 2; background: var(--surface-bg); color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: .02em;
    text-align: center; padding: 7px 6px; border-bottom: 1px solid var(--border-light); border-right: 1px solid var(--border-light); line-height: 1.2; vertical-align: middle; }
.s91x-table th:last-child, .s91x-table td:last-child { border-right: none; }
.s91x-table thead th > span { display: block; font-weight: 600; color: var(--text-secondary); text-transform: none; }
.s91x-table tr.s91x-sh th { top: var(--s91x-h1, 30px); font-weight: 650; font-size: 11px; }
body[data-theme="dark"] .s91x-table th { background: #18212f; }
.s91x-table td { padding: 6px 7px; border-bottom: 1px solid var(--border-light); border-right: 1px solid var(--border-light); vertical-align: middle; background: var(--card-bg); }
.s91x-table tbody tr:last-child td { border-bottom: none; }
/* группы */
.s91x-table th.s91x-g[onclick] { cursor: pointer; }
.s91x-table th.s91x-g[onclick]:hover { text-decoration: underline; }
.s91x-table th.g-bank { background: var(--g-bank-bg); color: var(--g-bank); }
.s91x-table th.g-kkm { background: var(--g-kkm-bg); color: var(--g-kkm); }
.s91x-table th.g-esf { background: var(--g-esf-bg); color: var(--g-esf); }
.s91x-table th.s91x-mh.g-bank { background: var(--g-bank-soft); }
.s91x-table th.s91x-mh.g-kkm { background: var(--g-kkm-soft); }
.s91x-table th.s91x-mh.g-esf { background: var(--g-esf-soft); }
.s91x-table th.s91x-gsum { background: var(--g-sum-h); color: var(--primary-color); }
.s91x-table th.s91x-gsum svg { vertical-align: -2px; margin-right: 2px; }
/* ширины столбцов карточки: до «Статуса 091» помещается в экран 1440 px, правые колонки — прокруткой */
.s91x-table--card th.s91x-pr { width: 104px; }
.s91x-table--card th.s91x-pl { width: 70px; }
.s91x-table--card th.s91x-me { width: 48px; }
.s91x-table--card th.s91x-per { width: 86px; }
.s91x-table--card th.s91x-mh { width: 88px; }
.s91x-table--card th.s91x-mh.s91x-gsum { width: 106px; }
.s91x-table--card th.s91x-st { width: 160px; }
.s91x-table--card th.s91x-r { width: 140px; }
.s91x-table--card th.s91x-cf { width: 140px; }
.s91x-table--card th.s91x-sb { width: 118px; }
.s91x-table th.s91x-g { white-space: nowrap; }
.s91x-table th.s91x-g svg { vertical-align: -2px; }
/* первый столбец закреплён при прокрутке вбок */
.s91x-table--card th.s91x-pr, .s91x-table--card td.s91x-pr { position: sticky; left: 0; z-index: 3; }
.s91x-table--card td.s91x-pr { z-index: 1; text-align: left; }
.s91x-pr b { display: block; font-size: 13px; }
.s91x-pr span { display: block; font-size: 11px; color: var(--text-muted); font-weight: 500; }
.s91x-qrow td { background: var(--surface-bg); border-top: 1px solid var(--border-color); }
body[data-theme="dark"] .s91x-qrow td { background: #18212f; }

/* цифры документов */
.s91x-c { text-align: right; cursor: pointer; white-space: nowrap; transition: background .1s; }
.s91x-c .s91x-v { display: block; font-size: 12.5px; line-height: 1.3; }
.s91x-c.ctl .s91x-v { color: var(--text-muted); font-weight: 500; }
.s91x-c.use .s91x-v { color: var(--text-color); font-weight: 750; }
td.s91x-c.use.g-bank { background: var(--g-bank-soft); }
td.s91x-c.use.g-kkm { background: var(--g-kkm-soft); }
td.s91x-c.use.g-esf { background: var(--g-esf-soft); }
.s91x-c.unpaid .s91x-v { color: var(--s91x-err); font-weight: 700; }
td.s91x-c.st-err { background: var(--s91x-err-bg); }
.s91x-c.st-wait .s91x-v { color: var(--text-muted); }
td.s91x-c:hover, td.s91x-sum:hover, td.s91x-st.click:hover { background: var(--hover-bg); }
.s91x-sub { display: block; font-size: 10.5px; color: var(--text-muted); font-weight: 600; margin-top: 1px; }
.s91x-sub.warn { color: var(--s91x-err); }
.s91x-span, .s91x-modec { text-align: center !important; }
.s91x-cin { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.s91x-mode { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 7px; background: var(--hover-bg); color: var(--text-muted); font-size: 11px; font-weight: 650; white-space: nowrap; }
.s91x-0 { color: var(--s91x-zero); font-weight: 400; }
.s91x-na { font-size: 11px; color: var(--text-secondary); }
.s91x-np { display: inline-block; padding: 1px 7px; border-radius: 6px; background: rgba(217,48,37,.1); color: var(--s91x-err); font-size: 11px; font-weight: 800; }
.s91x-dn { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--hover-bg); color: var(--text-muted); font-size: 11px; font-weight: 800; }
/* сумма 091 */
.s91x-sum { text-align: right; cursor: pointer; white-space: nowrap; background: var(--g-sum) !important; }
.s91x-sum .s91x-v { display: block; font-weight: 800; font-size: 13px; color: var(--text-color); line-height: 1.3; }
.s91x-sum .s91x-tax { display: block; margin-top: 1px; font-size: 11px; font-weight: 650; color: var(--primary-color); }
.s91x-gap { display: inline-flex; margin-left: 3px; color: var(--s91x-warn); vertical-align: -1px; }
.s91x-unal { display: block; margin-top: 1px; font-size: 10.5px; font-weight: 700; color: var(--s91x-warn); }
/* район, метод, периодичность */
.s91x-pl { white-space: nowrap; overflow: hidden; text-align: left; cursor: help; }
.s91x-pl-d { font-size: 12px; line-height: 1.3; }
.s91x-pl-d b { font-weight: 750; }
.s91x-pl-d b.off { color: var(--text-secondary); font-weight: 600; text-decoration: line-through; }
.s91x-pl-d i, .s91x-pl-a i { font-style: normal; color: var(--text-secondary); margin: 0 2px; }
.s91x-pl-a { font-size: 11px; line-height: 1.3; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.s91x-pl-a .off { color: var(--text-secondary); }
.s91x-me { text-align: center; }
.s91x-mk { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 7px; font-size: 12px; font-weight: 800; cursor: help; }
.s91x-mk.k { background: var(--g-bank-bg); color: var(--g-bank); }
.s91x-mk.n { background: var(--g-esf-bg); color: var(--g-esf); }
.s91x-per { cursor: help; text-align: center; }
.s91x-per span { display: block; font-size: 11.5px; color: var(--text-color); font-weight: 600; }
.s91x-per small { display: block; margin-top: 1px; font-size: 11px; color: var(--text-muted); white-space: nowrap; }
/* статус 091 */
.s91x-st { line-height: 1.3; text-align: left; }
.s91x-st.click { cursor: pointer; }
.s91x-st1 { font-size: 11.5px; font-weight: 750; }
.s91x-st-tax { font-size: 11px; color: var(--text-muted); }
.s91x-st2 { font-size: 11px; font-weight: 650; margin-top: 1px; }
.s91x-st1.ok, .s91x-st2.ok { color: var(--s91x-ok); }
.s91x-st1.warn, .s91x-st2.warn { color: var(--s91x-warn); }
.s91x-st1.err, .s91x-st2.err { color: var(--s91x-err); }
.s91x-st1.mute, .s91x-st2.mute { color: var(--text-muted); }
.s91x-inq { font-size: 11px; color: var(--text-secondary); }
/* 091 первоначальный / уточнённый */
.s91x-r { text-align: left; }
.s91x-u { display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap; font-size: 11.5px; line-height: 1.35; cursor: help; }
.s91x-u + .s91x-u { margin-top: 3px; }
.s91x-u-l { min-width: 26px; color: var(--text-muted); font-weight: 600; }
.s91x-u-t { font-weight: 750; }
.s91x-u.st-ok .s91x-u-t { color: var(--s91x-ok); }
.s91x-u.st-err .s91x-u-t { color: var(--s91x-err); }
.s91x-u.st-soon .s91x-u-t, .s91x-u.st-due .s91x-u-t { color: var(--s91x-warn); }
.s91x-u.st-wait .s91x-u-t, .s91x-u.st-dn .s91x-u-t, .s91x-u.st-na .s91x-u-t { color: var(--text-muted); }
.s91x-u-s { margin-left: auto; color: var(--text-color); }
.s91x-u-c { flex-basis: 100%; padding-left: 31px; font-size: 10.5px; color: var(--s91x-warn); font-weight: 650; }
/* подтверждение */
.s91x-cf { text-align: left; vertical-align: top !important; }
.s91x-cfs { display: flex; flex-direction: column; gap: 4px; }
.s91x-cf-l { display: flex; align-items: center; gap: 6px; font-size: 11.5px; }
.s91x-cf-k { min-width: 42px; color: var(--text-muted); font-weight: 600; }
.s91x-cfc { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; white-space: nowrap; }
.s91x-cfc.st-ok { color: var(--s91x-ok); }
.s91x-cfc.st-na { color: var(--text-muted); font-weight: 500; }
.s91x-cfc.st-none { color: var(--s91x-zero); }
.s91x-cfb { margin-left: auto; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border-light); background: var(--card-bg);
    color: var(--text-muted); cursor: pointer; padding: 0; transition: var(--transition); }
.s91x-cfb:hover { color: var(--primary-color); border-color: var(--primary-color); background: var(--primary-light); }
.s91x-cfb:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 1px; }
.s91x-cf-q { font-size: 10.5px; color: var(--text-secondary); margin-top: 1px; }
/* сдать 091 */
.s91x-sb { text-align: left; }
.s91x-sbl { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; line-height: 1.35; white-space: nowrap; }
.s91x-sbl + .s91x-sbl { margin-top: 3px; }
.s91x-sbl i { font-style: normal; font-weight: 500; color: var(--text-muted); }
.s91x-sbl.st-ok { color: var(--s91x-ok); }
.s91x-sbl.st-wait { color: var(--s91x-warn); }
.s91x-sbl.st-dn { color: var(--text-muted); }
.s91x-sbb { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 7px; background: var(--primary-color); color: #fff !important; text-decoration: none; font-size: 11.5px; font-weight: 700; }
.s91x-sbb:hover { filter: brightness(1.08); }
.s91x-sbb.err { background: var(--danger-color); }
/* легенда */
.s91x-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: 11.5px; color: var(--text-muted); padding: 2px 2px 0; }
.s91x-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.s91x-lg { display: inline-block; width: 22px; height: 14px; border-radius: 4px; border: 1px solid var(--border-light); }
.s91x-lg.use { background: linear-gradient(90deg, var(--g-bank-soft) 0 33%, var(--g-kkm-soft) 33% 66%, var(--g-esf-soft) 66%); border-color: var(--border-color); }
.s91x-lg.ctl { background: var(--card-bg); }
.s91x-lg.err { background: var(--s91x-err-bg); border-color: rgba(217,48,37,.25); }
.s91x-lg-unpaid { color: var(--s91x-err); font-weight: 700; }
.s91x-legend .s91x-unal { display: inline; margin: 0; }
.s91x-lg-hint { flex-basis: 100%; color: var(--text-secondary); }
.s91x-lg-hint svg { vertical-align: -2px; }
/* пустое состояние и каркас */
.s91x-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 34px 18px; text-align: center; color: var(--text-muted);
    background: var(--card-bg); border: 1px solid var(--border-light); border-radius: 12px; }
.s91x-empty > svg { color: var(--text-secondary); }
.s91x-empty b { color: var(--text-color); font-size: 14px; }
.s91x-empty span { font-size: 12.5px; max-width: 520px; line-height: 1.45; }
.s91x-skel { display: flex; flex-direction: column; gap: 8px; }
.s91x-skel i { display: block; height: 42px; border-radius: 10px; background: linear-gradient(90deg, var(--hover-bg) 0%, var(--surface-bg) 50%, var(--hover-bg) 100%); background-size: 200% 100%; animation: s91xShim 1.3s infinite linear; }
.s91x-skel i:first-child { height: 64px; }
@keyframes s91xShim { from { background-position: 200% 0; } to { background-position: -200% 0; } }
/* подсветка строки «Сумм для сдачи 091» после клика по сумме */
@keyframes s91xFlash { 0%, 40% { box-shadow: inset 0 0 0 2px var(--primary-color); } 100% { box-shadow: inset 0 0 0 2px transparent; } }
.s91x-flash, .s91x-flash td { animation: s91xFlash 1.8s ease-out 1; }
.c91-back { height: 26px; margin-right: 10px; font-size: 12px; }

.s91x-meta { display: none; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.s91x-meta i { font-style: normal; font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 7px; background: var(--hover-bg); color: var(--text-color); }
.s91x-lg-unpaid { white-space: nowrap; }

@media (max-width: 640px) {
    .s91x-head { flex-wrap: wrap; }
    .s91x-meta { display: flex; }
    .s91x-scroll { max-height: none; border-radius: 10px; }
    .s91x-table--card { min-width: 1290px; }
    .s91x-table--card th.s91x-pr { width: 92px; }
    .s91x-table--card .s91x-pl, .s91x-table--card .s91x-me, .s91x-table--card .s91x-per { display: none; }
    .s91x-legend { font-size: 11px; gap: 6px 12px; }
}

/* ── «Свод 091» → «Все документы» (svod091-lk.js renderCmpTable): та же таблица по всем клиентам, оформление строк — свода ── */
#svod091Tab .sv91-cmp { min-width: 1880px; }
#svod091Tab .sv91-cmp th.s91x-pl, #svod091Tab .sv91-cmp th.s91x-me, #svod091Tab .sv91-cmp th.s91x-per, #svod091Tab .sv91-cmp th.s91x-st { text-transform: none; letter-spacing: 0; font-size: 11px; line-height: 1.2; white-space: normal; }
#svod091Tab .sv91-cmp thead th > span { display: block; font-weight: 500; color: var(--sv-ink4); }
#svod091Tab .sv91-cmp th.s91x-gsum { background: linear-gradient(var(--g-sum-h), var(--g-sum-h)), var(--sv-card); color: var(--primary-color); }
#svod091Tab .sv91-cmp th.sv91-g.s91x-gsum { border-bottom-color: var(--primary-color); }
#svod091Tab .sv91-cmp th.s91x-gsum svg { vertical-align: -2px; margin-right: 2px; }
#svod091Tab .sv91-cmp tr.sv91-mh th { white-space: normal; line-height: 1.15; }
#svod091Tab .sv91-cmp td.s91x-c, #svod091Tab .sv91-cmp td.s91x-sum { padding: 5px 7px 5px 4px; }
#svod091Tab .sv91-cmp td.s91x-pl, #svod091Tab .sv91-cmp td.s91x-st { padding: 4px 6px; }
#svod091Tab .sv91-cmp .gs { border-left: 1px solid var(--sv-bdr-soft); }
.sv91-cmp-wait { padding: 6px 10px !important; }
.sv91-cmp-sk { display: flex; gap: 10px; }
.sv91-cmp-sk i { flex: 1; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--hover-bg) 0%, var(--surface-bg) 50%, var(--hover-bg) 100%); background-size: 200% 100%; animation: s91xShim 1.3s infinite linear; }
.sv91-cmp-na { color: var(--text-muted); font-size: 12px; }
.sv91-cmp-na svg { vertical-align: -2px; margin-right: 4px; }
#svod091Tab .sv91-cmp tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--sv-card); border-top: 1px solid var(--sv-bdr); font-weight: 700; }
#svod091Tab .sv91-cmp tfoot td.s91x-sum { background: linear-gradient(var(--g-sum), var(--g-sum)), var(--sv-card) !important; }
#svod091Tab .sv91-cmp tfoot td.sv91-org, #svod091Tab .sv91-cmp tfoot td.sv91-ck { z-index: 3; }
.sv91-cmp-foot-r { text-align: right; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.sv91-cmp-foot-r b { color: var(--text-color); }
.sv91-legend-x { margin-top: 10px; }
#svod091Tab .sv91-back { white-space: nowrap; }
/* «Свод 091» на телефоне: квартал, месяц и год переносятся, страница не шире экрана (п. 3.5 — добавилась выпадашка месяца) */
@media (max-width: 640px) {
    #svod091Tab .sv91-period { flex-wrap: wrap; }
    #svod091Tab .sv91-period .sv91-select { flex: 1 1 120px; min-width: 0; }
}
