.cleanup-panel {
  overflow: hidden;
}

.cleanup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  width: 100%;
}

.cleanup-file-row {
  margin-top: 8px;
}

.cleanup-action-row {
  margin-top: 16px;
}

.cleanup-filter-row {
  margin-top: 16px;
}

.cleanup-file-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 320px;
  min-width: 240px;
}

.cleanup-file-name {
  color: var(--muted);
  font-size: 14px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cleanup-select {
  flex: 1 1 230px;
  min-width: 210px;
}

.cleanup-action-btn {
  flex: 0 0 auto;
  min-width: 190px;
  min-height: 52px;
}

.primary-btn,
.secondary-btn,
.row-btn {
  border: 0;
  color: white;
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.1;
  white-space: nowrap;
}

.primary-btn {
  background: var(--primary);
  box-shadow: 0 10px 24px rgba(242, 140, 24, 0.18);
}

.secondary-btn {
  background: #111827;
}

.row-btn {
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 10px;
}

.row-btn.keep {
  background: #15803d;
}

.row-btn.remove {
  background: #dc2626;
}

.sheet-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  height: 52px;
  padding: 0 42px 0 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%),
    #ffffff;
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px),
    0 0;
  background-size: 6px 6px, 6px 6px, 100% 100%;
  background-repeat: no-repeat;
  color: var(--text);
  font-weight: 600;
  outline: none;
}

.sheet-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(242, 140, 24, 0.12);
}

.toggle-chip,
.rule-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-weight: 600;
  min-height: 46px;
}

.toggle-chip input {
  margin: 0;
}

.summary-text {
  color: var(--muted);
  font-size: 13px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .cleanup-row {
    flex-direction: column;
    align-items: stretch;
  }

  .cleanup-file-wrap,
  .cleanup-select,
  .cleanup-action-btn,
  .toggle-chip,
  .rule-chip {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
  }

  .cleanup-file-wrap {
    align-items: flex-start;
    flex-direction: column;
  }

  .cleanup-file-name {
    display: none;
  }

  .sheet-select {
    width: 100%;
  }

  .toggle-chip,
  .rule-chip {
    border-radius: 16px;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

.cleanup-action-row {
  justify-content: flex-start !important;
  align-items: center !important;
}

.cleanup-action-row .cleanup-action-btn {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 160px !important;
  max-width: 230px !important;
  padding-left: 18px !important;
  padding-right: 18px !important;
}

@media (max-width: 700px) {
  .cleanup-action-row .cleanup-action-btn {
    width: 100% !important;
    max-width: none !important;
  }
}


/* ===== REVIEW TABLE CONSTRAINT FIX ===== */

/* prevent page horizontal overflow */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* keep cards within screen without clipping inner table scroll */
.module-card {
  max-width: 100%;
}

/* review container */
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 10px;
}

/* table should size to content, not force page stretch */
.data-table {
  width: max-content;
  min-width: 100%;
}

/* keep cells readable without blowing layout */
.data-table th,
.data-table td {
  white-space: nowrap;
}

/* mobile safety */
@media (max-width: 768px) {
  .table-wrap {
    overflow-x: auto;
  }
}


/* allow the review area to own horizontal scrolling */
.table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: scroll;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* keep scrollbar visible enough for review tables */
.table-wrap::-webkit-scrollbar {
  height: 10px;
}

.table-wrap::-webkit-scrollbar-thumb {
  border-radius: 20px;
}


/* review box owns both table directions */
.table-wrap {
  width: 100%;
  max-width: 100%;
  max-height: 520px;
  overflow: auto !important;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
}

/* table expands inside the review box only */
.table-wrap .data-table {
  width: max-content !important;
  min-width: 100%;
}

/* stop page/card from swallowing the table scrollbar */
section.module-card:has(.table-wrap) {
  overflow: visible;
}


/* ===== STRONG REVIEW SCROLL SHELL ===== */

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden !important;
}

.shell,
.app-main,
.review-card {
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden !important;
}

.review-card {
  display: block;
}

.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.review-head h3 {
  margin: 0 0 4px 0;
}

.review-scroll-shell {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #ffffff;
}

.review-scroll-shell .table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 520px;
  overflow-x: auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

.review-scroll-shell .data-table {
  width: max-content !important;
  min-width: 1400px !important;
  table-layout: auto !important;
}

.review-scroll-shell .data-table th,
.review-scroll-shell .data-table td {
  white-space: nowrap !important;
}

.review-scroll-shell .table-wrap::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.review-scroll-shell .table-wrap::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.review-scroll-shell .table-wrap::-webkit-scrollbar-track {
  background: #f8fafc;
}

@media (max-width: 768px) {
  .review-scroll-shell .table-wrap {
    height: 460px;
  }

  .review-head {
    align-items: flex-start;
  }

  #expandReviewBtn {
    width: auto !important;
    min-width: 160px;
  }
}


/* ===== REVIEW OVERLAY ===== */

.review-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.review-overlay-inner {
  width: 95%;
  max-width: 1400px;
  height: 90%;
  background: #fff;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.review-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.review-overlay-body {
  flex: 1;
  padding: 16px;
}

.review-overlay-body .table-wrap {
  height: 100%;
}


/* ===== AUTO FIX PANEL ===== */

.auto-fix-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
}

.auto-fix-item {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  padding: 10px 12px;
  border-radius: 10px;
}


.auto-fix-hint {
  font-size: 12px;
  color: #6b7280;
  margin-top: 6px;
}


/* ===== REGISTER PROCESSING INDICATOR ===== */

.register-processing-dots {
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.register-processing-dots span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #fb8c00;
  display: inline-block;
  animation: registerPulse 1s infinite ease-in-out;
}

.register-processing-dots span:nth-child(2) { animation-delay: 0.1s; }
.register-processing-dots span:nth-child(3) { animation-delay: 0.2s; }
.register-processing-dots span:nth-child(4) { animation-delay: 0.3s; }
.register-processing-dots span:nth-child(5) { animation-delay: 0.4s; }

@keyframes registerPulse {
  0%, 100% {
    opacity: 0.35;
    transform: translateY(0) scale(0.9);
  }
  50% {
    opacity: 1;
    transform: translateY(-5px) scale(1.08);
  }
}


/* ===== ROW EDIT MODAL ===== */

.row-edit-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
}

.row-edit-card {
  width: 760px;
  max-width: 96%;
  background: #ffffff;
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
}

.row-edit-header h3 {
  margin: 0;
  font-size: 22px;
  color: #111827;
}

.row-edit-header p {
  margin: 6px 0 22px;
  color: #6b7280;
  font-size: 14px;
}

.row-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.row-edit-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
  color: #374151;
  font-size: 14px;
}

.row-edit-grid input,
.row-edit-grid select {
  height: 48px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 0 14px;
  font-size: 15px;
  color: #111827;
  background: #f9fafb;
}

.row-edit-grid input:focus {
  outline: none;
  border-color: #fb8c00;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(251, 140, 0, 0.12);
}

.row-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

@media (max-width: 720px) {
  .row-edit-card {
    padding: 22px;
  }

  .row-edit-grid {
    grid-template-columns: 1fr;
  }
}


/* ===== ROW ACTION POPUP ===== */

.row-action-popup {
  position: fixed;
  z-index: 9998;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.18);
  padding: 8px;
  gap: 8px;
  align-items: center;
}

.row-action-popup button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  background: #f3f4f6;
  color: #111827;
}

.row-action-popup button:hover {
  background: #e5e7eb;
}

#popupDeleteBtn {
  background: #fee2e2;
  color: #b91c1c;
}

#popupDeleteBtn:hover {
  background: #fecaca;
}
