/*
 * Manrope und Inter, selbst ausgeliefert (SIL Open Font License, public/fonts/OFL.txt).
 * Kein externer Font-Abruf.
 */
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/manrope-v20-latin-regular.woff2") format("woff2");
}

@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/fonts/manrope-v20-latin-500.woff2") format("woff2");
}

@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/fonts/manrope-v20-latin-600.woff2") format("woff2");
}

@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("/fonts/manrope-v20-latin-700.woff2") format("woff2");
}

/* Inter 4.1 (rsms/inter, offizielles Release); lädt nur, wenn --font Inter nennt */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/inter-v4.1-regular.woff2") format("woff2");
}

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

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

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

/*
 * Variablen in drei Schichten (Design-System, Beschreibung in der Projektdoku).
 *
 * 1. Basis: feste Werte für Abstände, Radien, Schriftgrößen, Schatten und Statusfarben.
 *    Nur hier stehen feste Farbwerte; Regeln unten nutzen ausschließlich Variablen.
 * 2. Bedeutung: Flächen, Text, Linien, Akzent, Fokus und Schrift. Regeln nutzen
 *    bevorzugt diese Namen.
 * 3. Mandant: das Mandanten-Design überschreibt nur --bg, --text, --nav, --accent,
 *    --accent-hover, --accent-soft, --on-accent, --accent-text, --focus und --font
 *    (Block im Seitenkopf, nur geprüfte #rrggbb-Werte und Schriften aus fester Liste).
 *    Die Werte hier sind der Standard ohne eigenes Design.
 *
 * Grundwerte nach dem abgenommenen Entwurf der Oberfläche (gleich für alle Mandanten).
 *
 * Kontrastpaare (WCAG 2.x, nachgerechnet). „Standard“ = ohne eigenes Design,
 * „Beispiel“ = eigenes Design mit gelbem Akzent (Akzent #ffc928, Zweitfarbe #29659c, Dunkel #17211d, Text #24322d, Hintergrund #f7f2e8):
 *   --text auf #ffffff: Standard #0e1726 17,96 : 1 | Beispiel #24322d 13,38 : 1
 *   --text auf --canvas #fbfaf8: Standard 17,22 : 1 | Beispiel 12,83 : 1
 *   --text auf --surface-soft #f5f4f1: Standard 16,33 : 1 | Beispiel 12,17 : 1
 *   --text auf --accent-soft (aktiver Menüpunkt, Pillen): Standard auf #fde5da 14,88 : 1 | Beispiel auf #f8eccb 11,38 : 1
 *   --muted #55615c auf #ffffff 6,46 : 1 | auf --canvas 6,19 : 1 | auf --surface-soft 5,87 : 1 | auf --teal-soft #e1eef3 5,45 : 1
 *     | auf --danger-soft #fdecea 5,65 : 1 | auf --accent-soft Standard 5,35 : 1, Beispiel 5,49 : 1
 *   --subtle #646f6a (Gruppenüberschriften, Icons) auf #ffffff 5,22 : 1 | auf --canvas 5,00 : 1
 *   Statuspaare: --ok #1d7a4f auf --ok-soft #e6f3ec 4,66 : 1 | --warn #9a5b00 auf --warn-soft #fdf1dc 4,86 : 1
 *     | --danger #b42318 auf --danger-soft #fdecea 5,75 : 1 | --info #2c5f8a auf --info-soft #e8f0f7 5,86 : 1
 *     | --teal-deep #2c6d8c auf --teal-soft #e1eef3 4,83 : 1 | --danger auf #ffffff 6,57 : 1
 *   --on-danger auf --danger (Knopf Gefahr, alle Mandanten gleich): Weiß auf #b42318 6,57 : 1
 *   --on-accent auf --accent (Hauptknopf): Standard Weiß auf #b4471f 5,44 : 1 | Beispiel #17211d auf #ffc928 10,72 : 1
 *   --on-accent auf --accent-hover: Standard Weiß auf #a8431d 6,02 : 1 | Beispiel #17211d auf #e8b827 8,90 : 1
 *   --accent-text auf #ffffff: Standard #b4471f 5,44 : 1 | Beispiel #29659c 6,11 : 1
 *   --accent-text auf --canvas: Standard 5,21 : 1 | Beispiel 5,86 : 1
 *   Weiß auf --nav (Frage im Chat, Kamera): Standard #0e1726 17,96 : 1 | Beispiel #17211d 16,51 : 1
 *   Bedienelemente (≥ 3 : 1): --control-border #808a85 auf #ffffff 3,56 : 1 | auf --canvas 3,42 : 1 | auf --surface-soft 3,24 : 1
 *   Fokus (≥ 3 : 1): Standard #2c6d8c auf #ffffff 5,72 : 1 | auf --canvas 5,48 : 1 | auf --accent-soft 4,74 : 1
 *     | Beispiel #29659c auf #ffffff 6,11 : 1 | auf --canvas 5,86 : 1 | auf --accent-soft 5,20 : 1
 *   Linien --border/--border-strong sind Gestaltung, keine Bedienelement-Rahmen (dafür --control-border).
 *
 * Ein eigenes Design wird vor dem Speichern auf diese Paare geprüft (Text ≥ 4,5 : 1, Fokus ≥ 3 : 1).
 * Schrift auf Akzentflächen immer --on-accent, Akzent als Textfarbe immer --accent-text.
 * Seitenfläche ist --canvas für alle Mandanten; --bg bleibt für die Kontrastprüfung.
 */
:root {
    /* 1. Basis: Abstände */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    /* Basis: Radien */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --pill: 999px;

    /* Basis: Schriftgrößen */
    --fs-12: 12px;
    --fs-13: 13px;
    --fs-14: 14px;
    --fs-15: 15px;
    --fs-18: 18px;
    --fs-22: 22px;
    --fs-26: 26px;
    --fs-30: 30px;

    /* Basis: Schatten, Bewegung, Überlagerungen */
    --shadow: 0 1px 0 rgba(20, 28, 26, .04), 0 1px 3px rgba(20, 28, 26, .06);
    --shadow-lg: 0 1px 2px rgba(14, 23, 38, .05), 0 12px 32px rgba(14, 23, 38, .12);
    --ease: cubic-bezier(.22, 1, .36, 1);
    --hover: rgba(20, 28, 26, .04);
    --row-hover: rgba(20, 28, 26, .025);
    --backdrop: rgba(14, 23, 38, .6);
    --scrim: rgba(0, 0, 0, .35);
    --tag-bg: rgba(20, 28, 26, .06);
    --track: rgba(20, 28, 26, .08);

    /* Basis: Statusfarben, je Paar Schrift auf -soft */
    --ok: #1d7a4f;
    --ok-soft: #e6f3ec;
    --warn: #9a5b00;
    --warn-soft: #fdf1dc;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --on-danger: #ffffff;
    --info: #2c5f8a;
    --info-soft: #e8f0f7;
    --teal-deep: #2c6d8c;
    --teal-soft: #e1eef3;
    --violet: #5b3f8c;
    --violet-soft: #efeaf7;
    --petrol: #1f6168;
    --petrol-soft: #e7f2f3;

    /* Basis: Weiß, Schwarz, Markierungen im Dokument */
    --white: #fff;
    --black: #000;
    --mark: rgba(255, 214, 0, .45);
    --mark-line: #6b5200;
    --mark-soft: #ffe680;
    --quote-border: #4a5566;

    /* 2. Bedeutung */
    --canvas: #fbfaf8;
    --surface: #ffffff;
    --surface-soft: #f5f4f1;
    --muted: #55615c;
    --subtle: #646f6a;
    --border: rgba(20, 28, 26, .10);
    --border-strong: rgba(20, 28, 26, .18);
    --control-border: #808a85;

    /* 2. Bedeutung, vom Mandanten überschreibbar (3. Schicht; hier die Standardwerte) */
    --bg: #eef2f5;
    --text: #0e1726;
    --nav: #0e1726;
    --accent: #b4471f;
    --accent-hover: #a8431d;
    --accent-soft: #fde5da;
    --on-accent: #ffffff;
    --accent-text: #b4471f;
    --focus: #2c6d8c;
    --font: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font);

    background: var(--canvas);
    color: var(--text);

    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

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

/*
 * LOGIN
 */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.auth-card {
    width: min(100%, 440px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: var(--shadow);
}

/*
 * APPLICATION
 * Slice 083: helle Seitenleiste (weiß, Linie rechts), Menüpunkte 44 px hoch,
 * aktiver Punkt mit --accent-soft, 3 px Akzentkante links und Schriftstärke.
 */

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 248px 1fr;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;

    width: 248px;

    background: var(--surface);
    border-right: 1px solid var(--border);
    color: var(--text);

    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-head {
    min-height: 64px;
    padding: 0 20px;

    display: flex;
    align-items: center;

    border-bottom: 1px solid var(--border);
}

.brand {
    min-width: 0;
}

/* Wortmarke: Firmenname, wenn der Mandant kein Logo hat */
.brand-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.01em;
}

/* Slice 082/083: Logo des Tenants, feste Höhe */
.brand-logo {
    display: block;
    height: 40px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.auth-logo {
    display: block;
    height: 48px;
    width: auto;
    max-width: 100%;
    margin-bottom: 20px;
    object-fit: contain;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 10px;
}

.nav-group {
    padding: 16px 12px 6px;

    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--subtle);
}

.nav-link {
    display: flex;
    gap: 12px;
    align-items: center;

    min-height: 44px;
    padding: 0 12px;

    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 500;
}

.nav-link .nav-icon {
    color: var(--subtle);
}

.nav-link:hover {
    background: var(--hover);
}

/* Aktiv: Hintergrund, Akzentkante links und Schriftstärke, nicht nur Farbe */
.nav-link.active {
    background: var(--accent-soft);
    box-shadow: inset 3px 0 0 var(--accent);
    font-weight: 600;
}

.nav-link.active .nav-icon {
    color: var(--text);
}

/* Slice 084: Zahl rechts im Menüpunkt; --muted auf Weiß 6,46 : 1, auf --accent-soft Beispiel 5,88 : 1, Standard 5,35 : 1 */
.nav-count {
    margin-left: auto;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.nav-link.active .nav-count {
    color: var(--text);
}

.nav-icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    width: 20px;
    justify-content: center;
}

/* Slice 059: Icons als inline SVG, Farbe aus dem Text */
.icon {
    display: inline-block;
    flex: none;
    vertical-align: -.2em;
}

.filter-chip .icon {
    margin-right: 4px;
}

.machine-status-symbol .icon {
    display: block;
}

.sidebar-footer {
    margin-top: auto;
    padding: 6px 20px 14px;
    border-top: 1px solid var(--border);
}

.logout-button {
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;

    color: var(--text);
    font-weight: 500;
    cursor: pointer;
}

.logout-button:hover {
    text-decoration: underline;
}

.sidebar-product {
    font-size: 12px;
    color: var(--subtle);
}

/*
 * MAIN
 */

.main {
    grid-column: 2;
    min-width: 0;
}

/* Slice 083: Kopfleiste 64 px, weiß, Linie unten; rechts Scannen, Hinweise, Name mit Rolle */
.topbar {
    min-height: 64px;
    padding: 0 32px;

    display: flex;
    align-items: center;
    justify-content: flex-end;

    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

/* Slice 063: Glocke – 44px Tippfläche, Zahl als Plakette (Text steht im aria-label) */
.bell-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;

    border-radius: var(--radius-sm);
    color: var(--muted);
}

.bell-link:hover,
.bell-link.active {
    background: var(--surface-soft);
    color: var(--text);
}

.bell-badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: var(--pill);
    background: var(--danger);
    color: var(--white);

    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.topbar-user {
    min-width: 0;
    max-width: 260px;
    font-size: 14px;
    line-height: 1.25;
}

.user-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.user-role {
    color: var(--muted);
    font-size: 12px;
}

.content {
    padding: 28px 32px 48px;
    max-width: 1360px;
}

.page-header {
    margin-bottom: 24px;
}

/* Slice 083: Pfad über dem Titel (Eltern-Seite als Link, aktuelle Seite als Text) */
.crumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0 6px;
    align-items: center;

    font-size: 13px;
    color: var(--muted);
}

.crumbs a {
    display: inline-flex;
    align-items: center;
    min-width: 44px;
    min-height: 44px;

    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.crumbs a:hover {
    color: var(--text);
}

.crumbs [aria-current="page"] {
    overflow-wrap: anywhere;
}

.eyebrow {
    margin-bottom: 8px;

    font-size: 12px;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: .07em;

    color: var(--accent-text);
}

h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.02em;
}

.lead {
    max-width: 700px;

    margin-top: 6px;
    margin-bottom: 0;

    color: var(--muted);
    line-height: 1.6;
}

/*
 * CARDS
 */

.grid {
    display: grid;
    grid-template-columns:
        repeat(3, minmax(0, 1fr));
    gap: 16px;
}

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

.card h2 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
}

/* Slice 083: Karte mit Kopfzeile (Titel links, Link rechts, Linie unten) */
.card-head {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    justify-content: space-between;

    margin: -24px -24px 20px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
}

.card .card-head h2 {
    margin: 0;
    font-size: 15px;
}

.card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.card-link {
    display: block;
    transition: border-color .15s var(--ease);
}

.card-link:hover {
    border-color: var(--control-border);
}

.empty-state {
    min-height: 220px;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    text-align: center;
}

/*
 * FORMS
 */

.auth-card label {
    display: block;
    margin: 20px 0;
}

.auth-card input {
    width: 100%;
    margin-top: 7px;
    padding: 12px 14px;

    border: 1px solid var(--control-border);
    border-radius: var(--radius-sm);
}

.primary-button {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 12px 16px;

    color: var(--on-accent);
    background: var(--accent);
    font-weight: 600;

    cursor: pointer;
    transition: background .2s var(--ease);
}

.primary-button:hover {
    background: var(--accent-hover);
}

.error {
    margin: 18px 0;
    padding: 12px 14px;

    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
}

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

/*
 * KNOWLEDGE – Chat-Ansicht (Slice 044)
 * Kontrast: Weiß auf --nav (Frage) 17,96 : 1 | --teal-deep auf --teal-soft (Kennzeichnung) 4,83 : 1
 * --text auf --danger-soft (Hinweis bei Fehler) > 15 : 1 | --muted auf --danger-soft 7,1 : 1
 */

.knowledge {
    font-size: 16px;
    line-height: 1.5;
}

.chat {
    max-width: 860px;
}

/* Breite Bildschirme (per JS): Verlauf mittig; offen (Slice 047) Verlauf links, Quellen-Spalte rechts */
.chat.chat--panel {
    max-width: none;
}

.chat--panel:not(.chat--open) .chat-main {
    margin-inline: auto;
}

.chat.chat--open {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
    gap: 28px;
    align-items: start;
}

.chat-main {
    min-width: 0;
    max-width: 860px;
}

.chat-header {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
}

.chat-header h1 {
    font-size: clamp(26px, 3.5vw, 34px);
}

.chat-new[aria-disabled="true"] {
    color: var(--muted);
    cursor: not-allowed;
}

.chat-empty {
    margin-bottom: 24px;
    padding: 24px;

    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
}

.chat-empty .lead {
    margin-top: 0;
    font-size: 17px;
}

.chat-empty-hint {
    margin: 12px 0 0;
    color: var(--text);
    font-weight: 600;
}

.chat-log {
    display: flex;
    flex-direction: column;
    gap: 28px;

    margin: 0;
    padding: 0;
    list-style: none;
}

.chat-log:not(:empty) {
    margin-bottom: 24px;
}

.chat-turn {
    display: flex;
    flex-direction: column;
    gap: 12px;

    scroll-margin-top: 16px;
    scroll-margin-bottom: 200px;
}

.chat-question {
    display: flex;
    justify-content: flex-end;
}

.chat-question-bubble {
    max-width: min(85%, 640px);
    margin: 0;
    padding: 12px 16px;

    border-radius: var(--radius) var(--radius) 6px var(--radius);
    background: var(--nav);
    color: var(--white);

    white-space: pre-line;
    overflow-wrap: anywhere;
}

.chat-response:focus-visible,
.evidence-card:focus-visible,
.chat-sources-summary:focus-visible,
.knowledge-textarea:focus-visible,
.knowledge-button:focus-visible,
.knowledge-cite:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/* Antwort: Kennzeichnung als Text und Akzent links, nicht nur Farbe */
.card.chat-answer,
.card.chat-findings {
    padding-left: 28px;
    border-left: 4px solid var(--teal-deep);
}

.chat--open .chat-turn.is-selected .card.chat-response {
    border-top-color: var(--teal-deep);
    border-right-color: var(--teal-deep);
    border-bottom-color: var(--teal-deep);
}

.card p.chat-answer-label {
    display: inline-block;
    margin: 0 0 12px;
    padding: 4px 10px;

    border-radius: var(--radius-sm);
    background: var(--teal-soft);
    color: var(--teal-deep);

    font-size: 14px;
    font-weight: 600;
}

.card .knowledge-answer-text {
    margin: 0 0 14px;
    color: var(--text);
    font-size: 17px;
    line-height: 1.6;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* Mindestzielgröße 24 px (WCAG 2.5.8) */
.knowledge-cite {
    display: inline-block;
    min-width: 24px;
    min-height: 24px;
    padding: 0 4px;

    border-radius: 6px;

    color: var(--focus);
    font-weight: 600;
    line-height: 24px;
    text-align: center;
    text-decoration: underline;
}

.knowledge-cite:hover {
    background: var(--teal-soft);
}

.card p.knowledge-answer-note {
    font-size: 14px;
    color: var(--muted);
}

.chat-findings-title {
    margin: 0;
}

/* Hinweis (ABSTAIN, nicht verfügbar, keine Unterlagen, Fehler): Symbol, Überschrift, gestrichelter Rahmen – nie wie eine Antwort */
.chat-notice {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 20px 24px;

    border: 2px dashed var(--control-border);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.chat-notice-unavailable,
.chat-notice-error {
    border-color: var(--danger);
    background: var(--danger-soft);
}

.chat-notice-icon {
    flex: none;
    width: 40px;
    height: 40px;
    padding: 8px;

    border-radius: var(--pill);
    background: var(--surface);
    color: var(--text);
}

.chat-notice-icon svg {
    display: block;
    width: 24px;
    height: 24px;
}

.chat-notice-icon-text {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 20px;
    font-weight: 700;
}

.chat-notice-body {
    flex: 1;
    min-width: 0;
}

.chat-notice-title {
    margin: 0 0 6px;
    font-size: 18px;
}

.chat-notice p {
    margin: 0;
    color: var(--text);
    line-height: 1.55;
}

.chat-notice p + p {
    margin-top: 8px;
}

.chat-notice p.knowledge-notice-hint {
    color: var(--muted);
}

/* Quellen unter der Antwort (schmal bzw. ohne JS) */
.chat--panel .chat-sources {
    display: none;
}

/* Breit: „Quellen (n)“ öffnet die Spalte (Slice 047); offen zusätzlich dicker Rahmen, nicht nur Farbe */
.chat-turn .chat-sources-toggle {
    display: none;
}

.chat--panel .chat-turn .chat-sources-toggle {
    display: inline-flex;
    align-self: flex-start;
    padding: 10px 16px;
}

.chat-turn .chat-sources-toggle[aria-expanded="true"] {
    border: 2px solid var(--teal-deep);
    background: var(--teal-soft);
    color: var(--teal-deep);
}

.chat-sources-summary {
    width: fit-content;
    min-height: 44px;
    padding: 10px 16px;

    border: 1px solid var(--control-border);
    border-radius: var(--radius-sm);
    background: var(--surface);

    font-weight: 600;
    cursor: pointer;
}

.chat-sources[open] .chat-sources-summary {
    margin-bottom: 12px;
}

.evidence-card {
    margin-bottom: 16px;
}

.card p.evidence-source {
    margin: 0 0 12px;
    color: var(--text);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.card.evidence-card {
    box-shadow: none;
}

.evidence-text {
    margin: 0;
    padding: 4px 0 4px 16px;

    border-left: 3px solid var(--quote-border);
    line-height: 1.6;

    white-space: pre-line;
    overflow-wrap: anywhere;
}

.knowledge-note {
    margin: 0;
    color: var(--muted);
}

.evidence-card h3.evidence-number {
    margin: 0 0 6px;
    font-size: 16px;
}

/* Ausgewählte Quelle bzw. Sprungziel: Rahmen und Text „ausgewählt“, nicht nur Farbe */
.card.evidence-card.is-selected,
.evidence-card:target {
    border: 2px solid var(--teal-deep);
}

.evidence-selected {
    color: var(--teal-deep);
}

@media (prefers-reduced-motion: no-preference) {
    html:has(.knowledge) {
        scroll-behavior: smooth;
    }
}

/* Quellen-Spalte: scrollt unabhängig vom Verlauf */
.chat-panel {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 20px;

    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.chat-panel-head {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.chat-panel-title {
    margin: 0;
    font-size: 18px;
}

.chat-panel-title:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.chat-panel-close.button {
    padding: 8px 16px;
}

.chat-panel-question {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.chat-panel-empty {
    margin: 0;
    color: var(--muted);
}

/*
 * Beleg im Original-PDF (Slice 045)
 * Kontrast: --text auf --surface-soft 16,72 : 1 | --muted auf --surface-soft 7,03 : 1 | --danger auf --danger-soft 6,05 : 1
 * Schaltflächen 44 px hoch (Tablet), Fokus wie alle Bedienelemente.
 */
.card p.evidence-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    margin: 14px 0 0;
}

.evidence-download {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.chat-panel.is-viewing > :not(.pdf-viewer) {
    display: none;
}

/* Breite Bildschirme: Spalte beim Lesen etwas breiter */
@media (min-width: 1440px) {
    .chat.chat--open.chat--viewing {
        grid-template-columns: minmax(0, 1fr) minmax(400px, 560px);
    }
}

.pdf-viewer-head {
    margin-bottom: 12px;
}

.pdf-viewer-title {
    margin: 0 0 4px;
    font-size: 18px;
    overflow-wrap: anywhere;
}

.pdf-viewer-title:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.pdf-viewer-page {
    margin: 0;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.pdf-viewer-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
    margin-bottom: 12px;
}

.pdf-viewer-controls .button {
    padding: 8px 16px;
}

.pdf-viewer-controls .button[aria-disabled="true"] {
    color: var(--muted);
    border-style: dashed;
    cursor: not-allowed;
}

.pdf-viewer-tab {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.pdf-viewer-status:not(:empty) {
    margin: 0 0 12px;
    color: var(--text);
    font-weight: 600;
}

.pdf-viewer-status:empty {
    margin: 0;
}

.pdf-viewer-error {
    margin-bottom: 12px;
    padding: 12px 14px;

    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 600;
}

.pdf-viewer-error p {
    margin: 0;
}

.pdf-viewer-error p + p {
    margin-top: 6px;
}

.pdf-viewer-canvas-wrap {
    position: relative;
    margin-bottom: 16px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
}

/* Auflösung über width/height-Attribute, Anzeige auf Spaltenbreite */
.pdf-viewer-canvas {
    display: block;
    width: 100%;
    height: auto;
}

/*
 * Belegstelle im PDF (Slice 048): Markerfarbe plus Unterstrich, nicht nur Farbe.
 * halbtransparent mit multiply: dunkler Text bleibt dunkel (Schwarz auf Weiß unter der Markierung 17,7 : 1); Unterstrich #6b5200 auf Weiß 7,4 : 1.
 */
.pdf-viewer-marks {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.pdf-viewer-mark {
    position: absolute;
    box-sizing: border-box;
    border-bottom: 2px solid var(--mark-line);
    background: var(--mark);
    mix-blend-mode: multiply;
}

.pdf-viewer-excerpt-title {
    margin: 0 0 8px;
    font-size: 16px;
}

/*
 * Word-Vorschau (Slice 046): Inhalt und Struktur, kein Seitenlayout.
 * Kontrast: --text auf --surface 17,96 : 1 | --text auf --teal-soft 15,16 : 1 | --text auf #ffe680 14,44 : 1 | Link --teal-deep auf --surface 5,72 : 1
 * Belegstelle: Hintergrund plus Unterstreichung, nicht nur Farbe.
 */
.pdf-viewer [hidden] {
    display: none;
}

.docx-viewer-note {
    margin: 0 0 12px;
    padding: 10px 14px;

    border-left: 3px solid var(--teal-deep);
    border-radius: var(--radius-sm);
    background: var(--teal-soft);
    color: var(--text);
}

.docx-viewer-content {
    margin-bottom: 16px;
    padding: 16px 18px;
    overflow-x: auto;

    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.docx-viewer-content > :first-child {
    margin-top: 0;
}

.docx-viewer-content > :last-child {
    margin-bottom: 0;
}

.docx-viewer-content h1,
.docx-viewer-content h2,
.docx-viewer-content h3,
.docx-viewer-content h4,
.docx-viewer-content h5,
.docx-viewer-content h6 {
    margin: 1.2em 0 .5em;
    font-size: 17px;
    line-height: 1.35;
}

.docx-viewer-content h1 {
    font-size: 20px;
}

.docx-viewer-content h2 {
    font-size: 18px;
}

.docx-viewer-content p,
.docx-viewer-content ul,
.docx-viewer-content ol,
.docx-viewer-content table {
    margin: 0 0 .8em;
}

.docx-viewer-content table {
    border-collapse: collapse;
}

.docx-viewer-content th,
.docx-viewer-content td {
    padding: 6px 8px;
    border: 1px solid var(--border-strong);
    text-align: left;
    vertical-align: top;
}

.docx-viewer-content th p,
.docx-viewer-content td p {
    margin: 0;
}

.docx-viewer-content a {
    color: var(--teal-deep);
    text-decoration: underline;
}

.docx-viewer-content a:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.docx-viewer-content mark {
    background: var(--mark-soft);
    color: var(--text);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

/* Schmal: Vollbild */
.pdf-dialog {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 16px;

    border: 0;
    background: var(--surface-soft);
    color: var(--text);
}

.pdf-dialog::backdrop {
    background: var(--backdrop);
}

/* Eingabe unten fest, Senden immer sichtbar */
.card.chat-form {
    position: sticky;
    bottom: 12px;
    z-index: 10;
    padding: 16px 20px;

    border-color: var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.knowledge-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.chat-input-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

/* 16 px: kein automatischer Zoom auf iOS; max. ca. 6 Zeilen */
.knowledge-textarea {
    display: block;
    flex: 1;
    min-width: 0;
    min-height: 48px;
    max-height: 170px;
    padding: 11px 14px;

    font: inherit;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);

    background: var(--surface);
    border: 1px solid var(--control-border);
    border-radius: var(--radius-sm);

    resize: none;
    overflow-y: auto;
}

.knowledge-textarea[aria-invalid="true"] {
    border: 2px solid var(--danger);
}

.card p.knowledge-help {
    margin: 8px 0 0;
    font-size: 14px;
}

.card p.field-error {
    margin: 0 0 8px;
    padding: 10px 12px;

    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 600;
}

.knowledge-button {
    flex: none;
    min-height: 48px;
    padding: 12px 24px;

    border: 0;
    border-radius: var(--radius-sm);

    font: inherit;
    font-weight: 600;
    color: var(--on-accent);
    background: var(--accent);

    cursor: pointer;
    transition: background .2s var(--ease);
}

.knowledge-button:hover {
    background: var(--accent-hover);
}

.knowledge-button:disabled {
    background: var(--muted);
    cursor: progress;
}

/*
 * Rückmeldung (Slice 052): Symbol und Text, Ziel 44 px (Tablet), gewählt = dicker Rahmen und Fettschrift, nicht nur Farbe.
 * Kontrast: --text auf --surface 17,96 : 1 | --teal-deep auf --teal-soft 4,83 : 1 | --muted auf --surface 7,4 : 1 | --danger auf --danger-soft 6,05 : 1
 * Ohne JS ist der Bereich „Stimmt nicht“ sichtbar; mit JS (chat--feedback-js) erst nach Klick.
 */
.chat-feedback {
    margin: 0;
}

.chat-feedback-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chat-feedback-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 16px;

    border: 1px solid var(--control-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);

    font: inherit;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.chat-feedback-button svg {
    flex: none;
    width: 20px;
    height: 20px;
}

.chat-feedback-button:hover {
    background: var(--surface-soft);
}

.chat-feedback-button[aria-pressed="true"] {
    border: 2px solid var(--teal-deep);
    background: var(--teal-soft);
    color: var(--teal-deep);
    font-weight: 700;
}

.chat-feedback-button:disabled {
    cursor: default;
}

.chat-feedback-button:disabled:not([aria-pressed="true"]) {
    opacity: .6;
}

.chat-feedback textarea:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.chat-feedback-toggle,
.chat-feedback-cancel {
    display: none;
}

.chat--feedback-js .chat-feedback-toggle {
    display: inline-flex;
}

.chat--feedback-js .chat-feedback-cancel {
    display: inline-flex;
}

.chat-feedback-wrong {
    margin: 12px 0 0;
    padding: 16px 18px;
    min-width: 0;

    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.chat--feedback-js .chat-feedback-wrong:not(.is-open) {
    display: none;
}

.chat-feedback-legend {
    padding: 0 4px;
    font-weight: 700;
}

.chat-feedback p.chat-feedback-hint {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.chat-feedback-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.chat-feedback-optional {
    color: var(--muted);
    font-weight: 400;
}

.knowledge-textarea.chat-feedback-comment {
    width: 100%;
    min-height: 96px;
    resize: vertical;
}

.chat-feedback-wrong-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.chat-feedback p.chat-feedback-status {
    margin: 8px 0 0;
    color: var(--text);
    font-weight: 600;
}

.chat-feedback p.chat-feedback-status:empty {
    display: none;
}

.chat-feedback-notice {
    margin: 0 0 16px;
    padding: 12px 16px;

    border-left: 4px solid var(--teal-deep);
    border-radius: var(--radius-sm);
    background: var(--teal-soft);
    color: var(--text);
    font-weight: 600;
}

.chat-feedback-notice.chat-feedback-notice-error {
    border-left-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
}

/* Verwaltungsübersicht: nur Zählwerte */
.feedback-counts {
    margin: 0;
    padding: 0;
    list-style: none;
    line-height: 1.8;
}

/*
 * LADEANZEIGE (nur mit JS sichtbar, keine vorgetäuschten Schritte)
 */

.knowledge-loading {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

.knowledge-loading-icon {
    flex: none;
    width: 48px;
    height: 48px;
    padding: 10px;

    border-radius: var(--radius-sm);
    background: var(--teal-soft);
    color: var(--teal-deep);
}

.knowledge-loading-icon svg {
    display: block;
    width: 28px;
    height: 28px;
}

.knowledge-loading-body {
    flex: 1;
    min-width: 0;
}

.knowledge-loading-title {
    margin: 0 0 6px;
    font-size: 18px;
}

.card p.knowledge-loading-text {
    color: var(--text);
}

.knowledge-progress {
    position: relative;
    height: 6px;
    margin: 16px 0;
    overflow: hidden;

    border-radius: var(--pill);
    background: var(--teal-soft);
}

.knowledge-progress span {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 40%;

    border-radius: var(--pill);
    background: var(--teal-deep);
}

.knowledge-steps {
    margin: 0 0 12px;
    padding-left: 22px;
    color: var(--muted);
}

.knowledge-steps li {
    margin: 2px 0;
}

.card p.knowledge-elapsed {
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: no-preference) {
    .knowledge-progress span {
        animation: knowledge-indeterminate 1.6s var(--ease) infinite;
    }

    .knowledge-loading-icon svg {
        animation: knowledge-pulse 2s ease-in-out infinite;
    }
}

@keyframes knowledge-indeterminate {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(250%);
    }
}

@keyframes knowledge-pulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .45;
    }
}

@media (prefers-reduced-motion: reduce) {
    .knowledge * {
        animation: none;
        transition: none;
    }

    /* nur Text und Zähler */
    .knowledge-progress {
        display: none;
    }
}

/*
 * VERWALTUNG (Slice 029)
 * Status-Paare (Slice 083): --ok auf --ok-soft 4,66 : 1 | --warn auf --warn-soft 4,86 : 1 | --muted auf --surface-soft 5,87 : 1
 * Weiß auf --danger #b42318 6,57 : 1
 */

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

.notice {
    margin-bottom: 20px;
    padding: 12px 14px;

    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}

.notice-success {
    background: var(--teal-soft);
    color: var(--text);
}

.notice-error {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
    font-weight: 600;
}

.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.filter-label {
    margin-right: 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
}

/* Aktiver Filter: Rahmen, Schriftstärke und Häkchen, nicht nur Farbe */
.filter-chip {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 4px 12px;

    border: 1px solid var(--control-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 14px;
    font-weight: 500;
}

.filter-chip:hover {
    background: var(--surface-soft);
}

.filter-chip[aria-current="true"] {
    border: 2px solid var(--teal-deep);
    font-weight: 700;
}

/* Slice 083: Knöpfe 6 px Radius, eine Hauptaktion im Akzent, weitere weiß mit Rahmen */
.button {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 16px;

    border: 1px solid transparent;
    border-radius: var(--radius-sm);

    font: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--on-accent);
    background: var(--accent);

    cursor: pointer;
    transition: background .15s var(--ease);
}

.button:hover {
    background: var(--accent-hover);
}

.button-secondary {
    border: 1px solid var(--control-border);
    color: var(--text);
    background: var(--surface);
}

.button-secondary:hover {
    background: var(--surface-soft);
}

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

.button-danger:hover {
    background: var(--danger);
    text-decoration: underline;
}

.text-link {
    color: var(--focus);
    font-weight: 600;
    text-decoration: underline;
}

.table-wrap {
    overflow-x: auto;
}

/* Slice 083: Kopf in Großbuchstaben 12 px, Zeilen 52 px, Zahlen mit festen Ziffernbreiten */
.data-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
    height: 52px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.data-table thead th {
    height: auto;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    background: var(--canvas);
}

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

.data-table tbody tr:hover {
    background: var(--row-hover);
}

.data-table td.email {
    overflow-wrap: anywhere;
}

/* Slice 083: Status-Pillen mit Paaren aus dem Entwurf (grün/gelb/rot/grau), immer Symbol plus Text */
.status {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    min-height: 24px;
    padding: 2px 9px;

    border: 1px solid transparent;
    border-radius: var(--pill);

    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.status-aktiv {
    background: var(--ok-soft);
    color: var(--ok);
}

.status-ausstehend {
    background: var(--warn-soft);
    color: var(--warn);
}

.status-deaktiviert {
    background: var(--surface-soft);
    color: var(--muted);
}

.admin-card {
    max-width: 720px;
    margin-bottom: 20px;
}

/*
 * QUALIFIKATIONEN (Slice 055)
 * Status mit Symbol und Text, nicht nur Farbe.
 * Kontrast (Slice 083): --ok auf --ok-soft 4,66 : 1 | --warn auf --warn-soft 4,86 : 1
 * --danger auf --danger-soft 5,75 : 1 | --muted auf --surface-soft 5,87 : 1
 */
.status-gueltig {
    background: var(--ok-soft);
    color: var(--ok);
}

.status-ablaufend {
    background: var(--warn-soft);
    color: var(--warn);
}

.status-abgelaufen {
    border-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
}

.status-widerrufen,
.status-kuenftig {
    background: var(--surface-soft);
    color: var(--muted);
}

.card.qualification-card,
.qualification-actions {
    margin-bottom: 20px;
}

.card p.qualification-intro,
p.qualification-intro {
    margin: 0 0 16px;
}

.qualification-summary {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.qualification-summary-item {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    padding: 12px 14px;

    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}

.qualification-summary-name {
    flex: 1 1 200px;
    font-weight: 600;
}

.qualification-summary-until {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.qualification-detail {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
    overflow-wrap: anywhere;
}

.qualification-evidence-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.field-input.qualification-textarea {
    min-height: 72px;
    resize: vertical;
}

.field-input.qualification-number {
    max-width: 160px;
}

.field-input.qualification-file {
    padding: 8px;
}

.qualification-suggestions {
    margin: 0 0 16px;
    padding-left: 20px;
    line-height: 1.7;
}

/*
 * Slice 065: Vorschläge aus dem Erkennungsdienst. Markierung mit Text,
 * nicht nur Farbe: --text auf --accent-soft 14,88 : 1, Rahmen --accent.
 */
.suggestion-notice {
    background: var(--teal-soft);
    color: var(--text);
}

.card p.suggestion-note {
    margin: 6px 0 0;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.suggestion-badge {
    display: inline-block;
    margin-right: 6px;
    padding: 2px 8px;

    border-radius: var(--pill);
    background: var(--accent-soft);
    color: var(--text);
    font-weight: 600;
}

.field-input[data-suggested="true"],
.field-select[data-suggested="true"] {
    border: 2px dashed var(--accent);
}

/* Slice 067: Zitat je Vorschlag „Pflichten aus Dokument“ und Vorschau darunter */
.obligation-quote {
    margin: 10px 0 4px;
}

.obligation-viewer {
    margin-top: 16px;
}

.suggest-loading {
    margin-top: 12px;
}

/*
 * BETRIEBSMITTEL (Slice 056)
 * Prüfstatus mit Symbol und Text, nicht nur Farbe. Gleiche Farbpaare wie 055:
 * --ok auf --ok-soft 4,66 : 1 | --warn auf --warn-soft 4,86 : 1
 * --danger auf --danger-soft 5,75 : 1 | --muted auf --surface-soft 5,87 : 1
 * Maschinenseite mobil zuerst: Status oben, große Schrift, Ziele ≥ 48 px.
 */
.status-ok {
    background: var(--ok-soft);
    color: var(--ok);
}

.status-bald_faellig {
    background: var(--warn-soft);
    color: var(--warn);
}

.status-ueberfaellig,
.status-nicht_bestanden,
.status-gesperrt {
    border-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
}

.status-ohne_pflicht,
.status-ausgemustert {
    background: var(--surface-soft);
    color: var(--muted);
}

.asset-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: flex-end;
}

.asset-filter .field {
    margin-bottom: 0;
}

.asset-filter .field-select {
    min-width: 180px;
}

.asset-assignments {
    display: grid;
    gap: 12px;
    margin: 0 0 20px;
}

.asset-documents {
    max-height: 320px;
    overflow-y: auto;
}

.machine {
    max-width: 720px;
}

.machine-header h1 {
    margin: 0 0 4px;
    font-size: 28px;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.machine-type {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 18px;
}

.machine-status {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 0 0 20px;
    padding: 16px 18px;

    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);

    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
}

.machine-status .machine-status-symbol {
    flex: 0 0 auto;
    font-size: 28px;
}

.machine-checks {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.machine-check {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    align-items: center;
    padding: 14px;

    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);

    font-size: 17px;
}

.machine-check-name {
    flex: 1 1 220px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.machine-check-due {
    flex: 1 1 100%;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.machine-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 0 0 20px;
}

.machine-actions .button,
.machine-actions form {
    min-height: 48px;
}

.machine-documents {
    margin: 0;
    padding: 0;
    list-style: none;
}

.machine-documents a {
    display: flex;
    align-items: center;
    min-height: 48px;
    font-size: 17px;
    overflow-wrap: anywhere;
}

.machine-hint {
    margin: 0 0 20px;
}

a.primary-button.machine-login {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    text-decoration: none;
}

.machine-history-meta {
    display: block;
    color: var(--muted);
    font-size: 14px;
    overflow-wrap: anywhere;
}

/*
 * AMPEL „DARF BEDIENEN“ UND EINWEISUNGEN (Slice 057)
 * Ampel nie nur über Farbe: Symbol plus Text, Gründe als Liste. Gleiche Farbpaare wie 055/056:
 * --danger auf --danger-soft 5,75 : 1 | --ok auf --ok-soft 4,66 : 1 | --warn auf --warn-soft 4,86 : 1
 * --muted auf --surface-soft 5,87 : 1
 */
.status-rot,
.status-verfallen {
    border-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
}

.status-gelb,
.status-wartet {
    background: var(--warn-soft);
    color: var(--warn);
}

.status-gruen {
    background: var(--ok-soft);
    color: var(--ok);
}

.status-grau,
.status-abgelehnt {
    background: var(--surface-soft);
    color: var(--muted);
}

.permission-reasons {
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
    font-size: 14px;
    line-height: 1.5;
}

.permission-reasons li {
    display: flex;
    gap: 6px;
    overflow-wrap: anywhere;
}

.permission-reasons.permission-reasons-large {
    display: grid;
    gap: 6px;
    margin: 0 0 16px;
    font-size: 17px;
}

.permission-reason-rot {
    color: var(--danger);
    font-weight: 600;
}

.card p.permission-contact {
    margin: 0;
    font-size: 18px;
}

.briefing-pending-list {
    display: grid;
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.briefing-pending-item {
    padding: 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}

.briefing-pending-item p {
    margin: 0 0 8px;
}

.briefing-pending-item .button {
    min-height: 48px;
}

/*
 * FRISTEN (Slice 058)
 * Gruppe und Tage als Text, Farbpaare aus 055/056 (siehe oben).
 */
.card h3.deadline-group-title {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
    margin: 20px 0 10px;
    font-size: 16px;
}

.deadline-group-count {
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
}

.card p.deadline-empty {
    margin: 0 0 8px;
}

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

.card p.deadline-home-link,
.card p.deadline-all-clear {
    margin: 12px 0 0;
}

.deadline-home-link .text-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

/*
 * STARTSEITE (Slice 060)
 * Mobil zuerst: Kacheln mindestens 2 je Zeile, Ziele ≥ 48 px, 12 px Abstand.
 * Dringlichkeit mit Symbol und Satz, Farbe nur zusätzlich (Farbpaare aus 055/056):
 * --danger auf --danger-soft 6,05 : 1 | --text auf --accent-soft 14,88 : 1
 * --teal-deep auf --teal-soft 4,83 : 1 | --text auf --surface-soft 16,72 : 1
 */
.home-section {
    margin-bottom: 20px;
}

.card h2.home-section-title {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 0 0 14px;
    font-size: 20px;
}

.home-todo {
    border: 2px solid var(--accent);
}

.home-todo .home-section-title {
    color: var(--accent-text);
}

.home-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.home-tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    min-height: 132px;
    padding: 18px;

    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text);
}

a.home-tile:hover,
.home-tile-scan summary:hover {
    border-color: var(--control-border);
}

a.home-tile:focus-visible,
.home-tile-scan summary:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.home-tile-scan {
    padding: 0;
}

.home-tile-scan summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    min-height: 130px;
    padding: 18px;

    border-radius: var(--radius);
    cursor: pointer;
    list-style: none;
}

.home-tile-scan summary::-webkit-details-marker {
    display: none;
}

.home-tile-scan p {
    margin: 0;
    padding: 0 18px 18px;
    line-height: 1.55;
}

/* Slice 084: Symbol im hellen Feld; --accent-text auf --accent-soft: Standard 4,50 : 1, Beispiel 5,56 : 1 (Symbol braucht 3 : 1) */
.home-tile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent-text);
}

.home-tile-label {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.25;
}

.home-tile-note {
    color: var(--muted);
    font-size: 15px;
    line-height: 1.4;
}

.home-attention-list,
.home-onboarding-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.home-attention-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px 12px;
    align-items: center;
    padding: 12px 14px;

    border: 1px solid var(--border-strong);
    border-left-width: 6px;
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
}

.home-attention-item .button {
    grid-column: 1 / -1;
    min-height: 48px;
}

/* Slice 063: Seite „Hinweise“ und Hinweise auf der Startseite */
.home-attention-item .admin-actions {
    grid-column: 1 / -1;
}

.notification-state {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.notification-read-all {
    margin-bottom: 12px;
}

.notification-read .home-attention-icon {
    color: var(--muted);
}

.home-attention-danger {
    border-color: var(--danger);
    background: var(--danger-soft);
}

.home-attention-danger .home-attention-icon {
    color: var(--danger);
}

.home-attention-warning {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.home-attention-info .home-attention-icon {
    color: var(--teal-deep);
}

.home-attention-icon {
    display: inline-flex;
}

.home-attention-text {
    font-weight: 600;
    line-height: 1.4;
}

.card p.home-attention-more,
.card p.home-stat {
    margin: 12px 0 0;
}

.home-stat .text-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.card p.home-all-clear {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 14px;

    border-radius: var(--radius-sm);
    background: var(--teal-soft);
    color: var(--teal-deep);
    font-size: 18px;
    font-weight: 700;
}

.home-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.button.home-action {
    gap: 10px;
    justify-content: flex-start;
    min-height: 48px;
}

.home-onboarding {
    border: 2px solid var(--teal-deep);
}

.home-onboarding-head {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    align-items: baseline;
    justify-content: space-between;
}

.card p.home-onboarding-progress {
    margin: 0 0 8px;
    color: var(--text);
}

.home-onboarding-bar {
    width: 100%;
    height: 10px;
    margin-bottom: 16px;
    accent-color: var(--teal-deep);
}

.home-onboarding-step {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 8px 12px;
    align-items: start;
    padding: 12px 14px;

    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}

.home-onboarding-step.is-done {
    background: var(--surface-soft);
}

.home-onboarding-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;

    border: 2px solid var(--control-border);
    border-radius: 50%;
    font-weight: 700;
}

.is-done .home-onboarding-mark {
    border: 0;
    color: var(--teal-deep);
}

.card .home-onboarding-text h3 {
    margin: 4px 0 4px;
    font-size: 17px;
}

.home-onboarding-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    grid-column: 2;
}

.home-onboarding-actions .button,
.home-onboarding-actions .text-link,
.home-onboarding-hide .button {
    min-height: 48px;
}

.home-onboarding-actions .text-link {
    display: inline-flex;
    align-items: center;
}

.home-onboarding-hide {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    margin-top: 16px;
}

.home-onboarding-note {
    color: var(--muted);
    font-size: 14px;
}

/*
 * STARTSEITE, Teil 2 (Slice 084): Kennzahlen, „Zuletzt bewegt“, Aufmerksamkeit als Liste,
 * Werkstatt-Status als Pille. Farbe immer nur zusätzlich zu Text bzw. Symbol.
 * Kontrast: --muted auf Weiß 6,46 : 1 | --danger auf Weiß 6,57 : 1 | --info auf --info-soft 5,86 : 1 |
 * #5b3f8c auf #efeaf7 7,02 : 1 | --warn auf --warn-soft 4,86 : 1 | #1f6168 auf #e7f2f3 6,20 : 1 |
 * --ok auf --ok-soft 4,66 : 1 | --muted auf --surface-soft 5,87 : 1 | --text auf --accent-soft wie 082
 */
.home-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin: 0 0 24px;
    padding: 0;
    list-style: none;
}

.card.kpi {
    display: flex;
    flex-direction: column;
    padding: 18px 20px;
}

.kpi-label {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    color: var(--muted);
}

.kpi-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--info);
}

.kpi-dot-danger {
    background: var(--danger);
}

.kpi-dot-warn {
    background: var(--warn);
}

.kpi-dot-ok {
    background: var(--ok);
}

.kpi-value {
    margin-top: 6px;
    font-size: 30px;
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.kpi-sub {
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
}

.home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    margin-bottom: 20px;
}

.card.home-panel {
    padding: 0;
    overflow: hidden;
}

.card.home-panel .card-head {
    margin: 0;
    padding: 6px 20px;
    min-height: 52px;
}

.card.home-panel .card-head .text-link,
.text-link.home-recent-number {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.card.home-panel p.home-attention-more,
.card.home-panel p.home-stat,
.card.home-panel p.home-panel-empty {
    margin: 12px 20px;
}

.card.home-panel p.home-all-clear {
    margin: 16px 20px 0;
}

.home-recent-number {
    white-space: nowrap;
}

.home-recent-device {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.home-recent-age {
    color: var(--muted);
    white-space: nowrap;
}

.home-recent-age.is-late {
    color: var(--danger);
    font-weight: 600;
}

.home-recent-age .icon {
    vertical-align: -3px;
}

/* Slice 086: Baustein _list (Symbol, Titel, Beschreibung, Ziel); Aussehen wie „Braucht Ihre Aufmerksamkeit“ (084) */
.list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.list-item {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 4px 14px;
    align-items: start;
    padding: 14px 20px;

    border-bottom: 1px solid var(--border);
}

.list-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--info-soft);
    color: var(--info);
}

.list-item-danger .list-icon {
    background: var(--danger-soft);
    color: var(--danger);
}

.list-item-warning .list-icon {
    background: var(--warn-soft);
    color: var(--warn);
}

.list-text {
    align-self: center;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

/* --muted auf Weiß 6,46 : 1 */
.list-desc {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
}

.list-go {
    display: inline-flex;
    align-items: center;
    grid-column: 2;
    min-height: 44px;
    font-size: 14px;
}

.workshop-pill {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    min-height: 24px;
    padding: 2px 9px;

    border: 1px solid transparent;
    border-radius: var(--pill);
    background: var(--surface-soft);
    color: var(--muted);

    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.workshop-pill::before {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.workshop-pill-intake {
    background: var(--info-soft);
    color: var(--info);
}

.workshop-pill-diagnosis {
    background: var(--violet-soft);
    color: var(--violet);
}

.workshop-pill-repair {
    border-color: var(--border-strong);
    background: var(--accent-soft);
    color: var(--text);
}

.workshop-pill-waiting_part {
    background: var(--warn-soft);
    color: var(--warn);
}

.workshop-pill-testing {
    background: var(--petrol-soft);
    color: var(--petrol);
}

.workshop-pill-done {
    background: var(--ok-soft);
    color: var(--ok);
}

@media (min-width: 700px) {
    .list-item {
        grid-template-columns: 32px minmax(0, 1fr) auto;
    }

    .list-go {
        grid-column: auto;
        align-self: center;
    }
}

/*
 * STARTSEITE, Teil 3 (Slice 087): Leitstand nach Entwurf 084b. Band und Balken sind nur
 * Orientierung (Zahlen stehen immer als Text daneben bzw. im role="img"-Text).
 * Kontrast: --text auf Weiß wie 082 | --muted auf Weiß 6,46 : 1 | --danger auf Weiß 6,57 : 1 |
 * --focus auf Weiß (Links) Standard 5,72 : 1, Beispiel 6,11 : 1 | Rahmen Eingabefeld --control-border 3,56 : 1
 */
.home-grid-three > .card.home-panel {
    height: 100%;
}

.home-pipeline {
    margin-bottom: 16px;
}

.home-band {
    display: flex;
    gap: 2px;
    height: 10px;
    margin: 16px 20px;
    overflow: hidden;
    border-radius: 5px;
}

.home-band-part {
    display: block;
    flex-basis: 0;
    min-width: 4px;
    background: var(--muted);
}

.home-band-intake {
    background: var(--info);
}

.home-band-diagnosis {
    background: var(--violet);
}

.home-band-repair {
    background: var(--text);
}

.home-band-waiting_part {
    background: var(--warn);
}

.home-band-testing {
    background: var(--petrol);
}

.home-pipeline-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--border);
}

.home-pipeline-list > li {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.home-pipeline-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-height: 44px;
    height: 100%;
    padding: 14px 18px;
    color: var(--text);
    text-decoration: none;
}

.home-pipeline-item:hover {
    background: var(--surface-soft);
}

.home-pipeline-item .workshop-pill {
    white-space: normal;
}

.home-pipeline-value {
    font-size: 28px;
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.home-pipeline-sub {
    font-size: 13px;
    color: var(--muted);
}

.home-pipeline-sub.is-late,
.home-due-when.is-late {
    color: var(--danger);
    font-weight: 600;
}

.home-pipeline-sub .icon,
.home-due-when .icon {
    vertical-align: -3px;
}

.card-note {
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.card p.card-foot {
    margin: 16px 0 0;
    font-size: 13px;
}

.card.home-panel p.card-foot {
    margin: 0 20px 16px;
}

.home-bars {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 16px 20px 12px;
}

.home-bar {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    min-width: 0;
}

.home-bar-value {
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.home-bar-track {
    display: flex;
    align-items: flex-end;
    width: 100%;
    height: 80px;
}

.home-bar-fill {
    display: block;
    width: 100%;
    border-radius: 3px 3px 0 0;
    background: var(--nav);
}

/* Laufende Woche in --accent-text (≥ 3 : 1 auf Weiß, Standard 5,44 : 1, Beispiel 6,11 : 1); --accent wäre bei Beispiel zu hell */
.home-bar.is-current .home-bar-fill {
    background: var(--accent-text);
}

.home-bar-label {
    font-size: 11px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.home-recent-list,
.home-due-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.home-recent-item,
.home-due-item {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    align-items: center;
    justify-content: space-between;
    padding: 6px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.home-recent-item:last-child,
.home-due-item:last-child {
    border-bottom: 0;
}

.home-recent-main,
.home-due-main {
    display: flex;
    flex-wrap: wrap;
    gap: 0 10px;
    align-items: center;
    min-width: 0;
}

.home-due-main .text-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    overflow-wrap: anywhere;
}

.home-recent-meta {
    display: flex;
    gap: 10px;
    align-items: center;
}

.home-due-title {
    font-size: 13px;
    color: var(--muted);
}

.home-due-when {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}

.home-ampel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0 0 12px;
}

.home-ampel-item {
    padding: 14px 18px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.home-ampel-item:last-child {
    border-right: 0;
}

.home-ampel-item dt {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 13px;
    color: var(--muted);
}

.home-ampel-item dd {
    margin: 2px 0 0;
    font-size: 24px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.home-ask {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 20px 12px;
}

.home-ask-input {
    flex: 1 1 180px;
    min-width: 0;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--control-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

@media (max-width: 599px) {
    .home-ampel {
        grid-template-columns: minmax(0, 1fr);
    }

    .home-ampel-item {
        border-right: 0;
    }
}

@media (min-width: 600px) {
    .home-pipeline-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1100px) {
    .home-grid-three {
        grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr);
    }

    .home-pipeline-list {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .home-pipeline-list > li {
        border-bottom: 0;
    }

    .home-pipeline-list > li:last-child {
        border-right: 0;
    }
}

@media (min-width: 700px) {
    .home-tiles {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .home-attention-item {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .home-attention-item .button {
        grid-column: auto;
    }
}

@media (max-width: 420px) {
    .home-onboarding-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 600px) {
    .machine-actions .button,
    .machine-actions form,
    .machine-actions form .button {
        width: 100%;
    }
}

.card .field-note {
    margin: 0 0 20px;
    font-size: 14px;
}

.field {
    margin-bottom: 20px;
}

.field-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.field-required {
    color: var(--accent-text);
}

.field-input,
.field-select {
    display: block;
    width: 100%;
    max-width: 440px;
    min-height: 44px;
    padding: 10px 12px;

    font: inherit;
    color: var(--text);
    background: var(--surface);

    border: 1px solid var(--control-border);
    border-radius: var(--radius-sm);
}

.field-input[aria-invalid="true"],
.field-select[aria-invalid="true"] {
    border: 2px solid var(--danger);
}

.field-input:focus-visible,
.field-select:focus-visible,
.field-check:focus-visible,
.card summary:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.card p.field-hint {
    margin: 6px 0 0;
    font-size: 14px;
}

.field-error-text {
    color: var(--danger);
    font-weight: 600;
}

.card p.field-error-text {
    margin: 6px 0 0;
    color: var(--danger);
    font-size: 14px;
    font-weight: 600;
}

.field-static {
    margin: 0 0 20px;
}

.admin-fieldset {
    margin: 0 0 20px;
    padding: 0;
    border: 0;
}

.admin-fieldset legend {
    margin-bottom: 8px;
    padding: 0;
    font-weight: 600;
}

.check-row {
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 36px;
}

.field-check {
    width: 20px;
    height: 20px;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.inline-form .field-input {
    width: auto;
    min-width: 180px;
}

/*
 * SLICE 059: Seitenkopf, Rückweg, leere Zustände, Navigation mobil
 * Kontrast (Slice 083): --focus auf --canvas 5,48 : 1, Beispiel 5,86 : 1 (Rückweg) | --text auf #ffffff (untere Leiste)
 * --subtle auf #ffffff 5,22 : 1 (Symbol leerer Zustand)
 * Touch-Ziele: Buttons im Seitenkopf und Menüpunkte mobil ≥ 48 px, Rückweg ≥ 44 px
 */

.back-link {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    min-height: 44px;
    margin-bottom: 8px;

    color: var(--focus);
    font-weight: 600;
    text-decoration: underline;
}

.page-header-with-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    align-items: flex-end;
    justify-content: space-between;
}

.page-header-text {
    flex: 1 1 420px;
    min-width: 0;
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.page-header-actions .button {
    min-height: 48px;
}

.empty-state .empty-state-icon {
    margin-bottom: 12px;
    color: var(--subtle);
}

.empty-state .empty-state-text {
    margin: 0;
    max-width: 560px;

    color: var(--text);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
}

.empty-state .empty-state-hint {
    margin: 8px 0 0;
    max-width: 560px;
}

.empty-state .button {
    margin-top: 20px;
    min-height: 48px;
}

.settings-note {
    margin-bottom: 24px;
}

.card h2.settings-card-title {
    display: flex;
    gap: 10px;
    align-items: center;
}

.settings-card-title .icon {
    color: var(--teal-deep);
}

.settings-card .settings-card-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 8px;
}

.nav-toggle,
.bottom-nav {
    display: none;
}

.sidebar-menu {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

@media print {
    .nav-toggle,
    .bottom-nav {
        display: none !important;
    }

    html,
    body,
    .app,
    .main,
    .content {
        min-height: 0 !important;
        height: auto !important;
    }

    .main,
    .has-bottom-nav .main {
        padding-bottom: 0 !important;
    }
}

@media (max-width: 420px) {
    .card,
    .card.chat-form {
        padding: 20px 16px;
    }

    .card.chat-answer,
    .card.chat-findings {
        padding-left: 16px;
    }

    .chat-question-bubble {
        max-width: 92%;
    }

    .knowledge-button {
        padding: 12px 18px;
    }

    .knowledge-loading {
        flex-direction: column;
    }

    .auth-page {
        padding: 16px;
    }

    .auth-card {
        padding: 28px 20px;
    }

    .card-head {
        margin: -20px -16px 16px;
        padding: 14px 16px;
    }
}

@media (max-width: 850px) {
    .app {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .main {
        width: 100%;
    }

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

    .content {
        padding: 20px 16px 40px;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-user {
        max-width: 40vw;
    }

    .user-role {
        display: none;
    }

    /* Slice 059: Kopf mit Firmenname und Menü-Knopf; Liste per Knopf (ohne JS immer offen) */
    .sidebar-head {
        gap: 12px;
        justify-content: space-between;
        padding: 8px 16px;
    }

    .nav-toggle {
        display: inline-flex;
        flex: none;
        gap: 8px;
        align-items: center;
        min-height: 48px;
        padding: 10px 18px;

        border: 1px solid var(--control-border);
        border-radius: var(--radius-sm);
        background: var(--surface);

        color: var(--text);
        font-weight: 600;
        cursor: pointer;
    }

    .nav-toggle[hidden] {
        display: none;
    }

    .sidebar.nav-js:not(.nav-open) .sidebar-menu {
        display: none;
    }

    .sidebar nav {
        padding: 8px 10px;
    }

    .nav-link {
        min-height: 48px;
    }

    .sidebar-footer .logout-button {
        min-height: 48px;
    }

    /* Untere Leiste nur für Mitarbeitende: Start, Fragen, Meine Scheine (+ Werkstatt, Slice 071) */
    .has-bottom-nav .bottom-nav {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 30;

        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        gap: 4px;
        padding: 4px 8px env(safe-area-inset-bottom);

        background: var(--surface);
        border-top: 1px solid var(--border);
    }

    .bottom-nav-link {
        display: flex;
        flex-direction: column;
        gap: 2px;
        align-items: center;
        justify-content: center;
        min-height: 56px;
        padding: 6px 4px;

        border-radius: var(--radius-sm);
        color: var(--text);
        font-size: 14px;
        font-weight: 600;
        text-align: center;
    }

    .bottom-nav-link .nav-icon {
        color: var(--subtle);
    }

    .bottom-nav-link .nav-icon {
        width: 22px;
        height: 22px;
    }

    /* Aktiv: Hintergrund, Akzentkante oben und Schriftstärke, nicht nur Farbe */
    .bottom-nav-link.active {
        background: var(--accent-soft);
        box-shadow: inset 0 3px 0 var(--accent);
        font-weight: 700;
    }

    .bottom-nav-link.active .nav-icon {
        color: var(--text);
    }

    .bottom-nav-link:focus-visible {
        outline: 3px solid var(--focus);
        outline-offset: -3px;
    }

    .has-bottom-nav .main {
        padding-bottom: calc(68px + env(safe-area-inset-bottom));
    }

    .has-bottom-nav .card.chat-form {
        bottom: calc(72px + env(safe-area-inset-bottom));
    }
}

/*
 * SLICE 061: Assistent „Neues Gerät einrichten“
 * Auswahl-Kacheln und Schaltflächen ≥ 48 px hoch, Auswahl nicht nur über Farbe
 * (Rahmen 2 px plus sichtbares Optionsfeld), ohne JS bedienbar.
 */
.wizard-progress {
    margin: 0 0 16px;
}

.wizard-progress-text {
    margin: 0 0 8px;
}

.wizard-progress-bar {
    width: 100%;
    height: 10px;
    accent-color: var(--teal-deep);
}

.wizard-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
    font-size: 14px;
}

.wizard-step {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    color: var(--muted);
}

.wizard-step.is-current {
    color: var(--text);
    font-weight: 700;
}

.wizard-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 2px solid var(--control-border);
    border-radius: 50%;
    font-size: 13px;
}

.is-current .wizard-step-number {
    border-color: var(--teal-deep);
    color: var(--white);
    background: var(--teal-deep);
}

.is-done .wizard-step-number {
    border-color: var(--teal-deep);
    color: var(--teal-deep);
}

.card h2.wizard-title {
    margin: 0 0 16px;
}

.card h3.wizard-subtitle {
    margin: 20px 0 10px;
    font-size: 17px;
}

.wizard-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.wizard-tile {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: center;
    min-height: 56px;
    padding: 12px 16px;

    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}

.wizard-tile:hover {
    background: var(--surface-soft);
}

.wizard-tile:has(.wizard-tile-input:checked) {
    border-color: var(--teal-deep);
    background: var(--surface-soft);
}

.wizard-tile:has(.wizard-tile-input:focus-visible) {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.wizard-tile.is-disabled {
    cursor: not-allowed;
    opacity: .85;
}

.wizard-tile-other {
    grid-column: 1 / -1;
    display: block;
    cursor: default;
}

.wizard-tile-row {
    display: flex;
    gap: 12px;
    align-items: center;
    min-height: 44px;
    margin-bottom: 8px;
    cursor: pointer;
}

.wizard-tile-input {
    flex: none;
    width: 22px;
    height: 22px;
    accent-color: var(--teal-deep);
}

.wizard-tile-label {
    font-weight: 600;
}

/* Slice 073: Geräteart-Kacheln (Werkstatt) – groß, mit Symbol, gut auf dem Tablet */
.workshop-kind-tile {
    min-height: 72px;
    font-size: 18px;
}

.workshop-kind-tile .icon {
    flex: none;
    color: var(--teal-deep);
}

/* Slice 075: Störungsbild als kurze Kennzeichen (Board, Übersicht) */
.workshop-fault-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
    margin-top: 4px;
}

.workshop-fault-chip {
    padding: 1px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--pill);
    background: var(--surface-soft);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.wizard-tile-hint {
    flex-basis: 100%;
    color: var(--muted);
    font-size: 14px;
}

.wizard-items {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.wizard-item {
    padding: 12px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}

.wizard-item .check-row {
    min-height: 44px;
}

.wizard-item-name {
    margin: 0;
    font-weight: 600;
}

.card p.wizard-item-meta {
    margin: 4px 0 0;
    font-size: 14px;
}

.wizard-item-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0 24px;
    margin-top: 8px;
}

.wizard-item-fields .field {
    margin-bottom: 8px;
}

.field-input.field-input-short {
    max-width: 200px;
}

.wizard-hint {
    margin-bottom: 16px;
}

.wizard-more {
    margin: 0 0 20px;
}

.wizard-more summary {
    min-height: 44px;
    padding: 10px 0;
    font-weight: 600;
    cursor: pointer;
}

.wizard-more-body {
    padding-top: 8px;
}

.wizard-inherited {
    margin: 0 0 16px;
}

.wizard-summary {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-strong);
}

.wizard-summary-list {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 4px 16px;
    margin: 0 0 8px;
}

.wizard-summary-list dt {
    font-weight: 600;
}

.wizard-summary-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.wizard-actions {
    margin-top: 24px;
}

.wizard-actions .button,
.wizard-next .button {
    min-height: 48px;
}

.button.button-quiet {
    color: var(--focus);
    background: transparent;
    text-decoration: underline;
}

.button.button-quiet:hover {
    background: var(--surface-soft);
}

.wizard-next {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.wizard-alternative {
    margin-top: 16px;
    font-size: 14px;
}

/* Slice 062: Personen-Seite – auf dem Handy untereinander, breit zweispaltig */
.person-status {
    margin: -8px 0 16px;
}

.person-jump {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.person-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
}

.person-grid > .card,
.person-grid > .person-section .card {
    margin: 0;
}

.person-section {
    scroll-margin-top: 16px;
}

.person-section-head {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.person-section-head h2 {
    margin: 0;
}

.person-section-wide .card + .card {
    margin-top: 20px;
}

.person-facts {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.person-facts li {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.person-details {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 4px 16px;
    margin: 0 0 16px;
}

.person-details dt {
    font-weight: 600;
}

.person-details dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.button.person-row-action {
    min-height: 44px;
}

@media (min-width: 1000px) {
    .person-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .person-section-wide {
        grid-column: 1 / -1;
    }
}

/* Slice 062: Einweisungs-Assistent – große Auswahlflächen */
.briefing-search {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.briefing-search .field {
    flex: 1 1 240px;
    margin: 0;
}

.briefing-search .button {
    min-height: 48px;
}

a.wizard-tile {
    color: inherit;
    text-decoration: none;
}

a.wizard-tile:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.wizard-tile .status {
    flex-basis: 100%;
}

@media (max-width: 600px) {
    .wizard-actions .button,
    .wizard-next form,
    .wizard-next .button {
        width: 100%;
    }

    .wizard-summary-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .wizard-summary-list dd {
        margin-bottom: 8px;
    }
}

/*
 * Slice 076: Scannen-Knopf, Kamera-Baustein am Dateifeld und Kamera-Ansicht (Vollbild).
 * Kontrast: --text auf --surface 17,96 : 1 | Weiß auf --nav #0e1726 17,96 : 1 |
 * --on-accent auf --accent (Auslöser) 5,44 : 1 (Standard) | --text auf Weiß (Fertig) 17,96 : 1 |
 * Fokus in der Kamera-Ansicht: Weiß auf #0e1726 bzw. #000 ≥ 17 : 1
 */
.scan-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 14px;

    border: 1px solid var(--control-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);

    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.scan-button:hover {
    background: var(--surface-soft);
}

.scan-button[hidden],
.camera-field[hidden],
.camera-open[hidden] {
    display: none;
}

.camera-field {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.camera-open {
    gap: 8px;
    min-height: 48px;
}

.camera-or {
    margin: 0;
}

.camera-note:empty {
    margin: 0;
}

.camera-dialog {
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;

    border: 0;
    background: var(--black);
    color: var(--white);
}

.camera-dialog[open] {
    display: flex;
    flex-direction: column;
}

.camera-dialog::backdrop {
    background: var(--black);
}

.camera-dialog [hidden] {
    display: none !important;
}

.camera-head,
.camera-panel {
    background: var(--nav);
    padding: 12px 16px;
}

.camera-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
}

.camera-title {
    margin: 0;
    font-size: 18px;
    line-height: 1.3;
}

.camera-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.camera-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.camera-frame {
    position: absolute;
    inset: 15% 8%;

    border: 3px solid var(--white);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px var(--scrim);
    pointer-events: none;
}

.camera-scan .camera-frame {
    inset: auto;
    top: 50%;
    left: 50%;
    width: min(70vw, 50vh);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
}

.camera-panel {
    display: grid;
    gap: 10px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.camera-hint,
.camera-status {
    margin: 0;
    text-align: center;
}

.camera-thumbs {
    display: flex;
    gap: 12px;
    margin: 0;
    padding: 0;
    overflow-x: auto;
    list-style: none;
}

.camera-thumb {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.camera-thumb img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border: 2px solid var(--white);
    border-radius: 8px;
}

.camera-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.camera-btn {
    min-width: 48px;
    min-height: 48px;
    padding: 0 16px;

    border: 2px solid var(--white);
    border-radius: var(--pill);
    background: transparent;
    color: var(--white);

    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.camera-btn[aria-pressed="true"],
.camera-done {
    background: var(--white);
    color: var(--text);
}

.camera-shutter {
    min-width: 72px;
    min-height: 72px;
    padding: 0 24px;

    border: 4px solid var(--white);
    border-radius: var(--pill);
    background: var(--accent);
    color: var(--on-accent);

    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.camera-dialog button:focus-visible {
    outline: 3px solid var(--white);
    outline-offset: 3px;
}

/*
 * BAUSTEINE (Slice 086): Meldung, Marke, Fortschritt, Segment-Umschalter.
 * Kontrast: --text auf --teal-soft bzw. --info-soft ≥ 13 : 1 | --danger auf --danger-soft 5,75 : 1
 *   | --muted auf --tag-bg über Weiß 5,76 : 1 | --muted auf Weiß 6,46 : 1 | Weiß auf --nav wie oben
 */
.flash {
    margin-bottom: 20px;
    padding: 12px 14px;

    border: 1px solid var(--border-strong);
    border-left-width: 3px;
    border-left-color: var(--info);
    border-radius: var(--radius-sm);
    background: var(--info-soft);
    color: var(--text);
}

.flash-success {
    border-left-color: var(--teal-deep);
    background: var(--teal-soft);
}

.flash-error {
    border-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 600;
}

.tag {
    padding: 1px 8px;

    border: 1px solid transparent;
    border-radius: 4px;
    background: var(--tag-bg);
    color: var(--muted);

    font-size: 11px;
    font-weight: 600;
}

.progress {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.progress-bar {
    flex: 1 1 auto;
    height: 4px;
    overflow: hidden;
    border-radius: 2px;
    background: var(--track);
}

.progress-bar span {
    display: block;
    height: 100%;
    background: var(--progress-color, var(--accent));
}

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 16px;
    padding: 4px;

    border: 1px solid var(--border-strong);
    border-radius: var(--pill);
    background: var(--surface);
}

.segmented a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: var(--pill);
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

.segmented a[aria-current="page"] {
    background: var(--nav);
    color: var(--white);
}

.segmented a:hover {
    text-decoration: underline;
}

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