:root {
    color-scheme: light;
    --page-bg: #b7b7b7;
    --paper: #ffffff;
    --text: #222222;
    --muted: #5f6673;
    --accent: #b40000;
    --accent-dark: #8f0000;
    --danger: #e64747;
    --warning: #ffc107;
    --open: #ffc7ce;
    --submitted: #c6efce;
    --ready: #ffc107;
    --border: #d5d8df;
}

/* Grundlayout */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: var(--page-bg);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

/* Buttons */

button {
    padding: 0.65rem 0.9rem;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
    button:hover:not([disabled]) {
        background: var(--accent-dark);
    }
}

button[disabled] {
    cursor: not-allowed;
    opacity: 0.55;
}

/* Anwendung */

.app-shell {
    min-height: 100vh;
}

/* Anmeldung */

.login-view {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1rem;
}

.login-form {
    display: grid;
    width: min(360px, 100%);
    gap: 1rem;
    padding: 1.5rem;
    background: var(--paper);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(120, 0, 0, 0.35);
}

    .login-form h1 {
        margin: 0 0 0.25rem;
        font-size: 1.4rem;
    }

/* Formularelemente */

label {
    display: grid;
    gap: 0.35rem;
    color: var(--muted);
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    background: white;
}

textarea {
    min-height: 5rem;
    resize: vertical;
}

/* Arbeitsbereich */

.workspace {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 0.45rem;
}

/* Kopfzeilen */

.topbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

    /*
 * Linker Bereich:
 * Name, Ausbildungsjahr, Logout und Alle Berichte
 * stehen nebeneinander.
 */

    .topbar .user-info {
        display: grid;
        grid-template-columns: max-content max-content max-content max-content;
        align-items: center;
        width: auto;
        gap: 0.75rem;
    }

        .topbar .user-info > strong,
        .topbar .user-info > span,
        .topbar .user-info > button {
            display: block;
            width: auto;
            margin: 0;
            white-space: nowrap;
        }

        .topbar .user-info > span {
            color: var(--muted);
        }

/* Alle anderen Aktionsgruppen nach rechts */

.actions,
.edit-actions,
.sign-actions {
    margin-left: auto;
}

/* Übersicht: Signieren und Bearbeiten */

.actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 0.4rem;
}

    .actions button {
        width: 100%;
        white-space: nowrap;
    }

/* Bearbeiten- und Signaturaktionen */

.edit-actions,
.sign-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

    .edit-actions button,
    .sign-actions button {
        white-space: nowrap;
    }

    .edit-actions button {
        min-width: 90px;
    }

    .sign-actions button {
        min-width: 108px;
    }

/* Benachrichtigungen */

.notifications {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.notice {
    padding: 0.75rem;
    border-radius: 6px;
}

    .notice.danger {
        background: var(--danger);
        color: white;
    }

    .notice.warning {
        background: var(--warning);
        color: #1f1f1f;
    }

/* Bericht */

.content-grid {
    display: block;
    width: 100%;
}

.report-paper {
    width: 100%;
    padding: 1.4rem;
    overflow-x: auto;
    background: var(--paper);
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(255, 0, 0, 0.55);
}

    .report-paper.compact {
        margin-bottom: 1rem;
    }

/* Berichtskopf */

.report-head {
    position: relative;
    min-height: 72px;
    text-align: center;
}

    .report-head img {
        position: absolute;
        top: 0;
        right: 0;
        width: auto;
        height: 60px;
        max-width: 150px;
        object-fit: contain;
    }

.report-title {
    margin: 0 80px 0.6rem;
    font-size: 1.1rem;
}

/* Berichtsinformationen */

.report-meta {
    display: grid;
    justify-content: center;
    gap: 0.45rem;
    margin-bottom: 1rem;
    text-align: center;
}

/* Tabellen */

.report-table,
.edit-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.report-table {
    table-layout: fixed;
}

    .report-table th,
    .report-table td,
    .edit-table th,
    .edit-table td {
        padding: 0.45rem;
        border: 1px solid #333;
        vertical-align: top;
    }

    .report-table .column-weekday {
        width: 110px;
    }

    .report-table .column-activity {
        width: auto;
    }

    .report-table .column-hours {
        width: 130px;
    }

.weekday {
    width: 110px;
    font-weight: 700;
    white-space: nowrap;
}

.hours {
    width: 120px;
    text-align: center;
}

.report-table td.activity-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

/* Wochenleiste */

.week-strip {
    display: flex;
    width: 100%;
    gap: 0.4rem;
    overflow-x: auto;
    padding: 1rem 4px;
    scroll-padding-inline: 4px;
}

    .week-strip button {
        flex: 0 0 auto;
        -webkit-tap-highlight-color: transparent;
        background: #e9edf3;
        color: #111;
    }

    .week-strip .Offen {
        background: var(--open);
    }

    .week-strip .Abgeschlossen {
        background: var(--submitted);
    }

    .week-strip .AbgabeFertig {
        background: var(--ready);
    }

    .week-strip .selected {
        outline: 2px solid var(--accent);
        outline-offset: -2px;
    }

/* Formulare */

.report-form,
.signature-form {
    display: grid;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--paper);
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(255, 0, 0, 0.55);
}

.table-wrap {
    overflow-x: auto;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Fehlermeldung */

.form-error {
    margin: 0;
    padding: 0.75rem;
    border-radius: 6px;
    background: #fee2e2;
    color: #991b1b;
}

/* Bearbeitungsseite */

.edit-view-form {
    display: block;
    width: 100%;
    margin: 0;
}

.edit-topbar {
    margin-bottom: 0.6rem;
}

.edit-view-form .report-form {
    width: 100%;
}

.edit-view-form .edit-table textarea {
    min-height: 72px;
}

.edit-view-form .edit-table input {
    min-width: 70px;
}

/* Signaturseite */

.sign-view-form {
    display: block;
    width: 100%;
    margin: 0;
}

.sign-topbar {
    margin-bottom: 0.6rem;
}

.sign-view-form .report-paper {
    width: 100%;
}

.sign-view-form .signature-form {
    width: 100%;
    min-height: 310px;
}

/* Signaturformular */

.signature-form {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 1rem !important;
    width: 100%;
}

/* Drei Signaturfelder */

.signature-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 1rem;
    width: 100%;
    align-items: start;
}

    .signature-grid label {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        min-width: 0;
        margin: 0;
    }

        .signature-grid label > span {
            display: block;
            min-height: 42px;
            margin-bottom: 6px;
            font-weight: 600;
        }

    /* Zeichenfläche */

    .signature-grid canvas {
        display: block;
        width: 100% !important;
        height: 135px !important;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: white;
        touch-action: none;
    }

/* Signaturdatum */

.signature-date {
    display: block;
    min-height: 38px;
    margin-top: 8px;
    color: #555;
    font-size: 0.82rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
}

    .signature-date:empty {
        visibility: hidden;
    }

/* Fehlermeldungen im Signaturformular */

.signature-form .form-error[hidden] {
    display: none !important;
}

.signature-form .form-error:not([hidden]) {
    display: block;
    width: 100%;
    margin: 0;
}

/* Gespeicherte Signaturen */

.saved-signatures {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
    width: 100%;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.saved-signature {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.saved-signature-title {
    display: block;
    min-height: 40px;
    margin-bottom: 0.4rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.saved-signature-image {
    display: block;
    width: 100%;
    height: 110px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    object-fit: contain;
}

.saved-signature-date {
    display: block;
    min-height: 1.4em;
    margin-top: 0.5rem;
    color: #555;
    font-size: 0.8rem;
    line-height: 1.35;
}

/* Tablet */

@media (min-width: 521px) and (max-width: 820px) {
    /* Tag-Spalte etwas breiter */

    .report-table col.column-weekday {
        width: 145px !important;
    }

    .report-table th:first-child,
    .report-table td:first-child,
    .edit-table th:first-child,
    .edit-table td:first-child {
        width: 145px !important;
        min-width: 145px !important;
        padding-left: 10px;
        padding-right: 10px;
        white-space: nowrap;
    }

    .topbar,
    .edit-topbar,
    .sign-topbar {
        display: flex;
        flex-direction: row;
        align-items: center;
    }

        .topbar .user-info {
            grid-template-columns: max-content max-content max-content max-content;
        }

    .actions,
    .edit-actions,
    .sign-actions {
        margin-left: auto;
    }
}

/* Tablet und kleinere Bildschirme */

@media (max-width: 820px) {
    .signature-grid {
        grid-template-columns: 1fr !important;
    }

        .signature-grid label > span {
            min-height: auto;
        }

    .report-head {
        padding-top: 68px;
    }

        .report-head img {
            right: auto;
            left: 50%;
            transform: translateX(-50%);
        }

    .report-title {
        margin-inline: 0;
    }

    .saved-signatures {
        grid-template-columns: 1fr;
    }

    .saved-signature-title {
        min-height: auto;
    }
}

/* Smartphone */

@media (max-width: 520px) {
    .workspace {
        padding: 0.6rem;
    }

    .topbar,
    .edit-topbar,
    .sign-topbar {
        align-items: stretch;
        flex-direction: column;
    }

        /*
   * Erste Zeile:
   * Name und Ausbildungsjahr.
   *
   * Zweite Zeile:
   * Logout und Alle Berichte.
   */

        .topbar .user-info {
            display: grid;
            grid-template-columns: max-content max-content;
            align-items: center;
            width: 100%;
            gap: 0.5rem;
        }

            .topbar .user-info > strong,
            .topbar .user-info > span,
            .topbar .user-info > button {
                width: auto;
                margin: 0;
                white-space: nowrap;
            }

    .actions,
    .edit-actions,
    .sign-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
        margin-left: 0;
    }

        .actions button,
        .edit-actions button,
        .sign-actions button {
            width: 100%;
            min-width: 0;
        }

    .report-paper,
    .report-form,
    .signature-form {
        padding: 1rem;
    }
}

/* Benutzername und Ausbildungsjahr sicher nebeneinander */

.topbar .user-info {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    width: auto !important;
    gap: 0.75rem !important;
}

.user-identity {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 0.75rem !important;
    width: auto !important;
    white-space: nowrap !important;
}

    .user-identity > strong,
    .user-identity > span {
        display: inline-block !important;
        width: auto !important;
        margin: 0 !important;
        white-space: nowrap !important;
    }

    .user-identity > span {
        color: var(--muted);
    }

.topbar .user-info > button {
    flex: 0 0 auto !important;
    width: auto !important;
    margin: 0 !important;
    white-space: nowrap !important;
}

/* Auf sehr kleinen Smartphones dürfen nur die Buttons umbrechen */

@media (max-width: 520px) {
    .topbar .user-info {
        flex-wrap: wrap !important;
    }

    .user-identity {
        flex: 0 0 100% !important;
    }
}

[data-export-all] {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
}

    [data-export-all] .pdf-icon {
        display: block;
        flex: 0 0 auto;
        width: 22px;
        height: 22px;
        color: white;
    }