.table-wrap {
  overflow: auto;
  max-height: 62vh;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.data-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  font-weight: 800;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  line-height: 1.25;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
  min-width: 180px;
  max-width: 260px;
}

.data-table thead th:first-child {
  min-width: 56px;
  max-width: 56px;
  width: 56px;
}

.data-table thead th.actions-col {
  min-width: 170px;
  max-width: 170px;
  width: 170px;
}

.data-table thead th.status-col {
  min-width: 120px;
  max-width: 120px;
  width: 120px;
}

.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: top;
  background: #fff;
  line-height: 1.25;
  min-width: 180px;
  max-width: 260px;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}

.data-table tbody tr:hover td {
  background: #fcfcfd;
}

.data-table tbody tr.row-duplicate td {
  background: #fff7ed;
}

.data-table tbody tr.row-removed td {
  background: #f9fafb;
  color: #9ca3af;
  text-decoration: line-through;
}

.index-col {
  width: 56px;
  min-width: 56px !important;
  max-width: 56px !important;
  color: var(--muted);
  font-weight: 700;
}

.data-table thead th:first-child,
.data-table tbody td:first-child {
  position: sticky;
  left: 0;
}

.data-table thead th:first-child {
  background: #f8fafc;
  z-index: 2;
}

.data-table tbody td:first-child {
  background: #fff;
  z-index: 1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-unique {
  background: #ecfdf3;
  color: #15803d;
}

.status-duplicate {
  background: #fff1f2;
  color: #dc2626;
}

.status-kept {
  background: #eff6ff;
  color: #1d4ed8;
}

.status-removed {
  background: #f3f4f6;
  color: #6b7280;
}

.editable-cell {
  min-width: 180px;
  max-width: 260px;
  outline: none;
}


/* ===== RISK ROWS ===== */

.data-table tbody tr.row-warning td {
  background: #fff7ed;
}

.data-table tbody tr.row-risk td {
  background: #fef2f2;
}

/* subtle left indicator */
.data-table tbody tr.row-warning td:first-child {
  border-left: 4px solid #f59e0b;
}

.data-table tbody tr.row-risk td:first-child {
  border-left: 4px solid #dc2626;
}


/* ===== RISK ROWS ===== */

.row-warning {
  background: rgba(239, 68, 68, 0.05);
  border-left: 4px solid #ef4444;
}


/* ===== REGISTER ROW ACTIONS ===== */

.row-action-cell {
  white-space: nowrap;
  display: flex;
  gap: 8px;
  align-items: center;
}

.mini-action-btn,
.mini-danger-btn {
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.mini-action-btn {
  background: #f3f4f6;
  color: #111827;
}

.mini-danger-btn {
  background: #fee2e2;
  color: #b91c1c;
}


/* ===== REGISTER ROW ACTIONS - VISIBLE ===== */

.row-action-cell {
  min-width: 230px;
  white-space: nowrap;
  display: flex;
  gap: 8px;
  align-items: center;
}

.mini-action-btn,
.mini-danger-btn {
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.mini-action-btn {
  background: #f3f4f6;
  color: #111827;
}

.mini-danger-btn {
  background: #fee2e2;
  color: #b91c1c;
}

.data-table th,
.data-table td {
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.35;
  vertical-align: top;
}

.data-table th {
  min-width: 150px;
  max-width: 220px;
}

.data-table td {
  min-width: 150px;
  max-width: 260px;
}

.data-table th:first-child,
.data-table td:first-child {
  min-width: 56px;
  max-width: 70px;
  text-align: center;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  min-width: 130px;
  max-width: 160px;
}

.data-table th:nth-child(4),
.data-table td:nth-child(4),
.data-table th:nth-child(5),
.data-table td:nth-child(5),
.data-table th:nth-child(8),
.data-table td:nth-child(8) {
  min-width: 190px;
  max-width: 260px;
}

.data-table th:nth-child(n+27),
.data-table td:nth-child(n+27) {
  min-width: 240px;
  max-width: 340px;
}

.table-wrap {
  overflow-x: auto;
}

.review-scroll-shell {
  overflow-x: auto;
}

.review-card .data-table {
  table-layout: fixed !important;
  width: max-content !important;
  min-width: 100% !important;
}

.review-card .data-table th,
.review-card .data-table td,
.review-overlay .data-table th,
.review-overlay .data-table td {
  white-space: normal !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
  line-height: 1.25 !important;
  vertical-align: top !important;
  height: auto !important;
  min-height: 44px !important;
  padding: 12px 14px !important;
}

.review-card .data-table th,
.review-overlay .data-table th {
  width: 180px !important;
  min-width: 180px !important;
  max-width: 180px !important;
  font-size: 14px !important;
}

.review-card .data-table td,
.review-overlay .data-table td {
  width: 180px !important;
  min-width: 180px !important;
  max-width: 180px !important;
}

.review-card .data-table th:first-child,
.review-card .data-table td:first-child,
.review-overlay .data-table th:first-child,
.review-overlay .data-table td:first-child {
  width: 60px !important;
  min-width: 60px !important;
  max-width: 60px !important;
}

.review-card .data-table th:nth-child(2),
.review-card .data-table td:nth-child(2),
.review-overlay .data-table th:nth-child(2),
.review-overlay .data-table td:nth-child(2) {
  width: 120px !important;
  min-width: 120px !important;
  max-width: 120px !important;
}

.review-card .data-table th:nth-child(n+27),
.review-card .data-table td:nth-child(n+27),
.review-overlay .data-table th:nth-child(n+27),
.review-overlay .data-table td:nth-child(n+27) {
  width: 260px !important;
  min-width: 260px !important;
  max-width: 260px !important;
}

.review-scroll-shell,
.table-wrap,
.review-overlay-body {
  overflow-x: auto !important;
}

.similarity-mode-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.similarity-mode-btn {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #374151;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.similarity-mode-btn.active {
  background: #352665;
  color: #ffffff;
  border-color: #352665;
}

.data-table tr.row-similarity-exact td {
  background: #fee2e2;
}

.data-table tr.row-similarity-high td {
  background: #ffedd5;
}

.data-table tr.row-similarity-medium td {
  background: #fef9c3;
}

.data-table tr.row-similarity td:first-child {
  border-left: 5px solid #ef4037;
}

.data-table tr.row-similarity-high td:first-child {
  border-left-color: #f97316;
}

.data-table tr.row-similarity-medium td:first-child {
  border-left-color: #eab308;
}

.data-table tbody tr.row-similarity-exact td,
.data-table tbody tr.row-similarity-exact.row-duplicate td,
.data-table tbody tr.row-similarity-exact.row-risk td {
  background: #fee2e2 !important;
}

.data-table tbody tr.row-similarity-high td,
.data-table tbody tr.row-similarity-high.row-duplicate td,
.data-table tbody tr.row-similarity-high.row-risk td {
  background: #ffedd5 !important;
}

.data-table tbody tr.row-similarity-medium td,
.data-table tbody tr.row-similarity-medium.row-duplicate td,
.data-table tbody tr.row-similarity-medium.row-risk td {
  background: #fef9c3 !important;
}

.data-table tbody tr.row-similarity-exact td:first-child {
  border-left: 6px solid #dc2626 !important;
}

.data-table tbody tr.row-similarity-high td:first-child {
  border-left: 6px solid #f97316 !important;
}

.data-table tbody tr.row-similarity-medium td:first-child {
  border-left: 6px solid #eab308 !important;
}

/* ===== GLOBAL TABLE MOBILE PATCH ===== */

.table-wrap,
.materials-table-wrap,
.review-table-wrap,
.excel-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  min-width: 760px;
}

@media (max-width: 560px) {
  table {
    min-width: 680px;
  }

  th, td {
    font-size: 12px !important;
    padding: 9px 8px !important;
  }

  .cleanup-row,
  .cleanup-file-row,
  .cleanup-action-row,
  .cleanup-filter-row,
  .report-upload-actions,
  .materials-actions {
    flex-direction: column;
    align-items: stretch !important;
  }

  .cleanup-action-btn,
  .compact-action-btn,
  .primary-btn,
  .secondary-btn {
    width: 100%;
  }
}


@keyframes cleanupSpin {
  to { transform: rotate(360deg); }
}


/* ===== RESTORE DUPLICATE INVESTIGATION BUTTON STYLING ===== */

.duplicate-investigation-panel {
  margin: 14px 0 18px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(15,23,42,0.06);
}

.duplicate-investigation-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.duplicate-investigation-head strong {
  display: block;
  color: #111827;
  font-size: 16px;
}

.duplicate-investigation-head span {
  display: block;
  color: #64748b;
  font-size: 13px;
  margin-top: 4px;
}

.duplicate-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.duplicate-filter-btn {
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #ffffff;
  color: #374151;
  padding: 10px 14px;
  font-weight: 900;
  cursor: pointer;
  transition: all .15s ease;
}

.duplicate-filter-btn.id.active {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}

.duplicate-filter-btn.cell.active {
  background: #ffedd5;
  border-color: #f97316;
  color: #9a3412;
}

.duplicate-filter-btn.province.active {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.duplicate-filter-btn.name.active {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #5b21b6;
}

.duplicate-filter-btn.reset {
  background: #111827;
  color: #ffffff;
  border-color: #111827;
}

.duplicate-investigation-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f8fafc;
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 560px) {
  .duplicate-investigation-head {
    display: block;
  }

  .duplicate-filter-btn.reset {
    margin-top: 10px;
  }

  .duplicate-filter-row {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* ===== DUPLICATE INVESTIGATION PROVINCE PATCH 4 ===== */

.data-table tbody tr.row-investigation-province td {
  background: #dbeafe !important;
}

.data-table tbody tr.row-investigation-province td:first-child {
  border-left: 6px solid #3b82f6 !important;
}

.data-table tbody tr.row-investigation-id.row-investigation-province td {
  background: linear-gradient(90deg, #fee2e2 0%, #fee2e2 50%, #dbeafe 50%, #dbeafe 100%) !important;
}

.data-table tbody tr.row-investigation-cellphone.row-investigation-province td {
  background: linear-gradient(90deg, #ffedd5 0%, #ffedd5 50%, #dbeafe 50%, #dbeafe 100%) !important;
}

.data-table tbody tr.row-investigation-id.row-investigation-cellphone.row-investigation-province td {
  background: linear-gradient(90deg, #fee2e2 0%, #fee2e2 33%, #ffedd5 33%, #ffedd5 66%, #dbeafe 66%, #dbeafe 100%) !important;
}


/* ===== DUPLICATE INVESTIGATION NAME PATCH 5 ===== */

.data-table tbody tr.row-investigation-name td {
  background: #ede9fe !important;
}

.data-table tbody tr.row-investigation-name td:first-child {
  border-left: 6px solid #8b5cf6 !important;
}

.data-table tbody tr.row-investigation-id.row-investigation-name td {
  background: linear-gradient(90deg, #fee2e2 0%, #fee2e2 50%, #ede9fe 50%, #ede9fe 100%) !important;
}

.data-table tbody tr.row-investigation-cellphone.row-investigation-name td {
  background: linear-gradient(90deg, #ffedd5 0%, #ffedd5 50%, #ede9fe 50%, #ede9fe 100%) !important;
}

.data-table tbody tr.row-investigation-province.row-investigation-name td {
  background: linear-gradient(90deg, #dbeafe 0%, #dbeafe 50%, #ede9fe 50%, #ede9fe 100%) !important;
}

