        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f5f7fa;
            color: #333;
        }

        .container {
            display: flex;
            min-height: 100vh;
        }

        /* Боковая панель */
        .sidebar {
            width: 260px;
            min-width: 260px;
            background-color: #2c3e50;
            color: white;
            padding: 18px;
            overflow-y: auto;
            overflow-x: visible;
            height: 100vh;
            position: fixed;
            left: 0;
            top: 0;
            z-index: 100;
        }

        .sidebar h2 {
            font-size: 1.05rem;
            margin-bottom: 12px;
            padding-bottom: 0;
            border-bottom: none;
        }

        .nav-btn {
            display: block;
            width: 100%;
            padding: 12px 15px;
            margin-bottom: 10px;
            background-color: #3498db;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 1rem;
            text-align: left;
            transition: background-color 0.3s;
            text-decoration: none;
        }

        .nav-btn:hover {
            background-color: #2980b9;
        }

        .nav-btn.active {
            background-color: #1abc9c;
        }

        .filter-section {
            margin-bottom: 20px;
        }

        .filter-section h3 {
            font-size: 1rem;
            margin-bottom: 15px;
            color: #ecf0f1;
            padding-bottom: 10px;
            border-bottom: 1px solid #4a6278;
        }

        .filter-section label {
            display: block;
            margin-bottom: 5px;
            font-size: 0.9rem;
            color: #bdc3c7;
        }

        .filter-section select {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border: none;
            border-radius: 5px;
            background-color: #34495e;
            color: white;
            font-size: 0.9rem;
        }

        .filter-section select:focus {
            outline: 2px solid #3498db;
        }

        .filter-section select option:first-child {
            color: #95a5a6;
        }

        /* Custom searchable dropdown */
        .searchable-dropdown {
            position: relative;
            margin-bottom: 15px;
        }

        .searchable-dropdown .dropdown-trigger {
            width: 100%;
            padding: 10px;
            background-color: #34495e;
            color: white;
            border: none;
            border-radius: 5px;
            font-size: 0.9rem;
            cursor: pointer;
            text-align: left;
            display: flex;
            justify-content: space-between;
            align-items: center;
            min-height: 40px;
        }

        .searchable-dropdown .dropdown-trigger:hover {
            background-color: #4a6278;
        }

        .searchable-dropdown .dropdown-trigger.open {
            background-color: #4a6278;
            border-bottom-left-radius: 0;
            border-bottom-right-radius: 0;
        }

        .searchable-dropdown .dropdown-trigger .arrow {
            transition: transform 0.2s;
            font-size: 0.7rem;
            color: #95a5a6;
        }

        .searchable-dropdown .dropdown-trigger.open .arrow {
            transform: rotate(180deg);
        }

        .searchable-dropdown .dropdown-menu {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 500px;
            max-width: 90vw;
            max-height: 100vh;
            z-index: 9999;
            background-color: #34495e;
            border-radius: 5px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.5);
        }

        .searchable-dropdown .dropdown-menu.open {
            display: block;
        }

        .searchable-dropdown .dropdown-search {
            width: calc(100% - 20px);
            margin: 8px 10px;
            padding: 8px 10px;
            background-color: #2c3e50;
            color: white;
            border: 1px solid #4a6278;
            border-radius: 4px;
            font-size: 0.85rem;
            outline: none;
        }

        .searchable-dropdown .dropdown-search::placeholder {
            color: #7f8c8d;
        }

        .searchable-dropdown .dropdown-search:focus {
            border-color: #3498db;
        }

        .searchable-dropdown .dropdown-options {
            max-height: calc(100vh - 80px);
            overflow-y: auto;
            padding: 0 10px 10px;
        }

        .searchable-dropdown .dropdown-options::-webkit-scrollbar {
            width: 6px;
        }

        .searchable-dropdown .dropdown-options::-webkit-scrollbar-track {
            background: #2c3e50;
        }

        .searchable-dropdown .dropdown-options::-webkit-scrollbar-thumb {
            background: #4a6278;
            border-radius: 3px;
        }

        .searchable-dropdown .dropdown-option {
            padding: 8px 10px;
            color: #ecf0f1;
            cursor: pointer;
            border-radius: 4px;
            font-size: 0.85rem;
            white-space: nowrap;
        }

        .searchable-dropdown .dropdown-option:hover {
            background-color: #4a6278;
        }

        .searchable-dropdown .dropdown-option.selected {
            background-color: #2980b9;
            color: white;
            font-weight: 600;
        }

        .searchable-dropdown .dropdown-option.hidden {
            display: none;
        }

        .searchable-dropdown .no-results {
            padding: 10px;
            color: #7f8c8d;
            text-align: center;
            font-size: 0.85rem;
        }

        .stats-section {
            background-color: #34495e;
            border-radius: 8px;
            margin-top: 20px;
            overflow: hidden;
        }

        .stats-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px;
            cursor: pointer;
            user-select: none;
        }

        .stats-header:hover {
            background-color: #4a6278;
        }

        .stats-header h3 {
            font-size: 1rem;
            margin: 0;
            color: #ecf0f1;
            flex: 1;
        }

        .stats-toggle-arrow {
            font-size: 0.7rem;
            color: #95a5a6;
            transition: transform 0.3s ease;
            margin-left: 10px;
            flex-shrink: 0;
        }

        .stats-toggle-arrow.open {
            transform: rotate(180deg);
        }

        .stats-body {
            display: none;
            padding: 0 15px 15px 15px;
        }

        .stats-body.open {
            display: block;
        }

        .stat-item {
            display: flex;
            justify-content: space-between;
            padding: 8px 0;
            border-bottom: 1px solid #4a6278;
        }

        .stat-item:last-child {
            border-bottom: none;
        }

        .stat-label {
            color: #bdc3c7;
        }

        .stat-value {
            font-weight: bold;
            color: #3498db;
        }

        .stat-sublabel {
            font-size: 0.75rem;
            color: #95a5a6;
            margin-top: 4px;
            margin-left: 60px;
        }

        .stat-sublabel .used-count {
            color: #27ae60;
            font-weight: bold;
        }

        .stat-sublabel .total-count {
            color: #3498db;
            font-weight: bold;
        }

        /* Основная область */
        .main-content {
            flex: 1;
            padding: 20px;
            margin-left: 260px;
            width: calc(100vw - 260px);
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding: 20px;
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        .header h1 {
            font-size: 1.8rem;
            color: #2c3e50;
        }

        .search-box {
            display: flex;
            gap: 10px;
        }

        .search-box input {
            padding: 10px 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 0.9rem;
            width: 300px;
        }

        .search-box input:focus {
            outline: none;
            border-color: #3498db;
        }

        .calculate-btn {
            width: 36px;
            height: 36px;
            background-color: #9b59b6;
            color: white;
            border: none;
            border-radius: 50%;
            cursor: pointer;
            font-size: 1.1rem;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            position: relative;
            transition: background-color 0.3s, transform 0.2s;
        }

        .calculate-btn:hover {
            background-color: #8e44ad;
            transform: scale(1.1);
        }

        /* Tooltip для кнопки "Пересчитать" */
        .calculate-btn::after {
            content: attr(data-tooltip);
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            margin-top: 8px;
            background-color: #2c3e50;
            color: white;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 0.75rem;
            white-space: nowrap;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
            z-index: 100;
        }

        .calculate-btn:hover::after {
            opacity: 1;
        }

        /* Мигание кнопки «Обновить информацию» (при «Сервер перегружен») */
        .calculate-btn.flash {
            animation: calculate-btn-flash 0.7s ease-in-out 4;
        }
        @keyframes calculate-btn-flash {
            0%, 100% { background-color: #9b59b6; transform: scale(1); box-shadow: 0 0 0 0 rgba(231,76,60,0); }
            50% { background-color: #e74c3c; transform: scale(1.12); box-shadow: 0 0 0 6px rgba(231,76,60,.3); }
        }

        .reset-db-btn {
            padding: 10px 20px;
            background-color: #e74c3c;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 0.9rem;
            transition: background-color 0.3s;
        }

        .reset-db-btn:hover {
            background-color: #c0392b;
        }

        /* Маленькие иконки-кнопки с tooltip */
        .icon-btn {
            width: 36px;
            height: 36px;
            background-color: #3498db;
            color: white;
            border: none;
            border-radius: 50%;
            cursor: pointer;
            font-size: 1.1rem;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background-color 0.3s, transform 0.2s;
            flex-shrink: 0;
            position: relative;
        }

        .icon-btn:hover {
            background-color: #2980b9;
            transform: scale(1.1);
        }

        .icon-btn.active {
            background-color: #27ae60;
        }

        /* Tooltip для иконки-кнопки */
        .icon-btn::after {
            content: attr(data-tooltip);
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            margin-top: 8px;
            background-color: #2c3e50;
            color: white;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 0.75rem;
            white-space: nowrap;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
            z-index: 100;
        }

        .icon-btn:hover::after {
            opacity: 1;
        }

        /* Таблица */
        .table-container {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            position: relative;
        }

        table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
        }

        thead {
            background-color: #1a3a5c;
            color: white;
        }

        /* Фиксированная шапка — вся шапка (labels + filters + visibility)
           остаётся видимой при прокрутке таблицы (sticky относительно окна) */
        table thead {
            position: sticky;
            top: 0;
            z-index: 100;
        }

        tr.th-labels-row th {
            background-color: #1a3a5c !important;
            box-shadow: 0 2px 6px rgba(0,0,0,0.3);
        }

        th {
            padding: 12px 10px;
            text-align: left;
            font-weight: 600;
            font-size: 0.9rem;
            vertical-align: bottom;
        }

        /* Labels row - минимальная высота */
        tr.th-labels-row th {
            padding: 6px 8px 2px 8px;
            border-bottom: none;
            line-height: 1.2;
            font-size: 0.85rem;
        }

        /* Filters row - минимальная высота */
        tr.th-filters-row th {
            padding: 2px 8px 6px 8px;
            background-color: #1a3a5c !important;
        }

        /* Third row: visibility checkboxes - скрыта по умолчанию (высота 0) */
        tr.th-visibility-row {
            height: 0;
            overflow: hidden;
            transition: height 0.2s ease;
        }

        tr.th-visibility-row.active {
            height: auto;
        }

        tr.th-visibility-row th {
            padding: 0;
            background-color: #1a3a5c !important;
            vertical-align: top;
        }

        tr.th-visibility-row.active th {
            padding: 2px 8px 6px 8px;
        }

        th .th-content {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        th .th-label {
            font-weight: 600;
        }

        th .th-filter-cell {
            padding: 8px 10px 12px 10px;
        }

        th .th-filter-wrapper {
            position: relative;
            width: 100%;
        }

        th .th-filter {
            width: 100%;
            padding: 6px 24px 6px 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 0.8rem;
            background-color: white;
            color: #333;
        }

        th .th-filter:focus {
            outline: none;
            border-color: #3498db;
        }

        th .th-filter::placeholder {
            color: #999;
            font-size: 0.75rem;
        }

        th .th-filter-clear {
            position: absolute;
            right: 4px;
            top: 50%;
            transform: translateY(-50%);
            width: 16px;
            height: 16px;
            background-color: #bbb;
            color: white;
            border: none;
            border-radius: 50%;
            font-size: 10px;
            line-height: 1;
            cursor: pointer;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 0;
        }

        th .th-filter-clear:hover {
            background-color: #999;
        }

        th .th-filter-clear.visible {
            display: flex;
        }

        /* Кнопка сброса всех фильтров */
        .reset-filters-btn {
            width: 36px;
            height: 36px;
            background-color: #95a5a6;
            color: white;
            border: none;
            border-radius: 50%;
            cursor: pointer;
            font-size: 1.1rem;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            position: relative;
            transition: background-color 0.3s, transform 0.2s;
        }

        .reset-filters-btn:hover {
            background-color: #7f8c8d;
            transform: scale(1.1);
        }

        /* Tooltip для кнопки "Сбросить фильтры" */
        .reset-filters-btn::after {
            content: attr(data-tooltip);
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            margin-top: 8px;
            background-color: #2c3e50;
            color: white;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 0.75rem;
            white-space: nowrap;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
            z-index: 100;
        }

        .reset-filters-btn:hover::after {
            opacity: 1;
        }

        td {
            padding: 12px 10px;
            border-bottom: 1px solid #ecf0f1;
            font-size: 0.9rem;
        }

        tbody tr:hover {
            background-color: #f8f9fa;
        }

        /* Подсветка прибыли */
        .profit-positive {
            color: #27ae60;
            font-weight: bold;
        }

        .profit-negative {
            color: #e74c3c;
            font-weight: bold;
        }

        .profit-neutral {
            color: #7f8c8d;
        }

        /* Стрелки сравнения КЗ/ДЗП с федеральными значениями */
        .coeff-value {
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }

        .coeff-arrow {
            display: inline-block;
            font-size: 0.85rem;
            line-height: 1;
        }

        .coeff-arrow.up {
            color: #27ae60;
        }

        .coeff-arrow.down {
            color: #e74c3c;
        }

        /* Рост случаев к предыдущему периоду */
        .growth-arrow {
            display: inline-block;
            font-size: 0.85rem;
            font-weight: bold;
            cursor: default;
        }
        .growth-arrow.growth-up {
            color: #27ae60;
        }
        .growth-arrow.growth-down {
            color: #e74c3c;
        }
        .cases-with-note {
            color: #b7950b;
            font-weight: bold;
            background-color: #fef9e7;
            border-radius: 3px;
            padding: 0 2px;
            cursor: help;
        }
        .th-period-select {
            padding: 3px 6px;
            border: 1px solid #ccc;
            border-radius: 4px;
            font-size: 0.75rem;
            max-width: 110px;
            background-color: #fff;
        }
        .th-inline-check {
            display: inline-flex;
            align-items: center;
            gap: 3px;
            font-size: 0.68rem;
            color: #666;
            cursor: pointer;
            white-space: nowrap;
        }

        /* Модалка анализа нозологий — от правого края слайдбара */
        /* Слева от слайдбара (260px), справа отступ под скроллбар (17px),
           сверху/снизу по 8px чтобы не налезать на скроллбары */
        #mkb-codes-modal {
            position: fixed !important;
            left: 260px !important;
            top: 8px !important;
            right: 17px !important;
            bottom: 8px !important;
            width: auto !important;
            height: auto !important;
            align-items: stretch !important;
            justify-content: stretch !important;
            padding: 0 !important;
            box-sizing: border-box;
        }
        #mkb-codes-modal .modal {
            max-width: 100% !important;
            width: 100% !important;
            height: 100% !important;
            max-height: 100% !important;
            margin: 0 !important;
            border-radius: 8px !important;
            padding: 16px !important;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
        }
        #mkb-codes-modal-title {
            flex-shrink: 0;
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
            font-size: 1rem;
        }
        #mkb-codes-modal-body {
            overflow-y: auto;
            flex: 1;
            margin-bottom: 0 !important;
        }
        #mkb-codes-modal .modal-actions {
            flex-shrink: 0;
            padding-top: 10px;
            border-top: 1px solid #eee;
        }
        /* Блокируем скролл основного окна, когда модалка открыта */
        body.modal-nozology-open {
            overflow: hidden !important;
        }

        /* Цвета строк по типу стационара */
        .row-ds {
            background-color: #d6eaf8;
        }

        .row-ds:hover {
            background-color: #c4ddf6;
        }

        .row-ks {
            background-color: #d5f5e3;
        }

        .row-ks:hover {
            background-color: #c4edd8;
        }

        /* Модальное окно подтверждения */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.5);
            z-index: 2000;
            justify-content: center;
            align-items: center;
        }

        .modal-overlay.active {
            display: flex;
        }

        .modal {
            background-color: white;
            border-radius: 8px;
            padding: 30px;
            max-width: 450px;
            width: 90%;
            box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        }

        .modal h3 {
            font-size: 1.2rem;
            color: #2c3e50;
            margin-bottom: 15px;
        }

        .modal p {
            color: #7f8c8d;
            margin-bottom: 20px;
            line-height: 1.5;
        }

        .modal-actions {
            display: flex;
            gap: 10px;
            justify-content: flex-end;
        }

        .modal-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 0.9rem;
            transition: background-color 0.3s;
        }

        .modal-btn.cancel {
            background-color: #ecf0f1;
            color: #7f8c8d;
        }

        .modal-btn.cancel:hover {
            background-color: #bdc3c7;
        }

        .modal-btn.confirm {
            background-color: #e74c3c;
            color: white;
        }

        .modal-btn.confirm:hover {
            background-color: #c0392b;
        }

        /* Пагинация */
        .pagination {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
            gap: 10px;
        }

        .pagination button {
            padding: 8px 15px;
            background-color: #3498db;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 0.9rem;
        }

        .pagination button:disabled {
            background-color: #bdc3c7;
            cursor: not-allowed;
        }

        .pagination button:hover:not(:disabled) {
            background-color: #2980b9;
        }

        .page-info {
            color: #7f8c8d;
            font-size: 0.9rem;
        }

        /* Загрузочный индикатор */
        .loading {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 40px;
            color: #7f8c8d;
        }

        .loading::after {
            content: '';
            width: 30px;
            height: 30px;
            border: 3px solid #f3f3f3;
            border-top: 3px solid #3498db;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-left: 10px;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* Уведомления */
        .notification {
            position: fixed;
            top: 20px;
            right: 20px;
            padding: 15px 25px;
            border-radius: 5px;
            color: white;
            font-size: 0.9rem;
            z-index: 1000;
            animation: slideIn 0.3s ease-out;
        }

        .notification.success {
            background-color: #27ae60;
        }

        .notification.error {
            background-color: #e74c3c;
        }

        @keyframes slideIn {
            from {
                transform: translateX(100%);
                opacity: 0;
            }
            to {
                transform: translateX(0);
                opacity: 1;
            }
        }

        /* Loading overlay */
        .loading-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 9999;
            justify-content: center;
            align-items: center;
        }

        .loading-overlay.active {
            display: flex;
        }

        .loading-spinner {
            background-color: white;
            padding: 40px 50px;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
            text-align: center;
        }

        .loading-spinner .spinner {
            width: 50px;
            height: 50px;
            border: 5px solid #e0e0e0;
            border-top: 5px solid #3498db;
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
            margin: 0 auto 20px;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .loading-spinner p {
            margin: 0;
            font-size: 1.1rem;
            color: #2c3e50;
            font-weight: 600;
        }

        /* Стили для страницы Тарифное соглашение */
        .tariff-section {
            display: none;
            padding: 20px;
        }

        .tariff-section.active {
            display: block;
        }

        .tariff-card {
            background-color: white;
            border-radius: 8px;
            padding: 25px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        .tariff-card h2 {
            font-size: 1.5rem;
            color: #2c3e50;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid #3498db;
        }

        .tariff-actions {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }

        .tariff-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 0.9rem;
            transition: background-color 0.3s;
        }

        .tariff-btn.add {
            background-color: #27ae60;
            color: white;
        }

        .tariff-btn.add:hover {
            background-color: #219a52;
        }

        .tariff-btn.edit {
            background-color: #3498db;
            color: white;
            padding: 5px 10px;
            font-size: 0.8rem;
        }

        .tariff-btn.edit:hover {
            background-color: #2980b9;
        }

        .tariff-btn.delete {
            background-color: #e74c3c;
            color: white;
            padding: 5px 10px;
            font-size: 0.8rem;
        }

        .tariff-btn.delete:hover {
            background-color: #c0392b;
        }

        .tariff-btn.save {
            background-color: #27ae60;
            color: white;
            padding: 5px 10px;
            font-size: 0.8rem;
        }

        .tariff-btn.save:hover {
            background-color: #219a52;
        }

        .tariff-table-container {
            overflow-x: auto;
        }

        .tariff-table {
            width: 100%;
            border-collapse: collapse;
        }

        .tariff-table thead {
            background-color: #1a3a5c;
            color: white;
        }

        .tariff-table th {
            padding: 12px 10px;
            text-align: left;
            font-weight: 600;
            font-size: 0.85rem;
            white-space: nowrap;
        }

        .tariff-table td {
            padding: 10px;
            border-bottom: 1px solid #ecf0f1;
            font-size: 0.85rem;
        }

        .tariff-table tbody tr:hover {
            background-color: #f8f9fa;
        }

        .tariff-table input {
            width: 100%;
            padding: 6px 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 0.85rem;
        }

        .tariff-table input:focus {
            outline: none;
            border-color: #3498db;
        }

        .tariff-empty {
            text-align: center;
            padding: 40px;
            color: #7f8c8d;
        }

        /* Стили для калькулятора возмещения */
        .calculator-section {
            display: none;
            padding: 20px;
        }

        .calculator-section.active {
            display: block;
        }

        .calculator-card {
            background-color: white;
            border-radius: 8px;
            padding: 25px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            max-width: 800px;
            margin: 0 auto;
        }

        .calculator-card h2 {
            font-size: 1.5rem;
            color: #2c3e50;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid #3498db;
        }

        .calculator-form {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            margin-bottom: 25px;
        }

        .form-group {
            display: flex;
            flex-direction: column;
        }

        .form-group.full-width {
            grid-column: 1 / -1;
        }

        .form-group label {
            font-size: 0.9rem;
            color: #34495e;
            margin-bottom: 5px;
            font-weight: 600;
        }

        .form-group input,
        .form-group select {
            padding: 10px 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 1rem;
        }

        .form-group input:focus,
        .form-group select:focus {
            outline: none;
            border-color: #3498db;
        }

        .calculate-submit-btn {
            grid-column: 1 / -1;
            padding: 15px 30px;
            background-color: #27ae60;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 1.1rem;
            font-weight: 600;
            transition: background-color 0.3s;
        }

        .calculate-submit-btn:hover {
            background-color: #219a52;
        }

        .calculation-result {
            background-color: #f8f9fa;
            border-radius: 8px;
            padding: 20px;
            margin-top: 20px;
        }

        .calculation-result h3 {
            font-size: 1.2rem;
            color: #2c3e50;
            margin-bottom: 15px;
        }

        .result-row {
            display: flex;
            justify-content: space-between;
            padding: 10px 0;
            border-bottom: 1px solid #e0e0e0;
        }

        .result-row:last-child {
            border-bottom: none;
        }

        .result-label {
            color: #7f8c8d;
        }

        .result-value {
            font-weight: 600;
            color: #2c3e50;
        }

        .result-value.total {
            font-size: 1.3rem;
            color: #27ae60;
        }

        .formula-info {
            background-color: #e8f4f8;
            border-left: 4px solid #3498db;
            padding: 15px;
            margin-top: 20px;
            border-radius: 0 5px 5px 0;
        }

        .formula-info h4 {
            font-size: 1rem;
            color: #2c3e50;
            margin-bottom: 10px;
        }

        .formula-info .formula {
            font-family: 'Courier New', monospace;
            background-color: white;
            padding: 10px;
            border-radius: 4px;
            overflow-x: auto;
            font-size: 0.9rem;
        }

        .coefficients-info {
            margin-top: 20px;
            padding: 15px;
            background-color: #fff9e6;
            border-radius: 8px;
        }

        .coefficients-info h4 {
            font-size: 1rem;
            color: #2c3e50;
            margin-bottom: 10px;
        }

        .coefficient-item {
            padding: 8px 0;
            border-bottom: 1px solid #eee;
        }

        .coefficient-item:last-child {
            border-bottom: none;
        }

        .coefficient-name {
            font-weight: 600;
            color: #3498db;
        }

        /* Toggle switch styling */
        .toggle-switch input:checked + .toggle-slider {
            background-color: #27ae60;
        }
        .toggle-switch input:checked + .toggle-slider span {
            transform: translateX(18px);
        }
        .toggle-switch:hover input + .toggle-slider {
            background-color: #999;
        }
        .toggle-switch:hover input:checked + .toggle-slider {
            background-color: #219a52;
        }

        /* Модальные окна для выбора регионов */
        .region-modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.6);
            z-index: 3000;
            justify-content: center;
            align-items: center;
        }

        .region-modal-overlay.active,
        .region-modal-overlay[style*="display: flex"] {
            display: flex !important;
        }

        .region-modal {
            background-color: white;
            border-radius: 12px;
            padding: 30px;
            max-width: 650px;
            width: 90%;
            max-height: 85vh;
            overflow-y: auto;
            box-shadow: 0 8px 40px rgba(0,0,0,0.3);
        }

        .region-modal h3 {
            font-size: 1.3rem;
            color: #2c3e50;
            margin-bottom: 15px;
        }

        .region-modal p {
            color: #7f8c8d;
            margin-bottom: 15px;
            line-height: 1.5;
        }

        .region-tag {
            display: inline-block;
            padding: 4px 10px;
            border-radius: 4px;
            font-size: 0.85rem;
            margin: 3px;
        }

        .region-tag.conflict {
            background-color: #fdebd0;
            color: #e67e22;
            border: 1px solid #f0b27a;
        }

        .region-tag.new {
            background-color: #d5f5e3;
            color: #27ae60;
            border: 1px solid #82e0aa;
        }

        .region-badge {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 3px;
            font-size: 0.75rem;
            margin-left: 8px;
        }

        .region-badge.conflict {
            background-color: #fdebd0;
            color: #e67e22;
        }

        .region-badge.new {
            background-color: #d5f5e3;
            color: #27ae60;
        }

        .region-checkbox-item {
            display: flex;
            align-items: center;
            padding: 8px 10px;
            border-bottom: 1px solid #ecf0f1;
            cursor: pointer;
        }

        .region-checkbox-item:hover {
            background-color: #f8f9fa;
        }

        .region-checkbox-item input[type="checkbox"] {
            width: 18px;
            height: 18px;
            margin-right: 10px;
            cursor: pointer;
        }

        .region-checkbox-label {
            flex: 1;
            font-size: 0.9rem;
            color: #2c3e50;
        }

        .modal-actions-row {
            display: flex;
            gap: 10px;
            justify-content: flex-end;
            margin-top: 20px;
            flex-wrap: wrap;
        }

        .modal-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 0.9rem;
            transition: background-color 0.3s;
        }

        .modal-btn.cancel {
            background-color: #ecf0f1;
            color: #7f8c8d;
        }

        .modal-btn.cancel:hover {
            background-color: #bdc3c7;
        }

        .modal-btn.confirm {
            background-color: #27ae60;
            color: white;
        }

        .modal-btn.confirm:hover {
            background-color: #219a52;
        }

        .modal-btn.warning {
            background-color: #e67e22;
            color: white;
        }

        .modal-btn.warning:hover {
            background-color: #d35400;
        }

        .modal-btn.secondary {
            background-color: #3498db;
            color: white;
        }

        .modal-btn.secondary:hover {
            background-color: #2980b9;
        }

        .region-select-toolbar {
            display: flex;
            gap: 10px;
            margin-bottom: 15px;
            padding: 10px;
            background-color: #f8f9fa;
            border-radius: 6px;
        }

        .region-select-list {
            max-height: 400px;
            overflow-y: auto;
            border: 1px solid #ecf0f1;
            border-radius: 6px;
        }

        .region-select-list::-webkit-scrollbar {
            width: 6px;
        }

        .region-select-list::-webkit-scrollbar-track {
            background: #ecf0f1;
        }

        .region-select-list::-webkit-scrollbar-thumb {
            background: #bdc3c7;
            border-radius: 3px;
        }

        /* Responsive */
        @media (max-width: 768px) {
            .container {
                flex-direction: column;
            }

            .sidebar {
                width: 100%;
                height: auto;
                position: relative;
                max-height: none;
            }

            .main-content {
                margin-left: 0;
                width: 100vw;
            }

            .search-box input {
                width: 200px;
            }

            .calculator-form {
                grid-template-columns: 1fr;
            }
        }

        /* Блок информации о выбранных фильтрах в header */
        .filters-info {
            display: flex;
            flex-direction: column;
            gap: 4px;
            padding: 10px 15px;
            background-color: #f0f7ff;
            border-radius: 6px;
            margin-left: 20px;
            font-size: 0.85rem;
            color: #34495e;
            flex: 1;
            min-width: 0;
        }

        .filters-info .filter-row {
            display: flex;
            gap: 8px;
            align-items: center;
        }

        .filters-info .filter-label {
            font-weight: 600;
            color: #7f8c8d;
            min-width: 120px;
        }

        .filters-info .filter-value {
            color: #2c3e50;
        }

        .filters-info .filter-coeff {
            color: #3498db;
            font-size: 0.8rem;
        }

        /* Кнопка настроек отображения */
        .column-settings-btn {
            width: 36px;
            height: 36px;
            background-color: #95a5a6;
            color: white;
            border: none;
            border-radius: 50%;
            cursor: pointer;
            font-size: 1.2rem;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background-color 0.3s, transform 0.3s;
            flex-shrink: 0;
        }

        .column-settings-btn:hover {
            background-color: #7f8c8d;
            transform: rotate(45deg);
        }

        .column-settings-btn.active {
            background-color: #3498db;
            transform: rotate(180deg);
        }

        /* Кнопка при запрете права «Настройка отображения столбцов» */
        .column-settings-btn.denied {
            opacity: 0.45;
            cursor: not-allowed;
        }
        .column-settings-btn.denied:hover {
            background-color: #95a5a6;
            transform: none;
        }
/* «Настройки пользователя»: общий вид заблокированной кнопки.
           Неактивный чекбокс блокирует доступ, но кнопка остаётся видимой. */
        .denied {
            opacity: .35 !important;
            cursor: not-allowed !important;
            filter: grayscale(1);
            box-shadow: none !important;
            transform: none !important;
        }
        .denied:hover,
        .denied:focus,
        .denied:active {
            /* Блокированная кнопка НЕ «оживает» при наведении: серый фон, 
               никаких свечений/подъёма и фирменных цветов. */
            background-color: #95a5a6 !important;
            color: #fff !important;
            transform: none !important;
            box-shadow: none !important;
            text-shadow: none !important;
        }
        .denied::after,
        .denied:hover::after {
            opacity: 0 !important;
        }

        /* Чекбокс видимости столбца в заголовке */
        .th-visibility-toggle {
            display: flex;
            align-items: center;
            gap: 4px;
            margin-top: 4px;
        }

        .th-visibility-toggle input[type="checkbox"] {
            width: 14px;
            height: 14px;
            cursor: pointer;
            accent-color: #3498db;
        }

        .th-visibility-toggle label {
            font-size: 0.65rem;
            color: #aaa;
            cursor: pointer;
            white-space: nowrap;
        }

        /* Скрытый столбец */
        .column-hidden {
            display: none !important;
        }

        /* Ячейка стоимости схемы — интерактивная */
        .scheme-cost-cell {
            cursor: pointer;
            position: relative;
        }

        .scheme-cost-cell:hover {
            background-color: #e8f4f8 !important;
            color: #2980b9;
            font-weight: 600;
        }

        .scheme-cost-cell::after {
            content: '🔍 двойной клик для расчета';
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%);
            background-color: #2c3e50;
            color: white;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.7rem;
            white-space: nowrap;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
            z-index: 10;
        }

        .scheme-cost-cell:hover::after {
            opacity: 1;
        }

        /* Стрелки сортировки в заголовках столбцов */
        .th-sort-wrapper {
            display: inline-flex;
            align-items: center;
            gap: 3px;
            cursor: pointer;
            user-select: none;
        }

        .th-sort-wrapper:hover {
            color: #3498db;
        }

        .th-sort-arrows {
            display: flex;
            flex-direction: column;
            line-height: 1;
            font-size: 0.6rem;
            gap: 0;
        }

        .th-sort-arrows .sort-arrow-up,
        .th-sort-arrows .sort-arrow-down {
            opacity: 0.3;
            transition: opacity 0.2s, color 0.2s;
            color: white;
            pointer-events: none;
        }

        .th-sort-arrows .sort-arrow-up.active {
            opacity: 1;
            color: #f1c40f;
        }

        .th-sort-arrows .sort-arrow-down.active {
            opacity: 1;
            color: #f1c40f;
        }

        /* Ячейка нозологии — максимум 1 строка, полный текст при наведении (title) */
        .nozology-cell {
            max-width: 20ch;
            min-width: 20ch;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            cursor: default;
        }

        /* Заголовок нозологии — ограниченная ширина */
        /* width обязателен: в table-layout: auto min/max-width к ячейкам не применяются,
           без width при скрытии строки фильтров столбец сжимается до ширины текста */
        .th-nozology {
            width: 20ch;
            max-width: 20ch;
            min-width: 20ch;
        }

        /* Фильтр нозологии — ограниченная ширина (20 символов) */
        th.th-nozology-filter {
            max-width: 20ch;
            min-width: 20ch;
            width: 20ch;
            overflow: hidden;
        }
        th.th-nozology-filter .th-filter-wrapper {
            max-width: 100%;
            overflow: hidden;
        }
        th.th-nozology-filter select.th-filter {
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        /* Ячейка стоимости возмещения — интерактивная */
        .reimbursement-cell {
            cursor: pointer;
            position: relative;
        }

        .reimbursement-cell:hover {
            background-color: #e8f4f8 !important;
            color: #2980b9;
            font-weight: 600;
        }

        .reimbursement-cell::after {
            content: '💰 двойной клик для расчета возмещения';
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%);
            background-color: #2c3e50;
            color: white;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.7rem;
            white-space: nowrap;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
            z-index: 10;
        }

        .reimbursement-cell:hover::after {
            opacity: 1;
        }

        /* Кнопка настроек КС */
        .ks-settings-gear {
            width: 20px;
            height: 20px;
            background-color: transparent;
            color: #3498db;
            border: 1px solid #3498db;
            border-radius: 50%;
            cursor: pointer;
            font-size: 0.7rem;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            margin-left: 4px;
            vertical-align: middle;
            padding: 0;
            line-height: 1;
        }

        .ks-settings-gear:hover {
            background-color: #3498db;
            color: white;
            transform: rotate(90deg);
        }

        /* Модальное окно настроек КС */
        .ks-config-modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.6);
            z-index: 4000;
            justify-content: center;
            align-items: center;
        }

        .ks-config-modal-overlay.active {
            display: flex;
        }

        .ks-config-modal {
            background-color: white;
            border-radius: 12px;
            padding: 30px;
            max-width: 900px;
            width: 95%;
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: 0 8px 40px rgba(0,0,0,0.3);
        }

        .ks-config-modal h3 {
            font-size: 1.3rem;
            color: #2c3e50;
            margin-bottom: 10px;
        }

        .ks-config-modal .subtitle {
            color: #7f8c8d;
            margin-bottom: 20px;
            font-size: 0.9rem;
        }

        .ks-rule-card {
            background-color: #f8f9fa;
            border-radius: 8px;
            padding: 15px;
            margin-bottom: 12px;
            border-left: 4px solid #3498db;
        }

        .ks-rule-card.disabled {
            opacity: 0.5;
            border-left-color: #95a5a6;
        }

        .ks-rule-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }

        .ks-rule-title {
            font-weight: 600;
            color: #2c3e50;
            font-size: 1rem;
        }

        .ks-rule-desc {
            color: #7f8c8d;
            font-size: 0.85rem;
            margin-bottom: 10px;
        }

        .ks-rule-fields {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
            gap: 10px;
        }

        .ks-rule-field {
            display: flex;
            flex-direction: column;
        }

        .ks-rule-field label {
            font-size: 0.8rem;
            color: #7f8c8d;
            margin-bottom: 3px;
        }

        .ks-rule-field input {
            padding: 6px 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 0.9rem;
        }

        .ks-rule-field input:focus {
            outline: none;
            border-color: #3498db;
        }

        .ks-codes-textarea {
            width: 100%;
            min-height: 60px;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 0.85rem;
            font-family: monospace;
            resize: vertical;
        }

        .ks-codes-textarea:focus {
            outline: none;
            border-color: #3498db;
        }

        .ks-modal-actions {
            display: flex;
            gap: 10px;
            justify-content: flex-end;
            margin-top: 20px;
            padding-top: 15px;
            border-top: 1px solid #ecf0f1;
        }

        /* Стили для модального окна калькулятора возмещения */
        .calculator-modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.6);
            z-index: 5000;
            justify-content: center;
            align-items: center;
        }

        .calculator-modal-overlay.active {
            display: flex;
        }

        .calculator-modal {
            background-color: white;
            border-radius: 12px;
            padding: 25px;
            max-width: 900px;
            width: 95%;
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: 0 8px 40px rgba(0,0,0,0.3);
        }

        .calculator-modal h2 {
            font-size: 1.4rem;
            color: #2c3e50;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 2px solid #3498db;
        }

        .calculator-modal .modal-close-btn {
            position: absolute;
            top: 15px;
            right: 15px;
            width: 32px;
            height: 32px;
            background-color: #e74c3c;
            color: white;
            border: none;
            border-radius: 50%;
            cursor: pointer;
            font-size: 1.2rem;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background-color 0.3s;
        }

        .calculator-modal .modal-close-btn:hover {
            background-color: #c0392b;
        }
/* ===== Согласие на cookie (нижняя строка при первом входе) ===== */
        .cookie-consent-bar {
            position: fixed;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 10000;
            background-color: #1a3a5c;
            color: #ecf0f1;
            box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.35);
            padding: 10px 16px;
            font-size: 0.85rem;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 14px;
            flex-wrap: wrap;
        }
        .cookie-consent-bar[hidden] {
            display: none;
        }
        .cookie-consent-body {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 14px;
            flex-wrap: wrap;
            max-width: 1100px;
            width: 100%;
        }
        .cookie-consent-text {
            max-width: 640px;
            line-height: 1.35;
        }
        .cookie-consent-check {
            display: flex;
            align-items: center;
            gap: 6px;
            cursor: pointer;
            white-space: nowrap;
            color: #d5e8f5;
        }
        .cookie-consent-check input[type="checkbox"] {
            width: 16px;
            height: 16px;
            accent-color: #3498db;
            cursor: pointer;
        }
        .cookie-consent-buttons {
            display: flex;
            align-items: center;
            gap: 8px;
            white-space: nowrap;
        }
        .cookie-consent-btn {
            background-color: #3498db;
            color: #fff;
            border: none;
            border-radius: 6px;
            padding: 6px 16px;
            cursor: pointer;
            font-size: 0.85rem;
        }
        .cookie-consent-btn:hover:not(:disabled) {
            background-color: #217dbb;
        }
        .cookie-consent-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
        .cookie-consent-btn.secondary {
            background-color: #7f8c8d;
        }
        .cookie-consent-btn.secondary:hover {
            background-color: #6b7a7b;
        }

        /* Пункты меню при ограниченном (гостевом) доступе: видимы, но неактивны */
        .cookie-restricted {
            opacity: 0.55;
            pointer-events: none;
            cursor: not-allowed;
        }

/* ===== Индикатор статуса данных (заголовок Схемы КСГ) ===== */
#data-status.status-stale{ color:#e74c3c; }
#data-status.status-loading{ color:#f5a623; }
#data-status.status-ready{ color:#27ae60; }
#data-status.status-no-network{ color:#7f8c8d; }
#data-status.status-server-error{ color:#7f8c8d; }
/* ===== Заголовок-кнопка Фильтры (Обновить) ===== */
.filter-section .filter-apply-btn{ display:block; width:100%; padding:8px 12px; margin-bottom:14px; background:#2980b9; color:#fff; border:none; border-radius:4px; cursor:pointer; text-align:left; font-weight:bold; font-size:1rem; box-shadow:0 1px 2px rgba(0,0,0,0.1); }
.filter-section .filter-apply-btn:hover{ background:#2472a4; }
.filter-section .filter-apply-btn:active{ background:#1f5f8f; }

/* ===== Индикатор: подпись под заголовком внутри column-flex ===== */
.data-status-msg{ font-size:0.82rem; font-weight:normal; color:#7f8c8d; margin-top:2px; }


/* ===== Плавающая бровка статуса (скролл) ===== */
.status-bar{ position:fixed; top:0; left:50%; transform:translateX(-50%); display:flex; align-items:center; gap:8px; padding:8px 14px 10px 14px; background:rgba(255,255,255,0.92); border-radius:0 0 12px 12px; box-shadow:0 2px 8px rgba(0,0,0,0.12); z-index:2000; opacity:1; transition:opacity 0.25s ease, transform 0.25s ease; }
.status-bar[hidden]{ display:none; }
.status-bar-dot{ width:12px; height:12px; border-radius:50%; flex-shrink:0; background:#7f8c8d; }
.status-bar-text{ font-size:0.85rem; color:#2c3e50; white-space:nowrap; }


/* ===== Селектор Строк на экране (в пагинации) ===== */
.page-size-select{ display:inline-flex; align-items:center; gap:6px; margin-left:10px; font-size:0.85rem; color:#2c3e50; }
.page-size-select select{ padding:2px 6px; border:1px solid #ccc; border-radius:4px; font-size:0.85rem; }
.page-size-hint{ margin-left:8px; font-size:0.78rem; color:#e67e22; }

/* ===== Бровка статуса: скрыть для гостей через JS; тут дефолт = вид */

