Coping with a difficult manager is never fun, but some lines should never be crossed.

We’ve all had our share of difficult bosses. Those who micromanage to death and those who pay no attention at all. The experts who lack basic communication skills and the sub-proficient who love interacting with employees.

But how do you determine when your boss is so difficult or stressful that you should look for ways to protect yourself?

If, after reading through the examples below, you believe you’ve experienced discrimination or harassment, follow the steps outlined here and look to your HR department for support.

When you’re new to a company, it’s a little like being in a foreign country. You need to learn the local language and customs, the underlying culture of the organization. How do people dress? Talk? Interact? Be a good observer as you learn to fit into that culture.

Take note of the organizational structure: Who reports to whom? What is the line of authority? This can be important if you experience problems with someone other than your immediate supervisor.

Once you have the lay of the land, you can begin to get a sense of where and how you fit in and what kind of behavior deviates from the norm. Let’s consider some possible scenarios.

1. Your boss treats you differently.

Your boss holds you to higher standards, directs more criticism at you, gives you more work than your colleagues. Is it because of your gender, race or religious beliefs? Or is he or she seeing your potential and grooming you to take on more responsibility?

Before rushing to judgment, look at the big picture. Are you the only woman in your department? The only minority? Are you uncomfortable, or just pushed to do more than you’ve done before? If you feel that you’re being singled out for reasons other than your abilities, you may have grounds for a discrimination claim. Federal law bars employers from treating workers differently based on race, color, religion, sex, or national origin, and provides protections for older, pregnant and disabled workers.

Keep a written record of how you’re treated, including any remarks that may show bias. If you can, talk with your boss. Ask her why you’re being singled out or treated differently. If you’re unable to do this or feel that your concerns weren’t properly addressed, go to HR and share your story and documentation with them.

2. Your boss makes you uncomfortable.

He comments on your clothes or your hair, tells off-color jokes, or fosters a locker-room culture in your department. Even if your supervisor isn’t the one making inappropriate comments, his failure to take action when others do so is unacceptable. The workplace is not a boys’ club, and a manager who participates in or condones inappropriate behavior is creating a hostile work environment.

After-hours or off-site gatherings that are work-related must also be open and inclusive. The ban against hostile work environment doesn’t stop at the office door. Rude or offensive behavior shown to everyone in the workplace that doesn’t specifically address gender or sexuality isn’t sexual harassment, but it’s still not okay.

If you experience or observe inappropriate comments, try sharing your concerns with your boss or co-workers. Maybe, “You shouldn’t say things that make people uncomfortable” or “Do you think that comment could be viewed as hurtful or inappropriate?” Sometimes a gentle reminder is all that’s needed. If that doesn’t do the trick, document what happened and take it to HR. You can use your phone to take notes, or send text messages or an email to yourself while an incident is fresh in your mind. It’s your employer’s job to make the workplace safe for everybody.

3. Your boss asks you for favors.

When you enter into an employment contract, you agree to provide specific services to your employer in exchange for specific benefits and wages. This is perfectly normal and legal. When your supervisor, however, asks you for “something for something” — sexual favors in exchange for a job, a promotion, job benefits, or something else of value — it is neither normal nor legal.

You are under no obligation to do something outside the scope of your job description. Document what happened and report it to HR. If you believe you’ve been retaliated against because of your refusal to provide favors, you may have grounds for a legal claim against your company.

What are your rights?

Document as much as you can as soon as you can. If there were witnesses, get them to confirm what occurred. This can be done with a simple text or email — “Can you believe that our boss just made that crude remark about wanting to see you naked?” “Yes, he’s a creep!” If you’re unable to write things down immediately, do your best to create a timeline of what happened, when and where it happened, and who was involved. A review of your calendar and any documents you’ve already collected may help refresh your memory and suggest other potential documents. You can ask witnesses to verify what happened even if the event occurred weeks ago.

Share your story with HR. Let them do an investigation and take whatever action they believe is necessary to resolve the matter. If you believe HR’s investigation or action was inadequate, you may also file a complaint with the EEOC or a state agency. Such a complaint is generally a precondition for filing a lawsuit.

Above all, look out for self

Understand the corporate culture, learn the chain of command, assert your rights, document what happened, and report to HR in a timely manner. When you take care of yourself, you help others in your workplace and make your company a better place to work.

26 Signs You’re a Great Boss, Even If It Doesn’t Feel Like It

“People look for retreats for themselves, in the country, by the coast, or in the hills . . . There is nowhere that a person can find a more peaceful and trouble-free retreat than in his own mind. . . . So constantly give yourself this retreat, and renew yourself.”