/* ==========================================================================
   1Life Unified Hub - Account Merging Module Styles
   Visually Blended with POD Validation (Signature #39c5bc & #2baeba Theme)
   ========================================================================== */

/* View Container */
.unified-automation-view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.merge-view-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #f4f6f9;
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: #1e293b;
  overflow: hidden;
}

/* --- Topbar: Exact 1Life Signature Gradient (#39c5bc to #2baeba) --- */
.merge-topbar {
  min-height: 44px;
  height: 44px;
  background: linear-gradient(90deg, rgba(57, 197, 188, 1) 0%, rgba(57, 197, 188, 1) 5%, rgba(43, 174, 186, 1) 100%) !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  color: #ffffff;
  flex-shrink: 0;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  z-index: 10;
}

.merge-topbar .pod-topbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.merge-title {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* Patient / Current Selection Badge (Matches .pod-patient-badge) */
.merge-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 2px 8px;
  border-radius: 16px;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.merge-header-badge .pod-patient-name {
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Topbar Right Controls (Matches .pod-top-btn) */
.merge-topbar .pod-topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.merge-topbar .pod-top-btn {
  background: #ffffff !important;
  color: #179b94 !important;
  border: 1px solid #ffffff !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  padding: 3px 8px !important;
  border-radius: 5px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  cursor: pointer !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
  transition: all 0.15s ease !important;
  line-height: 1.4 !important;
}

.merge-topbar .pod-top-btn:hover {
  background: #f0fdfa !important;
  color: #0f766e !important;
  transform: translateY(-1px);
}

.merge-topbar .pod-top-btn.is-refreshing .material-icons {
  animation: pod-spin-kf 0.85s linear infinite !important;
}

@keyframes pod-spin-kf {
  100% {
    transform: rotate(360deg);
  }
}

/* --- Secondary Control Toolbar (Matches .pod-qa-bar) --- */
.merge-control-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 10px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  z-index: 9;
  flex-shrink: 0;
  min-height: 40px;
}

.merge-control-bar .pod-qa-left,
.merge-control-bar .pod-qa-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Company Dropdown (Matches .pod-qa-status-dropdown) */
.merge-company-wrap {
  display: inline-flex;
  align-items: center;
}

.merge-company-select {
  background-color: #f0fdfa !important;
  color: #0f766e !important;
  border: 1px solid #2baeba !important;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  outline: none;
  cursor: pointer;
  height: 28px;
  box-shadow: 0 1px 2px rgba(43, 174, 186, 0.1);
  transition: all 0.15s ease;
  max-width: 200px;
}

.merge-company-select:hover {
  background-color: #e6fffa !important;
  border-color: #0f766e !important;
}

/* Date Input Wrapper (Matches .pod-qa-date-wrap) */
.merge-date-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0 6px;
  height: 28px;
  transition: all 0.15s ease;
}

.merge-date-wrap:focus-within {
  border-color: #2baeba;
  box-shadow: 0 0 0 2px rgba(43, 174, 186, 0.15);
}

.merge-date-input {
  border: none;
  outline: none;
  background: transparent;
  color: #1e293b;
  font-size: 11px;
  font-weight: 600;
  padding: 0;
  font-family: inherit;
}

/* --- Live Search Interval Control --- */
.merge-interval-wrap {
  display: inline-flex;
  align-items: center;
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 5px;
  padding: 1.5px 6px;
  gap: 3px;
  height: 28px;
  box-sizing: border-box;
}

.merge-interval-label {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  letter-spacing: -0.2px;
}

.merge-interval-select {
  border: none;
  outline: none;
  background: transparent;
  color: #0f766e;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 1px 2px;
  font-family: inherit;
}

.merge-interval-select:hover {
  color: #2baeba;
}

.merge-live-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 68px;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  transition: background-color 0.15s ease, color 0.15s ease;
  user-select: none;
  flex-shrink: 0;
  box-sizing: border-box;
}

.merge-live-indicator.is-active {
  background: #dcfce7;
  color: #15803d;
}

.merge-live-indicator.is-syncing {
  background: #e0f2fe;
  color: #0369a1;
}

.merge-live-indicator.is-error {
  background: #fee2e2;
  color: #b91c1c;
}

.merge-live-dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
  transition: all 0.2s ease;
}

.merge-live-indicator.is-active .merge-live-dot {
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: livePulse 2s infinite;
}

.merge-live-indicator.is-syncing .merge-live-dot {
  background: #0ea5e9;
  box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.7);
  animation: livePulse 0.8s infinite;
}

.merge-live-indicator.is-error .merge-live-dot {
  background: #ef4444;
}

@keyframes livePulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  }

  70% {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* Mode Switch Wrap & Buttons (Matches .pod-mode-switch-wrap & .pod-mode-switch-btn) */
.merge-control-bar .pod-mode-switch-wrap {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 1.5px;
  gap: 1.5px;
  flex-shrink: 0;
}

.merge-control-bar .pod-mode-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.merge-control-bar .pod-mode-switch-btn:hover {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.7);
}

.merge-control-bar .pod-mode-switch-btn.active {
  background: #0f766e;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.3);
}

/* Priority Badges */
.priority-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 12px;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.priority-badge.p1 {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.priority-badge.p2 {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
}

.priority-badge.p3 {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* --- Main Workspace Stage (Matches .pod-main-stage) --- */
.merge-workspace-body {
  flex: 1 1 0;
  display: flex;
  overflow: hidden;
  position: relative;
  background: #f4f6f9;
}

/* --- Left: Runs Browser Panel --- */
.merge-runs-panel {
  width: 310px;
  background: #ffffff;
  border-right: 1px solid #dee2e6;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.merge-runs-header {
  padding: 8px 10px;
  border-bottom: 1px solid #e9ecef;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Search Box (Matches .pod-search-box) */
.merge-search-box {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 2px 8px;
  gap: 4px;
  transition: all 0.2s ease;
}

.merge-search-box:focus-within {
  border-color: #2baeba;
  box-shadow: 0 0 0 2px rgba(43, 174, 186, 0.18);
}

.merge-search-box .pod-search-icon {
  font-size: 15px;
  color: #94a3b8;
  transition: color 0.2s ease;
}

.merge-search-box:focus-within .pod-search-icon {
  color: #2baeba;
}

.merge-runs-search {
  background: transparent;
  border: none;
  outline: none;
  color: #1e293b;
  font-size: 11.5px;
  font-weight: 600;
  width: 100%;
  padding: 2px 0;
  font-family: inherit;
}

.merge-runs-search::placeholder {
  color: #94a3b8;
  font-weight: 500;
}

.merge-runs-subbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #64748b;
  font-weight: 700;
  padding: 0 2px;
}

.merge-runs-list {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Run Card */
.merge-run-card {
  display: flex;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.merge-run-card:hover {
  border-color: #2baeba;
  background: #f0fdfa;
  transform: translateY(-1px);
}

.merge-run-card.active {
  border-color: #2baeba;
  background: #e6fffa;
  border-left: 3.5px solid #2baeba;
  box-shadow: 0 2px 6px rgba(43, 174, 186, 0.2);
}

.merge-run-checkbox {
  accent-color: #2baeba;
  margin-top: 3px;
  cursor: pointer;
}

.merge-run-card-info {
  flex: 1 1 0;
  min-width: 0;
}

.merge-run-name {
  font-size: 12px;
  font-weight: 700;
  color: #0f766e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.merge-run-date {
  font-size: 11px;
  color: #64748b;
  margin-top: 1px;
}

.merge-run-badges {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.badge-p1 {
  background: #dcfce7;
  color: #166534;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}

.badge-p2 {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}

.badge-p3 {
  background: #fef3c7;
  color: #92400e;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}

/* --- Center: Duplicate Review Deck (Matches .pod-compare-body) --- */
.merge-review-deck {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  gap: 10px;
  overflow-y: auto;
  background: #f4f6f9;
}

.merge-review-header {
  background: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 6px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
}

.merge-review-header-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: #0f766e;
}

.merge-pair-counter {
  color: #0f766e;
}

/* Comparison Cards Row */
.merge-cards-row {
  display: flex;
  gap: 12px;
  flex: 1 1 0;
  min-height: 480px;
  padding: 0 !important;
  background: transparent !important;
}

/* Account Cards (Matches .pod-col-pane) */
.merge-account-card {
  flex: 1 1 0;
  min-height: 0;
  background: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.2s ease;
  position: relative;
}

.merge-account-card.is-primary {
  border: 2px solid #2baeba !important;
  box-shadow: 0 3px 12px rgba(43, 174, 186, 0.25) !important;
}

/* Card Header (Matches .pod-pane-header) */
.merge-card-header {
  background: #ffffff;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: #2baeba;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e9ecef;
  flex-shrink: 0;
}

.merge-primary-radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: #0f766e;
  cursor: pointer;
  user-select: none;
}

.merge-primary-radio-label input[type="radio"] {
  accent-color: #2baeba;
  cursor: pointer;
}

.merge-account-id-badge {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

/* Card Patient Profile */
.merge-patient-profile {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  overflow-y: auto;
  gap: 10px;
}

/* Avatar Frame */
.merge-avatar-wrap {
  width: 150px;
  height: 150px;
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.merge-avatar-wrap:hover {
  border-color: #2baeba;
  box-shadow: 0 4px 12px rgba(43, 174, 186, 0.22);
}

.merge-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.merge-avatar-wrap:hover img {
  transform: scale(1.05);
}

.merge-profile-meta {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Profile Field Row */
.merge-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 6px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
  min-height: 28px;
  transition: background 0.15s ease;
  border-radius: 3px;
}

.merge-field-row:hover {
  background: #f8fafc;
}

.merge-field-row.name-row {
  border-bottom: 1.5px solid #e2e8f0;
  padding-bottom: 6px;
  margin-bottom: 4px;
}

.name-copy-container {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 5px;
  transition: all 0.15s ease;
  position: relative;
}

.name-copy-container:hover {
  background: #e2e8f0;
}

.name-copy-container:hover .btn-copy-name {
  color: #0f766e;
  opacity: 1;
}

.name-copy-container .val-fullname {
  font-size: 13.5px;
  font-weight: 800;
  color: #0f172a;
  user-select: text;
}

.btn-copy-name {
  background: transparent;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #94a3b8;
  opacity: 0.7;
  transition: all 0.15s ease;
}

.btn-copy-name .material-icons {
  font-size: 14px;
}

.name-copied-tooltip {
  position: absolute;
  top: -24px;
  right: 0;
  background: #0f172a;
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 1000;
}

.merge-field-label {
  color: #64748b;
  font-size: 11.5px;
  font-weight: 600;
  flex-shrink: 0;
}

.merge-field-value {
  color: #0f172a;
  font-weight: 700;
  font-size: 12px;
  word-break: break-word;
  text-align: right;
}

/* Diff Highlight: Soft Amber Pill (Matches .pod-badge-sideways) */
.merge-field-value.diff-highlight {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

/* View ID Files Button (Matches .pod-header-tool-btn) */
.merge-id-action-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.merge-id-action-cell .val-id-count {
  font-size: 12.5px;
  font-weight: 800;
  color: #2baeba;
}

.btn-view-id-files {
  background: #f0fdfa;
  color: #0f766e;
  border: 1px solid #2baeba;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
  line-height: 1.4;
  white-space: nowrap;
}

.btn-view-id-files:hover {
  background: #2baeba;
  color: #ffffff;
  border-color: #2baeba;
  transform: translateY(-1px);
}

.btn-view-id-files * {
  pointer-events: none;
}

/* Center VS Divider */
.merge-vs-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 50px;
  gap: 6px;
  flex-shrink: 0;
}

.merge-vs-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #39c5bc 0%, #2baeba 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(43, 174, 186, 0.35);
}

.merge-score-tag {
  font-size: 10px;
  font-weight: 700;
  color: #0f766e;
  background: #ccfbf1;
  border: 1px solid #99f6e4;
  padding: 1px 5px;
  border-radius: 4px;
  text-align: center;
  white-space: nowrap;
}

/* --- Bottom Action Bar (POD Validation Blended Style) --- */
.merge-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  position: sticky;
  bottom: 0;
  z-index: 10;
  flex-shrink: 0;
  gap: 8px;
}

.merge-action-left,
.merge-action-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Primary Merge Button */
.merge-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #39c5bc 0%, #2baeba 100%) !important;
  color: #ffffff !important;
  border: none !important;
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(43, 174, 186, 0.35);
  transition: all 0.15s ease;
  user-select: none;
}

.merge-btn-primary:hover {
  background: linear-gradient(135deg, #2baeba 0%, #0f766e 100%) !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(43, 174, 186, 0.45);
}

.merge-btn-primary:active {
  transform: translateY(0);
}

/* Skip Button */
.merge-btn-skip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.merge-btn-skip:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
}

.merge-btn-skip kbd,
.merge-btn-nav kbd {
  background: #e2e8f0;
  color: #0f766e;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 9px;
  font-family: inherit;
  margin-left: 2px;
}

/* Prev / Next Navigation Buttons (Matches .pod-queue-nav-btn) */
.merge-btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  color: #0f766e;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.merge-btn-nav:hover:not(:disabled) {
  background: #2baeba;
  color: #ffffff;
  border-color: #2baeba;
}

.merge-btn-nav:hover:not(:disabled) kbd {
  background: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

.merge-btn-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #e2e8f0;
  color: #cbd5e1;
  box-shadow: none;
}

.merge-btn-nav * {
  pointer-events: none;
}

/* --- Grace Period Undo Banner --- */
.merge-undo-banner {
  display: none;
  background: #0f172a;
  color: #ffffff;
  border-radius: 6px;
  padding: 8px 14px;
  margin-top: 6px;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  font-size: 12px;
  font-weight: 600;
}

.merge-undo-btn {
  background: #f59e0b;
  border: none;
  color: #0f172a;
  font-weight: 800;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.merge-undo-btn:hover {
  background: #d97706;
  color: #ffffff;
}

.merge-undo-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: #f59e0b;
  transition: width linear;
}

/* --- Live Merge Status Alert (System Down / Retrying / Verified) --- */
.merge-status-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin-top: 6px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: fadeIn 0.2s ease-in;
}

.merge-status-alert.warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
}

.merge-status-alert.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.merge-status-alert.success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

.merge-status-alert.info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.merge-status-alert-btn {
  background: #dc2626;
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.merge-status-alert-btn:hover {
  background: #b91c1c;
}

.merge-retry-btn {
  background: #dc2626;
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s ease;
}

.merge-retry-btn:hover {
  background: #b91c1c;
}

/* --- Slide-Out Merge Queue Drawer (Matches .pod-queue-drawer) --- */
.merge-queue-drawer {
  position: absolute;
  top: 0;
  right: -360px;
  width: 360px;
  height: 100%;
  background: #ffffff;
  border-left: 1px solid #dee2e6;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 25;
}

.merge-queue-drawer.open {
  right: 0;
}

.merge-queue-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #e9ecef;
  background: #f8fafc;
  font-size: 12.5px;
  font-weight: 700;
  color: #0f766e;
}

.merge-queue-items {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.merge-queue-item {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  transition: all 0.15s ease;
}

.merge-queue-item:hover {
  border-color: #2baeba;
  background: #f0fdfa;
}

/* --- Identification Modal Lightbox --- */
.merge-id-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  backdrop-filter: blur(4px);
}

.merge-id-modal-card {
  background: #ffffff;
  width: 92%;
  max-width: 960px;
  height: 80vh;
  min-height: 520px;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

.merge-id-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.merge-id-modal-body {
  flex: 1 1 auto;
  height: 100%;
  min-height: 420px;
  overflow-y: auto;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  grid-auto-rows: min-content;
  align-content: start;
  gap: 16px;
  background: #f1f5f9;
}

.merge-id-card-item {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.merge-id-card-item:hover {
  border-color: #2baeba;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(43, 174, 186, 0.22);
}

.merge-id-img-frame {
  width: 100%;
  height: 220px;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.merge-id-img-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.merge-id-card-item:hover .merge-id-img-frame img {
  transform: scale(1.05);
}

.merge-id-zoom-hint {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.85);
  color: #38bdf8;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.merge-id-caption {
  padding: 8px 12px;
  font-size: 11.5px;
  font-weight: 700;
  color: #1e293b;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
}

/* --- High-Res Zoom Overlay --- */
.merge-id-zoom-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 15, 29, 0.96);
  z-index: 100000;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
}

.merge-id-zoom-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 18px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.merge-id-zoom-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.merge-id-zoom-badge {
  background: #2baeba;
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.merge-id-zoom-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-zoom-action {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-zoom-action:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: #38bdf8;
  color: #38bdf8;
}

.merge-id-zoom-viewport {
  flex: 1 1 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-in;
}

.merge-id-zoom-viewport.is-zoomed {
  cursor: zoom-out;
}

#merge-id-zoom-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
  user-select: none;
}

/* --- Auto-Merge P1 Modal (Maximized Full-Workspace Layout) --- */
.merge-auto-p1-modal-card {
  width: 96vw !important;
  max-width: 1520px !important;
  height: 92vh !important;
  max-height: 94vh !important;
}

.merge-auto-p1-modal-card .merge-id-modal-header {
  padding: 8px 16px;
}

.merge-auto-p1-body {
  flex: 1 1 0;
  min-height: 0;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  background: #f1f5f9;
}

.merge-auto-p1-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 7px 12px;
  flex-shrink: 0;
}

.merge-auto-p1-toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.merge-auto-p1-toolbar-label {
  font-size: 11.5px;
  font-weight: 800;
  color: #334155;
  margin-right: 2px;
}

.merge-auto-p1-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.merge-auto-p1-scope-badge {
  font-size: 11px;
  font-weight: 700;
  color: #0f766e;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  padding: 3px 8px;
  border-radius: 6px;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.merge-auto-p1-select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  font-size: 11.5px;
  font-weight: 700;
  font-family: inherit;
}

.merge-auto-p1-results {
  flex: 1 1 0;
  min-height: 0;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.merge-auto-p1-summary {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #cbd5e1;
  font-size: 11.5px;
  font-weight: 700;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.merge-auto-p1-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(580px, 1fr));
  gap: 8px;
  padding: 8px;
  align-content: start;
}

.merge-auto-p1-pill {
  padding: 2px 8px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #334155;
}

.merge-auto-p1-pill.is-ok {
  background: #dcfce7;
  color: #15803d;
}

.merge-auto-p1-pill.is-skip {
  background: #fef3c7;
  color: #92400e;
}

.merge-auto-p1-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid #fde68a;
  border-radius: 6px;
  background: #fffbeb;
  font-size: 11px;
}

.merge-auto-p1-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.merge-auto-p1-badge.is-merge {
  background: #ccfbf1;
  color: #0f766e;
}

.merge-auto-p1-badge.is-skip {
  background: #fef3c7;
  color: #92400e;
}

.merge-auto-p1-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  font-size: 11.5px;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
  user-select: none;
}

.merge-auto-p1-chip input[type="checkbox"] {
  accent-color: #0d9488;
  cursor: pointer;
  margin: 0;
}

.merge-auto-p1-audit-card {
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 7px 10px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.merge-auto-p1-audit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
  font-size: 11.5px;
}

.merge-auto-p1-tag {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
}

.merge-auto-p1-tag.is-ok {
  background: #dcfce7;
  color: #15803d;
}

.merge-auto-p1-tag.is-diff {
  background: #fee2e2;
  color: #b91c1c;
}

.merge-auto-p1-audit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.merge-auto-p1-audit-col {
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 10.5px;
  line-height: 1.35;
  color: #334155;
}

.merge-auto-p1-audit-col.is-primary {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
}

.merge-auto-p1-audit-col.is-dup {
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.merge-auto-p1-col-title {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
  margin-bottom: 2px;
  color: #0f172a;
}

.merge-auto-p1-audit-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  font-size: 10px;
  color: #475569;
}