html, body {
    font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html, body, #app {
    min-height: 100%;
}

body {
    overscroll-behavior-y: none;
    touch-action: manipulation;
}

.doctopus-standalone body {
    background: var(--mud-palette-background);
}

.doctopus-standalone .mud-appbar {
    padding-top: env(safe-area-inset-top, 0px);
}

.doctopus-standalone .main-content,
.doctopus-standalone .auth-main-content {
    padding-left: calc(12px + env(safe-area-inset-left, 0px)) !important;
    padding-right: calc(12px + env(safe-area-inset-right, 0px)) !important;
}

.doctopus-standalone .main-content {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
}

@media (max-width: 959.98px) {
    .mud-snackbar-location-bottom-center {
        bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
        left: calc(8px + env(safe-area-inset-left, 0px)) !important;
        right: calc(8px + env(safe-area-inset-right, 0px)) !important;
        width: auto !important;
    }

    .mud-icon-button:not(.documents-toolbar-add) {
        min-height: 44px;
        min-width: 44px;
    }

    .page-heading {
        font-size: 1.35rem !important;
        line-height: 1.25;
    }

    .responsive-table-panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .responsive-table-panel .mud-table {
        min-width: 520px;
    }

    .library-sharing-form {
        flex-direction: column;
        align-items: stretch;
    }

    .library-sharing-email {
        max-width: none;
        width: 100%;
    }
}

h1:focus {
    outline: none;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--mud-palette-primary, #594ae2);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

.auth-form-card {
    width: 100%;
}

.main-content {
    padding: 12px !important;
    padding-top: calc(var(--mud-appbar-height) + 8px) !important;
}

@media (min-width: 960px) {
    .main-content {
        padding: 16px !important;
        padding-top: calc(var(--mud-appbar-height) + 12px) !important;
    }
}

.app-bar-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.app-bar-brand:hover,
.app-bar-brand:focus-visible {
    color: inherit;
    text-decoration: none;
}

.app-bar-logo {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border-radius: 6px;
}

.app-bar-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-drawer .mud-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.app-drawer-inner {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
}

.app-drawer-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.app-drawer-footer {
    flex: 0 0 auto;
    padding: 8px;
    border-top: 1px solid var(--mud-palette-lines-default);
}

/* Main-layout pages: title is already in the nav drawer on desktop. */
@media (min-width: 960px) {
    .page-heading,
    .documents-page-title {
        display: none !important;
    }
}

@media (max-width: 959.98px) {
    .main-content {
        display: flex;
        flex-direction: column;
        min-height: calc(100dvh - var(--mud-appbar-height) - env(safe-area-inset-top, 0px));
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .documents-page {
        flex: 1 1 auto;
        min-height: 0;
        max-width: 100%;
        width: 100%;
        gap: 8px;
        max-height: none;
    }

    .documents-page-title {
        flex: 0 0 auto;
        margin: 0;
    }

    .documents-toolbar {
        flex: 0 0 auto;
        margin: 0;
    }

    .documents-list-panel-wrapper {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    .documents-list-panel {
        max-height: 100%;
        overflow-y: auto;
    }

    .document-tree-row-meta {
        display: none;
    }
}

.documents-page {
    width: 100%;
    max-width: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.documents-bulk-progress {
    margin-top: -4px;
}

.documents-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.documents-toolbar-search {
    flex: 1 1 auto;
    min-width: 0;
}

.documents-toolbar-add {
    flex: 0 0 auto;
}

.documents-list-panel-wrapper {
    border-radius: var(--mud-default-borderradius);
    transition: box-shadow 0.2s ease, outline 0.2s ease;
}

.documents-list-panel-wrapper.documents-list-dragover {
    outline: 2px dashed var(--mud-palette-primary);
    outline-offset: -2px;
    box-shadow: 0 0 0 4px rgba(var(--mud-palette-primary-rgb), 0.12);
}

.documents-list-panel {
    overflow: hidden;
}

.documents-tree {
    --documents-tree-item-height: 26px;
    padding: 2px 0 4px;
}

.documents-tree .document-tree-library > .mud-treeview-item-content {
    font-weight: 600;
}

.documents-tree .document-tree-library .document-tree-folder-label {
    font-weight: 500;
}

.documents-tree .mud-treeview-item {
    margin: 0;
}

.documents-tree .mud-treeview-item-content {
    min-height: var(--documents-tree-item-height);
    padding-top: 0;
    padding-bottom: 0;
}

.documents-tree .document-tree-folder > .mud-treeview-item-content {
    min-height: calc(var(--documents-tree-item-height) + 2px);
}

.documents-tree .mud-treeview-item-label {
    font-size: 0.8125rem;
    line-height: 1.2;
}

.documents-tree .mud-treeview-item-icon .mud-icon-root {
    font-size: 1.05rem !important;
}

.documents-tree .mud-treeview-item-arrow .mud-icon-button {
    width: 24px;
    height: 24px;
    padding: 2px;
}

.documents-tree .document-tree-folder .mud-treeview-item-arrow {
    display: none !important;
}

.documents-tree .document-tree-file .mud-treeview-item-content {
    padding-top: 0;
    padding-bottom: 0;
}

.documents-tree .document-tree-file .mud-treeview-item-icon {
    align-self: center;
}

.document-tree-row {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    min-height: var(--documents-tree-item-height);
    padding: 0 2px;
    cursor: pointer;
    border-radius: var(--mud-default-borderradius);
}

.document-tree-drag-handle {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: var(--documents-tree-item-height);
    cursor: grab;
    touch-action: none;
    color: var(--mud-palette-text-secondary);
    border-radius: var(--mud-default-borderradius);
}

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

.document-tree-drag-handle .mud-icon-root {
    font-size: 1rem !important;
}

.document-tree-drag-ghost {
    position: fixed;
    top: -1000px;
    left: -1000px;
    max-width: 280px;
    padding: 4px 10px;
    font-size: 0.8125rem;
    line-height: 1.3;
    color: var(--mud-palette-text-primary);
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    box-shadow: var(--mud-elevation-4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.document-tree-touch-ghost {
    top: 0;
    left: 0;
    z-index: 1300;
}

.documents-tree .document-tree-file .mud-treeview-item-icon {
    display: none;
}

.document-tree-folder-hit {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    min-height: var(--documents-tree-item-height);
    padding: 0 4px;
    line-height: var(--documents-tree-item-height);
    border-radius: var(--mud-default-borderradius);
    font-size: 0.8125rem;
}

.document-tree-folder-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-tree-folder-count {
    flex: 0 0 auto;
    font-size: 0.75rem;
    line-height: 1.2;
}

.document-tree-drop-folder > .mud-treeview-item-content {
    width: 100%;
}

.documents-tree .document-tree-folder .mud-treeview-item-icon {
    cursor: pointer;
}

.document-tree-drop-active {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.14);
    outline: 1px dashed var(--mud-palette-primary);
    outline-offset: -1px;
}

.document-tree-row:hover {
    background-color: var(--mud-palette-action-default-hover);
}

.document-tree-row-title {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.document-tree-row-meta {
    font-size: 0.75rem;
}

.document-tree-processing-chip {
    margin-left: 0.35rem;
    vertical-align: middle;
}

.documents-processing-banner {
    border-radius: 8px;
}

.document-tree-row-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.document-tree-row-actions .mud-icon-button {
    width: 26px;
    height: 26px;
    padding: 2px;
}

.document-tree-row-actions .mud-icon-button .mud-icon-root {
    font-size: 1rem !important;
}

.library-sharing-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.library-sharing-email {
    flex: 1 1 220px;
    max-width: 320px;
}

.documents-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 48px 24px;
    text-align: center;
}

.documents-list-empty-icon {
    font-size: 2rem !important;
    opacity: 0.45;
    margin-bottom: 4px;
}

.document-list-item {
    cursor: pointer;
}

.document-list-item:hover {
    background-color: var(--mud-palette-action-default-hover);
}

.document-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 4px 8px;
    min-height: 44px;
}

.document-row-icon {
    flex-shrink: 0;
}

.document-row-main {
    flex: 1 1 auto;
    min-width: 0;
}

.document-row-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-row-tags {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    max-width: 240px;
    overflow: hidden;
}

.document-row-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.document-tags-loading {
    display: flex;
    justify-content: center;
    padding: 24px;
}

.document-tags-input {
    flex: 1;
    min-width: 140px;
}

.document-tags-algorithm {
    min-width: 160px;
}

.document-row-divider {
    margin: 0 !important;
}

.document-viewer-dialog-content {
    overflow: hidden !important;
    padding-top: 0 !important;
}

.document-viewer-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.document-viewer-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.document-viewer-shell-mobile {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    width: 100%;
}

.document-viewer-mobile-header {
    flex: 0 0 auto;
    padding: 10px 12px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface);
}

.document-viewer-mobile-footer {
    flex: 0 0 auto;
    padding: 10px 12px;
    border-top: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface);
}

/* Mobile fullscreen document viewer: header + preview + footer in one column */
.mud-dialog-container:has(.document-viewer-shell-mobile) {
    padding: 0 !important;
    align-items: stretch !important;
}

.mud-dialog-container:has(.document-viewer-shell-mobile) .mud-dialog {
    display: flex !important;
    flex-direction: column !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 0 !important;
}

.mud-dialog-container:has(.document-viewer-shell-mobile) .mud-dialog-title {
    display: none !important;
}

.mud-dialog-container:has(.document-viewer-shell-mobile) .mud-dialog-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
}

.mud-dialog-container:has(.document-viewer-shell-mobile) .mud-dialog-actions {
    display: none !important;
}

.mud-dialog-container:has(.document-viewer-shell-mobile) .document-viewer-preview {
    flex: 1 1 auto;
    min-height: 0;
    height: 100% !important;
    max-height: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mud-dialog-container:has(.document-viewer-shell-mobile) .document-viewer-body {
    flex: 1 1 auto;
    min-height: 0;
}

.mud-dialog-container:has(.document-viewer-shell-mobile) .document-viewer-loading {
    flex: 1 1 auto;
    align-items: center;
    padding: 24px;
}

.mud-dialog-container:has(.document-viewer-shell-mobile) .document-viewer-image {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.mud-dialog-fullscreen .document-viewer-dialog-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    width: 100% !important;
    max-width: 100% !important;
}

.mud-dialog-fullscreen .document-viewer-preview {
    flex: 1 1 auto;
    min-height: 0;
}

.document-viewer-loading {
    display: flex;
    justify-content: center;
    padding: 48px;
}

.document-viewer-preview {
    height: 70vh;
    overflow: hidden;
}

.document-viewer-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: var(--mud-default-borderradius);
    background: var(--mud-palette-background-gray);
}

.document-viewer-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
    object-fit: contain;
}

.document-viewer-pre {
    height: 100%;
    margin: 0;
    padding: 12px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.8125rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    background: var(--mud-palette-background-gray);
    box-sizing: border-box;
}

.document-viewer-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.new-document-dialog {
    min-height: 120px;
}

.new-document-upload-input {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.new-document-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.new-document-option {
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.new-document-option:hover {
    background-color: var(--mud-palette-action-default-hover);
    border-color: var(--mud-palette-primary) !important;
}

.new-document-option-icon {
    font-size: 2rem !important;
    margin-bottom: 8px;
    color: var(--mud-palette-primary);
}

.scan-camera-shell {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    max-height: 420px;
    border-radius: var(--mud-default-borderradius);
    overflow: hidden;
    background: #111;
}

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

.scan-camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.55) 70%);
}

.scan-camera-frame {
    position: relative;
    width: min(82%, 320px);
    aspect-ratio: 1 / 1.414;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
}

.scan-corner {
    position: absolute;
    width: 22px;
    height: 22px;
    border-color: #fff;
    border-style: solid;
}

.scan-corner-tl {
    top: -1px;
    left: -1px;
    border-width: 3px 0 0 3px;
    border-top-left-radius: 8px;
}

.scan-corner-tr {
    top: -1px;
    right: -1px;
    border-width: 3px 3px 0 0;
    border-top-right-radius: 8px;
}

.scan-corner-bl {
    bottom: -1px;
    left: -1px;
    border-width: 0 0 3px 3px;
    border-bottom-left-radius: 8px;
}

.scan-corner-br {
    bottom: -1px;
    right: -1px;
    border-width: 0 3px 3px 0;
    border-bottom-right-radius: 8px;
}

.new-document-dialog {
    min-height: 120px;
}

.scan-dialog-active {
    padding: 0 !important;
}

.scan-camera-shell-active {
    aspect-ratio: 3 / 4;
    max-height: min(72vh, 640px);
    min-height: 280px;
    flex: 1 1 280px;
    min-width: 220px;
}

.scan-layout {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.scan-debug-panel {
    flex: 0 0 240px;
    max-width: 280px;
    overflow-y: auto;
    max-height: min(72vh, 640px);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.scan-debug-phase {
    font-weight: 600;
    text-transform: capitalize;
}

.scan-debug-ready {
    color: var(--mud-palette-success);
    font-weight: 600;
}

.scan-debug-checks {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scan-debug-check {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 6px 8px;
    border-radius: var(--mud-default-borderradius);
    border: 1px solid var(--mud-palette-lines-default);
}

.scan-debug-check.pass {
    border-color: rgba(76, 175, 80, 0.45);
    background: rgba(76, 175, 80, 0.08);
}

.scan-debug-check.fail {
    border-color: rgba(244, 67, 54, 0.45);
    background: rgba(244, 67, 54, 0.08);
}

.scan-debug-check-icon {
    width: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.scan-debug-check.pass .scan-debug-check-icon {
    color: var(--mud-palette-success);
}

.scan-debug-check.fail .scan-debug-check-icon {
    color: var(--mud-palette-error);
}

.scan-debug-check-body {
    min-width: 0;
}

@media (max-width: 959.98px) {
    .scan-layout {
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }

    .scan-camera-shell-active {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        aspect-ratio: auto;
    }

    .scan-debug-panel {
        flex: 0 0 auto;
        max-width: none;
        max-height: 160px;
    }

    .mud-dialog-container:has(.scan-dialog-active) {
        padding: 0 !important;
        align-items: stretch !important;
    }

    .mud-dialog-container:has(.scan-dialog-active) .mud-dialog {
        display: flex !important;
        flex-direction: column !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .mud-dialog-container:has(.scan-dialog-active) .mud-dialog-content {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .mud-dialog-container:has(.scan-dialog-active) .mud-dialog-actions {
        flex: 0 0 auto;
        margin: 0 !important;
        padding: 10px 12px !important;
        border-top: 1px solid var(--mud-palette-lines-default);
        background: var(--mud-palette-surface);
    }
}

.scan-capture-flash {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0.85;
    animation: scan-flash 0.35s ease-out forwards;
    pointer-events: none;
    z-index: 3;
}

.scan-upload-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    z-index: 4;
    color: #fff;
}

@keyframes scan-flash {
    from {
        opacity: 0.85;
    }

    to {
        opacity: 0;
    }
}

.scan-camera-frame.scan-frame-detecting {
    border-color: rgba(129, 199, 132, 0.95);
    box-shadow: 0 0 0 2px rgba(129, 199, 132, 0.35);
}

.scan-camera-frame.scan-frame-detecting .scan-corner {
    border-color: #c8e6c9;
}

.scan-camera-frame.scan-frame-capturing {
    border-color: rgba(255, 255, 255, 0.95);
}

.scan-preview-image {
    display: block;
    width: 100%;
    max-height: 420px;
    object-fit: contain;
    border-radius: var(--mud-default-borderradius);
    border: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-background-gray);
}
