:root {
  --app-primary: #1f4e79;
  --bs-link-color: #0a58ca; --bs-link-color-rgb: 10, 88, 202; --bs-link-hover-color: #084298;
  --sidebar-w: 240px;
  --bottom-nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}
html { -webkit-text-size-adjust: 100%; }
body { background: #f4f6f9; padding-top: var(--safe-top); }
a { text-decoration: none; }
.text-pdz { color: var(--app-primary); }
.btn-pdz { --bs-btn-color: #fff; --bs-btn-bg: var(--app-primary); --bs-btn-border-color: var(--app-primary);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--app-primary); --bs-btn-hover-border-color: var(--app-primary);
  --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--app-primary); --bs-btn-active-border-color: var(--app-primary);
  --bs-btn-disabled-color: #fff; --bs-btn-disabled-bg: var(--app-primary); --bs-btn-focus-shadow-rgb: 31, 78, 121; }
.btn-pdz:hover { filter: brightness(1.15); }
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 2000; }
.skip-link:focus { left: 8px; top: 8px; background: #fff; padding: 6px 10px; }

/* ---------- Каркас ---------- */
.app-topbar { background: var(--app-primary); color: #fff; position: sticky; top: 0; z-index: 1030;
  min-height: 56px; padding-left: env(titlebar-area-x, 0); }
.app-topbar a, .app-topbar .btn-link { color: #fff; }
.app-topbar .brand img { height: 32px; width: 32px; border-radius: 6px; background: #fff; }
.app-sidebar { display: none; }
.app-main { padding: 12px 12px calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px); }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030; background: #fff;
  border-top: 1px solid #dee2e6; display: flex; padding-bottom: var(--safe-bottom); height: calc(var(--bottom-nav-h) + var(--safe-bottom)); }
.bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #495057; font-size: .75rem; border: 0; background: none; min-height: 48px; }
.bottom-nav a.active { color: var(--app-primary); font-weight: 600; }
.bottom-nav i { font-size: 1.35rem; }
.titlebar-drag { -webkit-app-region: drag; app-region: drag; }
.titlebar-drag a, .titlebar-drag button, .titlebar-drag form, .titlebar-drag input { -webkit-app-region: no-drag; app-region: no-drag; }

@media (min-width: 1024px) {
  .app-sidebar { display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w);
    background: #15324f; color: #cfd8e3; z-index: 1040; overflow-y: auto; }
  .app-sidebar .nav-link { color: #cfd8e3; border-radius: 8px; margin: 1px 8px; padding: 8px 12px; }
  .app-sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
  .app-sidebar .nav-link.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
  .app-sidebar .brand { padding: 14px 16px; color: #fff; font-weight: 700; display: flex; gap: 10px; align-items: center; }
  .app-sidebar .brand img { height: 36px; width: 36px; border-radius: 8px; background: #fff; }
  .app-sidebar .sidebar-caption { color: #b8c4d2; }
  .app-topbar, .app-main { margin-left: var(--sidebar-w); }
  .app-topbar .brand { display: none !important; }
  .app-main { padding: 20px 24px 32px; }
  .bottom-nav { display: none; }
  .mobile-only { display: none !important; }
}
@media (max-width: 1023.98px) { .desktop-only { display: none !important; } }

/* Таблицы с закреплённой шапкой */
.table-sticky { max-height: 70vh; overflow: auto; }
.table-sticky thead th { position: sticky; top: 0; background: #f8f9fa; z-index: 2; box-shadow: inset 0 -1px 0 #dee2e6; }
.table td, .table th { vertical-align: middle; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-hidden { display: none !important; }

/* Карточки вместо таблиц на телефоне */
.cards-mobile { display: none; }
@media (max-width: 767.98px) {
  .table-desktop { display: none; }
  .cards-mobile { display: block; }
  .btn-touch { min-height: 44px; min-width: 44px; }
  h1, .h1 { font-size: 1.4rem; }
}
.client-card { border-left: 4px solid #adb5bd; }
.client-card.lvl-danger { border-left-color: #dc3545; }
.client-card.lvl-warning { border-left-color: #fd7e14; }
.client-card.lvl-info { border-left-color: #0dcaf0; }
.client-card.lvl-success { border-left-color: #198754; }

/* KPI и план */
.kpi { border: 0; border-radius: 14px; }
.kpi .kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; overflow-wrap: normal; word-break: normal; }
.kpi-xl .kpi-value { font-size: 2.3rem; }
.plan-block .list-group-item { padding: .55rem .75rem; }
.plan-block .card-header { font-weight: 600; }
.quick-actions .btn { padding: .3rem .55rem; }
.badge-new { background: #ffc107; color: #000; }
.chart-box { position: relative; height: 300px; }
.chart-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .chart-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1600px) { .chart-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }
.fullscreen-target:fullscreen { background: #f4f6f9; overflow: auto; padding: 24px; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: #dee2e6; }
.timeline-item { position: relative; margin-bottom: 14px; }
.timeline-item::before { content: ""; position: absolute; left: -19px; top: 6px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--app-primary); border: 2px solid #fff; }
.timeline-item.no-contact::before { background: #adb5bd; }

#install-btn[hidden] { display: none !important; }
.toast-container { z-index: 2000; bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 8px) !important; }
@media (min-width: 1024px) { .toast-container { bottom: 16px !important; } }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.kbd { border: 1px solid #ccc; border-radius: 4px; padding: 0 5px; font-size: .8em; background: #fff; color: #333; }

/* ---------- Печать ---------- */
@media print {
  .app-sidebar, .app-topbar, .bottom-nav, .no-print, .btn, .toast-container, .modal, form.no-print { display: none !important; }
  .app-main { margin: 0 !important; padding: 0 !important; }
  body { background: #fff; font-size: 11pt; }
  .card { border: 1px solid #999 !important; box-shadow: none !important; break-inside: avoid; }
  .table-desktop { display: block !important; }
  .cards-mobile { display: none !important; }
  .table-sticky { max-height: none; overflow: visible; }
  a { color: #000; }
  .print-only { display: block !important; }
  .chart-box { height: 240px; }
}
.print-only { display: none; }
.min-w-0, .plan-block .list-group-item > .me-auto, .list-group-item > .me-auto { min-width: 0; overflow-wrap: anywhere; }

/* Контраст (WCAG AA) */
.btn-outline-secondary { --bs-btn-color: #495057; --bs-btn-border-color: #6c757d; }
.btn-outline-success { --bs-btn-color: #146c43; --bs-btn-border-color: #198754; }
.btn-outline-primary { --bs-btn-color: #0a58ca; }
.text-success { color: #146c43 !important; }
.text-warning { color: #995700 !important; }
.text-info { color: #087990 !important; }
.text-muted { color: #5c636a !important; }
.chart-grid > * { min-width: 0; } .chart-box canvas { max-width: 100%; }

/* ---------- Обучение (тур) ---------- */
.tour-layer { position: fixed; inset: 0; z-index: 3000; }
.tour-box { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(10, 20, 35, .62); transition: all .25s ease;
  outline: 3px solid #ffc107; pointer-events: none; }
.tour-card { position: fixed; background: #fff; color: #212529; border-radius: 14px; padding: 14px 16px; box-shadow: 0 10px 40px rgba(0,0,0,.35);
  max-width: calc(100vw - 24px); transition: top .25s ease, left .25s ease; }
.tour-card .tour-title { color: var(--app-primary); }
@media print { .tour-layer { display: none !important; } }

/* ---------- Чек-лист «Начало работы» ---------- */
.onboarding .step { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed #e3e7ec; }
.onboarding .step:last-child { border-bottom: 0; }
.onboarding .step .bi { font-size: 1.25rem; line-height: 1; }
.onboarding .step.done .step-title { text-decoration: line-through; color: #6c757d; }
.help-fab { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
  background: rgba(255,255,255,.18); color: #fff !important; }
.help-fab:hover { background: rgba(255,255,255,.3); }
.sidebar-help { margin: 8px; padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.08); color: #fff !important; display: block; }
.sidebar-help:hover { background: rgba(255,255,255,.16); }
.help-toc a { display: block; padding: 4px 8px; border-radius: 6px; color: inherit; }
.help-toc a:hover { background: #eef2f6; }
.help-section { scroll-margin-top: 72px; }
.help-section h2 { scroll-margin-top: 72px; }
.help-steps li { margin-bottom: 4px; }

.num, td.num { white-space: nowrap; }

/* ---------- Современная панель фильтров ---------- */
.fbar { border: 0; border-radius: 14px; }
.fbar-search { position: relative; }
.fbar-search > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #8a94a6; pointer-events: none; }
.fbar-search .form-control { padding-left: 40px; border-radius: 999px; background: #f4f6f9; border-color: transparent; height: 42px; }
.fbar-search .form-control:focus { background: #fff; border-color: var(--app-primary); box-shadow: 0 0 0 .2rem rgba(31, 78, 121, .15); }
.fbar-more-btn { border-radius: 999px; height: 42px; padding: 0 14px; white-space: nowrap; }
.fbar-more-btn[aria-expanded="true"] { background: var(--app-primary); color: #fff; border-color: var(--app-primary) !important; }
.fbar-row { display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; padding: 2px 0;
  -webkit-overflow-scrolling: touch; mask-image: linear-gradient(90deg, #000 92%, transparent); }
.fbar-row::-webkit-scrollbar { display: none; }
.fbar-label { color: #8a94a6; flex: none; width: 20px; text-align: center; }
.fchip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid #dfe3ea; background: #fff; color: #33415c; font-size: .875rem; cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s, color .15s; white-space: nowrap; }
.fchip:hover { border-color: var(--app-primary); color: var(--app-primary); }
.btn-check:checked + .fchip { background: var(--app-primary); border-color: var(--app-primary); color: #fff; }
.btn-check:focus-visible + .fchip { outline: 2px solid var(--app-primary); outline-offset: 2px; }
.fchip-n { font-size: .75rem; padding: 0 6px; border-radius: 999px; background: #eef1f6; color: #5b6b85; font-variant-numeric: tabular-nums; }
.btn-check:checked + .fchip .fchip-n { background: rgba(255, 255, 255, .22); color: #fff; }
.fdot { width: 8px; height: 8px; border-radius: 50%; background: #adb5bd; flex: none; }
.fchip-create .fdot { background: #198754; } .fchip-update .fdot { background: #0d6efd; }
.fchip-delete .fdot, .fchip-denied .fdot, .fchip-login_failed .fdot { background: #dc3545; }
.fchip-export .fdot, .fchip-bulk .fdot { background: #ffc107; } .fchip-login .fdot, .fchip-logout .fdot { background: #6c757d; }
.btn-check:checked + .fchip .fdot { box-shadow: 0 0 0 2px #fff; }
.fchip-active { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border-radius: 999px;
  background: rgba(31, 78, 121, .1); color: var(--app-primary); font-weight: 500; }
.fchip-active i { font-size: .7rem; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(31, 78, 121, .15); }
.fchip-active:hover i { background: var(--app-primary); color: #fff; }
.fbar-results.htmx-request { opacity: .55; transition: opacity .15s; pointer-events: none; }
.audit-meta { white-space: nowrap; }
@media (max-width: 767.98px) { .audit-meta { white-space: normal; margin-left: 0 !important; width: 100%; font-size: .8rem; } }

/* ---------- Тёмная тема ---------- */
.theme-switch .btn.active { background: var(--app-primary); border-color: var(--app-primary); color: #fff; }
[data-bs-theme=dark] {
  --bs-body-bg: #12161c; --bs-body-color: #dde3ea; --bs-secondary-bg: #1b2129; --bs-tertiary-bg: #171c23;
  --bs-border-color: #2c3440; --bs-emphasis-color: #f1f4f8;
  --bs-link-color: #79b0ff; --bs-link-color-rgb: 121, 176, 255; --bs-link-hover-color: #a6c9ff;
  --bs-light-rgb: 33, 40, 49; --bs-white-rgb: 27, 33, 41;
  color-scheme: dark;
}
[data-bs-theme=dark] body { background: #0e1217; }
[data-bs-theme=dark] .card, [data-bs-theme=dark] .modal-content, [data-bs-theme=dark] .dropdown-menu,
[data-bs-theme=dark] .offcanvas, [data-bs-theme=dark] .list-group-item, [data-bs-theme=dark] .accordion-item { --bs-card-bg: #171c23; background-color: #171c23; }
[data-bs-theme=dark] .card-header, [data-bs-theme=dark] .card-footer { background-color: #1b2129; }
[data-bs-theme=dark] .shadow-sm { box-shadow: 0 .125rem .35rem rgba(0,0,0,.45) !important; }
[data-bs-theme=dark] .app-topbar { background: color-mix(in srgb, var(--app-primary) 55%, #0e1217); }
[data-bs-theme=dark] .app-sidebar { background: #0b0f14; border-right: 1px solid #1f2630; }
[data-bs-theme=dark] .bottom-nav { background: #12161c; border-top-color: #2c3440; }
[data-bs-theme=dark] .bottom-nav a, [data-bs-theme=dark] .bottom-nav button { color: #aab4c2; }
[data-bs-theme=dark] .bottom-nav a.active, [data-bs-theme=dark] .text-pdz, [data-bs-theme=dark] .tour-card .tour-title { color: #79b0ff; }
/* светлые кнопки, таблицы и плашки Bootstrap не меняются сами — подстраиваем */
[data-bs-theme=dark] .btn-light { --bs-btn-color: #dde3ea; --bs-btn-bg: #222a34; --bs-btn-border-color: #2c3440;
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #2a3340; --bs-btn-hover-border-color: #3a4554;
  --bs-btn-active-color: #fff; --bs-btn-active-bg: #313b49; --bs-btn-active-border-color: #3a4554; }
[data-bs-theme=dark] .table { --bs-table-bg: transparent; --bs-table-striped-bg: rgba(255,255,255,.03); --bs-table-hover-bg: rgba(255,255,255,.05); }
[data-bs-theme=dark] .table-light { --bs-table-color: #dde3ea; --bs-table-bg: #1b2129; --bs-table-border-color: #2c3440;
  --bs-table-striped-bg: #1f262f; --bs-table-hover-bg: #232b35; color: #dde3ea; }
[data-bs-theme=dark] .table-sticky thead th { background: #1b2129; box-shadow: inset 0 -1px 0 #2c3440; }
[data-bs-theme=dark] .text-bg-light { color: #dde3ea !important; background-color: #232b35 !important; }
[data-bs-theme=dark] .bg-white { background-color: #171c23 !important; }
[data-bs-theme=dark] .alert-light { --bs-alert-bg: #1b2129; --bs-alert-color: #dde3ea; --bs-alert-border-color: #2c3440; }
[data-bs-theme=dark] .form-control, [data-bs-theme=dark] .form-select { background-color: #12161c; border-color: #2f3946; }
[data-bs-theme=dark] .form-control:disabled, [data-bs-theme=dark] .form-select:disabled { background-color: #1b2129; }
[data-bs-theme=dark] .app-topbar .form-control, [data-bs-theme=dark] .app-topbar .form-select { background-color: rgba(255,255,255,.1); color: #fff; border-color: transparent; }
[data-bs-theme=dark] .app-topbar .form-control::placeholder { color: rgba(255,255,255,.6); }
[data-bs-theme=dark] .app-topbar .form-select option { color: #dde3ea; background: #171c23; }
/* контрастные цвета текста для тёмного фона */
[data-bs-theme=dark] .text-success { color: #5cd08f !important; }
[data-bs-theme=dark] .text-warning { color: #ffc65c !important; }
[data-bs-theme=dark] .text-info { color: #5fd3ea !important; }
[data-bs-theme=dark] .text-muted { color: #98a3b3 !important; }
[data-bs-theme=dark] .text-danger { color: #ff7b86 !important; }
[data-bs-theme=dark] .text-primary { color: #79b0ff !important; }
[data-bs-theme=dark] .btn-outline-secondary { --bs-btn-color: #c3cad5; --bs-btn-border-color: #5a6574; --bs-btn-hover-bg: #2a3340; --bs-btn-hover-border-color: #6c7787; --bs-btn-hover-color: #fff; }
[data-bs-theme=dark] .btn-outline-primary { --bs-btn-color: #79b0ff; --bs-btn-border-color: #3d7fe0; --bs-btn-hover-bg: #1d4f99; --bs-btn-hover-color: #fff; }
[data-bs-theme=dark] .btn-outline-success { --bs-btn-color: #5cd08f; --bs-btn-border-color: #2f9a62; }
[data-bs-theme=dark] .btn-link { --bs-btn-color: #79b0ff; }
[data-bs-theme=dark] .app-topbar .btn-link { color: #fff; }
[data-bs-theme=dark] .kbd { background: #222a34; color: #dde3ea; border-color: #3a4554; }
[data-bs-theme=dark] .timeline::before { background: #2c3440; }
[data-bs-theme=dark] .timeline-item::before { border-color: #171c23; }
[data-bs-theme=dark] .tour-card { background: #1b2129; color: #dde3ea; }
[data-bs-theme=dark] .help-toc a:hover { background: #222a34; }
[data-bs-theme=dark] .onboarding .step { border-bottom-color: #2c3440; }
[data-bs-theme=dark] .fullscreen-target:fullscreen { background: #0e1217; }
[data-bs-theme=dark] .fbar-search .form-control { background: #1b2129; }
[data-bs-theme=dark] .fbar-search .form-control:focus { background: #12161c; }
[data-bs-theme=dark] .fchip { background: #1b2129; border-color: #2f3946; color: #c3cad5; }
[data-bs-theme=dark] .fchip:hover { color: #79b0ff; border-color: #3d7fe0; }
[data-bs-theme=dark] .fchip-n { background: #2a3340; color: #aab4c2; }
[data-bs-theme=dark] .fchip-active { background: rgba(121,176,255,.14); color: #a6c9ff; }
[data-bs-theme=dark] .fchip-active i { background: rgba(121,176,255,.2); }
[data-bs-theme=dark] .badge.text-bg-warning, [data-bs-theme=dark] .badge-new { color: #000 !important; }

/* ---------- Этапы взыскания ---------- */
.stage-badge { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 600; padding: 1px 8px; border-radius: 999px;
  background: #eef1f6; color: #4a5568; white-space: nowrap; margin-top: 2px; }
.stage-reminder { background: #e7f1ff; color: #0a58ca; } .stage-negotiation { background: #e6f7fb; color: #087990; }
.stage-claim { background: #fff4e0; color: #995700; } .stage-notice { background: #ffe9dc; color: #b54708; }
.stage-court { background: #fde8ea; color: #b02a37; }
.stage-badge.stuck { box-shadow: inset 0 0 0 1.5px #dc3545; }
[data-bs-theme=dark] .stage-badge { background: #2a3340; color: #c3cad5; }
[data-bs-theme=dark] .stage-reminder { background: rgba(61,127,224,.2); color: #8fbcff; }
[data-bs-theme=dark] .stage-negotiation { background: rgba(13,202,240,.15); color: #6fdcf2; }
[data-bs-theme=dark] .stage-claim { background: rgba(255,193,7,.15); color: #ffd36b; }
[data-bs-theme=dark] .stage-notice { background: rgba(253,126,20,.18); color: #ffad6b; }
[data-bs-theme=dark] .stage-court { background: rgba(220,53,69,.2); color: #ff8f9a; }
.stage-steps { display: flex; gap: 4px; list-style: none; padding: 0; margin: 0; counter-reset: st; }
.stage-steps li { flex: 1 1 0; min-width: 0; position: relative; padding: 8px 6px 6px; border-radius: 10px; text-align: center; font-size: .8rem;
  background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); line-height: 1.2; }
.stage-steps li::before { counter-increment: st; content: counter(st); display: flex; width: 22px; height: 22px; margin: 0 auto 4px; border-radius: 50%;
  align-items: center; justify-content: center; font-weight: 700; font-size: .75rem; background: var(--bs-secondary-bg); border: 1px solid var(--bs-border-color); }
.stage-steps li.done { color: #146c43; } .stage-steps li.done::before { content: "✓"; background: #198754; color: #fff; border-color: #198754; }
.stage-steps li.current { background: var(--app-primary); color: #fff; font-weight: 600; }
.stage-steps li.current::before { background: #fff; color: var(--app-primary); border-color: #fff; }
.stage-steps li.current.stuck { background: #dc3545; } .stage-steps li.current.stuck::before { color: #dc3545; }
@media (max-width: 575.98px) { .stage-steps li { font-size: .68rem; padding: 6px 2px; } .stage-steps li span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } }
.stage-card { border-radius: 14px; }
.funnel-card { border: 0; border-radius: 14px; transition: transform .1s; } .funnel-card:hover { transform: translateY(-2px); }
.funnel-card .bar { height: 6px; border-radius: 3px; background: var(--bs-secondary-bg); overflow: hidden; }
.funnel-card .bar > span { display: block; height: 100%; background: var(--app-primary); }
[data-bs-theme=dark] .stage-steps li.done { color: #5cd08f; }

/* ---------- Отчёты ---------- */
.report-tabs .nav-link { border-radius: 999px; padding: .35rem .9rem; color: var(--bs-body-color); background: var(--bs-tertiary-bg); }
.report-tabs .nav-link.active { background: var(--app-primary); color: #fff; }
.aging-bar { display: flex; height: 22px; border-radius: 11px; overflow: hidden; background: var(--bs-secondary-bg); }
.aging-bar span { display: block; height: 100%; min-width: 3px; }
.aging-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.ab-1_30 { background: #0dcaf0; } .ab-31_60 { background: #ffc107; } .ab-61_90 { background: #fd7e14; }
.ab-91_180 { background: #dc3545; } .ab-180 { background: #7a1f2b; }
.heat-1_30 { background: rgba(13,202,240,.12) !important; } .heat-31_60 { background: rgba(255,193,7,.16) !important; }
.heat-61_90 { background: rgba(253,126,20,.16) !important; } .heat-91_180 { background: rgba(220,53,69,.16) !important; }
.heat-180 { background: rgba(122,31,43,.2) !important; }
.aging-table td.heat { font-weight: 600; }
.aging-table tfoot td { border-top: 2px solid var(--bs-border-color); }
[data-bs-theme=dark] .weekly-card td[style*="background"] { background: #1b2129 !important; }
[data-bs-theme=dark] .weekly-card [style*="color:#5c636a"] { color: #98a3b3 !important; }
[data-bs-theme=dark] .weekly-card tr[style*="border"] { border-color: #2c3440 !important; }
[data-bs-theme=dark] .weekly-card [style*="color:#146c43"] { color: #5cd08f !important; }
[data-bs-theme=dark] .weekly-card [style*="color:#b02a37"] { color: #ff8f9a !important; }
[data-bs-theme=dark] .weekly-card [style*="color:#995700"] { color: #ffc65c !important; }
.aging-table { font-size: .875rem; } .aging-table th { white-space: nowrap; } .aging-table td:first-child { min-width: 170px; }
.report-kpis .kpi-value, .kpi .kpi-value.fs-4 { font-size: clamp(1.05rem, 1.6vw, 1.45rem) !important; }
[data-bs-theme=dark] .btn-outline-dark { --bs-btn-color: #dde3ea; --bs-btn-border-color: #6c7787; --bs-btn-hover-bg: #dde3ea; --bs-btn-hover-color: #12161c; --bs-btn-hover-border-color: #dde3ea; }
[data-bs-theme=dark] .text-bg-dark { background-color: #3a4554 !important; }
@media (max-width: 575.98px) {
  .weekly-card .weekly-kpis, .weekly-card .weekly-kpis tbody, .weekly-card .weekly-kpis tr { display: block; }
  .weekly-card .weekly-kpis td { display: block; width: auto !important; margin-bottom: 8px; }
  .report-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } .report-tabs .nav-link { white-space: nowrap; }
}
[data-bs-theme=dark] .table-danger { --bs-table-bg: rgba(220,53,69,.2); --bs-table-color: #f6d5d9; --bs-table-border-color: #4a2a30; color: #f6d5d9; }
[data-bs-theme=dark] .table-warning { --bs-table-bg: rgba(255,193,7,.14); --bs-table-color: #f5e6b8; --bs-table-border-color: #4a4128; color: #f5e6b8; }
[data-bs-theme=dark] .table-success { --bs-table-bg: rgba(25,135,84,.16); --bs-table-color: #cdeedd; --bs-table-border-color: #234a37; color: #cdeedd; }
[data-bs-theme=dark] .table-info { --bs-table-bg: rgba(13,202,240,.14); --bs-table-color: #cdf2fa; --bs-table-border-color: #1f4650; color: #cdf2fa; }

/* ---------- Интеграции ---------- */
.api-code { background: #0f1720; color: #d6e2f0; padding: 12px 14px; border-radius: 10px; font-size: .78rem; line-height: 1.45;
  white-space: pre; overflow-x: auto; max-width: 100%; }
.api-doc code { font-size: .8rem; }
.fchip-link { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--bs-border-color);
  color: var(--bs-body-color); background: var(--bs-body-bg); font-size: .875rem; }
.fchip-link.active { background: var(--app-primary); color: #fff; border-color: var(--app-primary); }

/* ---------- Справочный центр ---------- */
.hc-hero { border-radius: 20px; background: linear-gradient(135deg, var(--app-primary), #3b82f6 60%, #8b5cf6); color: #fff; overflow: visible; }
.hc-hero-in { padding: 28px 28px 22px; }
@media (max-width: 575.98px) { .hc-hero-in { padding: 20px 16px 16px; } }
.hc-kicker { font-size: .8rem; opacity: .85; font-weight: 600; letter-spacing: .02em; }
.hc-title { font-size: clamp(1.6rem, 3.2vw, 2.3rem); font-weight: 800; margin: 2px 0 0; letter-spacing: -.02em; }
.hc-tour { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; backdrop-filter: blur(4px); }
.hc-tour:hover { background: rgba(255,255,255,.28); color: #fff; }
.hc-search { position: relative; max-width: 760px; }
.hc-search > i { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: #64748b; font-size: 1.1rem; z-index: 1; }
.hc-search input { width: 100%; height: 56px; border: 0; border-radius: 16px; padding: 0 18px 0 50px; font-size: 1.02rem;
  background: #fff; color: #1e293b; box-shadow: 0 10px 30px rgba(15,23,42,.18); outline: none; }
.hc-search input:focus { box-shadow: 0 10px 30px rgba(15,23,42,.18), 0 0 0 4px rgba(255,255,255,.45); }
.hc-results { position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 20; background: var(--bs-body-bg); color: var(--bs-body-color);
  border-radius: 16px; box-shadow: 0 18px 50px rgba(15,23,42,.25); padding: 6px; max-height: 60vh; overflow: auto; }
.hc-r { display: block; padding: 10px 12px; border-radius: 12px; color: inherit; }
.hc-r:hover, .hc-r:focus { background: var(--bs-tertiary-bg); }
.hc-r-g { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); font-weight: 700; }
.hc-r-t { display: block; font-weight: 600; }
.hc-r-s { display: block; font-size: .82rem; color: var(--bs-secondary-color); }
.hc-r-s mark { background: #fde68a; color: inherit; padding: 0 2px; border-radius: 3px; }
.hc-r-none { padding: 14px; color: var(--bs-secondary-color); }
.hc-popular { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.hc-pill { padding: 6px 14px; border-radius: 999px; background: rgba(255,255,255,.16); color: #fff !important; font-size: .86rem;
  border: 1px solid rgba(255,255,255,.28); transition: background .15s; }
.hc-pill:hover { background: rgba(255,255,255,.3); }

.hc-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
@media (max-width: 575.98px) { .hc-grid { grid-template-columns: 1fr; gap: 12px; } }
.hc-card { background: var(--bs-body-bg); border-radius: 18px; padding: 18px 16px 10px; box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 6px 20px rgba(15,23,42,.05);
  border: 1px solid var(--bs-border-color-translucent); transition: transform .15s, box-shadow .15s; }
.hc-card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(15,23,42,.06), 0 14px 34px rgba(15,23,42,.09); }
.hc-card-head { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; padding: 0 4px; }
.hc-blob { flex: none; width: 48px; height: 48px; border-radius: 15px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.35rem; color: #fff; background: var(--hc-grad); box-shadow: 0 6px 16px var(--hc-shadow); }
.hc-card-title { font-size: 1.08rem; font-weight: 700; margin: 0; }
.hc-card-desc { font-size: .82rem; color: var(--bs-secondary-color); }
.hc-topics { list-style: none; padding: 0; margin: 0; }
.hc-topics a { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 10px; color: var(--bs-body-color); font-size: .93rem; }
.hc-topics a:hover { background: var(--hc-soft); }
.hc-topics a:hover .hc-go { transform: translateX(3px); color: var(--hc-c); }
.hc-ti { color: var(--hc-c); width: 18px; text-align: center; }
.hc-go { color: var(--bs-secondary-color); font-size: .8rem; transition: transform .15s; }
.hc-role { font-size: .68rem; padding: 2px 8px; border-radius: 999px; background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); white-space: nowrap; }
.hc-green  { --hc-c: #16a34a; --hc-grad: linear-gradient(135deg, #22c55e, #059669); --hc-shadow: rgba(22,163,74,.3); --hc-soft: rgba(34,197,94,.08); }
.hc-blue   { --hc-c: #2563eb; --hc-grad: linear-gradient(135deg, #3b82f6, #1d4ed8); --hc-shadow: rgba(37,99,235,.3); --hc-soft: rgba(59,130,246,.08); }
.hc-teal   { --hc-c: #0d9488; --hc-grad: linear-gradient(135deg, #14b8a6, #0f766e); --hc-shadow: rgba(13,148,136,.3); --hc-soft: rgba(20,184,166,.08); }
.hc-orange { --hc-c: #ea580c; --hc-grad: linear-gradient(135deg, #fb923c, #ea580c); --hc-shadow: rgba(234,88,12,.3); --hc-soft: rgba(251,146,60,.1); }
.hc-purple { --hc-c: #7c3aed; --hc-grad: linear-gradient(135deg, #a78bfa, #7c3aed); --hc-shadow: rgba(124,58,237,.3); --hc-soft: rgba(167,139,250,.1); }
.hc-slate  { --hc-c: #475569; --hc-grad: linear-gradient(135deg, #94a3b8, #475569); --hc-shadow: rgba(71,85,105,.3); --hc-soft: rgba(148,163,184,.12); }
.hc-pink   { --hc-c: #db2777; --hc-grad: linear-gradient(135deg, #f472b6, #db2777); --hc-shadow: rgba(219,39,119,.3); --hc-soft: rgba(244,114,182,.1); }
[data-bs-theme=dark] .hc-green { --hc-c: #4ade80; } [data-bs-theme=dark] .hc-blue { --hc-c: #60a5fa; } [data-bs-theme=dark] .hc-teal { --hc-c: #2dd4bf; }
[data-bs-theme=dark] .hc-orange { --hc-c: #fb923c; } [data-bs-theme=dark] .hc-purple { --hc-c: #a78bfa; } [data-bs-theme=dark] .hc-slate { --hc-c: #94a3b8; }
[data-bs-theme=dark] .hc-pink { --hc-c: #f472b6; }
[data-bs-theme=dark] .hc-card, [data-bs-theme=dark] .hc-support { background: #171c23; border-color: #2c3440; }
[data-bs-theme=dark] .hc-hero { background: linear-gradient(135deg, #1e3a8a, #312e81 60%, #4c1d95); }

.hc-support { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; background: var(--bs-body-bg); border-radius: 18px; padding: 18px;
  border: 1px solid var(--bs-border-color-translucent); box-shadow: 0 6px 20px rgba(15,23,42,.05); }
.hc-sup-blob { --hc-grad: linear-gradient(135deg, #f472b6, #8b5cf6); --hc-shadow: rgba(139,92,246,.3); }

.hc-panel { --bs-offcanvas-width: min(600px, 100vw); border-left: 0 !important; }
@media (max-width: 575.98px) { .hc-panel { --bs-offcanvas-width: 100vw; } }
.hc-a-head { display: flex; gap: 14px; align-items: center; margin: 6px 0 10px; }
.hc-a-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--hc-c); }
.hc-a-title { font-size: 1.45rem; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.hc-lead { font-size: 1.02rem; color: var(--bs-secondary-color); margin-bottom: 16px; }
.hc-steps { list-style: none; counter-reset: s; padding: 0; margin: 0 0 14px; position: relative; }
.hc-steps li { counter-increment: s; position: relative; padding: 2px 0 14px 46px; }
.hc-steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--hc-grad);
  color: #fff; font-weight: 700; font-size: .85rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px var(--hc-shadow); }
.hc-steps li:not(:last-child)::after { content: ""; position: absolute; left: 14px; top: 32px; bottom: 2px; width: 2px; background: var(--hc-soft); }
.hc-tip { display: flex; gap: 10px; background: #fffbeb; border: 1px solid #fde68a; color: #713f12; border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; font-size: .9rem; }
.hc-tip i { color: #f59e0b; margin-top: 2px; }
[data-bs-theme=dark] .hc-tip { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.3); color: #fde68a; }
.hc-faq details { border: 1px solid var(--bs-border-color); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.hc-faq summary { font-weight: 600; cursor: pointer; }
.hc-faq details > div { color: var(--bs-secondary-color); margin-top: 6px; }
.hc-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--bs-border-color); }
.hc-nav a { display: block; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--bs-border-color); color: inherit; }
.hc-nav a:hover { border-color: var(--hc-c); }
.hc-nav small { display: block; color: var(--bs-secondary-color); font-size: .75rem; }
.hc-nav span { font-weight: 600; font-size: .9rem; }
.hc-nav-next { text-align: right; grid-column: 2; }
.hc-lock { color: var(--bs-secondary-color); font-size: .8rem; opacity: .7; }

/* ---------- Цвета кнопок фильтров на разных страницах ---------- */
.fchip-s-debt .fdot, .fchip-g-reminder .fdot, .fchip-m-card .fdot, .fchip-r-callback .fdot, .fchip-t-today .fdot { background: #0d6efd; }
.fchip-s-overdue .fdot, .fchip-g-court .fdot, .fchip-g-stuck .fdot, .fchip-r-refused .fdot, .fchip-r-wrong_number .fdot,
.fchip-t-overdue .fdot, .fchip-p-broken .fdot { background: #dc3545; }
.fchip-s-new .fdot, .fchip-g-claim .fdot, .fchip-p-today .fdot, .fchip-m-mortgage .fdot { background: #ffc107; }
.fchip-s-paid .fdot, .fchip-m-cash .fdot, .fchip-r-paid .fdot, .fchip-r-promise .fdot, .fchip-t-done .fdot, .fchip-p-kept .fdot { background: #198754; }
.fchip-g-negotiation .fdot, .fchip-m-bank .fdot, .fchip-m-transfer .fdot { background: #0dcaf0; }
.fchip-g-notice .fdot { background: #fd7e14; }
.fchip-r-no_answer .fdot, .fchip-m-other .fdot, .fchip-r-other .fdot, .fchip-p-pending .fdot { background: #adb5bd; }
.fbar .input-group-sm .form-control { min-width: 0; }
.fbar-sep { flex: none; width: 1px; height: 22px; background: var(--bs-border-color); margin: 0 4px; }
.fbar-select { height: 42px; border-radius: 999px; }

/* ---------- Компактная таблица клиентов ---------- */
table[data-cols-key="clients"] { font-size: .9rem; }
table[data-cols-key="clients"] th { white-space: nowrap; }
table[data-cols-key="clients"] td { padding-top: .45rem; padding-bottom: .45rem; }
.cl-proj { max-width: 190px; }
.cl-proj-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table[data-cols-key="clients"] td:nth-child(2) a.fw-semibold { white-space: nowrap; }
/* суммы в карточках-показателях не переносят «сум» на новую строку */
.kpi .kpi-value { font-size: clamp(1.05rem, 1.55vw, 1.6rem); overflow-wrap: normal; word-break: keep-all; }
.onb-compact { border-radius: 14px; }
.onb-head { padding: 10px 14px; }
.onb-toggle { background: none; border: 0; padding: 0; color: inherit; min-width: 0; flex: 1 1 auto; }
.onb-chev { color: var(--bs-secondary-color); transition: transform .2s; }
.onb-toggle[aria-expanded="true"] .onb-chev { transform: rotate(180deg); }
.onb-ring { --p: 0; flex: none; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--app-primary) calc(var(--p) * 1%), var(--bs-secondary-bg) 0); }
.onb-ring span { width: 32px; height: 32px; border-radius: 50%; background: var(--bs-body-bg); display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; }
[data-bs-theme=dark] .onb-ring span { background: #171c23; }

/* меню языка (общее с CRM) */
.lang-btn { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; border-radius: 10px; border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg); color: var(--bs-body-color); padding: 6px 10px; }
.lang-btn:hover, .lang-btn[aria-expanded="true"] { border-color: #9fb7d1; color: var(--bs-link-color); background: var(--bs-tertiary-bg); }
.lang-btn::after { margin-left: 2px; }
.lang-list { min-width: 190px; padding: 6px; border-radius: 14px; border: 1px solid var(--bs-border-color); box-shadow: 0 16px 40px rgba(15,34,54,.14); }
.lang-list .dropdown-item { display: flex; justify-content: space-between; align-items: center; border-radius: 9px; padding: 8px 10px; font-weight: 500; }
.lang-list .dropdown-item small { color: #8a99a8; font-weight: 600; }
.lang-list .dropdown-item.active { background: var(--bs-primary-bg-subtle); color: var(--bs-link-color); }
.lang-list .dropdown-item.active small { color: var(--bs-link-color); }


/* ---------- Облегчённый режим для слабых устройств ----------
   Класс .lite ставится до отрисовки (скрипт в <head>), если у устройства мало памяти или ядер, включена экономия трафика
   или медленная сеть; то же — при «уменьшить движение» в системе. Выключаются размытие, анимации, тяжёлые тени и 3D. */
.lite *, .lite *::before, .lite *::after { animation: none !important; transition: none !important; }
.lite .pub-nav { backdrop-filter: none; -webkit-backdrop-filter: none; background: #fff; }
.lite .pub-logo, .lite .pub-cta { box-shadow: none; }
.lite .hc-tour { backdrop-filter: none; }
.lite .card, .lite .shadow-sm, .lite .shadow, .lite .shadow-lg { box-shadow: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Узкие экраны (старые и недорогие телефоны, 320–400 px) ---------- */
/* Вкладки (отчёты, интеграции) — в одну строку с прокруткой пальцем, а не за край экрана */
.report-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
.report-tabs::-webkit-scrollbar { display: none; }
.report-tabs .nav-link { white-space: nowrap; }
/* Длинные метки статуса в заголовках переносятся */
h1 .badge, .h3 .badge { white-space: normal; text-align: left; line-height: 1.25; }
/* Суммы в карточках-показателях подстраиваются под ширину карточки */
@media (max-width: 420px) { .kpi .kpi-value { font-size: .95rem !important; overflow-wrap: anywhere; } }
@supports (container-type: inline-size) {
  .kpi .card-body { container-type: inline-size; }
  .kpi .kpi-value { font-size: clamp(.78rem, 10.5cqi, 1.6rem) !important; overflow-wrap: normal; }
}
/* На самых узких телефонах (до 374 px) карточки с суммами — по одной в строку: «1 234 567 890 сум» иначе не помещается */
@media (max-width: 374px) {
  .row > .col-6:has(> .kpi), .row > .col-6:has(> .card.kpi) { flex: 0 0 100%; max-width: 100%; }
}
