:root {
    /* ReglerLab-Tokens */
    --side: #0f172a;
    --card: #1e293b;
    --card-border: #334155;
    --card-hover: #2d3f55;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --bar: #e2e8f0;
    --btn: #334155;
    --btn-hover: #475569;
    --canvas: #f8fafc;
    --grid: #e6ebf2;
    --accent: #2563eb;
    --accent-hover: #4f46e5;
    --danger: #dc2626;
    --ok: #15803d;
    --side-w: 250px;
    --font: Helvetica, Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    /* Hauptbereich (hell) */
    --ink: #111111;
    --ink-soft: #64748b;
    --surface: #ffffff;
    --surface-strong: #ffffff;
    --line: #dbe2ea;
    --radius: 8px;
    --radius-lg: 10px;
    /* Kompatibilitaet: bisherige Namen, auch in Inline-Styles verwendet */
    --bg: var(--canvas);
    --brand: var(--accent);
    --brand-2: #d97706;
    --brand-3: var(--accent);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.10);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--canvas);
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell {
    width: min(1460px, 96vw);
    margin: 0 auto;
    padding: 1rem 0 2.5rem;
}
/* Eingeloggt: App-Shell ueber die volle Breite wie bei ReglerLab */
.shell.shell-app {
    width: 100%;
    padding: 0;
}
.app-shell {
    display: grid;
    grid-template-columns: var(--side-w) minmax(0, 1fr);
    gap: 0;
    align-items: start;
    min-height: 100vh;
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem .85rem;
    background: var(--side);
    color: var(--text-light);
    border-right: 1px solid var(--card-border);
}
.brand-block {
    padding: .8rem .9rem;
    border-radius: var(--radius);
    background: var(--card);
    border: 1px solid var(--card-border);
}
.brand {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .01em;
}
.brand-subtitle {
    margin-top: .3rem;
    color: var(--ink-soft);
    font-size: .85rem;
    line-height: 1.45;
}
.sidebar .brand-subtitle { color: var(--text-muted); }
.sidebar-section {
    display: grid;
    gap: .5rem;
}
.sidebar-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.sidebar .sidebar-label { color: var(--text-muted); padding: 0 .35rem; }
.nav {
    display: grid;
    gap: .25rem;
}
.nav a,
.nav .nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .6rem .75rem;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--ink);
    text-decoration: none;
    background: transparent;
    transition: background .15s ease, border-color .15s ease;
}
.nav a:hover,
.nav .nav-link:hover {
    text-decoration: none;
    background: var(--bar);
}
.nav a.active {
    background: var(--bar);
    font-weight: 700;
}
.sidebar .nav a,
.sidebar .nav .nav-link { color: var(--text-light); }
.sidebar .nav a:hover,
.sidebar .nav .nav-link:hover {
    background: var(--card-hover);
    border-color: var(--card-border);
}
.sidebar .nav a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.nav-meta {
    font-size: .72rem;
    color: var(--ink-soft);
    white-space: nowrap;
}
.sidebar .nav-meta { color: rgba(248, 250, 252, 0.75); }
.sidebar-card {
    margin-top: auto;
    padding: .85rem;
    border-radius: var(--radius);
    background: var(--card);
    border: 1px solid var(--card-border);
    color: var(--text-light);
}
.sidebar-card-title {
    font-size: .9rem;
    font-weight: 700;
    margin-bottom: .3rem;
}
.sidebar-card-text {
    color: var(--text-muted);
    font-size: .85rem;
    line-height: 1.5;
}
.sidebar .btn.secondary {
    background: var(--btn);
    border-color: var(--card-border);
    color: var(--text-light);
}
.sidebar .btn.secondary:hover { background: var(--btn-hover); }
.main-panel {
    min-width: 0;
    display: grid;
    gap: 1rem;
    padding: 0 1.5rem 2.5rem;
}
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin: 0 -1.5rem;
    padding: .7rem 1.5rem;
    background: var(--bar);
    border-bottom: 1px solid #cbd5e1;
}
.topbar .brand {
    font-size: 1.1rem;
}
.topbar-actions {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    align-items: center;
}
.mobile-nav-toggle,
.mobile-nav-backdrop,
.mobile-note {
    display: none;
}
/* Hamburger-Icon */
.hamburger-icon {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 20px;
    height: 18px;
    flex-shrink: 0;
}
.hamburger-icon span {
    display: block;
    height: 2px;
    width: 100%;
    background: currentColor;
    border-radius: 2px;
    transition: transform .2s ease, opacity .2s ease;
}
body.nav-open .hamburger-icon span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
body.nav-open .hamburger-icon span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
body.nav-open .hamburger-icon span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}
.mono {
    font-family: var(--mono);
    font-size: .82rem;
    color: var(--ink-soft);
}
.btn, button {
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    padding: .55rem .95rem;
    border-radius: 6px;
    font: inherit;
    font-weight: 600;
    font-size: .92rem;
    line-height: 1.3;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.btn:hover, button:hover {
    background: var(--accent-hover);
    text-decoration: none;
}
.btn.secondary, button.secondary {
    background: #fff;
    color: var(--ink);
    border-color: #cbd5e1;
}
.btn.secondary:hover, button.secondary:hover { background: var(--bar); }
.btn.warning { background: #d97706; color: #fff; }
.btn.warning:hover { background: #b45309; }
.btn.danger, button.danger { background: var(--danger); color: #fff; }
.btn.danger:hover, button.danger:hover { background: #b91c1c; }
.grid {
    display: grid;
    gap: 1rem;
}
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-sm);
}
h1, h2, h3 { margin: .2rem 0 .8rem; line-height: 1.2; }
h1 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
h2 { font-size: 1.22rem; }
h3 { font-size: 1rem; }
label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: .3rem; }
input, select, textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: .5rem .65rem;
    font: inherit;
    background: #fff;
    color: var(--ink);
    margin-bottom: .7rem;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
textarea { min-height: 120px; resize: vertical; }
.pill {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 600;
}
.flash { padding: .7rem .9rem; border-radius: var(--radius); margin-bottom: .5rem; border: 1px solid transparent; border-left-width: 4px; background: #fff; }
.flash.success { background: #f0fdf4; border-color: #bbf7d0; border-left-color: var(--ok); }
.flash.error { background: #fef2f2; border-color: #fecaca; border-left-color: var(--danger); }
.flash.warning { background: #fffbeb; border-color: #fde68a; border-left-color: #d97706; }
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.column { background: var(--grid); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: .8rem; }
.task { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: .7rem; margin-bottom: .6rem; background: #fff; box-shadow: var(--shadow-sm); }
.split {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .7rem;
}
.small { font-size: .84rem; color: var(--ink-soft); line-height: 1.45; }
.list { margin: .4rem 0 0; padding: 0; list-style: none; }
.list li { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.section-head {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    align-items: end;
    margin-bottom: .8rem;
}
.section-kicker {
    font-family: var(--mono);
    font-size: .74rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: .3rem;
}
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, .9fr);
    gap: 1rem;
    align-items: stretch;
}
.hero-panel {
    padding: 1.3rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--side);
    color: var(--text-light);
    border-color: var(--card-border);
}
.hero-panel .small,
.hero-panel .section-kicker,
.hero-panel .brand-subtitle { color: var(--text-muted); }
.hero-panel .btn.secondary {
    background: var(--btn);
    border-color: var(--card-border);
    color: var(--text-light);
}
.hero-panel .btn.secondary:hover { background: var(--btn-hover); }
.hero-panel a:not(.btn) { color: #93c5fd; }
.hero-actions .pill { align-self: center; }
.hero-panel .pill { background: var(--card); border-color: var(--card-border); color: #93c5fd; }
.hero-copy {
    max-width: 60ch;
}
.hero-actions {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .9rem;
}
.stat-card {
    padding: .95rem 1rem;
    border-radius: var(--radius-lg);
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}
.stat-label {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-soft);
    margin-bottom: .35rem;
}
.stat-value {
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.1;
}
.stat-note {
    margin-top: .3rem;
    color: var(--ink-soft);
    font-size: .83rem;
}
.group-card {
    display: grid;
    gap: .85rem;
    min-height: 100%;
}
.group-card-top {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    align-items: start;
}
.group-progress {
    display: grid;
    gap: .35rem;
}
.progress-bar {
    height: 10px;
    border-radius: 999px;
    background: var(--grid);
    overflow: hidden;
}
.progress-bar > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
}
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #fff;
}
.report-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}
.report-table th,
.report-table td {
    text-align: left;
    padding: .78rem .85rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    font-size: .92rem;
}
.report-table th {
    font-family: var(--mono);
    font-size: .76rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-soft);
    background: var(--canvas);
}
.report-table tr:last-child td { border-bottom: 0; }
.report-layout {
    display: grid;
    gap: 1rem;
}
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
}
.report-meta {
    display: grid;
    gap: .35rem;
}
.screen-only { display: initial; }
.print-only { display: none; }
/* ── Programmablaufplan (PAP-Editor im iframe, pm-pap.js) ── */
.pap-preview {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .75rem;
    background: #fff;
}
.pap-preview img { display: block; max-width: 100%; height: auto; }
.pap-legacy { margin-top: .8rem; }
.pap-legacy summary { cursor: pointer; font-weight: 600; margin-bottom: .5rem; }
.pap-dialog {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--side);
}
.pap-dialog[open] { display: flex; flex-direction: column; }
.pap-dialog-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .5rem 1rem;
    background: var(--side);
    color: var(--text-light);
}
.pap-dialog-status { flex: 1; color: var(--text-muted); font-size: .85rem; }
.pap-dialog iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.task-document-card {
    display: grid;
    gap: 1rem;
}
.document-textarea {
    min-height: 380px;
    font-family: var(--mono);
    line-height: 1.55;
}
.doc-help-trigger {
    font-size: .85rem;
    padding: .45rem .9rem;
    margin-bottom: .7rem;
}
.document-preview {
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: #fff;
    overflow-x: auto;
}
.document-preview-empty {
    margin: 0;
    color: var(--ink-soft);
}
.doc-content {
    display: grid;
    gap: .9rem;
    line-height: 1.7;
}
.doc-content > * {
    margin: 0;
}
.doc-content h2,
.doc-content h3,
.doc-content h4 {
    margin: .3rem 0 0;
}
.doc-list {
    margin: 0;
    padding-left: 1.25rem;
}
.doc-code {
    margin: 0;
    padding: .95rem 1rem;
    border-radius: var(--radius);
    background: var(--side);
    color: #f8fafc;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: .88rem;
    line-height: 1.6;
}
.doc-inline-code {
    padding: .12rem .4rem;
    border-radius: 4px;
    background: var(--line);
    font-family: var(--mono);
    font-size: .92em;
}
.doc-quote {
    margin: 0;
    padding: .85rem 1rem;
    border-left: 4px solid var(--brand-3);
    border-radius: 0 16px 16px 0;
    background: rgba(37, 99, 235, 0.08);
}
.doc-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}
.doc-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.doc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
    line-height: 1.5;
}
.doc-table th,
.doc-table td {
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
.doc-table th {
    background: var(--canvas);
    font-weight: 700;
}
.doc-table tbody tr:last-child td { border-bottom: 0; }
.doc-table .doc-align-left { text-align: left; }
.doc-table .doc-align-center { text-align: center; }
.doc-table .doc-align-right { text-align: right; }
.doc-preview-status.is-dirty {
    background: #fffbeb;
    border-color: #fde68a;
    color: #b45309;
}
.math-inline,
.math-block {
    overflow-x: auto;
}
.math-block {
    padding: .85rem 1rem;
    border-radius: var(--radius);
    background: rgba(217, 119, 6, 0.08);
    border: 1px solid rgba(217, 119, 6, 0.14);
}
.file-entry-actions {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    margin-top: .55rem;
    align-items: center;
}
.embed-snippet {
    padding: .5rem .7rem;
    border-radius: 6px;
    background: rgba(23, 33, 43, 0.06);
    border: 1px solid var(--line);
    font-family: var(--mono);
    font-size: .78rem;
    overflow-x: auto;
}
/* ── Formatierungshilfe-Modal ── */
.doc-help-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 8000;
    background: rgba(15, 23, 42, 0.6);
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
}
.doc-help-overlay.active { display: flex; }
.doc-help-inner {
    background: var(--surface-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-width: 680px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    padding: 1.6rem;
    border: 1px solid var(--line);
}
.doc-help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.1rem;
}
.doc-help-header h3 { margin: 0; }
.doc-help-close {
    background: none;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    padding: .25rem .7rem;
    color: var(--ink-soft);
    box-shadow: none;
    line-height: 1.5;
}
.doc-help-close:hover { background: rgba(23,33,43,.06); }
.doc-help-section {
    font-family: var(--mono);
    font-size: .74rem;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin: 1.1rem 0 .4rem;
}
.doc-help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
    margin-bottom: .5rem;
}
.doc-help-table th,
.doc-help-table td {
    text-align: left;
    padding: .55rem .65rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
.doc-help-table th {
    font-family: var(--mono);
    font-size: .73rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-soft);
    background: var(--canvas);
}
.doc-help-table tr:last-child td { border-bottom: 0; }
.doc-help-table code {
    font-family: var(--mono);
    font-size: .85em;
    background: rgba(23,33,43,.07);
    padding: .1rem .38rem;
    border-radius: 8px;
    white-space: nowrap;
}
/* ── Sidebar ein-/ausklappen (Desktop) ── */
.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .5rem .6rem;
    flex-shrink: 0;
}
.topbar-title { flex: 1; min-width: 0; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
@media (min-width: 1025px) {
    .app-shell { transition: grid-template-columns .2s ease; }
    body.sidebar-hidden .app-shell { grid-template-columns: 0 minmax(0, 1fr); }
    body.sidebar-hidden .sidebar {
        visibility: hidden;
        padding-left: 0;
        padding-right: 0;
        border-right: 0;
        overflow: hidden;
    }
}
/* ── Seitenaktionen & Formular-Overlays (pm-dialogs.js) ── */
.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    justify-content: flex-end;
}
.page-actions[hidden] { display: none; }
.grid.grid-collapsed { grid-template-columns: minmax(0, 1fr); }
.task-card-actions { display: inline-flex; gap: .4rem; flex-wrap: wrap; }
/* Kanban-Karte: Aktionen oben, Status-Auswahl in eigener Zeile darunter */
.task > .split { flex-wrap: wrap; }
.task > .split > form { flex: 1 1 100%; }
.task > .split > form select { margin-bottom: 0; }
.pm-dialog {
    width: min(620px, calc(100vw - 2rem));
    max-height: calc(100vh - 3rem);
    padding: 0;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
    overflow: hidden;
}
.pm-dialog[open] { display: flex; flex-direction: column; }
.pm-dialog::backdrop { background: rgba(15, 23, 42, 0.55); }
.pm-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1rem;
    background: var(--side);
    color: var(--text-light);
}
.pm-dialog-head h2 { margin: 0; font-size: 1.05rem; }
.pm-dialog-close {
    background: var(--btn);
    color: var(--text-light);
    border: 1px solid var(--card-border);
    padding: .3rem .65rem;
    line-height: 1.2;
}
.pm-dialog-close:hover { background: var(--btn-hover); }
.pm-dialog-body {
    padding: 1rem 1.1rem 1.1rem;
    overflow-y: auto;
}
/* Inhalt wird unveraendert uebernommen: Kartenrahmen, erste Ueberschrift und Trennlinie sind im Dialog ueberfluessig */
.pm-dialog-body > .card {
    border: 0;
    box-shadow: none;
    padding: 0;
    background: transparent;
}
.pm-dialog-body > [data-dialog] > h2:first-child,
.pm-dialog-body > [data-dialog] > h3:first-child,
.pm-dialog-body > [data-dialog] > hr:first-child,
.pm-dialog-body > [data-dialog] > hr:first-child + h3 { display: none; }
.pm-dialog-body > [data-dialog] > form:first-of-type { margin-top: 0 !important; }
/* ── Laborbuch ── */
.lab-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.lab-toolbar-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .75rem;
    margin: 0;
}
.lab-toolbar-form label { margin: 0; }
.lab-toolbar-form select { width: auto; margin: 0; }
.lab-entries { display: grid; gap: 1rem; }
.lab-entry { display: grid; gap: .9rem; border-left: 3px solid var(--accent); scroll-margin-top: 1rem; }
.lab-entry:target { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25); }
.lab-entry-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}
.lab-entry-head h2 { margin: .1rem 0 .25rem; }
.lab-entry-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.lab-entry-actions form { margin: 0; }
.lab-files, .lab-comments {
    display: grid;
    gap: .6rem;
    padding-top: .8rem;
    border-top: 1px solid var(--line);
}
.lab-file { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.lab-file-thumb {
    display: block;
    max-width: 220px;
    max-height: 160px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
}
.lab-file-meta { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.lab-file-meta form, .lab-comment-head form { margin: 0; }
.lab-mini-btn { padding: .25rem .6rem; font-size: .78rem; }
.lab-comment {
    padding: .65rem .8rem;
    border-radius: var(--radius);
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}
.lab-comment-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .3rem; }
.lab-comment-form textarea { min-height: 70px; }
.lab-textarea { min-height: 220px; }
/* ── Druck-Bereich (PDF-Export) ── */
#doc-print-area { display: none; }
@media (max-width: 1180px) {
    .shell {
        width: min(1460px, 98vw);
    }
    .shell.shell-app { width: 100%; }
    .app-shell {
        grid-template-columns: 230px minmax(0, 1fr);
    }
}
@media (max-width: 1024px) {
    .sidebar-toggle { display: none; }
    .pm-dialog {
        width: calc(100vw - 1rem);
        max-height: calc(100vh - 1rem);
    }
    body.nav-open {
        overflow: hidden;
    }
    .shell,
    .shell.shell-app {
        width: min(100%, 100vw);
        padding: .75rem .7rem 2rem;
    }
    .main-panel { padding: 0; }
    .app-shell {
        grid-template-columns: 1fr;
    }
    .mobile-nav-toggle {
        display: inline-flex;
        align-items: center;
        gap: .5rem;
        width: max-content;
        margin: 0 0 .5rem;
        padding: .65rem 1rem;
        min-height: 44px;
        font-size: 1rem;
    }
    .mobile-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1200;
        opacity: 0;
        pointer-events: none;
        background: rgba(15, 23, 42, 0.55);
        transition: opacity .2s ease;
    }
    body.nav-open .mobile-nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1300;
        height: 100vh;
        width: min(86vw, 340px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(-108%);
        transition: transform .22s ease;
    }
    body.nav-open .sidebar {
        transform: translateX(0);
    }
    /* Grössere Touch-Targets für iPad */
    .nav a, .nav .nav-link {
        padding: .95rem 1rem;
        min-height: 44px;
    }
    .btn, button {
        min-height: 44px;
    }
    .topbar {
        position: sticky;
        top: .4rem;
        z-index: 900;
        margin: 0;
        border: 1px solid #cbd5e1;
        border-radius: var(--radius-lg);
    }
}
@media (max-width: 980px) {
    .app-shell, .hero, .stat-grid { grid-template-columns: 1fr; }
    .lab-entry-head { flex-direction: column; }
    .grid.two, .grid.three, .kanban { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .topbar-actions {
        width: 100%;
        grid-auto-flow: row;
        grid-auto-columns: unset;
        justify-items: stretch;
    }
    .topbar-actions .btn {
        text-align: center;
    }
    .section-head, .group-card-top { align-items: start; flex-direction: column; }
    .report-header { flex-direction: column; }
}
/* ── Smartphone (≤ 760 px) ── */
@media (max-width: 760px) {
    /* Lesbare Basisschrift, verhindert iOS-Auto-Zoom */
    body { font-size: 1rem; }
    input, select, textarea, button, .btn {
        font-size: 1rem !important;
    }
    input, select, textarea {
        padding: .65rem .75rem;
    }
    .btn, button {
        padding: .75rem 1rem;
        min-height: 48px;
    }
    label {
        font-size: 1rem;
        font-weight: 600;
    }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }
    .card {
        padding: 1rem;
        border-radius: var(--radius-lg);
    }
    .split {
        flex-direction: column;
        align-items: stretch;
    }
    /* Nicht wesentliche Elemente ausblenden */
    .mobile-optional {
        display: none !important;
    }
    /* Kleine Info-Texte verbergen, die auf großen Screens Platz-Hinweise geben */
    .nav-meta { display: none; }
    /* Hinweistexte einblenden */
    .mobile-note {
        display: block;
        margin-top: .4rem;
        font-size: .92rem;
        color: var(--ink-soft);
    }
    .document-textarea {
        min-height: 220px;
        font-size: 1rem;
    }
    .doc-help-inner {
        padding: 1rem;
        border-radius: var(--radius);
    }
    /* Topbar kompakt */
    .topbar {
        padding: .75rem 1rem;
        border-radius: var(--radius-lg);
    }
    .topbar .brand { font-size: 1rem; }
    .topbar .mono { font-size: .82rem; }
    /* Statistik-Karten grösser lesbar */
    .stat-value { font-size: 1.6rem; }
    /* Tabellen scrollbar */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
@media print {
    body {
        background: #fff;
        color: #000;
    }
    .sidebar,
    .topbar,
    .page-actions,
    .pm-dialog,
    .screen-only,
    .btn,
    button,
    form,
    canvas,
    .flash {
        display: none !important;
    }
    .shell,
    .main-panel {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
    }
    .app-shell {
        display: block;
        min-height: 0;
    }
    .card,
    .hero-panel,
    .stat-card,
    .table-wrap {
        background: #fff;
        box-shadow: none;
        border: 1px solid #d0d7de;
        backdrop-filter: none;
    }
    .print-only { display: block; }
    .no-print,
    .pm-dialog-body,
    [data-dialog] { display: none !important; }
    /* Hero ist am Bildschirm dunkel – im Druck schwarz auf weiss */
    .hero-panel,
    .hero-panel * { color: #000 !important; }
    .lab-entry { break-inside: avoid-page; border-left: 3px solid #000; }
    .lab-comment { background: #fff; border-color: #999; }
    a {
        color: #000;
        text-decoration: none;
    }
    /* Dokument-PDF-Export */
    body[data-printing-doc] .shell > * { display: none !important; }
    body[data-printing-doc] #doc-print-area {
        display: block !important;
        padding: 2cm 2.5cm;
        font-family: Georgia, serif;
        font-size: 11pt;
        line-height: 1.75;
        color: #000;
        max-width: none;
    }
    body[data-printing-doc] #doc-print-area h1 {
        font-size: 1.7rem;
        border-bottom: 2px solid #000;
        padding-bottom: .5rem;
        margin-bottom: 1.5rem;
    }
    body[data-printing-doc] #doc-print-area h2 { font-size: 1.3rem; }
    body[data-printing-doc] #doc-print-area h3, body[data-printing-doc] #doc-print-area h4 { font-size: 1.1rem; }
    body[data-printing-doc] #doc-print-area pre {
        background: #f5f5f5;
        border: 1px solid #ccc;
        padding: .8rem 1rem;
        border-radius: 4px;
        font-size: 9.5pt;
        white-space: pre-wrap;
        word-break: break-all;
    }
    body[data-printing-doc] #doc-print-area code {
        background: #f2f2f2;
        padding: .05rem .3rem;
        border-radius: 3px;
        font-size: 9.5pt;
    }
    body[data-printing-doc] #doc-print-area img { max-width: 100%; }
    body[data-printing-doc] #doc-print-area table {
        border-collapse: collapse;
        width: 100%;
        font-size: 10pt;
    }
    body[data-printing-doc] #doc-print-area th,
    body[data-printing-doc] #doc-print-area td {
        border: 1px solid #999;
        padding: .3rem .5rem;
    }
    body[data-printing-doc] #doc-print-area blockquote {
        border-left: 3px solid #888;
        margin-left: 0;
        padding-left: 1rem;
        color: #555;
    }
}
#git-section details > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: .4rem;
}
#git-section details > summary::-webkit-details-marker { display: none; }
#git-section details > summary::marker { content: ''; }
#git-section details > summary::before {
    content: '▶';
    font-size: .7em;
    display: inline-block;
    transition: transform .15s;
    flex-shrink: 0;
}
#git-section details[open] > summary::before { transform: rotate(90deg); }
