﻿/*
1. Базовые настройки
2. Таблица
   2.1 wrapper
   2.2 сама таблица
   2.3 заголовки
   2.4 ячейки
   2.5 Δ-колонки
3. Панель управления таблицей
   3.1 Абсолютные / Относительные
   3.2 Изменения
   3.3 Пользовательские даты
4. Sticky-колонки
5. Иерархия таблицы level-0 ... level-5
6. Дополнительные состояния таблицы
7. Вкладки
8. Карточка рейтингов
9. Ошибки
10. Подсветка нарушений таблицы с нормативами
11. Интерактивный ползунок
12. Адаптивность
*/

/* =========================================================
   1. БАЗОВЫЕ НАСТРОЙКИ
   ========================================================= */
/* Финансовый шрифт: современный, чёткий, лёгкий */
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600&display=swap');

html {
    scroll-snap-type: x proximity;
    scroll-padding-left: 350px;
}
/* =========================================================
   2. ТАБЛИЦА
   ========================================================= */
.data-table-wrapper {
    width: 100%;
    max-width: 100%;
    min-width: 0;

    box-sizing: border-box;

    position: relative;

    overflow-x: visible;
    overflow-y: visible;
}


.data-table-content {
    width: max-content;
    min-width: 100%;
}

/* =========================================================
   Горизонтальный анализ в таблице нормативов —
   всегда прижат к правому краю таблицы
   ========================================================= */

#section-normatives .horizontal-analysis-controls,
#section-reg_cap .horizontal-analysis-controls {
    margin-left: auto;
}

/* Запрещаем изменение высоты и ширины первого столбца через контент */
/* Основная таблица */
.data-table {
    width: 100%;
    min-width: 0;
    max-width: 100%;

    border-collapse: collapse;

    margin: 20px 0;

    font-family: 'Source Sans Pro', sans-serif;
    color: #333;

    border-radius: 12px;

    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);

}


/* Заголовки столбцов */
.data-table th {
  background-color: #f0f4f8;
  border: 1px solid #dbe2ea;
  padding: 12px;
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}


/* Ячейки данных */
.data-table td {
  cursor: default; 
  border: 1px solid #e4e8ec;
  padding: 10px 12px;
  /* text-align: right; */
  vertical-align: middle;
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1); /* Плавная анимация */
}

/* Δ, % — фиксированная компактная колонка */
.data-table th.horizontal-analysis-percent,
.data-table td.horizontal-change-percent {
    width: 80px;
    min-width: 80px;
    max-width: 80px;

    box-sizing: border-box;
}

/* Заголовок Δ, % может переноситься */
.data-table th.horizontal-analysis-percent {
    white-space: normal;
    line-height: 1.2;
}

/* =========================================================
   3. ПАНЕЛЬ УПРАВЛЕНИЯ ТАБЛИЦЕЙ
   ========================================================= */

/* ---------------------------------------------------------
   3.1 Общая панель
   --------------------------------------------------------- */

.table-analysis-toolbar {
    width: max-content;
    min-width: 100%;

    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-bottom: 8px;

    box-sizing: border-box;
}
/* ---------------------------------------------------------
   3.2 Переключатель:
       Абсолютные / Относительные
   --------------------------------------------------------- */

.value-mode-switch {
    display: inline-flex;
    align-items: center;

    gap: 6px;

    margin-left: 15px;
    padding: 4px 8px;

    border: 1px solid #c8c8c8;
    border-radius: 6px;

    background: #f5f5f5;
}

.value-mode-option {
    border: none;
    background: transparent;

    padding: 5px 9px;

    font-size: 14px;
    font-weight: 500;

    color: #777;

    cursor: pointer;

    border-radius: 4px;

    transition:
        background-color 0.15s ease,
        color 0.15s ease;
}

.value-mode-option:hover {
    color: #333;
}

.value-mode-option.active {
    background: #fff;

    color: #222;
    font-weight: 600;

    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.value-mode-divider {
    color: #aaa;
    user-select: none;
}


/* ---------------------------------------------------------
   3.3 Блок «Изменения»
   --------------------------------------------------------- */

.horizontal-analysis-controls {
    display: flex;
    align-items: center;

    gap: 8px;

    font-size: 14px;
}


/* Подпись «Изменения:» */

.horizontal-analysis-controls > label {
    color: #64748b;

    font-weight: 600;

    white-space: nowrap;
}

/* =========================================================
   3.4 Блок горизонтального анализа в таблице
   ========================================================= */

/* Левая граница блока Δ */
.data-table th.horizontal-analysis-cell:first-of-type,
.data-table td[data-horizontal-abs] {
    border-left: 2px solid #cbd5e1;
}


/* Фон всего блока анализа */
.data-table th.horizontal-analysis-cell,
.data-table td.horizontal-analysis-cell {
    background: #f8fafc;
}


/* Заголовки блока */
.data-table th.horizontal-analysis-cell {
    color: #475569;
    font-weight: 600;
}


/* Правая граница блока */
.data-table th.horizontal-analysis-percent,
.data-table td.horizontal-analysis-percent {
    border-right: 2px solid #cbd5e1;
}


/* ---------------------------------------------------------
   Нормативы: Δ, bp — компактный последний столбец
   --------------------------------------------------------- */

#section-normatives
.data-table th.change-cell,
#section-normatives
.data-table td.change-cell.normative-change {
    background: #f8fafc;
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    box-sizing: border-box;
    white-space: nowrap;
}

/* Заголовок делаем немного компактнее */
#section-normatives
.data-table th.change-cell {
    font-size: 13px;
    padding-left: 6px;
    padding-right: 6px;
}

/* Значения изменения */
#section-normatives
.data-table td.change-cell.normative-change {
    padding-left: 6px;
    padding-right: 6px;
}

/* Левая граница столбца изменения */
#section-normatives
.data-table_normative th.change-cell,
#section-normatives
.data-table_normative td.change-cell.normative-change {
    border-left: 2px solid #cbd5e1;
}

/* Названия нормативов: освобождаем место для истории */
#section-normatives
.data-table_normative th:first-child,
#section-normatives
.data-table_normative td:first-child {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    white-space: normal;
    overflow-wrap: break-word;
}

/* Названия разделов нормативов не переносятся */
#section-normatives
.data-table_normative tr.level-0 td:first-child {
    white-space: nowrap;
    position: relative;
    z-index: 1;
}

/* ---------------------------------------------------------
   3.4 Основной селектор режима
   --------------------------------------------------------- */

#horizontal-analysis-mode {
    appearance: none;
    -webkit-appearance: none;

    min-width: 150px;

    padding: 7px 34px 7px 12px;

    border: 1px solid #dbe2ea;
    border-radius: 8px;

    background-color: #ffffff;

    color: #334155;

    font-family: 'Source Sans Pro', sans-serif;
    font-size: 14px;
    font-weight: 600;

    cursor: pointer;
    outline: none;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background-color 0.2s ease;

    /* стрелка */

    background-image:
        linear-gradient(45deg, transparent 50%, #64748b 50%),
        linear-gradient(135deg, #64748b 50%, transparent 50%);

    background-position:
        calc(100% - 15px) 50%,
        calc(100% - 10px) 50%;

    background-size:
        5px 5px,
        5px 5px;

    background-repeat: no-repeat;
}

#horizontal-analysis-mode:hover {
    border-color: #93c5d8;
    background-color: #f8fafc;
}

#horizontal-analysis-mode:focus {
    border-color: #7aaec2;

    box-shadow:
        0 0 0 3px rgba(122, 174, 194, 0.14);
}


/* ---------------------------------------------------------
   3.5 Пользовательские даты
   --------------------------------------------------------- */

.horizontal-custom-dates {
    display: none;

    grid-template-columns: auto auto;

    row-gap: 4px;
    column-gap: 8px;

    align-items: center;
}


/* Подписи двух дат */

.horizontal-custom-dates label {
    color: #64748b;

    font-size: 14px;
    font-weight: 500;

    white-space: nowrap;
}


/* Селекторы дат */

.horizontal-custom-dates select {
    min-width: 110px;

    padding: 6px 28px 6px 10px;

    border: 1px solid #dbe2ea;
    border-radius: 7px;

    background: #ffffff;

    color: #334155;

    font-family: 'Source Sans Pro', sans-serif;
    font-size: 14px;

    cursor: pointer;
    outline: none;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.horizontal-custom-dates select:hover {
    border-color: #93c5d8;
}

.horizontal-custom-dates select:focus {
    border-color: #7aaec2;

    box-shadow:
        0 0 0 3px rgba(122, 174, 194, 0.14);
}
/* =========================================================
   4. STICKY - КОЛОНКИ
   ========================================================= */

.data-table th:first-child,
.data-table td:first-child {
    position: sticky;
    left: 0;

    width: 350px;
    min-width: 350px;
    max-width: 350px;

    box-sizing: border-box;

    z-index: 10;
}

.data-table thead th:first-child {
    position: sticky;
    left: 0;

    z-index: 30;
    background-color: #f0f4f8;
}

.data-table thead th {
    position: sticky;
    top: 0;

    background-color: #f0f4f8;

    border-top: 1px solid #dbe2ea;
    z-index:20;
}

.data-table thead th.date-cell {
    scroll-snap-align: start;
}

/* =========================================================
   5. Иерархия таблицы level-0 ... level-5
   ========================================================= */
/* 1. Курсор для открываемых строк (без non-opening) */
.data-table tbody tr.level-0:not(.non-opening) td:first-child,
.data-table tbody tr.level-1:not(.non-opening) td:first-child,
.data-table tbody tr.level-2:not(.non-opening) td:first-child,
.data-table tbody tr.level-3:not(.non-opening) td:first-child,
.data-table tbody tr.level-4:not(.non-opening) td:first-child {
  cursor: pointer;
  user-select: yes; /* Запрещаем выделение при клике */
}

/* 2. Курсор для неоткрываемых строк (с non-opening) */
.data-table tbody tr.non-opening td:first-child {
  cursor: default;
}


/*  cursor: url('/static/css/images/account.png'), auto; */
.data-table tbody td#drill-down:hover {
  background-color: #f0f8ff; /* Лёгкий голубой оттенок */
  transition: background-color 0.3s;
}

.data-table tbody tr td:first-child:hover ~ td,
.data-table tbody tr td:first-child:hover {
  background: #ffffff;
  color: #3b82a0;
  transform: scale(1.02) translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  z-index: 11;
}

.data-table tbody tr td:first-child:hover ~ td .text-muted {
  color: #6fa3b8;
}

/* Уровень 0 — основные разделы */
.level-0 td:first-child {
    text-align: right;
}

/* Выделение основных разделов */
.data-table tbody tr.level-0 td {
    border-bottom: 2px solid #cbd5e1;
}

.finres-section-divider td {
    border-bottom: 2px solid #cbd5e1;
}

/* Уровень 1 — основные разделы */
.level-1 td:first-child {
    font-weight: 700;
    background-color: #e9f2fa;
    padding-left: 8px;
    border-left: 3px solid #2c8ebc;
}

.level-1 td {
    padding-top: 14px;
    padding-bottom: 14px;
}


/* Уровень 2 — подразделы */
.level-2 td:first-child {
    font-weight: 600;
    color: #1a5f8c;
    padding-left: 28px;
    background-color: #f5f9fd;
    text-align: right;
}

.level-2 td {
    padding-top: 10px;
    padding-bottom: 10px;
}

.level-2 td.reserv {
    color: #990000;
    font-weight: 600;
}


/* Уровень 3 — детализация */
.level-3 td:first-child {
    font-weight: 400;
    color: #4a5c66;
    padding-left: 48px;
    background-color: #fdfdfd;
}

.level-3 td {
    padding-top: 8px;
    padding-bottom: 8px;
}

.level-3 td.reserv {
    color: #990000;
    font-weight: 400;
}


/* Уровень 4 — глубокая детализация */
.level-4 td:first-child {
    font-weight: 400;
    color: #56666f;
    padding-left: 68px;
    background-color: #f7f9fa;
    font-style: italic;

    /* визуальная линия иерархии */
    border-left: 2px solid #d8e0e5;
}

.level-4 td {
    padding-top: 6px;
    padding-bottom: 6px;
}

.level-4 td.reserv {
    color: #990000;
    font-weight: 400;
}


/* Уровень 5 — конечный элемент */
.level-5 td:first-child {
    font-weight: 400;
    color: #6c7a82;
    padding-left: 88px;
    background-color: #f1f4f6;
    font-style: italic;

    /* продолжение линии иерархии */
    border-left: 2px solid #d8e0e5;
}

.level-5 td {
    padding-top: 5px;
    padding-bottom: 5px;
}

.level-5 td.reserv {
    color: #990000;
    font-weight: 400;
}
/* =========================================================
   6. ДОПОЛНИТЕЛЬНЫЕ СОСТОЯНИЯ ТАБЛИЦ
   ========================================================= */
/* Текст "нет данных" и нули */
.text-muted {
  color: #888;
  opacity: 0.8;
}


.data-table td.reserv {
  background-color: #ffe6e6;
  font-weight: 500;
}

/* Для чисел — моноширинный интервал (опционально) 
.data-table td:not(:first-child) {
  font-family: 'Consolas', 'Courier New', monospace;
  letter-spacing: 0.3px;
}

.level-2, .level-3 {
  display: table-row; /* Нормальное состояние таблицы */
  overflow: visible;
}
/* =========================================================
   7. ВКЛАДКИ
   ========================================================= */

/* Контейнер вкладок */
.tab-container {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 4px 4px 0 0;
    border: 1px solid #ddd;
    border-bottom: none;
}

/* Кнопки вкладок */
.tab-btn {
    padding: 12px 20px;
    margin: 0 5px -1px 0;
    background: #e9ecef;
    border: 1px solid #dee2e6;
    border-bottom: none;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: white;
    border-color: #dee2e6;
    border-bottom: 2px solid #007bff;
    color: #007bff;
}

.tab-btn:hover:not(.active) {
    background: #dde2e6;
}

/* Контейнеры контента */
.tab-content {
    display: none;
    position: relative;

    width: auto;
    max-width: none;
    min-width: 0;

    padding: 20px;

    border: none;

    min-height: 300px;

    box-sizing: border-box;
}

.tab-content.active {
    display: block;
}

.value-absolute {
    display: inline;
}

.value-percent {
    display: none;
}

.value-mode-toggle {
    cursor: pointer;
}
/* =========================================================
   8. СТИЛИ ДЛЯ КАРТОЧКИ С РЕЙТИНГАМИ
   ========================================================= */

.card-main-area {
    display: flex;
    align-items: stretch;
    flex: 1;
    min-width: 0;
}

.card-info {
    flex: 0 0 500px;
    width: 500px;
}

.card-ratings {
    flex: 0 0 270px;

    margin-left: 28px;
    padding-left: 24px;

    border-left: 1px solid #e5eaf7;

    align-self: stretch;
}

.ratings-title {
    font-size: 15px;
    font-weight: 600;
    color: #64748b;

    text-transform: uppercase;
    letter-spacing: 0.7px;

    margin-bottom: 12px;
}

.rating-item {
    display: grid;

    grid-template-columns: 140px 1fr;

    padding: 8px 0;

    border-bottom: 1px solid #eef2f7;
}

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

.rating-agency {
    grid-row: 1 / 3;

    display: flex;
    align-items: center;
    color: #64748b;
    font-size: 0.925rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.rating-value {
    font-size: 16px;
    font-weight: 700;

    color: #2563eb;

    line-height: 1.1;

    text-decoration: none;
    cursor: pointer;
}

.rating-value a,
.rating-value a:visited {
    color: #2563eb;
    text-decoration: none;
    cursor: pointer;
}

.rating-value a:hover {
    text-decoration: underline;
}


.rating-details {
    display: flex;
    gap: 8px;

    margin-top: 3px;

    font-size: 15px;
    color: #94a3b8;
}


/* =========================================================
   9. ОШИБКА ЧЕРЕЗ ERROR
   ========================================================= */

.mars-error {
    font-family: "Manrope", sans-serif;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    margin: 20px 0;
    background: #fff5f5;
    border: 1px solid #f2cccc;
    border-left: 4px solid #dc3545;
    border-radius: 10px;
    color: #343a40;
}

.mars-error__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: #fde2e2;
    color: #c62828;
    border-radius: 10px;
    font-size: 17px;
}

.mars-error__content {
    min-width: 0;
}

.mars-error__title {
    margin-bottom: 5px;
    font-size: 16px;
    font-weight: 600;
    color: #a61e2d;
}

.mars-error__text {
    font-size: 14px;
    line-height: 1.5;
}

.mars-error__hint {
    margin-top: 8px;
    font-size: 12px;
    color: #6c757d;
}

/* =========================================================
   10. ПОДСВЕТКА НАРУШЕНИЙ ТАБЛИЦЫ С НОРМАТИВАМИ
   ========================================================= */

/* Нарушение обязательного норматива */
.data-table_normative td.normative-violation {
    background-color: #f8d7da;
    color: #842029;
}

/* Приближение к границе норматива */
.data-table_normative td.normative-approaching {
    background-color: #fff3cd;
    color: #664d03;
}

/* без проверки, т.к. нет данных о лицензии */
.data-table_normative td.normative-unchecked {
    background-color: #f1f3f5;
    color: #495057;
    text-decoration: underline dotted;
    text-decoration-color: #98a2b3;
    text-underline-offset: 3px;
}


/* =========================================================
   11. ИНТЕРАКТИВНЫЙ ПОЛЗУНОК
   ========================================================= */

/* Ползунок порога предупреждения нормативов */
.normative-threshold-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 0px;
    white-space: nowrap;
    font-size: 13px;
    color: var(--text-color, #344054);
}

.normative-threshold-control label {
    margin: 0;
    font-weight: 500;
}

#normative-threshold-slider {
    --slider-progress: 100%;

    appearance: none;
    -webkit-appearance: none;
    width: 110px;
    height: 4px;
    margin: 0;
    border: none;
    border-radius: 4px;
    outline: none;
    cursor: pointer;

    background: linear-gradient(
        to right,
        #3978d4 0%,
        #3978d4 var(--slider-progress),
        #d9e1ed var(--slider-progress),
        #d9e1ed 100%
    );
}

/* Бегунок Chrome / Edge */
#normative-threshold-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: #3978d4;
    box-shadow: 0 0 0 1px #3978d4;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

#normative-threshold-slider::-webkit-slider-thumb:hover {
    transform: scale(1.12);
    box-shadow: 0 0 0 3px rgba(57, 120, 212, 0.18);
}

/* Бегунок Firefox */
#normative-threshold-slider::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: #3978d4;
    box-shadow: 0 0 0 1px #3978d4;
}

#normative-threshold-slider::-moz-range-track {
    height: 4px;
    border-radius: 4px;
    background: #d9e1ed;
}

#normative-threshold-slider::-moz-range-progress {
    height: 4px;
    border-radius: 4px;
    background: #3978d4;
}

#normative-threshold-slider:focus-visible {
    outline: 2px solid rgba(57, 120, 212, 0.35);
    outline-offset: 5px;
}

#normative-threshold-value {
    display: inline-block;
    min-width: 34px;
    color: #3978d4;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* =========================================================
   НОРМАТИВЫ: СЛУЖЕБНЫЕ СТОЛБЦЫ
   ========================================================= */

/* Минимальное и максимальное значения норматива */
#section-normatives
.data-table_normative th.normative-limit-cell,
#section-normatives
.data-table_normative td.normative-limit-cell {
    background-color: #f0eff8;
    color: #475569;
}

/* Расчётный порог предупреждения */
#section-normatives
.data-table_normative th.normative-signal-cell,
#section-normatives
.data-table_normative td.normative-signal-cell {
    background-color: #fff7e6;
    color: #854d0e;
    border-right: 2px solid #b8c5d6;
}

/* Единое отображение чисел */
#section-normatives
.data-table_normative td.normative-limit-cell,
#section-normatives
.data-table_normative td.normative-signal-cell {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}


/* =========================================================
   12. Адаптивность под гаджеты
   ========================================================= */
/* Адаптивность: минимальный размер ячеек */
@media (max-width: 768px) {
    .data-table td,
    .data-table th {
        padding: 8px 10px;
        font-size: 0.9rem;
    }

    /* Первый столбец на мобильных */
    .data-table th:first-child,
    .data-table td:first-child {
        width: 240px;
        min-width: 240px;
        max-width: 240px;
    }
}
