I hope you have found your answer at this point, but just in case you haven’t: “man” here means “mankind,” “humankind,” etc. For example, “Man’s greatest treasure” means “Mankind’s greatest treasure.” If J.K. Rowling (or Rowena Ravenclaw, I guess) wanted to indicate gender, she would have used “men.” In short, “man” means “mankind”/“humankind.”
“A man”/“The man” = “a male.” ONE MALE (this is important in a few seconds).
“Man,” when used alone (without “a”/“the”/etc.) , = “mankind.”
If J.K. Rowling had wanted to apply the quote to the male gender only, she would have written “[...] men’s greatest treasure.” She would have pluralized it.