:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1a1f2e;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --ok: #059669;
    --defect: #dc2626;
    --warn: #d97706;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: min(1200px, 100% - 2rem);
    margin: 0 auto;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    gap: 1rem;
}

.logo {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    font-size: 1.1rem;
}

nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
}

nav a:hover { color: var(--primary); }

.nav-dropdown {
    position: relative;
}

.nav-dropdown summary {
    list-style: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.95rem;
    user-select: none;
}

.nav-dropdown summary::-webkit-details-marker {
    display: none;
}

.nav-dropdown summary::after {
    content: " ▾";
    font-size: 0.75em;
}

.nav-dropdown[open] summary,
.nav-dropdown summary:hover {
    color: var(--primary);
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    min-width: 11rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 0.35rem;
    display: grid;
    gap: 0.1rem;
    z-index: 20;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a.active {
    background: var(--bg);
    color: var(--primary);
}

.nav-logout-form {
    display: inline;
    margin: 0;
}

.nav-logout-form .btn-logout {
    vertical-align: middle;
}

.nav-login {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-login input[type="text"],
.nav-login input[type="password"] {
    width: 9.5rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    font-size: 0.9rem;
    background: var(--bg);
}

.nav-login input:focus {
    outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent);
    outline-offset: 1px;
    border-color: var(--primary);
}

.nav-login-mobile { display: none; }

@media (max-width: 720px) {
    .header-inner {
        flex-wrap: wrap;
        padding: 0.5rem 0;
        min-height: 52px;
        gap: 0.5rem;
    }

    .nav-login-desktop { display: none; }
    .nav-login-mobile { display: inline-flex; }

    .nav-link-desktop { display: none; }

    .user-badge {
        max-width: 7.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .btn-logout {
        padding: 0.45rem 0.65rem;
        min-height: 44px;
    }
}

.user-badge {
    font-size: 0.85rem;
    background: var(--bg);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
}

main.container {
    padding: 1.5rem 0 3rem;
    flex: 1 0 auto;
}

.site-footer {
    padding: 1.25rem 0 2rem;
    color: var(--muted);
    text-align: center;
    margin-top: auto;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.footer-text {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-text a {
    color: var(--text);
    text-decoration: none;
}

.footer-text a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.card-narrow {
    max-width: 420px;
    margin: 2rem auto;
}

h1, h2 { margin-top: 0; }

.form label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 500;
}

.form input[type="text"],
.form input[type="password"],
.form input[type="file"],
.form input[type="time"],
.form select,
.form textarea {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    border: none;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef2ff; color: var(--primary-dark); }
.btn-danger { background: #fee2e2; color: var(--defect); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
.btn-lg {
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
    font-weight: 600;
    min-height: 52px;
    border-radius: 12px;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }

.hint { color: var(--muted); font-size: 0.9rem; }
.hint-tight { margin: 0; }

.choice-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 720px) {
    .choice-grid { grid-template-columns: 1fr 1fr; }
}

.choice-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem 1rem;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    min-height: 7.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.choice-card strong {
    display: block;
    font-size: 1.15rem;
    line-height: 1.25;
}

.choice-card small {
    display: block;
    margin-top: 0.25rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.choice-card input { display: none; }

.choice-card:active {
    transform: scale(0.98);
}

.choice-card:has(input:checked) {
    border-color: var(--primary);
    background: #eff6ff;
}

.choice-card.choice-ok:has(input:checked) {
    border-color: var(--ok);
    background: #ecfdf5;
}

.choice-card.choice-defect:has(input:checked) {
    border-color: var(--defect);
    background: #fef2f2;
}

.choice-icon {
    display: inline-flex;
    width: 56px;
    height: 56px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.75rem;
    margin-bottom: 0.55rem;
}

.choice-icon.ok { background: #d1fae5; color: var(--ok); }
.choice-icon.defect { background: #fee2e2; color: var(--defect); }

.defect-fields.hidden { display: none; }

.defect-fields textarea {
    min-height: 6rem;
    font-size: 1rem;
}

.reuse-last-defect {
    margin-bottom: 0.85rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

.reuse-last-preview {
    margin-top: 0.55rem;
}

.reuse-last-meta {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.reuse-last-note {
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
    line-height: 1.35;
}

.reuse-last-thumbs {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.45rem;
}

.reuse-last-thumbs img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.reuse-last-applied {
    margin: 0.45rem 0 0;
    color: var(--ok);
}

.photo-field {
    display: block;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    background: var(--bg);
    text-align: center;
}

.photo-label {
    display: block;
    font-weight: 600;
    font-size: 1.05rem;
}

.photo-hint {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 400;
    margin: 0.25rem 0 0.75rem;
}

.photo-field input[type="file"] {
    margin-top: 0;
    padding: 0.75rem;
    font-size: 1rem;
    min-height: 48px;
    background: var(--surface);
    border-radius: 8px;
}

.success-card { text-align: center; }
.success-icon {
    font-size: 3.5rem;
    color: var(--ok);
    margin-bottom: 0.5rem;
    line-height: 1;
}

.scan-next { margin-top: 1.25rem; }

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.legend-details {
    margin: 0.35rem 0 0.65rem;
}

.legend-summary {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    list-style: none;
}

.legend-summary::-webkit-details-marker {
    display: none;
}

.legend-summary::before {
    content: '';
    width: 0.4rem;
    height: 0.4rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
    margin-top: -0.1rem;
}

.legend-details[open] > .legend-summary::before {
    transform: rotate(45deg);
    margin-top: 0;
}

.legend-details[open] > .legend-summary {
    margin-bottom: 0.35rem;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.85rem;
    margin: 0;
    padding: 0;
    font-size: 0.8rem;
    color: var(--muted);
    background: none;
    border: none;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.legend-item .cell-symbol {
    width: 1.25rem;
    height: 1.25rem;
    font-size: 0.75rem;
    border-radius: 4px;
}

.legend-item .cell-changed-label {
    font-size: 0.65rem;
}

.legend-item .cell-third-party-mark {
    width: 0.85rem;
    height: 0.85rem;
    font-size: 0.6rem;
}

.legend-item .final-star {
    font-size: 0.85rem;
    color: #5b21b6;
}

.legend-non-working {
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 3px;
    background: #e5e7eb;
    border: 1px solid #d1d5db;
    flex-shrink: 0;
}


.matrix-wrapper {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.matrix-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.matrix-table th,
.matrix-table td {
    border: 1px solid var(--border);
    text-align: center;
    padding: 0.5rem;
}

.matrix-table thead th {
    background: #f9fafb;
    font-size: 0.85rem;
}

.date-col {
    white-space: normal;
    background: #f9fafb;
    font-weight: 600;
    vertical-align: top;
    min-width: 4.5rem;
    max-width: 7rem;
}

.date-col-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.date-label {
    white-space: nowrap;
}

.date-col.has-remark {
    background: #fff7ed;
}

.date-col.non-working.has-remark {
    background: #f3e8e0;
}

.day-remark-preview {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    color: #9a3412;
    line-height: 1.2;
    max-width: 6.5rem;
    text-align: center;
    word-break: break-word;
}

.day-remark-edit {
    position: relative;
    font-weight: 500;
}

.day-remark-edit > summary {
    list-style: none;
    cursor: pointer;
    font-size: 0.65rem;
    color: var(--primary);
    user-select: none;
}

.day-remark-edit > summary::-webkit-details-marker {
    display: none;
}

.day-remark-edit[open] > summary {
    color: var(--primary-dark);
}

.day-remark-form {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    width: 14rem;
    padding: 0.55rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    text-align: left;
    font-weight: 400;
}

.day-remark-form textarea {
    width: 100%;
    margin: 0 0 0.4rem;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-size: 0.8rem;
    resize: vertical;
    min-height: 4rem;
}

.day-remark-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.day-remark-meta {
    margin: 0.4rem 0 0;
    font-size: 0.7rem;
}

@media print {
    .day-remark-edit {
        display: none !important;
    }

    .day-remark-preview {
        color: #000;
        font-size: 7pt;
        max-width: none;
    }

    .date-col.has-remark {
        background: #fff7ed !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

.date-col.non-working {
    background: #e5e7eb;
    color: #6b7280;
    font-weight: 500;
}

.matrix-cell.non-working {
    background: #f3f4f6;
}

.matrix-cell.non-working .cell-link {
    opacity: 0.45;
}

.matrix-cell.non-working.third-party,
.matrix-cell.non-working.was-changed {
    /* Einträge an Feiertagen bleiben erkennbar, Spalte bleibt ausgegraut */
    background: #eceff3;
}

.matrix-cell.non-working .cell-symbol {
    filter: grayscale(0.35);
}

@media print {
    .date-col.non-working,
    .matrix-cell.non-working {
        background: #eee !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

.room-col {
    white-space: nowrap;
    text-align: left;
    background: #f9fafb;
    font-weight: 600;
    position: sticky;
    left: 0;
    z-index: 1;
}

.matrix-cell a,
.cell-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    text-decoration: none;
    color: inherit;
    min-width: 3.5rem;
    min-height: 2.75rem;
    padding: 0.25rem 0.2rem;
    border-radius: 6px;
}

.cell-link:hover {
    background: rgba(37, 99, 235, 0.08);
}

.cell-status-row {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.matrix-hint {
    margin: 0 0 0.75rem;
}

.cell-symbol {
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-weight: 700;
}

.cell-symbol.ok { background: #d1fae5; color: var(--ok); }
.cell-symbol.defect { background: #fee2e2; color: var(--defect); }
.cell-symbol.changed { background: #fef3c7; color: var(--warn); }
.cell-symbol.empty { color: #cbd5e1; }
.cell-symbol.override { background: #e0e7ff; color: #3730a3; }

.cell-photo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    line-height: 1;
    flex-shrink: 0;
}

.cell-photo-icon svg {
    display: block;
}

.override-mark,
.final-mark {
    font-size: 0.75rem;
    color: #4338ca;
    line-height: 1;
}

.cell-inspector {
    display: block;
    font-size: 0.65rem;
    line-height: 1.15;
    color: var(--muted);
    max-width: 4.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.final-star {
    color: #7c3aed;
    font-weight: 700;
    margin-left: 0.15em;
    font-size: 1em;
    line-height: 1;
}

.cell-changed-label {
    display: block;
    font-size: 0.62rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    text-transform: lowercase;
    color: var(--warn);
    line-height: 1.1;
}

.matrix-cell.third-party {
    background: #fff7ed;
    box-shadow: inset 0 0 0 2px #fb923c;
}

.matrix-cell.was-changed:not(.third-party) {
    background: #fffbeb;
}

.cell-third-party-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0.95rem;
    height: 0.95rem;
    border-radius: 50%;
    background: #ea580c;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
}

.dashboard-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.print-only { display: none; }

.badge-final {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-third-party {
    background: #ffedd5;
    color: #9a3412;
}

.timeline-item.third-party-edit {
    border-color: #fb923c;
    box-shadow: inset 3px 0 0 #ea580c;
}

.timeline-actions {
    margin-left: auto;
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-shrink: 0;
}

.btn-final-star {
    margin: 0;
    padding: 0.1rem 0.35rem;
    border: none;
    background: transparent;
    color: #c4b5fd;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
}

.btn-final-star:hover {
    color: #6366f1;
    background: #eef2ff;
}

.btn-final-star.is-active {
    color: #4f46e5;
}

.timeline-item.is-final {
    border-color: #818cf8;
    box-shadow: inset 3px 0 0 #6366f1;
}

.admin-final .final-current {
    margin: 0 0 1rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.stat-time {
    font-variant-numeric: tabular-nums;
}

.stat-time small {
    color: var(--muted);
    font-weight: 400;
}

.photo-item {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: flex-start;
}

.photo-delete {
    margin: 0;
}

.edit-details,
.audit-details {
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.edit-details summary,
.audit-details summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 0.9rem;
    user-select: none;
}

.edit-details summary:hover,
.audit-details summary:hover {
    color: var(--primary);
}

.edit-details[open] summary,
.audit-details[open] summary {
    margin-bottom: 0.75rem;
    color: var(--text);
}

.audit-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.65rem;
}

.audit-list li {
    background: var(--bg);
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
}

.audit-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.audit-ref {
    color: var(--primary);
    text-decoration: none;
}

.audit-ref:hover {
    text-decoration: underline;
}

.audit-ref-deleted {
    color: var(--muted);
    font-style: italic;
}

.detail-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0;
}

.room-history-link {
    color: inherit;
    text-decoration: none;
}

.room-history-link:hover {
    color: var(--primary, #2563eb);
    text-decoration: underline;
}

.history-filter-form {
    display: inline-flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.history-day {
    margin-bottom: 1.25rem;
}

.history-day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 0.5rem;
}

.history-day-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.detail-page .detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.detail-page .detail-heading .back-link {
    margin-bottom: 0.15rem;
    font-size: 0.85rem;
}

.detail-page .detail-heading h1 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.2;
}

.detail-page .detail-heading .room-meta {
    margin: 0.2rem 0 0;
    font-size: 0.9rem;
}

.detail-page .alert {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.65rem;
    font-size: 0.9rem;
}

.detail-page .detail-empty {
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.65rem;
}

.detail-page .detail-empty p {
    margin: 0;
}

.detail-page .detail-add,
.detail-page .detail-audit {
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.65rem;
}

.detail-page .detail-add summary,
.detail-page .detail-audit summary {
    cursor: pointer;
    list-style: none;
    user-select: none;
    font-size: 0.95rem;
}

.detail-page .detail-add summary::-webkit-details-marker,
.detail-page .detail-audit summary::-webkit-details-marker {
    display: none;
}

.detail-page .detail-add summary::before,
.detail-page .detail-audit summary::before {
    content: "▸ ";
    color: var(--muted);
}

.detail-page .detail-add[open] summary::before,
.detail-page .detail-audit[open] summary::before {
    content: "▾ ";
}

.detail-page .detail-add .form,
.detail-page .detail-audit .audit-list,
.detail-page .detail-audit .audit-more {
    margin-top: 0.65rem;
}

.detail-page .detail-add .choice-grid {
    gap: 0.45rem;
    margin-bottom: 0.65rem;
}

.detail-page .detail-add .choice-card {
    min-height: 0;
    padding: 0.55rem 0.4rem;
}

.detail-page .detail-add .choice-icon {
    width: 36px;
    height: 36px;
    font-size: 1.15rem;
    margin-bottom: 0.2rem;
}

.detail-page .detail-add .choice-card strong {
    font-size: 0.9rem;
}

.detail-page .detail-add .form label {
    margin-bottom: 0.55rem;
    font-size: 0.9rem;
}

.detail-page .detail-add textarea,
.detail-page .detail-add input[type="file"] {
    padding: 0.45rem 0.55rem;
    font-size: 0.9rem;
}

.detail-page .audit-section h2 {
    display: none;
}

.detail-page .audit-section {
    margin-top: 0.65rem;
}

.detail-page .timeline {
    margin-bottom: 0.65rem;
}

.audit-more {
    margin-top: 0.75rem;
}

.audit-more summary {
    cursor: pointer;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
    user-select: none;
    list-style: none;
}

.audit-more summary::-webkit-details-marker {
    display: none;
}

.audit-more summary::before {
    content: "▸ ";
}

.audit-more[open] summary::before {
    content: "▾ ";
}

.audit-more .audit-list,
.audit-more .audit-table {
    margin-top: 0.75rem;
}

.audit-detail {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.audit-list li:hover .audit-detail,
.audit-more[open] .audit-detail {
    -webkit-line-clamp: unset;
    overflow: visible;
}

.audit-detail {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
    word-break: break-word;
}

.audit-detail-text {
    margin: 0 0 0.35rem;
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.4;
}

.audit-table td {
    vertical-align: top;
}

.audit-time {
    white-space: nowrap;
    color: var(--muted);
    font-size: 0.9rem;
}

.edit-form {
    max-width: 520px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.stats-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.stats-card-header h2 {
    margin: 0;
}

.stats-date-form label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-size: 0.9rem;
}

.stats-date-form input[type="date"] {
    min-height: 2rem;
    padding: 0.25rem 0.45rem;
}

.stat-item {
    background: var(--bg);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    border: 1px solid transparent;
}

.stat-item.stat-complete {
    background: #d1fae5;
    border-color: #a7f3d0;
}

.stat-item.stat-incomplete {
    background: #fee2e2;
    border-color: #fecaca;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-ok { background: #d1fae5; color: var(--ok); }
.badge-warn { background: #fef3c7; color: var(--warn); }

.timeline { display: grid; gap: 0.45rem; }

.detail-page .timeline-item.card {
    padding: 0.55rem 0.75rem;
    margin-bottom: 0;
}

.timeline-header {
    display: flex;
    align-items: center;
    gap: 0.4rem 0.55rem;
    flex-wrap: nowrap;
    margin-bottom: 0;
}

.timeline-header-main {
    display: flex;
    align-items: center;
    gap: 0.4rem 0.55rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.timeline-expand {
    margin-top: 0.35rem;
}

.timeline-more {
    list-style: none;
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
}

.timeline-more::-webkit-details-marker {
    display: none;
}

.timeline-more:hover {
    color: var(--primary);
}

.timeline-more-open {
    display: none;
}

.timeline-expand[open] > .timeline-more .timeline-more-closed {
    display: none;
}

.timeline-expand[open] > .timeline-more .timeline-more-open {
    display: inline;
}

.timeline-more-arrow {
    display: inline-block;
    transition: transform 0.15s ease;
    font-size: 0.75rem;
}

.timeline-expand[open] > .timeline-more .timeline-more-arrow {
    transform: rotate(90deg);
}

.timeline-photo-hint {
    font-size: 0.75rem;
    color: var(--muted);
}

.timeline-body {
    margin-top: 0.45rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--border);
}

.timeline-user {
    font-size: 0.9rem;
    font-weight: 600;
}

.detail-page .timeline-item .note {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.35;
}

.detail-page .timeline-item time {
    font-size: 0.85rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.detail-page .status-badge {
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
}

.detail-page .timeline-item .badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.35rem;
}

.status-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-badge.ok { background: #d1fae5; color: var(--ok); }
.status-badge.defect { background: #fee2e2; color: var(--defect); }

.photo-grid {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin-top: 0.45rem;
}

.detail-page .photo-grid img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.detail-page .timeline-item.defect .photo-grid img,
.detail-page .timeline-expand[open] .photo-grid img {
    width: min(100%, 420px);
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    background: #f8fafc;
}

.photo-grid img {
    width: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.detail-page .photo-item {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.15rem;
}

.detail-page .photo-delete .btn {
    padding: 0.1rem 0.35rem;
    min-height: 0;
    line-height: 1;
}

.detail-page .edit-details {
    margin-top: 0.4rem;
}

.detail-page .edit-details summary {
    font-size: 0.85rem;
}

.detail-page .edit-details .choice-grid {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    gap: 0.45rem;
}

.detail-page .edit-details .choice-card {
    min-height: 0;
    padding: 0.55rem 0.45rem;
}

.detail-page .edit-details .choice-icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.detail-page .edit-details .choice-card strong {
    font-size: 0.9rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 0.75rem;
    color: var(--primary);
    text-decoration: none;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--border);
    padding: 0.65rem;
    text-align: left;
    vertical-align: top;
}

.data-table tr.deleted { opacity: 0.6; }

.form-inline {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 700px) {
    .form-grid-2 { grid-template-columns: 1fr; }
}

.user-list {
    display: grid;
    gap: 1rem;
}

.user-card.user-inactive {
    opacity: 0.72;
}

.user-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.user-card-status-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.table-scroll {
    overflow-x: auto;
}

.users-table-head,
.users-table-edit {
    display: grid;
    grid-template-columns: minmax(8rem, 1.3fr) minmax(7rem, 1fr) minmax(7rem, 0.9fr) minmax(6rem, 0.8fr) auto auto;
    gap: 0.45rem;
    align-items: center;
    min-width: 700px;
}

.users-table-head {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
    padding: 0 4.5rem 0.5rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}

.users-table-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
    min-width: 760px;
}

.users-table-row:last-child {
    border-bottom: none;
}

.users-table-row.is-inactive {
    opacity: 0.65;
}

.users-table-edit {
    flex: 1;
    min-width: 0;
}

.users-table-edit input,
.users-table-edit select {
    width: 100%;
    padding: 0.35rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-size: 0.9rem;
    background: #fff;
}

.users-table-actions {
    display: flex;
    justify-content: flex-end;
}

.users-table-toggle {
    margin: 0;
    flex: 0 0 auto;
}

.form-inline select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #fff;
}

.room-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
    justify-content: flex-end;
}

.actions-menu {
    position: relative;
}

.actions-menu > summary {
    list-style: none;
    cursor: pointer;
}

.actions-menu > summary::-webkit-details-marker {
    display: none;
}

.actions-menu > summary::after {
    content: ' ▾';
    font-size: 0.75em;
    opacity: 0.7;
}

.actions-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.2rem);
    z-index: 20;
    min-width: 10.5rem;
    padding: 0.3rem;
    background: var(--surface, #fff);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    display: grid;
    gap: 0.1rem;
}

.actions-menu-panel a,
.actions-menu-panel button {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0.45rem 0.65rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.85rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.actions-menu-panel a:hover,
.actions-menu-panel button:hover {
    background: #f1f5f9;
}

.actions-menu-danger button {
    color: var(--defect, #b91c1c);
}

.actions-menu-danger button:hover {
    background: #fee2e2;
}

.actions-menu-panel form {
    margin: 0;
}

.rooms-create-card {
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
}

.rooms-create-form {
    margin: 0;
    gap: 0.45rem;
}

.rooms-create-form input {
    flex: 1;
    min-width: 8rem;
    padding: 0.4rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-size: 0.9rem;
    background: var(--bg);
}

.rooms-list-hint {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
}

.rooms-list-card {
    padding: 0.35rem 0.75rem;
}

.rooms-list {
    display: grid;
    gap: 0;
}

.room-row {
    display: grid;
    grid-template-columns: 1.75rem minmax(0, 1fr) auto auto;
    gap: 0.45rem 0.55rem;
    align-items: center;
    margin: 0;
    padding: 0.4rem 0.15rem;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    transition: background 0.12s, opacity 0.12s;
}

.room-row:last-child {
    border-bottom: none;
}

.room-row.is-active {
    border-left: 2px solid var(--ok);
    padding-left: 0.35rem;
}

.room-row.is-inactive {
    opacity: 0.72;
    border-left: 2px solid var(--warn);
    padding-left: 0.35rem;
}

.room-row.deleted {
    opacity: 0.5;
    border-left: 2px solid var(--border);
    padding-left: 0.35rem;
}

.room-edit-form {
    display: grid;
    grid-template-columns: minmax(6rem, 0.9fr) minmax(7rem, 1.2fr) auto;
    gap: 0.35rem;
    align-items: center;
    margin: 0;
    min-width: 0;
}

.room-edit-form input {
    width: 100%;
    margin: 0;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-size: 0.9rem;
    background: var(--bg);
}

.room-edit-form input[name="name"] {
    font-weight: 600;
    background: var(--surface);
}

.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    margin: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    cursor: grab;
    color: var(--muted);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.drag-handle span,
.drag-handle span::before {
    display: block;
    width: 0.7rem;
    height: 1px;
    border-radius: 1px;
    background: currentColor;
    box-shadow: 0 3px 0 currentColor, 0 6px 0 currentColor;
}

.drag-handle span {
    height: 7px;
    background: transparent;
    box-shadow: none;
    position: relative;
}

.drag-handle span::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    box-shadow: 0 3px 0 currentColor, 0 6px 0 currentColor;
}

.drag-handle:hover {
    color: var(--primary);
    border-color: var(--border);
    background: var(--bg);
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle-spacer {
    width: 1.75rem;
    height: 1.75rem;
}

.room-row.is-dragging {
    opacity: 0.45;
    background: #eff6ff;
}

.room-row.drag-over {
    box-shadow: inset 0 2px 0 var(--primary);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 900px) {
    .room-row {
        grid-template-columns: 1.75rem 1fr;
    }

    .room-edit-form {
        grid-column: 2;
        grid-template-columns: 1fr 1fr auto;
    }

    .room-row > .badge {
        grid-column: 2;
        justify-self: start;
    }

    .room-actions {
        grid-column: 2;
        justify-content: flex-start;
    }
}

@media (max-width: 560px) {
    .room-edit-form {
        grid-template-columns: 1fr;
    }

    .rooms-create-form {
        flex-direction: column;
        align-items: stretch;
    }

    .rooms-create-form input {
        width: 100%;
    }
}

.hidden {
    display: none !important;
}

.qr-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 800px) {
    .qr-layout { grid-template-columns: 1fr; }
}

.qr-card { text-align: center; }

.qr-history-list {
    display: grid;
    gap: 0.75rem;
}

.qr-history-item {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 0.75rem;
    align-items: start;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
}

.qr-history-item.is-inactive-token {
    opacity: 0.85;
}

.qr-history-preview {
    display: block;
    width: 96px;
    height: 96px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.qr-history-preview svg {
    display: block;
    width: 100%;
    height: 100%;
}

.qr-history-meta {
    min-width: 0;
}

.qr-history-meta p {
    margin: 0.15rem 0;
    font-size: 0.9rem;
}

.qr-history-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.qr-history-status time {
    font-size: 0.85rem;
    color: var(--muted);
}

.audit-qr-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.65rem;
}

.audit-qr-preview {
    margin: 0;
    padding: 0.5rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
}

.audit-qr-preview figcaption {
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.audit-qr-preview svg {
    display: block;
    margin: 0 auto 0.35rem;
}

.audit-qr-preview a {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
}

.audit-qr-preview a:hover {
    text-decoration: underline;
}

.qr-image {
    max-width: 280px;
    width: 100%;
    height: auto;
    margin: 0 auto;
}

.qr-image svg {
    display: block;
    width: 100%;
    height: auto;
    max-width: 280px;
    margin: 0 auto;
}

.qr-toolbar {
    display: flex;
    gap: 0.5rem;
}

.qr-all-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.qr-overview .dashboard-header {
    margin-bottom: 0.5rem;
}

.qr-overview .dashboard-header h1 {
    font-size: 1.35rem;
}

.qr-overview .qr-all-grid {
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 0.55rem;
}

.qr-overview .qr-print-card {
    gap: 0.4rem;
    padding: 0.55rem 0.6rem;
    margin-bottom: 0;
}

.qr-overview .qr-room-name {
    font-size: 0.9rem;
    margin: 0 0 0.1rem;
    line-height: 1.2;
}

.qr-overview .qr-room-desc {
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    line-height: 1.2;
}

.qr-overview .qr-image,
.qr-overview .qr-image svg {
    max-width: 120px;
}

.qr-overview .qr-admin-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.qr-overview .qr-admin-meta .hint {
    margin: 0;
    font-size: 0.7rem;
}

.qr-overview .qr-admin-meta .scan-url {
    margin: 0;
}

.qr-overview .qr-admin-meta .scan-url code {
    display: block;
    font-size: 0.62rem;
    line-height: 1.25;
    max-height: 2.5em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qr-overview .qr-validity-form {
    margin: 0.15rem 0 0;
    gap: 0.3rem;
    align-items: center;
}

.qr-overview .qr-validity-form label {
    font-size: 0.72rem;
    margin: 0;
    gap: 0.25rem;
}

.qr-overview .qr-validity-form input[type="date"] {
    padding: 0.2rem 0.3rem;
    font-size: 0.75rem;
    min-height: 0;
}

.qr-overview .qr-actions {
    gap: 0.3rem;
    margin-top: 0.1rem;
}

.qr-overview .qr-actions .btn {
    padding: 0.2rem 0.45rem;
    min-height: 0;
    font-size: 0.75rem;
}

.qr-print-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.qr-print-label {
    text-align: center;
}

.qr-room-name {
    margin: 0 0 0.25rem;
    font-size: 1.15rem;
}

.qr-room-desc {
    margin: 0 0 0.75rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.qr-valid-print {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.qr-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.qr-validity-form {
    margin: 0.5rem 0;
}

.qr-admin-meta .scan-url {
    margin: 0 0 0.35rem;
}

.form input[type="date"] {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}

.form-inline input[type="date"] {
    width: auto;
    display: inline-block;
    margin-top: 0;
    padding: 0.4rem 0.5rem;
}

@media print {
    .site-header,
    .site-footer,
    .no-print,
    .qr-admin-meta,
    .qr-toolbar {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    main.container {
        width: 100%;
        max-width: none;
        padding: 0;
        margin: 0;
    }

    .print-title h1 {
        margin: 0 0 0.25rem;
        font-size: 16pt;
    }

    .print-title p {
        margin: 0 0 0.75rem;
        font-size: 10pt;
        color: #333;
    }

        .legend {
        font-size: 8pt;
        margin: 0 0 0.4rem;
        gap: 0.25rem 0.65rem;
    }

    .matrix-wrapper {
        overflow: visible;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    .matrix-table {
        min-width: 0;
        width: 100%;
        font-size: 9pt;
    }

    .matrix-table th,
    .matrix-table td {
        padding: 0.3rem 0.2rem;
    }

    .matrix-cell.third-party {
        background: #fff7ed !important;
        box-shadow: inset 0 0 0 1.5pt #ea580c;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .matrix-cell.has-final {
        background: #eef2ff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .cell-symbol {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .cell-inspector {
        max-width: none;
        white-space: normal;
        font-size: 7.5pt;
        color: #000;
    }

    .cell-link {
        min-width: 0;
        min-height: 0;
    }

    .cell-link::after {
        /* prevent link URLs in some browsers */
        content: none !important;
    }

    .qr-all-grid {
        display: block;
    }

    .qr-print-card {
        break-inside: avoid;
        page-break-inside: avoid;
        border: 1px solid #ccc;
        border-radius: 0;
        box-shadow: none;
        width: 7cm;
        min-height: 9cm;
        float: left;
        margin: 0.4cm;
        padding: 0.4cm;
        display: block;
    }

    .qr-print-label .qr-image,
    .qr-print-label .qr-image svg {
        width: 5cm !important;
        height: 5cm !important;
        max-width: 5cm !important;
    }

    .qr-room-name {
        font-size: 14pt;
    }

    .qr-room-desc,
    .qr-valid-print {
        font-size: 10pt;
        color: #000;
    }
}

.scan-url code {
    word-break: break-all;
    font-size: 0.8rem;
}

.small-code {
    font-size: 0.75rem;
    word-break: break-all;
}

.info-list {
    padding-left: 1.2rem;
    color: var(--muted);
}

.inline-form select {
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* —— Mitarbeiter: mobil-first —— */
.room-meta {
    color: var(--muted);
    margin-top: -0.35rem;
    margin-bottom: 1.25rem;
}

.scan-kicker {
    margin: 0 0 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--primary);
}

.scan-title {
    font-size: clamp(1.5rem, 5vw, 1.85rem);
    line-height: 1.2;
    margin-bottom: 0.35rem;
}

.nav-help {
    font-weight: 500;
}

.nav-help.active {
    color: var(--primary);
}

.help-steps {
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0;
    display: grid;
    gap: 0.75rem;
    counter-reset: help-step;
}

.help-steps li {
    counter-increment: help-step;
    display: grid;
    grid-template-columns: 2.5rem 1fr;
    gap: 0.75rem 1rem;
    align-items: start;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.help-steps li::before {
    content: counter(help-step);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: #dbeafe;
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 1.1rem;
    grid-row: 1 / span 2;
}

.help-steps strong {
    font-size: 1.05rem;
}

.help-steps span {
    color: var(--muted);
    font-size: 0.95rem;
    grid-column: 2;
}

.login-card {
    margin-top: 1rem;
}

body.role-worker,
body.page-scan,
body.page-auth {
    -webkit-text-size-adjust: 100%;
}

body.role-worker .container,
body.page-scan .container,
body.page-auth .container {
    width: min(560px, 100% - 1.25rem);
}

body.role-worker main.container,
body.page-scan main.container,
body.page-auth main.container {
    padding: 1rem 0 2rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
}

body.role-worker .site-footer,
body.page-scan .site-footer {
    padding: 0.85rem 0 calc(1rem + env(safe-area-inset-bottom, 0px));
}

body.role-worker .footer-text,
body.page-scan .footer-text {
    font-size: 0.8rem;
}

body.page-scan .scan-card,
body.role-worker .scan-card,
.login-card {
    border-radius: 16px;
    padding: 1.35rem 1.15rem 1.25rem;
}

.scan-actions {
    margin-top: 1.25rem;
}

.scan-form .choice-grid {
    gap: 0.55rem;
    margin-bottom: 0.85rem;
}

.scan-form .choice-card {
    padding: 0.7rem 0.65rem;
    min-height: 0;
}

.scan-form .choice-icon {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
    margin-bottom: 0.35rem;
}

.scan-form .choice-card strong {
    font-size: 0.98rem;
}

.scan-form .choice-card small {
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.scan-form .defect-fields textarea {
    min-height: 4.25rem;
}

.scan-form .photo-field {
    padding: 0.55rem 0.65rem;
    border-width: 1px;
}

.scan-form .photo-label {
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.scan-form .photo-field input[type="file"] {
    padding: 0.4rem 0.45rem;
    font-size: 0.85rem;
    min-height: 0;
}

@media (min-width: 720px) {
    .scan-form .choice-grid {
        gap: 0.65rem;
    }
}

/* Scan: Auswahl ≤ 50 % Höhe, Mangel-Bereich füllt Rest bis Speichern */
body.page-scan {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

body.page-scan .site-header {
    flex-shrink: 0;
}

body.page-scan main.container {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: min(560px, 100% - 1.25rem);
}

body.page-scan .scan-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.page-scan .scan-kicker,
body.page-scan .scan-title,
body.page-scan .alert {
    flex-shrink: 0;
}

body.page-scan .scan-form {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.page-scan .scan-form .choice-grid {
    flex: 0 1 auto;
    max-height: 50%;
    max-height: 50dvh;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

body.page-scan .scan-form .choice-card {
    height: 100%;
    box-sizing: border-box;
}

body.page-scan .scan-form .defect-fields:not(.hidden) {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0;
    padding-bottom: 0.25rem;
}

body.page-scan .scan-form .defect-fields > label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

body.page-scan .scan-form .defect-fields > label:has(textarea) {
    flex: 1 1 auto;
    min-height: 0;
}

body.page-scan .scan-form .defect-fields textarea {
    flex: 1 1 auto;
    min-height: 2.75rem;
    resize: none;
}

body.page-scan .scan-form .photo-field,
body.page-scan .scan-form .reuse-last-defect {
    flex-shrink: 0;
}

body.page-scan .scan-actions {
    flex-shrink: 0;
}

@media (max-width: 719px) {
    body.page-scan .scan-form .choice-grid {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
        max-height: 50%;
    }

    body.page-scan .scan-form .choice-card {
        padding: 0.4rem 0.5rem;
    }

    body.page-scan .scan-form .choice-icon {
        width: 32px;
        height: 32px;
        font-size: 1.05rem;
        margin-bottom: 0.2rem;
    }

    body.page-scan .scan-form .choice-card strong {
        font-size: 0.9rem;
    }

    body.page-scan .scan-form .choice-card small {
        font-size: 0.72rem;
    }
}

@media (min-width: 720px) {
    body.page-scan .scan-form .choice-grid {
        max-height: 45%;
        align-content: stretch;
    }

    body.page-scan .scan-form .choice-card {
        min-height: 0;
    }
}

@media (max-width: 720px) {
    body.page-scan .site-header,
    body.role-worker .site-header {
        padding-top: env(safe-area-inset-top, 0px);
    }

    body.page-scan main.container,
    body.role-worker main.container,
    body.page-auth main.container {
        padding-top: 0.75rem;
        padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    }

    body.page-scan .scan-card,
    body.role-worker .scan-card {
        border: none;
        box-shadow: none;
        background: transparent;
        padding: 0.25rem 0 0;
        margin-bottom: 0;
    }

    body.page-scan .scan-actions {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 15;
        margin: 0;
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        background: color-mix(in srgb, var(--surface) 92%, transparent);
        backdrop-filter: blur(8px);
        border-top: 1px solid var(--border);
    }

    body.page-scan .site-footer {
        display: none;
    }

    .form input[type="text"],
    .form input[type="password"],
    .form textarea {
        font-size: 16px; /* verhindert iOS-Zoom beim Fokus */
        min-height: 48px;
        padding: 0.85rem 0.9rem;
    }

    .form textarea {
        min-height: 7rem;
    }
}

.scan-camera-cta {
    margin: 0 0 1.25rem;
}

.round-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin: 1.25rem 0 1.5rem;
    padding: 0;
}

.round-summary > div {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.65rem 0.4rem;
    text-align: center;
}

.round-summary dt {
    margin: 0;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.round-summary dd {
    margin: 0.2rem 0 0;
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.scan-round-complete .success-icon {
    color: var(--ok);
}

.scan-camera-hint {
    margin: 0 0 0.75rem;
}

.scan-camera-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: min(38dvh, 280px);
    margin: 0 auto 0.75rem;
    border-radius: 14px;
    overflow: hidden;
    background: #0f172a;
    border: 1px solid var(--border);
}

.scan-camera-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-camera-video.is-mirrored {
    transform: scaleX(-1);
}

.scan-camera-frame {
    position: absolute;
    inset: 14% 16%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 10px;
    box-shadow: 0 0 0 999px rgba(15, 23, 42, 0.35);
    pointer-events: none;
}

.scan-camera-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    margin: 0 0 0.55rem;
}

.scan-camera-toolbar .btn {
    font-size: 0.9rem;
    padding: 0.55rem 0.65rem;
}

.scan-camera-actions {
    display: grid;
    gap: 0.4rem;
}

.scan-camera-page .scan-title {
    font-size: clamp(1.25rem, 4vw, 1.5rem);
    margin-bottom: 0.2rem;
}

.scan-camera-hint {
    margin: 0 0 0.55rem;
    font-size: 0.85rem;
}

body.page-scan-camera .site-footer {
    display: none;
}

@media (max-width: 720px) {
    body.page-scan-camera main.container {
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }
}
