.file-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 12px;
}

.file-preview-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    max-width: 130px;
}

.file-preview-open {
    height: 96px;
    width: 96px;
    padding: 6px;
    border: 1px solid #e2e4ee;
    border-radius: 6px;
    background: #f7f8fc;
    display: grid;
    place-content: center;
    cursor: zoom-in;
    overflow: hidden;
}

.file-preview-open img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.file-preview-open i {
    font-size: 34px;
    color: #6b7280;
}

.file-preview-meta {
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.file-preview-item .remove-icon {
    position: absolute;
    top: -8px;
    right: -8px;
    height: 22px;
    width: 22px;
    padding: 0;
    border: 0;
    background: #c7c7c7;
    border-radius: 50px;
    display: grid;
    place-content: center;
    cursor: pointer;
}

.file-preview-item .remove-icon i {
    color: #434343;
    font-size: 12px;
}

/* The backdrop. `cursor: default` on purpose — the old zoom-out cursor sat on
   the whole overlay while every click merely closed it, so the pointer
   described a zoom the viewer never performed. */
.file-preview-viewer {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(17, 20, 40, .82);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* Capped to the viewport with the overflow inside, so opening a large scan
   never makes the page behind it grow or scroll. */
.file-preview-viewer-dialog {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 3rem);
    max-width: min(1100px, 94vw);
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}

.file-preview-viewer-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #e2e4ee;
    background: #f7f8fc;
}

.file-preview-viewer-title {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: #18227c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-preview-viewer-size {
    margin-left: 8px;
    font-weight: 400;
    color: #6b7280;
}

.file-preview-viewer-action {
    flex: none;
    height: 30px;
    width: 30px;
    display: grid;
    place-content: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #4b5563;
    font-size: 17px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.file-preview-viewer-action:hover,
.file-preview-viewer-action:focus-visible {
    background: rgba(24, 34, 124, .10);
    color: #18227c;
    outline: none;
}

.file-preview-viewer-body {
    overflow: auto;
    display: grid;
    place-content: center;
    padding: 12px;
    background: #fff;
}

/* Fit-to-dialog by default. `.is-zoomed` (toggled by clicking the image) drops
   the cap so a dense receipt can be read at natural size, and the cursor flips
   to match — a zoom cursor now means a zoom really happens. */
.file-preview-viewer-image {
    max-width: 100%;
    max-height: calc(100vh - 9rem);
    display: block;
    cursor: zoom-in;
}

.file-preview-viewer-body.is-zoomed {
    place-content: start;
}

.file-preview-viewer-body.is-zoomed .file-preview-viewer-image {
    max-width: none;
    max-height: none;
    cursor: zoom-out;
}

.file-preview-viewer-body iframe {
    width: min(1000px, 90vw);
    height: calc(100vh - 9rem);
    border: 0;
    display: block;
}

.file-preview-viewer-icon {
    font-size: 96px;
    color: #9aa1b1;
    padding: 48px;
}

/* Stored attachments (payment / expense receipts) in list cells and detail
   panels. The viewer overlay itself is shared with the upload preview above. */
.attachment-link { text-decoration: none; }
.attachment-link:hover { text-decoration: underline; }
.attachment-thumb {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: cover;
    border-radius: 0.25rem;
    border: 1px solid var(--sg-border-color, #e5e7eb);
}
