:root {
    --timeline-gap: 8px;
    --timeline-grid: 1fr 1.5fr 2fr 2fr 1.5fr 2fr;
    --header-bg: #f0f0f3; /* светло-серый фон шапки */
    --body-bg: #f5f5f7;
    --border-color: #dddddd;
    --accent: #e53935;
    --accent-soft: #ffe6e6;
    --text-main: #222222;
    --text-muted: #777777;
    --radius: 8px;
    --shadow-soft: 0 4px 10px rgba(0, 0, 0, 0.04);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        sans-serif;
    color: var(--text-main);
    background: var(--body-bg);
}

/* ОБЩИЙ КОНТЕЙНЕР — НА ВСЮ ШИРИНУ */

.timeline {
    width: 100%;
    margin: 0;
    padding: 16px;
}

/* ФИКСИРОВАННАЯ ШАПКА */

.timeline-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--header-bg);
    padding: 12px 12px 10px;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-soft);
}

/* ТЕМА */

.timeline-topic {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.timeline-topic label {
    font-size: 14px;
    font-weight: 600;
}

.timeline-topic input {
    flex: 1;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    font-size: 14px;
}

/* ШАПКА КОЛОНОК */

.timeline-columns {
    display: grid;
    grid-template-columns: var(--timeline-grid);
    gap: var(--timeline-gap);
}

.col-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    text-align: center;
    font-size: 13px;
    padding-bottom: 4px;
}

.col-header-title {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 13px;
}

.col-toggle {
    align-self: center;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #fafafa;
    cursor: pointer;
}

.col-toggle:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}

/* ВЕРТИКАЛЬНЫЕ ЛИНИИ В ШАПКЕ */

.col-header-date {
    position: relative;
    border-right: 2px solid #b0b0b0; /* толстая сплошная */
    padding-right: 8px;
}

.col-header-event,
.col-header-causes,
.col-header-result,
.col-header-actors,
.col-header-summary {
    border-right: 1px dashed #cfcfcf; /* тонкая пунктирная */
    padding: 0 8px;
}

/* последний столбец "Комментарий" без правой границы */
.col-header-comment {
    padding-left: 8px;
}


/* КНОПКИ < и > В ШАПКЕ (на границе между датой и событием) */

.header-tools {
    position: absolute;
    top: 24px;              /* можно подрегулировать по вкусу */
    left: 100%;             /* на правую границу ячейки */
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    pointer-events: auto;
}

/* ТЕЛО ТАЙМЛАЙНА */

.timeline-body {
    margin-top: 12px;
}

/* ОДНА СТРОКА */

.timeline-row {
    display: grid;
    grid-template-columns: var(--timeline-grid);
    gap: var(--timeline-gap);
    margin-bottom: 8px;
    background: #ffffff;
    border-radius: var(--radius);
    border: 1px solid #eeeeee;
    padding: 8px 0;
    box-shadow: var(--shadow-soft);
}

/* ВЕРТИКАЛЬНЫЕ ЛИНИИ В СТРОКАХ */

.timeline-cell {
    font-size: 14px;
    line-height: 1.4;
    padding: 0 21px;
    display: flex;
    justify-content: space-between;
}

.timeline-cell .cell-value {
    white-space: pre-wrap;
}

/* первая граница между датой и событием — толстая сплошная */
.timeline-row .col-date {
    position: relative;
    border-right: 2px solid #b0b0b0;
    padding-right: 8px;
	    margin-right: -10px;
}

/* отступ текста от кнопок в колонке даты */
.timeline-row .col-date .cell-value {
    display: block;
    padding-right: 18px;
}

.timeline-row .col-event,
.timeline-row .col-causes,
.timeline-row .col-result,
.timeline-row .col-actors,
.timeline-row .col-summary {
    border-right: 1px dashed #cfcfcf;
}

/* Дерево тематических сущностей */
.tl-tree {
    margin-bottom: 20px;
}

.tl-tree-group {
    border: 1px solid #eee;
    border-radius: 6px;
    margin-bottom: 12px;
    background: #fff;
}

.tl-tree-group-header {
    padding: 8px 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.tl-tree-arrow {
    display: inline-block;
    width: 14px;
    margin-right: 6px;
    transition: transform 0.2s ease;
}

.tl-tree-group.collapsed .tl-tree-arrow {
    transform: rotate(-90deg);
}

.tl-tree-group-body {
    border-top: 1px solid #eee;
    padding: 6px 0;
}

.tl-tree-group.collapsed .tl-tree-group-body {
    display: none;
}

.tl-tree-subgroup {
    padding: 4px 12px;
}

.tl-tree-subgroup + .tl-tree-subgroup {
    border-top: 1px solid #f5f5f5;
}

.tl-tree-subgroup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tl-tree-subgroup-title {
    font-size: 14px;
}

.tl-tree-subgroup.is-empty .tl-tree-subgroup-title {
    color: #888;
    font-style: italic;
}

.tl-tree-facts-list {
    list-style: disc;
    padding-left: 20px;
    margin: 6px 0 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tl-tree-fact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tl-tree-facts-actions {
    margin: 6px 0 0 18px;
}

.tl-tree-facts-actions .btn-link {
    padding-left: 0;
    font-size: 12px;
}

/* последняя колонка "Комментарий" без правой границы */
.timeline-row .col-comment {
    /* только внутренний отступ слева уже есть */
	
}


/* КНОПКИ < и > В СТРОКАХ НА ЛИНИИ */

.row-tools {
    position: absolute;
    top: 4px;
    left: 100%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    pointer-events: auto;
}

.row-btn {
    width: 20px;
    height: 20px;
    font-size: 12px;
    padding: 0;
    border-radius: 4px;
    border: 1px solid #bcbcbc;
    background: #e0e0e0;
    color: #555555;
    cursor: pointer;
}

.row-btn:hover {
    background: #d0d0d0;
    border-color: #9a9a9a;
}

/* активная кнопка */
.row-btn--active {
    background: #c6c6c6;
    border-color: #888888;
    color: #333333;
}

/* КНОПКА "ДОБАВИТЬ СОБЫТИЕ" */

.timeline-add-wrapper {
    display: flex;
    justify-content: center;
    margin: 16px 0 24px;
}

.add-event-btn {
    padding: 10px 26px;
    border-radius: 999px;
    border: none;
    background: var(--accent);
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.25);
}

.add-event-btn:hover {
    filter: brightness(1.05);
}

/* МОДАЛЬНОЕ ОКНО */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-out;
    z-index: 50;
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease-out;
    z-index: 51;
}

.modal-inner {
    width: min(640px, 100% - 32px);
    max-height: 90vh;
    overflow: auto;
    background: #ffffff;
    border-radius: 12px;
    padding: 16px 18px 18px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-field label {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
}

.modal-field input,
.modal-field textarea {
    width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 14px;
    resize: vertical;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 6px;
}

.btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid #ccc;
    background: #f5f5f5;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-main);
}

.btn:hover {
    background: #e8e8e8;
}

.btn-primary,
.btn-secondary {
    padding: 8px 18px;
    border-radius: 999px;
    border: none;
    font-size: 14px;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
}

.btn-secondary {
    background: #eeeeee;
    color: var(--text-main);
}

.btn-danger {
    border-color: #d32f2f;
    color: #d32f2f;
    background: #fff5f5;
}

.btn-primary:hover {
    filter: brightness(1.05);
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger:hover {
    background: #ffe5e5;
}

/* СОСТОЯНИЯ МОДАЛКИ */

.modal.is-open,
.modal-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* ───────────────── СКРЫТИЕ КОЛОНОК В ШАПКЕ ───────────────── */

/* Дата */

.timeline.hide-col-date .col-header-date {
    opacity: 0.15;
}

.timeline.hide-col-date .col-date {
    opacity: 0.15;
}

.timeline.hide-col-date .col-date .cell-value {
    visibility: hidden;
}

.timeline.hide-col-comment .col-header-comment {
    opacity: 0.15;
}

.timeline.hide-col-comment .col-comment {
    opacity: 0.15;
}

.timeline.hide-col-comment .col-comment .cell-value {
    visibility: hidden;
}


/* но если строка попросила явно показать дату — показываем её,
   даже когда колонка скрыта глобально */
.timeline.hide-col-date .timeline-row.row-force-show-date .col-date {
    opacity: 1;
}

.timeline.hide-col-date .timeline-row.row-force-show-date .col-date .cell-value {
    visibility: visible;
}

/* Событие */

.timeline.hide-col-event .col-header-event {
    opacity: 0.15;
}

.timeline.hide-col-event .col-event {
    opacity: 0.15;
}

.timeline.hide-col-event .col-event .cell-value {
    visibility: hidden;
}

/* Причины */

.timeline.hide-col-causes .col-header-causes {
    opacity: 0.15;
}

.timeline.hide-col-causes .col-causes {
    opacity: 0.15;
}

.timeline.hide-col-causes .col-causes .cell-value {
    visibility: hidden;
}

/* Результат */

.timeline.hide-col-result .col-header-result {
    opacity: 0.15;
}

.timeline.hide-col-result .col-result {
    opacity: 0.15;
}

.timeline.hide-col-result .col-result .cell-value {
    visibility: hidden;
}

/* Участники */

.timeline.hide-col-actors .col-header-actors {
    opacity: 0.15;
}

.timeline.hide-col-actors .col-actors {
    opacity: 0.15;
}

.timeline.hide-col-actors .col-actors .cell-value {
    visibility: hidden;
}

/* Итог / анализ */

.timeline.hide-col-summary .col-header-summary {
    opacity: 0.15;
}

.timeline.hide-col-summary .col-summary {
    opacity: 0.15;
}

.timeline.hide-col-summary .col-summary .cell-value {
    visibility: hidden;
}

/* Переопределение: если строка сказала "покажи правую часть",
   показываем все правые колонки в этой строке,
   даже если они скрыты глобальными кнопками в шапке. */

.timeline.hide-col-event  .timeline-row.row-force-show-rest .col-event,
.timeline.hide-col-causes .timeline-row.row-force-show-rest .col-causes,
.timeline.hide-col-result .timeline-row.row-force-show-rest .col-result,
.timeline.hide-col-actors .timeline-row.row-force-show-rest .col-actors,
.timeline.hide-col-summary .timeline-row.row-force-show-rest .col-summary ,
.timeline.hide-col-comment .timeline-row.row-force_show_rest .col-comment {
    opacity: 1;
}

.timeline.hide-col-event  .timeline-row.row-force-show-rest .col-event .cell-value,
.timeline.hide-col-causes .timeline-row.row-force-show-rest .col-causes .cell-value,
.timeline.hide-col-result .timeline-row.row-force-show-rest .col-result .cell-value,
.timeline.hide-col-actors .timeline-row.row-force-show-rest .col-actors .cell-value,
.timeline.hide-col-summary .timeline-row.row-force-show-rest .col-summary .cell-value,
.timeline.hide-col-comment .timeline-row.row-force_show_rest .col-comment .cell-value {
    visibility: visible;
}

/* ─────────────── СКРЫТИЕ ЧАСТИ ОДНОЙ СТРОКИ (кнопки < и >) ─────────────── */

.timeline-row.row-hide-date .col-date .cell-value {
    visibility: hidden;
}

.timeline-row.row-hide-rest .col-event .cell-value,
.timeline-row.row-hide-rest .col-causes .cell-value,
.timeline-row.row-hide-rest .col-result .cell-value,
.timeline-row.row-hide-rest .col-actors .cell-value,
.timeline-row.row-hide-rest .col-summary .cell-value,
.timeline-row.row-hide-rest .col-comment .cell-value {
    visibility: hidden;
}

/* АДАПТИВ */

@media (max-width: 960px) {
    :root {
        --timeline-grid: 1.1fr 1.4fr 1.8fr 1.8fr 1.3fr 1.8fr;
    }

    .timeline-topic {
        flex-direction: column;
        align-items: stretch;
    }
}


button.col-toggle.js-toggle-column {
    display: none;
}

/* --- Действия в строке события (иконки редактирования/удаления) --- */

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    vertical-align: middle;
	border-left: 1px dashed #cfcfcf;
}

.row-icon-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 999px;
    color: #757575;
}

.row-icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

.row-icon-delete {
    color: #e53935;
}

.row-icon-delete:hover {
    background: rgba(229, 57, 53, 0.08);
    color: #c62828;
}

.row-delete-form {
    display: inline;
}

.date-parts {
    background: #fafafa;
    border: 1px dashed #dcdcdc;
    border-radius: 6px;
    padding: 10px;
}

.date-parts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    align-items: end;
}

.date-parts-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #555;
}

.date-parts-item input,
.date-parts-item select {
    width: 100%;
    font-size: 14px;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #dcdcdc;
    box-sizing: border-box;
}

.checkbox-inline {
    font-weight: 600;
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.date-second-block {
    display: none;
}

.date-second-block.is-visible {
    display: block;
}

.date-preview {
    background: #f5f5f5;
    border-radius: 6px;
    border: 1px solid #e2e2e2;
    padding: 10px;
}

.date-preview-title {
    font-size: 12px;
    color: #777;
    margin-bottom: 4px;
}

.date-preview-value {
    font-weight: 600;
}


#timeline-body > div.timeline-row > div.timeline-cell.col-event {
    margin-right: -8px;
}

.timeline-cell.col-causes {
   margin-right: -4px;
}

.timeline-cell.col-actors {
    margin-right: 4px;
}

.timeline-cell.col-summary {
    margin-right: 8px;
}

ul.tl-tree-facts-list {
    padding-left: 200px;
}

button.btn.btn-xxs.btn-link.js-tl-fact-edit {
    margin-left: 200px;
}


.options {
    font-size: x-large;
}