.crm-image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 170px)); gap: 12px; align-items: start; }
:root { --crm-image-danger: #b91c1c; --crm-image-danger-hover: #991b1b; --crm-image-danger-contrast: #fff; }
html[data-theme="dark"] { --crm-image-danger: #fda4af; --crm-image-danger-hover: #fecdd3; --crm-image-danger-contrast: #172033; }
.crm-image-tile { min-width: 0; padding: 8px; border: 1px solid var(--app-border, #cbd5e1); border-radius: 10px; background: var(--app-surface-soft, #f8fafc); color: var(--app-text, #172033); }
a[data-lightbox] img, a[data-delivery-photo] img, img[data-lightbox-image], .update-content img { display: block; width: 100%; max-width: 170px; height: 120px; max-height: 120px; object-fit: contain; border-radius: 6px; background: var(--app-surface-soft, #f1f5f9); cursor: zoom-in; }
.crm-image-grid a[data-lightbox], .crm-image-grid a[data-delivery-photo] { display: block; }
.crm-image-delete { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; font-weight: 600; }
.crm-image-delete:disabled { cursor: wait; opacity: .65; }
.crm-image-delete.btn-outline-danger { --bs-btn-color: var(--crm-image-danger); --bs-btn-border-color: var(--crm-image-danger); --bs-btn-hover-bg: var(--crm-image-danger); --bs-btn-hover-border-color: var(--crm-image-danger); --bs-btn-hover-color: var(--crm-image-danger-contrast); --bs-btn-disabled-color: var(--crm-image-danger); --bs-btn-disabled-border-color: var(--crm-image-danger); }
.crm-image-delete.btn-danger { --bs-btn-bg: var(--crm-image-danger); --bs-btn-border-color: var(--crm-image-danger); --bs-btn-color: var(--crm-image-danger-contrast); --bs-btn-hover-bg: var(--crm-image-danger-hover); --bs-btn-hover-border-color: var(--crm-image-danger-hover); --bs-btn-hover-color: var(--crm-image-danger-contrast); --bs-btn-disabled-bg: var(--crm-image-danger); --bs-btn-disabled-border-color: var(--crm-image-danger); --bs-btn-disabled-color: var(--crm-image-danger-contrast); }
.crm-image-delete:focus-visible { outline: 3px solid var(--app-header-icon, #2563eb); outline-offset: 2px; }
.crm-image-deleting { padding: 12px; border: 1px dashed var(--app-border, #cbd5e1); border-radius: 10px; background: var(--app-surface-soft, #f1f5f9); color: var(--app-text, #172033); }
.crm-lightbox { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--app-surface, #fff); color: var(--app-text, #172033); }
.crm-lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.crm-lightbox::backdrop { background: rgba(2, 6, 23, .85); }
.crm-lightbox__toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--app-border, #cbd5e1); }
.crm-lightbox__counter { margin-left: 8px; color: var(--app-muted, #64748b); font-variant-numeric: tabular-nums; }
.crm-lightbox__actions { display: flex; gap: 6px; }
.crm-lightbox button { display: grid; flex-shrink: 0; width: 44px; height: 44px; place-items: center; border: 1px solid var(--app-border, #cbd5e1); border-radius: 8px; background: var(--app-surface, #fff); color: var(--app-text, #172033); font-size: 1.5rem; cursor: pointer; }
.crm-lightbox button:hover { background: var(--app-surface-soft, #e2e8f0); }
.crm-lightbox button:focus-visible, a[data-lightbox]:focus-visible { outline: 3px solid var(--app-primary, #2563eb); outline-offset: 2px; }
.crm-lightbox button[hidden] { display: none; }
.crm-lightbox__stage { position: relative; display: grid; place-items: center; overflow: hidden; touch-action: none; background: var(--app-surface-soft, #f1f5f9); }
.crm-lightbox__image { display: block; max-width: calc(100vw - 120px); max-height: calc(100dvh - 150px); object-fit: contain; transform-origin: center; user-select: none; cursor: grab; }
.crm-lightbox__previous, .crm-lightbox__next { position: absolute; top: calc(50% - 22px); z-index: 1; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }
.crm-lightbox__previous { left: 8px; }.crm-lightbox__next { right: 8px; }
.crm-lightbox__caption { padding: 10px 16px; min-height: 42px; max-height: 15vh; overflow: auto; text-align: center; overflow-wrap: anywhere; }
.crm-lightbox__loading { display: none; position: absolute; padding: 10px 16px; border-radius: 8px; background: var(--app-surface, #fff); color: var(--app-text, #172033); pointer-events: none; }
.crm-lightbox.is-loading .crm-lightbox__loading { display: block; }
@media (max-width: 480px) {
    .crm-image-grid { grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); }
    .crm-lightbox__toolbar { flex-wrap: wrap; justify-content: center; padding: 6px; gap: 4px; }
    .crm-lightbox__image { max-width: calc(100vw - 20px); max-height: calc(100dvh - 160px); }
    .crm-lightbox__previous, .crm-lightbox__next { top: auto; bottom: 8px; }
}
