refactors panel-colouring logic