Outline: align numbers of headers to the right

Hello,
I would like to align the numbers of headers in my outline to the right.
So to achieve something similar like this:
https://tex.stackexchange.com/questions/510223/how-to-align-to-right-number-sections-in-toc

My code looks like this:

#set heading(numbering: "1.1.1.1")


#outline()


= first
= second
= third
= fourth
= fifth
= sixth
= seventh
= eighth
= ninth
= tenth
= eleventh

And here is the corresponding picture (with an arrow indicating what I actually would like to do).

Thanks for any ideas!

Here’s the first solution I could think of:

Code
#set heading(numbering: "1.1.1.1")

#show outline.entry: it => link(
  it.element.location(),
  it.indented(
    box(
      width: measure(str(counter(heading).final().first())).width,
      align(
        right,
        it.prefix(),
      ),
    ),
    it.inner(),
  ),
)

#outline()

= first
= second
= third
= fourth
= fifth
= sixth
= seventh
= eighth
= ninth
= tenth
= eleventh

Outlines which also contain the figure supplement appear to overflow to the left, is that desirable in your situation?

You would need to use a separate counter here, in fact for every outline.

Inspired by @hpcfzl , this is an improved version:

#show outline.entry: it => link(
  it.element.location(),
  it.indented(
    box(
      width: calc.max(
        ..query(outline.entry.where(level: it.level))
        .map(it => measure(it.prefix()).width)
      ),
      align(
        right,
        it.prefix(),
      ),
    ),
    it.inner(),
  ),
)

It handles different level of headings separately, and use the maximum width as the final box size.

Great! Thank you both for your solutions!