.profile-menu {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.profile-menu-btn {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--admin-text);
  cursor: pointer;
  line-height: 1;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.profile-menu-btn:hover,
.profile-menu-btn[aria-expanded="true"] {
  background: #f5f5f7;
  border-color: var(--admin-border);
}

.profile-menu-btn:focus-visible,
.profile-menu-input:focus-visible,
.profile-menu-preview-avatar-btn:focus-visible,
.profile-menu-avatar-menu-item:focus-visible {
  outline: 2px solid var(--admin-accent-focus);
  outline-offset: 2px;
}

.profile-menu-avatar-wrap,
.profile-menu-preview-avatar-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 999px;
  background: #f3f3f6;
  color: var(--admin-text);
  font-weight: 750;
  flex: 0 0 auto;
}

.profile-menu-avatar-wrap {
  width: 32px;
  height: 32px;
}

.profile-menu-preview-avatar-wrap {
  width: 56px;
  height: 56px;
}

.profile-menu-avatar,
.profile-menu-preview-avatar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-menu-avatar-fallback,
.profile-menu-preview-fallback {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--admin-accent-weak);
  color: var(--admin-accent);
}

.profile-menu-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
}

.profile-menu-modal {
  z-index: 2200;
}

.profile-menu-modal-card {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  overflow: hidden;
  border-radius: calc(var(--r) + 2px);
  background: #fff;
}

.profile-menu-modal-head {
  background: #fff;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

.profile-menu-modal-title {
  margin: 0;
}

.profile-menu-modal-body {
  display: block;
  padding: 16px 20px;
  overflow: visible;
  background: #fff;
}

.profile-menu-preview {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--admin-border);
  border-radius: var(--r);
  background: #fcfcfd;
  overflow: visible;
}

.profile-menu-preview-avatar-btn {
  position: relative;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  flex: 0 0 auto;
}

.profile-menu-avatar-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(17, 18, 20, 0.36);
  color: #fff;
  opacity: 0;
  transition: opacity 140ms ease;
}

.profile-menu-preview-avatar-btn:hover .profile-menu-avatar-overlay,
.profile-menu-preview-avatar-btn:focus-visible .profile-menu-avatar-overlay,
.profile-menu-preview-avatar-btn[aria-expanded="true"] .profile-menu-avatar-overlay {
  opacity: 1;
}

.profile-menu-avatar-overlay-icon {
  width: 18px;
  height: 18px;
}

.profile-menu-avatar-overlay-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.profile-menu-avatar-menu {
  position: absolute;
  top: 74px;
  left: 12px;
  z-index: 2250;
  min-width: 160px;
  padding: 6px;
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--admin-shadow);
}

.profile-menu-avatar-menu-item {
  width: 100%;
  display: block;
  padding: 9px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--admin-text);
  text-align: left;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.profile-menu-avatar-menu-item:hover {
  background: #f5f5f7;
}

.profile-menu-input {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.profile-menu-preview-input {
  flex: 1 1 auto;
}

.profile-menu-security {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--admin-border);
  border-radius: var(--r);
  background: #fcfcfd;
}

.profile-menu-security-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.profile-menu-security-summary {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.profile-menu-security-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--admin-text);
}

.profile-menu-security-state {
  color: var(--admin-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.profile-menu-security-state.is-enabled {
  color: #148255;
}

.profile-menu-security-actions,
.profile-menu-security-enroll-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.profile-menu-security-enroll {
  display: grid;
  gap: 14px;
  padding: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(55, 53, 47, 0.08);
  border-radius: 14px;
  background: #fff;
}

.profile-menu-security-enroll-head {
  display: block;
}

.profile-menu-security-enroll-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--admin-text);
}

.profile-menu-security-enroll-grid {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.profile-menu-security-qr-stack {
  display: grid;
  gap: 12px;
  align-content: start;
}

.profile-menu-security-qr-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  border: 1px solid rgba(55, 53, 47, 0.08);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #fafafb 100%);
}

.profile-menu-security-qr {
  width: min(192px, 100%);
  min-height: 192px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(55, 53, 47, 0.12);
  border-radius: 14px;
  background: #fff;
}

.profile-menu-security-qr img,
.profile-menu-security-qr svg {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.profile-menu-security-enroll-fields {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.profile-menu-security-secret-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.profile-menu-security-secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.profile-menu-security-copy-btn {
  flex: 0 0 auto;
  min-width: 84px;
}

.profile-menu-security-enroll-actions {
  margin-top: 2px;
}

.profile-menu-security-code {
  letter-spacing: 0.28em;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}

.profile-menu-security-hint {
  color: var(--admin-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.profile-menu-modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: #fff;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}

.profile-menu-logout-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.profile-menu-logout {
  width: 100%;
  margin: 0;
  border-color: rgba(96, 100, 108, 0.2);
  background: rgba(96, 100, 108, 0.06);
  color: var(--admin-text);
  font-weight: 650;
}

.profile-menu-logout:hover {
  border-color: rgba(96, 100, 108, 0.3);
  background: rgba(96, 100, 108, 0.1);
}

.profile-menu-account-fields {
  display: grid;
  gap: 14px;
  flex: 1 1 auto;
  min-width: 0;
}

.profile-menu-account-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.profile-menu-embedded {
  width: 100%;
  max-width: 100%;
}

.profile-menu-embedded .profile-menu-modal,
.profile-menu-embedded .profile-menu-modal-card,
.profile-menu-embedded .profile-menu-modal-body,
.profile-menu-embedded .profile-menu-modal-actions {
  display: contents;
}

.profile-menu-embedded .profile-menu-popup,
.profile-menu-embedded .profile-menu-account-fields {
  width: 100%;
}

.profile-menu-embedded .profile-menu-account-fields {
  gap: 16px;
}

.profile-menu-embedded .profile-menu-input {
  width: 100%;
}

.profile-menu-embedded #profileMenuAvatarField {
  width: 100%;
}

.profile-menu-embedded .profile-menu-account-footer {
  width: 100%;
  margin-top: 2px;
}

.profile-menu-embedded .profile-menu-logout {
  width: auto;
  min-width: 96px;
  margin: 0 0 0 auto;
}

.profile-menu-embedded #profileMenuCancelBtn,
.profile-menu-embedded #profileMenuSaveBtn,
.profile-menu-embedded #profileMenuCloseBtn,
.profile-menu-embedded .profile-menu-modal-title,
.profile-menu-embedded .profile-menu-preview,
.profile-menu-embedded .profile-menu-security,
.profile-menu-embedded .profile-menu-logout-row {
  display: none !important;
}

.sidebar-profile-mount .profile-menu-btn {
  min-height: 32px;
  height: 32px;
  padding: 5px 8px;
  border-radius: 8px;
  gap: 8px;
  line-height: 1.3;
}

.sidebar-profile-mount .profile-menu-avatar-wrap {
  width: 20px;
  height: 20px;
}

.sidebar-profile-mount .profile-menu-name {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  align-self: stretch;
}

.profile-menu-btn[hidden],
.profile-menu-modal[hidden],
.profile-menu-avatar-menu[hidden],
.profile-menu-security-enroll[hidden],
.profile-menu-security-qr-card[hidden],
.profile-menu-security-qr[hidden],
.profile-menu-avatar[hidden],
.profile-menu-preview-avatar[hidden],
.profile-menu-avatar-fallback[hidden],
.profile-menu-preview-fallback[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .profile-menu-modal-card {
    width: min(520px, calc(100vw - 32px));
  }

  .profile-menu-preview {
    align-items: flex-start;
  }

  .profile-menu-security-enroll-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .profile-menu-modal-actions {
    flex-wrap: wrap-reverse;
  }

  .profile-menu-preview {
    flex-direction: column;
    align-items: stretch;
  }

  .profile-menu-security-head {
    flex-direction: column;
  }

  .profile-menu-security-secret-row,
  .profile-menu-security-enroll-actions {
    flex-direction: column;
  }

  .profile-menu-logout-row,
  .profile-menu-modal-actions .btn,
  .profile-menu-security-actions .btn,
  .profile-menu-security-enroll-actions .btn,
  .profile-menu-security-copy-btn {
    width: 100%;
  }

  .profile-menu-logout {
    width: 100%;
  }
}
