/* ==========================================================================
   UKB ADMIN PROFILE MODAL - MODERN LUXURY THEME
   ========================================================================== */

/* Overlay with Backdrop Blur */
:where(.profile-modal-overlay) .profile-modal-teacher .detail-value { word-break: normal; overflow-wrap: anywhere; min-width: 0; }
:where(.profile-modal-overlay) .profile-modal-teacher .detail-label { flex: 0 0 43%; }
:where(.profile-modal-overlay) .profile-modal-teacher .detail-value { flex: 1; }
:where(.profile-modal-overlay) .profile-modal-teacher .profile-modal-footer button,
:where(.profile-modal-overlay) .profile-modal-teacher .profile-tab-btn,
:where(.profile-modal-overlay) .profile-modal-teacher .profile-email-badge { width: auto; flex: 0 0 auto; }
:where(.profile-modal-overlay) .profile-modal-teacher .profile-hero-name { text-transform: none; }
.profile-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 20px;
    box-sizing: border-box;
    animation: profileOverlayFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes profileOverlayFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Modal Window Container */
:where(.profile-modal-overlay) .profile-modal-container {
    background: #ffffff;
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    border-radius: 24px;
    box-shadow: 0 25px 70px -12px rgba(15, 23, 42, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    animation: profileModalZoomIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes profileModalZoomIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ==========================================================================
   HEADER BANNER
   ========================================================================== */
:where(.profile-modal-overlay) .profile-modal-header-banner {
    background: linear-gradient(135deg, #090d16 0%, #1e1b4b 55%, #312e81 100%);
    color: #ffffff;
    padding: 24px 28px 24px 28px;
    position: relative;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.1);
}

:where(.profile-modal-overlay) .profile-modal-header-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 85% 15%, rgba(99, 102, 241, 0.25) 0%, transparent 60%);
    pointer-events: none;
}

:where(.profile-modal-overlay) .profile-banner-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    position: relative;
    z-index: 2;
}

:where(.profile-modal-overlay) .profile-banner-institution {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #a5b4fc;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.08);
    padding: 4px 12px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

:where(.profile-modal-overlay) .profile-modal-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

:where(.profile-modal-overlay) .profile-modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.9);
    border-color: rgba(239, 68, 68, 1);
    transform: rotate(90deg) scale(1.05);
}

/* Hero Content */
:where(.profile-modal-overlay) .profile-hero-content {
    display: flex;
    align-items: center;
    gap: 22px;
    position: relative;
    z-index: 2;
}

:where(.profile-modal-overlay) .profile-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

:where(.profile-modal-overlay) .profile-avatar-circle {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4338ca 0%, #6366f1 50%, #38bdf8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: 1px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

:where(.profile-modal-overlay) .profile-avatar-status-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #10b981;
    border: 3px solid #1e1b4b;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
    animation: pulseStatus 2s infinite;
}

@keyframes pulseStatus {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

:where(.profile-modal-overlay) .profile-hero-meta {
    flex: 1;
    min-width: 0;
}

:where(.profile-modal-overlay) .profile-hero-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

:where(.profile-modal-overlay) .profile-hero-name {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.02em;
}

:where(.profile-modal-overlay) .profile-superadmin-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    padding: 3px 10px;
    border-radius: 9999px;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35);
}

:where(.profile-modal-overlay) .profile-hero-role-desc {
    margin: 0 0 10px 0;
    font-size: 0.85rem;
    color: #cbd5e1;
    font-weight: 400;
}

:where(.profile-modal-overlay) .profile-hero-badges-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

:where(.profile-modal-overlay) .profile-email-badge {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #e2e8f0;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

:where(.profile-modal-overlay) .profile-email-badge:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

:where(.profile-modal-overlay) .copied-tag {
    color: #34d399;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

:where(.profile-modal-overlay) .copy-icon-tag {
    opacity: 0.65;
    font-size: 0.7rem;
}

:where(.profile-modal-overlay) .profile-id-pill {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #94a3b8;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 8px;
}

:where(.profile-modal-overlay) .profile-status-pill {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

:where(.profile-modal-overlay) .pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #34d399;
}

/* ==========================================================================
   NAVIGATION TABS
   ========================================================================== */
:where(.profile-modal-overlay) .profile-nav-tabs {
    display: flex;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 16px;
    gap: 6px;
    overflow-x: auto;
}

:where(.profile-modal-overlay) .profile-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

:where(.profile-modal-overlay) .profile-tab-btn:hover {
    color: #1e1b4b;
    background: rgba(241, 245, 249, 0.7);
}

:where(.profile-modal-overlay) .profile-tab-btn.active {
    color: #4338ca;
    border-bottom-color: #4338ca;
    background: #ffffff;
}

/* ==========================================================================
   ALERTS
   ========================================================================== */
:where(.profile-modal-overlay) .profile-alert {
    margin: 16px 24px 0 24px;
    padding: 12px 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.86rem;
    font-weight: 500;
    animation: alertSlideDown 0.2s ease forwards;
}

@keyframes alertSlideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

:where(.profile-modal-overlay) .profile-alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

:where(.profile-modal-overlay) .profile-alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

:where(.profile-modal-overlay) .alert-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    color: currentColor;
    opacity: 0.7;
    cursor: pointer;
}

:where(.profile-modal-overlay) .alert-dismiss:hover {
    opacity: 1;
}

/* ==========================================================================
   MODAL BODY & SCROLL
   ========================================================================== */
:where(.profile-modal-overlay) .profile-modal-body {
    padding: 24px 28px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    overscroll-behavior: contain;
}

:where(.profile-modal-overlay) .profile-modal-header-banner,
:where(.profile-modal-overlay) .profile-nav-tabs,
:where(.profile-modal-overlay) .profile-modal-footer {
    flex-shrink: 0;
}

:where(.profile-modal-overlay) .profile-modal-body::-webkit-scrollbar {
    width: 6px;
}

:where(.profile-modal-overlay) .profile-modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
}

:where(.profile-modal-overlay) .profile-modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Loading Box */
:where(.profile-modal-overlay) .profile-loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #64748b;
    gap: 16px;
    text-align: center;
}

:where(.profile-modal-overlay) .profile-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: #4338ca;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   TAB 1: VUE D'ENSEMBLE
   ========================================================================== */
:where(.profile-modal-overlay) .profile-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

:where(.profile-modal-overlay) .profile-info-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
    transition: all 0.2s ease;
}

:where(.profile-modal-overlay) .profile-info-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

:where(.profile-modal-overlay) .card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

:where(.profile-modal-overlay) .card-icon-bubble {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #eef2ff;
    color: #4338ca;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

:where(.profile-modal-overlay) .card-icon-bubble.security {
    background: #ecfdf5;
    color: #059669;
}

:where(.profile-modal-overlay) .card-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
}

:where(.profile-modal-overlay) .card-subtitle {
    margin: 0;
    font-size: 0.75rem;
    color: #64748b;
}

:where(.profile-modal-overlay) .card-details-list {
    display: flex;
    flex-direction: column;
    gap: 11px;
}

:where(.profile-modal-overlay) .detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.83rem;
    gap: 12px;
}

:where(.profile-modal-overlay) .detail-label {
    color: #64748b;
    font-weight: 500;
}

:where(.profile-modal-overlay) .detail-value {
    color: #0f172a;
    font-weight: 600;
    text-align: right;
    word-break: break-all;
}

:where(.profile-modal-overlay) .detail-value.highlight-email {
    color: #3730a3;
    font-family: monospace;
    font-size: 0.8rem;
}

:where(.profile-modal-overlay) .detail-value.badge-role {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #eef2ff;
    color: #3730a3;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.76rem;
}

:where(.profile-modal-overlay) .detail-value.status-active {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #059669;
    font-weight: 700;
}

/* Quick Actions Bar */
:where(.profile-modal-overlay) .profile-quick-actions-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 6px;
}

:where(.profile-modal-overlay) .btn-quick-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    color: #334155;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

:where(.profile-modal-overlay) .btn-quick-action:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

:where(.profile-modal-overlay) .btn-quick-action.highlight {
    background: linear-gradient(135deg, #1e1b4b 0%, #3730a3 100%);
    color: #ffffff;
    border: none;
    box-shadow: 0 2px 6px rgba(30, 27, 75, 0.2);
}

:where(.profile-modal-overlay) .btn-quick-action.highlight:hover {
    background: linear-gradient(135deg, #312e81 0%, #4338ca 100%);
    transform: translateY(-1px);
}

/* ==========================================================================
   TAB 2 & 3: FORMS (EDIT & PASSWORD)
   ========================================================================== */
:where(.profile-modal-overlay) .form-intro-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 0.84rem;
    color: #475569;
    line-height: 1.45;
}

:where(.profile-modal-overlay) .form-intro-banner svg {
    color: #4338ca;
    font-size: 1.15rem;
    flex-shrink: 0;
}

:where(.profile-modal-overlay) .form-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

:where(.profile-modal-overlay) .form-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

:where(.profile-modal-overlay) .form-field-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
}

:where(.profile-modal-overlay) .field-label-with-strength {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

:where(.profile-modal-overlay) .strength-text {
    font-size: 0.74rem;
}

:where(.profile-modal-overlay) .input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

:where(.profile-modal-overlay) .field-icon {
    position: absolute;
    left: 14px;
    color: #94a3b8;
    font-size: 0.95rem;
    pointer-events: none;
}

:where(.profile-modal-overlay) .input-icon-wrapper input {
    width: 100%;
    padding: 11px 42px 11px 40px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 0.88rem;
    color: #0f172a;
    font-weight: 500;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

:where(.profile-modal-overlay) .input-icon-wrapper input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

:where(.profile-modal-overlay) .password-toggle-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    transition: color 0.2s ease;
}

:where(.profile-modal-overlay) .password-toggle-btn:hover {
    color: #334155;
}

:where(.profile-modal-overlay) .field-hint {
    font-size: 0.75rem;
    color: #64748b;
}

:where(.profile-modal-overlay) .password-strength-bar {
    width: 100%;
    height: 5px;
    background: #e2e8f0;
    border-radius: 3px;
    margin-top: 6px;
    overflow: hidden;
}

:where(.profile-modal-overlay) .password-strength-fill {
    height: 100%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

:where(.profile-modal-overlay) .match-indicator {
    font-size: 0.76rem;
    font-weight: 600;
    margin-top: 4px;
}

:where(.profile-modal-overlay) .match-indicator.match {
    color: #047857;
}

:where(.profile-modal-overlay) .match-indicator.mismatch {
    color: #dc2626;
}

:where(.profile-modal-overlay) .form-actions-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

:where(.profile-modal-overlay) .btn-primary-save {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(30, 27, 75, 0.2);
}

:where(.profile-modal-overlay) .btn-primary-save:hover:not(:disabled) {
    background: linear-gradient(135deg, #312e81 0%, #4f46e5 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(67, 56, 202, 0.3);
}

:where(.profile-modal-overlay) .btn-primary-save:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

:where(.profile-modal-overlay) .btn-secondary-cancel {
    padding: 11px 18px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    color: #475569;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

:where(.profile-modal-overlay) .btn-secondary-cancel:hover {
    background: #f1f5f9;
    color: #0f172a;
}

:where(.profile-modal-overlay) .button-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* ==========================================================================
   TAB 4: PRIVILÈGES & SYSTÈME
   ========================================================================== */
:where(.profile-modal-overlay) .permissions-intro {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
    border: 1px solid #dbeafe;
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

:where(.profile-modal-overlay) .permissions-intro .intro-icon {
    font-size: 1.8rem;
    color: #2563eb;
    flex-shrink: 0;
}

:where(.profile-modal-overlay) .permissions-intro h4 {
    margin: 0 0 4px 0;
    font-size: 0.98rem;
    font-weight: 700;
    color: #1e3a8a;
}

:where(.profile-modal-overlay) .permissions-intro p {
    margin: 0;
    font-size: 0.82rem;
    color: #475569;
}

:where(.profile-modal-overlay) .permissions-pills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

:where(.profile-modal-overlay) .permission-pill-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

:where(.profile-modal-overlay) .permission-pill-card .perm-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: #0f172a;
    margin-bottom: 6px;
}

:where(.profile-modal-overlay) .permission-pill-card .perm-header svg {
    color: #4338ca;
}

:where(.profile-modal-overlay) .permission-pill-card .perm-level {
    display: inline-block;
    background: #ecfdf5;
    color: #047857;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    margin-bottom: 6px;
}

:where(.profile-modal-overlay) .permission-pill-card .perm-desc {
    margin: 0;
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.4;
}

:where(.profile-modal-overlay) .security-notice-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 0.82rem;
    color: #92400e;
    line-height: 1.45;
}

:where(.profile-modal-overlay) .security-notice-box svg {
    color: #d97706;
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 2px;
}

:where(.profile-modal-overlay) .security-notice-box p {
    margin: 0;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
:where(.profile-modal-overlay) .profile-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    gap: 12px;
    flex-wrap: wrap;
}

:where(.profile-modal-overlay) .btn-profile-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background: #ffffff;
    border: 1px solid #fecaca;
    color: #dc2626;
    border-radius: 10px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

:where(.profile-modal-overlay) .btn-profile-logout:hover {
    background: #fef2f2;
    border-color: #ef4444;
    color: #b91c1c;
}

:where(.profile-modal-overlay) .btn-profile-close {
    padding: 9px 24px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    border-radius: 10px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

:where(.profile-modal-overlay) .btn-profile-close:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 640px) {
    :where(.profile-modal-overlay) .profile-modal-container {
        max-height: 95vh;
        border-radius: 20px;
    }

    :where(.profile-modal-overlay) .profile-modal-header-banner {
        padding: 20px 18px;
    }

    :where(.profile-modal-overlay) .profile-hero-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    :where(.profile-modal-overlay) .profile-hero-name {
        font-size: 1.25rem;
    }

    :where(.profile-modal-overlay) .profile-modal-body {
        padding: 18px;
    }

    :where(.profile-modal-overlay) .form-fields-grid {
        grid-template-columns: 1fr;
    }

    :where(.profile-modal-overlay) .profile-cards-grid {
        grid-template-columns: 1fr;
    }

    :where(.profile-modal-overlay) .profile-modal-footer {
        padding: 14px 18px;
    }
}

@media (max-width: 640px) and (max-height: 640px) {
    :where(.profile-modal-overlay) .profile-modal-security .profile-modal-header-banner {
        padding: 12px 18px;
    }

    :where(.profile-modal-overlay) .profile-modal-security .profile-banner-top {
        margin-bottom: 8px;
    }

    :where(.profile-modal-overlay) .profile-modal-security .profile-banner-institution {
        max-width: calc(100% - 48px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    :where(.profile-modal-overlay) .profile-modal-security .profile-avatar-wrapper,
    :where(.profile-modal-overlay) .profile-modal-security .profile-hero-role-desc,
    :where(.profile-modal-overlay) .profile-modal-security .profile-superadmin-pill,
    :where(.profile-modal-overlay) .profile-modal-security .profile-id-pill,
    :where(.profile-modal-overlay) .profile-modal-security .profile-status-pill {
        display: none;
    }

    :where(.profile-modal-overlay) .profile-modal-security .profile-hero-name {
        font-size: 1.1rem;
    }
}

/* Accessibility rules remain confined to the account dialog. */
@media screen {
    :where(.profile-modal-overlay) .profile-modal-container :is(button,input,a,[tabindex]):focus-visible { outline: 3px solid #2563eb !important; outline-offset: 3px; }
    :where(.profile-modal-overlay) .profile-modal-container .profile-modal-header-banner :focus-visible { outline-color: #93c5fd !important; }
    :where(.profile-modal-overlay) .profile-modal-container .status-active { color: #047857 !important; }
    :where(.profile-modal-overlay) .profile-modal-container .strength-text { color: #334155 !important; }
    :where(.profile-modal-overlay) .profile-modal-container .alert-dismiss { min-width: 36px; min-height: 36px; opacity: 1; }
    :where(.profile-modal-overlay) .profile-modal-container .profile-tab-btn { min-height: 40px; }
    :where(.profile-modal-overlay) .profile-modal-container .profile-tab-btn[aria-selected="true"] { border-bottom-width: 3px; }
    :where(.profile-modal-overlay) .profile-modal-container .profile-tab-btn:disabled { opacity: 1; color: #475569; cursor: wait; }
    :where(.profile-modal-overlay) .profile-modal-container .profile-nav-tabs { scroll-padding: 6px; }
    @media (prefers-reduced-motion: reduce) {
        .profile-modal-overlay,:where(.profile-modal-overlay) .profile-modal-container,:where(.profile-modal-overlay) .profile-modal-container * { animation: none !important; transition: none !important; }
    }
}

@media screen {
    :where(.profile-modal-overlay) .profile-modal-container .profile-superadmin-pill { background: #b45309 !important; color: #fff !important; }
    :where(.profile-modal-overlay) .profile-modal-container .profile-id-pill { color: #e2e8f0 !important; }
}

/* At high native zoom, keep the entire dialog vertically reachable. */
@media screen and (max-height: 600px) {
    .profile-modal-overlay { padding: 8px; }
    :where(.profile-modal-overlay) .profile-modal-container { max-height: calc(100dvh - 16px); overflow-y: auto; }
    :where(.profile-modal-overlay) .profile-modal-container .profile-modal-body { flex: 0 0 auto; min-height: auto; overflow: visible; }
    :where(.profile-modal-overlay) .profile-modal-container .profile-modal-footer { position: static; }
}
