/*
 * Kundenbereich. Brand rules (docs/ARCHITEKTUR.md): blue #1c3fa6 acts, yellow appears only as the offset
 * ("Durchschlag") behind a sheet or a button, no gradients, no cards.
 *
 * The page answers a strict CSP (style-src 'self'): everything lives in this file, nothing inline.
 */

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/statisch/schrift/IBMPlexSans-latin-variabel.woff2") format("woff2");
  font-weight: 100 700;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/statisch/schrift/IBMPlexMono-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --tinte: #0c1b45;
  --tinte-leise: #4a5578;
  --handlung: #1c3fa6;
  --handlung-dunkel: #142f80;
  --versatz: #ffd24a;
  --grund: #ffffff;
  --flaeche: #f4f6fb;
  --linie: #d5dbea;
  --gut: #146c43;
  --schlecht: #a4161a;

  --schrift: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius: 0.375rem;
  --rand: clamp(1.25rem, 4vw, 3.5rem);
  --leiste-breite: 16rem;
  --lesebreite: 60rem;

  /* The same easing and distances as the consent buttons of the website. */
  --ruhe: cubic-bezier(0.2, 0.7, 0.2, 1);
  --versatz-ruhe: 3px;
  --versatz-weit: 6px;
  --versatz-blatt: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--schrift);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--tinte);
  background: var(--grund);
}

a {
  color: var(--handlung);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration-thickness: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--handlung);
  outline-offset: 2px;
}

h1 {
  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 1.75rem 0 0.5rem;
}

p {
  margin: 0.75rem 0;
  max-width: 44rem;
}

.mono,
code {
  font-family: var(--mono);
  font-size: 0.95em;
}

.klein {
  font-size: 0.85rem;
}

.leise {
  color: var(--tinte-leise);
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ demo strip */

.demo {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.75rem;
  max-width: none;
  margin: 0;
  padding: 0.45rem var(--rand);
  background: var(--versatz);
  color: var(--tinte);
  font-size: 0.9rem;
}

.demo strong {
  padding: 0.05rem 0.5rem;
  border: 1.5px solid var(--tinte);
  border-radius: var(--radius);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------ frame: bar on top, rail on wide screens */

.rahmen {
  display: flex;
  flex: 1;
  flex-direction: column;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.spalte {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.leiste {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.9rem var(--rand) 0;
  border-bottom: 1px solid var(--linie);
}

.gast .leiste {
  padding-bottom: 0.9rem;
}

.marke {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--tinte);
  font-weight: 600;
  text-decoration: none;
}

.marke img {
  display: block;
  width: auto;
  height: 32px;
}

.marke span {
  padding-left: 0.75rem;
  border-left: 1px solid var(--linie);
  color: var(--tinte-leise);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.konto {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.firma {
  margin: 0;
  overflow: hidden;
  color: var(--tinte-leise);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.abmelden {
  margin: 0;
}

/* Narrow: the areas are one row that scrolls sideways, the open one is underlined. */
.navi {
  display: flex;
  grid-column: 1 / -1;
  order: 3;
  gap: 0.25rem;
  margin: 0 calc(var(--rand) * -1);
  padding: 0 calc(var(--rand) - 0.6rem);
  overflow-x: auto;
  scrollbar-width: none;
}

.navi::-webkit-scrollbar {
  display: none;
}

.navi a {
  flex: none;
  padding: 0.6rem 0.6rem 0.5rem;
  border-bottom: 3px solid transparent;
  color: var(--tinte);
  text-decoration: none;
  transition: border-color 200ms var(--ruhe), box-shadow 200ms var(--ruhe), background-color 150ms;
}

.navi a:hover {
  border-bottom-color: var(--linie);
}

.navi a[aria-current="page"] {
  border-bottom-color: var(--versatz);
  font-weight: 600;
}

/* The content column sits in the middle of the room it has; inside it everything stays left-aligned. */
.inhalt {
  width: 100%;
  max-width: calc(var(--lesebreite) + 2 * var(--rand));
  margin-inline: auto;
  padding: 2.25rem var(--rand) 3rem;
}

.fuss {
  display: grid;
  gap: 0.5rem 2.5rem;
  margin-top: auto;
  padding: 1.25rem var(--rand) 2rem;
  border-top: 1px solid var(--linie);
  color: var(--tinte-leise);
  font-size: 0.85rem;
}

.fuss p {
  max-width: 34rem;
  margin: 0;
}

.angemeldet .fuss {
  width: 100%;
  max-width: calc(var(--lesebreite) + 2 * var(--rand));
  margin-inline: auto;
  padding-top: 0;
  border-top: 0;
}

.angemeldet .fuss::before {
  grid-column: 1 / -1;
  margin-bottom: 0.75rem;
  border-top: 1px solid var(--linie);
  content: "";
}

@media (max-width: 30rem) {
  .firma,
  .marke span {
    display: none;
  }
}

@media (min-width: 60rem) {
  .fuss {
    grid-template-columns: repeat(2, minmax(0, 34rem));
  }

  .angemeldet .rahmen {
    flex-direction: row;
    align-items: stretch;
  }

  /* The strip stays as well, so the rail below it always ends exactly at the bottom of the window. */
  .angemeldet:has(.demo) {
    --demo-hoehe: 2.25rem;
  }

  .angemeldet .demo {
    position: sticky;
    top: 0;
    z-index: 2;
    align-items: center;
    min-height: var(--demo-hoehe);
    padding-block: 0;
  }

  /* Wide: the bar becomes a rail that stays while the page scrolls. */
  .angemeldet .leiste {
    position: sticky;
    top: var(--demo-hoehe, 0px);
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: stretch;
    align-self: flex-start;
    gap: 1.75rem;
    width: var(--leiste-breite);
    height: calc(100vh - var(--demo-hoehe, 0px));
    padding: 1.75rem 1rem 1.25rem;
    border-right: 1px solid var(--linie);
    border-bottom: 0;
    overflow-y: auto;
  }

  .angemeldet .marke {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0 0.75rem;
  }

  .angemeldet .marke span {
    padding-left: 0;
    border-left: 0;
  }

  .angemeldet .navi {
    order: 0;
    flex-direction: column;
    gap: 0.15rem;
    margin: 0;
    padding: 0;
    overflow: visible;
  }

  .angemeldet .navi a {
    padding: 0.55rem 0.75rem;
    border-bottom: 0;
    border-radius: var(--radius);
    box-shadow: inset 0 0 0 var(--versatz);
  }

  /* The yellow slides in from the left edge, the rail's answer to the buttons' offset. */
  .angemeldet .navi a:hover,
  .angemeldet .navi a:focus-visible,
  .angemeldet .navi a[aria-current="page"] {
    background: var(--flaeche);
    box-shadow: inset 4px 0 0 var(--versatz);
  }

  .angemeldet .konto {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    margin-top: auto;
    padding: 1rem 0.75rem 0;
    border-top: 1px solid var(--linie);
  }

  .angemeldet .firma {
    max-width: 100%;
    color: var(--tinte);
    font-weight: 600;
    white-space: normal;
  }

  .angemeldet .inhalt {
    padding-top: 3rem;
  }
}

/* ------------------------------------------------------------------ sections */

.blatt {
  display: flow-root;
  margin: 0 0 1.5rem;
  padding: 1.5rem 0 0.25rem;
  border-top: 1px solid var(--linie);
}

.blatt > h2:first-child {
  margin-top: 0;
}

/* The one sheet with a carbon copy: sign-in, second factor, recovery codes. At most one per screen. */
.blatt.schmal,
.codeblatt {
  max-width: 32rem;
  margin: 0.5rem var(--versatz-blatt) calc(1.5rem + var(--versatz-blatt)) 0;
  padding: clamp(1.25rem, 5vw, 2.25rem);
  border: 1.5px solid var(--tinte);
  border-radius: var(--radius);
  background: var(--grund);
  box-shadow: var(--versatz-blatt) var(--versatz-blatt) 0 var(--versatz);
}

.blatt.schmal > :last-child,
.codeblatt > :last-child {
  margin-bottom: 0;
}

/* Signed out (sign-in, second factor, recovery codes, errors): one narrow column in the middle of the page. */
.gast .inhalt {
  max-width: calc(32rem + var(--versatz-blatt) + 2 * var(--rand));
  padding-top: clamp(2rem, 9vh, 6rem);
}

.gast .leiste {
  grid-template-columns: 1fr;
  justify-items: center;
}

.gast .fuss {
  grid-template-columns: 1fr;
  justify-items: center;
  text-align: center;
}

/* Wide: the heading of a section stands in its own column, the content beside it. */
@media (min-width: 72rem) {
  .blatt:not(.schmal):has(> h2:first-child) > h2 {
    float: left;
    width: 13rem;
    margin: 0;
  }

  .blatt:not(.schmal):has(> h2:first-child) > :not(h2) {
    margin-left: 15rem;
  }

  .blatt:not(.schmal):has(> h2:first-child) > :nth-child(2) {
    margin-top: 0;
  }
}

/* Key facts in one ruled row above the details. No boxes: lines only. */
.eckdaten {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem 0;
  margin: 1.5rem 0 2rem;
  padding: 0;
}

.eckdaten div {
  padding: 0.1rem 1.5rem 0.1rem 1rem;
  border-left: 3px solid var(--linie);
}

.eckdaten div:first-child {
  border-left-color: var(--versatz);
}

.eckdaten dt {
  color: var(--tinte-leise);
  font-size: 0.85rem;
}

.eckdaten dd {
  margin: 0.1rem 0 0;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.25;
}

.eckdaten dd.ein {
  color: var(--gut);
}

.eckdaten dd.aus {
  color: var(--schlecht);
}

/* ------------------------------------------------------------------ forms */

form {
  margin: 0.75rem 0;
}

label {
  display: block;
  margin: 0.9rem 0 0.3rem;
  font-weight: 600;
}

label.wahl,
label.haken {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0.45rem 0;
  font-weight: 400;
}

label.wahl input,
label.haken input {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.25rem;
  accent-color: var(--handlung);
}

fieldset {
  margin: 1rem 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  font-weight: 600;
}

input[type="text"],
input[type="email"],
input:not([type]),
select {
  width: 100%;
  max-width: 28rem;
  padding: 0.65rem 0.8rem;
  border: 1.5px solid var(--tinte-leise);
  border-radius: var(--radius);
  background: var(--grund);
  color: inherit;
  font: inherit;
  box-shadow: 0 0 0 var(--versatz);
  transition: box-shadow 200ms var(--ruhe), border-color 150ms;
}

input[type="text"]:focus,
input[type="email"]:focus,
input:not([type]):focus,
select:focus {
  border-color: var(--tinte);
  box-shadow: 4px 4px 0 var(--versatz);
}

/*
 * Buttons, after the two consent buttons of the website: an outline on paper, and on hover or keyboard focus the
 * yellow carbon copy slides out behind it. A zero-blur shadow follows the rounded corners exactly like the
 * website's second layer and needs no extra element. Pressing pushes the button onto its copy.
 */
button,
.knopf {
  display: inline-block;
  margin-top: 0.9rem;
  padding: 0.65rem 1.2rem;
  border: 1.5px solid var(--tinte);
  border-radius: var(--radius);
  background: var(--grund);
  color: var(--tinte);
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 0 0 var(--versatz);
  transition: box-shadow 200ms var(--ruhe), transform 200ms var(--ruhe), background-color 150ms, border-color 150ms;
}

button:hover,
button:focus-visible,
.knopf:hover,
.knopf:focus-visible {
  box-shadow: var(--versatz-weit) var(--versatz-weit) 0 var(--versatz);
}

button:active,
.knopf:active {
  transform: translate(var(--versatz-ruhe), var(--versatz-ruhe));
  box-shadow: var(--versatz-ruhe) var(--versatz-ruhe) 0 var(--versatz);
}

/* The one main action of a screen: blue, and its copy already shows a little at rest. */
button.haupt,
.knopf.haupt {
  border-color: var(--handlung);
  background: var(--handlung);
  color: #fff;
  box-shadow: var(--versatz-ruhe) var(--versatz-ruhe) 0 var(--versatz);
}

button.haupt:hover,
button.haupt:focus-visible,
.knopf.haupt:hover,
.knopf.haupt:focus-visible {
  border-color: var(--handlung-dunkel);
  background: var(--handlung-dunkel);
  box-shadow: var(--versatz-weit) var(--versatz-weit) 0 var(--versatz);
}

button.haupt:active,
.knopf.haupt:active {
  box-shadow: 0 0 0 var(--versatz);
}

button.klein,
.knopf.klein {
  margin-top: 0;
  padding: 0.3rem 0.75rem;
  font-size: 0.9rem;
}

/* A quiet action inside a row: reads as a link, never moves. */
button.leise,
button.leise:hover,
button.leise:focus-visible,
button.leise:active {
  margin: 0;
  padding: 0.25rem 0;
  border: 0;
  background: none;
  color: var(--handlung);
  font-weight: 400;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  box-shadow: none;
  transform: none;
}

button.leise:hover {
  text-decoration-thickness: 2px;
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
  box-shadow: none;
  transform: none;
}

form.zeile {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

form.zeile select {
  width: auto;
  padding: 0.3rem 0.5rem;
}

form.zeile button {
  margin-top: 0;
}

.aktionen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem 1.25rem;
  max-width: none;
  margin: 1.25rem 0;
}

.aktionen button,
.aktionen .knopf,
.aktionen form {
  margin: 0;
}

.meldung {
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--handlung);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--flaeche);
}

.meldung.ein {
  border-left-color: var(--gut);
}

.meldung.aus {
  border-left-color: var(--schlecht);
}

.hinweis {
  color: var(--tinte-leise);
  font-size: 0.95rem;
}

/* ------------------------------------------------------------------ lists and tables */

table.liste {
  width: 100%;
  margin: 0.75rem 0 1.25rem;
  border-collapse: collapse;
}

table.liste th,
table.liste td {
  padding: 0.7rem 1rem 0.7rem 0;
  border-bottom: 1px solid var(--linie);
  text-align: left;
  vertical-align: middle;
}

table.liste th {
  border-bottom-color: var(--tinte);
  color: var(--tinte-leise);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

table.liste td:last-child,
table.liste th:last-child {
  padding-right: 0;
  text-align: right;
}

table.liste td form {
  justify-content: flex-end;
  margin: 0;
}

table.liste td.zahl,
table.liste th.zahl {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.ein {
  color: var(--gut);
  font-weight: 600;
}

td.aus {
  color: var(--schlecht);
  font-weight: 600;
}

ul.liste {
  margin: 0.5rem 0;
  padding: 0;
  list-style: none;
}

ul.liste li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--linie);
}

ul.liste li form {
  margin: 0;
}

dl.angaben {
  display: grid;
  grid-template-columns: minmax(11rem, max-content) 1fr;
  gap: 0;
  margin: 0.5rem 0;
}

dl.angaben dt,
dl.angaben dd {
  margin: 0;
  padding: 0.55rem 1.5rem 0.55rem 0;
  border-bottom: 1px solid var(--linie);
}

dl.angaben dt {
  color: var(--tinte-leise);
}

ol.codes {
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 2rem;
  font-size: 1.1rem;
  list-style: none;
  counter-reset: code;
}

ol.codes li {
  padding: 0.3rem 0;
  break-inside: avoid;
  counter-increment: code;
  letter-spacing: 0.04em;
}

ol.codes li::before {
  display: inline-block;
  width: 2rem;
  color: var(--tinte-leise);
  font-size: 0.8rem;
  letter-spacing: 0;
  content: counter(code, decimal-leading-zero);
}

ol.schritte {
  padding-left: 1.25rem;
}

ol.schritte li {
  color: var(--tinte-leise);
}

ol.schritte li.erledigt {
  color: var(--tinte);
}

ol.schritte li[aria-current="step"] {
  color: var(--tinte);
  font-weight: 600;
}

.qr {
  width: min(100%, 18rem);
  margin: 0.75rem 0;
}

.qr svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ------------------------------------------------------------------ motion */

@keyframes herein {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

.inhalt > * {
  animation: herein 360ms var(--ruhe) backwards;
}

.inhalt > :nth-child(2) {
  animation-delay: 50ms;
}

.inhalt > :nth-child(3) {
  animation-delay: 100ms;
}

.inhalt > :nth-child(n + 4) {
  animation-delay: 150ms;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ------------------------------------------------------------------ narrow */

@media (max-width: 40rem) {
  :root {
    --versatz-blatt: 7px;
  }

  body {
    font-size: 1rem;
  }

  h1 {
    font-size: 1.6rem;
  }

  dl.angaben {
    grid-template-columns: 1fr;
  }

  dl.angaben dt {
    padding-bottom: 0;
    border-bottom: 0;
    font-size: 0.85rem;
  }

  dl.angaben dd {
    padding-top: 0.1rem;
  }

  ol.codes {
    columns: 1;
  }

  /* The main action of a form fills the row, easier to hit with a thumb. */
  form:not(.zeile) > button.haupt,
  .blatt.schmal .knopf.haupt {
    width: 100%;
    text-align: center;
  }

  /* Tables become blocks of rows; the column title comes from data-titel. */
  table.liste thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  table.liste,
  table.liste tbody,
  table.liste tr,
  table.liste td {
    display: block;
    width: 100%;
  }

  table.liste tr {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--linie);
  }

  table.liste td,
  table.liste td:last-child,
  table.liste td.zahl {
    padding: 0.15rem 0;
    border: 0;
    text-align: left;
  }

  table.liste td:first-child {
    font-weight: 600;
  }

  table.liste td:last-child:not(:empty) {
    padding-top: 0.5rem;
  }

  table.liste td form {
    justify-content: flex-start;
  }

  table.liste td[data-titel]::before {
    color: var(--tinte-leise);
    content: attr(data-titel) ": ";
  }
}

/* Printing the recovery codes: only the sheet, without its copy. */
@media print {
  .demo,
  .leiste,
  .fuss,
  .aktionen,
  form {
    display: none !important;
  }

  .codeblatt {
    box-shadow: none;
  }
}
