/*
 * PraxisLedger: Stylesheet der Weboberfläche (Design-Grundlage, Entwurf vom 14.10.2026).
 *
 * - Alle Farben, Abstände, Schriftgrößen und Radien stehen als Eigenschaften auf :root. Bauteile nennen nie
 *   eine feste Farbe, nur diese Eigenschaften.
 * - Hell ist die Voreinstellung der Anwendung (der Server setzt data-theme="light"). Dunkel gilt bei
 *   data-theme="dark" und bei „wie das Gerät“ (kein Attribut) mit prefers-color-scheme: dark. data-theme
 *   am html-Element gewinnt immer gegen die Einstellung des Geräts.
 * - Schrift: Inter, lokal aus /fonts/ (woff2, SIL Open Font License). Keine externen Ressourcen.
 * - Symbole: lokales Sprite /img/icons.svg, Marke aus /img/praxisledger-mark*.svg.
 * - Bedienung: Klickflächen mindestens 40 px, Fokusrahmen 3 px, Kontrast mindestens WCAG AA.
 * - Rahmen: feste Seitenleiste ab 900 px (T-05: das Menü ist beim Scrollen immer erreichbar), darunter ohne
 *   Skript ein Block über dem Inhalt und mit public/js/nav.js (Klasse nav-js) ein Einschub hinter „Menü“.
 */

/* ---------- Schrift ---------- */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-latin-500-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/inter-latin-600-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/inter-latin-700-normal.woff2') format('woff2');
}

/*
 * Weitere Schriftteile für Namen mit Zeichen außerhalb des lateinischen Grundbestands (ł, ş, ř, ő,
 * kyrillisch, griechisch). Der Browser lädt einen Teil nur, wenn die Seite ein Zeichen daraus enthält
 * (unicode-range). Dieselben Teile stehen im PDF (src/infra/pdf-fonts.js), damit Bildschirm und Beleg
 * übereinstimmen.
 */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-latin-ext-500-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/inter-latin-ext-600-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/inter-latin-ext-700-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-cyrillic-400-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-cyrillic-500-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/inter-cyrillic-600-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/inter-cyrillic-700-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-greek-400-normal.woff2') format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-greek-500-normal.woff2') format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/inter-greek-600-normal.woff2') format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/inter-greek-700-normal.woff2') format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

/* ---------- Design-Variablen ---------- */

:root {
  color-scheme: light;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;

  /* Flächen: 0 = Seite, 1 = Karte und Leiste, 2 = leicht abgesetzt (Kopf der Tabelle, Eingabe im Ruhezustand) */
  --color-bg: #f3f5f6;
  --color-surface: #ffffff;
  --color-surface-muted: #f5f7f8;

  /* Text: primär, sekundär (muted), gedämpft (subtle, Beschriftungen und graue Einträge für Geplantes) */
  --color-text: #17262b;
  --color-text-muted: #4a5f66;
  --color-text-subtle: #5a6c72;

  /* Linien: border dekorativ, border-strong für Eingabefelder (mindestens 3:1) */
  --color-border: #d9e1e4;
  --color-border-strong: #6b7e86;

  /* Akzent Teal (Hell #0e7490, Dunkel #22d3ee): Hauptknopf, aktueller Eintrag, Verweise */
  --color-primary: #0e7490;
  --color-primary-hover: #0b5f75;
  --color-on-primary: #ffffff;
  --color-primary-text: #0e7490;
  --color-primary-soft: #e3f2f6;
  --color-link: #0e7490;
  --color-focus: #0b57d0;

  /* Status: Erfolg (Bezahlt) grün, Warnung gelb, Fehler (Überfällig) rot, Hinweis (Offen) blau; Entwurf neutral */
  --color-success-text: #14623a;
  --color-success-bg: #e4f4ea;
  --color-success-border: #7fbf98;
  --color-warning-text: #7a4a00;
  --color-warning-bg: #fdf0d2;
  --color-warning-border: #d9ad4f;
  --color-danger-text: #a3231a;
  --color-danger-bg: #fce9e7;
  --color-danger-border: #dd8f88;
  --color-danger-solid: #b3261e;
  --color-on-danger: #ffffff;
  --color-info-text: #1e40af;
  --color-info-bg: #e8effc;
  --color-info-border: #8fa8e0;

  /* Abstände 4 / 8 / 12 / 16 / 24 / 32 */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;

  /* Schriftgrößen: 12 Beschriftung, 13 Tabelle und Hilfe, 14 Fließtext, 16 Eingabe, 20 und 22 Überschriften, 28 Zahl */
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.375rem;
  --text-3xl: 1.75rem;

  /* Form: Radien 8 und 12, Schatten nur für Menüs */
  --radius-control: 8px;
  --radius-card: 12px;
  --shadow-card: none;
  --shadow-menu: 0 8px 24px rgba(16, 38, 43, 0.14), 0 2px 6px rgba(16, 38, 43, 0.08);

  /* Maße: Seitenleiste 232 px, Inhalt höchstens 1180 px plus Seitenränder 2 x 24 px */
  --sidebar-width: 14.5rem;
  --content-width: 73.75rem;
  --page-width: 76.75rem;
  --tap-size: 2.75rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;

    --color-bg: #0d1518;
    --color-surface: #152125;
    --color-surface-muted: #1b2a2f;

    --color-text: #e8f0f2;
    --color-text-muted: #a4b6bc;
    --color-text-subtle: #8ea2a9;

    --color-border: #2b3c42;
    --color-border-strong: #6f858d;

    --color-primary: #22d3ee;
    --color-primary-hover: #67e8f9;
    --color-on-primary: #052a30;
    --color-primary-text: #22d3ee;
    --color-primary-soft: #12373f;
    --color-link: #22d3ee;
    --color-focus: #8ab4f8;

    --color-success-text: #86d9a8;
    --color-success-bg: #13291d;
    --color-success-border: #2f6b46;
    --color-warning-text: #f2c66d;
    --color-warning-bg: #2b2110;
    --color-warning-border: #6e5522;
    --color-danger-text: #ffa59d;
    --color-danger-bg: #351819;
    --color-danger-border: #7c3d3d;
    --color-danger-solid: #f28b82;
    --color-on-danger: #2a0907;
    --color-info-text: #a9c1fa;
    --color-info-bg: #16233f;
    --color-info-border: #3a5693;

    --shadow-menu: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --color-bg: #0d1518;
  --color-surface: #152125;
  --color-surface-muted: #1b2a2f;

  --color-text: #e8f0f2;
  --color-text-muted: #a4b6bc;
  --color-text-subtle: #8ea2a9;

  --color-border: #2b3c42;
  --color-border-strong: #6f858d;

  --color-primary: #22d3ee;
  --color-primary-hover: #67e8f9;
  --color-on-primary: #052a30;
  --color-primary-text: #22d3ee;
  --color-primary-soft: #12373f;
  --color-link: #22d3ee;
  --color-focus: #8ab4f8;

  --color-success-text: #86d9a8;
  --color-success-bg: #13291d;
  --color-success-border: #2f6b46;
  --color-warning-text: #f2c66d;
  --color-warning-bg: #2b2110;
  --color-warning-border: #6e5522;
  --color-danger-text: #ffa59d;
  --color-danger-bg: #351819;
  --color-danger-border: #7c3d3d;
  --color-danger-solid: #f28b82;
  --color-on-danger: #2a0907;
  --color-info-text: #a9c1fa;
  --color-info-bg: #16233f;
  --color-info-border: #3a5693;

  --shadow-menu: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* ---------- Grundlagen ---------- */

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

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h2 {
  margin-block-end: 0.75rem;
  font-size: var(--text-xl);
  font-weight: 500;
}

h3 {
  margin-block-end: 0.5rem;
  font-size: var(--text-lg);
  font-weight: 500;
}

p {
  margin: 0;
}

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

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

img,
svg {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--color-text-muted);
}

.lead {
  font-size: 1.125rem;
}

code,
kbd {
  padding: 0.1em 0.4em;
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  overflow-wrap: anywhere;
}

kbd {
  border-bottom-width: 2px;
}

/* Symbole aus /img/icons.svg: Größe hier, Farbe vom umgebenden Text (currentColor). */
.icon {
  display: inline-block;
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  vertical-align: middle;
}

/* ---------- Sprunglink ---------- */

.skip-link {
  position: absolute;
  top: -5rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-control);
}

.skip-link:focus {
  top: 0.75rem;
}

/* ---------- Marke ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.5rem;
  font-size: 1.125rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--color-text);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand__mark {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  background-image: url('/img/praxisledger-mark.svg');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.brand__ledger {
  font-weight: 500;
}

/* Die Marke für dunklen Grund: bei festem Dunkel und bei „wie das Gerät“ mit dunklem Gerät. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .brand__mark {
    background-image: url('/img/praxisledger-mark-on-dark.svg');
  }
}

:root[data-theme='dark'] .brand__mark {
  background-image: url('/img/praxisledger-mark-on-dark.svg');
}

/* ---------- Kopfzeile vor der Anmeldung ---------- */

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: var(--space-2) var(--space-4);
}

/* ---------- Rahmen: Seitenleiste und Inhaltsbereich ---------- */

/* Ohne Skript und am Handy: ein Block über dem Inhalt. */
.app-shell {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  min-width: 0;
}

.app-main {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-1);
}

/* Kopfleiste mit „Menü“: erscheint nur mit Skript (Klasse nav-js) und nur am Handy. */
.app-bar {
  display: none;
}

.app-bar__toggle {
  display: none;
}

.sidebar .sidebar__close {
  display: none;
}

.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(13, 21, 24, 0.5);
}

.main-nav {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--space-2) var(--space-2) var(--space-3);
}

.nav-group + .nav-group {
  margin-top: var(--space-3);
}

.nav-group__title {
  margin: 0 0 var(--space-1);
  padding: 0 0.625rem;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
}

.nav-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/*
 * Ein Eintrag: Symbol als Geschwister vor dem Verweis, per Stylesheet über den Verweis gelegt. So enthält der
 * Verweis nur den Namen der Seite, und die Klasse main-nav__link der alten Leiste bleibt gültig.
 */
.main-nav__item {
  position: relative;
  color: var(--color-text);
}

.main-nav__item > .icon {
  position: absolute;
  top: 50%;
  left: 0.625rem;
  z-index: 1;
  transform: translateY(-50%);
  pointer-events: none;
}

.main-nav__item--current {
  color: var(--color-primary-text);
}

.main-nav__item--planned {
  color: var(--color-text-subtle);
}

.main-nav__link {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 2.25rem;
  margin: 0;
  padding: 0 var(--space-2) 0 calc(0.625rem + 1.25rem + 0.625rem);
  font: inherit;
  font-size: var(--text-md);
  font-weight: 400;
  line-height: 1.3;
  color: var(--color-text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: var(--radius-control);
}

.main-nav__link:hover {
  text-decoration: none;
  background: var(--color-surface-muted);
}

.main-nav__link[aria-current='page'] {
  font-weight: 500;
  color: var(--color-primary-text);
  background: var(--color-primary-soft);
  box-shadow: inset 3px 0 0 var(--color-primary);
}

/* Bereich der Seite, deren Untereintrag aktuell ist: hervorgehoben, aber nicht als aktuelle Seite. */
.main-nav__link--section {
  font-weight: 500;
}

/*
 * Untereinträge (zum Beispiel die Gruppen der Einstellungen): kompakt, mit feiner Führungslinie unter dem Symbol
 * des Eintrags darüber. Bei 232 px Leistenbreite (mit dünnem Rollbalken 8 px) bleiben rund 185 px, damit auch
 * „Rechnung und Zahlungsziel“ (13 px, rund 172 px) in einer Zeile steht. Die Einträge brechen nie um und
 * liegen mit 2 px Abstand untereinander, ohne sich zu berühren.
 */
.main-nav__children {
  margin-block: 2px 4px;
}

.nav-list--sub {
  gap: 2px;
  margin-inline-start: 1.25rem;
  border-inline-start: 1px solid var(--color-border);
}

.main-nav__link--sub {
  min-height: 1.75rem;
  padding-block: 0.125rem;
  padding-inline: var(--space-2) var(--space-1);
  font-size: var(--text-sm);
  line-height: 1.25;
  white-space: nowrap;
}

/*
 * Geplantes: grau, ohne Ziel, ohne Hover. Name und Marke „später“ stehen in einer Zeile und brechen nie um
 * (auch „Änderungsprotokoll“ nicht): Der Name ist etwas kleiner, rechts bleibt wenig Rand.
 */
.main-nav__link--planned,
.main-nav__link--planned:hover {
  flex-wrap: nowrap;
  padding-block: 0.25rem;
  padding-inline-end: var(--space-1);
  font-size: var(--text-sm);
  white-space: nowrap;
  color: var(--color-text-subtle);
  cursor: default;
  background: transparent;
}

.planned-hint {
  flex: none;
  margin-inline-start: auto;
  padding-inline-start: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 400;
  white-space: nowrap;
  color: var(--color-text-subtle);
}

.sidebar__foot {
  display: grid;
  flex: none;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-2) var(--space-2);
  border-top: 1px solid var(--color-border);
}

.sidebar__practice {
  margin: 0;
  padding: 0 0.625rem;
  overflow: hidden;
  font-size: var(--text-md);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__links {
  display: grid;
  gap: 2px;
}

.logout-form {
  margin: 0;
}

/* Ab 900 px: Spalte links, beim Scrollen fest. */
@media (min-width: 900px) {
  .app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    align-items: start;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    border-right: 1px solid var(--color-border);
    border-bottom: 0;
  }

  /* Dünner Rollbalken: Bei niedrigen Fenstern rollt die Navigation, der Balken soll den Namen keinen Platz nehmen. */
  .main-nav {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  .app-main {
    min-height: 100vh;
    min-height: 100dvh;
  }
}

/* Am Handy mit Skript: Kopfleiste oben fest, Seitenleiste als Einschub von links. */
@media (max-width: 899.98px) {
  .nav-js {
    scroll-padding-top: 4.5rem;
  }

  .nav-js.nav-open {
    overflow: hidden;
  }

  .nav-js .app-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
  }

  .nav-js .app-bar__toggle {
    display: inline-flex;
  }

  .nav-js .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: min(20rem, 88vw);
    height: 100dvh;
    overflow-y: auto;
    scrollbar-width: thin;
    transform: translateX(-100%);
    visibility: hidden;
    border-right: 1px solid var(--color-border);
    border-bottom: 0;
    transition:
      transform 0.2s ease,
      visibility 0s linear 0.2s;
  }

  .nav-js .sidebar.is-open {
    transform: none;
    visibility: visible;
    box-shadow: var(--shadow-menu);
    transition:
      transform 0.2s ease,
      visibility 0s linear 0s;
  }

  .nav-js .sidebar .sidebar__close {
    display: inline-flex;
  }

  /*
   * Im Einschub rollt die ganze Leiste samt Fuß. Die Navigation behält ihre volle Höhe (kein Schrumpfen auf
   * die Höhe des Fensters): Sonst läuft sie bei niedrigen Fenstern sichtbar über den Fuß hinaus und die
   * Einträge liegen unter Praxisname, Hilfe und Abmelden.
   */
  .nav-js .main-nav {
    flex: 0 0 auto;
    min-height: auto;
    overflow-y: visible;
  }
}

/* ---------- Seite und Karte ---------- */

.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) 3rem;
}

.page--narrow {
  max-width: 36rem;
}

/* Seiten, die ihre Karten selbst setzen (card: false): Fließtext 14 px und 16 px Abstand zwischen den Blöcken. */
.page--bare {
  font-size: var(--text-md);
}

.page--bare > * + * {
  margin-top: var(--space-4);
}

.page:focus {
  outline: none;
}

.page-title {
  margin: var(--space-2) 0 1.25rem;
  font-size: var(--text-2xl);
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* Kopf mit Aktionen rechts: Überschrift links, Knöpfe rechts, am Handy umbrechend. */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  margin: var(--space-2) 0 1.25rem;
}

.page-head .page-title {
  margin: 0;
}

.page-head__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.card {
  padding: 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.card > * + * {
  margin-top: 1.25rem;
}

.section + .section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

@media (min-width: 700px) {
  .page {
    padding: var(--space-5) var(--space-5) 3rem;
  }

  .card {
    padding: var(--space-5);
  }
}

/* Zurück zur Übersicht: leiser Knopf oben im Inhalt einer Unterseite. */
.back-button {
  min-height: 2.25rem;
  margin: 0 0 var(--space-1) calc(var(--space-2) * -1);
  padding: 0 var(--space-3) 0 var(--space-2);
  font-weight: 400;
  color: var(--color-text-muted);
}

.back-button:hover {
  color: var(--color-text);
}

/* Karte der Oberfläche (Bauteil card in components.js). */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 3rem;
  padding: var(--space-3) var(--space-4) 0 var(--space-5);
}

.panel__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 500;
}

.panel__action {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-1);
}

.panel__body {
  padding: var(--space-3) var(--space-5) var(--space-5);
  font-size: var(--text-md);
}

.panel__foot {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

/* ---------- Hinweisleiste ---------- */

.flash-region {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.flash {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  padding: 0.875rem 1rem;
  border: 1px solid;
  border-left-width: 6px;
  border-radius: var(--radius-control);
}

.flash__label {
  font-weight: 700;
}

.flash--success {
  color: var(--color-success-text);
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
}

.flash--info {
  color: var(--color-info-text);
  background: var(--color-info-bg);
  border-color: var(--color-info-border);
}

.flash--error {
  color: var(--color-danger-text);
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
}

/* Meldungskasten im Inhalt (Bauteil noticeBox): Farbe, Symbol und Text. */
.notice-box {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-md);
  border: 1px solid;
  border-radius: var(--radius-control);
}

.notice-box__icon {
  display: inline-flex;
  flex: none;
  padding-top: 1px;
}

.notice-box__content {
  min-width: 0;
}

.notice-box__title {
  margin: 0 0 var(--space-1);
  font-weight: 500;
}

.notice-box__body > :first-child {
  margin-top: 0;
}

.notice-box--info {
  color: var(--color-info-text);
  background: var(--color-info-bg);
  border-color: var(--color-info-border);
}

.notice-box--success {
  color: var(--color-success-text);
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
}

.notice-box--warning {
  color: var(--color-warning-text);
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
}

.notice-box--danger {
  color: var(--color-danger-text);
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
}

/* ---------- Formulare ---------- */

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
}

.form-grid--narrow {
  max-width: 28rem;
}

.form-note {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
}

.field__label {
  font-size: var(--text-md);
  font-weight: 500;
}

.field__required {
  color: var(--color-danger-text);
}

.field__control {
  width: 100%;
  min-height: var(--tap-size);
  padding: 0.625rem 0.75rem;
  font: inherit;
  font-size: var(--text-lg);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
}

textarea.field__control {
  min-height: 7rem;
  resize: vertical;
}

.field__control:hover {
  border-color: var(--color-text-muted);
}

.field__control[aria-invalid='true'] {
  padding: calc(0.625rem - 1px) calc(0.75rem - 1px);
  border-width: 2px;
  border-color: var(--color-danger-text);
}

.field__hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.field__error {
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--color-danger-text);
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-height: var(--tap-size);
  padding: 0.5rem 0;
  cursor: pointer;
}

.checkbox__control {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0.125rem 0 0;
  accent-color: var(--color-primary);
}

.checkbox__text {
  padding-top: 0.125rem;
}

@media (min-width: 700px) {
  .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem 1.5rem;
  }

  .form-grid--narrow {
    grid-template-columns: minmax(0, 1fr);
  }

  .field--wide {
    grid-column: span 2;
  }

  .field--full,
  .form-note,
  .form-grid > .actions {
    grid-column: 1 / -1;
  }

  .form-grid--narrow .field--wide {
    grid-column: auto;
  }
}

/* ---------- Knöpfe ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: var(--tap-size);
  min-height: var(--tap-size);
  padding: 0.5rem 1.125rem;
  font: inherit;
  font-size: var(--text-md);
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn--primary {
  color: var(--color-on-primary);
  background: var(--color-primary);
}

.btn--primary:hover {
  background: var(--color-primary-hover);
}

.btn--secondary {
  color: var(--color-text);
  background: var(--color-surface);
  border-color: var(--color-border-strong);
}

.btn--secondary:hover {
  background: var(--color-surface-muted);
  border-color: var(--color-text-muted);
}

.btn--danger {
  color: var(--color-on-danger);
  background: var(--color-danger-solid);
}

.btn--danger:hover {
  filter: brightness(0.92);
}

/* Leiser Knopf: ohne Rahmen, für Nebenwege (Zurück, Kacheln anpassen, Stift an der Karte). */
.btn--quiet {
  color: var(--color-text);
  background: transparent;
  border-color: transparent;
}

.btn--quiet:hover {
  background: var(--color-surface-muted);
}

/* Knopf nur mit Symbol. */
.btn--icon {
  padding: 0;
}

/* Geplantes: grau, ohne Ziel, mit dem Hinweis „später“. */
.btn--planned,
.btn--planned:hover {
  color: var(--color-text-subtle);
  cursor: default;
  background: var(--color-surface-muted);
  border-color: var(--color-border);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

/* ---------- Tabellen ---------- */

.table-scroll {
  /* Bezugspunkt für absolut positionierte Texte (sr-only) in der Tabelle: ohne ihn verlängern sie am
     Handy die Seite über den Tabellenrahmen hinaus. */
  position: relative;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
}

/* Ein offenes Zeilenmenü ragt über den Rahmen hinaus und wird nicht abgeschnitten. */
.table-scroll:has(.more-menu[open]) {
  overflow: visible;
}

.data-table {
  width: 100%;
  min-width: 34rem;
  font-size: var(--text-md);
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: start;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
}

.data-table thead th {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  background: var(--color-surface-muted);
}

.data-table tbody th {
  font-weight: 500;
  white-space: nowrap;
}

/* Verweise in Zellen (zum Beispiel die Rechnungsnummer) haben die volle Klickhöhe, ohne die Zeile zu strecken. */
.data-table a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-size);
  margin-block: -0.625rem;
}

.data-table tbody tr:last-child > * {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: var(--color-surface-muted);
}

.data-table .cell--end {
  text-align: end;
}

/* Sortierbarer Spaltenkopf: Verweis mit Pfeil für die aktuelle Richtung. */
.data-table thead .sort-link {
  gap: var(--space-1);
  min-height: 0;
  margin-block: 0;
  color: inherit;
  text-decoration: none;
}

.data-table thead .sort-link:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.data-table thead .sort-link .icon {
  width: 1rem;
  height: 1rem;
}

.table-caption {
  padding: 0.75rem 1rem;
  font-weight: 500;
  text-align: start;
  caption-side: top;
}

/* Am Handy als gestapelte Karten: jede Zeile ein Block, jede Zelle mit ihrer Beschriftung. */
@media (max-width: 39.99rem) {
  .data-table--stack {
    min-width: 0;
  }

  .data-table--stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .data-table--stack,
  .data-table--stack tbody,
  .data-table--stack tr {
    display: block;
  }

  .data-table--stack tbody tr {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
  }

  .data-table--stack tbody tr:last-child {
    border-bottom: 0;
  }

  .data-table--stack td,
  .data-table--stack tbody th {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-1) 0;
    text-align: end;
    border-bottom: 0;
  }

  .data-table--stack td::before,
  .data-table--stack tbody th::before {
    flex: none;
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--color-text-muted);
    text-align: start;
    content: attr(data-label);
  }
}

.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td > .money:only-child {
  display: block;
  text-align: right;
}

.money--negative {
  color: var(--color-danger-text);
}

.empty-state {
  padding: 2rem 1rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* Leerzustand mit Überschrift, einem Satz und einem Knopf. */
.empty-state--rich {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
}

.empty-state__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--color-text);
}

.empty-state__text {
  max-width: 32rem;
  font-size: var(--text-md);
}

.empty-state__action {
  margin-top: var(--space-2);
}

.plain-list {
  margin: 0;
  padding-left: 1.25rem;
}

.plain-list li + li {
  margin-top: 0.5rem;
}

/* ---------- Marken ---------- */

.badge {
  display: inline-block;
  padding: 0.125rem 0.625rem;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 999px;
}

.badge--neutral {
  color: var(--color-text);
  background: var(--color-surface-muted);
  border-color: var(--color-border-strong);
}

.badge--success {
  color: var(--color-success-text);
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
}

.badge--warning {
  color: var(--color-warning-text);
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
}

.badge--danger {
  color: var(--color-danger-text);
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
}

.badge--info {
  color: var(--color-info-text);
  background: var(--color-info-bg);
  border-color: var(--color-info-border);
}

/* Statusmarke: Punkt vor dem Text, damit die Farbe nie allein steht. */
.badge--status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.badge__dot {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  background: currentColor;
  border-radius: 50%;
}

/* ---------- Reiterleiste ---------- */

/*
 * Die Linie unter der Leiste ist ein innerer Schatten, kein Rahmen, und die Reiter überlappen sie nicht über
 * einen negativen Außenabstand: Ein Rahmen plus margin-bottom: -1px ließ den aktiven Reiter 1 px über den
 * Inhalt hinausragen, und weil overflow-x: auto die Höhe mitrollt, zeigte der Browser einen senkrechten
 * Rollbalken (clientHeight 43, scrollHeight 44). Der Reiter liegt über dem Schatten, sein 2-px-Strich
 * deckt die Linie ab. Der Fokusrahmen liegt innen, damit ihn die rollende Leiste nicht abschneidet.
 */
.tab-bar {
  overflow-x: auto;
  box-shadow: inset 0 -1px 0 var(--color-border);
}

.tab-bar__list {
  display: flex;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.tab-bar__tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-size);
  padding: 0 var(--space-3);
  font-size: var(--text-md);
  color: var(--color-text-muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.tab-bar__tab:focus-visible {
  outline-offset: -3px;
}

.tab-bar__tab:hover {
  color: var(--color-text);
  text-decoration: none;
}

.tab-bar__tab[aria-current='page'] {
  font-weight: 500;
  color: var(--color-primary-text);
  border-bottom-color: var(--color-primary);
}

.tab-bar__tab--planned,
.tab-bar__tab--planned:hover {
  color: var(--color-text-subtle);
  cursor: default;
}

/* ---------- Kennzahlen ---------- */

/* Feine Linien zwischen den Feldern durch 1 px Lücke auf dem Linienton. */
.metric-bar {
  overflow: hidden;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.metric-bar__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr));
  gap: 1px;
  margin: 0;
}

.metric {
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
}

.metric__label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.metric__value {
  margin: var(--space-1) 0 0;
  font-size: var(--text-3xl);
  font-weight: 500;
  line-height: 1.15;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.metric__note {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.metric--success .metric__value {
  color: var(--color-success-text);
}

.metric--warning .metric__value {
  color: var(--color-warning-text);
}

.metric--danger .metric__value {
  color: var(--color-danger-text);
}

/* ---------- Zeilenmenü ---------- */

.more-menu {
  position: relative;
  display: inline-block;
}

.more-menu__summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-size);
  height: var(--tap-size);
  color: var(--color-text-muted);
  list-style: none;
  cursor: pointer;
  border-radius: var(--radius-control);
}

.more-menu__summary::-webkit-details-marker {
  display: none;
}

.more-menu__summary:hover,
.more-menu[open] > .more-menu__summary {
  color: var(--color-text);
  background: var(--color-surface-muted);
}

.more-menu__list {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  z-index: 20;
  min-width: 12.5rem;
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-menu);
}

.more-menu__form {
  margin: 0;
}

.more-menu__item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 2.5rem;
  padding: 0 var(--space-3);
  font: inherit;
  font-size: var(--text-md);
  color: var(--color-text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.more-menu__item:hover {
  text-decoration: none;
  background: var(--color-surface-muted);
}

/* In Tabellen gilt sonst die Regel für Verweise in Zellen (negativer Außenabstand) auch für die Einträge. */
.data-table .more-menu__item {
  display: flex;
  min-height: 2.5rem;
  margin-block: 0;
}

.more-menu__item--danger {
  color: var(--color-danger-text);
}

.more-menu__item--planned,
.more-menu__item--planned:hover {
  color: var(--color-text-subtle);
  cursor: default;
  background: transparent;
}

/* ---------- QR-Code und Ersatzcodes ---------- */

/*
 * Der QR-Code bekommt immer weißen Grund und einen Rand, auch im Dunkelmodus: Scanner brauchen
 * dunkle Module auf hellem Grund mit freiem Rand. Gilt für das Element selbst (img, svg) oder
 * für einen Rahmen, der img oder svg enthält.
 */
.qr-code {
  display: block;
  width: min(100%, 14rem);
  min-width: 10rem;
  max-width: 100%;
  margin-inline: auto;
  padding: 0.75rem;
  color: #000000;
  background: #ffffff;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
}

img.qr-code,
svg.qr-code {
  height: auto;
  aspect-ratio: 1 / 1;
}

img.qr-code {
  image-rendering: pixelated;
}

.qr-code > svg,
.qr-code > img {
  display: block;
  width: 100%;
  height: auto;
}

.recovery-codes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Ein Klick wählt den ganzen Code aus, damit er sich fehlerfrei kopieren lässt. */
.recovery-codes li {
  padding: 0.625rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-variant-ligatures: none;
  letter-spacing: 0.04em;
  text-align: center;
  overflow-wrap: anywhere;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  -webkit-user-select: all;
  user-select: all;
}

.recovery-codes li + li {
  margin-top: 0;
}

/* Zeile mit „Alle Codes kopieren“ unter der Liste; der Statustext steht neben dem Knopf. */
.recovery-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 1rem 0 0;
}

.recovery-copy[hidden] {
  display: none;
}

.recovery-codes code {
  padding: 0;
  font-size: inherit;
  background: none;
  border: 0;
  -webkit-user-select: all;
  user-select: all;
}

/*
 * Ab 450 px zwei Spalten. Dort ist jede Spalte nur etwa 150 px breit, deshalb ist die Schrift
 * zunächst kleiner, damit ein Code in einer Zeile bleibt. Ab 600 px gilt wieder die volle Größe.
 */
@media (min-width: 450px) {
  .recovery-codes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recovery-codes li {
    padding-inline: 0.5rem;
    font-size: 0.8125rem;
    letter-spacing: 0;
  }
}

@media (min-width: 600px) {
  .recovery-codes li {
    padding-inline: 0.75rem;
    font-size: 1rem;
    letter-spacing: 0.04em;
  }
}

/* ---------- Fuß ---------- */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding: 0.75rem max(var(--space-4), calc((100% - var(--page-width)) / 2 + var(--space-4)));
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

@media (min-width: 700px) {
  .site-footer {
    padding-inline: max(var(--space-5), calc((100% - var(--page-width)) / 2 + var(--space-5)));
  }
}

.site-footer__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-size);
  color: var(--color-text);
}

/* ---------- Bewegung und Kontrastmodus ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .btn {
    border-color: ButtonText;
  }

  .main-nav__link[aria-current='page'],
  .tab-bar__tab[aria-current='page'] {
    outline: 2px solid Highlight;
  }

  /* Der innere Schatten der Reiterleiste entfällt in diesem Modus: eine echte Linie an seine Stelle. */
  .tab-bar {
    border-bottom: 1px solid CanvasText;
    box-shadow: none;
  }

  .badge {
    border-color: CanvasText;
  }
}

/* ---------- Druck ---------- */

@media print {
  /* Auf Papier gilt immer die helle Palette, auch bei data-theme="dark" oder dunklem Gerät. */
  :root:root:root {
    color-scheme: light;

    --color-bg: #ffffff;
    --color-surface: #ffffff;
    --color-surface-muted: #ffffff;
    --color-text: #000000;
    --color-text-muted: #333333;
    --color-border: #999999;
    --color-border-strong: #000000;
    --color-link: #000000;
    --color-primary-text: #000000;
    --color-danger-text: #000000;
    --shadow-card: none;
  }

  .no-print {
    display: none !important;
  }

  /* Seitenleiste, Kopfleiste und Sprunglink gehören nicht aufs Papier. */
  .sidebar,
  .app-bar,
  .nav-backdrop,
  .skip-link {
    display: none;
  }

  .app-shell {
    display: block;
  }

  /* Ersatzcode-Seite: nur Überschrift, Hinweise und Codes, ohne Kopf, Navigation und Fuß. */
  body:has(.recovery-codes) .skip-link,
  body:has(.recovery-codes) .site-header,
  body:has(.recovery-codes) .site-footer,
  body:has(.recovery-codes) .flash-region,
  body:has(.recovery-codes) .recovery-copy,
  body:has(.recovery-codes) .actions {
    display: none;
  }

  body:has(.recovery-codes) .page {
    max-width: none;
    padding: 0;
  }

  body:has(.recovery-codes) .card {
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  body:has(.recovery-codes) .recovery-codes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  body:has(.recovery-codes) .recovery-codes li {
    color: #000000;
    background: #ffffff;
    border: 1px solid #000000;
    break-inside: avoid;
  }
}
