.modal-background,
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    z-index: 1050 !important;
    background: rgba(0, 0, 0, 0.45);
    justify-content: center;
    align-items: center;
    padding: 16px;
}

/* Ensure modals appear above fullscreen modals when both are active */
body:has(.fmu-fullscreen-modal--active) .modal-background.is-visible,
body:has(.fmu-fullscreen-modal--active) .modal.is-visible {
    z-index: 10001 !important;
}

.custom-modalcontent {
    position: relative;
    width: min(480px, 90vw);
    background-color: var(--neutrals-10);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(var(--hoverprimary-rgb), 0.35);
    z-index: 1051;
    padding: 32px;
    overflow: hidden;
    overflow-y: auto;
    text-align: center;
    height: fit-content;
    max-height: calc(100vh - 64px);
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    color: var(--textcolor-fullcontrast);
}

.custom-modalheader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(var(--hoverprimary-rgb), 0.1);
}

.custom-modaltitle,
.modal-title {
    flex-grow: 1;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.modal-subtitle {
    margin: 0;
    font-size: 14px;
    color: var(--textcolor-80contrast);
    font-style: italic;
}

.custom-modaltext {
    color: var(--textcolor-80contrast);
    line-height: 1.5;
}

.custom-modalfooter {
    border-top: 1px solid rgba(var(--hoverprimary-rgb), 0.1);
    padding-top: 16px;
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

.custom-modalclosebutton,
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: var(--textcolor-50contrast);
    transition: color 0.2s ease;
}

.custom-modalclosebutton:hover,
.custom-modalclosebutton:focus,
.modal-close:hover,
.modal-close:focus {
    color: var(--textcolor-fullcontrast);
}

.custom-modalbody {
    text-align: left;
    padding-top: 0;
}

.modal-actions,
.modal-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.modal-action-button,
.modal-buttons button {
    min-width: 140px;
    padding: 12px 28px;
    border-radius: 14px;
    border: none;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    color: white;
}

.modal-action-button:hover,
.modal-buttons button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(var(--hoverprimary-rgb), 0.18);
}

.modal-action-button:focus,
.modal-buttons button:focus {
    outline: 3px solid rgba(var(--primary-rgb), 0.35);
    outline-offset: 2px;
}

.modal-action-button--cancel,
.modal-buttons .cancel-button {
    background-color: var(--accent-color);
}

.modal-action-button--cancel:hover,
.modal-buttons .cancel-button:hover {
    background-color: var(--hoveraccent-color);
}

.modal-action-button--confirm,
.modal-buttons .confirm-button {
    background-color: var(--signals-activecolor);
}

.modal-action-button--confirm:hover,
.modal-buttons .confirm-button:hover {
    background-color: var(--hoversignals-activecolor);
}

.modal-action-button--primary {
    background-color: var(--primary-color);
}

.modal-action-button--primary:hover {
    background-color: var(--hoverprimary-color);
}

.modal-action-button--neutral {
    background-color: var(--textcolor-50contrast);
}

.modal-action-button--neutral:hover {
    background-color: var(--textcolor-fullcontrast);
}

.custom-bigmodal {
    width: min(1040px, 95vw);
    max-height: calc(100vh - 64px);
    text-align: left;
    padding: 28px 32px;
}

.modal-scroll-area {
    overflow-y: auto;
    max-height: 50vh;
    padding-right: 4px;
}

.modal-list-card {
    background: var(--neutrals-0);
    border-radius: var(--radius-xl);
    border: 1px solid var(--surface-border-light, rgba(var(--hoverprimary-rgb), 0.08));
    padding: 1.25rem 1.5rem;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.modal-list-card:hover {
    border-color: rgba(var(--primary-rgb), 0.3);
    box-shadow: 0 2px 12px rgba(var(--primary-rgb), 0.08);
}

.modal-list-card + .modal-list-card {
    margin-top: 0.75rem;
}

.modal-list-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.modal-list-card p {
    font-size: 0.88rem;
    line-height: 1.5;
    margin: 0;
    color: var(--textcolor-50contrast);
}

.modal-list-card .dataset-select-btn {
    align-self: flex-start;
    margin-top: 0.25rem;
}

.modal-list-card .dataset-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-lg);
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary-color);
    margin-bottom: 0.25rem;
    align-self: flex-start;
}

.modal-card--list {
    text-align: center;
}

.modal-card--list .custom-modaltext {
    text-align: left;
}

.modal-card--list img {
    margin: 0 auto;
    border-radius: 12px;
}
