html {
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

:root {
    --app-visual-viewport-height: 100vh;
    --app-visual-viewport-offset-top: 0px;
}

@supports (height: 100dvh) {
    :root {
        --app-visual-viewport-height: 100dvh;
    }
}

body.modal-open {
    overflow: hidden;
    overscroll-behavior: none;
}

/* Einsatzbezogene Arbeitsansicht innerhalb der Einsatzverwaltung. */
.embedded-operation-view .embedded-admin-action {
    display: none !important;
}

.embedded-operation-view .app-header {
    box-shadow: 0 1px 0 var(--line);
}

.embedded-operation-view .workspace {
    max-width: none;
}

.incident-row {
    grid-template-columns: minmax(0, 1fr);
}

.incident-summary-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.incident-summary-head > strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.incident-status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border: 0;
    border-radius: 999px;
    color: #fff !important;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 5px 9px;
    white-space: nowrap;
}

.incident-status-badge.is-open {
    background: var(--primary, #e60005);
}

.incident-status-badge.is-closed {
    background: var(--accent, #2276d0);
}

.incident-status-badge.is-archived {
    background: var(--muted, #666);
}

.permission-sheet {
    width: min(560px, 100%);
}

.permission-content {
    display: grid;
    gap: 8px;
    color: var(--text);
}

.permission-content p {
    margin: 0;
}

.permission-status {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
    padding: 9px 10px;
}

.permission-status.success {
    border-color: rgba(25, 135, 84, .28);
    background: rgba(25, 135, 84, .08);
    color: var(--success);
}

.permission-status.error {
    border-color: rgba(159, 47, 47, .28);
    background: rgba(159, 47, 47, .08);
    color: var(--danger);
}

.permission-actions {
    justify-content: flex-end;
}

.delete-confirm-summary {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
    margin: 0 0 12px;
}

textarea[aria-invalid="true"],
input[aria-invalid="true"] {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(159, 47, 47, .12);
}

.processing-step {
    min-height: 260px;
    display: grid;
    place-items: center;
    padding: 18px 0 24px;
}

.processing-card {
    display: grid;
    justify-items: center;
    gap: 10px;
    max-width: 360px;
    color: var(--text);
    text-align: center;
}

.processing-card h3 {
    margin: 4px 0 0;
    font-size: 20px;
    font-weight: 700;
}

.processing-card p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.processing-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(230, 0, 5, .14);
    border-top-color: var(--primary, #e60005);
    border-radius: 50%;
    animation: processing-spin .9s linear infinite;
}

@keyframes processing-spin {
    to {
        transform: rotate(360deg);
    }
}

.modal-backdrop {
    top: var(--app-visual-viewport-offset-top, 0px);
    bottom: auto;
    min-height: 0;
    height: var(--app-visual-viewport-height, 100vh);
    overflow: hidden;
}

.modal-sheet,
.modal-sheet.compact,
.modal-sheet.side-sheet {
    max-height: min(calc(var(--app-visual-viewport-height, 100vh) - 24px), 840px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

@media (max-width: 860px) {
    .incident-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .app-shell {
        min-height: 100dvh;
    }

    .modal-backdrop {
        min-height: 0;
        height: var(--app-visual-viewport-height, 100dvh);
        padding: 0 0 max(14px, env(safe-area-inset-bottom));
    }

    .modal-sheet,
    .modal-sheet.compact,
    .modal-sheet.side-sheet {
        max-height: calc(var(--app-visual-viewport-height, 100dvh) - max(22px, env(safe-area-inset-bottom)));
        padding-bottom: calc(24px + max(16px, env(safe-area-inset-bottom)));
        scroll-padding-top: 66px;
        scroll-padding-bottom: calc(76px + max(16px, env(safe-area-inset-bottom)));
    }

    .sticky-actions {
        bottom: 0;
        margin-bottom: 0;
        padding-bottom: calc(18px + max(16px, env(safe-area-inset-bottom)));
    }

    .mobile-command-bar {
        bottom: calc(12px + max(0px, env(safe-area-inset-bottom)));
    }

    .incident-row {
        min-height: 0;
        padding: 14px 16px;
    }

    .incident-summary {
        gap: 7px;
    }

    .incident-summary span,
    .incident-summary small,
    .incident-summary .small,
    .timeline-row-meta,
    .timeline-row-meta small,
    .timeline-row-meta .small,
    .entry-sequence,
    .entry-recorded-at,
    .time-adjust-note,
    .record-meta,
    .permission-content,
    .permission-status,
    .form-message,
    .delete-reason,
    .empty-state.compact {
        font-size: 13.5px;
    }

    .field > span,
    .field-label-row,
    .dropdown-item,
    .qr-code-url,
    .media-permission-panel p {
        font-size: 14px;
    }

    .permission-actions .icon-button {
        flex: 1 1 100%;
    }
}

@media (max-width: 430px) {
    .incident-summary-head {
        align-items: flex-start;
    }

    .incident-summary-head > strong {
        white-space: normal;
    }
}
