.pdf-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.pdf-preview-modal[hidden] {
    display: none !important;
}

.pdf-preview-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 12, 22, 0.78);
}

.pdf-preview-dialog {
    position: relative;
    z-index: 1;
    width: min(1280px, 98vw);
    height: min(920px, 94vh);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 28px 80px rgba(8, 12, 22, 0.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pdf-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e8ef;
    background: linear-gradient(180deg, #fff 0%, #f8f9fb 100%);
    flex-shrink: 0;
}

.pdf-preview-header-main {
    min-width: 0;
    flex: 1;
}

.pdf-preview-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #c91016;
}

.pdf-preview-header h2 {
    margin: 4px 0 0;
    font-size: 15px;
    font-weight: 800;
    color: #1a1f2b;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pdf-preview-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pdf-preview-tool,
.pdf-preview-close {
    height: 36px;
    border-radius: 8px;
    border: 1px solid #dce1ea;
    background: #fff;
    color: #303a4f;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 12px;
    text-decoration: none;
    white-space: nowrap;
}

.pdf-preview-close {
    border-color: #efc7ca;
    background: #fff5f6;
    color: #9d1b20;
}

.pdf-preview-tool:hover,
.pdf-preview-close:hover {
    background: #f3f5f8;
}

.pdf-preview-close:hover {
    background: #ffecee;
}

.pdf-preview-body {
    position: relative;
    flex: 1;
    min-height: 0;
    background: #525659;
}

.pdf-preview-loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #f3f4f6;
    color: #5c6478;
    font-size: 13px;
    font-weight: 600;
}

.pdf-preview-loading[hidden] {
    display: none !important;
}

.pdf-preview-loading i {
    font-size: 24px;
    color: #c91016;
}

.pdf-preview-body iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #525659;
}

.pdf-preview-pages {
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 10px 8px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
}

.pdf-preview-page {
    width: 100%;
    max-width: 100%;
    background: #fff;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.28);
    line-height: 0;
}

.pdf-preview-page canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #fff;
}

.pdf-preview-pages[hidden],
.pdf-preview-body iframe[hidden] {
    display: none !important;
}

.pdf-preview-error {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    color: #eceff3;
    text-align: center;
    background: #525659;
}

.pdf-preview-error[hidden] {
    display: none !important;
}

.pdf-preview-error i {
    font-size: 42px;
    opacity: 0.7;
}

.pdf-preview-error p {
    margin: 0;
    max-width: 280px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
}

body.pdf-preview-open {
    overflow: hidden;
}

.be-field-hint .be-pdf-preview-btn {
    border: 0;
    background: none;
    padding: 0;
    color: var(--be-primary, #c91016);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
}

.be-preview-pdf-action {
    margin-bottom: 14px;
}

.be-preview-pdf-action button {
    border: 1px solid #efc7ca;
    background: #fff8f8;
    color: #9d1b20;
    border-radius: 10px;
    height: 38px;
    padding: 0 14px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.doc-thumb {
    position: relative;
    overflow: hidden;
}

.doc-thumb[data-pdf-thumb] {
    cursor: pointer;
}

.doc-thumb canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.doc-thumb.has-thumb canvas {
    display: block;
}

.doc-thumb.has-thumb .doc-thumb-fallback {
    display: none;
}

.doc-preview-btn,
.prokum-page .doc-preview-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #eed5d7;
    border-radius: 8px;
    color: #b21a20;
    background: #fff9f9;
    display: grid;
    place-items: center;
    cursor: pointer;
    font: inherit;
    flex-shrink: 0;
}

.doc-preview-btn:hover,
.prokum-page .doc-preview-btn:hover {
    background: #fff2f3;
    border-color: #e8b8bc;
}

.doc-card .doc-preview-btn {
    width: 34px;
    height: 34px;
}

@media (max-width: 768px) {
    .pdf-preview-modal {
        padding: 0;
        align-items: stretch;
    }

    .pdf-preview-dialog {
        width: 100%;
        height: 100%;
        max-height: 100dvh;
        border-radius: 0;
    }

    .pdf-preview-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: max(10px, env(safe-area-inset-top, 0px)) 12px 10px;
    }

    .pdf-preview-header h2 {
        font-size: 14px;
        -webkit-line-clamp: 3;
    }

    .pdf-preview-toolbar {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .pdf-preview-tool,
    .pdf-preview-close {
        justify-content: center;
        min-height: 44px;
        height: auto;
        padding: 8px 6px;
        font-size: 11px;
        white-space: normal;
        text-align: center;
        line-height: 1.2;
    }

    .pdf-preview-body {
        flex: 1;
        min-height: 0;
        height: auto;
    }

    .pdf-preview-body iframe,
    .pdf-preview-pages {
        display: block;
        width: 100%;
        height: 100%;
        min-height: 0;
    }

    .doc-preview-btn,
    .prokum-page .doc-preview-btn,
    .doc-card .doc-preview-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .pdf-preview-toolbar {
        grid-template-columns: 1fr 1fr;
    }

    .pdf-preview-close {
        grid-column: span 2;
    }
}
