/* Grundlayout aller Seiten — ausgelagert aus templates/base.html, damit
   der Browser es einmal lädt und zwischenspeichert statt mit jeder Seite
   (~110 KB) neu. Eingebunden per {% static_v %} (Versionskennung). */
:root {
    color-scheme: light;
    --color-bg: #f4f6f9;
    --color-surface: #ffffff;
    --color-ink: #0f172a;
    --color-text: #1e293b;
    --color-muted: #64748b;
    --color-border: #e2e8f0;
    --color-border-strong: #cbd5e1;
    --color-accent: #2563eb;
    --color-accent-ink: #1d4ed8;
    --color-accent-bg: #eff6ff;
    --color-sidebar-bg: #0f172a;
    --color-sidebar-text: #cbd5e1;
    --color-sidebar-text-active: #ffffff;
    --color-sidebar-hover: #1e293b;
    --color-red: #dc2626;
    --color-red-bg: #fef2f2;
    --color-amber: #b45309;
    --color-amber-bg: #fffbeb;
    --color-green: #15803d;
    --color-green-bg: #f0fdf4;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.10);
    --sidebar-width: 234px;
    --sidebar-width-collapsed: 68px;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    /* Querformat am Handy: Bereiche neben Notch/Kamera selbst füllen
       (viewport-fit=cover) statt sie dem System zu überlassen, das sie
       in der installierten App in Theme-Blau einfärbt. Links in
       Seitenleisten-Farbe, rechts in Seitenfarbe. */
    background: linear-gradient(to right, var(--color-sidebar-bg) env(safe-area-inset-left, 0px), var(--color-bg) env(safe-area-inset-left, 0px));
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    color: var(--color-text);
    margin: 0;
    font-size: 0.94rem;
    line-height: 1.5;
}

.icon { width: 16px; height: 16px; margin-right: 0.4rem; vertical-align: -3px; flex-shrink: 0; }
.button .icon, button .icon, .nav-link .icon, .back-link .icon, .sidebar-brand .icon { margin-right: 0; }

h1, h2, h3 { color: var(--color-ink); font-weight: 700; line-height: 1.25; margin: 0 0 0.6rem; }
.page-subtitle { color: var(--color-muted); font-size: 0.89rem; margin: -0.35rem 0 1.3rem; max-width: 42rem; }
h1 { font-size: 1.5rem; letter-spacing: -0.01em; }
/* Seitenkopf mit Icon-Kachel (gleiches Symbol wie in der Seitenleiste):
   h1.page-title > span.title-icon (darin das Icon) + Titeltext. */
h1.page-title { display: flex; align-items: center; gap: 0.75rem; }
.title-icon {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 2.5rem; height: 2.5rem; border-radius: 0.75rem;
    background: linear-gradient(135deg, var(--color-accent-bg), #dbeafe); color: var(--color-accent);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}
.title-icon .icon { width: 20px; height: 20px; margin-right: 0; }
/* Kleines Symbol vor einem Listeneintrag, das seine Art zeigt (z. B.
   Schulung / E-Learning / Kenntnisnahme in „Meine Aufgaben"). */
.type-icon {
    display: inline-flex; align-items: center; justify-content: center; vertical-align: -0.45rem;
    width: 1.75rem; height: 1.75rem; margin-right: 0.55rem; border-radius: 0.5rem;
    background: var(--color-accent-bg); color: var(--color-accent);
}
.type-icon .icon { width: 15px; height: 15px; margin-right: 0; }
h2 { font-size: 1.1rem; margin-top: 1.75rem; }
h3 { font-size: 0.98rem; }
p { margin: 0 0 0.75rem; }
/* Verhindert horizontales Verschieben der ganzen Seite durch ein
   breites Bild (z. B. Foto im E-Learning-Lerninhalt) auf schmalen
   Bildschirmen. */
img, video { max-width: 100%; height: auto; }
/* Code-Block aus dem Rich-Text-Editor (Quill, siehe E-Learning-
   Lerninhalt) kann eine lange, nicht umbrechende Zeile enthalten —
   eigener horizontaler Scroll statt die ganze Seite zu verschieben. */
pre { overflow-x: auto; max-width: 100%; }
a { color: var(--color-accent); }

/* ---------- Layout: Seitenleiste + Hauptbereich ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    /* Unten mehr Luft: Der letzte Eintrag lässt sich über die Link-Vorschau
       des Browsers (Kasten unten links beim Überfahren eines Links) scrollen. */
    padding: 1rem 0.75rem 3.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
    padding: 0.4rem 0.6rem 1.1rem;
    letter-spacing: -0.01em;
}
.sidebar-brand .icon { width: 22px; height: 22px; color: var(--color-accent); flex-shrink: 0; }
/* Testsystem (APP_ENVIRONMENT=test): oranger Streifen oben, oranges Logo. */
.test-banner {
    background: #ea580c; color: #fff; text-align: center; font-weight: 700; font-size: 0.8rem;
    letter-spacing: 0.04em; padding: 0.3rem 0.75rem; position: relative; z-index: 50;
}
.is-test-system .sidebar-brand .icon, .is-test-system .mobile-topbar > .icon { color: #fb923c; }
.is-test-system .sidebar { box-shadow: inset 0 3px 0 #ea580c; }
@media print { .test-banner { display: none; } }
/* Kopf der Seitenleiste: Logo + Knopf ≡ zum Ein-/Ausklappen. */
.sidebar-head { display: flex; align-items: center; gap: 0.25rem; margin-bottom: 1.1rem; }
.sidebar-head .sidebar-brand { flex: 1 1 auto; min-width: 0; padding-bottom: 0.4rem; }
.sidebar-collapse-toggle {
    margin: 0; flex-shrink: 0; min-height: 40px; min-width: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: var(--radius-sm); background: transparent; color: var(--color-sidebar-text); cursor: pointer; box-shadow: none;
}
.sidebar-collapse-toggle .icon { width: 20px; height: 20px; margin: 0; }
.sidebar-collapse-toggle:hover, .sidebar-collapse-toggle:focus-visible { background: var(--color-sidebar-hover); color: #fff; }
/* Eingeklappt (Knopf ≡, je Gerät gemerkt) – wie die Symbol-Leiste auf dem Tablet. */
@media (min-width: 601px) {
    html.sidebar-collapsed { --sidebar-width: var(--sidebar-width-collapsed); }
    html.sidebar-collapsed .sidebar-brand span, html.sidebar-collapsed .nav-link span, html.sidebar-collapsed .nav-group-label { display: none; }
    html.sidebar-collapsed .nav-section.collapsed .nav-group { display: flex; }
    html.sidebar-collapsed .nav-section { border-top: 1px solid #1e293b; padding-top: 0.35rem; margin-top: 0.35rem; }
    html.sidebar-collapsed .nav-link { justify-content: center; }
    html.sidebar-collapsed .sidebar-head { flex-direction: column; }
    html.sidebar-collapsed .sidebar-head .sidebar-brand { justify-content: center; padding: 0.4rem 0; }
}
.nav-group { display: flex; flex-direction: column; gap: 0.1rem; margin-bottom: 0.5rem; }
.nav-group-label {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em;
    color: #64748b; margin: 1rem 0.6rem 0.35rem; font-weight: 700;
}
.nav-group-toggle {
    display: flex; align-items: center; justify-content: space-between; width: calc(100% - 1.2rem);
    background: none; border: none; padding: 0.2rem 0; min-height: 28px; cursor: pointer; font-family: inherit; text-align: left;
    margin: 0.9rem 0.6rem 0.3rem;
}
.nav-group-toggle:hover { color: var(--color-sidebar-text); }
.nav-group-toggle .nav-chevron { width: 14px; height: 14px; transition: transform 0.15s ease; margin: 0; }
.nav-section.collapsed .nav-chevron { transform: rotate(-90deg); }
.nav-section.collapsed .nav-group { display: none; }
.nav-link {
    display: flex; align-items: center; gap: 0.65rem; position: relative; min-height: 44px;
    padding: 0.5rem 0.6rem; border-radius: var(--radius-sm);
    color: var(--color-sidebar-text); text-decoration: none; font-size: 0.87rem; font-weight: 500;
    border: none; background: none; width: 100%; text-align: left; cursor: pointer;
}
.nav-link .icon { width: 17px; height: 17px; flex-shrink: 0; }
.nav-link:hover { background: var(--color-sidebar-hover); color: var(--color-sidebar-text-active); }
.nav-link.active { background: var(--color-accent); color: #fff; }
.nav-divider { border: 0; border-top: 1px solid #1e293b; margin: 0.35rem 0.6rem; }

/* Kopfleiste oben rechts: Glocke + Benutzermenü (templates/_user_controls.html).
   Desktop/Tablet: schlanke Leiste ohne eigenen Hintergrund über der
   Inhaltskarte. Smartphone: rechts in der dunklen Mobile-Topbar. */
.main-area.with-topbar { flex-direction: column; align-items: center; justify-content: flex-start; }
/* Bleibt beim Scrollen oben stehen; Hintergrund in Seitenfarbe, damit
   durchscrollender Inhalt nicht durchscheint. Schatten erst nach dem
   Scrollen (Klasse .scrolled, siehe Skript unten). */
.topbar {
    position: sticky; top: 0; z-index: 30; align-self: stretch;
    background: rgba(244, 246, 249, 0.92); backdrop-filter: saturate(1.4) blur(8px);
    -webkit-backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid transparent; transition: border-color 0.15s, box-shadow 0.15s;
}
.topbar.scrolled { border-bottom-color: var(--color-border); box-shadow: 0 1px 6px rgba(15, 23, 42, 0.05); }
.topbar-inner {
    max-width: calc(80rem + 3.5rem); margin: 0 auto; padding: 0.6rem 1.75rem;
    display: flex; justify-content: flex-end;
}
.user-controls { display: flex; align-items: center; gap: 0.35rem; }
.bell-link {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 999px; color: var(--color-muted); text-decoration: none;
}
.bell-link .icon { width: 20px; height: 20px; margin: 0; }
.bell-link:hover { background: var(--color-surface); color: var(--color-text); }
.bell-badge {
    position: absolute; top: 5px; right: 4px; min-width: 1.05rem; height: 1.05rem; padding: 0 0.28rem;
    display: inline-flex; align-items: center; justify-content: center; border-radius: 999px;
    background: var(--color-red); color: #fff; font-size: 0.66rem; font-weight: 700; line-height: 1;
    box-shadow: 0 0 0 2px var(--color-bg);
}
.user-menu .user-menu-toggle {
    min-height: 44px; gap: 0.5rem; padding: 0.25rem 0.55rem 0.25rem 0.3rem; border: none; border-radius: 999px;
    background: transparent; color: var(--color-text); font-size: 0.87rem; font-weight: 500;
}
.user-menu .user-menu-toggle:hover, .user-menu.open .user-menu-toggle { background: var(--color-surface); color: var(--color-text); }
.user-menu .user-menu-toggle .icon { width: 15px; height: 15px; margin: 0; color: var(--color-muted); transition: transform 0.15s; }
.user-menu:not(.open) .user-menu-toggle .icon { transform: rotate(180deg); }
.avatar {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 34px; height: 34px; border-radius: 999px; background: var(--color-accent); color: #fff;
    font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em;
}
.user-menu-name { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu .action-menu-panel { min-width: 15rem; z-index: 50; color: var(--color-text); }
/* Verwaltung (Zahnrad) neben der Glocke, gleiche Optik wie die Glocke. */
.admin-menu .admin-menu-toggle {
    width: 44px; height: 44px; min-width: 44px; border: none; border-radius: 999px; background: transparent; color: var(--color-muted);
}
.admin-menu .admin-menu-toggle .icon { width: 20px; height: 20px; margin: 0; transition: transform 0.25s ease; }
.admin-menu .admin-menu-toggle:hover, .admin-menu.open .admin-menu-toggle { background: var(--color-surface); color: var(--color-text); }
.admin-menu.open .admin-menu-toggle .icon { transform: rotate(45deg); }
.admin-menu.is-current .admin-menu-toggle { color: var(--color-accent); background: var(--color-accent-bg); }
.admin-menu .action-menu-panel { min-width: 15rem; z-index: 50; color: var(--color-text); }
.admin-menu .action-menu-panel a.active { background: var(--color-accent-bg); color: var(--color-accent-ink); font-weight: 600; }
.user-menu-header { display: flex; flex-direction: column; padding: 0.45rem 0.65rem 0.55rem; border-bottom: 1px solid var(--color-border); margin-bottom: 0.2rem; }
.user-menu-header strong { font-size: 0.87rem; color: var(--color-ink); }
.user-menu-header span { font-size: 0.78rem; color: var(--color-muted); }
.user-menu .action-menu-panel hr { border: 0; border-top: 1px solid var(--color-border); margin: 0.2rem 0; }
.user-menu .action-menu-panel form { margin: 0; }
/* Dialog „Über QM-System“ (Benutzermenü). */
dialog.about-dialog { max-width: 24rem; padding: 0; overflow: hidden; }
.about-close {
    position: absolute; top: 0.6rem; right: 0.6rem; margin: 0; padding: 0; width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center; border: none; border-radius: 999px;
    background: transparent; color: var(--color-muted); cursor: pointer;
}
.about-close:hover { background: var(--color-bg); color: var(--color-text); }
.about-close .icon { width: 18px; height: 18px; margin: 0; }
.about-hero {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 1.8rem 1.5rem 1.3rem; background: linear-gradient(180deg, var(--color-accent-bg), var(--color-surface));
}
.about-logo {
    display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px;
    border-radius: 14px; background: var(--color-accent); color: #fff; margin-bottom: 0.8rem;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}
.about-logo .icon { width: 28px; height: 28px; margin: 0; }
dialog.about-dialog h3 { margin: 0; font-size: 1.2rem; letter-spacing: -0.01em; }
.about-tagline { margin: 0.25rem 0 0; font-size: 0.85rem; color: var(--color-muted); }
.about-version {
    margin-top: 0.75rem; padding: 0.2rem 0.65rem; border-radius: 999px; border: 1px solid var(--color-border);
    background: var(--color-surface); font-size: 0.75rem; font-weight: 600; color: var(--color-muted);
    font-variant-numeric: tabular-nums;
}
.about-facts { margin: 0; padding: 0 1.5rem; }
.about-facts > div { padding: 0.75rem 0; border-top: 1px solid var(--color-border); }
.about-facts dt { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-muted); }
.about-facts dd { margin: 0.2rem 0 0; font-size: 0.92rem; font-weight: 500; }
.about-legal {
    margin: 0; padding: 0.8rem 1.5rem 1rem; border-top: 1px solid var(--color-border);
    background: var(--color-bg); font-size: 0.75rem; color: var(--color-muted); text-align: center;
}

.main-area { flex: 1; min-width: 0; display: flex; justify-content: center; }
main {
    width: 100%;
    min-width: 0;
    /* Breit genug für Tabellen/Formulare auf großen Monitoren.
       Fließtext begrenzt .prose bzw. .rich-text-content separat auf
       eine gut lesbare Zeilenlänge. */
    max-width: 80rem;
    margin: 2rem 1.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 2rem 2rem;
}
main.narrow { max-width: 30rem; }
/* Textlastige Seiten (Hilfe, Leitfaden): Absätze und Listen auf
   ca. 80 Zeichen pro Zeile, Tabellen/Grafiken dürfen breiter sein. */
main.prose :is(p, li, blockquote, dd) { max-width: 48rem; }
.with-topbar > main { margin-top: 0.4rem; }

/* Tablet: Sidebar bleibt sichtbar, aber nur Icons (kein Hamburger).
   Ebenso Handy im Querformat (wenig Höhe, Touch) — große iPhones sind
   quer breiter als 860px, die volle Seitenleiste nähme dort ein
   Drittel der Breite ein. */
@media (max-width: 860px), (max-height: 560px) and (pointer: coarse) {
    :root { --sidebar-width: var(--sidebar-width-collapsed); }
    .sidebar-brand span, .nav-link span, .nav-group-label { display: none; }
    /* Nur-Icon-Leiste: Gruppen immer offen, Trennlinie statt Überschrift. */
    .nav-section.collapsed .nav-group { display: flex; }
    .nav-section { border-top: 1px solid #1e293b; padding-top: 0.35rem; margin-top: 0.35rem; }
    .sidebar-brand { justify-content: center; padding: 0.4rem 0 1.1rem; }
    .sidebar-head { flex-direction: column; }
    .sidebar-head .sidebar-brand { padding: 0.4rem 0; }
    .nav-link { justify-content: center; }
    .topbar-inner { padding: 0.5rem 1rem; }
    /* Knopf ≡ klappt die Leiste vorübergehend mit Beschriftung über den Inhalt auf. */
    html.sidebar-overlay .app-shell { padding-left: var(--sidebar-width-collapsed); }
    html.sidebar-overlay .sidebar {
        position: fixed; top: 0; left: 0; z-index: 60; width: 250px; height: 100vh; box-shadow: var(--shadow-md);
    }
    html.sidebar-overlay .sidebar-brand span, html.sidebar-overlay .nav-link span, html.sidebar-overlay .nav-group-label { display: inline; }
    html.sidebar-overlay .nav-group-toggle { display: flex; pointer-events: none; }
    html.sidebar-overlay .nav-group-toggle .nav-chevron { display: none; }
    html.sidebar-overlay .nav-section { border-top: none; padding-top: 0; margin-top: 0; }
    html.sidebar-overlay .sidebar-head { flex-direction: row; }
    html.sidebar-overlay .sidebar-head .sidebar-brand { justify-content: flex-start; padding: 0.4rem 0.6rem; }
    html.sidebar-overlay .nav-link { justify-content: flex-start; }
    html.sidebar-overlay .sidebar-backdrop {
        display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 55;
    }
    .with-topbar > main { margin-top: 0.25rem; }
    main { margin: 1rem; padding: 1.25rem 1.25rem; }
}

/* ---------- Mobile-Topbar (Hamburger) + Off-Canvas-Sidebar ---------- */
.mobile-topbar {
    display: none; align-items: center; gap: 0.75rem; position: sticky; top: 0; z-index: 40;
    background: var(--color-sidebar-bg); color: #fff; padding: 0.7rem 1rem; font-weight: 700;
}
.mobile-topbar > .icon { color: var(--color-accent); }
.hamburger-button .icon { width: 22px; height: 22px; }
.hamburger-button {
    margin: 0; padding: 0.4rem; border: none; background: transparent; color: #fff; cursor: pointer;
    display: inline-flex; min-height: 44px; min-width: 44px; align-items: center; justify-content: center;
}
.sidebar-backdrop { display: none; }

/* ---------- Meldungen ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.messages li { display: flex; align-items: flex-start; gap: 0.55rem; padding: 0.65rem 0.6rem 0.65rem 0.85rem; border-radius: var(--radius-md); font-size: 0.88rem; line-height: 1.4; animation: msg-in 0.25s ease-out; }
.messages .error { background: var(--color-red-bg); color: var(--color-red); }
.messages .success { background: var(--color-green-bg); color: var(--color-green); }
.messages .info { background: var(--color-accent-bg); color: var(--color-accent-ink); }
.messages .warning { background: var(--color-amber-bg); color: var(--color-amber); }
.messages .msg-icon { flex-shrink: 0; display: inline-flex; margin-top: 0.05rem; }
.messages .msg-icon .icon { width: 17px; height: 17px; margin: 0; }
.messages .msg-text { flex: 1; min-width: 0; }
.messages .msg-close { flex-shrink: 0; margin: -0.25rem 0 -0.25rem 0.2rem; padding: 0; min-height: 30px; width: 30px; border: none; background: none; color: inherit; opacity: 0.6; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.messages .msg-close:hover { opacity: 1; background: rgba(0,0,0,0.06); }
.messages .msg-close .icon { width: 15px; height: 15px; margin: 0; }
.messages li.leaving { animation: msg-out 0.25s ease-in forwards; }
@keyframes msg-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes msg-out { to { opacity: 0; transform: translateY(-6px); } }
/* Schwebende Erfolgsmeldung (messages mit extra_tags="toast"): oben
   rechts, animiertes Häkchen, schließt sich nach einigen Sekunden. */
.messages li.toast {
    position: fixed; top: 1.1rem; right: 1.1rem; z-index: 90; width: min(24rem, calc(100vw - 2rem));
    padding: 0.9rem 0.7rem 1rem 0.95rem; background: var(--color-surface); color: var(--color-ink);
    border: 1px solid var(--color-border); border-radius: 0.9rem; overflow: hidden;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.08);
    animation: toast-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.messages li.toast .msg-icon { width: 2.3rem; height: 2.3rem; border-radius: 50%; align-items: center; justify-content: center; background: var(--color-green-bg); color: var(--color-green); margin: 0; }
.messages li.toast .msg-icon svg.tick { width: 20px; height: 20px; }
.messages li.toast .msg-icon svg.tick path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: tick-draw 0.45s 0.25s ease-out forwards; }
.messages li.toast .msg-text { align-self: center; font-weight: 600; }
.messages li.toast::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--color-green); transform-origin: left; animation: toast-timer 6s linear forwards; }
.messages li.toast:hover::after { animation-play-state: paused; }
.messages li.toast.leaving { animation: toast-out 0.3s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
@keyframes tick-draw { to { stroke-dashoffset: 0; } }
@keyframes toast-timer { to { transform: scaleX(0); } }
@media (max-width: 720px) { .messages li.toast { top: calc(66px + 0.6rem); right: 1rem; left: 1rem; width: auto; } }
@media (prefers-reduced-motion: reduce) {
    .messages li, .messages li.toast, .messages li.toast::after, .messages li.toast .msg-icon svg.tick path { animation: none !important; stroke-dashoffset: 0; }
}

/* ---------- Formulare ---------- */
label { display: block; margin: 1rem 0 0.3rem; font-weight: 600; font-size: 0.87rem; color: var(--color-ink); }
label:first-child { margin-top: 0; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="email"], input[type="url"], input[type="time"], input[type="datetime-local"], select, textarea {
    width: 100%; padding: 0.6rem 0.8rem; border: 1px solid var(--color-border-strong); border-radius: 8px;
    box-sizing: border-box; font-family: inherit; font-size: 0.9rem; background: var(--color-surface); color: var(--color-text);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
input[type="text"]:hover, input[type="password"]:hover, input[type="date"]:hover, input[type="number"]:hover,
input[type="email"]:hover, input[type="url"]:hover, input[type="time"]:hover, input[type="datetime-local"]:hover,
select:hover, textarea:hover { border-color: var(--color-muted); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}
input::placeholder, textarea::placeholder { color: #94a3b8; }
/* Einheitlicher, schlanker Pfeil statt des Browser-Standards */
select:not([multiple]) {
    appearance: none; -webkit-appearance: none; padding-right: 2.4rem; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 16px;
}
textarea { min-height: 6.5rem; resize: vertical; line-height: 1.5; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.55; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--color-accent); margin-right: 0.35rem; }
/* Eine Checkbox ist inline-level (Browser-Default) und hat — anders als
   input[type=text]/select/textarea oben — keine eigene Breite, die eine
   neue Zeile erzwingt. Direkt aus einem Formularfeld heraus (generic_form.html:
   <label>…</label>{{ field }}) rutscht sie dadurch ohne Zeilenumbruch bis an
   das nächste Element heran (meist den Speichern-Button) statt unter ihr Label
   zu bleiben. Radios bleiben bewusst inline (werden anderswo in eigenen
   <label style="display:inline-block"> nebeneinander verwendet, z. B.
   Checkliste Ja/Nein/N.A.). */
form > input[type="checkbox"] { display: block; margin: 0.2rem 0 0; }
select[multiple] { min-height: 7rem; }

/* Wiederverwendbare Optik für CheckboxSelectMultiple-Felder (z. B.
   Tätigkeitsbereiche bei Mitarbeitern) — ersetzt das schwer bedienbare
   native select[multiple] (Mehrfachauswahl per Strg/Cmd-Klick, auf
   Touch-Geräten praktisch nicht nutzbar) durch eine antippbare Liste
   mit ordentlicher Mindest-Tippfläche. Widget-Attribut class="checkbox-list"
   setzen, um dieses Styling zu bekommen. */
.checkbox-list {
    display: flex; flex-direction: column; border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md); padding: 0.3rem; background: var(--color-surface);
}
.checkbox-list > div { margin: 0; }
.checkbox-list label {
    display: flex; align-items: center; gap: 0.55rem; margin: 0; padding: 0.6rem 0.7rem;
    min-height: 44px; font-weight: 400; border-radius: var(--radius-sm); cursor: pointer;
}
.checkbox-list label:hover { background: var(--color-bg); }
.checkbox-list input[type="checkbox"] { margin: 0; }

/* ---------- Modernes Formular-Layout (generic_form.html & Co.) ----------
   Jedes Feld steckt in .form-field--<widget_type>; daraus ergeben sich
   Schalter für Ja/Nein-Felder, Auswahlkarten für Mehrfachauswahl und
   eine abgesetzte Aktionsleiste. */
.form-modern { max-width: 46rem; }
.form-fields { display: flex; flex-direction: column; gap: 1.35rem; }
.form-field { min-width: 0; }
.form-field[hidden] { display: none; }
.form-modern label { margin: 0 0 0.45rem; display: flex; align-items: center; gap: 0.1rem; }
.form-modern .field-help { margin-left: 0.3rem; }
.required-mark { color: var(--color-red); margin-left: 0.15rem; font-weight: 600; }
.field-error {
    display: flex; align-items: center; gap: 0.35rem; margin: 0.4rem 0 0;
    color: var(--color-red); font-size: 0.82rem; font-weight: 500;
}
.field-error .icon { width: 14px; height: 14px; margin: 0; flex-shrink: 0; }
.form-field.has-error input, .form-field.has-error select, .form-field.has-error textarea { border-color: var(--color-red); }
.form-field.has-error input:focus, .form-field.has-error select:focus, .form-field.has-error textarea:focus { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12); }

/* Eigene Checkbox-Optik (rund, Akzentfarbe, Haken) */
.form-modern input[type="checkbox"], .choice-card input[type="checkbox"] {
    appearance: none; -webkit-appearance: none; flex-shrink: 0;
    width: 1.15rem; height: 1.15rem; margin: 0; border: 1.5px solid var(--color-border-strong); border-radius: 5px;
    background: var(--color-surface) center / 0.8rem no-repeat; cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.form-modern input[type="checkbox"]:hover, .choice-card input[type="checkbox"]:hover { border-color: var(--color-accent); }
.form-modern input[type="checkbox"]:checked, .choice-card input[type="checkbox"]:checked {
    background-color: var(--color-accent); border-color: var(--color-accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}
.form-modern input[type="checkbox"]:focus-visible, .choice-card input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18); }

/* Ja/Nein-Feld als Schalter in einer Zeile mit dem Label */
.toggle-row {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.8rem 1rem;
    border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-bg);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.toggle-row:hover { border-color: var(--color-border-strong); }
.toggle-row:has(input:checked) { background: var(--color-accent-bg); border-color: #bfdbfe; }
.toggle-row label { margin: 0; cursor: pointer; }
.toggle-row .field-help { margin-left: -0.4rem; }
.form-modern .toggle-row input[type="checkbox"] {
    width: 2.6rem; height: 1.5rem; border-radius: 999px; border: none; background: var(--color-border-strong);
    background-image: none; position: relative;
}
.form-modern .toggle-row input[type="checkbox"]::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: calc(1.5rem - 6px); height: calc(1.5rem - 6px);
    border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25); transition: transform 0.18s ease;
}
.form-modern .toggle-row input[type="checkbox"]:checked { background: var(--color-accent); background-image: none; }
.form-modern .toggle-row input[type="checkbox"]:checked::after { transform: translateX(1.1rem); }

/* Mehrfachauswahl (CheckboxSelectMultiple) als Karte mit Zeilen */
.form-field--checkboxselectmultiple > div[id], .form-field--radioselect > div[id] {
    display: flex; flex-direction: column; border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-surface); overflow: hidden; max-height: 22rem; overflow-y: auto; box-shadow: var(--shadow-sm);
}
.form-field--checkboxselectmultiple > div[id] > div, .form-field--radioselect > div[id] > div { margin: 0; border-top: 1px solid var(--color-border); }
.form-field--checkboxselectmultiple > div[id] > div:first-child, .form-field--radioselect > div[id] > div:first-child { border-top: none; }
.form-field--checkboxselectmultiple > div[id] label, .form-field--radioselect > div[id] label {
    display: flex; align-items: center; gap: 0.7rem; margin: 0; padding: 0.65rem 0.9rem; min-height: 44px;
    box-sizing: border-box; font-weight: 500; color: var(--color-text); cursor: pointer; transition: background-color 0.12s ease;
}
.form-field--checkboxselectmultiple > div[id] label:hover, .form-field--radioselect > div[id] label:hover { background: var(--color-bg); }
.form-field--checkboxselectmultiple > div[id] label:has(input:checked) { background: var(--color-accent-bg); color: var(--color-accent-ink); }
/* Lange Häkchen-Listen (ab 7 Einträgen, per Skript): Suchfeld, Zähler,
   „Nur ausgewählte“, Ausgewählte oben, kompaktere Zeilen. */
.multi-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; margin: 0 0 0.4rem; }
.multi-tools input[type="search"] { flex: 1 1 14rem; margin: 0; min-height: 38px; padding: 0.35rem 0.7rem; }
.multi-tools .multi-count { font-size: 0.84rem; color: var(--color-muted); white-space: nowrap; }
.multi-tools label { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0; font-weight: 400; font-size: 0.84rem; white-space: nowrap; cursor: pointer; }
.multi-enhanced > div[id] { max-height: 15rem; }
.multi-enhanced > div[id] label { min-height: 40px; padding: 0.45rem 0.9rem; }
.multi-enhanced > div[id] > div[hidden] { display: none; }
.multi-enhanced .multi-empty { padding: 0.6rem 0.9rem; font-size: 0.86rem; color: var(--color-muted); }
.form-field--radioselect input[type="radio"] { margin: 0; width: 1.05rem; height: 1.05rem; }
.form-field--checkboxselectmultiple > div[id]:not(:has(input))::before {
    content: "Noch keine Einträge vorhanden."; padding: 0.75rem 0.9rem; color: var(--color-muted); font-size: 0.85rem;
}

/* Aktionsleiste unter dem Formular */
.form-actions {
    display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
    margin-top: 1.8rem; padding-top: 1.3rem; border-top: 1px solid var(--color-border);
}
.form-actions button, .form-actions .button { margin-top: 0; }
.form-actions button[type="submit"]:not(.secondary) { padding-left: 1.35rem; padding-right: 1.35rem; }

/* Auswahlkarten (z. B. Tagesordnung vorschlagen) */
.choice-group {
    border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 0; margin: 0 0 1.1rem;
    background: var(--color-surface); box-shadow: var(--shadow-sm); overflow: hidden; min-width: 0;
}
.choice-group-header {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    padding: 0.8rem 1rem; background: var(--color-bg); border-bottom: 1px solid var(--color-border);
}
.choice-group-header h2 { margin: 0; font-size: 0.95rem; display: flex; align-items: center; gap: 0.5rem; }
.choice-count {
    display: inline-flex; align-items: center; justify-content: center; min-width: 1.5rem; height: 1.5rem; padding: 0 0.45rem;
    border-radius: 999px; background: var(--color-accent-bg); color: var(--color-accent-ink); font-size: 0.75rem; font-weight: 700;
}
.choice-group-header button { margin: 0; min-height: 34px; padding: 0.25rem 0.8rem; font-size: 0.8rem; }
.form-modern .choice-card, .choice-card {
    display: flex; align-items: flex-start; gap: 0.8rem; margin: 0; padding: 0.85rem 1rem;
    border-top: 1px solid var(--color-border); cursor: pointer; font-weight: 500; color: var(--color-text);
    transition: background-color 0.12s ease;
}
.choice-card:first-of-type { border-top: none; }
.choice-card:hover { background: var(--color-bg); }
.choice-card:has(input:checked) { background: #f8fbff; }
.choice-card input[type="checkbox"] { margin-top: 0.12rem; }
.choice-card-text { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.choice-card-text .meta { font-weight: 400; font-size: 0.82rem; color: var(--color-muted); }

button, .button {
    margin-top: 1.4rem; padding: 0.55rem 1.15rem; border: 1px solid var(--color-accent); border-radius: var(--radius-sm);
    background: var(--color-accent); color: #fff; font-weight: 600; cursor: pointer; font-size: 0.88rem;
    display: inline-flex; align-items: center; gap: 0.4rem; text-decoration: none; white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease;
    min-height: 44px; /* Mindest-Tippfläche für Touch-Bedienung (Apple/Google-Richtlinie) */
}
button:hover, .button:hover { background: var(--color-accent-ink); border-color: var(--color-accent-ink); }
/* Gesperrte Knöpfe sichtbar als gesperrt (sonst wirkt ein Klick „kaputt“). */
button:disabled, button:disabled:hover { opacity: 0.45; cursor: not-allowed; background: var(--color-accent); border-color: var(--color-accent); }
button.secondary:disabled, button.secondary:disabled:hover { background: var(--color-surface); border-color: var(--color-border); }
button.secondary, .button.secondary {
    background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong);
}
button.secondary:hover, .button.secondary:hover { background: var(--color-bg); border-color: var(--color-muted); }
.button .icon, button .icon { width: 15px; height: 15px; }
/* --- Moderne Buttons ------------------------------------------------
   Gilt für die Standard-Varianten: primär (blau, ohne Klasse bzw.
   class="button") und sekundär (weiß, .secondary). Spezial-Buttons
   mit eigener Klasse (Menüs, Icon-Knöpfe, Listen-Hauptaktion …)
   bleiben unberührt. Icons etwas kräftiger, damit sie zur
   halbfetten Schrift passen. */
button .icon, .button:not(.ghost) .icon { stroke-width: 2.25; }
button:not([class]), .button[class="button"], button.block-mobile:not(.secondary), .button.block-mobile:not(.secondary), button.review-open:not(.secondary) {
    border-radius: 10px; letter-spacing: 0.005em;
    border-color: #1f5bd8;
    background: linear-gradient(180deg, #4f8df7 0%, var(--color-accent) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 1px 2px rgba(15, 23, 42, 0.10), 0 4px 12px -2px rgba(37, 99, 235, 0.35);
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
}
button:not([class]):hover, .button[class="button"]:hover, button.block-mobile:not(.secondary):hover, .button.block-mobile:not(.secondary):hover, button.review-open:not(.secondary):hover {
    border-color: var(--color-accent-ink);
    background: linear-gradient(180deg, #3b82f6 0%, var(--color-accent-ink) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 2px 4px rgba(15, 23, 42, 0.10), 0 8px 20px -4px rgba(37, 99, 235, 0.45);
    transform: translateY(-1px);
}
button:not([class]):active, .button[class="button"]:active, button.block-mobile:not(.secondary):active, .button.block-mobile:not(.secondary):active, button.review-open:not(.secondary):active {
    transform: translateY(0); box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.22);
}
button:not([class]):disabled, .button[class="button"]:disabled {
    transform: none; box-shadow: none; background: var(--color-accent);
}
button.secondary, .button.secondary {
    border-radius: 10px;
    border-color: #dbe2ea; background: var(--color-surface); color: var(--color-text);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 0 rgba(15, 23, 42, 0.02);
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
}
button.secondary .icon, .button.secondary .icon { color: var(--color-muted); transition: color 0.15s ease; }
button.secondary:hover, .button.secondary:hover {
    border-color: var(--color-border-strong); background: #f8fafc;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.06), 0 6px 14px -4px rgba(15, 23, 42, 0.14);
    transform: translateY(-1px);
}
button.secondary:hover .icon, .button.secondary:hover .icon { color: var(--color-accent); }
button.secondary:active, .button.secondary:active { transform: translateY(0); box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.12); }
button.secondary:disabled, .button.secondary:disabled { transform: none; box-shadow: none; }
button:focus-visible, .button:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    button, .button { transition: none !important; transform: none !important; }
}

/* Zurückhaltende Verwaltungs-Links (z. B. "Kategorien verwalten") neben einer
   primären Aktion — bewusst kein voller Button, um nicht mit der Haupt-CTA
   zu konkurrieren. */
.button.ghost {
    margin-top: 0; padding: 0.4rem 0.65rem; border-color: transparent; min-height: 36px;
    background: transparent; color: var(--color-muted); font-weight: 500; font-size: 0.83rem;
}
.button.ghost:hover { background: var(--color-bg); color: var(--color-text); border-color: var(--color-border); }
.button.ghost .icon { width: 14px; height: 14px; }

.list-actions {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: 0.5rem 1rem; margin: 1.1rem 0 1rem;
}
.list-actions .button { margin-top: 0; }
/* Jahres-/Zeitraum-Navigation (Qualitätsziele, Auditplan): Pfeile und
   Jahreszahl auf einer Linie. */
.plan-nav .button { margin-top: 0; }
/* Hauptaktion einer Liste („Neue Anforderung", „Ereignis melden" …):
   Pillenform mit Verlauf, weichem Schatten und Plus-Icon im hellen
   Kreis. Nur ab Tablet-Breite — auf dem Smartphone übernimmt der
   schwebende Button (fab-mobile, siehe unten) mit eigener Gestaltung. */
@media (min-width: 601px) {
    .list-actions > .button:not(.ghost):not(.secondary) {
        padding: 0.4rem 1.1rem 0.4rem 0.45rem; min-height: 40px; gap: 0.55rem;
        border: none; border-radius: 999px; font-size: 0.87rem; letter-spacing: 0.01em;
        background: linear-gradient(135deg, #3b82f6 0%, var(--color-accent) 55%, var(--color-accent-ink) 100%);
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 4px 14px rgba(37, 99, 235, 0.25);
        transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    }
    .list-actions > .button:not(.ghost):not(.secondary) .icon {
        width: 14px; height: 14px; padding: 6px; box-sizing: content-box;
        border-radius: 50%; background: rgba(255, 255, 255, 0.2);
    }
    .list-actions > .button:not(.ghost):not(.secondary):hover {
        background: linear-gradient(135deg, #3b82f6 0%, var(--color-accent) 55%, var(--color-accent-ink) 100%);
        filter: brightness(1.06); transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(15, 23, 42, 0.08), 0 8px 22px rgba(37, 99, 235, 0.32);
    }
    .list-actions > .button:not(.ghost):not(.secondary):active { transform: none; filter: brightness(0.97); }
    .list-actions > .button:not(.ghost):not(.secondary):focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
}

/* Kebab-Menü für mehrere Aktionen in einer Tabellenzeile (z. B.
   Bearbeiten/Passwort zurücksetzen/Deaktivieren) — statt mehrerer
   nebeneinander/untereinander gestapelter Buttons, die eine Zeile
   unnötig breit oder hoch machen. Wiederverwendbares Muster,
   JS-Verhalten siehe Klick-Handler weiter unten im Dokument. */
.action-menu { position: relative; display: inline-block; }
.action-menu-toggle {
    margin: 0; padding: 0; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
    background: var(--color-surface); color: var(--color-muted); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; min-height: 40px; min-width: 40px;
}
.action-menu-toggle:hover { background: var(--color-bg); color: var(--color-text); }
.action-menu-panel {
    display: none; flex-direction: column; gap: 0.1rem; position: absolute; top: 100%; right: 0;
    margin-top: 0.3rem; z-index: 20; background: var(--color-surface); border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-md); min-width: 13rem; padding: 0.3rem;
}
.action-menu.open .action-menu-panel { display: flex; }
/* Bei Zeilen nahe dem unteren Bildschirmrand (z. B. letzte
   Tabellenzeile) reicht der Platz nach unten oft nicht — JS setzt
   dann .opens-up, das Menü klappt stattdessen nach oben auf, statt
   über den sichtbaren Bereich hinaus abgeschnitten zu werden. */
.action-menu.opens-up .action-menu-panel { top: auto; bottom: 100%; margin-top: 0; margin-bottom: 0.3rem; }
.action-menu-panel a, .action-menu-panel button {
    display: flex; align-items: center; gap: 0.55rem; width: 100%; text-align: left; margin: 0;
    padding: 0.6rem 0.65rem; min-height: 40px; border: none; background: transparent; color: var(--color-text);
    font-size: 0.87rem; font-weight: 500; cursor: pointer; border-radius: var(--radius-sm); text-decoration: none;
}
.action-menu-panel a:hover, .action-menu-panel button:hover { background: var(--color-bg); }
.action-menu-panel .danger { color: var(--color-red); }
.list-actions-secondary { display: flex; flex-wrap: wrap; gap: 0.15rem; }
.action-menu-panel form { margin: 0; }

/* Panels mit Kopfzeile, optional einklappbar (<details class="panel
   collapsible-panel"><summary class="panel-header">…). Grundregeln für
   alle Seiten — Dashboard, Berichte usw. dürfen sie im eigenen Template
   verfeinern. Ohne diese Regeln zeigt der Browser den rohen Pfeil und
   die Überschrift in einer eigenen Zeile. */
.panel { border: 1px solid var(--color-border); border-radius: var(--radius-md); margin-bottom: 1.25rem; overflow: hidden; background: var(--color-surface); }
.panel-header { display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--color-border); background: var(--color-bg); }
.panel-header .icon { margin-right: 0; width: 18px; height: 18px; }
.panel-header h2 { margin: 0; font-size: 0.95rem; }
.panel-body { padding: 0.4rem 1rem 0.8rem; }
.collapsible-panel > summary { list-style: none; cursor: pointer; min-height: 44px; }
.collapsible-panel > summary::-webkit-details-marker { display: none; }
.collapsible-panel > summary::after {
    content: ""; margin-left: auto; width: 0.45rem; height: 0.45rem; flex-shrink: 0;
    border-right: 2px solid var(--color-muted); border-bottom: 2px solid var(--color-muted);
    transform: rotate(45deg); transition: transform 0.15s ease;
}
.collapsible-panel[open] > summary::after { transform: rotate(-135deg); }
.collapsible-panel:not([open]) > summary { border-bottom: none; }

/* Globale Suche in der Kopfzeile (specs/12-globale-suche.md). */
.global-search { position: relative; margin: 0 0.5rem 0 0; }
.global-search-field { display: flex; align-items: center; gap: 0.4rem; padding: 0 0.7rem; border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface); color: var(--color-muted); }
.global-search-field:focus-within { border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.global-search-field .icon { width: 15px; height: 15px; margin: 0; flex-shrink: 0; }
.global-search input { border: none; background: transparent; padding: 0.4rem 0; width: 15rem; min-height: 36px; box-shadow: none; margin: 0; font-size: 0.88rem; }
.global-search input:focus { outline: none; box-shadow: none; }
.global-search-preview {
    position: absolute; top: calc(100% + 0.35rem); right: 0; width: 26rem; max-height: 70vh; overflow-y: auto; z-index: 60;
    background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 0.4rem;
}
.global-search-icon { display: none; }
.search-group h3 { display: flex; align-items: center; gap: 0.4rem; margin: 0.5rem 0.4rem 0.2rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-muted); }
.search-group h3 .icon { width: 13px; height: 13px; margin: 0; }
.search-group ul { list-style: none; margin: 0; padding: 0; }
.search-group li a { display: flex; flex-direction: column; padding: 0.45rem 0.55rem; border-radius: var(--radius-sm); text-decoration: none; color: var(--color-text); }
.search-group li a:hover, .search-group li a:focus { background: var(--color-bg); outline: none; }
.search-hit-title { font-weight: 600; font-size: 0.9rem; }
.search-hit-sub { font-size: 0.78rem; color: var(--color-muted); }
.search-more { display: block; padding: 0.3rem 0.55rem 0.5rem; font-size: 0.82rem; }
.search-empty { color: var(--color-muted); font-size: 0.88rem; margin: 0.5rem; }
.search-page-form .search-field { max-width: 40rem; }
.search-results-page { max-width: 46rem; margin-top: 0.8rem; }
.search-results-page .search-group { margin-bottom: 0.8rem; }
/* Nebenaktionen: am Desktop als Buttons, auf dem Smartphone ab zwei
   Stück gesammelt im ⋮-Menü (per Skript erzeugt, siehe unten
   „Nebenaktionen ins ⋮-Menü“): .desktop-only / .mobile-only. */
.mobile-only { display: none !important; }

/* Umschalter zwischen zwei Ansichten einer Liste (z. B. Meine/Alle
   Aufgaben) — echte Links (?ansicht=…), damit Zurück-Button und
   Lesezeichen funktionieren. */
.segmented {
    display: inline-flex; gap: 0.2rem; padding: 0.2rem; margin: 0 0 1.1rem;
    background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-md);
}
.segmented a {
    display: inline-flex; align-items: center; gap: 0.45rem; min-height: 40px; padding: 0.4rem 1.1rem;
    border-radius: var(--radius-sm); color: var(--color-muted); font-weight: 600; font-size: 0.88rem; text-decoration: none;
}
.segmented a:hover { color: var(--color-text); }
.segmented a .icon { width: 15px; height: 15px; margin: 0; }
.settings-tabs-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.settings-tabs-row .segmented { margin: 0; }
.segmented a.active { background: var(--color-surface); color: var(--color-ink); box-shadow: var(--shadow-sm); }
.segmented-count {
    min-width: 1.4rem; padding: 0 0.4rem; border-radius: 999px; background: var(--color-border);
    font-size: 0.74rem; text-align: center; color: var(--color-text);
}
.segmented a.active .segmented-count { background: var(--color-accent-bg); color: var(--color-accent-ink); }
.segmented .label-short { display: none; }
/* Viele Reiter (Maßnahmen, Beschwerden, Ereignisse): seitlich wischbar statt umbrechen. */
.segmented-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented-scroll::-webkit-scrollbar { display: none; }
.segmented-scroll a { white-space: nowrap; flex: 0 0 auto; }
@media (max-width: 600px) {
    .segmented { display: flex; }
    .segmented a { flex: 1; justify-content: center; white-space: nowrap; padding: 0.4rem 0.6rem; }
    .segmented-scroll a { flex: 0 0 auto; }
    /* Lange Beschriftungen (z. B. „Wirksamkeitskontrolle offen“) auf
       dem Smartphone kurz, damit der Schalter einzeilig bleibt. */
    .segmented .label-short { display: inline; }
    .segmented .label-long { display: none; }
    /* Reiter der Einstellungen volle Breite, „Änderungen ansehen“ darunter. */
    .settings-tabs-row .segmented { flex: 1 1 100%; }
    .global-search { display: none; }
    .global-search-icon { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; color: inherit; }
    .global-search-icon .icon { width: 20px; height: 20px; margin: 0; }
}

/* Aktionszeile auf Detailseiten (z. B. E-Learning-Modul: Lern-Inhalt,
   Quiz starten + Drei-Punkte-Menü für Verwalten/Exportieren). Auf dem
   Smartphone teilen sich die Buttons die Zeile gleichmäßig, das Menü
   bleibt quadratisch rechts daneben. */
/* Seitentitel mit Drei-Punkte-Menü rechts oben (z. B. E-Learning-Modul:
   Verwalten/Exportieren) — seltene Verwaltungsaktionen aus dem Weg der
   eigentlichen Aktionen, aber immer an derselben Stelle auffindbar. */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.page-header h1 { min-width: 0; overflow-wrap: anywhere; }
.page-header > .action-menu { flex-shrink: 0; }
.page-header > .action-menu .action-menu-toggle { min-height: 44px; min-width: 44px; }

.detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 1.4rem 0 1rem; }
.detail-actions > .button, .detail-actions > button, .detail-actions > form > button { margin-top: 0; }
/* Je nach Status kann die Zeile leer sein (z. B. abgeschlossenes Audit). */
.detail-actions:not(:has(> .button, > button, > form > button)) { display: none; }
.detail-actions > .action-menu .action-menu-toggle { min-height: 44px; min-width: 44px; }
@media (max-width: 600px) {
    /* Gleich breit nebeneinander; ab drei Buttons zwei pro Zeile. */
    .detail-actions > .button, .detail-actions > button { flex: 1 1 10rem; justify-content: center; }
    /* Zeilen nur mit Nebenaktionen (z. B. „Prüfung/Wartung planen“,
       „Weitere Funktion“, „Fahrer/innen eintragen“): kompakte Chips
       statt bildschirmbreiter Kacheln. Hauptaktionen bleiben breit. */
    .detail-actions:not(:has(> .button:not(.secondary):not(.ghost), > button:not(.secondary):not(.ghost))) { gap: 0.5rem; }
    .detail-actions:not(:has(> .button:not(.secondary):not(.ghost), > button:not(.secondary):not(.ghost))) > .button,
    .detail-actions:not(:has(> .button:not(.secondary):not(.ghost), > button:not(.secondary):not(.ghost))) > button {
        flex: 0 0 auto; min-height: 40px; padding: 0.4rem 0.95rem; border-radius: 999px; font-size: 0.86rem;
    }
}

/* Leichtgewichtiges Bestätigungs-Dialogfenster über das native
   <dialog>-Element — kein JS-Framework nötig, für Aktionen, die
   vor dem Absenden noch einen Lese-/Denkschritt verdienen (z. B.
   Kenntnisnahme erst nach Ansicht des Dokuments bestätigen). */
dialog.confirm-dialog {
    border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
    padding: 1.25rem 1.4rem; max-width: 26rem; width: 90vw; box-shadow: 0 12px 32px rgba(0,0,0,0.18);
    /* white-space:normal explizit erzwingen: Ein <dialog> steht im DOM oft
       innerhalb einer Tabellenzelle (Aktion je Zeile) und erbt sonst deren
       white-space:nowrap — unabhängig davon, dass der Dialog optisch im
       Top-Layer über der ganzen Seite schwebt (CSS-Vererbung folgt dem
       DOM-Baum, nicht der Darstellung). Sonst wird längerer Bestätigungstext
       rechts abgeschnitten statt umzubrechen. */
    white-space: normal;
}
dialog.confirm-dialog::backdrop { background: rgba(15,23,42,0.45); }
/* Rückfrage für data-confirm (static/js/ui-actions.js) statt window.confirm. */
dialog.ask-dialog { max-width: 28rem; padding: 1.3rem 1.4rem 1.1rem; border-radius: 1rem; background: var(--color-surface); color: var(--color-text); }
dialog.ask-dialog[open] { animation: review-pop 0.18s ease-out; }
.ask-dialog-head { display: flex; align-items: center; gap: 0.8rem; }
.ask-dialog-head h3 { margin: 0; font-size: 1.05rem; line-height: 1.35; overflow-wrap: anywhere; }
.ask-dialog-icon { flex-shrink: 0; width: 2.6rem; height: 2.6rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--color-accent-bg); color: var(--color-accent); }
.ask-dialog-icon .icon { width: 21px; height: 21px; margin: 0; }
dialog.ask-dialog.is-danger .ask-dialog-icon { background: var(--color-red-bg); color: var(--color-red); }
.ask-dialog-text { margin: 0.75rem 0 0 3.4rem; font-size: 0.9rem; color: var(--color-muted); line-height: 1.5; }
dialog.ask-dialog .dialog-actions { margin-top: 1.2rem; }
dialog.ask-dialog .dialog-actions button.danger { background: var(--color-red); border-color: var(--color-red); color: #fff; }
dialog.ask-dialog .dialog-actions button.danger:hover { filter: brightness(0.92); }
@media (max-width: 600px) {
    .ask-dialog-text { margin-left: 0; }
    dialog.ask-dialog .dialog-actions { flex-direction: column-reverse; }
    dialog.ask-dialog .dialog-actions button { width: 100%; justify-content: center; }
}
/* Dialog „Rückmeldung geben“ (Kontomenü). */
dialog.feedback-dialog { max-width: 30rem; }
.feedback-intro { margin: 0 0 0.8rem; font-size: 0.88rem; color: var(--color-muted); }
.feedback-privacy { display: flex; gap: 0.4rem; align-items: center; margin: 0 0 0.4rem; padding: 0.45rem 0.7rem; border-radius: var(--radius-sm); background: var(--color-amber-bg); color: var(--color-amber); font-size: 0.84rem; }
.feedback-privacy .icon { margin: 0; flex-shrink: 0; width: 15px; height: 15px; }
.feedback-contact { display: flex; align-items: flex-start; gap: 0.2rem; margin-top: 0.7rem; font-weight: 400; font-size: 0.88rem; }
dialog.confirm-dialog h3 { margin: 0 0 0.6rem; }
dialog.confirm-dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }
dialog.confirm-dialog .dialog-actions button, dialog.confirm-dialog .dialog-actions .button { margin-top: 0; }
dialog.confirm-dialog fieldset.change-type { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 0.4rem 0.8rem 0.7rem; margin: 0.8rem 0 0; }
/* Dialog „Überprüfung vermerken?“ */
dialog.review-dialog { max-width: 30rem; padding: 1.3rem 1.4rem 1.2rem; border-radius: 1rem; }
dialog.review-dialog[open] { animation: review-pop 0.18s ease-out; }
@keyframes review-pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.review-dialog-head { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.8rem; }
.review-dialog-head h3 { margin: 0; font-size: 1.1rem; }
.review-dialog-sub { margin: 0.1rem 0 0; font-size: 0.85rem; color: var(--color-muted); }
.review-dialog-icon { flex-shrink: 0; width: 2.8rem; height: 2.8rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--color-green-bg); color: var(--color-green); }
.review-dialog-icon.warn { background: var(--color-amber-bg); color: var(--color-amber); }
.review-dialog-icon .icon { width: 22px; height: 22px; margin: 0; }
.review-note { margin: 0 0 0.8rem; padding: 0.55rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.88rem; display: flex; gap: 0.4rem; align-items: center; }
.review-note.warn { background: var(--color-amber-bg); color: var(--color-amber); }
.review-note.danger { background: var(--color-red-bg); color: var(--color-red); }
.review-note.ok { background: var(--color-green-bg); color: var(--color-green); }
.review-note .icon { margin: 0; flex-shrink: 0; }
.review-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin: 0 0 0.9rem; }
.review-summary div { background: var(--color-bg); border-radius: var(--radius-sm); padding: 0.5rem 0.6rem; }
.review-summary div.next { background: var(--color-accent-bg); }
.review-summary dt { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-muted); }
.review-summary dd { margin: 0.15rem 0 0; font-weight: 600; font-size: 0.9rem; }
.review-summary div.next dd { color: var(--color-accent-ink); }
.review-gaps { border: 1px solid var(--color-border); border-left: 4px solid var(--color-amber); border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; font-size: 0.86rem; }
.review-gaps ul { margin: 0.35rem 0 0.35rem; padding-left: 1.1rem; }
.review-gaps li span { display: block; font-size: 0.78rem; color: var(--color-muted); }
.review-gaps small { color: var(--color-muted); }
dialog.review-dialog .dialog-actions { margin-top: 1.1rem; }
@media (max-width: 600px) {
    .review-summary { grid-template-columns: 1fr; }
    dialog.review-dialog .dialog-actions { flex-direction: column-reverse; }
    dialog.review-dialog .dialog-actions button { width: 100%; justify-content: center; }
}
.review-extra { font-size: 0.85rem; color: var(--color-muted); margin: 0 0 0.8rem; }
.detail-actions > .review-open, section > .review-open { margin-top: 0; }
dialog.confirm-dialog fieldset.change-type legend { font-weight: 600; font-size: 0.87rem; padding: 0 0.3rem; }
dialog.confirm-dialog fieldset.change-type label { display: flex; align-items: flex-start; gap: 0.2rem; font-weight: 400; margin: 0.5rem 0 0; }
dialog.confirm-dialog fieldset.change-type input { margin-top: 0.2rem; }

.search-box { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem; margin: 0 0 1.25rem; }
.search-field {
    display: flex; align-items: center; gap: 0.5rem; flex: 1; min-width: 12rem; max-width: 24rem;
    background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: 999px;
    padding: 0 0.4rem 0 0.85rem; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-field:focus-within { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-bg); }
.search-field .icon { width: 15px; height: 15px; color: var(--color-muted); flex-shrink: 0; margin-right: 0; }
.search-field input[type="search"] {
    flex: 1; border: none; padding: 0.5rem 0; margin: 0; background: transparent; min-width: 0;
}
.search-field input[type="search"]:focus { outline: none; box-shadow: none; }
.search-field input[type="search"]::-webkit-search-cancel-button { display: none; }
.search-clear {
    display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem;
    border-radius: 50%; color: var(--color-muted); flex-shrink: 0;
}
.search-clear:hover { background: var(--color-bg); color: var(--color-text); }
.search-clear .icon { width: 13px; height: 13px; margin-right: 0; }
.search-box button[type="submit"] { margin-top: 0; }

/* Kombinierte Such-/Filterleiste für Listenseiten mit mehreren
   Filtern (Suche + Dropdowns + optional Checkbox) — eine Card statt
   loser, unverbundener Formularelemente nebeneinander. */
/* Zuklappbarer Rahmen um die Filterleiste — standardmäßig zu, damit
   die Liste selbst oben steht; bei aktiven Filtern offen (siehe
   Templates), damit sichtbar bleibt, was gerade filtert. */
.filter-panel { margin: 0 0 1.25rem; }
.filter-panel > summary, .filter-toggle {
    list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.45rem;
    padding: 0.42rem 0.95rem; min-height: 38px; border: 1px solid var(--color-border-strong); border-radius: 999px;
    background: var(--color-surface); color: var(--color-text); font-weight: 600; font-size: 0.86rem;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.filter-panel > summary::-webkit-details-marker { display: none; }
.filter-panel > summary:hover, .filter-toggle:hover { background: var(--color-bg); border-color: var(--color-muted); }
.filter-panel > summary .icon, .filter-toggle .icon { width: 15px; height: 15px; color: var(--color-muted); margin: 0; }
.filter-toggle { margin: 0; box-shadow: none; }
.filter-panel > summary::after, .filter-toggle::after {
    content: ""; width: 0; height: 0; margin-left: 0.15rem;
    border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid var(--color-muted);
    transition: transform 0.15s ease;
}
.filter-panel[open] > summary::after, .filter-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }
.filter-panel .filter-active, .filter-toggle .filter-active {
    padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700;
    background: var(--color-accent-bg); color: var(--color-accent-ink);
}
.filter-panel > .filter-bar { margin: 0.65rem 0 0; }
.filter-bar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.85rem;
    background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-md);
    padding: 1rem 1.1rem; margin: 0 0 1.25rem;
}
.filter-bar .field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 11rem; }
.filter-bar .field label {
    margin: 0; font-size: 0.72rem; color: var(--color-muted); text-transform: uppercase;
    letter-spacing: 0.05em; font-weight: 700;
}
.filter-bar .field select {
    padding: 0.5rem 0.7rem; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
    background: var(--color-surface); font-size: 0.88rem; color: var(--color-text);
}
.filter-bar .field-search { flex: 1; min-width: 14rem; max-width: 22rem; }
.filter-bar .field-search .search-field { max-width: none; }
.checkbox-field { display: flex; align-items: center; gap: 0.45rem; }
.checkbox-field input[type="checkbox"] { margin: 0; }
.checkbox-field label { margin: 0; font-weight: 400; }
.filter-bar .checkbox-field { display: flex; align-items: center; gap: 0.45rem; padding-bottom: 0.5rem; }
.filter-bar .checkbox-field input[type="checkbox"] { margin: 0; }
.filter-bar .checkbox-field label { margin: 0; font-weight: 400; font-size: 0.88rem; color: var(--color-text); }
.filter-bar button[type="submit"], .filter-bar .button { margin-top: 0; }
.filter-bar .field input[type="date"] {
    padding: 0.45rem 0.6rem; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
    background: var(--color-surface); font-size: 0.88rem; color: var(--color-text);
}
.filter-bar .field[hidden] { display: none; }
.filter-bar .field.period-custom { min-width: 9rem; }
.filter-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
/* Suche und „Filter“ in einer Zeile; der geöffnete Filter darunter in voller Breite. */
.list-tools { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 0.75rem; margin: 0 0 1.25rem; }
.list-tools .search-box { margin: 0; flex: 1 1 22rem; }
.list-tools .filter-toggle { margin-left: auto; align-self: center; }
.list-tools .list-filter { flex: 1 1 100%; margin-top: 0.6rem; }
.list-tools .list-filter[hidden] { display: none; }

/* Feld-Hinweis (i)-Icon mit Klick-Tooltip, siehe apps.workflow.templatetags.icons.field_help */
.field-help { display: inline-block; position: relative; margin-left: 0.35rem; vertical-align: middle; }
.field-help summary { list-style: none; cursor: pointer; display: inline-flex; }
.field-help summary::-webkit-details-marker { display: none; }
.field-help .icon { width: 15px; height: 15px; margin-right: 0; color: var(--color-muted); }
.field-help[open] summary .icon { color: var(--color-accent); }
.field-help-content {
    position: absolute; top: 135%; left: 0; z-index: 30;
    background: var(--color-ink); color: #fff; padding: 0.55rem 0.75rem; border-radius: var(--radius-sm);
    font-size: 0.8rem; font-weight: 400; line-height: 1.4; width: max-content; max-width: 240px; box-shadow: var(--shadow-md);
}

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; margin-top: 0.5rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
/* Zellinhalt nicht umbrechen lassen — sonst quetscht der Browser die
   Tabelle auf Container-Breite zusammen (Text wird zu 2-3 Zeilen
   gestaucht), statt sie natürlich breiter werden zu lassen und den
   bereitstehenden overflow-x:auto-Scroll (.table-wrap) zu nutzen.
   Bei Bedarf gezielt mit style="white-space:normal" pro Zelle
   aufheben (z. B. für lange Freitext-Spalten). */
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--color-border); vertical-align: top; white-space: nowrap; }
th { font-size: 0.72rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
tbody tr:hover td { background: var(--color-bg); }
/* Zeilen-Link (class="row-link"): dezent statt blau-unterstrichen; die
   ganze Zeile ist klickbar (per Skript, siehe Zeilen-Link unten), Hover
   hebt den Titel hervor. Weitere Links/Buttons bleiben eigenständig. */
a.row-link { color: var(--color-accent-ink); font-weight: 600; text-decoration: none; transition: color 0.15s ease; }
/* Link auf eine Datei (Dokumentversion, Nachweis-Anhang): Datei-Icon
   statt blau-unterstrichenem Text, unterstrichen erst beim Hover. */
a.file-link { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--color-accent-ink); font-weight: 600; text-decoration: none; }
a.file-link .icon { width: 15px; height: 15px; flex-shrink: 0; }
a.file-link:hover, a.file-link:focus-visible { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
/* Chevron am Zeilenende als Klick-Hinweis (nur Desktop-Tabelle). */
@media (min-width: 601px) {
    table tbody tr:has(a.row-link) > td:last-child {
        padding-right: 2.2rem;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E");
        background-repeat: no-repeat; background-size: 16px 16px; background-position: right 0.8rem center;
        transition: background-position 0.15s ease;
    }
    table tbody tr:has(a.row-link):hover > td:last-child {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d4ed8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E");
        background-position: right 0.55rem center;
    }
}
/* Aktionsmenü (⋮) in breiten Tabellen am rechten Rand festhalten, damit
   es ohne seitliches Scrollen sichtbar bleibt. Offenes Menü über die
   festgehaltenen Zellen der folgenden Zeilen legen. */
@media (min-width: 601px) {
    .table-wrap td.cell-menu { position: sticky; right: 0; background-color: var(--color-surface); box-shadow: -8px 0 8px -8px rgba(15, 23, 42, 0.18); }
    .table-wrap tbody tr:hover td.cell-menu { background-color: var(--color-bg); }
    .table-wrap td.cell-menu:has(.action-menu.open) { z-index: 5; }
}
/* Bewusst KEIN Stretched Link (a::after mit position:absolute): WebKit
   (iOS/iPad, PWA) macht ein <tr> mit position:relative nicht
   zuverlässig zum Bezugsrahmen — dann liegen die Klickflächen aller
   Zeilen übereinander und jeder Tipp öffnet den letzten Eintrag. */
table tbody tr:has(a.row-link) { cursor: pointer; }
tbody tr:hover a.row-link, a.row-link:focus-visible { color: var(--color-accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.empty { color: var(--color-muted); }
/* „Mehr anzeigen“ unter Tabellen mit data-page-size (siehe Skript unten).
   [hidden] explizit, weil die Karten-Ansicht tr auf display:flex setzt. */
table tr[hidden] { display: none !important; }
button.show-more { display: flex; margin: 0.75rem auto 0; justify-content: center; }
button.show-more[hidden] { display: none; }
@media (max-width: 600px) { button.show-more { width: 100%; } }
/* Fließtext-Tabellen (Hilfe, Leitfaden) brechen um, statt die Seite
   in die Breite zu ziehen — anders als die Daten-Listen oben. */
table.prose-table th, table.prose-table td { white-space: normal; }

/* Listen-Tabellen als Karten auf dem Smartphone — statt seitlich zu
   scrollen (wichtige Spalten wie Status/Frist/Aktion lägen sonst
   außerhalb des Bildschirms). Muster: <table class="responsive-table">,
   jede <td> mit data-label="Spaltenname"; die Zelle, die als
   Kartentitel dienen soll, bekommt class="cell-title" (ohne Label, fett,
   immer oben — auch wenn sie in der Desktop-Tabelle nicht die erste
   Spalte ist). Ein Link mit class="row-link" macht die ganze Karte
   antippbar (per Skript) — Buttons/Formulare/weitere Links bleiben
   eigenständig bedienbar. */
@media (max-width: 600px) {
    .table-wrap:has(> table.responsive-table) { overflow-x: visible; }
    table.responsive-table thead { display: none; }
    table.responsive-table, table.responsive-table tbody { display: block; width: 100%; }
    table.responsive-table tr {
        position: relative; display: flex; flex-direction: column;
        border: 1px solid var(--color-border); border-radius: var(--radius-md);
        padding: 0.7rem 0.85rem; margin-bottom: 0.75rem; background: var(--color-surface);
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 6px 18px rgba(15, 23, 42, 0.14);
        transition: box-shadow 0.15s ease, transform 0.15s ease;
    }
    /* Antippbare Karte: beim Drücken leicht "eingedrückt". */
    table.responsive-table tbody tr:has(a.row-link):active { box-shadow: var(--shadow-sm); transform: scale(0.99); }
    table.responsive-table tbody tr:hover td { background: transparent; }
    table.responsive-table td {
        display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem;
        padding: 0.2rem 0; border: none; white-space: normal; text-align: right;
    }
    table.responsive-table td[data-label]::before {
        content: attr(data-label); flex-shrink: 0; text-align: left;
        font-size: 0.72rem; color: var(--color-muted); text-transform: uppercase;
        letter-spacing: 0.05em; font-weight: 700;
    }
    table.responsive-table td.cell-title {
        order: -1; display: block; text-align: left; font-weight: 600; font-size: 0.95rem;
        color: var(--color-ink); padding-bottom: 0.35rem;
    }
    table.responsive-table td.cell-title a { color: var(--color-ink); text-decoration: none; }
    table.responsive-table td.cell-title .empty { font-weight: 400; font-size: 0.82rem; }
    /* Mit Typ-Symbol: Titeltext bündig neben dem Symbol, auch beim Umbruch. */
    table.responsive-table td.cell-title:has(> .type-icon) { display: flex; align-items: flex-start; justify-content: flex-start; gap: 0; }
    table.responsive-table td.cell-title > .type-icon { vertical-align: 0; margin-top: -0.15rem; }
    table.responsive-table tr:has(a.row-link):active { background: var(--color-bg); }
    table.responsive-table td.cell-action { display: block; text-align: left; padding-top: 0.55rem; }
    table.responsive-table td.cell-action .button, table.responsive-table td.cell-action button { width: 100%; justify-content: center; }
    table.responsive-table td.empty { display: block; text-align: left; }
    table.responsive-table td.cell-empty { display: none; }
    /* Längerer Wert (Freitext, Details) — Label über dem Wert,
       linksbündig, statt rechts in die Zeile gequetscht. */
    table.responsive-table td.cell-block { display: block; text-align: left; }
    table.responsive-table td.cell-block[data-label]::before { display: block; margin-bottom: 0.15rem; }
    /* Drei-Punkte-Menü einer Zeile (z. B. Benutzerkonten) in der
       rechten oberen Ecke der Karte. */
    table.responsive-table td.cell-menu { position: absolute; top: 0.45rem; right: 0.45rem; width: auto; padding: 0; }
    table.responsive-table tr:has(> td.cell-menu) > td.cell-title { padding-right: 3rem; }
    /* Fließtext-Tabellen (Hilfe, Leitfaden): alle Zellen Label über
       Wert, erste Spalte als Kartentitel (class="prose-table", Labels
       setzt das Skript am Seitenende aus dem Tabellenkopf). */
    table.prose-table td { display: block; text-align: left; }
    table.prose-table td[data-label]::before { display: block; margin-bottom: 0.15rem; }
    table.prose-table td:first-child { font-weight: 600; color: var(--color-ink); padding-bottom: 0.35rem; }
    table.prose-table td:first-child::before { display: none; }
    table.responsive-table td.cell-action + td.cell-action { padding-top: 0.4rem; }
    table.responsive-table tr:has(> td.empty:only-child) { border-style: dashed; }
}

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.18rem 0.6rem; border-radius: 999px; font-size: 0.76rem; font-weight: 700; }
/* Farbpunkt vor Status-Badges — Status auf einen Blick, auch in langen Listen. */
.badge[class*="status-"]::before { content: ""; width: 0.4rem; height: 0.4rem; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.status-OFFEN, .badge.status-ENTWURF, .badge.status-IN_PRUEFUNG { background: var(--color-amber-bg); color: var(--color-amber); }
.badge.status-IN_BEARBEITUNG { background: var(--color-accent-bg); color: var(--color-accent-ink); }
.badge.status-ERLEDIGT, .badge.status-ABGESCHLOSSEN, .badge.status-FREIGEGEBEN { background: var(--color-green-bg); color: var(--color-green); }
.badge.status-ARCHIVIERT, .badge.status-AUSGETRETEN { background: #f1f5f9; color: var(--color-muted); }
.badge.status-AKTIV { background: var(--color-green-bg); color: var(--color-green); }
.badge.status-overdue, .badge.prio-HOCH, .badge.prio-KRITISCH { background: var(--color-red-bg); color: var(--color-red); }
.badge.level-INFO { background: var(--color-accent-bg); color: var(--color-accent-ink); }
.badge.level-WARNUNG { background: var(--color-amber-bg); color: var(--color-amber); }
.badge.level-KRITISCH { background: var(--color-red-bg); color: var(--color-red); }

dl.detail {
    margin: 0.6rem 0 0; display: grid; grid-template-columns: max-content 1fr;
    gap: 0.65rem 1.75rem; align-items: baseline;
}
dl.detail dt { font-size: 0.78rem; color: var(--color-muted); font-weight: 600; white-space: nowrap; }
dl.detail dd { margin: 0; color: var(--color-text); }
@media (max-width: 600px) {
    dl.detail { grid-template-columns: 1fr; gap: 0.1rem 0; }
    dl.detail dt { margin-top: 0.8rem; }
    dl.detail dt:first-child { margin-top: 0; }
    h1.page-title { gap: 0.6rem; }
    .title-icon { width: 2.2rem; height: 2.2rem; border-radius: 0.65rem; }
    .title-icon .icon { width: 18px; height: 18px; }
    /* Opt-in für kurze Kopfdaten (z. B. E-Learning-Modul: Status,
       Bestehensgrenze) — bleibt auch auf dem Smartphone zweispaltig
       statt jedes Feld auf zwei Zeilen zu verteilen. */
    dl.detail.detail-compact { grid-template-columns: max-content 1fr; gap: 0.55rem 1rem; }
    dl.detail.detail-compact dt { margin-top: 0; white-space: normal; max-width: 8.5rem; }
    /* Lange Freitexte (Beschreibung, Notizen …) innerhalb einer
       kompakten Liste: Label über Wert in voller Breite statt in die
       schmale rechte Spalte gequetscht. */
    dl.detail.detail-compact .detail-full { grid-column: 1 / -1; max-width: none; }
    dl.detail.detail-compact dt.detail-full { margin-top: 0.4rem; }
    dl.detail.detail-compact dd.detail-full { margin-top: -0.35rem; }

    /* iOS Safari zoomt automatisch in die Seite hinein, wenn ein
       fokussiertes Formularfeld weniger als 16px Schriftgröße hat —
       hier gezielt nur auf schmalen Bildschirmen angehoben, damit
       die kompaktere Desktop-Schrift unangetastet bleibt. */
    input[type="text"], input[type="password"], input[type="date"],
    input[type="number"], input[type="email"], input[type="search"], select, textarea {
        font-size: 16px;
    }

    /* Smartphone: Sidebar komplett ausgeblendet, stattdessen Hamburger-
       Topbar. Öffnet sich die Sidebar, zeigt sie (mehr Platz als die
       Tablet-Icon-Leiste) wieder Icons + Beschriftung — überschreibt
       dafür gezielt die 860px-Icon-only-Regeln oben. */
    .mobile-topbar { display: flex; }
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; width: 250px;
        transform: translateX(-100%); transition: transform 0.2s ease; z-index: 60;
        box-shadow: var(--shadow-md);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar-collapse-toggle { display: none; }
    .sidebar-head { flex-direction: row; }
    .sidebar-head .sidebar-brand { justify-content: flex-start; padding: 0.4rem 0.6rem; }
    .sidebar-brand span, .nav-link span, .nav-group-label { display: inline; }
    .nav-group-toggle { display: flex; }
    .nav-section.collapsed .nav-group { display: none; }
    .nav-section { border-top: none; padding-top: 0; margin-top: 0; }
    .sidebar-brand { justify-content: flex-start; padding: 0.4rem 0.6rem 1.1rem; }
    .nav-link { justify-content: flex-start; }
    .topbar { display: none; }
    .mobile-topbar { padding-top: 0.35rem; padding-bottom: 0.35rem; }
    .mobile-topbar .user-controls { margin-left: auto; gap: 0.1rem; }
    .mobile-topbar .bell-link { color: #cbd5e1; }
    .mobile-topbar .admin-menu .admin-menu-toggle { color: #cbd5e1; }
    .mobile-topbar .admin-menu .admin-menu-toggle:hover, .mobile-topbar .admin-menu.open .admin-menu-toggle { background: var(--color-sidebar-hover); color: #fff; }
    .mobile-topbar .admin-menu.is-current .admin-menu-toggle { background: var(--color-accent); color: #fff; }
    .mobile-topbar .bell-link:hover, .mobile-topbar .user-menu .user-menu-toggle:hover,
    .mobile-topbar .user-menu.open .user-menu-toggle { background: var(--color-sidebar-hover); color: #fff; }
    .mobile-topbar .bell-badge { box-shadow: 0 0 0 2px var(--color-sidebar-bg); }
    .mobile-topbar .user-menu-name, .mobile-topbar .user-menu .user-menu-toggle .icon { display: none; }
    .mobile-topbar .user-menu .user-menu-toggle { padding: 0.25rem; font-weight: 600; }
    .mobile-topbar .avatar { width: 32px; height: 32px; }
    .sidebar-backdrop.visible {
        display: block; position: fixed; inset: 0; background: rgba(15,23,42,0.45); z-index: 55;
    }
    /* Inhalt randlos statt als schwebende Karte — Rahmen und
       doppelter Außen-/Innenabstand kosten auf 360-400px Breite
       sonst rund 15 % der nutzbaren Fläche. */
    main { margin: 0; padding: 1.1rem 1rem 2rem; border: none; border-radius: 0; box-shadow: none; }
    h1 { font-size: 1.35rem; }
    .page-subtitle { margin-bottom: 1rem; }

    /* Hauptaktion ("Neue Maßnahme", "Ereignis melden" …) volle Breite —
       leichter zu treffen, ghost-Links bleiben kompakt daneben. */
    .list-actions > .button:not(.ghost) { flex: 1 1 100%; justify-content: center; }
    /* Nebenaktionen (z. B. „Schaden melden“, „Managementbewertung“,
       „Drucken / PDF“, „Funktionen verwalten“) als kompakte Chips:
       natürliche Breite, Beschriftung einzeilig; reicht der Platz
       nicht, rutschen weitere Chips in die nächste Zeile — alle
       bleiben sichtbar, nichts muss erwischt werden. */
    .list-actions-secondary { flex: 1 1 100%; flex-wrap: wrap; gap: 0.5rem; }
    .list-actions-secondary > form { flex: 0 0 auto; display: flex !important; margin: 0; }
    .list-actions-secondary > .desktop-only, .desktop-only { display: none !important; }
    .list-actions-secondary > .mobile-only, .mobile-only { display: inline-block !important; }
    /* ⋮ rechts am Rand der Chip-Zeile, im Chip-Stil. */
    .list-actions-secondary > .action-menu { margin-left: auto; }
    .list-actions-secondary > .action-menu .action-menu-toggle { min-height: 40px; min-width: 40px; border-radius: 999px; border-color: var(--color-border); }
    .list-actions-secondary > .button, .list-actions-secondary > form > .button {
        flex: 0 0 auto; white-space: nowrap; min-height: 40px; padding: 0.4rem 0.95rem; border-radius: 999px;
        border-color: var(--color-border); background: var(--color-surface); color: var(--color-text); font-size: 0.86rem;
    }
    /* Mit Drei-Punkte-Menü daneben (z. B. E-Learning: Import/Export)
       teilen sich Hauptaktion und Menü eine Zeile. */
    .list-actions > .button:not(.ghost):has(+ .action-menu) { flex: 1 1 0; }
    .list-actions > .action-menu .action-menu-toggle { min-height: 44px; min-width: 44px; }

    /* Hauptaktion einer Liste ("Neue Maßnahme", "Ereignis melden" …) als
       schwebender Button unten rechts — beim Scrollen durch lange
       Listen jederzeit mit dem Daumen erreichbar, statt oben Platz zu
       belegen. Opt-in per class="button fab-mobile". Liegt unter
       Sidebar/Backdrop (z-index 55/60), damit das geöffnete Menü ihn
       verdeckt. */
    .list-actions > .button.fab-mobile {
        position: fixed; right: 1rem; bottom: max(1rem, env(safe-area-inset-bottom));
        z-index: 30; flex: none; margin: 0; padding: 0.85rem 1.25rem; border-radius: 999px;
        font-size: 0.92rem; box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35), 0 2px 6px rgba(15, 23, 42, 0.15);
    }
    .list-actions > .button.fab-mobile .icon { width: 18px; height: 18px; }
    .list-actions:has(> .fab-mobile:only-child) { margin: 0; }
    .list-actions:has(> .fab-mobile) > .action-menu { margin-left: auto; }
    main:has(.fab-mobile) { padding-bottom: 6rem; }
    .search-field { max-width: none; flex: 1 1 100%; }
    /* Die Bildschirmtastatur hat bei type="search" eine eigene
       Suchen-Taste — der zusätzliche Button kostet nur Platz. */
    .search-box button[type="submit"] { display: none; }
    /* Einzelner Formular-Button (z. B. "Abschließen" unter der
       Abschlussnotiz) in voller Breite — opt-in per class="block-mobile". */
    button.block-mobile, .button.block-mobile { width: 100%; justify-content: center; }
    .filter-bar .field, .filter-bar .field-search { min-width: 0; max-width: none; flex: 1 1 100%; }
}

.back-link { display: inline-flex; align-items: center; gap: 0.3rem; margin-bottom: 1.1rem; font-size: 0.85rem; color: var(--color-muted); text-decoration: none; }
.back-link:hover { color: var(--color-accent); }
.back-link .icon { width: 14px; height: 14px; }

img.qr { display: block; margin: 1rem auto; }

/* ---------- Druckansicht (z. B. Prüfungsvorbereitung, Jahresbericht "Als PDF speichern") ---------- */
@media print {
    .sidebar, .back-link, .messages, .no-print, .comments-attachments { display: none !important; }
    .main-area { display: block !important; }
    html, body { background: #fff !important; }
    main { margin: 0 !important; padding: 0 !important; max-width: 100% !important; border: none !important; box-shadow: none !important; }
    /* Bedienknöpfe (Anlegen, Drucken …) gehören nicht aufs Papier. */
    .list-actions { display: none !important; }
    /* Tabellen nicht abschneiden: kein Scroll-Container im Druck. */
    .table-wrap { overflow: visible !important; border: none !important; }
    /* Schlichte Links schwarz; farbige Status-Links (z. B. a.mx) behalten ihre Farbe. */
    main a:not([class]), main a.row-link { color: inherit !important; text-decoration: none !important; }
}

/* ---------- Kommentare & Anhänge (siehe _comments_attachments.html) ---------- */
.comments-attachments { margin-top: 2.25rem; padding-top: 1.25rem; border-top: 1px solid var(--color-border); }
.comments-attachments h2 { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 1.05rem; }
/* Anzahl im Kopf der zugeklappten Bereiche (Kommentare, Anhänge, Wiedervorlagen). */
.comments-attachments .section-count {
    display: inline-flex; align-items: center; justify-content: center; min-width: 1.45rem; height: 1.45rem; padding: 0 0.4rem;
    border-radius: 999px; background: var(--color-accent-bg); color: var(--color-accent); font-size: 0.78rem; font-weight: 700;
}
.comment-list, .attachment-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; }
.comment-list li, .attachment-list li {
    padding: 0.65rem 0.85rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); margin-bottom: 0.5rem;
}
.comment-list li p { margin: 0.3rem 0 0; }
.comment-meta .meta, .attachment-list .meta { font-size: 0.78rem; color: var(--color-muted); }
.comment-list li:last-child, .attachment-list li:last-child { margin-bottom: 0; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* QR-Check-in-Hinweis auf Schulungs-/Besprechungsseiten (apps.workflow.checkin). */
.checkin-box { margin: 1rem 0 1.2rem; padding: 0.9rem 1.1rem; border-radius: var(--radius-md); background: var(--color-accent-bg); }
.checkin-box p { margin: 0 0 0.6rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.checkin-box .button, .checkin-box button { margin-top: 0; }
.checkin-option { display: flex; gap: 0.4rem; align-items: flex-start; font-weight: 400; font-size: 0.88rem; margin: 0 0 0.6rem; }
/* Antworten auf Kommentare (eine Ebene, wie ein Thread). */
.comment-replies { list-style: none; margin: 0.6rem 0 0 0.4rem; padding: 0 0 0 0.9rem; border-left: 2px solid var(--color-border); }
.comment-replies li { border: none; padding: 0.35rem 0; margin: 0; }
.comment-reply { margin-top: 0.35rem; }
.comment-reply summary::before, .older-comments summary::before { display: none !important; }
.comment-reply summary { flex-wrap: wrap; }
.comment-reply summary .meta { font-weight: 400; color: var(--color-muted); margin-left: 0.2rem; }
.comment-reply-form { margin-top: 0.5rem; }
/* Eigener Kommentar: Stift/Mülleimer oben rechts (_comment_own_actions.html) */
.comment-list li, .comment-replies li { position: relative; }
.comment-list li:has(> .comment-own-wrap) > .comment-meta { padding-right: 4.6rem; }
.comments-attachments .comment-tool {
    position: absolute; top: 0.45rem; right: 0.5rem; z-index: 1;
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; min-height: 30px; margin: 0; padding: 0;
    border: none; border-radius: var(--radius-sm); background: transparent; box-shadow: none;
    color: var(--color-muted); cursor: pointer; list-style: none;
}
.comment-tool::-webkit-details-marker { display: none; }
.comment-own summary.comment-tool::before { display: none !important; }
.comment-tool .icon { width: 16px; height: 16px; margin: 0; }
.comment-own-wrap.has-delete .comment-own summary.comment-tool { right: 2.4rem; }
.comments-attachments .comment-tool:hover, .comments-attachments .comment-tool:focus-visible, .comment-own[open] summary.comment-tool { background: var(--color-accent-bg); color: var(--color-accent); }
.comments-attachments button.comment-tool-delete:hover, .comments-attachments button.comment-tool-delete:focus-visible { background: var(--color-red-bg); color: var(--color-red); }
.comments-attachments form.comment-delete-form { margin: 0; }
.comment-replies .comment-tool { top: 0.15rem; }
/* Reaktionen auf Kommentare (_comment_reactions.html). Selektoren mit
   .comments-attachments form.comment-reactions, damit die allgemeinen
   Knopf-Regeln des Kommentarblocks (Polster, 44px auf Touch) nicht greifen.
   Die Auswahl hängt an der ganzen Leiste (links bündig), nicht am Knopf –
   sonst ragt sie auf dem Handy über den rechten Rand. */
.comments-attachments form.comment-reactions { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin: 0.35rem 0 0; }
.comments-attachments form.comment-reactions button {
    min-height: 28px; height: 28px; width: auto; margin: 0; padding: 0 0.5rem; gap: 0.25rem;
    font-size: 0.8rem; font-weight: 600; line-height: 1; border-radius: 999px; box-shadow: none;
    background: var(--color-surface); color: var(--color-text, inherit); border: 1px solid var(--color-border);
}
.comments-attachments form.comment-reactions button.mine { background: var(--color-accent-bg); border-color: var(--color-accent); color: var(--color-accent-ink); }
.reaction-picker { position: static; }
.reaction-picker summary { list-style: none; cursor: pointer; height: 28px; display: inline-flex; align-items: center; gap: 0.1rem; padding: 0 0.45rem; border-radius: 999px; border: 1px dashed var(--color-border); font-size: 0.8rem; line-height: 1; color: var(--color-muted); opacity: 0.8; }
.reaction-picker summary::-webkit-details-marker { display: none; }
.reaction-picker summary::before { display: none !important; }
.reaction-picker summary:hover, .reaction-picker[open] summary { opacity: 1; border-color: var(--color-accent); }
.reaction-choices { position: absolute; z-index: 20; left: 0; top: calc(100% + 4px); display: flex; gap: 0.15rem; padding: 0.25rem; max-width: 100%; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 999px; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12); }
.comments-attachments form.comment-reactions .reaction-choices button { width: 36px; height: 36px; min-height: 36px; padding: 0; justify-content: center; border: none; background: none; font-size: 1.15rem; }
.comments-attachments form.comment-reactions .reaction-choices button:hover { background: var(--color-accent-bg); }
@media (pointer: coarse) {
    /* Etwas größere Tippfläche, aber kompakt genug für eine Zeile */
    .comments-attachments form.comment-reactions button, .reaction-picker summary { height: 32px; min-height: 32px; }
    .comments-attachments form.comment-reactions .reaction-choices button { width: 42px; height: 42px; min-height: 42px; }
}
.older-comments { margin: 0 0 0.6rem; }
.older-comments summary { cursor: pointer; list-style: none; font-size: 0.86rem; font-weight: 600; color: var(--color-accent); padding: 0.4rem 0; }
.older-comments summary::-webkit-details-marker { display: none; }
/* Sprungziel aus der Glocke kurz hervorheben. */
.comment-list li:target { animation: comment-flash 2.4s ease-out; border-radius: var(--radius-sm); }
@keyframes comment-flash { 0%, 35% { background: var(--color-accent-bg); box-shadow: 0 0 0 3px var(--color-accent-bg); } 100% { background: transparent; box-shadow: none; } }
.comment-reply summary { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; font-size: 0.84rem; color: var(--color-accent); font-weight: 600; list-style: none; }
.comment-reply summary::-webkit-details-marker { display: none; }
.comment-reply summary .icon { width: 14px; height: 14px; margin: 0; }
.comment-reply[open] summary { margin-bottom: 0.4rem; }
.comment-reply textarea { margin-top: 0; }
.attachment-list li.attachment-row { display: flex; align-items: center; gap: 0.75rem; }
.attachment-thumb { flex-shrink: 0; display: block; width: 3.5rem; height: 3.5rem; border-radius: var(--radius-sm); overflow: hidden; background: var(--color-bg); border: 1px solid var(--color-border); }
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.comments-attachments form { margin-top: 0.5rem; }
/* Kompakte Knöpfe: am Computer niedriger, auf Touch-Geräten 44 px. */
.comments-attachments form button { margin-top: 0; min-height: 36px; padding: 0.35rem 0.85rem; font-size: 0.86rem; }
.ca-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }
.ca-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem; }
.ca-fields > div { min-width: 0; }
.ca-fields .ca-grow { flex: 1 1 14rem; max-width: 26rem; }
.ca-fields label { margin-top: 0; }
.ca-fields input[type="date"], .ca-fields input[type="text"] { width: 100%; min-height: 36px; margin: 0; }
.comments-attachments input[type="file"] { max-width: 100%; font-size: 0.86rem; }
.comments-attachments input[type="file"]::file-selector-button {
    min-height: 36px; padding: 0.35rem 0.85rem; margin-right: 0.6rem; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
    background: var(--color-surface); color: var(--color-ink); font: inherit; font-weight: 600; cursor: pointer;
}
.comments-attachments form button.ca-delete { border-color: transparent; background: transparent; color: var(--color-muted); box-shadow: none; }
.comments-attachments form button.ca-delete:hover, .comments-attachments form button.ca-delete:focus-visible { background: var(--color-red-bg); border-color: transparent; color: var(--color-red); }
.comments-attachments form button.ca-icon { width: 36px; padding: 0; justify-content: center; }
.comments-attachments .ca-row-form { margin: 0 0 0 auto; flex-shrink: 0; }
.comment-list li.reminder-row { display: flex; align-items: center; gap: 0.75rem; }
@media (pointer: coarse) {
    .comments-attachments form button, .ca-fields input[type="date"], .ca-fields input[type="text"],
    .comments-attachments input[type="file"]::file-selector-button { min-height: 44px; }
    .comments-attachments form button.ca-icon { width: 44px; }
}

/* Standardmäßig eingeklappt — nimmt sonst auf jeder Detailseite viel
   Platz weg, obwohl die meisten Besuche diese Bereiche gar nicht
   brauchen. Natives <details>, kein JS nötig. */
.collapsible-section { border-top: 1px solid var(--color-border); padding-top: 0.9rem; margin-top: 0.9rem; }
.collapsible-section:first-of-type { border-top: none; padding-top: 0; }
.collapsible-section summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.5rem;
}
.collapsible-section summary::-webkit-details-marker { display: none; }
.collapsible-section summary::before {
    content: ""; width: 0; height: 0; flex-shrink: 0;
    border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 5px solid var(--color-muted);
    transition: transform 0.15s ease; margin-left: 0.1rem;
}
.collapsible-section[open] summary::before { transform: rotate(90deg); }
.collapsible-section .collapsible-body { padding-top: 0.6rem; }
/* Klick-Popover (nicht :hover/title) — funktioniert auch auf
   Touch-Geräten, konsistent mit .field-help. Kein natives <details>
   hier, weil das innerhalb eines <summary> ungültig verschachtelt
   wäre (die drei Punkte oben liegen in <details class="collapsible-section">). */
.icon-hint { display: inline-flex; position: relative; color: var(--color-muted); cursor: pointer; }
.icon-hint:hover, .icon-hint.open { color: var(--color-accent); }
.icon-hint .icon { width: 15px; height: 15px; }
.icon-hint-text {
    display: none; position: absolute; top: 135%; left: 0; z-index: 30;
    background: var(--color-ink); color: #fff; padding: 0.55rem 0.75rem; border-radius: var(--radius-sm);
    font-size: 0.8rem; font-weight: 400; line-height: 1.4; width: max-content; max-width: 240px; box-shadow: var(--shadow-md);
}
.icon-hint.open .icon-hint-text { display: block; }

/* Bereichs-Info: „Info“-Button im Seitentitel klappt eine Erklärung
   auf, was der Bereich bedeutet und wofür er da ist. Muster:
   <button class="section-info-toggle" aria-controls="ID"> im h1.page-title,
   darunter <div class="section-info" id="ID" hidden>. Skript unten. */
/* a.section-info-link: gleiches Aussehen, führt aber auf eine Hilfeseite statt aufzuklappen. */
button.section-info-toggle, a.section-info-link {
    margin: 0 0 0 0.15rem; min-height: 30px; padding: 0.2rem 0.65rem 0.2rem 0.5rem; gap: 0.3rem;
    border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface);
    color: var(--color-muted); font-size: 0.8rem; font-weight: 600; letter-spacing: 0;
}
button.section-info-toggle .icon, a.section-info-link .icon { width: 15px; height: 15px; }
a.section-info-link { display: inline-flex; align-items: center; vertical-align: middle; text-decoration: none; line-height: 1; }
button.section-info-toggle:hover, button.section-info-toggle[aria-expanded="true"], a.section-info-link:hover {
    background: var(--color-accent-bg); border-color: var(--color-accent-bg); color: var(--color-accent-ink);
}
.section-info {
    position: relative; margin: 0.25rem 0 1.1rem; padding: 0.9rem 2.6rem 0.9rem 1.1rem;
    background: var(--color-accent-bg); border-left: 3px solid var(--color-accent); border-radius: var(--radius-sm);
    font-size: 0.88rem; line-height: 1.5; color: var(--color-text);
}
.section-info[hidden] { display: none; }
.section-info h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-accent-ink); margin: 0.8rem 0 0.25rem; }
.section-info h2:first-of-type { margin-top: 0; }
.section-info p { margin: 0 0 0.4rem; }
.section-info ul, .section-info ol { margin: 0 0 0.4rem; padding-left: 1.2rem; }
.section-info li { margin-bottom: 0.15rem; }
button.section-info-close {
    position: absolute; top: 0.45rem; right: 0.45rem; margin: 0; min-height: 32px; width: 32px; padding: 0;
    justify-content: center; border: none; background: transparent; color: var(--color-muted);
}
button.section-info-close:hover { background: rgba(37, 99, 235, 0.1); color: var(--color-accent-ink); border: none; }
button.section-info-close .icon { width: 16px; height: 16px; }
@media print { button.section-info-toggle, .section-info { display: none !important; } }
