.app-modal .modal-dialog {
    max-width: min(var(--app-modal-width, 720px), calc(100vw - 1.5rem));
}

.app-modal .modal-content {
    max-height: calc(100svh - 2rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e7edf5;
    border-radius: 1rem;
    box-shadow: 0 24px 60px rgba(12, 15, 22, 0.18);
}

.app-modal .modal-content > form,
.app-modal .modal-content > .app-modal-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    max-height: inherit;
}

.app-modal .modal-header,
.app-modal .modal-footer {
    flex: 0 0 auto;
    background: #fff;
}

.app-modal .modal-header {
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #e9eef5;
}

.app-modal .modal-title {
    color: #0f172a;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.app-modal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1rem;
    overflow-x: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.app-modal--quick .modal-body {
    overflow-y: auto;
}

.app-modal .modal-dialog-scrollable .modal-body,
.app-modal--quick .modal-dialog-scrollable .modal-body {
    overflow-y: auto;
}

.app-modal--collapsible .modal-body {
    overflow-y: auto;
}

.app-modal--workbench .modal-body,
.app-modal--config .modal-body {
    overflow-y: auto;
}

.app-modal--confirm .modal-dialog {
    --app-modal-width: 460px;
}

.app-modal--quick .modal-dialog {
    --app-modal-width: 760px;
}

.app-modal--workbench .modal-dialog {
    --app-modal-width: 1120px;
}

.app-modal--config .modal-dialog {
    --app-modal-width: 1180px;
}

.app-modal,
.app-modal * {
    min-width: 0;
}

.app-modal .modal-footer {
    gap: 0.55rem;
    flex-wrap: wrap;
    padding: 0.85rem 1rem;
    border-top: 1px solid #e9eef5;
}

.app-modal .modal-footer .btn {
    min-height: 2.5rem;
    border-radius: var(--ds-button-radius);
}

.app-modal__subtitle {
    margin: 0.3rem 0 0;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.4;
}

.app-modal__section {
    padding: 0.85rem;
    border: 1px solid #e7edf5;
    border-radius: 0.85rem;
    background: #fff;
}

.app-modal__section + .app-modal__section {
    margin-top: 0.75rem;
}

.app-modal__section-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.65rem;
    color: #0f172a;
    font-size: 0.82rem;
    font-weight: 800;
}

.app-modal__disclosure {
    margin-top: 0.75rem;
    width: 100%;
    border-radius: 0.75rem;
    justify-content: center;
}

.app-modal__disclosure[aria-expanded="true"] {
    border-color: rgba(228, 130, 64, 0.42);
    color: #9a4f22;
    background: rgba(228, 130, 64, 0.08);
}

.app-modal__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.app-modal__grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.app-modal .grid-column-full {
    grid-column: 1 / -1;
}

.app-modal .form-label {
    margin-bottom: 0.35rem;
    color: #64748b;
    font-size: var(--ds-field-label-size, 0.75rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.app-modal .form-control,
.app-modal .form-select {
    max-width: 100%;
    min-height: var(--ds-field-height);
    padding: 0.38rem 0.58rem;
    border-color: var(--ds-field-border);
    border-radius: var(--ds-field-radius);
    background-color: var(--ds-field-background);
    color: var(--ds-field-ink);
    font-size: var(--ds-field-font-size);
    line-height: 1.25;
    box-shadow: none;
}

.app-modal .form-select {
    padding-right: 1.9rem;
}

.app-modal input[type="file"].form-control {
    padding-block: 0.25rem;
}

.app-modal .form-control:focus,
.app-modal .form-select:focus {
    border-color: var(--ds-field-border-focus);
    box-shadow: 0 0 0 2px var(--ds-field-focus);
}

.app-modal textarea.form-control {
    min-height: 6.5rem;
    resize: vertical;
}

.app-modal__scroll-region {
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
}

.app-modal .collapse.mt-3 {
    margin-top: 0.75rem !important;
}

.app-modal__tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.app-modal__tabs .nav-link {
    border: 1px solid #dbe3ef;
    border-radius: 999px;
    color: #475569;
    font-size: 0.76rem;
    font-weight: 800;
    padding: 0.38rem 0.65rem;
}

.app-modal__tabs .nav-link.active {
    background: #0f172a;
    border-color: #0f172a;
    color: #fff;
}

@media (max-width: 767.98px) {
    .app-modal .modal-dialog {
        max-width: calc(100vw - 0.75rem);
        margin: 0.375rem auto;
    }

    .app-modal .modal-content {
        max-height: calc(100svh - 0.75rem);
        border-radius: 0.85rem;
    }

    .app-modal__grid,
    .app-modal__grid--three {
        grid-template-columns: 1fr;
    }

    .app-modal .modal-footer .btn {
        flex: 1 1 auto;
    }
}
