.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1050;
    padding: 0 max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom))
        max(12px, env(safe-area-inset-left));
}

@media (min-width: 520px) {
    .modal-overlay {
        align-items: center;
        padding: 16px;
    }
}

.modal-dialog-custom {
    position: relative;
    background: #fff;
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -4px 32px rgba(15, 23, 42, 0.12);
    max-width: 420px;
    width: 100%;
    max-height: min(92dvh, 640px);
    overflow-y: auto;
    padding: 1.5rem 1.25rem max(1.25rem, env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 520px) {
    .modal-dialog-custom {
        border-radius: 1rem;
        box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.15);
        padding: 1.5rem 1.5rem 1.25rem;
    }
}
.modal-title-custom {
    margin: 0 0 0.5rem 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #333;
}
.modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: #f1f5f9;
    border-radius: 50%;
    font-size: 1.35rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.modal-close:hover,
.modal-close:focus-visible {
    color: #1e293b;
    background: #e2e8f0;
    outline: none;
}
#forgotModal .btn {
    width: 100%;
}
#forgotMessage {
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.45;
    text-align: left;
}
#forgotMessage.text-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}
#forgotMessage.text-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}
#forgotMessage a {
    color: inherit;
    font-weight: 600;
}

#forgotModal .form-label-group {
    position: relative;
    margin-bottom: 1.5rem;
}
#forgotModal .form-label-group input {
    width: 100%;
    padding: 0.75rem 1.25rem;
    border-radius: 2rem;
    border: 1px solid #ced4da;
    font-size: 1rem;
}
#forgotModal .form-label-group label {
    position: absolute;
    top: 0;
    left: 0;
    padding: 0.75rem 1.25rem;
    pointer-events: none;
    color: #6c757d;
    transition: all 0.15s ease;
}
#forgotModal .form-label-group input:focus,
#forgotModal .form-label-group input:not(:placeholder-shown) {
    padding-top: 1.1rem;
    padding-bottom: 0.4rem;
}
#forgotModal .form-label-group input:focus ~ label,
#forgotModal .form-label-group input:not(:placeholder-shown) ~ label {
    font-size: 0.75rem;
    padding-top: 0.35rem;
    color: #1e3a5f;
}

.forgot-dialog {
    max-width: 400px;
}
.forgot-title {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 0.35rem;
}
.forgot-subtitle {
    text-align: center;
    font-size: 0.9rem;
    color: #6c757d;
    margin: 0 0 1.1rem 0;
}
.forgot-login-display {
    text-align: center;
    font-size: 0.88rem;
    color: #475569;
    margin: -0.5rem 0 0.85rem;
}
.forgot-login-display strong {
    color: #1e3a5f;
}
.forgot-method-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-bottom: 1rem;
}
.forgot-method-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-height: 48px;
    padding: 0.85rem 1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.75rem;
    background: #fff;
    color: #1e3a5f;
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.forgot-method-btn:not(:disabled):hover {
    border-color: #1e3a5f;
    background: #f8fafc;
}
.forgot-method-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.forgot-method-icon {
    color: #e11d48;
    font-size: 1.15rem;
    width: 1.5rem;
    text-align: center;
}
.forgot-phone-invalid {
    font-size: 0.82rem;
    color: #dc3545;
    text-align: center;
    margin: -0.35rem 0 0.75rem 0;
}
.forgot-hint-box {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.75rem 0.9rem;
    margin-bottom: 1.1rem;
    background: #f1f5f9;
    border-left: 3px solid #e11d48;
    border-radius: 0.35rem;
    font-size: 0.88rem;
    color: #334155;
}
.forgot-hint-icon {
    color: #e11d48;
}
.btn-forgot-primary {
    background: #1e3a5f !important;
    color: #fff !important;
    border-color: #1e3a5f !important;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.btn-forgot-primary:hover:not(:disabled) {
    background: #16304f !important;
    color: #fff !important;
}
.btn-forgot-wide {
    width: 100%;
    margin-bottom: 0.65rem;
}
.forgot-back-link {
    display: block;
    width: 100%;
    margin-top: 0.5rem;
    border: none;
    background: none;
    color: #6c757d;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    min-height: 44px;
    padding: 0.5rem;
}
.forgot-back-link:hover {
    color: #1e3a5f;
}
.forgot-email-sent-icon {
    font-size: 3rem;
    text-align: center;
    margin: 0.5rem 0 1rem;
    line-height: 1;
}
.forgot-email-sent-text {
    text-align: center;
    line-height: 1.55;
    margin-bottom: 0.75rem;
}
.forgot-email-sent-text strong {
    color: #0A1E36;
    font-weight: 700;
    word-break: break-all;
}
.forgot-instructions-list {
    margin: 0 0 1rem 1.15rem;
    padding: 0;
    font-size: 0.88rem;
    color: #334155;
    line-height: 1.5;
}
.forgot-instructions-list li {
    margin-bottom: 0.45rem;
    text-align: left;
}
.forgot-step-instructions {
    text-align: center;
    font-size: 0.88rem;
    color: #475569;
    margin: 0 0 1rem;
    line-height: 1.45;
}
.forgot-email-sent-hint {
    text-align: center;
    font-size: 0.85rem;
    color: #64748b;
    margin: 0 0 1.25rem;
}
.forgot-call-icon {
    text-align: center;
    font-size: 2.5rem;
    color: #e11d48;
    margin: 0.5rem 0 1rem;
}
.forgot-code-inputs {
    display: flex;
    justify-content: center;
    gap: 0.55rem;
    margin-bottom: 1.1rem;
}
.forgot-code-digit {
    width: 3rem;
    height: 3rem;
    border: 1px solid #cbd5e1;
    border-radius: 50%;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: #e11d48;
    outline: none;
    background: #fff;
}
.forgot-code-digit:focus {
    border-color: #1e3a5f;
}

.forgot-modal--lk #forgotBackToLogin {
    display: none;
}
