.brand_link {
  color: inherit;
  text-decoration: none;
}

.gallery_shell {
  max-width: 1560px;
}

.gallery_intro h1 {
  max-width: 920px;
}

.gallery_filters {
  grid-template-columns: minmax(190px, 0.8fr) minmax(190px, 0.8fr) minmax(170px, 0.6fr) minmax(220px, 1fr) auto auto;
}

.gallery_filters select,
.gallery_filters input[type="search"] {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel-soft);
  color: var(--text);
}

.gallery_kpis {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.gallery_panel {
  min-height: 360px;
}

.gallery_batch_actions {
  display: grid;
  justify-items: end;
  gap: 6px;
  min-width: min(100%, 260px);
}

.gallery_batch_actions small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-align: right;
}

.gallery_grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.gallery_tile {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  min-height: 318px;
  display: grid;
  grid-template-rows: 230px auto;
  padding: 0;
  text-align: left;
  color: inherit;
  box-shadow: 0 10px 26px rgba(27, 36, 48, 0.07);
}

.gallery_tile:focus-visible {
  outline: 3px solid rgba(14, 165, 164, 0.45);
  outline-offset: 3px;
}

.gallery_thumb {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: linear-gradient(135deg, #eef1f6, #ffffff);
}

.gallery_thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.gallery_placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.gallery_badge {
  position: absolute;
  top: 10px;
  left: 10px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 800;
}

.gallery_badge.ready,
.gallery_badge.printed {
  color: #065f46;
}

.gallery_badge.processing,
.gallery_badge.active {
  color: #075985;
}

.gallery_badge.error {
  color: var(--red);
}

.gallery_badge.expired {
  color: #92400e;
}

.gallery_badge.abandoned {
  color: #475569;
}

.gallery_tile_body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.gallery_tile_title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.gallery_tile_title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery_tile_title span,
.gallery_tile_meta {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.gallery_steps,
.modal_steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.step_icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #edf0f5;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
}

.step_icon.done {
  border-color: rgba(22, 163, 74, 0.35);
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
}

.step_icon.active {
  border-color: rgba(14, 165, 164, 0.35);
  background: rgba(14, 165, 164, 0.12);
  color: var(--brand);
}

.step_icon.error {
  border-color: rgba(220, 38, 38, 0.32);
  background: rgba(220, 38, 38, 0.10);
  color: var(--red);
}

.gallery_modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  overflow: hidden;
}

.gallery_modal.open {
  display: block;
}

.gallery_modal_backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
}

.gallery_modal_panel {
  position: absolute;
  inset: clamp(12px, 3vw, 36px);
  max-height: calc(100dvh - clamp(24px, 6vw, 72px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.30);
  overflow: hidden;
}

.gallery_modal_header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.gallery_modal_header h2 {
  margin: 0;
}

.gallery_modal_body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  overflow: hidden;
}

.gallery_modal_media {
  min-height: 0;
  display: grid;
  place-items: center;
  background: #111827;
  padding: 16px;
  overflow: hidden;
}

.gallery_modal_media img {
  width: auto;
  height: auto;
  max-width: min(100%, calc((100dvh - 190px) * 0.6667));
  max-height: calc(100dvh - 190px);
  display: block;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
}

.gallery_modal_details {
  position: relative;
  z-index: 1;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 18px;
  background: var(--panel);
  overflow-y: auto;
}

.modal_fields {
  display: grid;
  gap: 8px;
}

.modal_field {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.modal_field span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.modal_field strong {
  overflow-wrap: anywhere;
}

.modal_links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal_links a,
.modal_links button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--brand);
  text-decoration: none;
  font-weight: 800;
}

.modal_links button {
  cursor: pointer;
}

.modal_links button:disabled {
  cursor: progress;
  opacity: 0.62;
}

@media (max-width: 1160px) {
  .gallery_filters,
  .gallery_kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery_modal_panel {
    max-height: calc(100dvh - 24px);
  }

  .panel_header {
    align-items: stretch;
    flex-direction: column;
  }

  .gallery_batch_actions {
    justify-items: stretch;
  }

  .gallery_batch_actions small {
    text-align: left;
  }

  .gallery_modal_body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    align-content: start;
    overflow-y: auto;
  }

  .gallery_modal_media {
    min-height: 0;
    padding: clamp(10px, 2vw, 16px);
  }

  .gallery_modal_media img {
    width: min(100%, 980px);
    height: auto;
    max-height: min(62dvh, 760px);
  }

  .gallery_modal_details {
    overflow: visible;
    max-height: none;
    padding: clamp(14px, 2.2vw, 20px);
  }
}

@media (max-width: 720px) {
  .gallery_filters,
  .gallery_kpis {
    grid-template-columns: 1fr;
  }

  .gallery_grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .gallery_tile {
    grid-template-rows: 180px auto;
    min-height: 278px;
  }

  .gallery_modal_panel {
    inset: 6px;
    max-height: calc(100dvh - 12px);
    border-radius: 6px;
  }

  .gallery_modal_header {
    gap: 12px;
    padding: 12px;
  }

  .gallery_modal_header h2 {
    font-size: 1.05rem;
    line-height: 1.18;
    overflow-wrap: anywhere;
  }

  .gallery_modal_media {
    padding: 8px;
  }

  .gallery_modal_media img {
    max-height: min(58dvh, 620px);
    border-radius: 6px;
  }

  .gallery_modal_details {
    gap: 12px;
    padding: 12px;
  }

  .modal_links a,
  .modal_links button {
    width: 100%;
  }
}
