html, body {
    margin: 0;
    min-height: 100%;
    background-color: var(--mud-palette-background, #fafafa);
    font-family: "Roboto", "Helvetica", "Arial", sans-serif;
}

body {
    min-height: 100vh;
}

h1:focus {
    outline: none;
}

h1, h2, h3, h4, h5, h6,
.mud-typography-h1, .mud-typography-h2, .mud-typography-h3,
.mud-typography-h4, .mud-typography-h5, .mud-typography-h6 {
    font-family: "Roboto", "Segoe UI", "Helvetica", "Arial", sans-serif;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ---- Header ---- */
.rka-header .mud-toolbar {
    padding: 0 8px;
}

.rka-header-menu {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.rka-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    position: relative;
}

.rka-header-title {
    min-width: 0;
    text-align: center;
    pointer-events: none;
    overflow: hidden;
}

/* ---- Login Header ---- */
.rka-login-header {
    background-color: var(--mud-palette-primary);
    width: 100%;
}

.rka-login-header-title {
    text-align: center;
}

.rka-header-auth {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    position: relative;
    z-index: 2;
}

.rka-user-initials {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid white;
    background-color: transparent;
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
}

.rka-user-name-text {
    display: inline;
    color: white;
}

.rka-header-title-large {
    display: block;
}

.rka-header-title-small {
    display: none;
}

.rka-header-title-text {
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: clamp(0.85rem, 2.2vw, 1.4rem);
    line-height: 1.2;
}

.rka-user-icon {
    display: inline-flex;
}

.rka-user-activator {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    color: white;
    user-select: none;
}

    .rka-user-activator:hover {
        background-color: rgba(255, 255, 255, 0.12);
    }

/* ---- Sidebar ---- */
.app-sidebar .mud-drawer-content {
    padding-top: 8px;
}

/* ---- Flexbox-Overflow-Fix: erlaubt Inhalten (z. B. Tabellen),
       sich an die verfügbare Breite anzupassen statt den Inhaltsbereich aufzuweiten ---- */
.mud-main-content {
    min-width: 0;
}

.mud-main-content > .mud-container {
    min-width: 0;
    max-width: 100%;
}

@media (max-width: 768px) {
    html, body {
        width: 100%;
        overflow-x: hidden;
        -webkit-tap-highlight-color: transparent;
        touch-action: auto;
    }

    body {
        min-height: 100dvh;
    }

    .mud-layout {
        min-height: 100dvh;
        background-color: var(--mud-palette-background, #fafafa);
    }

    .rka-header {
        padding-top: env(safe-area-inset-top);
        min-height: calc(64px + env(safe-area-inset-top));
    }

    .rka-header .mud-toolbar {
        min-height: 64px;
    }

    .rka-login-header {
        padding-top: env(safe-area-inset-top);
    }

    .mud-main-content {
        padding-bottom: env(safe-area-inset-bottom);
        touch-action: auto;
    }

    .mud-main-content > .mud-container {
        padding-left: 12px;
        padding-right: 12px;
        padding-top: 12px;
    }

    .mud-main-content .mud-paper {
        box-shadow: none !important;
        border: none !important;
        width: 100%;
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
        background: linear-gradient(180deg, #e3f2fd 0 2px, var(--mud-palette-surface) 2px);
    }

    .rka-header-title-large {
        display: none;
    }

    .rka-header-title-small {
        display: block;
    }

    .rka-header-title-small.rka-header-title-text {
        font-size: clamp(1rem, 5vw, 1.35rem);
    }

    .rka-header-auth {
        gap: 6px;
    }

    .rka-user-activator {
        gap: 6px;
    }

    .rka-user-name-text {
        display: none;
    }

    .rka-user-icon {
        display: none;
    }

    .rka-user-initials {
        display: flex;
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
}

@media (max-width: 1024px) {
    html:has(.mud-dialog-container .mud-dialog),
    body:has(.mud-dialog-container .mud-dialog) {
        overflow: hidden;
        height: 100dvh;
    }

    .mud-dialog-container {
        align-items: stretch;
        overflow: hidden;
        padding: 0;
        overscroll-behavior: contain;
        touch-action: pan-y;
    }

    .mud-dialog {
        margin: 0;
        width: 100dvw;
        max-width: 100dvw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .mud-dialog-title {
        padding-top: calc(12px + env(safe-area-inset-top));
        padding-left: 16px;
        padding-right: 16px;
    }

    .mud-dialog-content {
        flex: 1 1 auto;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: auto;
        padding-left: 12px;
        padding-right: 12px;
        padding-bottom: 12px;
    }

    .mud-dialog-content > [class*="dialog-root"] {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .mud-dialog-actions {
        position: sticky;
        bottom: 0;
        background: var(--mud-palette-surface);
        border-top: 1px solid var(--mud-palette-lines-default);
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        z-index: 2;
    }
}

.mud-button-root .mud-button-label {
    white-space: nowrap;
    flex-wrap: nowrap;
}

.mud-button-allow-wrap .mud-button-label {
    white-space: normal;
    flex-wrap: wrap;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}


.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjwvc3ZnPg==) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

.rka-login-shadow-input {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.rka-remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.rka-remember-me-input {
    width: 18px;
    height: 18px;
    accent-color: var(--mud-palette-primary);
    cursor: pointer;
}
