:root {
            --primary-color: #2c3e50;
            --accent-color: #1abc9c;
            --danger-color: #e74c3c;
            --bg-color: #f5f7fa;
            --card-bg: #ffffff;
            --text-color: #34495e;
            --border-color: #e2e8f0;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            background-color: var(--bg-color);
            color: var(--text-color);
            margin: 0;
            padding: clamp(10px, 2vw, 24px);
            padding-top: max(clamp(10px, 2vw, 24px), env(safe-area-inset-top));
            padding-bottom: max(clamp(10px, 2vw, 24px), env(safe-area-inset-bottom));
            min-height: 100vh;
            box-sizing: border-box;
            display: flex;
            justify-content: center;
            overflow-y: auto;
        }

        .dashboard-container {
            width: 100%;
            height: 100%;
            max-width: 1600px;
            background: var(--card-bg);
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
            padding: clamp(14px, 2vw, 24px);
            box-sizing: border-box;
        }

        .header-bar {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 10px;
        }

        h1 {
            font-size: 24px;
            color: var(--primary-color);
            margin: 0 0 5px 0;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .mandant-badge {
            font-size: 14px;
            color: #7f8c8d;
            font-weight: 500;
            margin-bottom: 8px;
        }

        .user-status {
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 13px;
            line-height: 1;
            background: #f1f5f9;
            padding: 6px 12px;
            border-radius: 20px;
            font-weight: 600;
            color: #475569;
        }

        .btn-logout {
            background: none;
            border: none;
            color: var(--danger-color);
            font-size: 13px;
            line-height: 1;
            font-weight: bold;
            cursor: pointer;
            padding: 2px 0 2px 8px;
            border-left: 1px solid #cbd5e1;
            display: inline-flex;
            align-items: center;
        }

        .btn-logout:hover {
            text-decoration: underline;
        }

        .nav-tabs {
            display: flex;
            gap: 10px;
            margin-bottom: 14px;
            border-bottom: 2px solid var(--border-color);
            padding-bottom: 6px;
        }

        .tab-btn {
            padding: 10px 20px;
            border: none;
            background: none;
            font-size: 15px;
            font-weight: 600;
            color: #64748b;
            cursor: pointer;
            border-radius: 6px;
            transition: all 0.2s ease;
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }

        .tab-btn:hover {
            background-color: #f1f5f9;
            color: var(--primary-color);
        }

        .tab-btn.active {
            background-color: var(--primary-color);
            color: white;
        }

        .tab-icon {
            display: inline-block;
            vertical-align: middle;
            fill: currentColor;
            opacity: 0.75;
            transition: all 0.2s ease;
        }

        .tab-btn.active .tab-icon {
            opacity: 1;
            fill: #ffffff;
        }

        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
        }

        .login-card {
            max-width: 400px;
            margin: 60px auto;
            background: #fff;
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 30px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
            text-align: left;
        }

        .login-card h2 {
            margin-top: 0;
            font-size: 20px;
            color: var(--primary-color);
            text-align: center;
        }

        .liability-box {
            background-color: #fff9f1;
            border-left: 4px solid #f39c12;
            padding: 10px 14px;
            border-radius: 0 8px 8px 0;
            font-size: 14px;
            line-height: 1.4;
            margin-bottom: 24px;
            display: flex;
            align-items: flex-start;
            gap: 10px;
        }

        .liability-box strong {
            color: #d35400;
        }

        .main-layout {
            display: grid;
            grid-template-columns: max-content minmax(0, 1fr);
            gap: clamp(15px, 2vw, 25px);
            align-items: stretch;
        }

        .management-layout {
            display: grid;
            grid-template-columns: minmax(280px, 360px) max-content;
            justify-content: start;
            gap: clamp(15px, 2vw, 25px);
            align-items: start;
        }

        @media (max-width: 992px) {

            .main-layout,
            .management-layout {
                grid-template-columns: 1fr;
                justify-content: stretch;
            }

            .table-section {
                width: max-content;
                max-width: 100%;
            }

            .reports-scroll-body,
            .reports-table-head {
                overflow-x: auto;
            }

            .reports-table-head table,
            .reports-scroll-body table {
                min-width: 325px;
            }

            .preview-card {
                height: auto;
                max-height: 400px;
            }
        }

        @media (max-width: 600px) {
            .header-bar {
                flex-direction: column;
                gap: 10px;
            }

            .nav-tabs {
                flex-direction: column;
            }

            .tab-btn {
                width: 100%;
                text-align: center;
            }
        }

        .table-section {
            border: 1px solid var(--border-color);
            border-radius: 8px;
            overflow: hidden;
            background: #fff;
            display: flex;
            flex-direction: column;
            height: 600px;
            box-sizing: border-box;
            width: auto;
        }

        .reports-table-head th {
            box-sizing: border-box;
        }

        /* Smartphone Landscape: Mindesthöhe & lesbare Zeilen bei geringer Displayhöhe */
        @media (orientation: landscape) and (max-height: 500px) {
            .reports-scroll-body {
                min-height: 160px;
            }

            .reports-scroll-body td {
                padding: 10px 8px;

                line-height: 1.3;
            }
        }

        .reports-table-container {
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
            min-height: 0;
        }

        .reports-table-body td {
            box-sizing: border-box;
        }

        .reports-table-container::-webkit-scrollbar {
            width: 6px;
        }

        .reports-table-container::-webkit-scrollbar-thumb {
            background-color: #cbd5e1;
            border-radius: 4px;
        }

        .reports-table-container::-webkit-scrollbar-thumb:hover {
            background-color: #94a3b8;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            text-align: left;
            font-size: 14px;
            table-layout: auto;
        }

        th {
            background-color: #f8fafc;
            color: #64748b;
            font-weight: 600;
            padding: 12px 10px;
            border-bottom: 1px solid var(--border-color);
            text-transform: uppercase;
            font-size: 12px;
            letter-spacing: 0.5px;
        }

        th.sortable {
            cursor: pointer;
            user-select: none;
            transition: background-color 0.15s ease;
        }

        th.sortable:hover {
            background-color: #f1f5f9;
            color: var(--primary-color);
        }

        .sort-icon {
            display: inline-flex;
            align-items: center;
            vertical-align: middle;
            margin-left: 6px;
            color: #64748b;
        }

        th.sortable.active .sort-icon {
            color: var(--accent-color);
        }

        .sort-btn:hover {
            color: #334155;
        }

        .sort-btn.active {
            color: var(--accent-color);
            font-weight: bold;
        }

        td {
            padding: 12px 10px;
            border-bottom: 1px solid var(--border-color);
            vertical-align: middle;
            color: #1e293b;
        }

        #userTableBody td strong {
            color: #0f172a;
            font-weight: 600;
        }

        #userTableBody code {
            color: #0f172a;
            font-weight: 600;
            background: #f1f5f9;
            padding: 2px 6px;
            border-radius: 4px;
        }

        .col-shrink {
            width: 1%;
            white-space: nowrap;
        }

        .col-grow {
            width: auto;
            white-space: nowrap;
        }

        .report-row {
            cursor: pointer;
            transition: background-color 0.2s ease;
        }

        .report-row:hover {
            background-color: #f8fafc;
        }

        .report-row.selected {
            background-color: #e0f2fe !important;
        }

        .timestamp-cell {
            font-weight: 400;
            font-size: 13px;
            color: #2c3e50;
            white-space: nowrap;
        }

        .filename-cell {
            color: #64748b;
            font-family: monospace;
            font-size: 12px;
            word-break: break-word;
            line-height: 1.3;
            cursor: default;
        }

        .profile-badge {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 3px 7px;
            border-radius: 4px;
            font-size: 11px;
            font-weight: 600;
            white-space: nowrap;
            background-color: #e2e8f0;
            color: #475569;
        }

        .profile-badge.sis {
            background-color: #dcfce7;
            color: #15803d;
            border: 1px solid #bbf7d0;
        }

        .profile-badge.uebergabe {
            background-color: #e0f2fe;
            color: #0369a1;
            border: 1px solid #bae6fd;
        }

        .profile-badge.arzt {
            background-color: #ffedd5;
            color: #c2410c;
            border: 1px solid #fed7aa;
        }

        .profile-badge.notfall {
            background-color: #fee2e2;
            color: #b91c1c;
            border: 1px solid #fecaca;
        }

        .status-cell {
            text-align: center;
            padding: 8px 10px;
            white-space: nowrap;
        }

        .status-pill {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 3px 8px;
            border-radius: 12px;
            font-size: 11px;
            font-weight: 600;
        }

        .status-pill.pending {
            background: #fffbeb;
            color: #b45309;
            border: 1px solid #fef3c7;
        }

        .status-pill.approved {
            background: #ecfdf5;
            color: #047857;
            border: 1px solid #d1fae5;
        }

        .status-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            display: inline-block;
            flex-shrink: 0;
            margin-left: 2px;
        }

        .status-dot.pending {
            background-color: #facc15;
            box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.25);
        }

        .status-dot.approved {
            background-color: #0dc47d;
            box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
        }

        .empty-state-row td {
            text-align: center;
            padding: 50px 20px;
            color: #94a3b8;
            font-size: 14px;
        }

        .detail-section {
            display: flex;
            flex-direction: column;
            gap: 16px;
            height: 600px;
            box-sizing: border-box;
        }

        .preview-card {
            border: 1px solid var(--border-color);
            border-radius: 8px;
            background: #fff;
            padding: 0;
            flex: 1;
            min-height: 0;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
            line-height: 1.5;
            user-select: none;
            -webkit-user-select: none;
        }

        .preview-card.unlocked {
            user-select: text;
            -webkit-user-select: text;
        }

        .preview-scroll-area {
            flex: 1;
            overflow-y: auto;
            padding: 16px 20px;
            box-sizing: border-box;
            min-height: 0;
        }

        /* Entfernt die leere Zeile / den oberen Rand des ersten Elements */
        #previewContent> :first-child,
        #previewContent p:first-of-type,
        #previewContent h4:first-of-type,
        #previewContent strong:first-of-type {
            margin-top: 0 !important;
            padding-top: 0 !important;
        }

        /* Erzeugt eine saubere Leerzeile zwischen den Absätzen / 6 Themenfeldern */
        #previewContent p,
        #previewContent div {
            margin-bottom: 10px;
            margin-top: 0;
            line-height: 1.5;
        }

        #previewContent h3,
        #previewContent h4,
        #previewContent>b:first-child,
        #previewContent>strong:first-child,
        #previewContent p:first-child {
            margin-top: 0 !important;
            margin-bottom: 4px !important;
            display: block;
        }

        /* Ignoriert ein direkt auf <h3> folgendes <br>-Tag */
        #previewContent>h3+br,
        #previewContent>h2+br {
            display: none;
        }

        /* Falls die Punkte mit fetten Titeln (z.B. 1. Kognition...) formatiert sind */
        #previewContent strong {
            display: inline-block;
            margin-top: 8px;
        }

        #previewContent strong:first-of-type {
            margin-top: 0;
        }

        #previewContent {
            font-size: clamp(13px, 0.95vw, 15px);
            line-height: 1.5;
        }

        .action-card h3,
        .form-card h3 {
            margin-top: 0;
            color: var(--primary-color);
            font-size: 16px;
            border-bottom: 1px solid var(--border-color);
            padding-bottom: 10px;
            margin-bottom: 15px;
            text-align: left;
        }

        .preview-card>h3 {
            margin-top: 0;
            margin-left: 0;
            margin-right: 0;
            background-color: #f8fafc;
            color: #64748b;
            font-size: 12px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            text-align: center;
            border-bottom: 1px solid var(--border-color);
            padding: 12px 10px;
            margin-bottom: 0;
            border-top-left-radius: 8px;
            border-top-right-radius: 8px;
            flex-shrink: 0;
        }

        #previewContent h3 {
            font-size: 1em;
            font-weight: 700;
            color: var(--text-color);
            text-align: left;
            text-transform: none;
            letter-spacing: normal;
            border-bottom: none;
            padding-bottom: 0;
            margin-top: 0;
            margin-bottom: 6px;
        }

        .action-card,
        .form-card {
            border: 1px solid var(--border-color);
            border-radius: 8px;
            background: #f8fafc;
            padding: 10px 14px;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .form-group {
            display: flex;
            flex-direction: column;
            gap: 6px;
            margin-bottom: 12px;
        }

        .form-group label {
            font-size: 12px;
            font-weight: 600;
            color: #475569;
        }

        .form-group input,
        .form-group select {
            padding: 10px 12px;
            border: 1px solid var(--border-color);
            border-radius: 6px;
            font-size: 14px;
            color: var(--text-color);
            background: #fff;
            box-sizing: border-box;
            width: 100%;
        }

        .form-group input:focus,
        .form-group select:focus {
            outline: none;
            border-color: var(--accent-color);
        }

        .checkbox-container {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            font-size: 13px;
            line-height: 1.5;
            cursor: pointer;
            user-select: none;
        }

        .checkbox-container input {
            margin-top: 2px;
        }

        .btn {
            width: 100%;
            padding: 8px 12px;
            border: none;
            border-radius: 6px;
            font-weight: 600;
            font-size: 13px;
            cursor: pointer;
            transition: all 0.2s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .btn-copy {
            background-color: var(--accent-color);
            color: white;
            transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
        }

        .btn-copy:hover:not(:disabled) {
            background-color: #16a085;
        }

        .btn-copy.copied {
            background-color: #27ae60 !important;
            border-color: #27ae60 !important;
            color: white !important;
        }

        .btn-delete {
            background-color: transparent;
            color: var(--danger-color);
            border: 1px solid var(--danger-color);
        }

        .btn-delete:hover:not(:disabled) {
            background-color: #fdf2f2;
        }

        .btn-submit {
            background-color: var(--primary-color);
            color: white;
            margin-top: 5px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .btn-submit:hover:not(:disabled) {
            background-color: #1e293b;
        }

        .btn-row-del {
            padding: 6px 12px;
            font-size: 12px;
            border-radius: 4px;
            border: 1px solid var(--danger-color);
            color: var(--danger-color);
            background: transparent;
            cursor: pointer;
        }

        .btn-row-del:hover {
            background: #fee2e2;
        }

        .btn:disabled {
            background-color: #e2e8f0;
            color: #94a3b8;
            border-color: #e2e8f0;
            cursor: not-allowed;
        }

        .toast {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%) translateY(100px);
            background-color: #334155;
            color: white;
            padding: 12px 24px;
            border-radius: 30px;
            font-size: 14px;
            transition: transform 0.3s ease;
            z-index: 1000;
        }

        .toast.show {
            transform: translateX(-50%) translateY(0);
        }

        /* Speziell für kompakte Bildschirme / 13-Zoll-Laptops mit geringer vertikaler Höhe */
        @media (max-height: 800px) {
            body {
                padding: 6px 12px;
            }

            .dashboard-container {
                padding: 10px 16px;
            }

            .header-bar {
                margin-bottom: 12px;
            }

            h1 {
                font-size: 20px;
                margin-bottom: 2px;
            }

            .mandant-badge {
                font-size: 12px;
                margin-bottom: 8px;
            }

            .nav-tabs {
                margin-bottom: 8px;
                padding-bottom: 4px;
                gap: 6px;
            }


            .tab-btn {
                padding: 6px 12px;
                font-size: 13px;
                border-radius: 4px;
            }

            .liability-box {
                padding: 6px 10px;
                font-size: 13px;
                line-height: 1.35;
                margin-bottom: 16px;
            }

            #previewContent h4 {
                font-size: 14px;
                margin-bottom: 4px;
            }

            #previewContent p,
            #previewContent div {
                margin-bottom: 8px;
            }

            .preview-card>h3 {
                font-size: 12px;
                margin-left: -12px;
                margin-right: -12px;
                padding: 8px 10px;
                margin-bottom: 8px;
            }

            .action-card h3 {
                font-size: 14px;
                margin-bottom: 8px;
                padding-bottom: 4px;
            }

            .action-card {
                padding: 8px 12px;
                gap: 5px;
            }

            .btn {
                padding: 6px 10px;
                font-size: 12px;
            }
        }