* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1a1a2e;
  color: #fff;
  padding: 0.75rem 1.5rem;
}

.nav-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}

.nav-actions { display: flex; gap: 0.5rem; align-items: center; }

.threshold-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #ccc;
  font-size: 0.8rem;
  margin-right: 0.5rem;
}
.threshold-control label { white-space: nowrap; }
#threshold-slider { width: 80px; cursor: pointer; accent-color: #e2703a; }
#threshold-value {
  background: #e2703a;
  color: #fff;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.8rem;
  min-width: 1.8rem;
  text-align: center;
}

main { max-width: 1200px; margin: 2rem auto; padding: 0 1rem; }

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  background: #e0e0e0;
  color: #333;
}
.btn:hover { background: #d0d0d0; }
.btn-scan { background: #16213e; color: #fff; }
.btn-scan:hover { background: #0f3460; }
.btn-review { background: #0f3460; color: #fff; text-decoration: none; display: inline-block; }
.btn-review:hover { background: #16213e; }
.btn-preview { background: #e2703a; color: #fff; }
.btn-merge { background: #3c6e71; color: #fff; }
.btn-merge:hover { background: #2c5557; }
.btn-dismiss { background: #c44536; color: #fff; }
.btn-dismiss:hover { background: #a33a2e; }

.queue-header { margin-bottom: 1.5rem; }
.queue-header h1 { margin-bottom: 0.75rem; }
.filters { display: flex; gap: 0.5rem; }
.filter-btn {
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  text-decoration: none;
  color: #333;
  background: #e0e0e0;
  font-size: 0.875rem;
}
.filter-btn.active { background: #0f3460; color: #fff; }

.queue-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 6px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.queue-table th { background: #f8f8f8; text-align: left; padding: 0.75rem 1rem; font-size: 0.8rem; text-transform: uppercase; color: #666; }
.queue-table td { padding: 0.75rem 1rem; border-top: 1px solid #eee; }

.score-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.85rem;
}
.score-high { background: #d4edda; color: #155724; }
.score-mid { background: #fff3cd; color: #856404; }
.score-low { background: #f8d7da; color: #721c24; }

.id-label { color: #999; font-size: 0.8rem; }

.empty-state { text-align: center; padding: 3rem; color: #999; }

/* Merge page */
.merge-header { margin-bottom: 1rem; }
.merge-header a { color: #0f3460; text-decoration: none; font-size: 0.875rem; }
.merge-header h1 { margin: 0.5rem 0; display: flex; align-items: center; gap: 0.5rem; }
.merge-nav { display: flex; justify-content: space-between; align-items: center; }
.next-link { font-weight: 600; }

/* Record summary cards */
.record-cards { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.record-card {
  flex: 1;
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card-a { border-left: 4px solid #0f3460; }
.card-b { border-left: 4px solid #e2703a; }
.record-card-vs { font-weight: 700; color: #999; font-size: 0.9rem; }
.card-label { font-size: 0.8rem; color: #666; text-transform: uppercase; letter-spacing: 0.04em; }
.card-name { font-size: 1.25rem; font-weight: 700; margin: 0.25rem 0; }
.card-fk { font-size: 0.8rem; color: #888; }

/* FK breakdown */
.fk-breakdown { margin-bottom: 1.25rem; background: #fff; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.fk-breakdown summary { padding: 0.75rem 1rem; cursor: pointer; font-size: 0.85rem; color: #555; font-weight: 600; }
.fk-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.fk-table th { background: #f8f8f8; padding: 0.4rem 0.75rem; text-align: left; }
.fk-table td { padding: 0.4rem 0.75rem; border-top: 1px solid #eee; }
.fk-table code { font-size: 0.8rem; color: #555; }

/* Sticky action bar */
.sticky-actions {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 0.75rem 1rem;
  margin: 0 -1rem 1.25rem -1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.action-hint { margin-left: auto; font-size: 0.75rem; color: #999; }
.action-hint kbd {
  background: #eee; border: 1px solid #ccc; border-radius: 3px;
  padding: 0.1rem 0.3rem; font-size: 0.7rem; font-family: inherit;
}

/* Section headers */
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.5rem;
}
.section-header h2 { font-size: 1rem; color: #333; }
.bulk-select { display: flex; gap: 0.35rem; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.75rem; }
.btn-skip { background: #6c757d; color: #fff; text-decoration: none; display: inline-block; }
.btn-skip:hover { background: #555; }

/* Merge table */
.merge-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 6px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 1.5rem; }
.merge-table th { background: #f8f8f8; padding: 0.6rem 1rem; text-align: left; font-size: 0.8rem; }
.merge-table .th-field { width: 180px; }
.merge-table td { padding: 0.45rem 1rem; border-top: 1px solid #eee; }
.merge-table .field-name { font-weight: 600; width: 180px; background: #fafafa; font-size: 0.8rem; }
.merge-table .field-diff { background: #fffde7; }
.merge-table-same .field-name { background: #f5f5f5; }

.field-pick { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.field-pick input[type="radio"] { cursor: pointer; accent-color: #0f3460; }
.field-value { font-size: 0.85rem; word-break: break-all; }
.null-val { color: #bbb; font-style: italic; }
.address-hint { font-size: 0.75rem; color: #666; margin-top: 0.2rem; padding-left: 1.5rem; font-style: italic; }
.record-name-hint { font-size: 0.8rem; font-weight: normal; color: #555; font-style: italic; }
.hidden-radio { display: none; }

/* Same fields section */
.same-fields-section { margin-bottom: 1.5rem; }
.section-header-toggle {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: #666;
  font-weight: 600;
  background: #fafafa;
  border-radius: 6px;
}

.modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: #fff; border-radius: 8px; padding: 2rem;
  max-width: 700px; width: 90%; max-height: 80vh; overflow-y: auto;
}
.modal-content h2 { margin-bottom: 1rem; }
.modal-content pre {
  background: #f5f5f5; padding: 1rem; border-radius: 4px;
  font-size: 0.8rem; overflow-x: auto; white-space: pre-wrap;
}
.modal-actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; justify-content: flex-end; }

.confirm-modal-content {
  max-width: 420px; width: 90%;
}
.confirm-modal-content h2 { margin-bottom: 0.5rem; }
.confirm-modal-content p { color: #555; margin-bottom: 0; }

.scanning-modal-content {
  text-align: center; padding: 2.5rem 3rem;
}
.scanning-modal-content h2 { margin: 0.75rem 0 0.25rem; }
.scanning-modal-content p { margin: 0; color: #666; }
.scanning-spinner {
  width: 48px; height: 48px; margin: 0 auto;
  border: 5px solid #e0e0e0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.merge-progress-container { margin-top: 1.25rem; }
.merge-progress-track {
  width: 100%; height: 8px; background: #e0e0e0;
  border-radius: 4px; overflow: hidden;
}
.merge-progress-fill {
  height: 100%; width: 0%;
  background: #3b82f6;
  border-radius: 4px;
  transition: width 0.25s ease;
}
.merge-progress-label {
  font-size: 0.8rem; color: #666;
  margin-top: 0.4rem; text-align: center;
}

/* Bulk actions bar */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.bulk-select-all { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; cursor: pointer; }
.bulk-count { font-size: 0.8rem; color: #666; margin-right: auto; }
.th-check { width: 36px; }
.pair-check { cursor: pointer; accent-color: #0f3460; }

.btn.loading { opacity: 0.6; pointer-events: none; }

/* Auto-merge options modal */
.auto-merge-modal-content { max-width: 500px; }
.auto-merge-desc { color: #555; margin-bottom: 1.25rem; font-size: 0.875rem; }
.auto-merge-options { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.auto-merge-option {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.75rem; border: 1px solid #e0e0e0; border-radius: 6px;
  cursor: pointer; transition: background 0.1s;
}
.auto-merge-option:hover { background: #f5f8ff; border-color: #b3cef7; }
.auto-merge-option input[type="checkbox"] { margin-top: 0.2rem; cursor: pointer; accent-color: #3c6e71; flex-shrink: 0; }
.auto-merge-option-text strong { display: block; font-size: 0.875rem; margin-bottom: 0.1rem; }
.auto-merge-option-text span { font-size: 0.8rem; color: #666; }
.auto-merge-count {
  background: #f0f7ff; border: 1px solid #bdd7f5; border-radius: 6px;
  padding: 0.6rem 0.9rem; font-size: 0.875rem; color: #0f3460; margin-bottom: 0.25rem;
}
