html, body {
    font-family: Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #0E1116;
}

/* Hilfsklasse: zeigt anklickbare Elemente (Tabellenzeilen, Dok-Karten) als klickbar an. */
.cursor-pointer {
    cursor: pointer;
}

/* Fehler-Grenze (ErrorBoundary) */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "Ein Fehler ist aufgetreten.";
}

/* Globale Fehlerleiste (von blazor.web.js bei unbehandelten Fehlern eingeblendet) */
#blazor-error-ui {
    color-scheme: dark only;
    background: #2b2611;
    color: #f5e9a0;
    border-top: 1px solid #D29922;
    bottom: 0;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.5);
    display: none;
    left: 0;
    padding: 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    /* above MudBlazor appbar/dialog/snackbar/tooltip layers */
    z-index: 2100;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.9rem;
    top: 0.55rem;
}

#blazor-error-ui .reload {
    color: #D29922;
    font-weight: 600;
}

/* ---- Aufgaben-Kanban-Board ---- */
.aufgaben-board {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: .5rem;
}

.aufgaben-spalte {
    flex: 1 1 0;
    min-width: 270px;
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    background-color: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    overflow: hidden;
}

.aufgaben-spalte-kopf {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .7rem 1rem;
    font-weight: 600;
    color: #fff;
}

    .aufgaben-spalte-kopf .mud-icon-root {
        color: #fff;
    }

.aufgaben-spalte-body {
    /* Feste Höhe für etwa 4 Aufgaben-Karten; danach scrollt die Spalte in sich selbst,
       statt die ganze Seite zu verlängern. Über die Variable je nach Kartenhöhe justierbar. */
    --aufgaben-karten-hoehe: 6.25rem;
    height: calc(4 * var(--aufgaben-karten-hoehe) + 3 * .6rem + 1.2rem);
    overflow-y: auto;
    padding: .6rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    transition: background-color .15s ease;
}

.aufgaben-karte {
    cursor: grab;
}

    .aufgaben-karte:active {
        cursor: grabbing;
    }

/* Drag-Visuals (MudDropContainer ApplyDropClassesOnDragStarted) */
.aufgaben-dropzone-aktiv {
    background-color: rgba(57, 211, 233, 0.08);
    outline: 2px dashed var(--mud-palette-primary);
    outline-offset: -6px;
}

.aufgaben-dropzone-gesperrt {
    background-color: rgba(244, 67, 54, 0.06);
}

/* ---- WYSIWYG-Editor (Quill) im dunklen NOOSE-Theme ---- */
.ql-toolbar.ql-snow,
.ql-container.ql-snow {
    border-color: var(--mud-palette-lines-default);
}

.ql-toolbar.ql-snow {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    background-color: var(--mud-palette-background-grey);
}

.ql-container.ql-snow {
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    background-color: var(--mud-palette-surface);
}

.ql-editor {
    min-height: 340px;
    color: var(--mud-palette-text-primary);
    font-family: Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 0.95rem;
}

    .ql-editor.ql-blank::before {
        color: var(--mud-palette-text-secondary);
        font-style: normal;
    }

/* Toolbar-Symbole/Labels im Dunkeln sichtbar machen. */
.ql-snow .ql-stroke {
    stroke: var(--mud-palette-text-secondary);
}

.ql-snow .ql-fill {
    fill: var(--mud-palette-text-secondary);
}

.ql-snow .ql-picker {
    color: var(--mud-palette-text-secondary);
}

.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke,
.ql-snow .ql-picker-label:hover .ql-stroke {
    stroke: var(--mud-palette-primary);
}

.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill {
    fill: var(--mud-palette-primary);
}

.ql-snow .ql-picker-options {
    background-color: var(--mud-palette-surface);
    border-color: var(--mud-palette-lines-default) !important;
}

/* ---- NOOSEI-Chatantwort: Dokument-Typografie, aber auf Blasengröße gestutzt ---- */
.noosei-antwort {
    font-size: .875rem;
}

.noosei-antwort > :first-child {
    margin-top: 0;
}

.noosei-antwort > :last-child {
    margin-bottom: 0;
}

.noosei-antwort h1,
.noosei-antwort h2,
.noosei-antwort h3 {
    margin: .75rem 0 .35rem;
    font-size: 1rem;
}

.noosei-antwort p,
.noosei-antwort ul,
.noosei-antwort ol {
    margin: .35rem 0;
}

.noosei-antwort table {
    font-size: .8125rem;
}

/* ---- NOOSEI-Werkzeuge in der Quill-Toolbar ---- */
.noose-rte-ki-laeuft .ql-toolbar button.ql-noosei-korrigieren,
.noose-rte-ki-laeuft .ql-toolbar button.ql-noosei-schreiben {
    opacity: .35;
    pointer-events: none;
}

/* ---- NOOSEI-Differenz (Vorschau-Dialog) ---- */
.noosei-diff ins {
    background: rgba(76, 175, 80, .18);
    color: var(--mud-palette-success);
    text-decoration: underline; /* nie nur Farbe */
    border-radius: 3px;
    padding: 0 2px;
}

.noosei-diff del {
    background: rgba(244, 67, 54, .18);
    color: var(--mud-palette-error);
    text-decoration: line-through;
    border-radius: 3px;
    padding: 0 2px;
}

.noosei-legende {
    display: inline-block;
    width: .75rem;
    height: .75rem;
    border-radius: 3px;
    vertical-align: -1px;
    margin-right: .25rem;
}

.noosei-legende-neu {
    background: rgba(76, 175, 80, .45);
}

.noosei-legende-weg {
    background: rgba(244, 67, 54, .45);
}

/* ---- NOOSEI-Kurzbrief ---- */
.ki-brief-tldr {
    background: rgba(34, 211, 238, .08);
    border-left: 3px solid var(--mud-palette-primary);
    border-radius: 8px;
}

.ki-brief-risk {
    background: var(--mud-palette-background-gray);
    border-radius: 8px;
}

.ki-brief-list {
    padding-top: 0;
    padding-bottom: 0;
}

.ki-brief-table td {
    vertical-align: top;
    padding-top: .35rem;
    padding-bottom: .35rem;
}

/* ---- Gerendertes Dokument-HTML (Viewer/Vorschau) ---- */
.dokument-html {
    color: var(--mud-palette-text-primary);
    line-height: 1.6;
    word-break: break-word;
}

    .dokument-html h1 {
        font-size: 1.6rem;
    }

    .dokument-html h2 {
        font-size: 1.35rem;
    }

    .dokument-html h3 {
        font-size: 1.15rem;
    }

    .dokument-html a {
        color: var(--mud-palette-primary);
    }

    .dokument-html blockquote {
        border-left: 3px solid var(--mud-palette-lines-default);
        margin-left: 0;
        padding-left: 1rem;
        color: var(--mud-palette-text-secondary);
    }

    .dokument-html pre {
        background-color: var(--mud-palette-background-grey);
        padding: .75rem 1rem;
        border-radius: 6px;
        overflow-x: auto;
        white-space: pre-wrap;
    }

    .dokument-html ul,
    .dokument-html ol {
        padding-left: 1.5rem;
    }

    .dokument-html img {
        max-width: 100%;
    }

    /* Tabellen (RichTextEditor / vendored quill1.3.7-table-module).
       Das Modul-CSS (table-module.css) wird nur auf Editor-Seiten geladen (durch richtext.js), weil es
       einige ungescopte globale Klassen enthält (.dialog, .input_input …). Die reine Lese-Ansicht
       stylen wir daher hier selbst und gescopt unter .dokument-html – inklusive des modul-eigenen
       <contain>-Zellwrappers (Klasse .ql-table-cell-inner). */
    .dokument-html .ql-table-wrapper {
        overflow-x: auto;
        max-width: 100%;
    }

    .dokument-html table {
        border-collapse: collapse;
        max-width: 100%;
    }

    .dokument-html td,
    .dokument-html th {
        border: 1px solid var(--mud-palette-lines-default);
        padding: 6px 10px;
        vertical-align: top;
    }

        /* <contain> ist ein modul-eigenes Element – ohne Modul-CSS sonst inline. */
        .dokument-html td contain,
        .dokument-html th contain,
        .dokument-html .ql-table-cell-inner {
            display: block;
        }

    /* Absätze in Zellen nicht mit großem Außenabstand rendern. */
    .dokument-html td p,
    .dokument-html th p {
        margin: 0;
    }

/* Bewerber-Chat: kompakte Absätze für Rich-Text-Nachrichten in der Sprechblase. */
.bewerbung-chat-html p {
    margin: 0 0 .25rem 0;
}

    .bewerbung-chat-html p:last-child {
        margin-bottom: 0;
    }

.bewerbung-chat-html ul,
.bewerbung-chat-html ol {
    margin: .25rem 0;
}

/* Bewerber-Chat: Editor kompakt halten (statt der globalen 340px-Mindesthöhe) und intern scrollen. */
.bewerbung-chat-editor .ql-editor {
    min-height: 96px;
    max-height: 160px;
    overflow-y: auto;
}

/* ---- Druck-/PDF-Export (Phase 7) ----
   window.print() (DruckButton) druckt nur den Akteninhalt: Navigation, Topbar, Buttons und
   andere Bedienelemente werden ausgeblendet, dunkles Theme wird auf Schwarz-auf-Weiß gedreht.
   "Als PDF speichern" im Browser-Druckdialog erzeugt den PDF-Export. */
@media print {
    .mud-appbar,
    .mud-drawer,
    .mud-snackbar,
    #blazor-error-ui,
    .mud-dialog-container,
    .mud-overlay,
    button,
    .mud-button-root,
    .mud-input-control,
    .mud-table-pagination,
    .no-print {
        display: none !important;
    }

    /* Inhalt über die volle Seite, ohne App-Abstände. */
    .mud-main-content {
        padding: 0 !important;
        margin: 0 !important;
    }

    .mud-container {
        max-width: 100% !important;
        padding: 0 !important;
    }

    /* Dunkles Theme für Papier invertieren: weißer Grund, dunkle Schrift. */
    html, body, .mud-layout, .mud-main-content, .mud-paper {
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
    }

    .mud-paper {
        border: 1px solid #ccc !important;
    }

    .mud-typography, .mud-text-secondary, .mud-link, .mud-chip, .mud-alert,
    .mud-table, .mud-table * {
        color: #000 !important;
    }

    .mud-table, .mud-table-container {
        background: #fff !important;
    }

    a, .mud-link {
        text-decoration: none !important;
    }
}

/* ---- Druckansicht der Akten (z. B. /personen/{id}/druck, Phase 7) ----
   Eigenständige Dokument-Darstellung: hell, schmale Spalte, klassische Akten-Optik. */
.druck-seite {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 16px;
    background: #fff;
    color: #111;
    min-height: 100vh;
}

.druck-aktionen {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.druck-dokument {
    font-size: 14px;
    line-height: 1.45;
    color: #111;
}

.druck-kopf {
    border-bottom: 3px double #111;
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.druck-behoerde {
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #444;
}

.druck-dokument h1 {
    font-size: 22px;
    margin: 4px 0 6px;
}

.druck-dokument h2 {
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid #999;
    padding-bottom: 3px;
    margin: 22px 0 8px;
}

.druck-meta {
    font-size: 12px;
    color: #444;
}

.druck-vs {
    display: inline-block;
    margin-left: 10px;
    padding: 1px 8px;
    border: 1.5px solid #b00;
    color: #b00;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: .06em;
}

.druck-felder {
    width: 100%;
    border-collapse: collapse;
}

    .druck-felder th {
        text-align: left;
        vertical-align: top;
        width: 200px;
        padding: 3px 10px 3px 0;
        font-weight: 600;
        color: #333;
    }

    .druck-felder td {
        padding: 3px 0;
    }

.druck-tabelle {
    width: 100%;
    border-collapse: collapse;
}

    .druck-tabelle th,
    .druck-tabelle td {
        border: 1px solid #bbb;
        padding: 4px 8px;
        text-align: left;
        vertical-align: top;
    }

    .druck-tabelle thead th {
        background: #eee;
    }

.druck-eintrag {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px 10px;
    margin-bottom: 8px;
    break-inside: avoid;
}

.druck-eintrag-kopf {
    margin-bottom: 4px;
}

.druck-mehrzeilig {
    white-space: pre-wrap;
}

.druck-fusszeile {
    margin-top: 28px;
    border-top: 1px solid #999;
    padding-top: 6px;
    font-size: 11px;
    color: #555;
}

@media print {
    /* Tab-Leisten der interaktiven Seiten gehören nicht aufs Papier (nur der aktive Inhalt). */
    .mud-tabs-tabbar,
    .mud-tabs-toolbar {
        display: none !important;
    }

    .druck-seite {
        max-width: none;
        padding: 0;
    }

    .druck-dokument h2 {
        break-after: avoid;
    }
}

/* ---- Phase 8: Beziehungsgraph (vis-network) ---- */
.noose-graph-flaeche {
    position: relative;
    overflow: hidden;
    border: 1px solid #222B36;
    border-radius: 10px;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(34, 211, 238, 0.06), transparent 60%),
        linear-gradient(180deg, #0F141A 0%, #0B0E13 100%);
}

/* vis-network rendert in einen Canvas; das umgebende div bekommt einen feinen Innenschatten. */
.noose-graph-flaeche > div:first-child {
    background: transparent;
}

.noose-graph-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background: rgba(11, 14, 19, 0.35);
}

.noose-graph-punkt {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}

.noose-graph-linie {
    display: inline-block;
    width: 22px;
    height: 3px;
    border-radius: 2px;
}

/* Legenden-Punkt für Schlüsselfiguren: größer, goldene Füllung + Glühen wie im Graphen.
   Rand bleibt neutral — im Graphen trägt der Rand weiter Typ/Einstufung. */
.noose-graph-schluessel {
    width: 16px;
    height: 16px;
    background: #4A3708;
    border: 2px solid #8B98A8;
    box-shadow: 0 0 8px rgba(255, 200, 87, 0.9);
}

/* vis-network Tooltip an das dunkle Theme angleichen. */
div.vis-tooltip {
    background: #11161D !important;
    border: 1px solid #2B3744 !important;
    border-radius: 8px !important;
    color: #E6EDF3 !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55) !important;
    padding: 8px 10px !important;
    font-family: Inter, 'Segoe UI', Roboto, sans-serif !important;
}

/* ---- Activity band: stacked CSS bars, no chart library and no JS ---- */
.noose-band-kopf {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
}

.noose-band-kennzahl {
    color: var(--mud-palette-text-primary);
    font-variant-numeric: tabular-nums;
}

.noose-band-plot {
    display: flex;
    gap: 0.5rem;
    transition: opacity 0.2s;
}

/* the band cannot honour a free-text filter, so it says so by fading instead of lying */
.noose-band-blass {
    opacity: 0.45;
}

.noose-band-achse {
    flex: none;
    width: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    /* pull the end labels onto their gridlines instead of between them */
    margin: -0.45rem 0;
    font-size: 0.68rem;
    color: var(--mud-palette-text-secondary);
    font-variant-numeric: tabular-nums;
}

.noose-band-flaeche {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    border-bottom: 1px solid var(--mud-palette-divider);
}

.noose-band-linie {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(139, 152, 168, 0.1);
    pointer-events: none;
}

.noose-band-spalten {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    height: 100%;
}

.noose-band-spalte {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border-radius: 2px 2px 0 0;
    cursor: pointer;
}

.noose-band-spalte > span:not(.noose-band-tip) {
    display: block;
    width: 100%;
    /* a one-event segment must stay visible instead of rounding to nothing */
    min-height: 1.5px;
}

.noose-band-spalte > span:first-child {
    border-radius: 2px 2px 0 0;
}

/* zero buckets are gap-filled; without a stub the band looks unfilled */
.noose-band-null {
    height: 2px;
    background: #222b36;
}

.noose-band-spalte:hover {
    background: rgba(139, 152, 168, 0.1);
}

.noose-band-spalte:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 1px;
}

.noose-band-gewaehlt {
    background: rgba(34, 211, 238, 0.14);
    box-shadow: inset 0 -2px 0 0 var(--mud-palette-primary);
}

.noose-band-tip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    min-width: 11rem;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    /* lighter than the surface it floats over; the vis-network tooltip is darker on purpose */
    background: #1b222b;
    border: 1px solid #2b3744;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
    color: var(--mud-palette-text-primary);
    font-size: 0.72rem;
    line-height: 1.5;
    white-space: nowrap;
    pointer-events: none;
}

.noose-band-spalte:hover > .noose-band-tip,
.noose-band-spalte:focus-visible > .noose-band-tip {
    display: flex;
    flex-direction: column;
}

.noose-band-tip.noose-band-anker-links {
    left: 0;
    transform: none;
}

.noose-band-tip.noose-band-anker-rechts {
    left: auto;
    right: 0;
    transform: none;
}

.noose-band-tip-zeile {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--mud-palette-text-secondary);
}

.noose-band-tip-zeile i {
    display: inline-block;
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.noose-band-leer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    border-bottom: 1px dashed rgba(139, 152, 168, 0.35);
}

.noose-band-leer-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
}

.noose-band-fuss {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.3rem;
}

.noose-band-luecke {
    flex: none;
    width: 3rem;
}

.noose-band-ticks {
    position: relative;
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    height: 1rem;
    font-size: 0.68rem;
    color: var(--mud-palette-text-secondary);
}

/* the inline left comes from the bucket index, so only the shift may be overridden here */
.noose-band-ticks > span {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    white-space: nowrap;
}

.noose-band-ticks > span.noose-band-anker-links {
    transform: none;
}

.noose-band-ticks > span.noose-band-anker-rechts {
    transform: translateX(-100%);
}

/* the legend doubles as the category filter, so there is one control row instead of two */
.noose-band-legende {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.noose-band-legende button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 999px;
    background: transparent;
    color: var(--mud-palette-text-secondary);
    font: inherit;
    font-size: 0.74rem;
    cursor: pointer;
}

.noose-band-legende button:hover {
    background: rgba(139, 152, 168, 0.08);
}

.noose-band-legende button:disabled {
    cursor: default;
    opacity: 0.5;
}

.noose-band-legende .noose-band-legende-aktiv {
    border-color: var(--mud-palette-primary);
    background: rgba(34, 211, 238, 0.1);
    color: var(--mud-palette-text-primary);
}

.noose-band-legende i {
    display: inline-block;
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* Chronicle feed */
.chronik-tag {
    position: sticky;
    /* sticks inside the rail pane, whose pa-4 the negative offset cancels */
    top: -1rem;
    z-index: 2;
    background: var(--mud-palette-surface);
    padding: 1rem 0 0.35rem;
    border-bottom: 1px solid var(--mud-palette-divider);
}

.chronik-zeile {
    display: grid;
    /* icon | time | content | actor: the actor on its own column saves a line per event */
    grid-template-columns: 1.75rem 3.25rem minmax(0, 1fr) auto;
    gap: 0.5rem;
    padding: 0.4rem 0;
    align-items: start;
}

.chronik-akteur {
    justify-self: end;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .chronik-zeile {
        grid-template-columns: 1.75rem 3.25rem minmax(0, 1fr);
    }

    .chronik-akteur {
        grid-column: 3;
        justify-self: start;
    }
}

.chronik-zeile + .chronik-zeile {
    border-top: 1px solid rgba(139, 152, 168, 0.1);
}

.chronik-zeile:hover {
    background: rgba(139, 152, 168, 0.06);
}

.chronik-neu {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0.75rem 0;
    color: var(--mud-palette-warning);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.chronik-neu::before,
.chronik-neu::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--mud-palette-warning);
    opacity: 0.4;
}

/* Record detail section rail */
.record-rail-shell {
    overflow: hidden;
}

.record-rail {
    flex: none;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--mud-palette-divider);
}

.record-rail .mud-button-root {
    justify-content: flex-start;
    text-transform: none;
    letter-spacing: normal;
    border-radius: 0;
    padding-left: 1rem;
    padding-right: 1rem;
}

.record-rail-content {
    min-width: 0;
}

@media (min-width: 960px) {
    /* one screenful, pinned under the app bar; both columns scroll inside it.
       No min-height: a sticky box taller than its stick window can never be
       scrolled to its own bottom edge. */
    .record-rail-shell {
        position: sticky;
        top: calc(var(--mud-appbar-height, 60px) + 1rem);
        height: calc(100vh - var(--mud-appbar-height, 60px) - 2rem);
        height: calc(100dvh - var(--mud-appbar-height, 60px) - 2rem);
    }

    .record-rail {
        width: 15rem;
        border-bottom: none;
        border-right: 1px solid var(--mud-palette-divider);
        overflow-y: auto;
        /* wheel past the last entry must not scroll the page underneath */
        overscroll-behavior: contain;
    }

    .record-rail-content {
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    /* Steckkarte: same one-screenful cap as .record-rail-shell next to it. */
    .akte-steckkarte {
        position: sticky;
        top: calc(var(--mud-appbar-height, 60px) + 1rem);
        height: calc(100vh - var(--mud-appbar-height, 60px) - 2rem);
        height: calc(100dvh - var(--mud-appbar-height, 60px) - 2rem);
    }

    .akte-steckkarte > .mud-paper {
        height: 100%;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

@media (min-width: 960px) {
    /* Rail pages fit exactly one screen: the container is capped to the viewport and the
       rail (plus Steckkarte) flexes into whatever the header above leaves over. A fixed
       shell height always overshot the screen by the header height. The sticky rules above
       remain as fallback for browsers without :has() and for rail-free Steckkarte pages. */
    .mud-container:has(.record-rail-shell) {
        display: flex;
        flex-direction: column;
        height: calc(100vh - var(--mud-appbar-height, 60px) - 3rem);
        height: calc(100dvh - var(--mud-appbar-height, 60px) - 3rem);
        overflow: hidden;
    }

    .mud-container:has(.record-rail-shell) > .record-rail-shell,
    .mud-container:has(.record-rail-shell) > .mud-grid {
        flex: 1 1 auto;
        min-height: 0;
        /* air between the shell's bottom edge and the legal footer */
        margin-bottom: 1.5rem;
    }

    /* flex stretch only ever grows grid rows/items, it never shrinks them below their
       content height — so pin the two record columns to the (now definite) grid height */
    .mud-container:has(.record-rail-shell) > .mud-grid > .mud-grid-item {
        height: 100%;
    }

    .mud-container:has(.record-rail-shell) .record-rail-shell,
    .mud-container:has(.record-rail-shell) .akte-steckkarte {
        position: static;
        height: auto;
    }

    .mud-container:has(.record-rail-shell) .mud-grid-item > .record-rail-shell,
    .mud-container:has(.record-rail-shell) .mud-grid-item > .akte-steckkarte {
        height: 100%;
    }

    .mud-container:has(.record-rail-shell) .record-rail-shell,
    .mud-container:has(.record-rail-shell) .akte-steckkarte > .mud-paper {
        border-radius: 12px;
    }
}

@media print {
    /* a screen-height scroll box would clip the record on paper */
    .mud-container:has(.record-rail-shell) {
        display: block;
        height: auto;
        overflow: visible;
    }

    .record-rail-shell {
        position: static;
        height: auto;
        overflow: visible;
    }

    .record-rail-content {
        overflow-y: visible;
    }
}

/* Two-column drawer: icon rail of areas + panel with that area's entries. */
/* .mud-drawer is a scrolling column, so the row shell needs its own overflow context. */
.noose-drawer { overflow: hidden; }

.noose-nav {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.noose-nav-rail {
    flex: 0 0 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    padding: .5rem 0;
    overflow-y: auto;
    border-right: 1px solid var(--mud-palette-divider);
    background-color: var(--mud-palette-background-gray);
}

.noose-nav-rail .mud-icon-button { border-radius: 8px; }

.noose-nav-rail-active {
    background-color: var(--mud-palette-primary-hover);
    box-shadow: inset 3px 0 0 0 var(--mud-palette-primary);
}

.noose-nav-panel {
    flex: 1 1 auto;
    min-width: 0;
    overflow-y: auto;
}

@media (max-width: 959.98px) {
    .noose-nav-rail { flex-basis: 56px; }
}

/* Desktop: the drawer rests at rail width and the entry panel expands over the content on hover.
   (hover: hover) excludes touch devices, which could never collapse it again. */
@media (min-width: 960px) and (hover: hover) and (pointer: fine) {
    /* content clears the icon rail only; overriding the rule beats the container's inline width var */
    .mud-drawer-open-responsive-md-left .mud-main-content { margin-left: 64px; }

    /* 0-3-0 to beat .mud-drawer.mud-drawer-responsive.mud-drawer-pos-left */
    .mud-drawer.mud-drawer-responsive.noose-drawer {
        width: 64px;
        transition: width 225ms cubic-bezier(0, 0, 0.2, 1),
                    box-shadow 225ms cubic-bezier(0, 0, 0.2, 1);
    }

    .mud-drawer.mud-drawer-responsive.noose-drawer:hover {
        width: 300px;
        box-shadow: var(--mud-elevation-8);
    }

    /* Keyboard focus only, and in its own rule. :focus-within would also match the link the mouse
       just clicked, pinning the drawer open until the focus moved on. A browser without :has()
       drops this rule alone instead of taking the :hover rule down with it. */
    .mud-drawer.mud-drawer-responsive.noose-drawer:has(:focus-visible) {
        width: 300px;
        box-shadow: var(--mud-elevation-8);
    }

    /* fixed width, or flex would squeeze the entries to zero during the animation */
    .noose-drawer .noose-nav-panel { flex: 0 0 236px; }
}

@media (prefers-reduced-motion: reduce) {
    .mud-drawer.mud-drawer-responsive.noose-drawer { transition: none; }
}

/* Evidence room: tile selection + clearing action bar */
.asservat-kachel {
    position: relative;
    border: 1px solid transparent;
}

.asservat-kachel:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.asservat-kachel-gewaehlt {
    border-color: var(--mud-palette-primary);
    background: var(--mud-palette-action-default-hover);
}

/* One line, never two: a wrapping second chip made the tiles different heights and broke the grid.
   The category gives way rather than the row being clipped — the chip keeps its rounded end and
   ellipsises its own label, so nothing looks sheared off. The tooltip still carries the full name. */
.asservat-kachel-chips {
    flex-wrap: nowrap;
    min-width: 0;
}

/* the stock is the number people scan for; it keeps its full width */
.asservat-kachel-chips > :first-child {
    flex: 0 0 auto;
}

/* the category shrinks instead, down to nothing if it has to */
.asservat-kachel-chips > :last-child {
    min-width: 0;
    flex: 0 1 auto;
}

.asservat-kachel-chips .mud-chip {
    max-width: 100%;
}

.asservat-kachel-chips .mud-chip-content {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Inert marker, not a checkbox: the tile owns the click, so this must not be a second target. */
.asservat-kachel-haken {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 1;
    pointer-events: none;
    line-height: 0;
    padding: 2px;
    border-radius: 4px;
    background: var(--mud-palette-surface);
}

.asservat-aktionsleiste {
    position: sticky;
    bottom: 0;
    z-index: 2;
    /* pulls into the rail pane's pa-4 so nothing scrolls through the gap below the bar */
    margin-bottom: -1rem;
    padding: 0.5rem 0.5rem 1.5rem;
    border-top: 1px solid var(--mud-palette-divider);
}
