.account-menu {
  position: relative;
  flex: 0 0 auto;
}

body.account-menu-open .dash-topbar,
body.account-menu-open .staff-topbar {
  z-index: 190;
}

.account-menu-trigger {
  min-width: 190px;
  min-height: 50px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 16px;
  gap: 10px;
  align-items: center;
  padding: 6px 10px 6px 7px;
  color: var(--ink-900);
  text-align: left;
  background: rgb(255 255 255 / 92%);
  border: 1px solid #d7dfeb;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgb(14 34 67 / 3%);
  transition: border-color 170ms ease, box-shadow 170ms ease, transform 170ms ease, background 170ms ease;
}

.account-menu-trigger.compact {
  min-width: 205px;
}

.account-menu-trigger:hover,
.account-menu-trigger[aria-expanded="true"] {
  background: #fff;
  border-color: #adc7e9;
  box-shadow: 0 10px 26px rgb(18 48 91 / 10%);
}

.account-menu-trigger:active {
  transform: translateY(1px);
}

.account-menu-trigger:focus-visible {
  outline: 3px solid rgb(7 95 216 / 18%);
  outline-offset: 2px;
}

.account-trigger-avatar,
.account-profile-avatar {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #dfe9f8;
  border-radius: 10px;
}

.account-trigger-avatar {
  width: 36px;
  height: 36px;
}

.account-trigger-avatar::after,
.account-profile-avatar::after {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 8px;
  height: 8px;
  background: #22b879;
  border: 2px solid #fff;
  border-radius: 50%;
  content: "";
}

.account-trigger-avatar img,
.account-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-trigger-copy {
  min-width: 0;
}

.account-trigger-copy small,
.account-trigger-copy strong {
  display: block;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.account-trigger-copy small {
  margin-bottom: 3px;
  color: var(--ink-500, #758195);
  font-size: .56rem;
  font-weight: 700;
}

.account-trigger-copy strong {
  font-size: .68rem;
}

.account-trigger-chevron {
  color: #718097;
  transition: transform 180ms ease;
}

.account-trigger-chevron .ui-icon {
  width: 15px;
  height: 15px;
}

.account-menu-trigger[aria-expanded="true"] .account-trigger-chevron {
  transform: rotate(180deg);
}

.account-menu-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 180;
  width: min(350px, calc(100vw - 28px));
  max-height: min(620px, calc(100svh - 96px));
  padding: 9px;
  overflow-x: hidden;
  overflow-y: auto;
  visibility: hidden;
  opacity: 0;
  background: rgb(255 255 255 / 98%);
  border: 1px solid rgb(205 216 232 / 88%);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgb(7 28 61 / 22%), 0 3px 12px rgb(7 28 61 / 8%);
  backdrop-filter: blur(20px);
  transform: translateY(-7px) scale(.98);
  transform-origin: top right;
  transition: visibility 0s linear 180ms, opacity 180ms ease, transform 180ms ease;
  overscroll-behavior: contain;
}

.account-menu-popover.is-open {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition-delay: 0s;
}

.account-menu-profile {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: linear-gradient(135deg, #f2f7ff, #f9fbff);
  border: 1px solid #dce8f7;
  border-radius: 15px;
}

.account-profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
}

.account-profile-copy {
  min-width: 0;
}

.account-profile-copy strong,
.account-profile-copy small {
  display: block;
}

.account-profile-copy strong {
  overflow: visible;
  font-size: .78rem;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.account-profile-copy small {
  margin-top: 4px;
  color: var(--ink-600);
  font-size: .6rem;
  line-height: 1.4;
}

.account-verified-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #07885b;
  background: #e4f7ef;
  border-radius: 9px;
}

.account-verified-mark .ui-icon {
  width: 15px;
  height: 15px;
}

.account-menu-label {
  display: block;
  margin: 13px 10px 6px;
  color: #8b97a8;
  font-size: .54rem;
  font-weight: 800;
  letter-spacing: .13em;
}

.account-menu-list {
  display: grid;
  gap: 3px;
}

.account-menu-item {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 16px;
  gap: 11px;
  align-items: center;
  padding: 8px 10px;
  color: var(--ink-900);
  text-align: left;
  text-decoration: none;
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, transform 150ms ease;
}

.account-menu-item:hover,
.account-menu-item:focus-visible {
  color: #075fd8;
  background: #f0f6ff;
  outline: none;
  transform: translateX(2px);
}

.account-item-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #075fd8;
  background: #eaf2ff;
  border-radius: 11px;
}

.account-item-icon .ui-icon,
.account-item-arrow .ui-icon {
  width: 16px;
  height: 16px;
}

.account-item-copy {
  min-width: 0;
}

.account-item-copy strong,
.account-item-copy small {
  display: block;
}

.account-item-copy strong {
  font-size: .69rem;
}

.account-item-copy small {
  margin-top: 4px;
  color: var(--ink-600);
  font-size: .58rem;
  line-height: 1.4;
}

.account-item-arrow {
  color: #9aa6b6;
}

.account-menu-item.danger {
  margin-top: 5px;
  color: #b42331;
  border-top: 1px solid #edf0f5;
  border-radius: 0 0 12px 12px;
}

.account-menu-item.danger:hover,
.account-menu-item.danger:focus-visible {
  color: #a51624;
  background: #fff1f2;
}

.account-menu-item.danger .account-item-icon {
  color: #b42331;
  background: #fff0f1;
}

.account-subview-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 5px 13px;
  border-bottom: 1px solid var(--line);
}

.account-subview-head button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--ink-600);
  background: #f4f7fb;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.account-subview-head strong,
.account-subview-head small {
  display: block;
}

.account-subview-head strong {
  font-size: .76rem;
}

.account-subview-head small {
  margin-top: 3px;
  color: var(--ink-600);
  font-size: .58rem;
}

.account-preferences {
  display: grid;
  gap: 6px;
  padding-top: 10px;
}

.account-preference {
  width: 100%;
  min-height: 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 12px;
  align-items: center;
  padding: 9px 10px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.account-preference:hover,
.account-preference:focus-visible {
  background: #f5f8fc;
  outline: none;
}

.account-preference strong,
.account-preference small {
  display: block;
}

.account-preference strong {
  font-size: .68rem;
}

.account-preference small {
  margin-top: 4px;
  color: var(--ink-600);
  font-size: .58rem;
  line-height: 1.4;
}

.account-switch {
  position: relative;
  width: 38px;
  height: 22px;
  background: #cfd7e3;
  border-radius: 999px;
  transition: background 160ms ease;
}

.account-switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgb(20 40 70 / 22%);
  content: "";
  transition: transform 160ms ease;
}

.account-preference[aria-checked="true"] .account-switch {
  background: #075fd8;
}

.account-preference[aria-checked="true"] .account-switch::after {
  transform: translateX(16px);
}

.account-settings-note {
  display: flex;
  gap: 9px;
  margin-top: 9px;
  padding: 11px;
  color: #39526f;
  background: #f1f6fc;
  border-radius: 11px;
  font-size: .57rem;
  line-height: 1.5;
}

.account-settings-note .ui-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: #075fd8;
}

.account-logout-confirm {
  padding: 14px 9px 8px;
  text-align: center;
}

.account-logout-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin: 4px auto 14px;
  color: #b42331;
  background: #fff0f1;
  border-radius: 17px;
}

.account-logout-icon .ui-icon {
  width: 24px;
  height: 24px;
}

.account-logout-confirm h3 {
  margin: 0;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 1rem;
  letter-spacing: -.035em;
}

.account-logout-confirm p {
  margin: 8px auto 18px;
  color: var(--ink-600);
  font-size: .63rem;
  line-height: 1.55;
}

.account-logout-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.account-logout-actions .btn {
  width: 100%;
  min-height: 42px;
  padding-inline: 12px;
  font-size: .66rem;
}

.account-logout-actions .btn-danger {
  color: #fff;
  background: #b42331;
  border-color: #b42331;
}

@media (max-width: 720px) {
  .account-menu-trigger,
  .account-menu-trigger.compact {
    min-width: 44px;
    min-height: 44px;
    grid-template-columns: 34px;
    padding: 4px;
    border-radius: 12px;
  }

  .account-trigger-avatar {
    width: 34px;
    height: 34px;
  }

  .account-trigger-copy,
  .account-trigger-chevron {
    display: none;
  }

  .account-menu-popover {
    position: fixed;
    top: 76px;
    right: 14px;
    width: min(350px, calc(100vw - 28px));
    max-height: calc(100svh - 92px);
  }

  .dash-topbar .account-menu-popover {
    max-height: calc(100svh - 164px);
  }
}

@media (max-width: 420px) {
  .top-actions {
    gap: 6px;
  }

  .top-actions .icon-btn,
  .account-menu-trigger,
  .account-menu-trigger.compact {
    width: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  .account-trigger-avatar {
    width: 31px;
    height: 31px;
  }

  .account-menu-popover {
    top: 68px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .account-menu-trigger,
  .account-trigger-chevron,
  .account-menu-popover,
  .account-menu-item,
  .account-switch,
  .account-switch::after {
    transition: none;
  }
}
