.finished-shell {
  min-height: 100vh;
  background: var(--bg);
}

.finished-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 360px;
  min-height: calc(100vh - 74px);
}

.finished-filters,
.finished-content,
.finished-detail {
  min-width: 0;
  background: var(--panel);
  padding: 20px;
  overflow: auto;
}

.finished-filters {
  border-right: 1px solid var(--line);
}

.finished-detail {
  border-left: 1px solid var(--line);
}

.filter-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
  margin-top: 10px;
  padding: 0 10px;
}

.filter-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 12px;
}

.bulk-download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 10px;
  text-decoration: none;
}

.finished-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.bulk-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
}

#selectedSummary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-right: auto;
}

.finished-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.finished-card.active,
.finished-card.selected,
.finished-card:hover {
  border-color: var(--primary);
}

.finished-select {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
}

.finished-thumb-button {
  display: block;
  width: 100%;
  border: 0;
  background: #f8fafc;
  cursor: pointer;
  padding: 0;
}

.finished-thumb-button:focus-visible,
.detail-image-button:focus-visible,
.image-lightbox-close:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.finished-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #fff;
}

.finished-card-body {
  padding: 10px;
}

.finished-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  word-break: break-word;
}

.finished-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.finished-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.card-action-button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.card-action-button:hover {
  border-color: var(--primary);
}

.card-action-button.danger {
  border-color: #fecaca;
  color: #991b1b;
}

.card-action-button.danger:hover {
  background: #fff1f2;
}

.state-row,
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.state-button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-size: 12px;
  padding: 0 9px;
}

.state-button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.button.danger-outline {
  background: #fff;
  border-color: #fecaca;
  color: #991b1b;
}

.detail-image {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.detail-image-button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: zoom-in;
}

.detail-block {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.detail-block h3 {
  font-size: 13px;
  margin: 0 0 8px;
}

.detail-text {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

body.lightbox-open {
  overflow: hidden;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.image-lightbox[hidden] {
  display: none;
}

.image-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
}

.image-lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(1180px, 96vw);
  max-height: 94vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.3);
}

.image-lightbox-header,
.image-lightbox-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.image-lightbox-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.image-lightbox-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  word-break: break-word;
}

.image-lightbox-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.image-lightbox-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.image-lightbox-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  background: #f8fafc;
  padding: 16px;
}

.image-lightbox-image {
  display: block;
  max-width: 100%;
  max-height: calc(94vh - 128px);
  object-fit: contain;
  background: #fff;
}

.redo-dialog {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.redo-dialog[hidden] {
  display: none;
}

.redo-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
}

.redo-panel {
  position: relative;
  z-index: 1;
  width: min(760px, 96vw);
  max-height: 92vh;
  overflow: auto;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.32);
  padding: 16px;
}

.redo-header,
.redo-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.redo-header h2 {
  margin: 0;
}

.redo-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.redo-preview img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.redo-reasons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.redo-reason,
.redo-check,
.redo-field {
  display: flex;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}

.redo-reason {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
}

.redo-field {
  display: grid;
  margin-top: 12px;
}

.redo-field textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  font: inherit;
}

.redo-check {
  align-items: center;
  margin: 12px 0;
}

@media (max-width: 1180px) {
  .finished-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .finished-detail {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .finished-layout {
    display: block;
  }

  .finished-filters,
  .finished-detail {
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .image-lightbox {
    padding: 10px;
  }

  .image-lightbox-panel {
    width: 100%;
    max-height: 96vh;
  }

  .image-lightbox-image {
    max-height: calc(96vh - 138px);
  }
}
