.doc-scanner {
    display: block;
    width: 100%;
    color: #0f172a;
}

.doc-scanner__banner {
    margin-bottom: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.22);
    color: #1e3a8a;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.4;
}

.doc-scanner__style {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #475569;
}

.doc-scanner__style select {
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: 8px;
    padding: 0.4rem 0.55rem;
    background: #fff;
    font-weight: 600;
}

.doc-scanner__layout {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(240px, 0.9fr);
    gap: 1rem;
    min-height: 28rem;
}

.doc-scanner__stage,
.doc-scanner__sidebar {
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 14px;
    background: #f8fafc;
    overflow: hidden;
}

.doc-scanner__viewport {
    position: relative;
    min-height: 26rem;
    display: grid;
    place-items: center;
    background: #0f172a;
}

.doc-scanner__viewport--preview {
    background: #e2e8f0;
}

.doc-scanner__video,
.doc-scanner__canvas,
.doc-scanner__preview-img {
    max-width: 100%;
    max-height: 26rem;
    display: block;
}

.doc-scanner__video {
    width: 100%;
    height: 26rem;
    object-fit: cover;
}

.doc-scanner__overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.doc-scanner__canvas {
    touch-action: none;
    cursor: crosshair;
    background: #111827;
}

.doc-scanner__hint {
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    margin: 0;
    padding: 0.45rem 0.65rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    font-size: 0.78rem;
    text-align: center;
}

.doc-scanner__sidebar {
    display: flex;
    flex-direction: column;
    background: #fff;
}

.doc-scanner__pages {
    flex: 1;
    padding: 0.9rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    overflow: auto;
}

.doc-scanner__pages-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.65rem;
    font-size: 0.85rem;
}

.doc-scanner__page-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 0.55rem;
}

.doc-scanner__page-thumb {
    position: relative;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 10px;
    background: #f8fafc;
    padding: 0.25rem;
    cursor: pointer;
}

.doc-scanner__page-thumb.is-active {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.doc-scanner__page-thumb img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.doc-scanner__page-thumb span {
    display: block;
    text-align: center;
    font-size: 0.7rem;
    margin-top: 0.2rem;
}

.doc-scanner__page-remove {
    position: absolute !important;
    top: 0.15rem;
    right: 0.2rem;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.75);
    color: #fff !important;
    line-height: 1.1rem;
    margin: 0 !important;
}

.doc-scanner__empty {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 0.8rem;
    color: #64748b;
}

.doc-scanner__actions {
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.doc-scanner__action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.doc-scanner__action-row--attach {
    margin-top: 0.25rem;
}

.doc-scanner__btn {
    appearance: none;
    border: 1px solid rgba(15, 23, 42, 0.14);
    background: #fff;
    color: #0f172a;
    border-radius: 999px;
    padding: 0.45rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.doc-scanner__btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.doc-scanner__btn--primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.doc-scanner__btn--success {
    background: #059669;
    border-color: #059669;
    color: #fff;
    width: 100%;
}

.doc-scanner__status {
    margin: 0;
    font-size: 0.78rem;
    color: #047857;
}

.doc-scanner__error {
    margin: 0;
    font-size: 0.78rem;
    color: #b91c1c;
}

/* Keep View / Download clickable above FilePond overlays. */
.fi-fo-file-upload .filepond--open-icon,
.fi-fo-file-upload .filepond--download-icon {
    pointer-events: auto !important;
    z-index: 6 !important;
    position: relative;
}

[x-cloak] {
    display: none !important;
}

.public-doc-scanner-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 4000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.public-doc-scanner-modal.is-open {
    display: flex;
}

.public-doc-scanner-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(8px);
}

.public-doc-scanner-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(72rem, calc(100vw - 1.5rem));
    max-height: min(94vh, 56rem);
    overflow: auto;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.35);
}

.public-doc-scanner-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem 0.85rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background: linear-gradient(180deg, #f8fafc, #fff);
}

.public-doc-scanner-modal__kicker {
    margin: 0 0 0.2rem;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #2563eb;
}

.public-doc-scanner-modal__header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    color: #0f172a;
}

.public-doc-scanner-modal__close {
    appearance: none;
    width: 2.4rem;
    height: 2.4rem;
    border: none;
    border-radius: 999px;
    background: #f1f5f9;
    color: #0f172a;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.public-doc-scanner-modal__body {
    padding: 1rem 1.15rem 1.2rem;
}

body.doc-scanner-modal-open {
    overflow: hidden;
}

@media (max-width: 900px) {
    .doc-scanner__layout {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .doc-scanner__viewport {
        min-height: 18rem;
    }

    .doc-scanner__video {
        height: 18rem;
    }
}
