.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  background: rgba(8, 18, 14, 0.9);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.2);
}

.logo {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.logoMark {
  width: 24px;
  height: 24px;
  border-radius: 50% 50% 44% 44%;
  background: linear-gradient(135deg, var(--primary), #71e7a9);
  display: inline-block;
  position: relative;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.logoMark::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 16px;
  width: 4px;
  height: 10px;
  border-radius: 3px;
  background: #4a2f16;
}

.logoImage {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  flex: 0 0 auto;
}

.logoText {
  max-width: min(220px, 36vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.authActions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.checkingAuth {
  opacity: 0.75;
}

.loginBtn,
.registerBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 40px;
  border-radius: 20px;
  padding: 8px 16px;
  border: 0;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.loginBtn {
  border: 1px solid var(--border);
  background: rgba(238, 248, 239, 0.05);
  color: var(--foreground);
}

.registerBtn {
  border: 1px solid rgba(45, 212, 143, 0.34);
  background: var(--primary-soft);
  color: var(--primary);
}

.loginBtn:hover,
.registerBtn:hover {
  transform: translateY(-2px);
}

.loginBtn:hover {
  background: var(--surface-hover);
}

.registerBtn:hover {
  background: rgba(16, 185, 129, 0.2);
}

.iconGroup {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.iconBtn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(238, 248, 239, 0.05);
  border: 1px solid var(--border);
  color: var(--foreground);
  transition: all var(--transition-fast);
  position: relative;
}

.iconBtn:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.activeIcon {
  border-color: rgba(45, 212, 143, 0.46);
  background: var(--primary-soft);
  color: var(--primary);
}

.iconSvg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.badgeDot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--background);
  border-radius: 50%;
  background: var(--warning);
}

.referralBtn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  border: 1px solid rgba(45, 212, 143, 0.28);
  transition: all var(--transition-fast);
}

.referralBtn:hover {
  background: rgba(45, 212, 143, 0.22);
}

.popover {
  position: absolute;
  top: 52px;
  right: 0;
  width: 320px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
  z-index: 1200;
}

.popoverHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.popoverHeader strong {
  color: var(--foreground);
  font-size: 0.95rem;
}

.popoverHeader a {
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
}

.popoverList {
  display: grid;
  gap: 8px;
  padding-top: 10px;
}

.popoverItem {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: all var(--transition-fast);
}

.popoverItem:hover {
  background: rgba(238, 248, 239, 0.06);
  border-color: var(--border);
}

.popoverItem span {
  color: var(--foreground);
  font-size: 0.84rem;
  font-weight: 700;
}

.popoverItem small {
  color: var(--muted);
  font-size: 0.76rem;
}

.profileMenu {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.accountMenu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.avatar:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(45, 212, 143, 0.24);
}

.accountToggle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: rgba(238, 248, 239, 0.05);
  color: var(--foreground);
  transition: all var(--transition-fast);
}

.accountToggle span {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}

.accountToggle:hover,
.accountToggleActive {
  background: var(--surface-hover);
  border-color: rgba(45, 212, 143, 0.42);
  color: var(--primary);
}

.accountDropdown {
  position: absolute;
  top: 52px;
  right: 0;
  width: 270px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
  z-index: 1300;
}

.accountIdentity {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  transition: background var(--transition-fast);
}

.accountIdentity:hover {
  background: rgba(238, 248, 239, 0.06);
}

.accountAvatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  font-weight: 800;
}

.accountIdentity span:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.accountIdentity strong,
.walletMenuItem strong {
  color: var(--foreground);
  font-size: 0.9rem;
}

.accountIdentity small,
.walletMenuItem span {
  color: var(--muted);
  font-size: 0.78rem;
}

.accountIdentity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.walletMenuItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0;
  padding: 11px 10px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.logoutMenuItem {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 800;
  transition: background var(--transition-fast);
}

.logoutMenuItem:hover {
  background: rgba(255, 107, 107, 0.1);
}

.logoutMenuItem:disabled {
  cursor: wait;
  opacity: 0.7;
}

@media (prefers-color-scheme: light) {
  .popover {
    background: var(--surface-strong);
    box-shadow: var(--shadow-soft);
  }

  .popoverItem small {
    color: var(--muted);
  }

  .accountDropdown {
    background: var(--surface-strong);
    box-shadow: var(--shadow-soft);
  }
}

@media (max-width: 700px) {
  .header {
    padding: 0 14px;
  }

  .logo {
    font-size: 20px;
  }

  .nav {
    gap: 10px;
  }

  .authActions {
    gap: 8px;
  }

  .loginBtn,
  .registerBtn {
    min-width: auto;
    min-height: 38px;
    padding: 8px 12px;
    font-size: 0.875rem;
  }

  .referralBtn {
    display: none;
  }

  .profileMenu {
    margin-left: 4px;
    padding-left: 8px;
    gap: 8px;
  }

  .accountMenu {
    gap: 4px;
  }

  .accountToggle {
    width: 22px;
    height: 22px;
  }

  .accountDropdown {
    right: -4px;
    width: min(270px, calc(100vw - 24px));
  }

  .popover {
    right: -88px;
    width: min(320px, calc(100vw - 24px));
  }
}
