﻿body.modal-open {
  overflow: hidden;
}

.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  width: min(380px, calc(100vw - 24px));
  display: grid;
  gap: 10px;
  z-index: 1200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border-radius: 12px;
  border: 1px solid #2a3c63;
  background: rgba(10, 18, 35, 0.97);
  color: #dbe7ff;
  box-shadow: 0 16px 38px rgba(3, 10, 24, 0.55);
  backdrop-filter: blur(8px);
  font-size: 0.92rem;
  line-height: 1.35;
  transform: translateY(-8px);
  opacity: 0;
  animation: toast-in 220ms ease forwards;
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.45);
  background: linear-gradient(135deg, rgba(16, 45, 34, 0.96), rgba(9, 25, 24, 0.96));
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.5);
  background: linear-gradient(135deg, rgba(50, 20, 30, 0.96), rgba(26, 11, 18, 0.96));
}

.toast__text {
  flex: 1;
  padding-top: 1px;
}

.toast__close {
  border: none;
  background: transparent;
  color: #a9bcdf;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  padding: 2px 6px;
}

.toast__close:hover {
  color: #fff;
  background: rgba(127, 145, 173, 0.22);
}

.toast.is-hiding {
  animation: toast-out 200ms ease forwards;
}

@keyframes toast-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1050;
}

.modal-backdrop.open {
  display: flex;
}

#defect-detail-attachments-backdrop.open,
#defect-detail-history-backdrop.open,
#nc-attachments-backdrop.open,
#nc-history-backdrop.open,
#nc-comments-backdrop.open {
  z-index: 1060;
}

#camera-modal-backdrop.open {
  z-index: 1070;
}

.modal {
  background: #121726;
  border: 1px solid #1f2533;
  border-radius: 12px;
  width: min(520px, 94vw);
  max-height: 92vh;
  overflow: auto;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  display: grid;
  gap: 16px;
  color: #e2e8f0;
  min-width: 0;
  overflow-x: hidden;
}

.modal h3 {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.modal form {
  display: grid;
  gap: 12px;
}

.modal label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: #cbd5f5;
}

.modal input,
.modal select,
.modal textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #293042;
  background: #0f1115;
  color: #f8fafc;
}

.modal textarea {
  min-height: 80px;
}

.reviewer-editor {
  display: grid;
  gap: 10px;
}

.assignee-select-hidden {
  display: none;
}

.reviewer-selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
  align-items: center;
}

.reviewer-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(30, 58, 138, 0.26);
  color: #dbeafe;
  font-size: 0.82rem;
  font-weight: 600;
}

.reviewer-chip-remove {
  border: none;
  background: transparent;
  color: #bfdbfe;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 6px;
}

.reviewer-chip-remove:hover {
  color: #fff;
  background: rgba(59, 130, 246, 0.25);
}

.reviewer-list {
  max-height: min(42vh, 340px);
  overflow: auto;
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 12px;
  background: rgba(7, 13, 24, 0.82);
  padding: 6px;
  display: grid;
  gap: 6px;
}

.reviewer-list-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.45);
  cursor: pointer;
}

.reviewer-list-item:hover {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(30, 58, 138, 0.2);
}

.reviewer-list-item.is-selected {
  border-color: rgba(59, 130, 246, 0.65);
  background: rgba(30, 64, 175, 0.26);
}

.reviewer-list-item input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.reviewer-list-meta {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.reviewer-list-name {
  color: #f8fafc;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}

.reviewer-list-email {
  color: #9db0d8;
  font-size: 0.8rem;
  line-height: 1.35;
  word-break: break-word;
}

.reviewer-list-empty {
  padding: 10px;
  border-radius: 10px;
  color: #9db0d8;
  font-size: 0.85rem;
  background: rgba(15, 23, 42, 0.3);
}

.assignee-row {
  display: flex;
  justify-content: flex-end;
}

.assignee-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.assignee-actions .placeholder {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-secondary {
  background: transparent;
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
}

.btn-secondary:hover {
  border-color: #60a5fa;
}

.btn-primary {
  background: #3b82f6;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.btn-compact {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-primary[disabled],
.btn-secondary[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.placeholder {
  color: #9db0d8;
}

.form-error {
  color: #f87171;
  min-height: 1.4em;
  font-size: 0.85rem;
}

.attachment-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 6px 0 8px;
}

.defect-view-modal {
  width: min(760px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  background: linear-gradient(160deg, rgba(11, 22, 49, 0.98), rgba(4, 13, 33, 0.98));
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: 16px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.defect-create-modal {
  width: min(580px, 95vw);
}

.defect-view-header {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.defect-view-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.defect-view-chips {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.defect-view-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(51, 65, 85, 0.3);
  color: #e2e8f0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: capitalize;
}

.defect-view-chip.compliance-policy-chip,
.nc-chip.compliance-policy-chip,
.attachment-compliance-badge {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.38);
  color: #fde68a;
}

.defect-view-chip.compliance-policy-chip,
.nc-chip.compliance-policy-chip {
  max-width: 100%;
  text-align: left;
  text-transform: none;
  white-space: normal;
}

.chip-identified {
  border-color: rgba(148, 163, 184, 0.5);
  background: rgba(51, 65, 85, 0.3);
}

.chip-pending {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(30, 64, 175, 0.28);
  color: #bfdbfe;
}

.chip-approved {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(6, 95, 70, 0.26);
  color: #a7f3d0;
}

.chip-rejected,
.chip-nc-open {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(127, 29, 29, 0.3);
  color: #fecaca;
}

.chip-nc-closed {
  border-color: rgba(148, 163, 184, 0.55);
  background: rgba(51, 65, 85, 0.3);
  color: #e2e8f0;
}

.defect-view-meta {
  color: #c8d8f6;
  font-size: 0.9rem;
  line-height: 1.45;
}

.defect-view-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.defect-view-field {
  border: 1px solid rgba(59, 130, 246, 0.24);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.4);
  padding: 10px 12px;
  display: grid;
  gap: 3px;
  min-width: 0;
  max-width: 100%;
}

.defect-view-field:has(.defect-card-actions) {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
}

.defect-view-field.nc-title-field {
  grid-column: 1 / -1;
}

.defect-view-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.76rem;
  color: #9fb3da;
  font-weight: 700;
}

.defect-view-value {
  font-size: 0.95rem;
  color: #f8fafc;
  font-weight: 700;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.defect-view-value.is-comment {
  color: #dbe7f7;
  font-weight: 400;
  line-height: 1.5;
}

.classification-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid rgba(96, 165, 250, 0.38);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(59, 130, 246, 0.14);
  color: #bfdbfe;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
}

.defect-card-actions {
  display: flex;
  justify-content: flex-end;
  grid-row: 1 / span 2;
  grid-column: 2;
}

.defect-card-actions .btn-compact {
  white-space: nowrap;
}

.attachment-list {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  /* Header plus seven compact attachment rows; additional files scroll vertically. */
  max-height: 350px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: #38576e transparent;
  width: 100%;
}

.attachment-list-head {
  position: sticky;
  top: 0;
  z-index: 1;
}

.defect-marker-preview {
  position: fixed;
  z-index: 40;
  width: min(320px, calc(100vw - 32px));
  box-sizing: border-box;
  padding: 16px;
  border: 1px solid rgba(73, 153, 255, 0.54);
  border-radius: 18px;
  background:
    radial-gradient(circle at 14% 0%, rgba(42, 128, 236, 0.18), transparent 43%),
    linear-gradient(145deg, rgba(14, 33, 55, 0.98), rgba(7, 18, 34, 0.98));
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  color: #e8f1fc;
}
.defect-marker-preview[hidden] { display: none; }
.defect-marker-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.defect-marker-preview-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.defect-marker-preview-severity,
.defect-marker-preview-status,
.defect-marker-preview-identifier { display: inline-flex; align-items: center; min-height: 25px; box-sizing: border-box; border-radius: 999px; padding: 4px 10px; font-size: .72rem; font-weight: 800; letter-spacing: .025em; }
.defect-marker-preview-severity { background: rgba(16, 185, 129, 0.16); border: 1px solid rgba(52, 211, 153, 0.22); color: #6ee7b7; }
.defect-marker-preview-status { background: rgba(37, 99, 235, 0.2); border: 1px solid rgba(96, 165, 250, 0.34); color: #c5dcff; }
.defect-marker-preview-identifier { background: rgba(15, 28, 48, 0.72); border: 1px solid rgba(148, 163, 184, 0.3); color: #c8d5e8; }
.defect-marker-preview-close { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid rgba(148, 163, 184, .32); border-radius: 50%; color: #dbeafe; background: rgba(11, 27, 48, .72); font-size: 1.35rem; line-height: 1; cursor: pointer; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.defect-marker-preview-close:hover { background: rgba(30, 64, 175, .42); border-color: rgba(125, 190, 255, .75); transform: scale(1.05); }
.defect-marker-preview h3 { margin: 14px 0 12px; padding-bottom: 12px; border-bottom: 1px solid rgba(148, 163, 184, .18); color: #f3f7ff; font-size: 1.12rem; line-height: 1.3; letter-spacing: -.015em; }
.defect-marker-preview-values { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.defect-marker-preview-values > div,
.defect-marker-preview-reference { min-width: 0; padding: 10px; border: 1px solid rgba(96, 165, 250, .16); border-radius: 10px; background: rgba(6, 18, 35, .48); }
.defect-marker-preview-values span,
.defect-marker-preview-reference span { display: block; color: #8faac5; font-size: .72rem; font-weight: 650; }
.defect-marker-preview strong { display: block; margin-top: 4px; color: #f0f6ff; font-size: .92rem; line-height: 1.3; overflow-wrap: anywhere; }
.defect-marker-preview-reference { margin: 8px 0 14px; }
.defect-marker-preview .btn-primary { width: 100%; min-height: 44px; border-radius: 10px; background: linear-gradient(135deg, #3b82f6, #2475ee); box-shadow: 0 9px 20px rgba(37, 99, 235, .28); font-size: .92rem; }

.attachment-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr) minmax(0, 1.45fr) minmax(0, 1.15fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.38);
  min-width: 0;
  padding: 6px 9px;
}

.attachment-list-head {
  color: #9fb3da;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.attachment-list-main {
  min-width: 0;
  overflow: hidden;
}

.attachment-list-name {
  color: #dbeafe;
  font-weight: 700;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  white-space: nowrap;
}

.attachment-list-name:hover {
  color: #ffffff;
  text-decoration: underline;
}

.attachment-list-meta {
  min-width: 0;
  overflow: hidden;
  color: #cbd5e1;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-list-description {
  position: relative;
  min-width: 0;
  overflow: hidden;
  color: #cbd5e1;
  font-size: 0.82rem;
}

.attachment-description-trigger {
  display: block;
  width: 100%;
  overflow: hidden;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-description-trigger:hover,
.attachment-description-trigger:focus-visible {
  color: #ffffff;
  text-decoration: underline;
}

.attachment-description-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 7px);
  left: 0;
  display: none;
  width: min(320px, calc(100vw - 48px));
  max-height: 180px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid rgba(96, 165, 250, 0.52);
  border-radius: 8px;
  background: #10253a;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  color: #e5eef8;
  line-height: 1.4;
  white-space: pre-wrap;
}

.attachment-list-description.is-open .attachment-description-popover {
  display: block;
}

@media (hover: hover) {
  .attachment-list-description:has(.attachment-description-trigger:hover) .attachment-description-popover {
    display: block;
  }
}

@media (max-width: 800px) {
  .attachment-list {
    max-height: 350px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 2px 4px 0;
  }

  .attachment-list-head { display: none; }

  .attachment-list-row:not(.attachment-list-head) {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "file action"
      "description description"
      "classification classification"
      "uploaded uploaded";
    gap: 7px 10px;
    padding: 12px;
  }
  .attachment-list-row:not(.attachment-list-head) > :nth-child(1) { grid-area: file; }
  .attachment-list-row:not(.attachment-list-head) > :nth-child(2) { grid-area: description; }
  .attachment-list-row:not(.attachment-list-head) > :nth-child(3) { grid-area: classification; }
  .attachment-list-row:not(.attachment-list-head) > :nth-child(4) { grid-area: uploaded; }
  .attachment-list-row:not(.attachment-list-head) > :nth-child(5) { grid-area: action; }
  .attachment-list-description::before,
  .attachment-list-meta::before { color: #8faac5; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
  .attachment-list-description::before { content: "Description"; display: block; margin-bottom: 2px; }
  .attachment-list-row:not(.attachment-list-head) > :nth-child(4)::before { content: "Uploaded"; margin-right: 7px; }
  .attachment-list-classification .attachment-compliance-badges { flex-wrap: wrap; }
}

.attachment-list-classification {
  min-width: 0;
  overflow: hidden;
}

.attachment-list-classification .attachment-compliance-badges {
  flex-wrap: nowrap;
  overflow: hidden;
}

.attachment-list-classification .attachment-compliance-badge {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-compliance-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.attachment-compliance-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid rgba(251, 191, 36, 0.38);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.attachment-upload-policy-note {
  display: none;
  margin: 6px 0 0;
  color: #fde68a;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.attachment-upload-policy-note.has-policy {
  display: block;
}

.attachment-format-pill {
  display: inline-flex;
  width: fit-content;
  border: 1px solid rgba(96, 165, 250, 0.42);
  border-radius: 999px;
  color: #bfdbfe;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 700;
}

.defect-view-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.defect-view-section {
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 12px;
  background: rgba(12, 18, 30, 0.56);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.defect-view-section h4 {
  margin: 0;
  font-size: 1rem;
}

.defect-detail-tab-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
  margin-bottom: 2px;
}

.defect-detail-tab-btn {
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(12, 18, 32, 0.88);
  color: #bfdbfe;
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.defect-detail-tab-btn:hover {
  border-color: rgba(96, 165, 250, 0.75);
  color: #dbeafe;
}

.defect-detail-tab-btn.active {
  background: rgba(37, 99, 235, 0.28);
  border-color: rgba(96, 165, 250, 0.85);
  color: #fff;
}

.defect-detail-tab-panel {
  display: none;
  gap: 12px;
}

#defect-detail-form .defect-detail-tab-panel.active,
.defect-view-columns.defect-detail-tab-panel.active {
  display: grid;
}

.defect-detail-card {
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 12px;
  background: rgba(12, 18, 30, 0.56);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.defect-detail-card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.defect-detail-control {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  color: #c4d4f3;
}

.defect-detail-control input,
.defect-detail-control select,
.defect-detail-control textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid rgba(59, 130, 246, 0.22);
  background: rgba(8, 12, 21, 0.9);
}

.defect-detail-control textarea {
  min-height: 96px;
  line-height: 1.45;
}

.defect-detail-actions {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid rgba(59, 130, 246, 0.18);
  padding-top: 10px;
  margin-top: 2px;
}

.defect-detail-actions-left,
.defect-detail-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.defect-detail-actions-right {
  justify-content: flex-end;
}

.defect-detail-actions-right > :is(a, button) {
  box-sizing: border-box;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.defect-view-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.defect-view-section-header h4 {
  margin: 0;
  line-height: 1.2;
}

#defect-detail-files-summary,
#defect-detail-history-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

#defect-detail-files-summary .btn-secondary,
#defect-detail-history-summary .btn-secondary {
  margin-left: auto;
}

#nc-comments-summary,
#nc-files-summary,
#nc-history-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

#nc-comments-summary .btn-secondary,
#nc-files-summary .btn-secondary,
#nc-history-summary .btn-secondary {
  margin-left: auto;
}

.defect-view-section.history-panel {
  display: none;
}

.defect-view-section.history-panel.open {
  display: grid;
}

#defect-detail-attachments,
#nc-view-attachments,
#defect-detail-reviews {
  max-height: 56vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.approval-summary {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 10px;
  padding: 10px;
  margin: 8px 0;
  display: grid;
  gap: 6px;
}

.approval-progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(20, 32, 56, 0.85);
  border: 1px solid rgba(59, 130, 246, 0.35);
  overflow: hidden;
}

.approval-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
}

.approval-comments {
  display: grid;
  gap: 8px;
}

.approval-comment {
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  padding: 8px;
}

.nc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  padding-bottom: 10px;
  min-width: 0;
}

.nc-header > div {
  min-width: 0;
}

.nc-header-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.nc-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(51, 65, 85, 0.3);
  color: #e2e8f0;
  font-size: 0.78rem;
  font-weight: 700;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.nc-chip-closed {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(127, 29, 29, 0.3);
  color: #fecaca;
}

.nc-chip-secondary {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(30, 58, 138, 0.25);
  color: #bfdbfe;
}

.nc-tab-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nc-tab-btn {
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(12, 18, 32, 0.88);
  color: #bfdbfe;
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  cursor: pointer;
}

.nc-tab-btn.active {
  background: rgba(37, 99, 235, 0.28);
  border-color: rgba(96, 165, 250, 0.85);
  color: #fff;
}

.nc-tab-panel {
  display: none;
  gap: 12px;
}

.nc-tab-panel.active {
  display: grid;
}

.nc-accordion {
  border: 1px solid rgba(59, 130, 246, 0.16);
  border-radius: 10px;
  background: rgba(12, 18, 30, 0.46);
  overflow: hidden;
}

.nc-accordion summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nc-accordion summary::-webkit-details-marker {
  display: none;
}

.nc-accordion summary::before {
  content: "▸";
  color: #93c5fd;
  transition: transform 0.15s ease;
}

.nc-accordion[open] summary::before {
  transform: rotate(90deg);
}

.nc-accordion-content {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.nc-quality-stack,
.nc-quality-create-block,
.nc-description-card {
  display: grid;
  gap: 8px;
}

.nc-quality-create-block,
.nc-description-card {
  border: 1px solid rgba(59, 130, 246, 0.16);
  border-radius: 10px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.28);
  min-width: 0;
  max-width: 100%;
}

.nc-description-value {
  color: #e2e8f0;
  line-height: 1.45;
  white-space: pre-wrap;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.quality-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  padding: 10px 12px;
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.34);
  align-items: center;
}

.quality-item-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.quality-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.quality-item-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  align-self: auto;
  margin-top: 2px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(147, 197, 253, 0.45);
  background: rgba(30, 58, 138, 0.2);
  color: #bfdbfe;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: capitalize;
}

.nc-attachment-folder {
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.4);
  margin-top: 8px;
  padding: 8px 10px;
  display: grid;
  gap: 6px;
}

.nc-attachment-folder-title {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #bfdbfe;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.attachment-pill,
#defect-view-attachments a,
#nc-view-attachments a,
#defect-detail-attachments a,
#nc-attachments-panel a,
#nc-history-summary a,
#nc-view-history a {
  color: #93c5fd;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  background: rgba(15, 23, 42, 0.6);
  margin: 4px 6px 0 0;
  text-decoration: none;
}

.attachment-pill:hover,
#defect-view-attachments a:hover,
#nc-view-attachments a:hover,
#defect-detail-attachments a:hover,
#nc-attachments-panel a:hover,
#nc-history-summary a:hover,
#nc-view-history a:hover {
  color: #e0f2fe;
  border-color: rgba(59, 130, 246, 0.65);
}

.camera-modal {
  max-width: 520px;
  width: min(520px, 92vw);
  padding: 18px;
  display: grid;
  gap: 12px;
}

.camera-preview {
  width: 100%;
  border-radius: 12px;
  background: #0b1220;
  border: 1px solid rgba(59, 130, 246, 0.2);
  overflow: hidden;
}

.camera-preview video {
  width: 100%;
  height: auto;
  display: block;
}

.camera-preview img {
  width: 100%;
  height: auto;
  display: block;
}

.camera-preview :is(video, img)[hidden] {
  display: none !important;
}

.camera-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 820px) {
  .defect-view-fields,
  .defect-view-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .defect-detail-card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .toast-stack {
    right: 12px;
    left: 12px;
    width: auto;
  }
}
/* Defect creation: a focused, responsive inspection dialog. */
#defect-modal-backdrop { background: rgba(2, 8, 17, .62); backdrop-filter: blur(5px); }
#defect-modal-backdrop .defect-create-modal {
  box-sizing: border-box; width: min(580px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px); padding: 0; gap: 0; overflow: hidden;
  display: flex; flex-direction: column; border-radius: 24px;
  border: 1px solid rgba(100, 171, 232, .35);
  background: radial-gradient(ellipse at top right, rgba(34, 83, 131, .28), transparent 55%), #081727;
  box-shadow: 0 32px 90px #0008, inset 0 1px 0 #ffffff0c; color: #f3f7ff;
  color-scheme: dark;
}
.defect-create-modal .defect-view-header { padding: 26px 28px 20px; flex: none; }
.defect-create-modal h3 { font-size: 28px; font-weight: 650; letter-spacing: -.8px; }
.defect-create-modal #defect-create-subtitle { margin: 0; color: #97aec8; font-size: 14px; line-height: 1.5; }
.defect-create-modal .defect-view-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; color: #57caff; background: #103453; border: 1px solid #25618b; font-size: 12px; }
.defect-create-modal .defect-view-chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #32c7fb; }
#defect-form { display: flex; flex-direction: column; gap: 0; min-height: 0; overflow: hidden; }
.defect-create-body { padding: 0 28px 24px; display: grid; gap: 17px; overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: #34516d transparent; }
#defect-form label, #defect-form legend { font-size: 14px; color: #b2c8e2; line-height: 1.45; }
#defect-form label { gap: 7px; }
#defect-form input:not([type=file]):not([type=checkbox]), #defect-form select, #defect-form textarea {
  min-height: 48px; padding: 12px 15px; border-radius: 13px; border: 1px solid #2b4055;
  background-color: #ffffff05; color: #f3f7ff; font: inherit; font-size: 15px;
  box-shadow: inset 0 1px 0 #ffffff03; transition: border-color .15s, box-shadow .15s;
}
#defect-form select:not([multiple]) { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23b2c8e2' stroke-width='1.8'%3E%3Cpath d='m3 6 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
#defect-form select option { background: #112236; color: #f3f7ff; }
#defect-form textarea { min-height: 96px; resize: vertical; }
#defect-form ::placeholder { color: #7e92a9; opacity: 1; }
.defect-input-wrap { position: relative; display: block; }
#defect-form .defect-input-wrap select, #defect-form .defect-input-wrap textarea { padding-left: 55px; }
.defect-control-icon { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 10px; background: #9dbfdf12; color: #b7cde5; }
.defect-control-icon svg { width: 20px; height: 20px; }
.defect-input-wrap > .defect-control-icon { position: absolute; left: 9px; top: 8px; pointer-events: none; }
.defect-attachment-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.defect-attachment-fieldset legend { padding: 0; margin-bottom: 9px; }
.defect-attachment-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#defect-form .defect-attachment-choice { position: relative; display: flex; align-items: center; gap: 12px; padding: 15px; border: 1px solid #254966; border-radius: 15px; background: #10304a66; text-align: left; cursor: pointer; font: inherit; min-width: 0; }
.defect-attachment-choice .defect-control-icon { width: 40px; height: 40px; background: #164573; color: #53caff; }
.defect-attachment-choice strong { display: block; color: #f3f7ff; font-size: 14px; font-weight: 600; }
.defect-attachment-choice small { display: block; color: #9db7d2; font-size: 12px; margin-top: 3px; }
#defect-form .defect-file-choice input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
#defect-form .attachment-compliance-panel { margin: 0; padding: 17px; border: 1px solid #20435f; border-radius: 15px; background: #0e263c66; }
#defect-form .attachment-compliance-panel strong { color: #e8f1fc; font-size: 14px; }
#defect-form .attachment-compliance-panel p { color: #9db7d2; font-size: 12px; line-height: 1.6; }
#defect-form .attachment-compliance-grid { grid-template-columns: 1fr; }
#defect-form .attachment-compliance-panel select { width: 100%; }
#defect-form .upload-review { gap: 14px; padding: 16px; border: 1px solid #2e5875; border-radius: 15px; background: #0e263c66; }
#defect-form .upload-review h4 { color: #e8f1fc; font-size: 15px; }
#defect-form .upload-drafts { display: grid; gap: 10px; }
#defect-form .upload-draft-summary { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
#defect-form .upload-draft-summary strong { color: #e8f1fc; font-size: 14px; }
#defect-form .upload-draft-summary small { color: #9db7d2; font-size: 12px; text-align: right; }
#defect-form .upload-draft-workspace { display: grid; grid-template-columns: minmax(155px, .78fr) minmax(0, 1.22fr); gap: 12px; align-items: start; }
#defect-form .upload-draft-list { display: grid; gap: 7px; max-height: 250px; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; scrollbar-color: #416783 transparent; }
#defect-form .upload-draft-select { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 9px 10px; border: 1px solid #294d6b; border-radius: 10px; color: #c8dcec; background: #091e32; text-align: left; cursor: pointer; font: inherit; }
#defect-form .upload-draft-select:hover, #defect-form .upload-draft-select.is-selected { border-color: #42bffc; background: #123959; color: #f1f8ff; }
#defect-form .upload-draft-select:disabled { cursor: wait; opacity: .7; }
#defect-form .upload-draft-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
#defect-form .upload-draft-meta { color: #9db7d2; font-size: 11px; white-space: nowrap; }
#defect-form .upload-draft-editor { display: grid; gap: 9px; padding: 12px; border: 1px solid #254966; border-radius: 12px; background: #081c2f8c; }
#defect-form .upload-draft-editor-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#defect-form .upload-draft-editor-header strong { color: #e8f1fc; font-size: 14px; }
#defect-form .upload-draft-editor-header small { color: #9db7d2; font-size: 12px; }
#defect-form .upload-draft { gap: 9px; padding: 13px; border: 1px solid #254966; border-radius: 12px; background: #081c2f8c; }
#defect-form .upload-draft:last-child { padding-bottom: 13px; border-bottom: 1px solid #254966; }
#defect-form .upload-draft textarea { min-height: 76px; }
#defect-form .upload-draft-editor textarea { min-height: 76px; }
#defect-form .modal-actions { flex: none; display: grid; grid-template-columns: 1fr 1.05fr; gap: 14px; margin: 0; padding: 18px 28px; border-top: 1px solid #29435c; background: #0d2034; }
#defect-form .modal-actions button { min-height: 48px; border-radius: 13px; font-size: 15px; font-weight: 600; cursor: pointer; }
#defect-form .btn-secondary { border: 1px solid #38516c; background: #ffffff04; color: #f3f7ff; }
#defect-form .btn-primary { border: 1px solid #44bfff; background: linear-gradient(120deg, #198dff, #1767ef); color: white; box-shadow: 0 4px 18px #087dff26; }
#defect-form :is(input, select, textarea, button):focus-visible, #defect-form .defect-file-choice:focus-within { outline: 2px solid #55c7ff; outline-offset: 3px; }
#defect-form .defect-attachment-choice:hover { background: #173b59; border-color: #4085b5; }
#defect-form .modal-actions button:hover { filter: brightness(1.12); }
#defect-form-errors:empty { display: none; }
@media (max-width: 520px) {
  #defect-modal-backdrop .defect-create-modal { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); border-radius: 20px; }
  .defect-create-modal .defect-view-header { padding: 20px 18px 16px; }
  .defect-create-modal h3 { font-size: 25px; }
  .defect-create-body { padding: 0 18px 20px; }
  #defect-form .modal-actions { padding: 15px 18px; }
  #defect-form .defect-attachment-choice { padding: 12px 9px; gap: 8px; }
  .defect-attachment-choice .defect-control-icon { width: 32px; height: 36px; }
  #defect-form .upload-review { gap: 12px; padding: 13px; }
  #defect-form .upload-draft-summary { align-items: flex-start; flex-direction: column; gap: 3px; }
  #defect-form .upload-draft-summary small { text-align: left; }
  #defect-form .upload-draft-workspace { grid-template-columns: 1fr; }
  #defect-form .upload-draft-list { max-height: 176px; }
}

.defect-catalog-field, .defect-source-field { position: relative; display: grid; gap: 7px; }
.defect-catalog-combobox { position: relative; }
#defect-form .defect-catalog-field .defect-catalog-combobox input[type="search"],
#defect-form .defect-source-field .defect-catalog-combobox input[type="search"] {
  padding-left: 55px; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23b2c8e2' stroke-width='1.8'%3E%3Cpath d='m3 6 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.defect-catalog-combobox .defect-control-icon { position: absolute; left: 9px; top: 8px; z-index: 1; pointer-events: none; }
.defect-catalog-results {
  position: absolute; z-index: 20; top: 77px; left: 0; right: 0; max-height: 310px; overflow: auto;
  padding: 8px; border: 1px solid #31516e; border-radius: 15px; background: #0b1c2d;
  box-shadow: 0 20px 45px #0009;
}
.defect-catalog-results[hidden] { display: none; }
.defect-catalog-group + .defect-catalog-group { border-top: 1px solid #ffffff0d; }
#defect-form .defect-catalog-category,
#defect-form .defect-catalog-option {
  width: 100%; border: 0; color: #e9f2fd; background: transparent; font: inherit; cursor: pointer; text-align: left;
}
#defect-form .defect-catalog-category {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 11px 10px; font-weight: 600;
}
.defect-catalog-category small { color: #7893af; font-size: 11px; font-weight: 500; }
.defect-catalog-chevron { width: 8px; height: 8px; border-right: 1.5px solid #9ab3cc; border-bottom: 1.5px solid #9ab3cc; transform: rotate(45deg); transition: transform .15s; }
.defect-catalog-category[aria-expanded="true"] .defect-catalog-chevron { transform: rotate(225deg); }
.defect-catalog-types { display: grid; gap: 2px; padding: 0 4px 8px 12px; }
.defect-catalog-types[hidden] { display: none; }
#defect-form .defect-catalog-option { display: flex; align-items: center; gap: 10px; padding: 9px; border-radius: 9px; font-size: 14px; }
#defect-form .defect-catalog-option:hover { background: #183650; }
#defect-form .defect-catalog-option[aria-selected="true"] { color: #62ceff; background: #123653; }
.defect-catalog-check { display: grid; place-items: center; width: 19px; height: 19px; border: 1px solid #52708d; border-radius: 6px; font-size: 12px; }
.defect-catalog-option[aria-selected="true"] .defect-catalog-check { border-color: #42bcf5; background: #168acf; color: white; }
.defect-catalog-selections { display: flex; flex-wrap: wrap; gap: 7px; }
.defect-catalog-selections[hidden] { display: none; }
.defect-catalog-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 7px 6px 10px; border: 1px solid #2b6389; border-radius: 999px; background: #103552; color: #bfe9ff; font-size: 12px; }
#defect-form .defect-catalog-chip button { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: #ffffff12; color: inherit; cursor: pointer; }
.defect-field-help { color: #7893af; font-size: 11px; }
.defect-requirement-card { display: grid; gap: 12px; padding: 16px; border: 1px solid #244761; border-radius: 15px; background: #0e263c66; }
.defect-requirement-card > div:first-child strong { color: #e8f1fc; font-size: 14px; }
.defect-requirement-card > div:first-child p { margin: 3px 0 0; color: #8faac5; font-size: 12px; }
.defect-requirement-card label span { color: #718ba4; font-size: 11px; }
.defect-requirement-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#defect-form .defect-requirement-card textarea { min-height: 72px; }
@media (max-width: 520px) {
  .defect-requirement-grid { grid-template-columns: 1fr; }
  .defect-catalog-results { max-height: 260px; }
}
/* Observation and NC review: calm hierarchy with progressive disclosure. */
.review-surface.modal {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  padding: 28px;
  border: 1px solid #294e68;
  border-radius: 26px;
  background: linear-gradient(135deg, #091826, #0e263c);
  box-shadow: 0 28px 90px #0008;
  color: #edf4ff;
  scrollbar-width: thin;
  scrollbar-color: #38576e transparent;
  gap: 20px;
}
.review-surface .review-intro { margin: 0; color: #9db4c9; font-size: .92rem; line-height: 1.6; }
.review-surface h3 { font-size: clamp(1.3rem, 2.4vw, 1.8rem); letter-spacing: -.035em; line-height: 1.25; overflow-wrap: anywhere; }
.review-surface .defect-view-title-row { align-items: flex-start; }
.review-surface .defect-view-title-row h3 { flex: 1 1 380px; }
.review-surface .defect-view-chips { gap: 6px; }
.review-surface .defect-view-chip { font-size: .78rem; font-weight: 600; padding: 6px 12px; }
.review-surface :is(.defect-detail-tab-nav, .nc-tab-nav) {
  height: 64px;
  max-height: 64px;
  box-sizing: border-box;
  padding: 5px; border-radius: 14px; background: #06131f80;
  border: 1px solid #294255; gap: 4px;
}
.review-surface :is(.defect-detail-tab-btn, .nc-tab-btn) {
  flex: 1; border: 1px solid transparent; border-radius: 10px;
  min-height: 52px;
  max-height: 52px;
  background: transparent; color: #a8bfd3; padding: 12px; font-size: .88rem;
}
.review-surface :is(.defect-detail-tab-btn, .nc-tab-btn).active {
  color: #f3f8ff; background: #1b3c55; border-color: #3b6580;
}
.review-surface :is(.defect-detail-card, .defect-view-section, .nc-description-card) {
  border-radius: 17px; border-color: #29485f; background: #0b1e2d80; padding: 18px; gap: 12px;
}
.review-surface .defect-view-field {
  border: 0; border-radius: 0; background: transparent;
  padding: 12px 0; gap: 6px; align-content: start;
}
.review-surface .defect-view-label {
  text-transform: none; letter-spacing: 0; font-weight: 500; font-size: .83rem; color: #9fb7cd;
}
.review-surface .defect-view-value { font-size: .98rem; font-weight: 550; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.review-surface :is(.defect-view-fields, .defect-detail-card-grid) { column-gap: 28px; row-gap: 0; }
.review-surface :is(.btn-secondary, .btn-primary) { border-radius: 11px; min-height: 38px; font-size: .85rem; }
.review-surface .btn-secondary { background: #ffffff05; border-color: #34546c; color: #cee2f2; }
.review-surface .btn-primary { background: linear-gradient(110deg, #159af9, #1767f0); border: 1px solid #4cbaff; color: white; }
.review-surface .defect-card-actions .btn-secondary { padding: 5px 10px; min-height: 32px; border-color: transparent; color: #65c9ff; }
.review-surface .defect-card-actions .btn-secondary:hover { background: #2b6b932b; border-color: #3b6580; }
.review-surface :is(button, a, summary):focus-visible { outline: 2px solid #52ccff; outline-offset: 3px; }
.review-surface .defect-detail-requirement,
.review-surface .review-requirement-fields { border: 1px solid #376681; border-left: 3px solid #4bc9ff; border-radius: 16px; background: #12334a70; padding: 18px; }
.review-surface .defect-detail-requirement h4 { font-size: 1rem; }
.review-surface .defect-detail-requirement .defect-view-field:last-child,
.review-surface .review-requirement-fields .defect-view-field:last-child { grid-column: 1 / -1; }
.review-surface .review-context { border: 1px solid #29485f; border-radius: 16px; padding: 0 18px; background: #07172460; }
.review-surface .review-context summary { cursor: pointer; padding: 17px 0; font-weight: 600; font-size: .92rem; color: #d4e4f3; }
.review-surface .review-context summary span { font-weight: 400; color: #8ea9bf; font-size: .8rem; margin-left: 12px; }
.review-surface .review-context[open] summary { border-bottom: 1px solid #29485f; }
.review-surface #nc-view-fields { display: grid; grid-template-columns: 1fr; gap: 16px; }
.review-surface .defect-detail-actions { position: sticky; bottom: -28px; z-index: 2; margin: 20px -28px -28px; padding: 16px 28px; background: #0b2133; border-top: 1px solid #2b4a62; }
/* The modal header already presents the title; keep its edit control compact and aligned with the field actions. */
.review-surface .defect-title-edit-field { padding: 12px 0; }
.review-surface .defect-title-edit-field .defect-card-actions { justify-content: flex-start; }
.review-surface .defect-title-edit-field .btn-secondary { min-width: 72px; }
.review-surface .defect-view-field:has(#defect-detail-status-card-display) { display: none; }
.review-surface #defect-detail-issue-source-display { display: grid; gap: 2px; }
.review-surface .issue-source-category { color: #9fb7cd; font-size: .8rem; font-weight: 500; }
.review-surface .issue-source-value { color: #edf4ff; }
.review-surface .classification-hierarchy { display: grid; gap: 2px; }
.review-surface #defect-detail-category-display { color: #9fb7cd; font-size: .8rem; font-weight: 500; }
.review-surface #defect-detail-type-display { color: #edf4ff; }
.review-surface .nc-description-value { line-height: 1.65; color: #d5e3ef; }
.review-surface .nc-description-value:not(.is-expanded) {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}
.review-surface .nc-description-value.is-expanded { display: block; }

/* Keep the primary defect dialog stable while its tab content changes.
   The review workflow establishes the visual baseline; longer panels scroll inside it. */
@media (min-width: 601px) {
  #defect-detail-backdrop .review-surface.modal {
    box-sizing: border-box;
    height: min(88dvh, 1120px);
    grid-template-rows: auto auto minmax(0, 1fr);
    align-content: start;
    overflow: hidden;
  }

  #defect-detail-backdrop #defect-detail-form {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    min-height: 0;
    height: 100%;
    gap: 0;
    overflow: visible;
  }

  #defect-detail-backdrop .defect-detail-tab-panel.active {
    min-height: 0;
    overflow-y: auto;
    align-content: start;
    scrollbar-width: thin;
    scrollbar-color: #38576e transparent;
  }

  #defect-detail-backdrop #defect-detail-panel-files {
    padding-top: 24px;
  }

  #defect-detail-backdrop .defect-detail-actions {
    position: static;
    box-sizing: border-box;
    margin: 0 -28px -24px;
    padding: 12px 28px;
    background: transparent;
    border-top: 1px solid #2b4a62;
    box-shadow: none;
  }
}

@media (max-width: 600px) {
  .review-surface.modal { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); padding: 18px; border-radius: 20px; gap: 16px; }
  .review-surface :is(.defect-view-fields, .defect-detail-card-grid) { grid-template-columns: 1fr; }
  .review-surface :is(.defect-detail-tab-nav, .nc-tab-nav) { height: auto; max-height: none; min-height: 0; flex-wrap: wrap; }
  .review-surface :is(.defect-detail-tab-btn, .nc-tab-btn) { min-height: 44px; max-height: none; flex: 1 1 100px; padding: 9px 6px; }
  .review-surface .review-context summary span { display: block; margin: 6px 0 0; }
  .review-surface .defect-detail-actions { bottom: -18px; margin: 18px -18px -18px; padding: 12px 18px; }
  .review-surface .defect-detail-actions-right > * { flex: 1 1 auto; text-align: center; }
}
/* Nested review editors and staged evidence uploads. */
.legacy-attachment-controls, .upload-review[hidden] { display: none !important; }
.review-surface :is(input:not([type=checkbox]):not([type=radio]):not([type=file]), textarea, select) {
  box-sizing: border-box; width: 100%; min-width: 0; font: inherit;
  padding: 13px 16px; color: #e8f2fa; background: #132b3e;
  border: 1px solid #34556d; border-radius: 12px; line-height: 1.55;
}
.review-surface textarea { min-height: 150px; resize: vertical; }
.review-surface :is(input, textarea, select):focus-visible { outline: 2px solid #55caff; outline-offset: 2px; }
.review-catalog-editor { display: grid; gap: 12px; grid-column: 1 / -1; }
.review-selected { display: flex; flex-wrap: wrap; gap: 8px; }
.review-catalog-results { max-height: 310px; overflow: auto; scrollbar-width: thin; }
.review-catalog-results details { border-bottom: 1px solid #29485f; padding: 9px 3px; }
.review-catalog-results summary { padding: 8px; cursor: pointer; color: #c9dfef; }
.review-catalog-results label { display: flex; align-items: center; gap: 12px; padding: 10px 18px; cursor: pointer; }
.review-catalog-results input { accent-color: #3cbdff; width: 18px; height: 18px; }
.review-catalog-results label:has(input:checked) { background: #204763; border-radius: 10px; }
.review-surface .defect-detail-control:has(.attachment-file-picker) { position: relative; display: grid; gap: 12px; }
.review-surface .attachment-file-picker { padding: 12px; border: 1px dashed #43718c; border-radius: 12px; color: #a4bed2; background: #132b3e; width: 100%; }
.review-surface .attachment-file-picker::file-selector-button { color: #edf6ff; background: #245571; border: 0; border-radius: 8px; padding: 10px 16px; margin-right: 12px; font: inherit; cursor: pointer; }
.attachment-choose-label { display: none; }
.upload-review { display: grid; gap: 16px; padding: 20px; border-radius: 18px; border: 1px solid #37647d; background: #102e4380; }
.upload-review h4 { margin: 0; }
.upload-drafts { display: grid; gap: 16px; }
.upload-draft { display: grid; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid #34556d; }
.upload-draft label { display: grid; gap: 6px; color: #afc6d8; }
.upload-draft small { overflow-wrap: anywhere; color: #91b0c5; }
.upload-draft textarea { min-height: 80px; }
.review-surface .attachment-evidence-card { display: flex !important; flex-wrap: wrap; margin: 12px 0 0 !important; padding: 18px; border: 1px solid #30536b; border-radius: 15px; background: #112a3d; gap: 12px !important; }
.review-surface .attachment-evidence-card .attachment-pill { flex: 1 1 55%; border: 0; border-radius: 0; padding: 0; background: transparent; overflow-wrap: anywhere; font-weight: 600; }
.attachment-evidence-card p { flex: 1 1 100%; margin: 0; color: #c0d3e0; white-space: pre-wrap; }
.attachment-evidence-card small { flex: 1 1 100%; color: #93b0c5; }
.review-surface .attachment-compliance-panel { padding: 16px; background: #091f30; border-color: #34556d; }
.review-surface .attachment-compliance-panel p { font-size: .85rem; }
