main.change-history {
    --ch-create-bg:     rgba(22, 163, 74, 0.10);
    --ch-create-text:   #16a34a;
    --ch-create-border: rgba(22, 163, 74, 0.30);

    --ch-update-bg:     rgba(33, 150, 243, 0.10);
    --ch-update-text:   #1565c0;
    --ch-update-border: rgba(33, 150, 243, 0.30);

    --ch-delete-bg:     rgba(220, 38, 38, 0.10);
    --ch-delete-text:   #c22b2b;
    --ch-delete-border: rgba(220, 38, 38, 0.30);

    --ch-import-bg:     rgba(217, 119, 6, 0.10);
    --ch-import-text:   #b45309;
    --ch-import-border: rgba(217, 119, 6, 0.30);
}

@media (prefers-color-scheme: dark) {
    main.change-history {
        --ch-create-bg:     rgba(22, 163, 74, 0.15);
        --ch-create-text:   #6fcf97;
        --ch-create-border: rgba(22, 163, 74, 0.35);

        --ch-update-bg:     rgba(33, 150, 243, 0.15);
        --ch-update-text:   #56ccf2;
        --ch-update-border: rgba(33, 150, 243, 0.35);

        --ch-delete-bg:     rgba(220, 38, 38, 0.15);
        --ch-delete-text:   #eb5757;
        --ch-delete-border: rgba(220, 38, 38, 0.35);

        --ch-import-bg:     rgba(217, 119, 6, 0.15);
        --ch-import-text:   #f2c94c;
        --ch-import-border: rgba(217, 119, 6, 0.35);
    }
}

main.change-history .be-card {
    background: var(--module-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius);
    padding: 12px 14px 14px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

main.change-history .be-card-title {
    letter-spacing: 0.09em;
    margin: 0 0 10px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--input-border);
    color: var(--link-color);
}

.ch-list-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

.ch-list-title {
    flex: 0 0 auto;
}

.ch-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin: 0 0 0 auto;
}

main.change-history .ch-filters .choices {
    flex: 0 0 auto;
    width: 230px;
    min-width: 0;
    margin-bottom: 0;
}

main.change-history .ch-filters .choices:first-child {
    width: 330px;
}

.ch-filter-reset {
    font-size: 0.85rem;
    white-space: nowrap;
}

.ch-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ch-entry {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) auto;
    align-items: start;
    gap: 6px 12px;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: rgba(var(--accent-color-rgb), 0.04);
}

.ch-badge {
    display: inline-block;
    justify-self: start;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
}

.ch-badge-create {
    background: var(--ch-create-bg);
    color: var(--ch-create-text);
    border-color: var(--ch-create-border);
}

.ch-badge-update {
    background: var(--ch-update-bg);
    color: var(--ch-update-text);
    border-color: var(--ch-update-border);
}

.ch-badge-delete {
    background: var(--ch-delete-bg);
    color: var(--ch-delete-text);
    border-color: var(--ch-delete-border);
}

.ch-badge-import {
    background: var(--ch-import-bg);
    color: var(--ch-import-text);
    border-color: var(--ch-import-border);
}

.ch-body {
    min-width: 0;
}

.ch-entity {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.ch-when {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.ch-user {
    opacity: 0.85;
}

.ch-diff {
    margin: 5px 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.9rem;
}

.ch-diff li {
    padding: 1px 0;
    overflow-wrap: anywhere;
}

.ch-field {
    font-weight: 500;
    color: var(--text-color);
}

.ch-old {
    color: var(--text-muted);
}

.ch-new {
    color: var(--accent-color);
}

.ch-more > summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    list-style: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--link-color);
}

.ch-more > summary::-webkit-details-marker {
    display: none;
}

.ch-more > summary::before {
    content: "";
    flex: 0 0 auto;
    width: 0;
    height: 0;
    border-left: 5px solid currentColor;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    opacity: 0.7;
    transition: transform 0.15s ease;
}

.ch-more[open] > summary::before {
    transform: rotate(90deg);
}

.ch-more .ch-diff {
    margin-top: 3px;
}

.ch-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.ch-meta {
    text-align: center;
    margin-top: 1rem;
}

@media (max-width: 700px) {
    .ch-filters {
        margin-left: 0;
        width: 100%;
    }

    main.change-history .ch-filters .choices,
    main.change-history .ch-filters .choices:first-child {
        flex: 1 1 160px;
        width: auto;
    }

    .ch-list-title {
        width: 100%;
    }

    .ch-entry {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .ch-badge {
        grid-row: 1;
        grid-column: 1;
    }

    .ch-when {
        grid-row: 1;
        grid-column: 2;
        flex-direction: row;
        align-items: baseline;
        gap: 8px;
    }

    .ch-body {
        grid-row: 2;
        grid-column: 1 / -1;
    }
}
