/* ==========================================================================
   Prüfprotokoll – Stylesheet (Design wie Boxen-/Silo-App)
   Layout: Kopfleiste mit Warnstreifen, Inhalt in einer Spalte bis 1200 px,
   auf dem Handy feste Tab-Leiste unten (Übersicht / Neu / Protokoll / …).
   Farbwelt der Lagerverwaltung: Navy, Cyan, Signalgelb.
   Schriften lokal eingebunden (keine Verbindung zu Google, DSGVO).
   ========================================================================== */

@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/space-grotesk-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/space-grotesk-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

:root {
    --bg: #eef2f6;
    --surface: #ffffff;
    --surface-2: #f4f7fa;
    --line: #d5dde7;
    --line-strong: #b9c5d3;
    --fg: #13233a;
    --muted: #5a6b80;
    --navy: #13233a;
    --navy-2: #1c3150;
    --on-navy: #e6eef7;
    --accent: #0b7f97;
    --accent-strong: #08657a;
    --accent-soft: #e2f3f6;
    --on-accent: #ffffff;
    --signal: #f2c230;
    --good: #1d7f52;
    --good-soft: #e3f4ea;
    --warn: #9a5d07;
    --warn-soft: #fff3d9;
    --bad: #b8322b;
    --bad-soft: #fde8e6;
    --pile: #8a97a6;
    --pile-side: #a9b4c1;
    --shadow: 0 1px 2px rgba(19, 35, 58, .06), 0 2px 8px rgba(19, 35, 58, .05);

    --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
    --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-data: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

    --radius: 10px;
    --tabbar-h: 0px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0c1522;
        --surface: #132033;
        --surface-2: #182a42;
        --line: #26395a;
        --line-strong: #34496c;
        --fg: #e4ecf5;
        --muted: #93a6bf;
        --navy: #0a1220;
        --navy-2: #13213a;
        --on-navy: #dfe8f3;
        --accent: #3cc3dc;
        --accent-strong: #67d4e8;
        --accent-soft: #10303c;
        --on-accent: #06131f;
        --good: #49c48a;
        --good-soft: #10301f;
        --warn: #f0b04a;
        --warn-soft: #33260c;
        --bad: #f0766d;
        --bad-soft: #3a1714;
        --pile: #6e7f95;
        --pile-side: #8798ad;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent-strong); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 50; }
.skip:focus { left: 1rem; }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; text-wrap: balance; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.4rem, 3.2vw, 1.85rem); font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--font-data); font-size: .92em; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: .05rem .35rem; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; overflow-x: auto; font-family: var(--font-data); font-size: .82rem; line-height: 1.55; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: .88rem; }
.nowrap { white-space: nowrap; }

/* --- Kopfleiste ----------------------------------------------------------- */
.topbar { background: var(--navy); color: var(--on-navy); position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top, 0px); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1.25rem; }
.hazard { height: 5px; background: repeating-linear-gradient(135deg, var(--signal) 0 12px, #1b1b1b 12px 24px); }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; letter-spacing: -.01em; white-space: nowrap; }
.brand-mark { width: 28px; height: 28px; color: #fff; flex: none; }
.mainnav { display: flex; gap: .25rem; flex: 1; }
.mainnav a { display: inline-flex; align-items: center; gap: .4rem; color: var(--on-navy); text-decoration: none; padding: .45rem .7rem; border-radius: 8px; font-weight: 500; font-size: .93rem; }
.mainnav a:hover { background: var(--navy-2); }
.mainnav a.is-active { background: var(--navy-2); color: #fff; box-shadow: inset 0 -2px 0 var(--signal); }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.userbox { display: flex; align-items: center; gap: .9rem; font-size: .86rem; margin-left: auto; }
.userbox-name small { color: #9fb1c8; margin-left: .25rem; }
.btn-link { color: #fff; }
/* Abmelden ist ein Formular-Knopf (POST mit CSRF-Prüfung), sieht aber wie der bisherige Link aus */
.logout-form { display: inline; margin: 0; }
.userbox button.btn-link { background: none; border: 0; color: #fff; font: inherit; font-weight: 400; text-decoration: underline; cursor: pointer; min-height: 0; padding: 0; width: auto; }
.userbox button.btn-link:hover { background: none; border: 0; color: #fff; }
@media (pointer: coarse) { .userbox button.btn-link { min-height: 40px; padding: 0 .5rem; } }

/* --- Inhalt --------------------------------------------------------------- */
.content { width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 3rem; flex: 1; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1.5rem; margin-bottom: 1.25rem; }
.page-head p { margin: .2rem 0 0; color: var(--muted); max-width: 70ch; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: .9rem 1rem; font-size: .8rem; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); min-width: 0; }
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid-form { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 1.25rem; align-items: start; }
.grid > *, .grid-form > * { min-width: 0; }

/* --- Kennzahlen ----------------------------------------------------------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); }
.stat .val { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .lbl { font-size: .8rem; color: var(--muted); }
.stat.is-warn { border-color: var(--warn); background: var(--warn-soft); }

/* --- Hinweise / Badges ---------------------------------------------------- */
.alert { border-radius: 8px; padding: .8rem 1rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-warning, .alert-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--fg); }
.alert-success { background: var(--good-soft); border-color: var(--good); color: var(--fg); }
.alert-error { background: var(--bad-soft); border-color: var(--bad); color: var(--fg); }
.alert-info { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); }
.alert ul { margin: .35rem 0 0 1.1rem; padding: 0; }
.alert > :last-child { margin-bottom: 0; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 600; border: 1px solid var(--line); color: var(--muted); background: var(--surface); white-space: nowrap; }
.badge-ok { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge-missing { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-off { background: var(--surface-2); color: var(--muted); }
.badge-role-admin { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.badge-role-user { background: var(--surface-2); color: var(--muted); }
.badge-role-haupt { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge-src { color: var(--accent-strong); border-color: var(--accent); }
.is-good { color: var(--good); }
.is-warn { color: var(--warn); }
.is-bad { color: var(--bad); }

/* --- Tabellen ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; font-size: .9rem; vertical-align: top; }
th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
td.num { white-space: nowrap; }
.rt-only-mobile { display: none; }

/* Responsive Tabelle: unter 720 px als Karten mit Feldbezeichnungen */
@media (max-width: 720px) {
    .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
    .rtable thead { position: absolute; left: -9999px; }
    .rtable tr { border-bottom: 1px solid var(--line); padding: .55rem .2rem; }
    .rtable tbody tr:last-child { border-bottom: 0; }
    .rtable td { border: 0; padding: .18rem .6rem; display: flex; gap: .75rem; justify-content: space-between; text-align: right; }
    .rtable td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 600; text-align: left; flex: none; }
    .rtable td.rt-title { font-weight: 600; font-size: 1rem; justify-content: flex-start; text-align: left; }
    .rtable td.rt-title::before { display: none; }
    .rtable td.rt-full { display: block; text-align: left; }
    .rtable td.rt-full::before { display: block; margin-bottom: .2rem; }
    .rtable td:empty, .rtable td.rt-hide-empty:empty { display: none; }
    .rt-only-mobile { display: inline; }
    .rtable td.rt-mobile-hide { display: none; }
}

/* --- Formulare ------------------------------------------------------------ */
.field { margin-bottom: .95rem; min-width: 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 0 1rem; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 .75rem; }
label, .label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .86rem; }
label .u, .label .u { font-weight: 400; color: var(--muted); }
.hint { font-size: .8rem; color: var(--muted); margin: .3rem 0 0; }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=email],
input[type=url], input[type=search], input[type=file], input[type=time], input[type=tel], select, textarea {
    width: 100%;
    min-height: 44px;
    padding: .55rem .7rem;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font: inherit;
    font-size: 16px; /* verhindert Zoom auf iOS */
    color: var(--fg);
    background: var(--surface);
}
input[type=file] { padding: .45rem; font-size: .9rem; }
input[inputmode=decimal] { font-variant-numeric: tabular-nums; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 0; }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 500; min-height: 36px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .4rem 1rem .2rem; margin: 0 0 1rem; min-width: 0; }
legend { font-family: var(--font-display); font-weight: 600; font-size: .95rem; padding: 0 .35rem; }
.field-error input, .field-error select { border-color: var(--bad); }

button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    min-height: 44px;
    background: var(--accent); color: var(--on-accent);
    border: 1px solid var(--accent);
    padding: .55rem 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    font: inherit; font-size: .93rem; font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
button:hover, .btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: var(--bad); filter: brightness(.92); border-color: var(--bad); }
.btn-small { min-height: 34px; padding: .3rem .7rem; font-size: .83rem; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
button[disabled] { opacity: .6; cursor: progress; }
details > summary { cursor: pointer; }
details.edit > summary { list-style: none; display: inline-flex; }
details.edit > summary::-webkit-details-marker { display: none; }
details.edit[open] { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: .75rem; margin-top: .25rem; }
details.edit[open] > summary { margin-bottom: .75rem; }

/* Admin-Reiter */
nav.tabs { display: flex; gap: .25rem; margin-bottom: 1.25rem; border-bottom: 2px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
nav.tabs a { padding: .55rem .9rem; border-radius: 8px 8px 0 0; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; margin-bottom: -2px; border-bottom: 2px solid transparent; }
nav.tabs a:hover { color: var(--fg); }
nav.tabs a.active { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }

/* Filterleiste */
.filters { display: flex; flex-wrap: wrap; gap: .6rem .9rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 150px; flex: 1 1 150px; }
.filters .btn-row { flex: 0 0 auto; }

/* Login */
.login-wrap { max-width: 400px; margin: 3rem auto; }
.login-wrap .card { padding: 1.5rem; }

/* Pager */
.pager { display: flex; gap: .5rem; justify-content: center; align-items: center; margin-top: 1rem; flex-wrap: wrap; }

/* Schlüssel-Anzeige */
.secret { font-family: var(--font-data); font-size: .95rem; background: var(--surface-2); border: 1px dashed var(--accent); border-radius: 8px; padding: .7rem .8rem; overflow-wrap: anywhere; user-select: all; }

/* --------------------------------------------------------------------------
   Tablet / Handy
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
    .grid-form { grid-template-columns: minmax(0, 1fr); }
    .userbox-name { display: none; }
}

@media (max-width: 760px) {
    :root { --tabbar-h: 64px; }
    body { font-size: 15px; }
    .topbar-inner { padding: .5rem 1rem; gap: .75rem; }
    .brand { font-size: 1.02rem; }
    .brand-mark { width: 24px; height: 24px; }

    /* Hauptnavigation als feste Tab-Leiste unten */
    .has-user .mainnav {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
        background: var(--navy); border-top: 3px solid var(--signal);
        padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom, 0px));
        gap: 0; justify-content: space-around;
    }
    .has-user .mainnav a { flex: 1 1 0; flex-direction: column; gap: .15rem; font-size: .7rem; padding: .35rem .2rem; border-radius: 8px; min-width: 0; text-align: center; }
    .has-user .mainnav a.is-active { box-shadow: none; background: var(--navy-2); color: var(--signal); }
    .has-user .mainnav .ico { width: 23px; height: 23px; }
    .has-user .content { padding-bottom: calc(var(--tabbar-h) + 2rem + env(safe-area-inset-bottom, 0px)); }
    .has-user .footer { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }

    .content { padding: 1rem 1rem 2rem; }
    .card { padding: .95rem; }
    .stat .val { font-size: 1.3rem; }
    .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .page-head .actions, .page-head .actions .btn { width: 100%; }
    .filters .field { flex-basis: 140px; }
}

@media (max-width: 420px) {
    .field-row-3 { gap: 0 .5rem; }
    .field-row-3 label { font-size: .78rem; }
    .stat-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .btn-row > .btn, .btn-row > button { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   Prüfprotokoll – eigene Bausteine
   ========================================================================== */
:root {
    --p1: #b8322b; --p1-soft: #fde8e6;
    --p2: #c25e0a; --p2-soft: #fdeedd;
    --p3: #8a6d00; --p3-soft: #fbf3cf;
    --p4: #0b7f97; --p4-soft: #e2f3f6;
    --p5: #5a6b80; --p5-soft: #eef2f6;
}
@media (prefers-color-scheme: dark) {
    :root {
        --p1: #f0766d; --p1-soft: #3a1714;
        --p2: #f39a4e; --p2-soft: #3a240f;
        --p3: #e8c84a; --p3-soft: #332c0c;
        --p4: #3cc3dc; --p4-soft: #10303c;
        --p5: #93a6bf; --p5-soft: #182a42;
    }
}

.w-full { width: 100%; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .75rem; }
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Prioritäts-Kennzeichen */
.prio { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-width: 1.75rem; height: 1.75rem; padding: 0 .45rem; border-radius: 6px; font-family: var(--font-display); font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums; border: 1px solid transparent; white-space: nowrap; }
.prio small { font-family: var(--font-body); font-weight: 600; font-size: .74rem; }
.prio-1 { background: var(--p1); color: #fff; }
.prio-2 { background: var(--p2-soft); color: var(--p2); border-color: var(--p2); }
.prio-3 { background: var(--p3-soft); color: var(--p3); border-color: var(--p3); }
.prio-4 { background: var(--p4-soft); color: var(--p4); }
.prio-5 { background: var(--p5-soft); color: var(--p5); }
.prio-0 { color: var(--muted); border-color: var(--line); }
@media (prefers-color-scheme: dark) { .prio-1 { color: #1a0605; } }

/* Art-Kreuze wie im Buch */
.kreuz { font-family: var(--font-display); font-weight: 700; color: var(--fg); }
th.art, td.art { text-align: center; width: 2.6rem; padding-left: .3rem; padding-right: .3rem; }
th.art span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; }
.art-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.art-chip { display: inline-block; font-size: .74rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.art-chip.st { border-color: var(--bad); color: var(--bad); }
.art-chip.re { border-color: var(--warn); color: var(--warn); }
.art-chip.wa { border-color: var(--good); color: var(--good); }

/* Auswahl-Kacheln (Art und Priorität) im Formular */
.wahl { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
.wahl legend { font-family: var(--font-body); font-size: .86rem; font-weight: 600; padding: 0; margin-bottom: .35rem; }
.wahl-reihe { display: grid; gap: .45rem; }
.wahl-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.wahl-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.wahl-k { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .05rem; min-height: 56px; padding: .45rem .3rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: center; font-weight: 600; font-size: .9rem; margin: 0; }
.wahl-k input { position: absolute; opacity: 0; pointer-events: none; }
.wahl-k .gross { font-family: var(--font-display); font-size: 1.35rem; line-height: 1.1; }
.wahl-k small { font-size: .7rem; font-weight: 500; color: var(--muted); }
.wahl-k:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.wahl-k:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.wahl-k.p1:has(input:checked) { border-color: var(--p1); background: var(--p1); color: #fff; box-shadow: none; }
.wahl-k.p1:has(input:checked) small { color: #fff; }
.wahl-k.p2:has(input:checked) { border-color: var(--p2); background: var(--p2-soft); box-shadow: inset 0 0 0 2px var(--p2); color: var(--p2); }
.wahl-k.p3:has(input:checked) { border-color: var(--p3); background: var(--p3-soft); box-shadow: inset 0 0 0 2px var(--p3); color: var(--p3); }
.wahl-k.p4:has(input:checked) { border-color: var(--p4); background: var(--p4-soft); box-shadow: inset 0 0 0 2px var(--p4); color: var(--p4); }
.wahl-k.p5:has(input:checked) { border-color: var(--p5); background: var(--p5-soft); box-shadow: inset 0 0 0 2px var(--p5); color: var(--fg); }
.wahl-k .haken { display: none; }
.wahl-3 .wahl-k:has(input:checked) .haken { display: inline; }
.wahl.field-error .wahl-k { border-color: var(--bad); }
.wahl-info { min-height: 1.2em; margin: .35rem 0 0; }
.feld-fehler { color: var(--bad); font-size: .8rem; font-weight: 600; margin: .3rem 0 0; }

/* Unterschrift */
.sig-box { position: relative; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff; touch-action: none; overflow: hidden; }
.sig-box canvas { display: block; width: 100%; height: 170px; cursor: crosshair; }
.sig-box .sig-linie { position: absolute; left: 1rem; right: 1rem; bottom: 34px; border-bottom: 1px dashed #b9c5d3; pointer-events: none; }
.sig-box .sig-hinweis { position: absolute; left: 1rem; bottom: 10px; font-size: .75rem; color: #5a6b80; pointer-events: none; }
.sig-box.hat-strich .sig-hinweis { display: none; }
.sig-bild { display: block; max-width: 320px; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .3rem; }
.sig-unter { font-size: .8rem; color: var(--muted); margin-top: .3rem; }

/* Fotos */
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.fotos figure { margin: 0; position: relative; }
.fotos img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.fotos figcaption { font-size: .74rem; color: var(--muted); margin-top: .2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fotos .check { min-height: 28px; font-size: .78rem; }
.foto-vorschau { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.foto-vorschau img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

/* Detailansicht */
.det { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem 1.25rem; margin-bottom: 1rem; }
.det > div { min-width: 0; }
.det > div > span { display: block; font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.det b { font-weight: 600; overflow-wrap: anywhere; }
.textblock { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: .75rem .9rem; margin: 0 0 1rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.textblock.leer { color: var(--muted); font-style: italic; }
.zwei-spalten { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 0 1.25rem; }
.historie { list-style: none; margin: 0; padding: 0; }
.historie > li { padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .86rem; }
.historie > li:last-child { border-bottom: 0; }
.historie .h-kopf { display: flex; flex-wrap: wrap; gap: .2rem .7rem; }
.historie .h-zeit { color: var(--muted); font-variant-numeric: tabular-nums; }
.historie ul { margin: .25rem 0 0 1rem; padding: 0; color: var(--muted); }
.historie ul li { padding: .1rem 0; }
.historie del { color: var(--bad); }
.historie ins { color: var(--good); text-decoration: none; }

/* Liste offener Vorgänge */
.vorgaenge { display: grid; gap: .6rem; }
.vorgang { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .2rem .8rem; align-items: start; padding: .7rem .8rem; border: 1px solid var(--line); border-left: 5px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: inherit; text-decoration: none; }
.vorgang:hover { border-color: var(--line-strong); }
.vorgang.p1 { border-left-color: var(--p1); }
.vorgang.p2 { border-left-color: var(--p2); }
.vorgang.p3 { border-left-color: var(--p3); }
.vorgang.p4 { border-left-color: var(--p4); }
.vorgang.p5 { border-left-color: var(--p5); }
.vorgang .v-titel { font-weight: 600; overflow-wrap: anywhere; }
.vorgang .v-text { font-size: .86rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vorgang .v-meta { font-size: .78rem; color: var(--muted); text-align: right; white-space: nowrap; }
.stat.is-bad { border-color: var(--p1); background: var(--p1-soft); }

/* Balken (häufigste Anlagenteile) */
.balken { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.balken li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .6rem; font-size: .88rem; }
.balken .b-bar { grid-column: 1 / -1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.balken .b-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.balken .b-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Protokoll-Tabelle */
.ptable td.text { min-width: 9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.ptable tr.is-offen td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
.ptable a.zeile { font-weight: 600; text-decoration: none; white-space: nowrap; }
.ptable .sig-ok { color: var(--good); font-weight: 600; font-size: .8rem; }
.zaehler { font-size: .86rem; color: var(--muted); margin: 0 0 .6rem; }
.legende-prio { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .8rem; color: var(--muted); margin-top: .75rem; }
.legende-prio span { display: inline-flex; align-items: center; gap: .35rem; }

@media (max-width: 720px) {
    .ptable td.text { max-width: none; min-width: 0; text-align: left; }
    .ptable td.art { display: none; }
    .ptable td.art-mobil { display: flex; }
    .ptable tr.is-offen td:first-child { box-shadow: none; }
    .ptable tr.is-offen { box-shadow: inset 4px 0 0 var(--warn); }
}
@media (min-width: 1024px) {
    .ptable td.art-mobil { display: none; }
}
@media (max-width: 760px) {
    .wahl-5 { gap: .3rem; }
    .wahl-k { min-height: 54px; padding: .35rem .15rem; }
    .wahl-k small { font-size: .62rem; }
    .vorgang { grid-template-columns: auto minmax(0, 1fr); }
    .vorgang .v-meta { grid-column: 2; text-align: left; }
    .sig-box canvas { height: 150px; }
}

/* Druck: Protokoll im Buchformat */
.nur-druck { display: none; }
@media print {
    @page { size: A4 landscape; margin: 12mm; }
    .topbar, .mainnav, .footer, .btn, button, nav.tabs, .filters, .pager, .skip, .no-print, details.edit { display: none !important; }
    body { background: #fff; color: #000; font-size: 10pt; }
    .content { max-width: none; padding: 0; }
    .card { box-shadow: none; border: 0; padding: 0; break-inside: auto; }
    .ptable tr { break-inside: avoid; }
    .ptable thead { display: table-header-group; }
    body.druckansicht .page-head { display: none; }
    .nur-druck { display: block; }
    .table-wrap { border: 0; overflow: visible; }
    .ptable th, .ptable td { border: 1px solid #555; padding: 4px 5px; font-size: 9pt; color: #000; background: #fff; }
    .ptable th { text-transform: none; letter-spacing: 0; }
    .ptable td.art-mobil { display: none !important; }
    .ptable td.art { display: table-cell !important; }
    .prio { border: 1px solid #000 !important; background: #fff !important; color: #000 !important; }
    .rtable thead { position: static !important; }
    .rtable, .rtable tbody, .rtable tr, .rtable td { display: revert !important; }
    .rtable td::before { display: none !important; }
    a { color: #000; text-decoration: none; }
}
a.stat { color: inherit; text-decoration: none; display: block; }
a.stat:hover { border-color: var(--line-strong); }

/* Schlagworte */
.sw-chips { display: inline-flex; flex-wrap: wrap; gap: .3rem; vertical-align: middle; }
.sw { display: inline-block; font-size: .76rem; font-weight: 600; line-height: 1.5; padding: .05rem .55rem; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); text-decoration: none; white-space: nowrap; }
a.sw:hover { border-color: var(--accent); color: var(--accent-strong); }
.sw-elektrik { background: var(--p3-soft); border-color: transparent; color: var(--p3); }
.sw-mechanik { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }
.sw-bauteil { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }
.sw-fehlerbild { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.sw-massnahme { background: var(--good-soft); border-color: transparent; color: var(--good); }
.sw-kennzeichen { font-family: var(--font-data); background: var(--surface-2); }
.sw-frei { background: var(--surface-2); }
.sw-manuell { border-style: dashed; border-color: var(--line-strong); }
.sw-mehr { color: var(--muted); background: transparent; }
.sw-vorschau { min-height: 44px; display: flex; align-items: center; flex-wrap: wrap; gap: .3rem; padding: .45rem .6rem; border: 1px dashed var(--line-strong); border-radius: 8px; background: var(--surface-2); }
.ptable .sw-zeile { display: block; margin-top: .35rem; }
.sw-legende { display: flex; flex-wrap: wrap; gap: .35rem .8rem; font-size: .78rem; color: var(--muted); margin: .5rem 0 0; }
.sw-wolke { display: flex; flex-wrap: wrap; gap: .4rem; }
.sw-wolke .sw small { font-weight: 500; opacity: .75; margin-left: .25rem; }
.sw-gruppe + .sw-gruppe { margin-top: .9rem; }
.sw-gruppe h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .35rem; }
@media print { .sw { border: 1px solid #999 !important; background: #fff !important; color: #000 !important; font-size: 8pt; } }

/* Anmeldung */
.login-seite .login-wrap { max-width: 440px; }
.pw-feld { position: relative; }
.pw-feld input { padding-right: 3.2rem; }
.pw-auge { position: absolute; right: 2px; top: 2px; bottom: 2px; min-height: 0; width: 46px; padding: 0; background: transparent; border: 0; color: var(--muted); border-radius: 0 7px 7px 0; }
.pw-auge:hover { background: var(--surface-2); color: var(--fg); border: 0; }
.pw-auge.ist-sichtbar { color: var(--accent-strong); }
.pw-auge.ist-sichtbar .ico { stroke-width: 2.4; }
.pw-auge.ist-sichtbar::after { content: ""; position: absolute; left: 12px; right: 12px; top: 50%; height: 2px; background: currentColor; transform: rotate(-35deg); }
.pw-caps { color: var(--warn); font-weight: 600; }
.pw-staerke { position: relative; height: 6px; margin-top: .45rem; border-radius: 3px; background: var(--surface-2); }
.pw-staerke i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--bad); transition: width .2s; }
.pw-staerke span { display: block; position: absolute; top: 8px; left: 0; font-size: .76rem; color: var(--muted); }
.pw-staerke.s2 i { background: var(--warn); }
.pw-staerke.s3 i, .pw-staerke.s4 i, .pw-staerke.s5 i { background: var(--good); }
.pw-staerke + * { margin-top: 1.4rem; }
.login-benutzer { display: grid; gap: .45rem; }
.login-k { flex-direction: row; justify-content: flex-start; gap: .7rem; min-height: 52px; padding: .45rem .7rem; text-align: left; }
.login-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--navy); color: #fff; font-family: var(--font-display); font-weight: 700; }
.login-k:has(input:checked) .login-avatar { background: var(--accent); }
.login-name { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; overflow: hidden; }
.login-name small { font-weight: 500; color: var(--muted); font-family: var(--font-data); font-size: .74rem; }
.login-wahl { margin-bottom: .9rem; }
.login-links { text-align: center; margin: .9rem 0 0; font-size: .9rem; }
.login-sicher { display: flex; gap: .5rem; align-items: flex-start; font-size: .8rem; color: var(--muted); margin: 1.1rem 0 0; padding-top: .9rem; border-top: 1px solid var(--line); }
.login-sicher .ico { width: 18px; height: 18px; margin-top: .05rem; }
.login-sicher.ok .ico { color: var(--good); }
.login-sicher.warn { color: var(--bad); }
.login-liste-loeschen { text-align: center; margin-top: .5rem; }
.btn-link-dunkel { background: none; border: 0; min-height: 0; padding: .2rem; color: var(--muted); font-weight: 500; font-size: .78rem; text-decoration: underline; }
.btn-link-dunkel:hover { background: none; border: 0; color: var(--fg); }
.badge-gesperrt { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.nur-sr, input.nur-sr[type] { position: absolute !important; width: 1px !important; min-width: 0 !important; height: 1px !important; min-height: 0 !important; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0 !important; padding: 0 !important; margin: -1px; }
[hidden] { display: none !important; }
.login-hinweis { margin: 0 0 .8rem; padding: .5rem .7rem; border-radius: 8px; background: var(--surface-2); }
.login-menue { font-size: 1.05rem; font-weight: 600; min-height: 52px; }
.sw-begriff { background: var(--surface); border-color: var(--accent); color: var(--accent-strong); }

/* Elektronische Unterschrift über die Anmeldung */
.esig { display: flex; gap: .7rem; align-items: center; padding: .65rem .8rem; border: 1px solid var(--good); background: var(--good-soft); border-radius: var(--radius); }
.esig .ico { width: 28px; height: 28px; color: var(--good); flex: none; }
.esig > div { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.esig strong { font-size: 1rem; }
.esig span { font-size: .8rem; color: var(--muted); }
.esig-offen { border-style: dashed; border-color: var(--line-strong); background: var(--surface-2); }
.esig-offen .ico { color: var(--muted); }

/* Zeitspannen, offene Dauer, Erledigungsgrad */
.dauer { display: inline-block; font-size: .76rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; border: 1px solid transparent; white-space: normal; line-height: 1.4; margin-top: .15rem; }
.dauer-ok { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.dauer-warn { background: var(--warn-soft); color: var(--warn); }
.dauer-ueber { background: var(--bad); color: #fff; }
.dauer-erledigt { background: var(--good-soft); color: var(--good); }
@media (prefers-color-scheme: dark) { .dauer-ueber { color: #1a0605; } }
.vorgang .v-dauer { grid-column: 2 / -1; }
.fortschritt { list-style: none; display: flex; margin: .2rem 0 .8rem; padding: 0; counter-reset: s; max-width: 460px; }
.fortschritt li { flex: 1; position: relative; text-align: center; font-size: .76rem; color: var(--muted); padding-top: 1.5rem; }
.fortschritt li::before { counter-increment: s; content: counter(s); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--line-strong); font-size: .7rem; line-height: 1.05rem; font-weight: 700; z-index: 1; }
.fortschritt li + li::after { content: ""; position: absolute; top: .6rem; right: 50%; width: 100%; height: 2px; background: var(--line-strong); }
.fortschritt li.fertig::before, .fortschritt li.aktuell::before { background: var(--good); border-color: var(--good); color: #fff; }
.fortschritt li.fertig + li::after, .fortschritt li.aktuell::after { background: var(--good); }
.fortschritt li.aktuell { color: var(--fg); font-weight: 700; }
.grad { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.grad i { display: block; height: 100%; width: 0; }
.g-erledigt { background: var(--good); }
.g-arbeit { background: var(--accent); }
.g-offen { background: var(--warn); }
.grad-legende { display: flex; flex-wrap: wrap; gap: .2rem .9rem; font-size: .76rem; color: var(--muted); margin: .3rem 0 0; }
.grad-legende i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.grad-zeilen { display: grid; gap: .9rem; }
.grad-titel { display: block; font-size: .86rem; margin-bottom: .3rem; }
.grad-titel b { font-family: var(--font-display); font-size: 1.05rem; margin-left: .3rem; }
.grad-auswahl { margin-bottom: .9rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
@media print { .dauer { border: 1px solid #999 !important; background: #fff !important; color: #000 !important; } .grad-auswahl { display: none; } }

/* --- Responsiv-Feinschliff (Version 9) ------------------------------------ */
/* Kleine Tablets im Querformat-Grenzbereich: Navigation enger, damit „Abmelden“ nicht über den Rand ragt */
@media (min-width: 761px) and (max-width: 960px) {
    .topbar-inner { gap: .6rem; padding-left: .75rem; padding-right: .75rem; }
    .mainnav { gap: 0; min-width: 0; }
    .mainnav a { padding: .45rem .5rem; gap: .3rem; font-size: .88rem; }
    .brand { font-size: 1.02rem; }
}
/* Lange Schaltflächentexte auf schmalen Handys umbrechen statt überstehen */
@media (max-width: 480px) {
    button, .btn { white-space: normal; text-align: center; max-width: 100%; }
}
/* Fingerfreundliche Trefferflächen auf Touch-Geräten */
@media (pointer: coarse) {
    .userbox .btn-link { display: inline-flex; align-items: center; min-height: 40px; padding: 0 .5rem; }
    a.sw { min-height: 30px; display: inline-flex; align-items: center; padding: .15rem .65rem; }
    .sw-chips { gap: .4rem; }
    .rtable td a:not(.sw):not(.btn) { display: inline-flex; align-items: center; min-height: 36px; }
    details > summary { padding: .5rem 0; }
    p.muted > a, p.hint > a { display: inline-block; padding: .55rem 0; }
    nav.tabs a { min-height: 44px; display: inline-flex; align-items: center; }
    .brand { min-height: 40px; }
    .card-head > a, .login-links a { display: inline-flex; align-items: center; min-height: 40px; }
}

/* --- Protokoll ohne seitliches Scrollen (Version 10) ---------------------- */
/* Breite Seite für das Protokoll auf großen Bildschirmen */
@media (min-width: 1280px) { .seite-breit .content { max-width: 1600px; } }
.ptable { width: 100%; }
.ptable th { white-space: normal; }
.ptable td.datum { white-space: normal; }
.ptable td.datum small { white-space: nowrap; }
.ptable .spalte-uhrzeit { display: none; }
.ptable td .badge, .ptable td .dauer { white-space: normal; }
.ptable th:nth-child(8), .ptable td:nth-child(8) { min-width: 6rem; }
.ptable td:nth-child(8), .ptable td:nth-child(9) { overflow-wrap: break-word; hyphens: auto; }
/* Druckansicht und Ausdruck behalten die Buchspalte „Uhrzeit“ */
body.druckansicht .ptable .spalte-uhrzeit { display: table-cell; }
body.druckansicht .ptable .uhr-inline { display: none; }
@media print {
    .ptable td.art-mobil { display: none !important; }
    .ptable .spalte-uhrzeit { display: table-cell !important; }
    .ptable .uhr-inline { display: none !important; }
}
/* Tablet (721–1023 px): Einträge als Karten wie auf dem Handy statt breiter Tabelle */
@media screen and (min-width: 721px) and (max-width: 1023px) {
    .table-wrap:has(.ptable) { overflow: visible; }
    .ptable, .ptable tbody, .ptable tr, .ptable td { display: block; width: 100%; }
    .ptable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .ptable tr { border-bottom: 1px solid var(--line); padding: .55rem .2rem; }
    .ptable tbody tr:last-child { border-bottom: 0; }
    .ptable td { border: 0; padding: .18rem .8rem; display: flex; gap: .75rem; justify-content: space-between; text-align: right; }
    .ptable td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 600; text-align: left; flex: none; }
    .ptable td.rt-title { font-weight: 600; font-size: 1rem; justify-content: flex-start; text-align: left; }
    .ptable td.rt-title::before { display: none; }
    .ptable td.rt-full { display: block; text-align: left; }
    .ptable td.rt-full::before { display: block; margin-bottom: .2rem; }
    .ptable td:empty, .ptable td.spalte-uhrzeit { display: none; }
    .ptable .rt-only-mobile { display: inline; }
    .ptable td.rt-mobile-hide, .ptable td.art { display: none; }
    .ptable td.art-mobil { display: flex; }
    .ptable td.text { min-width: 0; }
    .ptable tr.is-offen td:first-child { box-shadow: none; }
    .ptable tr.is-offen { box-shadow: inset 4px 0 0 var(--warn); }
}
@media (max-width: 720px) { .ptable td.spalte-uhrzeit { display: none; } }
/* Kleine Laptops (1024–1279 px): engere Spalten, damit die Tabelle ohne Querscrollen passt */
@media screen and (min-width: 1024px) and (max-width: 1279px) {
    .ptable th, .ptable td { padding-left: .45rem; padding-right: .45rem; }
    .ptable td.text { min-width: 7rem; }
    body.druckansicht .ptable td.text { min-width: 6.5rem; overflow-wrap: break-word; }
    body.druckansicht .ptable td.datum small { display: none; }
    .ptable .sw { font-size: .7rem; padding-left: .4rem; padding-right: .4rem; }
    body.druckansicht .ptable .spalte-uhrzeit { padding-left: .3rem; padding-right: .3rem; }
    .ptable td.datum small { white-space: normal; }
    .ptable th:nth-child(8), .ptable td:nth-child(8) { min-width: 0; }
    .ptable .sig-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* --- Tabellen ohne seitliches Scrollen (Version 11) ------------------------ */
/* Admin-Reiter umbrechen statt seitlich zu scrollen */
nav.tabs { flex-wrap: wrap; overflow-x: visible; row-gap: 0; }
/* Spaltenköpfe und Werte dürfen umbrechen */
.table-wrap th { white-space: normal; }
.table-wrap td.num { white-space: normal; }
.table-wrap td { overflow-wrap: break-word; }
.table-wrap td a[href^="mailto:"], .table-wrap td .mail { overflow-wrap: anywhere; }
@media (max-width: 420px) { .table-wrap th, .table-wrap td { padding-left: .45rem; padding-right: .45rem; } }
/* Tabellen in schmalen Karten (z. B. Übersicht „Zuletzt eingetragen“, zweispaltige Admin-Seiten)
   werden zu Karten, sobald der Platz nicht reicht – unabhängig von der Bildschirmbreite */
.table-wrap:has(> .rtable) { container-type: inline-size; }
@media screen {
@container (max-width: 880px) {
    .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
    .rtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .rtable tr { border-bottom: 1px solid var(--line); padding: .55rem .2rem; }
    .rtable tbody tr:last-child { border-bottom: 0; }
    .rtable td { border: 0; padding: .18rem .6rem; display: flex; gap: .75rem; justify-content: space-between; text-align: right; }
    .rtable td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 600; text-align: left; flex: none; }
    .rtable td.rt-title { font-weight: 600; font-size: 1rem; justify-content: flex-start; text-align: left; }
    .rtable td.rt-title::before { display: none; }
    .rtable td.rt-full { display: block; text-align: left; }
    .rtable td.rt-full::before { display: block; margin-bottom: .2rem; }
    .rtable td:empty { display: none; }
    .rtable td.rt-mobile-hide { display: none; }
}
}
/* Codebeispiele umbrechen statt seitlich scrollen */
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Admin-Reiter bei wenig Platz als umbrechende Schaltflächen */
@media (max-width: 900px) {
    nav.tabs { border-bottom: 0; gap: .4rem; }
    nav.tabs a { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 0; padding: .45rem .8rem; background: var(--surface); }
    nav.tabs a.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
}
/* Übersicht „Zuletzt eingetragen“: kompakte Karte mit 3 Zeilen je Eintrag statt Tabelle */
@media screen {
@container (max-width: 880px) {
    .ltable tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: .7rem; row-gap: .1rem; align-items: center; padding: .55rem .1rem; }
    .ltable td { display: block; width: auto; padding: 0 .5rem; text-align: left; }
    .ltable td::before { display: none; }
    .ltable td:nth-child(1) { grid-column: 1; grid-row: 1; }
    .ltable td:nth-child(2) { grid-column: 2; grid-row: 1; overflow-wrap: normal; }
    .ltable td:nth-child(3) { grid-column: 3; grid-row: 1; text-align: right; }
    .ltable td:nth-child(4) { grid-column: 1 / 3; grid-row: 2; color: var(--muted); font-size: .86rem; }
    .ltable td:nth-child(5) { grid-column: 3; grid-row: 2; text-align: right; color: var(--muted); font-size: .86rem; }
    .ltable td:nth-child(6) { grid-column: 1 / -1; grid-row: 3; }
    .ltable td:nth-child(6) .badge, .ltable td:nth-child(6) .dauer { margin-top: .15rem; }
}
}
/* Rechte-Übersicht (Admin): bei wenig Platz je Recht eine Zeile mit den drei Rollen nebeneinander */
@media screen {
@container (max-width: 880px) {
    .rechte tr { display: flex; flex-wrap: wrap; column-gap: 1rem; row-gap: .1rem; }
    .rechte td.rt-title { flex: 1 0 100%; font-size: .95rem; }
    .rechte td:not(.rt-title) { display: inline-flex; width: auto; gap: .35rem; padding-right: 0; }
    .rechte td:not(.rt-title)::before { font-weight: 500; }
}
}
/* Rollen & Rechte (Version 13) */
.rechte-liste { display: grid; gap: .15rem; padding-bottom: .5rem; }
.rechte-liste[disabled] { opacity: .75; }
.check.recht { align-items: flex-start; min-height: 0; padding: .3rem 0; }
.check.recht input { margin-top: .1rem; }
.check.recht small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; line-height: 1.35; }
.rolle-karte:target { outline: 2px solid var(--accent); outline-offset: 2px; }
.badge-role-eigen { background: var(--p3-soft); color: var(--p3); border-color: transparent; }

/* Anlagenteil: gestufte Auswahl (Version 14) */
.at-wahl .at-stufen:not([hidden]) { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 0 1rem; }
.at-wahl [hidden] { display: none !important; }
.at-baum { list-style: none; margin: 0; padding: 0; }
.at-baum ul { list-style: none; margin: .2rem 0 .2rem 1.1rem; padding: 0 0 0 .7rem; border-left: 2px solid var(--line); }
.at-baum li { margin: .15rem 0; }
.at-zeile { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; padding: .25rem 0; }
.at-zeile .at-name { font-weight: 600; }
.at-zeile .at-ebene-3 { font-weight: 500; }
.at-zeile.is-inaktiv .at-name { color: var(--muted); text-decoration: line-through; }
.at-bereich > summary { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; padding: .35rem 0; }
.at-bereich { border-bottom: 1px solid var(--line); padding: .3rem 0; }
.at-bereich:last-child { border-bottom: 0; }
@media (pointer: coarse) { a.badge { min-height: 32px; display: inline-flex; align-items: center; padding: .2rem .7rem; } }
@media (pointer: coarse) { .balken .b-name a { display: inline-block; padding: .35rem 0; } }
