give geometry the chance to know the headheight you are using by setting it with the geometry options:
Welcome to TeX.SE!
You can include the tikzpicture at the beginning of the document using the overlay option to ensure it doesn't take any space. From there, it can be appropriately shifted so that (for instance) the top-left corner of the green rectangle coincides with the top-left corner of the page. The code would be a bit more natural if you had given ...
it is easier to let geometry do all the setting, which can be done with includefoot:
footskip is the distance between the textbody and the baseline of the footer. 2mm is not enough here, use at least 6mm. You can set footskip in geometry, no need to do a \setlength.
The absolute simplest solution is to let KOMA-script do the job. Since you are using 12pt font and A4 paper, scrartcl will automatically calculate a type area where the left, right and top margins are approximately 25mm, (exclusive header). The bottom margin will be ca. 31mm (to baseline of the page number).
Using KOMA-script internal functions gives you ...
Disclaimer: I would suggest to use class scrreprt and \chapter.
Do not misuse \addtkomafont. There are only font commands allowed in the argument.
Change the patch of \sectionlinesformat to: