/* QS-Plattform – schlichtes, ruhiges Interface ohne externe Abhängigkeiten */
:root {
    --bg: #f5f6f4;
    --surface: #ffffff;
    --surface-2: #f0f2ef;
    --line: #dde1dc;
    --text: #1d2521;
    --muted: #5d6b64;
    --accent: #1f6f5c;
    --accent-ink: #ffffff;
    --accent-soft: #e3f0eb;
    --green: #2e7d4f;
    --green-bg: #e2f2e8;
    --yellow: #8a6200;
    --yellow-bg: #fbf0cf;
    --red: #b3261e;
    --red-bg: #fbe3e1;
    --grey: #5d6b64;
    --grey-bg: #eceeeb;
    --radius: 8px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h1, h2, h3 { overflow-wrap: break-word; hyphens: auto; }
h2 { font-size: 1.2rem; margin: 2rem 0 .75rem; }
h3 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }
p { margin: .4rem 0 .9rem; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.inline { display: inline; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; height: 56px; padding: 0 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; color: var(--text); text-decoration: none; }
.brand-logo { display: block; max-height: 36px; max-width: 220px; width: auto; height: auto; }
.brand-icon { display: block; width: 32px; height: 32px; border-radius: 8px; object-fit: cover; }
.plain-brand .brand-logo { max-height: 56px; max-width: 280px; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: .8rem; letter-spacing: .04em; }
.nav-toggle { display: none; -webkit-appearance: none; appearance: none; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.nav-toggle:hover, .nav-toggle[aria-expanded="true"] { color: var(--text); background: var(--surface-2); }
.nav-toggle svg { display: block; }
/* Benutzermenü hinter dem Personen-Symbol */
.user-menu { position: relative; margin-left: auto; background: none; border: 0; padding: 0; margin-bottom: 0; }
.user-menu > summary { list-style: none; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu[open] > summary { margin-bottom: 0; }
.user-menu > summary:hover, .user-menu[open] > summary { color: var(--text); background: var(--surface-2); }
.user-menu-panel { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 30; min-width: 220px; max-width: calc(100vw - 2rem); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .12); padding: .35rem 0; }
.user-menu-head { display: flex; flex-direction: column; padding: .55rem 1rem .6rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; overflow-wrap: anywhere; }
.user-menu-panel a, .user-menu-panel button { display: block; width: 100%; box-sizing: border-box; padding: .5rem 1rem; border: 0; background: none; color: var(--text); font: inherit; font-size: .92rem; text-align: left; text-decoration: none; cursor: pointer; }
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--surface-2); }
.user-menu-panel form { margin: 0; }

/* Rahmen */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: calc(100vh - 56px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 1rem .6rem 2rem; overflow-y: auto; position: sticky; top: 56px; height: calc(100vh - 56px); }
.sidebar a { display: block; padding: .38rem .7rem; border-radius: 6px; color: var(--text); text-decoration: none; font-size: .93rem; }
.sidebar a.sub { padding-left: 1.4rem; color: var(--muted); font-size: .88rem; }
.sidebar a:hover { background: var(--surface-2); }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-group { margin: 1.1rem .7rem .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.content { padding: 1.75rem 2rem 4rem; max-width: 1240px; width: 100%; min-width: 0; box-sizing: border-box; }
.page-head > div { min-width: 0; max-width: 100%; }

/* Seitenkopf */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head p { margin: .2rem 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
/* In Tabellenzellen bleibt .actions eine Zelle (sonst verrutschen Rahmen und Spalten) */
td.actions { display: table-cell; }
td.actions > * { display: inline-block; margin: 0 .35rem .35rem 0; vertical-align: middle; }
td.actions > *:last-child { margin-right: 0; }
.breadcrumb { font-size: .87rem; margin-bottom: .4rem; }
.breadcrumb a { color: var(--muted); }

/* Karten und Raster */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; }
.stat .num { font-size: 1.9rem; font-weight: 650; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .88rem; }
.stat.rot .num { color: var(--red); }
.stat.gelb .num { color: var(--yellow); }
.stat.gruen .num { color: var(--green); }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; }

/* Tabellen */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1.25rem; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbf9; }
td.actions { white-space: nowrap; }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }

/* Ampel */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge-gruen { background: var(--green-bg); color: var(--green); }
.badge-gelb { background: var(--yellow-bg); color: var(--yellow); }
.badge-rot { background: var(--red-bg); color: var(--red); }
.badge-grau, .badge-neutral { background: var(--grey-bg); color: var(--grey); }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .35rem; vertical-align: middle; }
.dot-gruen { background: var(--green); } .dot-gelb { background: #d39e00; } .dot-rot { background: var(--red); } .dot-grau { background: #9aa59f; }

/* Formulare */
form.stack { max-width: 760px; }
.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.field small { display: block; color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.field-check label { font-weight: 400; display: flex; gap: .5rem; align-items: flex-start; }
.field-check label input[type=checkbox] { margin-top: .22em; }
.req { color: var(--red); }
/* Einheitliche Höhe für alle einzeiligen Eingaben, Auswahlfelder, Dateifelder und Buttons */
:root { --control-h: 2.375rem; }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]):not([type=range]):not([type=color]), select, textarea {
    box-sizing: border-box; width: 100%; margin: 0; padding: 0 .65rem; border: 1px solid #c5ccc6; border-radius: 6px; background-color: #fff; font: inherit; font-size: .95rem; color: inherit;
}
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]):not([type=range]):not([type=color]), select {
    height: var(--control-h); line-height: calc(var(--control-h) - 2px);
}
textarea { padding: .45rem .65rem; line-height: 1.45; min-height: var(--control-h); }
/* Datum/Zeit: Browser-Innenabstände entfernen (Chrome, Safari/iOS) */
input::-webkit-datetime-edit, input::-webkit-datetime-edit-fields-wrapper { padding: 0; }
input::-webkit-date-and-time-value { text-align: left; min-height: calc(var(--control-h) - 2px); }
input::-webkit-calendar-picker-indicator { margin: 0; padding: 0; cursor: pointer; }
/* Auswahlfelder: eigener Pfeil, damit Safari die Höhe übernimmt */
select { -webkit-appearance: none; appearance: none; padding-right: 2rem; text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235d6b64' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .7rem center; background-size: 12px 8px; }
select[multiple], select[size]:not([size="1"]) { height: auto; line-height: 1.45; padding: .3rem .4rem; background-image: none; }
/* Dateifeld: eigenständiger Button links, Dateiname daneben – kein Rahmen um beides, damit nichts
   je nach Browser (Safari, Firefox, Chrome) im Feld verrutscht */
input[type=file] { height: auto !important; min-height: var(--control-h); padding: 0 !important; border: 0 !important; border-radius: 0; background: transparent !important; line-height: normal !important; font-size: .9rem; color: var(--muted); cursor: pointer; }
input[type=file]:focus { outline: none; }
input[type=file]:focus-visible::file-selector-button { outline: 3px solid rgba(31, 111, 92, .3); outline-offset: 1px; }
input[type=file]::file-selector-button { box-sizing: border-box; height: var(--control-h); margin: 0 .75rem 0 0; padding: 0 .95rem; border: 1px solid var(--accent); border-radius: 6px; background: var(--surface); color: var(--accent); font: inherit; font-size: .92rem; font-weight: 600; vertical-align: middle; cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--accent-soft, #e7f1ee); }
input[type=file]::-webkit-file-upload-button { box-sizing: border-box; height: var(--control-h); margin: 0 .75rem 0 0; padding: 0 .95rem; border: 1px solid var(--accent); border-radius: 6px; background: var(--surface); color: var(--accent); font: inherit; font-size: .92rem; font-weight: 600; vertical-align: middle; cursor: pointer; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(31, 111, 92, .3); outline-offset: 1px; border-color: var(--accent); }
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { width: 1.05rem; height: 1.05rem; margin: 0; flex: none; accent-color: var(--accent); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
/* Felder einer Zeile bündig: Beschriftung, Eingabe und Hinweis liegen je in einer gemeinsamen Zeile,
   auch wenn eine Beschriftung umbricht oder nur ein Feld einen Hinweis hat */
@supports (grid-template-rows: subgrid) {
    .form-row > .field, .form-row > .show-contents > .field { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; align-content: start; }
    .form-row > .field > label, .form-row > .show-contents > .field > label { align-self: end; }
    .form-row > .field-check > label { grid-row: 2; align-self: center; min-height: var(--control-h); margin: 0; }
    .form-row > .field-check > small { grid-row: 3; }
    .form-row > :not(.field) { grid-row: span 3; align-self: end; margin-bottom: .9rem; }
}
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem .2rem; margin: 0 0 1rem; }
legend { font-weight: 600; padding: 0 .35rem; }

/* Buttons */
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; box-sizing: border-box; height: var(--control-h); line-height: 1.1; white-space: nowrap; padding: 0 .95rem; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; font-size: .92rem; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.07); }
.btn-secondary, button.btn-secondary { background: var(--surface); color: var(--accent); }
.btn-danger, button.btn-danger { background: var(--surface); color: var(--red); border-color: #e2b4b0; }
.btn-small, button.btn-small, a.btn-small { height: var(--control-h); padding: 0 .75rem; font-size: .86rem; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }

/* Meldungen */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash-success { background: var(--green-bg); border-color: #b7dcc4; color: #1d5a37; }
.flash-error { background: var(--red-bg); border-color: #efbab5; color: #8c1d17; }
.flash-info { background: var(--accent-soft); border-color: #bcd9cf; color: #17503f; }
.notice { background: var(--surface-2); border-left: 4px solid var(--accent); padding: .75rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 1rem 0; }
.notice.warn { border-left-color: #d39e00; background: var(--yellow-bg); }
.notice.danger { border-left-color: var(--red); background: var(--red-bg); }
.secret-box { font-family: var(--mono); background: var(--surface-2); border: 1px dashed var(--accent); padding: .75rem 1rem; border-radius: 6px; word-break: break-all; }

/* Details */
details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem 1rem; margin-bottom: 1rem; }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: .75rem; }

/* Tabs/Filter */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; flex: 1 1 12rem; max-width: 22rem; }
.filters a { padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); text-decoration: none; color: var(--text); font-size: .87rem; }
.filters a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Einfache Seiten (Anmeldung, Einrichtung, Peer) */
body.plain { display: grid; place-items: start center; padding: 7vh 1rem 3rem; }
.plain-wrap { width: 100%; max-width: 420px; min-width: 0; }
.plain-wrap.wide { max-width: 1000px; }
.plain-box { box-sizing: border-box; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.75rem; box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .04); }
.plain-brand { display: flex; justify-content: center; align-items: center; gap: .65rem; margin: 0 0 2rem; font-size: 1.2rem; font-weight: 650; text-align: center; }
.plain-brand .brand-logo { max-height: 96px; max-width: min(400px, 100%); }
.plain-brand .brand-mark, .plain-brand .brand-icon { width: 44px; height: 44px; border-radius: 11px; font-size: .95rem; }
.plain-wrap.wide .plain-brand { justify-content: flex-start; margin-bottom: 1.25rem; }
/* Anmeldeseiten */
.auth-head { text-align: center; margin: 0 0 1.25rem; }
.auth-head h1 { margin: 0 0 .3rem; font-size: 1.55rem; letter-spacing: -.01em; }
.auth-head p { margin: 0; color: var(--muted); font-size: .95rem; }
body.auth .plain-box { padding: 2rem 2rem 1.6rem; }
.auth-form .field { margin-bottom: 1.15rem; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .25rem; }
.label-row label { margin: 0; font-weight: 600; font-size: .9rem; }
.label-row a { color: var(--muted); text-decoration: none; }
.label-row a:hover { color: var(--accent); text-decoration: underline; }
.btn.btn-block { display: flex; width: 100%; margin-top: .4rem; }
body.auth .btn.btn-block { background: #232c39; border-color: #232c39; color: #fff; }
body.auth .btn.btn-block:hover { background: #111821; border-color: #111821; }
@media (max-width: 480px) { body.plain { padding-top: 4vh; } body.auth .plain-box { padding: 1.4rem 1.2rem; } .plain-brand .brand-logo { max-height: 72px; } }
/* Wiederholbare Zeilen */
fieldset.repeat { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
fieldset.repeat legend { padding: 0; margin-bottom: .3rem; font-weight: 600; font-size: .92rem; }
.repeat-rows { display: grid; gap: .45rem; margin-bottom: .5rem; }
.repeat-row { display: flex; gap: .5rem; align-items: center; }
.repeat-row input { flex: 1; min-width: 0; }
.repeat-remove { flex: none; display: inline-grid; place-items: center; width: var(--control-h); height: var(--control-h); box-sizing: border-box; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.repeat-remove:hover { color: var(--red); border-color: #e2b4b0; background: var(--red-bg); }
fieldset.repeat > small { display: block; margin-top: .4rem; color: var(--muted); font-size: .85rem; }

/* Erscheinungsbild */
#erscheinungsbild { margin-top: 2rem; scroll-margin-top: 72px; }
.brand-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.25rem; }
.brand-slot { min-width: 0; }
.brand-preview { display: grid; place-items: center; height: 96px; margin-bottom: .75rem; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface-2); padding: .75rem; }
.brand-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-preview-icon img { width: 64px; height: 64px; border-radius: 14px; }
.brand-preview-favicon img { width: 32px; height: 32px; }

/* Fehlerseiten */
.error-box { max-width: 560px; margin: 2rem auto; text-align: center; }
.plain-box .error-box { margin: .5rem auto 0; }
.error-code { display: inline-block; min-width: 4.5rem; padding: .3rem .9rem; margin-bottom: .75rem; border-radius: 999px; background: var(--red-bg); color: var(--red); font-weight: 700; font-size: 1.05rem; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.error-code.soft { background: var(--grey-bg); color: var(--grey); }
.error-box h1 { margin: 0 0 .5rem; font-size: 1.45rem; }
.error-box p { margin: 0 0 .75rem; color: var(--muted); }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: 1.25rem; }
.error-ref { display: inline-block; margin-top: .25rem; font-family: var(--mono); font-size: .85rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: .15rem .5rem; color: var(--text); }
.error-detail { text-align: left; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: .78rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: .75rem; max-height: 50vh; overflow: auto; margin-top: 1rem; }
.qr img { width: 200px; height: 200px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 6px; }

/* Tablet-Erfassung */
.tile-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.tile { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: var(--text); }
.tile:hover { border-color: var(--accent); }
.tile strong { display: block; margin-bottom: .2rem; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { display: none; position: fixed; inset: 56px 0 0 0; z-index: 20; height: auto; }
    .sidebar.open { display: block; }
    .nav-toggle { display: inline-flex; }
    .content { padding: 1.25rem 1rem 3rem; }
    /* Logo mobil immer mittig zwischen Menü-Symbol und Benutzermenü */
    .topbar { position: sticky; justify-content: space-between; }
    .topbar > .brand { position: absolute; left: 50%; transform: translateX(-50%); max-width: calc(100% - 8rem); justify-content: center; }
    .topbar > .brand .brand-logo { max-width: 100%; }
    .topbar > .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .user-menu { margin-left: 0; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

@media print {
    .topbar, .sidebar, .actions, .btn { display: none !important; }
    .shell { display: block; }
    body { background: #fff; }
}

/* Mitarbeiterdokumente */
.inline-details { display: inline-flex; align-items: center; box-sizing: border-box; min-height: var(--control-h); vertical-align: top; padding: 0 .65rem; margin: 0 .5rem 0 0; }
.inline-details:not([open]) { height: var(--control-h); }
.inline-details[open] { display: block; height: auto; padding: .45rem .65rem; margin: 0 0 .5rem; max-width: 360px; }
.inline-details summary { font-weight: 500; font-size: .84rem; color: var(--accent); line-height: 1.1; }
tr.muted td { color: var(--muted); }
.auth-foot { margin: 1.25rem 0 0; }

/* Gültiges Dokument mit Freigabe */
.doc-current { border-left: 4px solid var(--green); }
.doc-current.overdue { border-left-color: var(--red); }
.doc-current-head { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: flex-start; }
.doc-current-head > div { min-width: 0; }
.doc-extend[open] { max-width: 420px; }
.notice.retired { background: var(--grey-bg); border-color: var(--line); color: var(--text); display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }

/* Text-Dokumente (Markdown) */
.doc-current.draft { border-left-color: var(--yellow); }
.doc-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.doc-actions .inline-details { margin: 0; }
.doc-new { margin: .5rem 0 1rem; }
.md-input { font-family: var(--mono); font-size: .9rem; line-height: 1.55; min-height: 50vh; }
.md-body { max-width: 860px; line-height: 1.6; }
.md-body h1 { font-size: 1.5rem; margin: .25rem 0 1rem; }
.md-body h2 { font-size: 1.2rem; margin: 1.6rem 0 .5rem; color: var(--accent); }
.md-body h3 { font-size: 1.02rem; margin: 1.2rem 0 .4rem; }
.md-body p, .md-body ul, .md-body ol { margin: 0 0 .8rem; }
.md-body li { margin-bottom: .25rem; }
.md-body table { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; font-size: .92rem; }
.md-body th, .md-body td { border: 1px solid var(--line); padding: .4rem .6rem; text-align: left; vertical-align: top; }
.md-body th { background: var(--surface-2); }
.md-body blockquote { margin: .5rem 0 1rem; padding: .4rem .9rem; border-left: 3px solid var(--accent); background: var(--accent-soft); }
.md-body code { font-size: .88em; }
@media print { .md-body { border: 0; padding: 0; } }

/* Gruppierte Formularfelder (z. B. je Kühlschrank Ist/Min/Max) */
fieldset.field-group { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem .1rem; margin: 0 0 1rem; }
fieldset.field-group legend { padding: 0 .35rem; font-weight: 600; font-size: .92rem; color: var(--accent); }
fieldset.field-group .form-row { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }

/* Schmale Bildschirme: lange Beschriftungen dürfen umbrechen, Mindesthöhe bleibt */
@media (max-width: 600px) {
    .btn, button.btn, .btn-small, button.btn-small, a.btn-small { white-space: normal; height: auto; min-height: var(--control-h); padding: .35rem .85rem; text-align: center; }
}

/* Unterschrift */
.sign-form { max-width: 760px; }
.signature-pad { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; margin: 1rem 0; }
.signature-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.signature-pad canvas { display: block; width: 100%; height: 220px; border: 1px dashed #9aa7a0; border-radius: 6px; background: #fff; touch-action: none; cursor: crosshair; }
.signature-error { color: var(--red); margin: .5rem 0 0; }
.nav-count { display: inline-block; min-width: 1.4em; padding: 0 .4em; margin-left: .35em; border-radius: 1em; background: var(--red); color: #fff; font-size: .8em; text-align: center; line-height: 1.5; }
@media (max-width: 600px) { .signature-pad canvas { height: 180px; } }
.sign-text { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .75rem; max-height: 50vh; overflow: auto; }
.sign-text > :last-child { margin-bottom: 0; }
.doc-sign-actions { margin: .75rem 0 1rem; }
body.auth .auth-foot { text-align: center; }
.sign-sheet { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .5rem 0 .75rem; }
.sign-sheet input[type=month], .sign-sheet .fp-alt { width: 11rem; }

/* Auswahl „ein Datum / ein Zeitraum“ */
.field-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.segmented { display: inline-flex; vertical-align: top; box-sizing: border-box; height: var(--control-h); border: 1px solid #c5ccc6; border-radius: 6px; overflow: hidden; background: var(--surface); line-height: 1; }
.segmented label { position: relative; display: inline-flex; align-items: center; height: 100%; margin: 0; padding: 0 1rem; font-size: .92rem; cursor: pointer; user-select: none; }
.segmented label + label { border-left: 1px solid #c5ccc6; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segmented label:has(input:focus-visible) { outline: 3px solid rgba(31, 111, 92, .3); outline-offset: -3px; }
.show-contents:not([hidden]) { display: contents; }

/* Kalender (flatpickr) im Stil der Seite */
input.fp-alt { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235d6b64' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .7rem center; background-size: 16px 16px; padding-right: 2.2rem !important; cursor: pointer; }
.flatpickr-calendar { font-family: var(--font); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(16, 24, 40, .12); }
.flatpickr-calendar.arrowTop::before, .flatpickr-calendar.arrowBottom::before { border-bottom-color: var(--line); }
.flatpickr-months .flatpickr-month, .flatpickr-current-month .flatpickr-monthDropdown-months, .flatpickr-current-month input.cur-year { color: var(--text); fill: var(--text); font-weight: 600; }
.flatpickr-current-month { font-size: 1rem; }
.flatpickr-months .flatpickr-prev-month:hover svg, .flatpickr-months .flatpickr-next-month:hover svg { fill: var(--accent); }
span.flatpickr-weekday { color: var(--muted); font-weight: 600; font-size: .8rem; }
.flatpickr-day { border-radius: 6px; color: var(--text); }
.flatpickr-day:hover, .flatpickr-day:focus { background: var(--accent-soft); border-color: var(--accent-soft); }
.flatpickr-day.today { border-color: var(--accent); }
.flatpickr-day.today:hover { background: var(--accent-soft); color: var(--text); }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.startRange, .flatpickr-day.endRange { background: var(--accent); border-color: var(--accent); color: #fff; }
.flatpickr-day.flatpickr-disabled, .flatpickr-day.flatpickr-disabled:hover, .flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay { color: #b8c0bb; }
.flatpickr-time input, .flatpickr-time .flatpickr-am-pm { font-family: var(--font); color: var(--text); }
.flatpickr-time input:hover, .flatpickr-time input:focus { background: var(--accent-soft); }
.flatpickr-monthSelect-month { border-radius: 6px; }
.flatpickr-monthSelect-month.selected, .flatpickr-monthSelect-month.selected:hover { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.flatpickr-monthSelect-month.today { border-color: var(--accent); }
.flatpickr-monthSelect-month:hover { background: var(--accent-soft); }

/* Scrollleisten: schmal, im Grau der Seite, ohne Pfeile */
/* Firefox (kennt ::-webkit-scrollbar nicht); Chrome/Safari/Edge nutzen die Regeln darunter, die Pfeile ausblenden */
@supports not selector(::-webkit-scrollbar) {
    * { scrollbar-width: thin; scrollbar-color: #c3cbc5 transparent; }
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9d0cb; border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #9fa9a3; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-corner { background: transparent; }
/* Monats- und Jahresauswahl im Kalenderkopf nicht wie Formularfelder darstellen */
.flatpickr-calendar input.cur-year, .flatpickr-calendar select.flatpickr-monthDropdown-months {
    height: auto !important; line-height: inherit !important; border: 0 !important; background: transparent !important; box-shadow: none; margin: 0;
    font: inherit; font-weight: 600; color: var(--text); }
.flatpickr-calendar select.flatpickr-monthDropdown-months { -webkit-appearance: menulist; appearance: auto; width: auto !important; padding: 0 .1rem !important; }
.flatpickr-calendar input.cur-year { width: 4.2ch !important; padding: 0 0 0 .4ch !important; box-sizing: content-box; }
.flatpickr-current-month { display: flex !important; align-items: center; justify-content: center; gap: .35rem; padding-top: 4px !important; }
.flatpickr-calendar input.cur-year, .flatpickr-calendar select.flatpickr-monthDropdown-months { font-weight: 600 !important; font-size: .98rem !important; color: var(--text) !important; border-radius: 6px !important; }
.flatpickr-calendar select.flatpickr-monthDropdown-months { padding: .15rem .35rem !important; }
.flatpickr-calendar select.flatpickr-monthDropdown-months:hover, .flatpickr-current-month .numInputWrapper:hover { background: var(--accent-soft) !important; }
.flatpickr-current-month .numInputWrapper { width: 7.2ch; border-radius: 6px; padding: .15rem 0; }
.flatpickr-calendar input.cur-year { width: 4.6ch !important; padding: 0 0 0 .5ch !important; cursor: pointer; }
.flatpickr-calendar .numInputWrapper span { border: 0; opacity: .55; width: 16px; padding: 0 4px; }
.flatpickr-calendar .numInputWrapper span:hover { background: transparent; opacity: 1; }
.flatpickr-current-month .numInputWrapper span.arrowUp:after { border-bottom-color: var(--accent); }
.flatpickr-current-month .numInputWrapper span.arrowDown:after { border-top-color: var(--accent); }
.flatpickr-calendar input.cur-year:focus, .flatpickr-calendar select.flatpickr-monthDropdown-months:focus { outline: 2px solid rgba(31, 111, 92, .3); border-radius: 4px; }
.print-hint { margin: -.4rem 0 .9rem; color: var(--muted); }

/* Sortierbare Tabellenköpfe */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable::after { content: ""; display: inline-block; width: .7em; height: .8em; margin-left: .4em; vertical-align: .05em; opacity: .25;
    background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 14'%3E%3Cpath d='M5 0l4 5H1zM5 14l4-5H1z' fill='%235d6b64'/%3E%3C/svg%3E"); }
th.sortable:hover { color: var(--text); }
th.sortable:hover::after { opacity: .6; }
th.sortable[aria-sort="ascending"]::after { opacity: 1; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 14'%3E%3Cpath d='M5 2l4 6H1z' fill='%231f6f5c'/%3E%3C/svg%3E"); }
th.sortable[aria-sort="descending"]::after { opacity: 1; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 14'%3E%3Cpath d='M5 12l4-6H1z' fill='%231f6f5c'/%3E%3C/svg%3E"); }
th.sortable:focus-visible { outline: 3px solid rgba(31, 111, 92, .3); outline-offset: -3px; }
