You derail when you were in the red yesterday and are in the red today. See
My understanding is that this has changed and the colors are now based on number of days since derailment - it would be helpful if @dreev or @bee could confirm!