.c9-history-modal .modal-content,
#documentHistoryModal .modal-content,
#partnerHistoryModal .modal-content,
#employeeHistoryModal .modal-content,
#taskHistoryModal .modal-content,
#historyCommunicationModal .modal-content,
#quoteHistoryModal .modal-content,
#businessDocumentHistoryModal .modal-content {
    overflow: hidden;
    border: 0;
    border-radius: 1.15rem;
    box-shadow: 0 1.5rem 4rem rgba(15, 45, 86, .24);
}

.c9-history-modal .modal-header,
#documentHistoryModal .modal-header,
#partnerHistoryModal .modal-header,
#employeeHistoryModal .modal-header,
#taskHistoryModal .modal-header,
#historyCommunicationModal .modal-header,
#quoteHistoryModal .modal-header,
#businessDocumentHistoryModal .modal-header {
    min-height: 5.75rem;
    padding: 1.15rem 1.4rem;
    color: #fff;
    border: 0;
    background:
        radial-gradient(circle at 88% 25%, rgba(255,255,255,.22), transparent 26%),
        linear-gradient(135deg, #0f3f91 0%, #1477f8 68%, #40a4ff 100%) !important;
}

.c9-history-modal .modal-title,
#documentHistoryModal .modal-title,
#partnerHistoryModal .modal-title,
#employeeHistoryModal .modal-title,
#taskHistoryModal .modal-title,
#historyCommunicationModal .modal-title,
#quoteHistoryModal .modal-title,
#businessDocumentHistoryModal .modal-title {
    font-weight: 750;
    letter-spacing: -.02em;
}

.c9-history-modal .modal-header .btn-close,
#documentHistoryModal .modal-header .btn-close,
#partnerHistoryModal .modal-header .btn-close,
#employeeHistoryModal .modal-header .btn-close,
#taskHistoryModal .modal-header .btn-close,
#historyCommunicationModal .modal-header .btn-close,
#quoteHistoryModal .modal-header .btn-close,
#businessDocumentHistoryModal .modal-header .btn-close {
    filter: invert(1) grayscale(1) brightness(2);
}

.c9-history-modal .modal-body,
#documentHistoryModal .modal-body,
#partnerHistoryModal .modal-body,
#employeeHistoryModal .modal-body,
#taskHistoryModal .modal-body,
#historyCommunicationModal .modal-body,
#quoteHistoryModal .modal-body,
#businessDocumentHistoryModal .modal-body {
    padding: 1.35rem;
    background: #f5f8fc;
}

.c9-history-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: .8rem 1rem;
    color: #36516f;
    background: #fff;
    border: 1px solid #dce6f2;
    border-radius: .85rem;
}

.c9-history-timeline {
    position: relative;
    display: grid;
    gap: .85rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* A jobb oldali előzménysávban minden flex-szint zsugorodhat, így maga a
   lista görgetődik, a fejléc és a rekordszám pedig a helyén marad. */
#viewHistoryContent,
#editHistoryContent,
#simpleTaskHistoryColumn,
#EditTaskHistoryColumn,
#EditTaskHistoryColumn > .h-100 {
    min-height: 0;
}

#viewHistoryContent,
#editHistoryContent,
#EditTaskHistoryColumn > .h-100 {
    overflow: hidden;
}

@media (min-width: 992px) {
    #taskViewModal .modal-content,
    #taskSimpleViewModal .modal-content,
    #editTaskModal .modal-content {
        height: 85vh;
    }

    #taskViewModal .modal-body,
    #taskSimpleViewModal .modal-body,
    #editTaskModal .modal-body,
    #editTaskModal form,
    #taskViewModal .modal-body > .row,
    #taskSimpleViewModal .modal-body > .row,
    #editTaskModal .modal-body > .row {
        min-height: 0;
    }

    #taskViewModal [class*="col-"]:has(#viewHistoryContent),
    #taskSimpleViewModal [class*="col-"]:has(#viewHistoryContent),
    #editTaskModal [class*="col-"]:has(#editHistoryContent) {
        min-height: 0;
        overflow: hidden;
    }
}

#viewHistoryList,
#editHistoryList,
#simpleTaskHistoryList {
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: .45rem;
}

.c9-history-timeline::before {
    position: absolute;
    top: 1.3rem;
    bottom: 1.3rem;
    left: 1.12rem;
    width: 2px;
    content: "";
    background: linear-gradient(#1976f3, #cbd9eb);
}

.c9-history-item {
    --c9-history-accent: #1976f3;
    position: relative;
    display: grid;
    grid-template-columns: 2.35rem minmax(0, 1fr);
    gap: .85rem;
}

.c9-history-marker {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    color: #fff;
    background: var(--c9-history-accent);
    border: .3rem solid #f5f8fc;
    border-radius: 50%;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--c9-history-accent) 35%, transparent);
}

.c9-history-card {
    container-type: inline-size;
    min-width: 0;
    padding: 1rem 1.05rem;
    background: #fff;
    border: 1px solid #dce6f2;
    border-left: .25rem solid var(--c9-history-accent);
    border-radius: .9rem;
    box-shadow: 0 .35rem 1rem rgba(15, 45, 86, .07);
}

.c9-history-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
}

.c9-history-action { color: #152b47; font-weight: 750; }
.c9-history-actor { margin-top: .18rem; color: #486581; font-size: .9rem; }
.c9-history-actor i { color: var(--c9-history-accent); }
.c9-history-time { color: #6b7f95; font-size: .8rem; white-space: nowrap; }
.c9-history-detail { display: grid; gap: .45rem; margin-top: .7rem; padding-top: .7rem; color: #354a62; font-size: .9rem; border-top: 1px solid #edf1f6; overflow-wrap: anywhere; }
.c9-history-change { display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr); gap: .65rem; align-items: start; }
.c9-history-field { color: #526b84; font-size: .78rem; font-weight: 750; }
.c9-history-values { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: .45rem; align-items: center; min-width: 0; }
.c9-history-values i { color: var(--c9-history-accent); }
.c9-history-old,
.c9-history-new { min-width: 0; padding: .28rem .45rem; border-radius: .45rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.c9-history-old { color: #6b7280; background: #f3f4f6; text-decoration-color: #a8b0ba; }
.c9-history-new { color: #173d64; background: #eaf3ff; font-weight: 650; }
.c9-history-note { white-space: pre-wrap; }
.c9-history-values small { display: block; font-size: .68rem; font-weight: 500; opacity: .8; margin-bottom: .2rem; }
.c9-history-files { display: grid; gap: .4rem; margin-top: .7rem; }
.c9-history-file { display: flex; align-items: center; gap: .55rem; padding: .65rem; border: 1px solid #b8d5f5; border-radius: .5rem; background: #eff6ff; color: #174e85; text-decoration: none; overflow-wrap: anywhere; }
.c9-history-file > span:first-of-type { min-width: 0; flex: 1; }
.c9-history-file:hover { background: #dcecff; text-decoration: underline; }
.c9-history-file:focus-visible { outline: 2px solid #1976f3; outline-offset: 2px; }
.c9-history-download { font-size: .75rem; white-space: nowrap; }
@container (max-width: 420px) {
    .c9-history-heading { flex-wrap: wrap; gap: .3rem; }
    .c9-history-change { grid-template-columns: 1fr; gap: .25rem; }
    .c9-history-values { grid-template-columns: 1fr; gap: .2rem; }
    .c9-history-values > i { display: none; }
    .c9-history-file { flex-wrap: wrap; }
}
[data-theme="dark"] .c9-history-file { background: #183b61; color: #e1efff; border-color: #436080; }
.c9-history-transition { display: inline-flex; align-items: center; gap: .4rem; margin-top: .65rem; color: #244765; font-size: .85rem; font-weight: 650; }
.c9-history-transition span { padding: .22rem .5rem; background: #edf4ff; border-radius: 999px; }

.c9-history-item[data-kind="create"] { --c9-history-accent: #15966a; }
.c9-history-item[data-kind="delete"],
.c9-history-item[data-kind="error"] { --c9-history-accent: #d74747; }
.c9-history-item[data-kind="status"] { --c9-history-accent: #7756d8; }
.c9-history-item[data-kind="attachment"] { --c9-history-accent: #0d8fa3; }
.c9-history-item[data-kind="approve"] { --c9-history-accent: #0f8a61; }
.c9-history-item[data-kind="warning"] { --c9-history-accent: #df8d16; }

.c9-history-state {
    display: grid;
    place-items: center;
    min-height: 12rem;
    padding: 2rem;
    color: #657a91;
    text-align: center;
    background: #fff;
    border: 1px dashed #cbd8e8;
    border-radius: 1rem;
}

.c9-history-state i { display: block; margin-bottom: .65rem; color: #79a5db; font-size: 2rem; }

@media (max-width: 575.98px) {
    .c9-history-modal .modal-body { padding: .9rem; }
    .c9-history-heading { display: block; }
    .c9-history-time { display: block; margin-top: .35rem; }
    .c9-history-change { grid-template-columns: 1fr; gap: .25rem; }
    .c9-history-values { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
}

[data-theme="dark"] .c9-history-modal .modal-body,
[data-theme="dark"] #documentHistoryModal .modal-body,
[data-theme="dark"] #partnerHistoryModal .modal-body,
[data-theme="dark"] #employeeHistoryModal .modal-body,
[data-theme="dark"] #taskHistoryModal .modal-body,
[data-theme="dark"] #historyCommunicationModal .modal-body,
[data-theme="dark"] #quoteHistoryModal .modal-body,
[data-theme="dark"] #businessDocumentHistoryModal .modal-body { background: #181d24; }
[data-theme="dark"] .c9-history-card,
[data-theme="dark"] .c9-history-summary,
[data-theme="dark"] .c9-history-state { color: #d9e5f3; background: #222a34; border-color: #344253; }
[data-theme="dark"] .c9-history-marker { border-color: #181d24; }
[data-theme="dark"] .c9-history-action { color: #f2f6fb; }
[data-theme="dark"] .c9-history-actor,
[data-theme="dark"] .c9-history-detail { color: #c1cede; }
[data-theme="dark"] .c9-history-detail { border-color: #344253; }
[data-theme="dark"] .c9-history-field { color: #aebfd2; }
[data-theme="dark"] .c9-history-old { color: #c0cad6; background: #303a47; }
[data-theme="dark"] .c9-history-new { color: #e1efff; background: #183b61; }
