main {
  display: flex;
  flex-direction: row;
  margin: 0 auto;
  gap: 1rem;

  overflow: unset !important; /* "scroll" would prevent the sticky <aside> */
}

@media screen and (max-width: 600px) {
  nav ul:not(:first-child) {
    display: none;
  }

  nav {
    justify-self: center;
  }
}

aside {
  max-width: 30%;
  padding: 1rem;
  background-color: #fff0ed;

  position: sticky;
  top: 0;
  height: max-content;
}

aside h1 {
  font-size: larger;
  font-weight: bold;
  text-align: center;
  color: black;
}

aside ol {
  list-style: none;
  counter-reset: list-counter;
  padding: 0;
}

aside li {
  counter-increment: list-counter;
  position: relative;

  color: black;
  padding: 1em;
  padding-left: 3.5em;
  border-radius: 0.5em;
  white-space: nowrap;
  margin: 1em;
}

aside li::before {
  content: counter(list-counter);
  position: absolute;
  left: 0.75em;
  top: 0.75em;
  width: 2em;
  height: 2em;
  line-height: 2em;
  text-align: center;
  font-weight: bold;
  border-radius: 50%; /* Makes it circular */
  background-color: var(--pico-primary);
  color: white;
}

aside li.active {
  background-color: var(--pico-primary);
  color: white;
}

aside li.active::before {
  background-color: white;
  color: var(--pico-primary);
}

@media screen and (max-width: 600px) {
  aside {
    display: none;
  }
}

form {
  width: 100%;
}

#id_is_sepa_helptext, /* make this helptext always visible */
fieldset:has([name=agb]) .helptext, /* ALL help text in the fieldset where AGB is in shall always be visible */
#id_sepa_mandat_helptext, #id_ueberweisung_info_helptext {
  color: var(--pico-primary);
  opacity: 1;
}
  
section:has([name=heute_button], [name=next_month_button]) {
  display: inline-block;
  width: fit-content;
  margin-inline-end: 1%;
}

/* Put the checkboxes right beside the label */
section:has([name=agb], [name=datenschutz]) label {
  display: inline;
  margin-inline-end: 1em;
}

@media screen and (min-width: 601px) {
  section:has([name=heute_button], [name=next_month_button]) {
    /* Align with the lieferbeginn input left of it, these here have no label. */
    margin-top: 1.2em;
  }
  
  #id_anrede > div,
  #id_anzahl_personen > div {
    display: inline-block;
    margin-right: 1em;
  }

  /* row 1 */
  section:has([name=strasse], [name=hausnummer]) {
    display: inline-block;
    width: 49%;
    margin-inline-end: 1%;
  }

  /* row 2 */
  section:has([name=lagebezeichnung]) {
    display: block;
    width: 49%;
    margin-inline-end: 1%;
  }

  /* row 3 */
  section:has([name=plz], [name=ort]) {
    display: inline-block;
    width: 49%;
    margin-inline-end: 1%;
  }

  /* row Zaehler */
  section:has([name=zaehlernummer], [name=anfangszaehlerstand]) {
    display: inline-block;
    width: 49%;
    margin-inline-end: 1%;
  }

  /* rows person */
  section:has([name=anrede], [name=name], [name=telefon], [name=email]) {
    display: inline-block;
    width: 49%;
    margin-inline-end: 1%;
  }

  /* rows vertrag */
  section:has([name=verbrauchsschaetzung], [name=abschlag]) {
    display: inline-block;
    width: 49%;
    margin-inline-end: 1%;
  }

  section:has([name=lieferbeginn]) {
    display: inline-block;
    width: 15em;
    margin-inline-end: 1%;
  }
  
  #id_is_sepa > div {
    display: inline-block;
    margin-right: 10em;
  }
  
  /* rows zahlung */
  section:has([name=iban], [name=bic], [name=kontoinhaber]) {
    display: inline-block;
    width: 32%;
    margin-inline-end: 1%;
  }

  /* rows consent */
  section:has([name=agb], [name=datenschutz]) {
    display: inline-block;
    width: 49%;
    margin-inline-end: 1%;
  }
}

div.inactive {
  display: none;
}

fieldset.disabled,
p.disabled {
  opacity: 0.1;
}

/* We will show the bank name in here. */
section:has([name=bic]) .helptext {
  opacity: 1;
  font-size: smaller;
  color: black;
}