        /* ===== DESIGN TOKENS =====
           UI-S1 (2026-05-08): семантические токены — единая ось для design-system.
           Legacy-имена (--primary, --neutral-N, --surface-raised, --shadow-md, --radius)
           остаются как алиасы реальных значений; используются 2000+ раз в коде.
           Удаляем их в UI-S8 cleanup после миграции компонентов на canonical names. */
        :root {
            color-scheme: light dark;

            /* === SEMANTIC COLOR (canonical) === */
            --bg:           #f8fafc;   /* page background */
            --surface:      #ffffff;   /* cards, modal, dropdown */
            --surface-2:    #f1f5f9;   /* table thead, code, raised inset */
            --border:       #e2e8f0;   /* default borders */
            --border-2:     #cbd5e1;   /* hover/active border */

            --text:         #0f172a;   /* body text, strong contrast */
            --text-muted:   #64748b;   /* labels, meta */
            --text-faint:   #94a3b8;   /* placeholders, hints */

            --brand:        #2563eb;   /* primary brand action color (canonical) */
            --success:      #15803d;
            --danger:       #dc2626;
            --warning:      #d97706;
            --info:         #0284c7;

            /* === TYPE === */
            --fs-xs:  11px;   /* meta, eyebrow */
            --fs-sm:  12px;   /* body-sm, table */
            --fs-md:  13px;   /* body */
            --fs-lg:  16px;   /* section-title */
            --fs-xl:  22px;   /* page-title */
            --fs-2xl: 28px;   /* hero kpi-value */

            /* === SPACING (4-base) === */
            --space-1: 4px;   --space-2: 8px;   --space-3: 12px;  --space-4: 16px;
            --space-5: 20px;  --space-6: 24px;  --space-8: 32px;  --space-10: 40px;

            /* === RADIUS === */
            --r-xs: 4px;
            --r-sm: 6px;
            --r-md: 8px;
            --r-lg: 12px;

            /* === LEGACY (kept) ===
               UI-S8-ALIASES-1 (2026-05-08): большинство aliases удалены после
               migration. Оставлены: --neutral-600/700 (нет canonical mid-grays),
               --surface-accent (distinct semantic — subtle accent bg), --bg-suffixes
               (легитимные для tinted alert backgrounds). */
            --success-bg:   #f0fdf4;
            --success-text: #166534;
            --danger-bg:    #fef2f2;
            --warning-bg:   #fffbeb;

            --neutral-600: #475569;            /* промежуточный mid-gray */
            --neutral-700: #334155;            /* промежуточный mid-gray */

            --surface-accent:  #eff6ff;        /* subtle accent bg для active states */

            --shadow:    0 4px 12px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);

            /* === FONTS === */
            --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;

            --nav-height:    40px;
            --sidebar-width: 220px;

            /* === BOOTSTRAP OVERRIDES === */
            --bs-body-font-family: var(--font-sans);
            --bs-body-bg:          var(--bg);
            --bs-body-color:       var(--text);
            --bs-border-color:     var(--border);
            --bs-primary:          var(--brand);
            --bs-primary-rgb:      37, 99, 235;
            --bs-link-color:       var(--brand);
            --bs-link-color-rgb:   37, 99, 235;
            --bs-card-bg:          var(--surface);
            --bs-card-border-color: var(--border);

            /* WCAG AA contrast fixes */
            --bs-success:     var(--success);
            --bs-success-rgb: 21, 128, 61;
            --bs-danger:      var(--danger);
            --bs-danger-rgb:  220, 38, 38;
        }

        /* ===== DARK THEME =====
           UI-S1 (2026-05-08): синхронизировано с canonical-токенами light-темы. */
        [data-bs-theme="dark"] {
            /* === SEMANTIC COLOR === */
            --bg:           #0f172a;
            --surface:      #1e293b;
            --surface-2:    #243044;
            --border:       #334155;
            --border-2:     #475569;

            --text:         #e2e8f0;
            --text-muted:   #94a3b8;
            --text-faint:   #64748b;

            --brand:        #60a5fa;
            --success:      #4ade80;
            --danger:       #f87171;
            --warning:      #fbbf24;
            --info:         #38bdf8;

            /* === LEGACY (kept) === */
            --success-bg:   rgba(74, 222, 128, 0.12);
            --success-text: #bbf7d0;
            --danger-bg:    rgba(248, 113, 113, 0.12);
            --warning-bg:   rgba(251, 191, 36, 0.12);

            --neutral-600: #cbd5e1;
            --neutral-700: var(--text);

            --surface-accent: rgba(96, 165, 250, 0.1);

            --shadow:    0 4px 12px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);

            /* === BOOTSTRAP OVERRIDES === */
            --bs-body-bg:          var(--bg);
            --bs-body-color:       var(--text);
            --bs-border-color:     var(--border);
            --bs-card-bg:          var(--surface);
            --bs-card-border-color: var(--border);
            --bs-success:          var(--success);
            --bs-success-rgb:      74, 222, 128;
            --bs-link-color:       var(--brand);
            --bs-link-color-rgb:   96, 165, 250;
            --bs-link-hover-color: #93c5fd;
            --bs-table-hover-bg:   rgba(255,255,255,0.04);
            --bs-table-striped-bg: rgba(255,255,255,0.02);
            --bs-modal-bg:         var(--surface);
            --bs-modal-header-border-color: var(--border);
            --bs-modal-footer-border-color: var(--border);
            --bs-input-bg:         var(--surface-2);
            --bs-input-border-color: var(--border-2);
            --bs-input-color:      var(--text);
            --bs-input-focus-bg:   var(--surface);
            --bs-input-focus-border-color: var(--brand);
            --bs-form-select-bg:   var(--surface-2);
            --bs-dropdown-bg:      var(--surface);
            --bs-dropdown-border-color: var(--border);
            --bs-dropdown-link-color: #cbd5e1;
            --bs-dropdown-link-hover-bg: var(--border);
        }

        /* Bootstrap component dark overrides */
        [data-bs-theme="dark"] .form-control,
        [data-bs-theme="dark"] .form-select,
        [data-bs-theme="dark"] textarea.form-control {
            background-color: #243044;
            border-color: #475569;
            color: #e2e8f0;
        }
        [data-bs-theme="dark"] .form-control:focus,
        [data-bs-theme="dark"] .form-select:focus {
            background-color: #1e293b;
            border-color: var(--brand);
            color: #f1f5f9;
            box-shadow: 0 0 0 3px rgba(96,165,250,0.2);
        }
        [data-bs-theme="dark"] .form-control::placeholder { color: #64748b; }
        [data-bs-theme="dark"] .modal-content {
            background: #1e293b;
            border-color: #334155;
        }
        [data-bs-theme="dark"] .modal-header,
        [data-bs-theme="dark"] .modal-footer { border-color: #334155; }
        [data-bs-theme="dark"] .table {
            --bs-table-color:       #e2e8f0;
            --bs-table-hover-color: #e2e8f0;
            --bs-table-bg: transparent;
            --bs-table-border-color: #334155;
        }
        [data-bs-theme="dark"] .table thead th { background: var(--surface-2); }
        [data-bs-theme="dark"] .table tfoot td,
        [data-bs-theme="dark"] .table tfoot th { background: var(--surface-2); }
        [data-bs-theme="dark"] .badge.bg-light { background: #334155 !important; color: #e2e8f0 !important; }
        [data-bs-theme="dark"] .alert-light { background: #243044; border-color: #334155; color: #cbd5e1; }
        [data-bs-theme="dark"] .btn-outline-secondary {
            color: #94a3b8; border-color: #475569;
        }
        [data-bs-theme="dark"] .btn-outline-secondary:hover {
            background: #334155; color: #e2e8f0; border-color: #64748b;
        }
        [data-bs-theme="dark"] .btn-outline-danger { color: #f87171; border-color: #f87171; }
        [data-bs-theme="dark"] .btn-outline-danger:hover { background: rgba(248,113,113,0.15); }
        /* DC-4: красный P&L тёмная тема 3.23:1 → 6.5:1 */
        [data-bs-theme="dark"] .text-danger { color: #f87171 !important; }
        [data-bs-theme="dark"] .text-dark { color: #e2e8f0 !important; }
        /* DC-5/DC-9: btn-warning — тёмный текст в обеих темах
           [data-bs-theme="dark"] .btn-warning нужен с той же специфичностью что .text-dark,
           чтобы победить [data-bs-theme="dark"] .text-dark { color: #e2e8f0 !important } */
        .btn-warning,
        [data-bs-theme="dark"] .btn-warning { color: #1e293b !important; }
        [data-bs-theme="dark"] .bg-light { background: #243044 !important; }
        [data-bs-theme="dark"] .border { border-color: #334155 !important; }
        [data-bs-theme="dark"] .card-header { background: var(--surface-2); border-color: var(--border); }
        [data-bs-theme="dark"] .popover {
            --bs-popover-bg: #243044;
            --bs-popover-body-color: #e2e8f0;
            --bs-popover-header-color: #f1f5f9;
            --bs-popover-header-bg: #1e293b;
            --bs-popover-border-color: #475569;
            background-color: #243044 !important;
            border-color: #475569 !important;
        }
        [data-bs-theme="dark"] .popover-header { background-color: #1e293b !important; color: #f1f5f9 !important; border-bottom-color: #334155 !important; }
        [data-bs-theme="dark"] .popover-body { color: #e2e8f0 !important; background-color: #243044 !important; }
        [data-bs-theme="dark"] .popover-arrow::before { border-color: #475569 transparent; }
        [data-bs-theme="dark"] .popover-arrow::after  { border-color: #243044 transparent; }
        .metric-hint {
            position: absolute; top: 7px; right: 8px;
            width: 16px; height: 16px; border-radius: 50%;
            border: 1px solid var(--border-2);
            background: transparent; color: var(--text-muted);
            font-size: 10px; font-weight: 700; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            padding: 0; line-height: 1;
            transition: background .15s, color .15s;
        }
        .metric-hint:hover { background: var(--border); color: var(--neutral-700); }
        [data-bs-theme="dark"] .dropdown-menu {
            background: #1e293b; border-color: #334155;
        }
        /* D1: контраст мелкого текста (#64748b → #94a3b8) */
        [data-bs-theme="dark"] .summary-detail,
        [data-bs-theme="dark"] .cell-ticker { color: var(--text-muted); }
        /* DC-2: явный цвет неактивных ссылок навбара (3.33:1 → 6.07:1 WCAG AA) */
        [data-bs-theme="dark"] .nav-right a:not(.active),
        [data-bs-theme="dark"] .nav-logout-btn { color: #94a3b8; }
        /* D2: text-muted читаем */
        [data-bs-theme="dark"] .text-muted { color: #94a3b8 !important; }

        /* UX-5: Unified empty states */
        .empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
        .empty-state-icon { font-size: 2.25rem; opacity: 0.3; margin-bottom: 0.625rem; }
        .empty-state-title { font-weight: 600; color: var(--neutral-700); margin-bottom: 0.25rem; }
        .empty-state-desc { font-size: 0.875rem; }

        /* UX-4: Focus visible outline — keyboard navigation */
        :focus-visible {
            outline: 2px solid var(--brand);
            outline-offset: 2px;
        }
        /* Для кнопок Bootstrap — заменяем стандартный box-shadow на outline */
        .btn:focus-visible,
        .form-control:focus-visible,
        .form-select:focus-visible,
        .nav-link:focus-visible,
        a:focus-visible {
            outline: 2px solid var(--brand);
            outline-offset: 2px;
            box-shadow: none;
        }

        /* ===== BASE ===== */
        body {
            background: var(--bg);
            font-family: var(--font-sans);
            color: var(--text);
            -webkit-font-smoothing: antialiased;
        }

        /* ===== NAVBAR (slim top bar) ===== */
        .app-nav {
            position: sticky;
            top: 0;
            z-index: 100;
            height: var(--nav-height);
            background: var(--surface);
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            padding: 0 16px;
            gap: 2px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.06);
        }
        .nav-logo {
            display: flex;
            align-items: center;
            gap: 7px;
            font-weight: 700;
            font-size: 13px;
            color: var(--text);
            text-decoration: none;
            flex-shrink: 0;
        }
        .nav-logo:hover { color: var(--text); text-decoration: none; }
        .nav-logout-btn {
            background: none;
            border: none;
            cursor: pointer;
            font-family: inherit;
        }
        .nav-right a, .nav-logout-btn {
            display: flex;
            align-items: center;
            gap: 5px;
            padding: 4px 8px;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 500;
            color: var(--text-muted);
            text-decoration: none;
            transition: color 0.15s, background 0.15s;
            white-space: nowrap;
        }
        .nav-right a:hover, .nav-logout-btn:hover {
            color: var(--text);
            background: var(--surface-2);
            text-decoration: none;
        }
        .nav-right a.active { color: var(--brand); background: var(--surface-accent); }
        .nav-icon {
            width: 15px;
            height: 15px;
            flex-shrink: 0;
        }
        .nav-right {
            display: flex;
            align-items: center;
            gap: 2px;
            margin-left: auto;
        }
        .nav-toggle {
            display: none;
            border: none;
            background: none;
            padding: 5px;
            color: var(--neutral-600);
            cursor: pointer;
            border-radius: 6px;
        }
        .nav-toggle:hover { background: var(--surface-2); }
        @media (max-width: 860px) {
            .nav-toggle { display: block; }
        }

        /* ===== PAGE LAYOUT (flex: sidebar + content) ===== */
        .page-body {
            display: flex;
            align-items: flex-start;
        }
        .page-content {
            flex: 1;
            min-width: 0;
            display: flex;
            flex-direction: column;
            min-height: calc(100vh - var(--nav-height));
        }

        /* ===== APP SIDEBAR ===== */
        .app-sidebar {
            flex-shrink: 0;
            width: max-content;
            min-width: 200px;
            background: var(--surface);
            border-right: 1px solid var(--border);
            position: sticky;
            top: var(--nav-height);
            height: calc(100vh - var(--nav-height));
            overflow-y: auto;
            z-index: 90;
            padding: 1rem 0 2.5rem;
        }
        .sidebar-version {
            position: absolute;
            bottom: 1rem;
            left: 0;
            right: 0;
            font-size: .68rem;
            color: var(--text-faint);
            text-align: center;
        }
        .sidebar-section {
            font-size: .65rem;
            font-weight: 600;
            letter-spacing: .08em;
            text-transform: uppercase;
            color: var(--text-faint);
            padding: 0 1.25rem .4rem;
            margin-top: 1.25rem;
        }
        .sidebar-section:first-child { margin-top: 0; }
        .sidebar-link {
            display: flex;
            align-items: center;
            gap: .55rem;
            padding: .45rem 1.25rem;
            color: var(--neutral-600);
            font-size: .875rem;
            text-decoration: none;
            transition: background .15s, color .15s;
        }
        .sidebar-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
        .sidebar-link.active { background: var(--surface-accent); color: var(--brand); font-weight: 600; }
        [data-bs-theme="dark"] .sidebar-link { color: #94a3b8; }
        [data-bs-theme="dark"] .sidebar-link:hover { color: #f1f5f9; }
        [data-bs-theme="dark"] .sidebar-link.active { color: var(--brand); }
        .sidebar-link svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .7; }
        .sidebar-link.active svg { opacity: 1; }
        .sidebar-badge {
            margin-left: auto;
            font-size: .65rem;
            background: var(--brand);
            color: #fff;
            border-radius: 9px;
            padding: 1px 6px;
            font-weight: 600;
        }
        /* Sidebar overlay (mobile) */
        .sidebar-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.35);
            z-index: 89;
        }
        .sidebar-overlay.open { display: block; }
        @media (max-width: 860px) {
            html, body { overflow-x: hidden; }
            .app-sidebar {
                position: fixed;
                top: var(--nav-height);
                left: 0;
                bottom: 0;
                width: var(--sidebar-width);
                transform: translateX(-100%);
                transition: transform .22s ease;
                z-index: 91;
                box-shadow: 4px 0 16px rgba(0,0,0,0.12);
            }
            .app-sidebar.open { transform: translateX(0); }
        }

        /* ===== CARDS ===== */
        .card {
            border-radius: var(--r-md);
            border: 1px solid var(--border);
            box-shadow: var(--shadow);
            background: var(--surface);
        }
        .card-title {
            font-size: 14px;
            font-weight: 600;
            color: var(--neutral-700);
            margin-bottom: 16px;
        }

        /* ===== SUMMARY CARDS =====
           UI-S2: блок схлопнут — стили теперь в `.kpi*` ниже + shared-селектор
           для legacy `.summary-card*` (zero-regression compat). Старые имена
           удалятся в UI-S8 после миграции 16 шаблонов на `.kpi`. */
        .summary-card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-left: 3px solid var(--border-2);
            border-radius: var(--r-md);
            padding: var(--space-4) var(--space-5);
            box-shadow: var(--shadow);
            transition: box-shadow .2s, transform .2s;
            position: relative;
        }
        .summary-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
        .summary-card.primary { border-left-color: var(--brand); }
        .summary-card.success { border-left-color: var(--success); }
        .summary-card.danger  { border-left-color: var(--danger); }
        .summary-card.warning { border-left-color: var(--warning); }
        .summary-card.hero {
            background: color-mix(in srgb, var(--brand) 6%, var(--surface));
            border-left-color: var(--brand);
            border-left-width: 4px;
        }
        /* .summary-grid / .summary-label / .summary-value / .summary-detail —
           определены в каноническом блоке UI-S2 (поиск ".kpi-grid" / ".kpi__"). */

        /* ===== TABLES ===== */
        .table { font-size: 13px; }
        .table thead th {
            font-size: 12px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            color: var(--text-muted);
            background: var(--bg);
            border-bottom: 2px solid var(--border) !important;
            padding: 10px 12px;
            white-space: nowrap;
        }
        .table tbody tr td { transition: background 0.15s ease; }
        .table tbody tr:hover td { background: var(--surface-2); }
        .table td { padding: 10px 12px; border-color: var(--surface-2); vertical-align: middle; }
        /* Sticky thead (только для страниц без overflow:hidden на родителе) */
        .table-sticky thead th {
            position: sticky;
            top: var(--nav-height);
            z-index: 10;
            background: var(--surface);
        }
        /* tfoot */
        .table tfoot td, .table tfoot th {
            font-weight: 600;
            background: var(--bg);
            border-top: 2px solid var(--border) !important;
            font-variant-numeric: tabular-nums lining-nums;
        }
        /* Instrument cell: name + ticker */
        .cell-name {
            font-weight: 500;
            font-size: 13px;
            color: var(--text);
            line-height: 1.3;
        }
        .cell-ticker {
            font-family: var(--font-mono);
            font-size: 11px;
            color: var(--text-muted);
            margin-top: 1px;
        }
        .cell-num {
            font-variant-numeric: tabular-nums lining-nums;
            font-weight: 500;
            text-align: right;
            white-space: nowrap;
        }
        .cell-positive { color: var(--success); }
        .cell-negative { color: var(--danger); }
        .price-dir { font-size: 11px; margin-right: 2px; opacity: 0.7; }
        .price-dir-up { color: var(--success); }
        .price-dir-dn { color: var(--danger); }
        /* P&L badge: ↑ +1 234 ₽ */
        .cell-badge {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: 500;
            white-space: nowrap;
            font-variant-numeric: tabular-nums lining-nums;
        }
        .cell-badge.positive { background: var(--success-bg); color: var(--success); }
        .cell-badge.negative { background: var(--danger-bg);  color: var(--danger);  }

        /* ===== PAGE TITLES ===== */
        .page-title {
            font-size: 22px;
            font-weight: 700;
            color: var(--text);
            margin-bottom: 4px;
        }
        .page-subtitle {
            font-size: 13px;
            color: var(--text-muted);
            margin-bottom: 24px;
        }

        /* ===== LEGACY COMPAT ===== UI-S2.7 (2026-05-08): .metric-card удалён —
           dead-class, 0 use в шаблонах. Использовать .kpi с модификаторами. */

        /* ===== BUTTONS ===== */
        .btn {
            border-radius: 8px;
            font-family: var(--font-sans);
            font-weight: 500;
            font-size: 13px;
        }
        .btn-primary { background: var(--brand); border-color: var(--brand); }
        .btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

        /* ===== PERIOD PILLS ===== */
        .period-pill-group {
            display: inline-flex;
            flex-wrap: wrap;
            gap: 2px;
            background: var(--surface-2);
            border-radius: 8px;
            padding: 3px;
            max-width: 100%;
        }
        .period-pill {
            padding: 5px 13px;
            border: none;
            background: none;
            font-family: var(--font-sans);
            font-size: 12px;
            font-weight: 500;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: 6px;
            transition: all 0.15s;
            white-space: nowrap;
            text-decoration: none;
            display: inline-block;
        }
        .period-pill:hover { color: var(--neutral-700); text-decoration: none; }
        .period-pill.active {
            background: var(--surface);
            color: var(--brand);
            box-shadow: 0 1px 3px rgba(0,0,0,0.15);
        }

        /* ===== LIVE PRICE FLASH ===== */
        .price-up   { background-color: rgba(22,163,74,0.15);  transition: background-color 1s; }
        .price-down { background-color: rgba(220,38,38,0.15);  transition: background-color 1s; }

        /* ===== TEXT UTILITIES ===== */
        .text-2xs  { font-size: 11px; }
        .text-xs   { font-size: 11px; }
        .text-sm2  { font-size: 12px; }  /* .text-sm занят Bootstrap */
        .text-md   { font-size: 13px; }

        /* ===== BADGE-CHIP: параметры инструмента (страница инструмента) ===== */
        .badge-chip {
            font-size: 12px;
            line-height: 1.4;
        }

        /* ===== TABLE SORT LINKS ===== */
        .table thead th a { color: var(--text-muted); text-decoration: none; }
        .table thead th a:hover { color: var(--neutral-700); text-decoration: none; }

        /* ===== VIS-003: Mobile overflow-x — fallback for tables not in .table-responsive ===== */
        @media (max-width: 767.98px) {
            .card table.table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
        }

        /* ===== ACCOUNT CARD HEADER (dashboard) ===== */
        .account-card-header { border-bottom: 1px solid var(--border); background: var(--bg); }
        .account-card-total  { font-weight: 600; font-variant-numeric: tabular-nums lining-nums; }
        [data-bs-theme="dark"] .account-card-header { background: var(--surface-2); border-color: var(--border); }

        /* ===== BID/ASK BADGES (signals) ===== */
        .badge-bid { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
        .badge-ask { background: color-mix(in srgb, var(--danger)  15%, transparent); color: var(--danger);  }
        .seg-btn-bid.active, .period-pill-bid.active { color: var(--success); }
        .seg-btn-ask.active, .period-pill-ask.active { color: var(--danger); }

        /* ===== FILTER CHIP (dashboard instrument type filter) ===== */
        .filter-chip {
            padding: 4px 12px; border-radius: 16px; border: 1.5px solid var(--border);
            background: var(--surface); color: var(--text-muted);
            font-size: 12px; font-weight: 500; cursor: pointer; transition: all .15s;
        }
        .filter-chip:hover { border-color: var(--brand); color: var(--brand); }
        .filter-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

        /* ===== PROGRESS MINI (tax income table) ===== */
        .progress-mini      { width: 80px; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; }
        .progress-mini-fill { height: 100%; background: var(--brand); border-radius: 3px; }

        /* ===== TLH METRIC VALUE (tax-loss harvesting) ===== */
        .tlh-value { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums lining-nums; }


        /* ===== SUMMARY GRID VARIANTS ===== */
        .summary-grid-3 { grid-template-columns: repeat(3, 1fr); }
        @media (max-width: 900px) { .summary-grid-3 { grid-template-columns: repeat(2, 1fr); } }
        @media (max-width: 480px) { .summary-grid-3 { grid-template-columns: 1fr; } }

        /* ============================================================
           CANONICAL UI-S2 (2026-05-08): KPI / sections / charts
           BEM-имена: .kpi, .section-head, .eyebrow.
           Делятся селекторами со старыми summary-* для нулевой регрессии.
           Удаление старых классов — UI-S8.
           ============================================================ */

        /* ----- .kpi (= .summary-card) -----
           Shared-селекторы: модификаторы (primary/success/danger/warning/hero)
           работают и со старым summary-card, и с новым kpi одинаково.
           Это упрощает миграцию шаблонов — нужно менять только root-класс. */
        .kpi-grid, .summary-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: var(--space-4);
            margin-bottom: var(--space-6);
        }
        .kpi-grid--3, .summary-grid-3 { grid-template-columns: repeat(3, 1fr); }
        @media (max-width: 900px) {
            .kpi-grid, .kpi-grid--3,
            .summary-grid, .summary-grid-3 { grid-template-columns: repeat(2, 1fr); }
        }
        @media (max-width: 480px) {
            .kpi-grid, .kpi-grid--3,
            .summary-grid, .summary-grid-3 { grid-template-columns: 1fr; }
        }
        .kpi {
            background: var(--surface);
            border: 1px solid var(--border);
            border-left: 3px solid var(--border-2);
            border-radius: var(--r-md);
            padding: var(--space-4) var(--space-5);
            box-shadow: var(--shadow);
            transition: box-shadow .2s, transform .2s;
            position: relative;
        }
        .kpi:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
        /* Модификаторы цвета — общие со старым .summary-card.<mod> для conditionals */
        .kpi.primary, .kpi--accent  { border-left-color: var(--brand); }
        .kpi.success, .kpi--success { border-left-color: var(--success); }
        .kpi.danger,  .kpi--danger  { border-left-color: var(--danger); }
        .kpi.warning, .kpi--warning { border-left-color: var(--warning); }
        .kpi--neutral               { border-left-color: var(--border-2); }
        .kpi.hero, .kpi--hero {
            background: color-mix(in srgb, var(--brand) 6%, var(--surface));
            border-left-color: var(--brand);
            border-left-width: 4px;
        }
        .kpi__label, .summary-label {
            font-size: var(--fs-sm);
            font-weight: 600;
            letter-spacing: 0.05em;
            color: var(--text-muted);
            margin-bottom: var(--space-1);
        }
        .kpi__value, .summary-value {
            font-size: var(--fs-xl);
            font-weight: 700;
            color: var(--text);
            line-height: 1.2;
            font-variant-numeric: tabular-nums lining-nums;
            white-space: nowrap;
        }
        /* Цветовые модификаторы value: и старые (.summary-value.success), и новые */
        .kpi__value.success, .summary-value.success, .kpi__value--success { color: var(--success); }
        .kpi__value.danger,  .summary-value.danger,  .kpi__value--danger  { color: var(--danger); }
        .kpi.hero .kpi__value, .kpi--hero .kpi__value,
        .summary-card.hero .summary-value { font-size: var(--fs-2xl); }
        .kpi__delta, .summary-detail {
            font-size: var(--fs-xs);
            color: var(--text-muted);
            margin-top: var(--space-1);
        }
        /* Размерные модификаторы (для будущих admin compact + hero) */
        .kpi--sm  { padding: var(--space-3) var(--space-4); }
        .kpi--sm  .kpi__value { font-size: var(--fs-lg); }
        .kpi--sm  .kpi__label { font-size: var(--fs-xs); }
        .kpi--lg  { padding: var(--space-5) var(--space-6); }
        .kpi--lg  .kpi__value { font-size: var(--fs-2xl); }

        /* ----- .section-head (вместо .card-header py-2 px-3 fw-semibold) ----- */
        .section-head {
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: var(--space-3);
            margin-bottom: var(--space-3);
        }
        .section-title {
            font-size: var(--fs-lg);
            font-weight: 600;
            color: var(--text);
            margin: 0;
            line-height: 1.3;
        }
        .section-action {
            font-size: var(--fs-sm);
            font-weight: 500;
            color: var(--text-muted);
            text-decoration: none;
            white-space: nowrap;
            flex-shrink: 0;
        }
        .section-action:hover { color: var(--brand); text-decoration: none; }

        /* ----- .eyebrow (uppercase micro-label над числами/хедерами) ----- */
        .eyebrow {
            font-size: var(--fs-xs);
            font-weight: 600;
            letter-spacing: 0.06em;
            text-transform: uppercase;
            color: var(--text-muted);
            display: inline-block;
        }

        /* ----- charts: .chart-{xl=400, lg=300, md=240, sm=160} +
           .chart-heatmap (580px — heatmap-only). Inline `style="height:..."`
           ушло в этот блок. */
        .chart-heatmap { height: 580px; width: 100%; }
        @media (max-width: 768px) { .chart-heatmap { height: 420px; } }

        /* ============================================================
           CANONICAL UI-S3 (2026-05-08): Tables + Segmented Controls
           ============================================================ */

        /* ----- table-app: .table-app--compact для плотных admin-таблиц.
           Базовая `.table` Bootstrap уже стилизована выше; модификатор
           уменьшает row padding для admin user/instruments/tasks/monitor. */
        .table-app--compact { font-size: var(--fs-sm); }
        .table-app--compact thead th { padding: 6px 10px; font-size: var(--fs-xs); }
        .table-app--compact td { padding: 6px 10px; }
        /* Числовые ячейки — tabular-nums + right-align. Используется как
           th class="num" / td class="num" в новых таблицах. */
        .table th.num, .table td.num,
        td.num, th.num {
            text-align: right;
            font-variant-numeric: tabular-nums lining-nums;
            white-space: nowrap;
        }
        .ticker {
            font-family: var(--font-mono);
            font-size: var(--fs-xs);
            color: var(--text-muted);
            font-weight: 500;
        }

        /* ============================================================
           CANONICAL UI-S6 (2026-05-08): Empty / Modal / Chat / Error / Prose
           Дополняет существующий .empty-state (UI-5) размерным модификатором.
           Новые компоненты: .chat (support), .error-code (404/500),
           .card-hoverable (help/index), .modal-app (footer normalization).
           ============================================================ */

        /* ----- .icon (UI-S8-ICONS-1, 2026-05-08) -----
           SVG icon из sprite `_icons.html`: используется как
           `<svg class="icon"><use href="#icon-NAME"/></svg>`.
           Размер по default 16px (em-relative — наследует font-size родителя),
           stroke=currentColor (наследует цвет родителя для status/badge/btn). */
        .icon {
            display: inline-block;
            width: 1em;
            height: 1em;
            vertical-align: -0.125em;
            stroke: currentColor;
            fill: none;
            flex-shrink: 0;
        }
        .icon--sm { width: 12px; height: 12px; }
        .icon--md { width: 16px; height: 16px; }
        .icon--lg { width: 20px; height: 20px; }
        .icon--xl { width: 24px; height: 24px; }

        /* ----- common utility-classes (UI-S8-STYLE-BLOCKS-1, 2026-05-08) -----
           Извлечены из page-specific <style> блоков (screener, what_to_buy_bonds,
           admin/instruments, history, instrument). */
        .sortable { cursor: pointer; white-space: nowrap; user-select: none; }
        .sortable:hover { background: var(--surface-2); color: var(--brand); }
        .sortable:not(.sort-asc):not(.sort-desc)::after { content: ''; font-size: .7em; opacity: .4; }
        .sort-asc::after  { content: ' ▲'; font-size: .7em; }
        .sort-desc::after { content: ' ▼'; font-size: .7em; }
        .sort-icon { font-style: normal; font-size: .75em; opacity: .6; margin-left: .2rem; }
        /* Текстовые акценты для значений в таблицах (P/E, доходность и т.п.) */
        .val-good  { color: var(--success); font-weight: 600; }
        .val-warn  { color: var(--warning); }
        .val-bad   { color: var(--danger); }
        /* Микро-label над broker-группой (analytics history account-selector) */
        .broker-group-label { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
        /* Truncate text by N lines (3 by default) — instrument description */
        .desc-clamped {
            overflow: hidden;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
        }

        /* ----- empty-state size modifier ----- */
        .empty-state--sm { padding: var(--space-3) var(--space-2); }
        .empty-state--sm .empty-state-icon { font-size: 1.5rem; margin-bottom: 0.25rem; }
        .empty-state--sm .empty-state-title { font-size: var(--fs-sm); }
        .empty-state--sm .empty-state-desc { font-size: var(--fs-xs); }

        /* ----- chat (support/ticket_detail) -----
           3 типа сообщения: user (right, brand bg), staff (left, surface-2 bg),
           system (centered, muted italic). */
        .chat { display: flex; flex-direction: column; gap: var(--space-2); }
        .chat__msg {
            max-width: 80%;
            padding: 8px 14px;
            border-radius: var(--r-lg);
            font-size: var(--fs-sm);
            line-height: 1.5;
            word-break: break-word;
            white-space: pre-wrap;
        }
        .chat__msg--user {
            align-self: flex-end;
            background: var(--brand);
            color: #fff;
            border-bottom-right-radius: var(--r-xs);
        }
        .chat__msg--user a { color: #fff; text-decoration: underline; }
        .chat__msg--staff {
            align-self: flex-start;
            background: var(--surface-2);
            color: var(--text);
            border-bottom-left-radius: var(--r-xs);
            border: 1px solid var(--border);
        }
        .chat__msg--system {
            align-self: center;
            background: transparent;
            color: var(--text-muted);
            font-style: italic;
            font-size: var(--fs-xs);
            text-align: center;
            max-width: 100%;
            padding: var(--space-1) 0;
        }
        .chat__meta {
            font-size: var(--fs-xs);
            margin-top: var(--space-1);
            opacity: 0.75;
        }
        .chat__msg--user .chat__meta { text-align: right; }
        .chat__msg--staff .chat__author {
            font-size: var(--fs-xs);
            font-weight: 600;
            color: var(--brand);
            margin-bottom: 2px;
        }

        /* ----- error-code (404 / 500 huge number) ----- */
        .error-code {
            font-size: 5rem;
            line-height: 1;
            opacity: 0.15;
            font-weight: 800;
            color: var(--text);
        }

        /* ----- card-hoverable (help/index sections) -----
           Заменяет inline onmouseover/onmouseout JS. */
        .card-hoverable {
            transition: box-shadow .2s, transform .2s;
        }
        .card-hoverable:hover {
            box-shadow: var(--shadow);
            transform: translateY(-2px);
        }

        /* ----- prose (help content)
           Базовые стили для help-статей без uppercase headers. */
        .prose h2 {
            font-size: var(--fs-lg);
            font-weight: 600;
            margin-top: var(--space-6);
            margin-bottom: var(--space-3);
            color: var(--text);
        }
        .prose h3 {
            font-size: var(--fs-md);
            font-weight: 600;
            margin-top: var(--space-4);
            margin-bottom: var(--space-2);
            color: var(--text);
        }
        .prose p, .prose li {
            font-size: var(--fs-md);
            line-height: 1.65;
            color: var(--text);
        }
        .prose code {
            background: var(--surface-2);
            padding: 2px 6px;
            border-radius: var(--r-xs);
            font-family: var(--font-mono);
            font-size: 0.9em;
        }

        /* ----- modal-app (header/footer normalization) ----- */
        .modal-app--confirm .modal-footer {
            justify-content: center;
            border-top: 0;
            padding-top: 0;
            gap: var(--space-2);
        }
        .modal-app--confirm .modal-body {
            text-align: center;
            padding: var(--space-5) var(--space-4);
        }

        /* ----- alert (UI-S5): глобальный override Bootstrap .alert на canonical
           padding/font/radius. 114 alert-инстансов в 46 файлах получают единый
           стиль без миграции шаблонов. */
        .alert {
            padding: var(--space-2) var(--space-3);
            font-size: var(--fs-sm);
            border-radius: var(--r-md);
            margin-bottom: var(--space-3);
            line-height: 1.5;
        }
        /* Specificity: .alert.alert-dismissible has reserved padding-right for close-btn —
           Bootstrap уже это покрывает через свой селектор, не трогаем. */

        /* ----- form (UI-S5): глобальный override .form-label на canonical
           muted-stroke + tightening. Help-text 11px faint. */
        .form-label {
            font-size: var(--fs-sm);
            font-weight: 500;
            color: var(--text-muted);
            margin-bottom: var(--space-1);
        }
        .form-text { font-size: var(--fs-xs); color: var(--text-faint); }

        /* ----- buttons (UI-S5): размерные модификаторы для замены
           ad-hoc `btn-sm py-0 px-2` (≥10 повторений). */
        .btn-app--xs { padding: 2px 8px;  font-size: var(--fs-xs); line-height: 1.4; }
        .btn-app--sm { padding: 4px 10px; font-size: var(--fs-sm); line-height: 1.4; }

        /* ----- status: единый pill для статусов (тикеты, telegram, services,
           portfolio-tag). Заменяет .svc-pill (admin/dashboard inline-<style>),
           .badge-portfolio (screener inline-<style>), .adm-status-dot (admin/
           users — будет в UI-S7). 6 семантик: success/warning/danger/info/
           neutral/brand. С опциональной точкой `.status--dot`. */
        .status {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 2px 8px;
            border-radius: var(--r-xs);
            font-size: var(--fs-xs);
            font-weight: 500;
            line-height: 1.5;
            white-space: nowrap;
            vertical-align: middle;
            text-decoration: none;
            border: 1px solid transparent;
        }
        .status--success { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
        .status--warning { background: color-mix(in srgb, var(--warning) 12%, transparent); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
        .status--danger  { background: color-mix(in srgb, var(--danger)  12%, transparent); color: var(--danger);  border-color: color-mix(in srgb, var(--danger)  25%, transparent); }
        .status--info    { background: color-mix(in srgb, var(--info)    12%, transparent); color: var(--info);    border-color: color-mix(in srgb, var(--info)    25%, transparent); }
        .status--neutral { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
        .status--brand   { background: var(--brand); color: #fff; }
        /* Точка перед текстом (компактный indicator-style) */
        .status--dot::before {
            content: "";
            display: inline-block;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: currentColor;
            flex-shrink: 0;
        }
        /* Размер sm для tightly-spaced UI (например, в строках таблиц) */
        .status--sm { padding: 1px 6px; font-size: 10px; gap: 4px; }

        /* ----- seg (segmented control): мердж с .period-pill-group через
           shared-селекторы для нулевой регрессии. Modifier .active работает
           с обоих имён (в шаблонах `.period-pill.active`). */
        .seg-group, .period-pill-group {
            display: inline-flex;
            flex-wrap: wrap;
            gap: 2px;
            background: var(--surface-2);
            border-radius: var(--r-md);
            padding: 3px;
            max-width: 100%;
        }
        .seg-btn, .period-pill {
            padding: 5px 13px;
            border: none;
            background: none;
            font-family: var(--font-sans);
            font-size: var(--fs-sm);
            font-weight: 500;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: var(--r-sm);
            transition: all .15s;
            white-space: nowrap;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }
        .seg-btn:hover, .period-pill:hover {
            color: var(--text);
            text-decoration: none;
        }
        .seg-btn.active, .period-pill.active,
        .seg-btn.is-active, .period-pill.is-active {
            background: var(--surface);
            color: var(--brand);
            box-shadow: 0 1px 3px rgba(0,0,0,0.15);
        }
        /* keyboard-focus для accessibility */
        .seg-btn:focus-visible, .period-pill:focus-visible {
            outline: 2px solid var(--brand);
            outline-offset: 2px;
        }
        /* Иконка внутри seg-btn (broker-icon, sector-letter и т.п.) */
        .seg-btn .seg-icon, .period-pill .broker-icon {
            width: 14px; height: 14px; flex-shrink: 0;
        }

        /* ===== ZEBRA STRIPING ===== */
        .table-zebra tbody tr:nth-child(even) td {
            background: color-mix(in srgb, var(--bg) 60%, white);
        }

        /* ===== PLOTLY LOADING SHIMMER ===== */
        @keyframes shimmer { to { background-position: -200% 0; } }
        [id^="chart-"]:empty, [id$="-chart"]:empty {
            background: linear-gradient(90deg, var(--surface-2) 25%, var(--bg) 50%, var(--surface-2) 75%);
            background-size: 200% 100%;
            animation: shimmer 1.5s infinite;
            border-radius: var(--r-md);
        }

        /* ===== CHART HEIGHT SYSTEM ===== */
        .chart-xl { height: 400px; }
        .chart-lg { height: 300px; }
        .chart-md { height: 240px; }
        .chart-sm { height: 160px; }
        @media (max-width: 768px) {
            .chart-xl { height: 300px; }
            .chart-lg { height: 240px; }
            .chart-md { height: 200px; }
            .chart-sm { height: 130px; }
        }

        /* ===== Z-INDEX HIERARCHY =====
           Bootstrap modal:     1050
           Autocomplete drop:   1060
           Toast container:     1100
           Scroll-to-top btn:    900 (ниже всех оверлеев)
        =============================*/

        /* ===== SCROLL TO TOP ===== */
        #scroll-top {
            position: fixed; bottom: 24px; right: 24px; z-index: 900;
            width: 36px; height: 36px; border-radius: 50%;
            background: var(--neutral-700); color: #fff;
            border: none; cursor: pointer; font-size: 16px;
            box-shadow: var(--shadow);
            opacity: 0; pointer-events: none;
            transition: opacity 0.25s;
        }
        #scroll-top.visible { opacity: 1; pointer-events: auto; }
        #scroll-top:hover { background: var(--text); }
        [data-bs-theme="dark"] #scroll-top { background: var(--surface); color: var(--neutral-600); border: 1px solid var(--border-2); }
        [data-bs-theme="dark"] #scroll-top:hover { background: var(--border); }

        /* ===== TAG (UI-S4-INSTTYPE-1) =====
           Canonical "tag" компонент: компактный inline-метка типа/категории.
           Семантически отличается от .status (живое состояние) и .badge
           (Bootstrap counter). Применяется для типов инструментов, тегов
           тем, статичных категорий. Цветовая гамма зеркалит .status. */
        .tag {
            display: inline-block;
            font-size: 11px; font-weight: 600; letter-spacing: .04em;
            text-transform: uppercase; padding: 2px 7px; border-radius: var(--r-xs);
            vertical-align: middle; line-height: 1.6;
            background: var(--surface-2); color: var(--text-muted);
        }
        .tag--brand   { background: color-mix(in srgb, var(--brand) 15%, transparent); color: var(--brand); }
        .tag--warning { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
        .tag--success { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
        .tag--danger  { background: color-mix(in srgb, var(--danger)  15%, transparent); color: var(--danger); }
        .tag--neutral { background: var(--surface-2); color: var(--text-muted); }
        .tag--sm      { padding: 1px 5px; font-size: 10px; }
        /* Backward-compat: .inst-type-badge — alias на .tag, удаляется в S8 cleanup. */
        .inst-type-badge,
        .inst-type-badge.currency { display: inline-block;
            font-size: 11px; font-weight: 600; letter-spacing: .04em;
            text-transform: uppercase; padding: 2px 7px; border-radius: var(--r-xs);
            vertical-align: middle; line-height: 1.6;
            background: var(--surface-2); color: var(--text-muted); }
        .inst-type-badge.share    { background: color-mix(in srgb, var(--brand) 15%, transparent); color: var(--brand); }
        .inst-type-badge.bond     { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
        .inst-type-badge.etf      { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }

        /* ===== A11Y ===== */
        .visually-hidden {
            position: absolute; width: 1px; height: 1px;
            padding: 0; margin: -1px; overflow: hidden;
            clip: rect(0,0,0,0); white-space: nowrap; border: 0;
        }

        /* ===== MAIN CONTAINER ===== */
        .main-container {
            width: 100%;
            max-width: 1320px;
            margin: 0 auto;
            padding: 28px 64px 56px 24px; /* right:64px = место для scroll-to-top (36px кнопка + 28px отступ) */
            flex: 1;
        }
        @media (max-width: 600px) { .main-container { padding: 16px 12px 40px; } }
        /* D-1: nav icon buttons */
        .nav-icon-btn {
            border: none; background: none; padding: 4px 6px; border-radius: 6px;
            cursor: pointer; color: var(--text-muted); line-height: 1;
            transition: background .15s; display: flex; align-items: center; position: relative;
        }
        .nav-icon-btn:hover { background: var(--surface-2); }

        /* ===== ACCORDION ===== */
        .accordion {
            --bs-accordion-bg: var(--surface);
            --bs-accordion-border-color: var(--border);
            border: 1px solid var(--border);
            border-radius: var(--r-md);
            box-shadow: var(--shadow);
            background: var(--surface);
            overflow: hidden;
        }
        .accordion-item {
            border: none;
            border-bottom: 1px solid var(--border);
        }
        .accordion-item:last-child { border-bottom: none; }
        .accordion-button {
            --bs-accordion-btn-bg: var(--surface);
            color: var(--neutral-700);
            font-weight: 500;
        }
        .accordion-button:not(.collapsed) {
            --bs-accordion-active-bg: var(--surface-accent);
            color: var(--brand);
            background: var(--surface-accent);
            box-shadow: none;
        }
        .accordion-button:hover { background: var(--bg); }
        [data-bs-theme="dark"] .accordion {
            --bs-accordion-bg: var(--surface);
            --bs-accordion-border-color: var(--border);
        }
        [data-bs-theme="dark"] .accordion-button {
            --bs-accordion-btn-bg: var(--surface);
            color: #cbd5e1;
        }
        [data-bs-theme="dark"] .accordion-button:not(.collapsed) {
            --bs-accordion-active-bg: rgba(96,165,250,0.15);
            color: var(--brand);
            background: rgba(96,165,250,0.15);
        }
        [data-bs-theme="dark"] .accordion-button:hover { background: var(--surface-2); }

        /* ===== PRIVACY MODE ===== */
        /* .money    — денежная сумма в RUB с data-rub (FX-конвертация)         */
        /* .pv-rub   — денежная сумма в RUB без FX (налоги, доходы в таблицах)  */
        /* .pv       — относительный показатель (%, доходность, коэффициент)    */
        /*             НЕ блюрится: не раскрывает масштаб капитала              */
        /* .pv-chart — контейнер Plotly-графика с абсолютными суммами           */
        /* .cell-badge — P&L значки в ₽                                         */
        /* [data-atab] .summary-value — KPI-карточки аналитики (VaR, IIS, ₽)   */
        [data-privacy="on"] .money,
        [data-privacy="on"] .pv-rub,
        [data-privacy="on"] .cell-badge,
        [data-privacy="on"] [data-atab] .summary-value {
            filter: blur(7px);
            user-select: none;
            cursor: default;
            transition: filter 0.2s ease;
        }
        [data-privacy="on"] .pv-chart {
            filter: blur(14px);
            pointer-events: none;
            transition: filter 0.2s ease;
        }
        /* Плавный показ при выключении */
        [data-privacy="off"] .money,
        [data-privacy="off"] .pv-rub,
        [data-privacy="off"] .cell-badge,
        [data-privacy="off"] [data-atab] .summary-value,
        [data-privacy="off"] .pv-chart {
            filter: blur(0);
            transition: filter 0.2s ease;
        }
        /* Иконка кнопки: активное состояние (скрыто) */
        #privacy-toggle[data-active="1"] { color: var(--brand); }

/* ── Utility classes (P2-8) ─────────────────────────────────────
   Extracted from 1031 inline style= instances across templates.
   Top 5 patterns — replaces ~200 inline styles.
*/
.fs-10 { font-size: 10px; }
.fs-11 { font-size: 11px; }
.fs-12 { font-size: 12px; }
.text-n400 { color: var(--text-faint); }
.text-n500 { color: var(--text-muted); }
.text-n600 { color: var(--neutral-600); }


/* GAZPROM-1: broker icon in accordion header (squircle baked into PNG) */
.broker-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.broker-icon {
    width: 18px;
    height: 18px;
    object-fit: cover;
    flex-shrink: 0;
}
/* INSTR-ICONS-1: иконка инструмента рядом с тикером (PNG с T-Invest CDN или SVG-placeholder) */
.instrument-icon {
    object-fit: contain;
    flex-shrink: 0;
    vertical-align: middle;
    margin-right: 6px;
    border-radius: 50%;
    background: #fff;
}

/* Help-страницы: anchor-ссылки # рядом с заголовками показываются только
   при ховере на сам заголовок. Иначе # болтается как мусорный символ.
   UI-S8-FONTSIZE-1: font-size + text-decoration переехали из inline-style
   (123 occurrences) — теперь шаблоны просто `<a href="#x" class="text-muted ms-1">#</a>`. */
h1 > a[href^="#"], h2 > a[href^="#"], h3 > a[href^="#"], h4 > a[href^="#"] {
    font-size: 0.6em;
    text-decoration: none;
    opacity: 0;
    transition: opacity .15s ease;
}
h1:hover > a[href^="#"], h2:hover > a[href^="#"], h3:hover > a[href^="#"], h4:hover > a[href^="#"],
h1 > a[href^="#"]:focus-visible, h2 > a[href^="#"]:focus-visible, h3 > a[href^="#"]:focus-visible, h4 > a[href^="#"]:focus-visible {
    opacity: 1;
}

/* ===== UI-S8-STYLE-BLOCKS-1: page-specific CSS вынесен из inline <style> ===== */

/* admin/llm.html (LLM provider chain config) */
.llm-limit-label { font-size: .68rem; font-weight: 600; letter-spacing: .04em; color: var(--text-faint); margin-left: .25rem; }
.llm-sub { font-size: .7rem; color: var(--text-faint); margin-top: .1rem; }
.llm-warn { color: var(--warning); }
.llm-ok   { color: var(--success); }
.llm-err  { color: var(--danger); }

/* admin/usage.html (LLM usage stats: KPI + per-broker bar) */
.usage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 900px) { .usage-grid { grid-template-columns: 1fr; } }
.usage-kpi-row { display: flex; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.usage-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
    padding: .875rem 1rem; min-width: 140px; flex: 1; }
.usage-kpi-label { font-size: .68rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
    color: var(--text-faint); margin-bottom: .3rem; }
.usage-kpi-val { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1; }
.usage-kpi-sub { font-size: .73rem; color: var(--text-muted); margin-top: .25rem; }
.usage-kpi.warn .usage-kpi-val { color: var(--danger); }
.broker-bar-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.broker-bar-label { font-size: .8rem; color: var(--neutral-700); width: 130px; flex-shrink: 0; }
.broker-bar-wrap { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.broker-bar-fill { height: 100%; border-radius: 4px; background: var(--brand); }
.broker-bar-val { font-size: .78rem; font-weight: 600; color: var(--neutral-600); width: 30px; text-align: right; }

/* portfolio/watchlist.html (sortable cols, sparklines, consensus, progress) */
.sort-col:hover { background-color: var(--surface-2); }
.sparkline-cell { vertical-align: middle; padding: 6px 8px; min-width: 72px; }
.suggestion-item.active, .suggestion-item:hover { background: var(--surface-accent); }
.consensus-cell { vertical-align: middle; white-space: nowrap; }
.consensus-badge { font-size: 11px; font-weight: 700; letter-spacing: .3px; cursor: default; }
.consensus-buy  { background: var(--success); color: #fff; }
.consensus-hold { background: var(--warning); color: #1e293b; }
.consensus-sell { background: var(--danger);  color: #fff; }
.wl-progress-bar { height: 4px; border-radius: 2px; margin-top: 4px;
    background: var(--border); overflow: hidden; }
.wl-progress-fill { height: 100%; border-radius: 2px; transition: width .3s; min-width: 4px; }

/* portfolio/instrument.html (lazy-load helpers + metric-grid + KPI sizing) */
.ops-hidden { display: none; }
.bond-events-hidden { display: none; }
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.metric-grid .kpi { padding: 12px 14px; position: relative; }
.metric-grid .kpi__value { font-size: 18px !important; }
.kpi__value.warning { color: var(--warning); }
/* .consensus-* уже определены в watchlist-блоке выше — canonical через var(--success/warning/danger). */

/* users/profile.html (Sber report drop-zone) */
.sber-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--r-md);
    padding: 14px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s, color .2s;
    color: var(--text-muted);
    font-size: 0.85em;
    user-select: none;
}
.sber-drop-zone:hover { border-color: var(--brand); color: var(--brand); }
.sber-drop-zone.drag-over {
    border-color: var(--brand);
    background: color-mix(in srgb, var(--brand) 6%, transparent);
    color: var(--brand);
}
.sber-drop-zone.file-ready {
    border-color: var(--success);
    background: color-mix(in srgb, var(--success) 6%, transparent);
    color: var(--success);
    cursor: default;
}
.sber-drop-icon { font-size: 1.4em; margin-bottom: 4px; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* analytics/partials/_scripts.html — bond tenor palette + LLM explain button */
:root {
  --tenor-short:   var(--success);
  --tenor-medium:  var(--brand);
  --tenor-long:    var(--warning);
  --tenor-perp:    #9b59b6;
  --tenor-unknown: var(--text-faint);
}
[data-bs-theme="dark"] {
  --tenor-short:   var(--success);
  --tenor-medium:  var(--brand);
  --tenor-long:    var(--warning);
  --tenor-perp:    #a78bfa;
  --tenor-unknown: var(--text-muted);
}
#coverage-toggle:hover { background: var(--surface-2) !important; }
.explain-metric-btn {
    position: absolute; bottom: 7px; right: 8px;
    font-size: 9px; font-weight: 600; letter-spacing: 0.03em;
    color: var(--brand); background: none;
    border: 1px solid var(--brand); border-radius: 8px;
    padding: 1px 5px; cursor: pointer; line-height: 1.5;
    opacity: 0.6; transition: opacity .15s;
}
.explain-metric-btn:hover { opacity: 1; }
.explain-metric-btn:disabled { opacity: 0.3; cursor: default; }
.explain-metric-popover { max-width: 300px; }

/* WITHDRAW-LIMITS-UI-1: popover «Свободно для вывода» — расширяем ширину и
   добавляем вертикальный скролл, чтобы 8+ счетов помещались на 13" экране. */
.popover-withdraw { max-width: min(460px, 92vw); }
.popover-withdraw .popover-body {
    max-height: min(60vh, 420px);
    overflow-y: auto;
    padding: 0.4rem 0.6rem;
}
.popover-withdraw .table { margin-bottom: 0; font-size: 0.8rem; }
.popover-withdraw .table td,
.popover-withdraw .table th { padding: 0.25rem 0.4rem; }

/* portfolio/dashboard_partials/_scripts.html — accounts-table grouping + mobile card layout */
.group-divider {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-faint);
    background: var(--bg) !important; padding: 7px 12px !important;
    border-top: 2px solid var(--border) !important;
}
@media (max-width: 575px) {
    .account-card .table-responsive { overflow-x: visible; }
    .account-card table { border: none; }
    .account-card thead { display: none; }
    .account-card tbody tr:not(.group-divider-row) {
        display: grid;
        grid-template-columns: 1fr auto auto;
        align-items: center;
        padding: 8px 12px;
        border-bottom: 1px solid var(--border);
        gap: 0 8px;
    }
    .account-card tbody td { display: block; padding: 0; border: none; vertical-align: middle; }
    .account-card tbody tr.group-divider-row { display: block; }
    .account-card tbody tr.group-divider-row td { display: block; }
    .account-card tbody tr:not(.group-divider-row) td:first-child { grid-column: 1 / -1; margin-bottom: 2px; }
}
@media (min-width: 576px) {
    .account-card .table-responsive { overflow-y: clip; }
}

/* admin_panel/instruments.html — filters/pagination/inline-edit page-specific */
.instr-filters {
    display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.instr-filters .form-control,
.instr-filters .form-select {
    font-size: .82rem; height: 2rem;
    padding-top: .25rem; padding-bottom: .25rem;
}
.instr-filters input[type=search] { width: 220px; }
.instr-filters select { width: auto; }

.instr-pagination {
    display: flex; align-items: center; gap: .4rem;
    padding: .6rem 1rem; font-size: .82rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.instr-pagination a,
.instr-pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 1.8rem; height: 1.8rem; padding: 0 .4rem;
    border-radius: .3rem; text-decoration: none; font-size: .8rem;
}
.instr-pagination a { color: var(--brand); border: 1px solid var(--border); }
.instr-pagination a:hover { background: var(--surface-2); }
.instr-pagination .pg-cur { background: var(--brand); color: #fff; border: 1px solid transparent; font-weight: 600; }
.instr-pagination .pg-dots { color: var(--text-faint); border: none; }

.fund-yes { color: var(--success); font-size: .85rem; }
.fund-no  { color: var(--text-faint); font-size: .8rem; }

.inst-val-display { cursor: pointer; }
.inst-val-display:hover { text-decoration: underline dotted; color: var(--brand); }
.inst-inline-edit { display: none; }
.inst-inline-edit.show { display: inline-flex; align-items: center; gap: .3rem; }

.uid-short { font-size: .72rem; color: var(--text-faint); font-family: monospace; }

/* portfolio/calendar.html — calendar grid + event badges + filter chips */
:root {
    --cal-dividend: var(--brand);
    --cal-coupon:   #059669;
    --cal-maturity: var(--warning);
    --cal-offer:    #7c3aed;
}
[data-bs-theme="dark"] {
    --cal-coupon:   #34d399;
    --cal-offer:    #c4b5fd;
}
.cal-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.78em;
    font-weight: 600;
    cursor: default;
}
.cal-badge.dividend { background: color-mix(in srgb, var(--cal-dividend) 18%, transparent); color: var(--cal-dividend); }
.cal-badge.coupon   { background: color-mix(in srgb, var(--cal-coupon)   18%, transparent); color: var(--cal-coupon); }
.cal-badge.maturity { background: color-mix(in srgb, var(--cal-maturity) 18%, transparent); color: var(--cal-maturity); }
.cal-badge.offer    { background: color-mix(in srgb, var(--cal-offer)    18%, transparent); color: var(--cal-offer); }

.cal-month { margin-bottom: 2rem; }
.cal-month-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: .5rem;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}
.cal-dow {
    text-align: center;
    font-size: 0.7em;
    font-weight: 600;
    color: var(--text-muted);
    padding: 3px 0;
}
.cal-cell {
    min-height: 72px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 4px 5px;
    font-size: 0.7em;
    vertical-align: top;
    overflow: hidden;
}
.cal-cell.today { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, var(--surface)); }
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.other-month { background: var(--bg); }
.cal-day-num { font-size: 0.82em; font-weight: 600; color: var(--neutral-700); margin-bottom: 2px; }
.cal-day-num.today-num { color: var(--brand); }
.cal-cell .cal-badge {
    display: block; margin-bottom: 1px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    max-width: 100%; padding: 1px 4px; font-size: 0.95em;
}
.cal-total { margin-top: 2px; font-size: 0.75em; color: var(--neutral-600); font-weight: 600; }
.cal-filter-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 12px; border-radius: 20px; border: 1.5px solid transparent;
    font-size: 0.8em; font-weight: 500; cursor: pointer; transition: opacity .15s;
}
.cal-filter-btn:hover { opacity: 0.85; }
.cal-group-label {
    font-size: 0.75em; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--text-muted);
}
.cal-group-total {
    font-size: 0.8em; font-weight: 600; color: var(--neutral-600);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 10px; padding: 2px 10px;
}

/* admin_panel/dashboard.html — infra/system metrics + activity grid + recent regs/feedback + reg chart */
.infra-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
@media (max-width: 900px) { .infra-grid { grid-template-columns: 1fr; } }
.infra-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 1rem 1.25rem; }
.infra-title {
    font-size: .68rem; font-weight: 600; letter-spacing: .07em;
    text-transform: uppercase; color: var(--text-faint); margin-bottom: .75rem;
}
.svc-pills { display: flex; gap: .5rem; flex-wrap: wrap; }
.sys-rows { display: flex; flex-direction: column; gap: .6rem; }
.sys-row { display: flex; align-items: center; gap: .6rem; }
.sys-label { font-size: .75rem; color: var(--text-muted); width: 40px; flex-shrink: 0; }
.sys-bar-wrap { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.sys-bar { height: 100%; border-radius: 3px; transition: width .3s; }
.sys-bar.low  { background: var(--success); }
.sys-bar.mid  { background: var(--warning); }
.sys-bar.high { background: var(--danger); }
.sys-val { font-size: .75rem; font-weight: 600; color: var(--neutral-700); width: 52px; text-align: right; flex-shrink: 0; }
.sys-sparkline { width: 80px; height: 28px; flex-shrink: 0; }
.sys-sparkline polyline { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.sys-meta { margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--surface-2); display: flex; flex-wrap: wrap; gap: .35rem .75rem; }
.sys-badge { font-size: .72rem; color: var(--text-muted); background: var(--surface-2); border-radius: 4px; padding: .1rem .45rem; }

.activity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
@media (max-width: 900px) { .activity-grid { grid-template-columns: 1fr; } }

.reg-row { display: flex; align-items: center; gap: .65rem; padding: .5rem 0; border-bottom: 1px solid var(--surface-2); }
.reg-row:last-child { border-bottom: none; }
.reg-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--surface-accent);
    color: var(--brand);
    font-size: .7rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.reg-name { font-size: .85rem; font-weight: 500; color: var(--text); }
.reg-date { font-size: .75rem; color: var(--text-faint); margin-left: auto; white-space: nowrap; }

.fb-row { padding: .6rem 0; border-bottom: 1px solid var(--surface-2); }
.fb-row:last-child { border-bottom: none; }
.fb-meta { display: flex; align-items: center; gap: .5rem; margin-bottom: .25rem; }
.fb-user { font-size: .78rem; font-weight: 600; color: var(--neutral-700); }
.fb-time { font-size: .72rem; color: var(--text-faint); margin-left: auto; }
.fb-text { font-size: .8rem; color: var(--neutral-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.reg-chart-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 1rem 1.25rem 1.25rem; }
.reg-chart-title {
    font-size: .68rem; font-weight: 600; letter-spacing: .07em;
    text-transform: uppercase; color: var(--text-faint); margin-bottom: 1rem;
}
.reg-chart { display: flex; align-items: flex-end; gap: 2px; height: 72px; }
.reg-bar-col { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 0; }
.reg-bar-el { width: 100%; background: var(--brand); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .75; transition: opacity .15s; }
.reg-bar-el:hover { opacity: 1; }
.reg-bar-el.zero { background: var(--border); opacity: 1; }
.reg-xlabels { display: flex; gap: 2px; margin-top: .4rem; }
.reg-xlabel { flex: 1; font-size: .58rem; color: var(--text-faint); text-align: center; overflow: hidden; white-space: nowrap; }

/* UI-S8-FONTSIZE-1: page-hero emoji/icon (help intro) — replaces inline style="font-size:2.5rem; line-height:1;" */
.hero-icon { font-size: 2.5rem; line-height: 1; }

/* UI-S8-FONTSIZE-1 Phase 3: relative-em utilities — для badges/inline-meta внутри h-tags */
.fs-em7 { font-size: 0.7em; }
.fs-em8 { font-size: 0.8em; }

/* UI-S8-FONTSIZE-1 Phase 4: page-intro icon (2rem, 32px). Меньшая версия .hero-icon (2.5rem). */
.icon-2xl { font-size: 2rem; line-height: 1; }
.icon-xl { font-size: 1.5rem; line-height: 1; }
/* UI-S8-FONTSIZE-1 Phase 4: dropdown ⋯ trigger 18px (broker action menu) */
.btn-dropdown-dots { font-size: 18px; line-height: 1; }
/* UI-S8-FONTSIZE-1 P5: misc rem sizes */
.fs-rem-md { font-size: 1.2rem; }
.fs-rem-sm { font-size: 0.875rem; }

/* AUDIT-B3 P0-CSP-INLINE-EVENTS: replaces inline onmouseover/onmouseout for theme cards */
.card-hover-lift {
  transition: box-shadow 0.2s, transform 0.2s;
}
.card-hover-lift:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

/* ===== UI-S7-T7.x ADMIN LAYOUT (admin.css полностью мигрирован 2026-05-09) =====
   admin-only sidebar/wrapper/main + mobile toggle. Markup admin templates
   использует .adm-sidebar/.adm-nav-link/.adm-wrapper/etc — без canonical
   equivalents (admin-panel UX уникальный, не переиспользуется в user-side).
   Включается через base.html → app.css (admin.css больше не подгружается). */

.main-container--admin { padding: 0 !important; max-width: none !important; margin: 0 !important; }

.adm-wrapper { display: flex; min-height: calc(100vh - var(--nav-height)); }
.adm-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 10;
    display: flex;
    flex-direction: column;
}
.adm-version { margin-top: auto; padding: 1rem 0 .25rem; text-align: center; font-size: var(--fs-xs); color: var(--text-faint); }
.adm-sidebar-title {
    font-size: 11px; font-weight: 600; letter-spacing: .08em;
    text-transform: uppercase; color: var(--text-faint); padding: 0 1.25rem .5rem;
}
.adm-nav-link {
    display: flex; align-items: center; gap: .55rem;
    padding: .5rem 1.25rem; color: var(--text-muted);
    text-decoration: none; font-size: var(--fs-md);
    transition: background .15s, color .15s;
}
.adm-nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.adm-nav-link.active { background: var(--surface-accent); color: var(--brand); font-weight: 600; }
.adm-nav-link svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .75; }
.adm-nav-link.active svg { opacity: 1; }
.adm-badge {
    margin-left: auto; font-size: var(--fs-xs);
    background: var(--brand); color: #fff;
    border-radius: 9px; padding: 1px 6px; font-weight: 600;
}
.adm-main { margin-left: 220px; flex: 1; padding: 1rem 2rem 2rem; max-width: 1200px; }
.adm-header { margin-bottom: 1.75rem; }
.adm-header h1 { font-size: var(--fs-xl); font-weight: 700; color: var(--text); margin: 0 0 .25rem; }
.adm-header .adm-breadcrumb { font-size: var(--fs-sm); color: var(--text-faint); }
.adm-breadcrumb a { color: var(--text-muted); text-decoration: none; }
.adm-breadcrumb a:hover { color: var(--brand); }

.adm-mobile-toggle {
    display: none;
    position: fixed; bottom: 1rem; right: 1rem; z-index: 20;
    width: 44px; height: 44px;
    border-radius: 50%; border: none;
    background: var(--brand); color: #fff;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow);
    align-items: center; justify-content: center;
}
.adm-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 9; }
@media (max-width: 860px) {
    .adm-mobile-toggle { display: flex; }
    .adm-sidebar { transform: translateX(-100%); transition: transform .25s ease; }
    .adm-sidebar.open { transform: translateX(0); }
    .adm-overlay.open { display: block; }
    .adm-main { margin-left: 0; padding: 1rem; }
}
