Since the girl has yet to be mentioned at the point "det" is used in the sentence, "det" cannot be a pronoun pointing back to the girl. Rather, it's a formal/empty subject; a placeholder of sorts.
When introducing something new, you default to the neuter form. When whatever it is has been mentioned, and you're using the pronoun to refer back to it, it needs to agree with the gender of the noun.
"Det er en bil. Den er fin."
"It is a car. It (=the car) is nice."
You can't replace the first "it" with "the car", because then you'd be saying "The car is a car". Makes sense?
Both dette and denne mean this, whereas, det/den typically mean that/it:
Dette er jenta mi. - This is my girl.
Det er jenta mi. - That is my girl.
Denne jenta heter Astrid. - This girl is called Astrid.
Den jenta heter Astrid. - That girl is called Astrid.
In both Norwegian and English, if you're pointing at something, this (dette/denne) is closer to you; that (det/den) is farther away.