/* Хронология и статистика workspace.
   Цвета направлений — проверенные шаги палитры для тёмной поверхности #111c30 (валидатор: все проверки пройдены);
   оттенки совпадают с бейджами источников на доске: банкротство — красный, арбитраж — синий, ФССП — жёлтый,
   суды общей юрисдикции — зелёный. Текст никогда не окрашивается цветом данных. */

.ins,
.ws-view-switch {
    --ins-surface: #111c30;
    --ins-plane: #0b1220;
    --ins-text: #e5edf8;
    --ins-text-2: #b8c7dc;
    --ins-muted: #8a99b3;
    --ins-grid: #1e2a3f;
    --ins-axis: #2c3b55;
    --ins-border: rgba(255, 255, 255, .08);

    --ic-bankruptcy: #e66767;
    --ic-arbitration: #3987e5;
    --ic-fssp: #c98500;
    --ic-courts: #199e70;

    --ic-respondent: #d95926;
    --ic-plaintiff: #3987e5;
    --ic-other: #199e70;
    --ic-unconfirmed: #64748b;
    --ic-active: #c98500;
    --ic-finished: #64748b;

    --st-critical: #d03b3b;
    --st-serious: #ec835a;
    --st-warning: #fab219;
    --st-good: #0ca30c;
}

.ic-s-bankruptcy { background: var(--ic-bankruptcy); }
.ic-s-arbitration { background: var(--ic-arbitration); }
.ic-s-fssp { background: var(--ic-fssp); }
.ic-s-courts { background: var(--ic-courts); }
.ic-s-respondent { background: var(--ic-respondent); }
.ic-s-plaintiff { background: var(--ic-plaintiff); }
.ic-s-other { background: var(--ic-other); }
.ic-s-unconfirmed { background: var(--ic-unconfirmed); }
.ic-s-active { background: var(--ic-active); }
.ic-s-finished { background: var(--ic-finished); }

/* ---- Переключатель видов в шапке доски ---- */

.ws-view-switch {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 10px;
    background: var(--ins-plane);
    border: 1px solid #263449;
}

.ws-view-switch button {
    padding: 6px 14px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ins-text-2);
    font-weight: 600;
}

.ws-view-switch button.active {
    background: #2563eb;
    color: #fff;
}

.ws-board-title {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.ws-insights-host {
    flex: 1;
    min-width: 0;
    contain: inline-size;
    min-height: 0;
    overflow-y: auto;
    background: var(--ins-plane);
}

/* ---- Общая рамка ---- */

.ins {
    padding: 16px 20px 28px;
    color: var(--ins-text);
}

.ins-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.ins-bar select,
.tl-filters select,
.tl-search {
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #020617;
    color: var(--ins-text);
}

.ins-refresh {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #1f2937;
    color: var(--ins-text);
}

.ins-hint,
.tl-summary {
    color: var(--ins-muted);
    font-size: 13px;
}

/* Перезагрузка держит прежнюю картинку — без мигания и скачка вёрстки. */
.is-refetching {
    opacity: .55;
    transition: opacity .15s;
}

/* ---- Хронология ---- */

.tl-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin-bottom: 14px;
    border-radius: 12px;
    background: var(--ins-surface);
    border: 1px solid var(--ins-border);
}

.tl-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid #334155;
    background: transparent;
    color: var(--ins-muted);
}

.tl-chip.is-on {
    color: var(--ins-text);
    background: #1e293b;
    border-color: #475569;
}

.tl-chip b {
    color: var(--ins-text-2);
    font-weight: 600;
}

.tl-chip:disabled {
    opacity: .45;
}

.tl-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ins-text-2);
    margin: 0 4px;
    font-size: 13px;
}

.tl-search {
    flex: 1;
    min-width: 220px;
}

.tl-dot {
    flex: none;
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--ins-plane);
}

.tl-empty {
    color: var(--ins-muted);
    padding: 24px 4px;
}

.tl-year h4 {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 18px 0 6px;
    padding: 6px 0;
    background: var(--ins-plane);
    font-size: 18px;
}

.tl-year h4 span {
    margin-left: 8px;
    color: var(--ins-muted);
    font-size: 13px;
    font-weight: 500;
}

.tl-list {
    list-style: none;
    margin: 0;
    padding: 0 0 0 4px;
    border-left: 1px solid var(--ins-axis);
}

.tl-item {
    display: grid;
    grid-template-columns: 92px 14px 1fr auto;
    gap: 10px;
    align-items: start;
    padding: 9px 10px 9px 12px;
    border-radius: 10px;
}

.tl-item:hover {
    background: rgba(148, 163, 184, .07);
}

.tl-item .tl-dot {
    margin-top: 5px;
}

.tl-date {
    color: var(--ins-text-2);
    font-variant-numeric: tabular-nums;
    padding-top: 1px;
}

.tl-title {
    color: var(--ins-text);
}

.tl-item.is-key .tl-title {
    font-weight: 600;
}

.tl-detail {
    margin-top: 2px;
    color: var(--ins-text-2);
    font-size: 13px;
    line-height: 1.4;
}

.tl-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
    color: var(--ins-muted);
    font-size: 12px;
}

.tl-case {
    color: var(--ins-text-2);
}

.tl-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    white-space: nowrap;
}

.tl-actions button,
.tl-actions a {
    padding: 4px 9px;
    border-radius: 7px;
    border: 1px solid #334155;
    background: transparent;
    color: #93c5fd;
    font-size: 13px;
    text-decoration: none;
}

/* ---- Статистика ---- */

.sv-note {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(250, 178, 25, .45);
    background: rgba(250, 178, 25, .08);
    color: var(--ins-text);
}

.sv-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.sv-tile {
    position: relative;
    padding: 14px 16px 14px 18px;
    border-radius: 12px;
    background: var(--ins-surface);
    border: 1px solid var(--ins-border);
    overflow: hidden;
}

.sv-tile::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
}

.sv-tile.is-critical::before { background: var(--st-critical); }
.sv-tile.is-serious::before { background: var(--st-serious); }
.sv-tile.is-warning::before { background: var(--st-warning); }
.sv-tile.is-good::before { background: var(--st-good); }

.sv-tile-label {
    color: var(--ins-text-2);
    font-size: 13px;
}

.sv-tile-value {
    margin-top: 6px;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
}

.sv-tile-note {
    margin-top: 6px;
    color: var(--ins-text-2);
    font-size: 13px;
    line-height: 1.4;
}

.sv-tile-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    color: var(--ins-text-2);
    font-size: 12px;
}

.sv-tile-status i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.sv-tile.is-critical .sv-tile-status i { background: var(--st-critical); }
.sv-tile.is-serious .sv-tile-status i { background: var(--st-serious); }
.sv-tile.is-warning .sv-tile-status i { background: var(--st-warning); }
.sv-tile.is-good .sv-tile-status i { background: var(--st-good); }

.sv-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 12px;
}

/* ---- График ---- */

.ic {
    margin: 0;
    padding: 16px 18px;
    border-radius: 12px;
    background: var(--ins-surface);
    border: 1px solid var(--ins-border);
}

.ic-head h4 {
    margin: 0;
    font-size: 15px;
}

.ic-head p {
    margin: 4px 0 0;
    color: var(--ins-muted);
    font-size: 12px;
}

.ic-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin: 10px 0 2px;
    color: var(--ins-text-2);
    font-size: 12px;
}

.ic-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ic-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.ic-seg {
    display: block;
    flex-basis: 0;
    min-width: 2px;
    min-height: 2px;
    outline: none;
}

.ic-seg:hover,
.ic-seg:focus-visible {
    filter: brightness(1.25);
}

/* Полосы: тонкие, растут от одной базовой линии, скругление 4px только у конца. */
.ic-bars {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.ic-bar-row {
    display: grid;
    grid-template-columns: minmax(120px, 36%) 1fr;
    gap: 12px;
    align-items: center;
}

.ic-bar-label {
    color: var(--ins-text-2);
    font-size: 13px;
    line-height: 1.3;
}

.ic-bar-plot {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    border-left: 1px solid var(--ins-axis);
}

.ic-bar-fill {
    display: flex;
    gap: 2px;
    height: 16px;
    min-width: 2px;
}

.ic-bar-fill > .ic-seg {
    height: 100%;
}

.ic-bar-fill > .ic-seg:last-child {
    border-radius: 0 4px 4px 0;
}

.ic-bar-value {
    flex: none;
    color: var(--ins-text);
    font-size: 13px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Столбцы по годам. */
.ic-cols {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    margin-top: 14px;
}

.ic-cols-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 180px;
    padding: 0 0 22px;
    margin-top: 20px;
    color: var(--ins-muted);
    font-size: 11px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.ic-cols-axis span {
    line-height: 0;
}

.ic-cols-plot {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 4px;
    box-sizing: border-box;
    height: 222px;
    padding-top: 20px;
}

/* Шкала: 180px области графика над полосой подписей годов 22px; сетка — на 100% и 50% шкалы. */
.ic-grid {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    border-top: 1px solid var(--ins-grid);
}

.ic-col {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    min-width: 0;
    box-sizing: border-box;
    padding-bottom: 22px;
}

.ic-col::after {
    content: "";
    position: absolute;
    left: -2px;
    right: -2px;
    bottom: 22px;
    border-top: 1px solid var(--ins-axis);
}

.ic-col-bar {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
}

.ic-col-stack {
    display: flex;
    flex-direction: column-reverse;
    gap: 2px;
    width: min(24px, 70%);
    height: 100%;
}

.ic-col-stack > .ic-seg {
    width: 100%;
}

.ic-col-stack > .ic-seg:last-child {
    border-radius: 4px 4px 0 0;
}

.ic-col-total {
    position: absolute;
    bottom: 100%;
    margin-bottom: 3px;
    color: var(--ins-text);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.ic-col-label {
    position: absolute;
    bottom: 0;
    color: var(--ins-muted);
    font-size: 11px;
    white-space: nowrap;
}

/* Таблица-двойник каждого графика. */
.ic-table {
    margin-top: 12px;
}

.ic-table summary {
    cursor: pointer;
    color: #93c5fd;
    font-size: 13px;
}

.ic-table table {
    width: 100%;
    margin-top: 8px;
    border-collapse: collapse;
    font-size: 13px;
}

.ic-table th,
.ic-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--ins-grid);
    text-align: left;
    color: var(--ins-text-2);
}

.ic-table th {
    color: var(--ins-muted);
    font-weight: 600;
}

.ic-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--ins-text);
}

/* Подсказка со значением: значение крупно, подпись следом. */
.ins-tooltip {
    position: fixed;
    z-index: 1000;
    display: none;
    max-width: 320px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #020617;
    color: #e5edf8;
    font-size: 12px;
    line-height: 1.4;
    pointer-events: none;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .45);
}

.ins-tooltip b {
    display: block;
    font-size: 14px;
}

@media (max-width: 900px) {
    .sv-charts { grid-template-columns: 1fr; }
    .tl-item { grid-template-columns: 80px 14px 1fr; }
    .tl-actions { grid-column: 3; }
}

/* ---- Лента событий (хронология в формате доски) ----
   Всё помещается по высоте области: фильтры сверху, лента занимает остаток, дорожки делят его поровну.
   Вертикальной прокрутки нет — только горизонтальная (колесо, перетаскивание, стрелки). */

.ws-insights-host {
    display: flex;
    flex-direction: column;
}

/* Хронология и статистика после первого открытия остаются на странице: неактивная «запаркована» невидимой поверх
   области (visibility, а не display:none) — компонент хранит закладку и фильтры, браузер — прокрутку. */
.ws-board-body {
    position: relative;
}

.ws-insights-host.is-parked {
    position: absolute;
    inset: 0;
    z-index: -1;
    visibility: hidden;
    pointer-events: none;
}

.ins {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.ins-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* В режиме ленты область не прокручивается по вертикали вовсе. */
.ins-content:has(> .tl.is-board) {
    overflow: hidden;
}

.tl.is-board {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.tl.is-board .tl-filters {
    flex: none;
}

.tl-mode {
    margin-right: 6px;
}

.tb {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    outline: none;
}

/* В режиме списка лента остаётся на странице спрятанной — со своей закладкой. */
.tl:not(.is-board) > .tb {
    display: none;
}

.tb-scroll {
    contain: inline-size;
    box-sizing: border-box;
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 12px;
    border: 1px solid var(--ins-border);
    background: var(--ins-plane);
    cursor: grab;
    user-select: none;
}

/* Новая лента не видна, пока не встанет на закладку: открывается сразу на месте, без прокрутки от начала. */
.tb-scroll:not([data-placed]) > .tb-grid {
    visibility: hidden;
}

.tb-scroll.is-dragging {
    cursor: grabbing;
}

.tb-grid {
    display: grid;
    height: 100%;
    min-width: max-content;
}

.tb-lane-head {
    position: sticky;
    left: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    background: var(--ins-surface);
    border-right: 1px solid var(--ins-axis);
    border-bottom: 1px solid var(--ins-grid);
    color: var(--ins-text);
    font-size: 13px;
}

.tb-lane-head b {
    margin-left: auto;
    color: var(--ins-muted);
    font-weight: 500;
}

.tb-cell {
    position: relative;
    display: flex;
    gap: 8px;
    min-height: 0;
    padding: 14px 8px 8px;
    border-bottom: 1px solid var(--ins-grid);
}

/* Смена года — тонкий разделитель с меткой года (вместо шкалы времени сверху). */
.tb-cell.is-year-start {
    border-left: 1px solid var(--ins-axis);
}

.tb-year {
    position: absolute;
    top: 0;
    left: 6px;
    z-index: 2;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--ins-plane);
    color: var(--ins-muted);
    font-size: 11px;
    font-weight: 600;
}

.tb-card {
    position: relative;
    flex: none;
    width: 176px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 0;
    overflow: hidden;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #263449;
    border-left: 3px solid transparent;
    background: var(--ins-surface);
    cursor: pointer;
}

.tb-card.lane-bankruptcy { border-left-color: var(--ic-bankruptcy); }
.tb-card.lane-arbitration { border-left-color: var(--ic-arbitration); }
.tb-card.lane-fssp { border-left-color: var(--ic-fssp); }
.tb-card.lane-courts { border-left-color: var(--ic-courts); }

.tb-card time {
    color: var(--ins-text-2);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.tb-card-title {
    color: var(--ins-text);
    font-size: 13px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tb-card.is-key .tb-card-title {
    font-weight: 600;
}

/* На карточке с закладкой место под кнопки — название в две строки. */
.tb-card.is-bookmark .tb-card-title {
    -webkit-line-clamp: 2;
}

.tb-card-case {
    color: var(--ins-muted);
    font-size: 11px;
}

/* Закладка: текущее событие — подсвечено, с лентой-закладкой и действиями. */
.tb-card.is-bookmark {
    border-color: #60a5fa;
    background: #13243f;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, .35);
}

.tb-ribbon {
    position: absolute;
    top: 0;
    right: 10px;
    width: 12px;
    height: 18px;
    background: #60a5fa;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
}

.tb-card-actions {
    display: flex;
    gap: 6px;
    margin-top: auto;
    padding-top: 4px;
}

.tb-card-actions button,
.tb-card-actions a {
    padding: 2px 7px;
    border-radius: 6px;
    border: 1px solid #334155;
    background: #0b1220;
    color: #93c5fd;
    font-size: 12px;
    text-decoration: none;
}

/* Стрелки по краям ленты: от события к событию. */
.tb-arrow {
    position: absolute;
    top: 50%;
    z-index: 5;
    width: 38px;
    height: 38px;
    margin-top: -19px;
    border-radius: 50%;
    border: 1px solid #475569;
    background: rgba(15, 23, 42, .92);
    color: #e5edf8;
    font-size: 14px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}

.tb-arrow.is-prev { left: 158px; }
.tb-arrow.is-next { right: 10px; }

.tb-arrow:disabled {
    opacity: .3;
}
