:root {
    --modal-ink: #172033;
    --modal-muted: #64748b;
    --modal-line: #e7ebf3;
    --modal-blue: #5755e7;
}

[data-app-popup] {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
    overflow-y: auto;
    background: rgba(17, 24, 39, 0.56);
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 180ms ease, visibility 180ms ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    width: min(100%, 500px);
    max-height: min(86vh, 760px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 28px 80px rgba(10, 20, 50, 0.26), 0 5px 18px rgba(10, 20, 50, 0.1);
    transform: translateY(12px) scale(0.98);
    transition: transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
    outline: none;
}

.modal-overlay.active .modal-container {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 24px 17px;
    border-bottom: 1px solid var(--modal-line);
    background: linear-gradient(180deg, #fff 0%, #fbfcff 100%);
}

.modal-heading {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.modal-symbol {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: #eef0ff;
    color: var(--modal-blue);
    font: 700 21px/1 system-ui, sans-serif;
}

.modal-overlay[data-variant="success"] .modal-symbol {
    background: #e6f8f1;
    color: #079669;
}

.modal-overlay[data-variant="warning"] .modal-symbol {
    background: #fff4dc;
    color: #c47b0a;
}

.modal-overlay[data-variant="danger"] .modal-symbol {
    background: #fff0ef;
    color: #d64747;
}

.modal-title {
    margin: 0;
    color: var(--modal-ink);
    font-size: 1.12rem;
    font-weight: 750;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.modal-close {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #8290a5;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
}

.modal-close:hover,
.modal-close:focus-visible {
    background: #f0f2f8;
    color: #344054;
}

.modal-body {
    padding: 22px 26px 25px;
    overflow-y: auto;
    color: #354158;
    font-size: 0.97rem;
    line-height: 1.8;
}

.modal-message {
    margin: 0;
    color: #475467;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px 21px;
    border-top: 1px solid #f0f2f6;
    background: #fbfcfe;
}

.modal-button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: 12px;
    font: inherit;
    font-size: 0.93rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 150ms ease, background 150ms ease;
}

.modal-button:hover {
    transform: translateY(-1px);
}

.modal-button:focus-visible {
    outline: 3px solid rgba(87, 85, 231, 0.22);
    outline-offset: 2px;
}

.modal-button-primary {
    background: linear-gradient(135deg, #6664f1, #4d49dc);
    color: #fff;
    box-shadow: 0 5px 13px rgba(83, 79, 220, 0.22);
}

.modal-button-primary:hover {
    box-shadow: 0 8px 17px rgba(83, 79, 220, 0.3);
}

.modal-button-primary.modal-button-danger {
    background: linear-gradient(135deg, #ef5a57, #d93030);
    box-shadow: 0 5px 13px rgba(217, 48, 48, 0.2);
}

.modal-button-secondary {
    border-color: #e2e7ef;
    background: #fff;
    color: #475467;
}

.modal-button-secondary:hover {
    background: #f5f7fa;
}

.modal-button[hidden] {
    display: none !important;
}

/* Rich editor controls used by existing custom modal forms. */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--modal-line);
    margin-bottom: 16px;
}

.modal-tab {
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 600;
    color: var(--modal-muted);
    border-bottom: 2px solid transparent;
}

.modal-tab.active {
    color: var(--modal-blue);
    border-bottom-color: var(--modal-blue);
}

.dropzone {
    border: 2px dashed #d7dce8;
    border-radius: 14px;
    padding: 32px;
    text-align: center;
    background: #f8f9fd;
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--modal-blue);
    background: #f0f1ff;
}

@media (max-width: 540px) {
    .modal-overlay {
        align-items: flex-end;
        padding: 12px;
    }

    .modal-container {
        width: 100%;
        max-height: 88vh;
        border-radius: 20px 20px 16px 16px;
    }

    .modal-header {
        padding: 18px 18px 14px;
    }

    .modal-body {
        padding: 20px 20px 22px;
    }

    .modal-footer {
        padding: 14px 18px 18px;
    }

    .modal-button {
        flex: 1;
        padding: 0 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .modal-overlay,
    .modal-container,
    .modal-close,
    .modal-button {
        transition: none;
    }
}