.toolbar {
    grid-template-columns: minmax(260px, 1fr) auto auto auto auto;
}

.recycle-button {
    gap: 7px;
}

.recycle-button span {
    display: inline-grid;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    place-items: center;
    border: 1px solid #9dacbb;
    border-radius: 999px;
    background: #dfe7ee;
    color: #334b61;
    font-size: .68rem;
}

.record-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.record-actions .btn {
    min-height: 42px;
    padding: 8px 11px;
    font-size: .74rem;
}

.btn.danger {
    border-color: #8f1d16;
    background: linear-gradient(180deg, #d9473e, #a91f17);
    color: #fff;
    box-shadow: inset 0 1px rgba(255, 255, 255, .35), 0 4px 0 #77150f, 0 7px 12px rgba(119, 21, 15, .23);
}

.btn.audit {
    border-color: #1f738a;
    background: linear-gradient(180deg, #effbff, #cceaf2);
    color: #075f74;
    box-shadow: inset 0 1px #fff, 0 4px 0 #70a9b8, 0 7px 12px rgba(7, 95, 116, .14);
}

.crud-dialog {
    width: min(960px, calc(100vw - 28px));
    max-height: min(90vh, 980px);
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid #8fa7bc;
    border-radius: 17px;
    background: #f8fbfd;
    color: #172536;
    box-shadow: 0 24px 70px rgba(3, 19, 33, .44), 0 0 0 1px rgba(255, 255, 255, .8);
}

.crud-dialog.compact {
    width: min(620px, calc(100vw - 28px));
}

.crud-dialog::backdrop {
    background: rgba(2, 15, 27, .72);
    backdrop-filter: blur(2px);
}

.crud-dialog > form {
    display: grid;
    max-height: min(90vh, 980px);
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 17px 20px;
    border-bottom: 4px solid #d4a43e;
    background: linear-gradient(145deg, #071e34, #174b75);
    color: #fff;
    box-shadow: inset 0 1px rgba(255, 255, 255, .16);
}

.dialog-head.danger-head {
    border-bottom-color: #c43d34;
}

.dialog-head h2 {
    margin: 2px 0 3px;
    font: 700 1.45rem/1.15 Georgia, Cambria, serif;
    text-shadow: 0 2px 5px rgba(0, 0, 0, .36);
}

.dialog-head p {
    margin: 0;
    color: #d7e4ef;
    font-size: .8rem;
}

.dialog-kicker {
    color: #f2d27e;
    font-size: .67rem;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.dialog-close {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .38);
    border-bottom: 3px solid rgba(255, 255, 255, .34);
    border-radius: 10px;
    background: rgba(4, 19, 33, .42);
    color: #fff;
    font-size: 1.45rem;
    font-weight: 500;
    cursor: pointer;
}

.dialog-close:focus-visible {
    outline: 3px solid rgba(242, 210, 126, .62);
    outline-offset: 2px;
}

.dialog-body {
    padding: 17px 20px 20px;
    overflow: auto;
    background: radial-gradient(circle at 100% 0, rgba(36, 99, 166, .08), transparent 24rem), #f8fbfd;
}

.dialog-body fieldset {
    margin: 0 0 13px;
    padding: 13px;
    border: 1px solid #bac9d7;
    border-top: 4px solid #2463a6;
    border-radius: 12px;
    background: #fff;
    box-shadow: inset 0 1px #fff, 0 5px 12px rgba(11, 40, 68, .07);
}

.dialog-body fieldset:nth-of-type(2) {
    border-top-color: #713ba5;
}

.dialog-body fieldset:nth-of-type(3) {
    border-top-color: #13736f;
}

.dialog-body fieldset.operator-fieldset {
    border-top-color: #d4a43e;
}

.dialog-body legend {
    padding: 0 7px;
    color: #173c5b;
    font-weight: 900;
    font-size: .76rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.crud-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.crud-grid label,
.stack-label,
.restore-actor {
    display: grid;
    gap: 4px;
}

.crud-grid label.wide {
    grid-column: 1 / -1;
}

.crud-grid label > span,
.stack-label > span,
.restore-actor > span {
    color: #40566d;
    font-size: .7rem;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.crud-grid input,
.crud-grid select,
.crud-grid textarea,
.stack-label input,
.stack-label textarea,
.restore-actor input {
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid #9fb1c3;
    border-radius: 9px;
    background: #fff;
    color: #172536;
    box-shadow: inset 0 2px 4px rgba(11, 40, 68, .07), 0 1px #fff;
}

.crud-grid textarea,
.stack-label textarea {
    resize: vertical;
}

.crud-grid input:focus,
.crud-grid select:focus,
.crud-grid textarea:focus,
.stack-label input:focus,
.stack-label textarea:focus,
.restore-actor input:focus {
    outline: none;
    border-color: #2463a6;
    box-shadow: 0 0 0 3px rgba(36, 99, 166, .18), inset 0 1px 2px rgba(11, 40, 68, .05);
}

.operator-note {
    align-self: center;
    margin: 0;
    padding: 9px 11px;
    border: 1px solid #e2c36d;
    border-radius: 9px;
    background: #fff8df;
    color: #66511a;
    font-size: .78rem;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 13px 20px 17px;
    border-top: 1px solid #ccd8e2;
    background: #eef4f8;
}

.dialog-message {
    min-height: 1.3em;
    margin: 9px 0 0;
    color: #617286;
    font-size: .8rem;
    font-weight: 700;
}

.dialog-message.success {
    color: #18794e;
}

.dialog-message.error {
    color: #b42318;
}

.confirm-copy {
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid #e1a6a2;
    border-radius: 10px;
    background: #fff1ef;
    color: #7f231d;
}

.confirm-copy strong {
    color: #b42318;
    font-size: 1.02rem;
}

.stack-label + .stack-label {
    margin-top: 11px;
}

.restore-actor {
    max-width: 360px;
    margin-bottom: 13px;
}

.operation-list {
    display: grid;
    gap: 10px;
}

.operation-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid #c8d5e2;
    border-left: 5px solid #0787a3;
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 4px 10px rgba(11, 40, 68, .07);
}

.operation-item.audit-entry {
    grid-template-columns: 120px minmax(0, 1fr);
    border-left-color: #713ba5;
}

.operation-item h3 {
    margin: 0;
    color: #173c5b;
    font-size: .93rem;
}

.operation-item p {
    margin: 4px 0 0;
    color: #526a80;
    font-size: .78rem;
    overflow-wrap: anywhere;
}

.operation-item small {
    display: block;
    margin-top: 4px;
    color: #718397;
    font-size: .69rem;
}

.change-list {
    display: grid;
    gap: 5px;
    margin-top: 7px;
}

.change-item {
    display: grid;
    grid-template-columns: minmax(120px, .45fr) minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    padding: 6px 8px;
    border: 1px solid #c3d2df;
    border-radius: 6px;
    background: #edf3f8;
    color: #496177;
    font-size: .65rem;
}

.change-item b {
    text-transform: capitalize;
    font-weight: 800;
}

.change-item span {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-width: 0;
}

.change-item del,
.change-item ins {
    overflow-wrap: anywhere;
    text-decoration: none;
}

.change-item del { color: #9f2942; }
.change-item ins { color: #166534; font-weight: 800; }
.change-item i { color: #718397; font-style: normal; }

.audit-date {
    color: #713ba5;
    font-size: .72rem;
    font-weight: 900;
}

@media (max-width: 980px) {
    .toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .toolbar input {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .record-actions {
        justify-content: stretch;
    }

    .record-actions .btn,
    .dialog-actions .btn {
        width: 100%;
    }

    .crud-grid {
        grid-template-columns: 1fr;
    }

    .crud-grid label.wide {
        grid-column: auto;
    }

    .dialog-head,
    .dialog-body,
    .dialog-actions {
        padding-left: 14px;
        padding-right: 14px;
    }

    .dialog-actions {
        flex-direction: column-reverse;
    }

    .operation-item,
    .operation-item.audit-entry {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 460px) {
    .toolbar {
        grid-template-columns: 1fr;
    }

    .toolbar input {
        grid-column: auto;
    }

    .crud-dialog {
        width: calc(100vw - 12px);
        max-height: 96vh;
        border-radius: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .crud-dialog::backdrop {
        backdrop-filter: none;
    }
}
