#sample-candidate-overlay {
  position: fixed;
  inset: 0;
  z-index: 1260;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(0, 0, 0, .48);
  backdrop-filter: blur(5px);
}

#sample-candidate-overlay.open {
  display: flex;
}

.sc-dialog {
  width: min(1180px, 97vw);
  height: min(820px, 92vh);
  min-height: 560px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  color: var(--text);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 16px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .3);
  animation: sc-dialog-in 220ms cubic-bezier(.2, .75, .25, 1) both;
}

@keyframes sc-dialog-in {
  from { opacity: 0; transform: scale(.975); }
  to { opacity: 1; transform: scale(1); }
}

.sc-head,
.sc-controls,
.sc-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
}

.sc-head {
  grid-row: 1;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.sc-title-wrap {
  min-width: 0;
}

.sc-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
}

.sc-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.sc-close {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: rgba(128, 128, 128, .14);
  font: inherit;
  font-size: 17px;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
  transform-origin: center;
}

.sc-close:hover { background: rgba(128, 128, 128, .24); transform: scale(1.06); }
.sc-close:active { transform: scale(.95); }

.sc-controls {
  grid-row: 2;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, var(--bg));
}

.sc-current-routing {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-current-routing.missing { color: #c83e34; }

.sc-routing-panel {
  grid-row: 3;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, var(--bg));
}

.sc-routing-panel[hidden] { display: none; }

.sc-routing-head,
.sc-routing-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sc-routing-head strong {
  color: var(--text);
  font-size: 13px;
}

.sc-routing-head span {
  margin-left: 8px;
  color: var(--muted);
  font-size: 11px;
}

.sc-routing-dismiss {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: rgba(128, 128, 128, .12);
  font: inherit;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
  transform-origin: center;
}

.sc-routing-dismiss:hover { background: rgba(128, 128, 128, .22); transform: scale(1.06); }

.sc-routing-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 116px;
  overflow-y: auto;
  margin: 11px 0;
  padding: 2px;
}

.sc-routing-chip {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.sc-routing-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sc-routing-chip span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  transition: transform 150ms ease, color 150ms ease, border-color 150ms ease, background 150ms ease;
  transform-origin: center;
}

.sc-routing-chip:hover span { transform: scale(1.025); border-color: rgba(239, 91, 54, .5); }
.sc-routing-chip input:checked + span { color: #a4371f; border-color: rgba(239, 91, 54, .5); background: rgba(239, 91, 54, .11); font-weight: 700; }
.sc-routing-chip input:focus-visible + span { outline: 2px solid rgba(239, 91, 54, .34); outline-offset: 2px; }

.sc-routing-actions { min-height: 34px; }
.sc-routing-actions > span { color: #c83e34; font-size: 11px; }

.sc-field {
  display: flex;
  align-items: center;
  gap: 7px;
}

.sc-field label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.sc-select {
  height: 34px;
  min-width: 110px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  font-size: 13px;
}

#sc-target { min-width: 210px; }
.sc-select:focus { border-color: #ef5b36; box-shadow: 0 0 0 3px rgba(239, 91, 54, .12); }

.sc-button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, opacity 150ms ease;
  transform-origin: center;
}

.sc-button:hover:not(:disabled) { transform: scale(1.025); border-color: rgba(239, 91, 54, .5); }
.sc-button:active:not(:disabled) { transform: scale(.98); }
.sc-button:disabled { cursor: default; opacity: .42; }
.sc-button.primary { border-color: #d94b2b; color: #fff; background: #e95332; }
.sc-button.primary:hover:not(:disabled) { background: #df4828; }
.sc-button.danger { color: #c83e34; border-color: rgba(200, 62, 52, .32); }

.sc-body {
  grid-row: 4;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
}

.sc-empty {
  min-height: 360px;
  display: grid;
  place-items: center;
  padding: 42px 20px;
  text-align: center;
  color: var(--muted);
}

.sc-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 15px;
}

.sc-loading-dot {
  width: 30px;
  height: 30px;
  margin: 0 auto 12px;
  border: 3px solid rgba(239, 91, 54, .18);
  border-top-color: #e95332;
  border-radius: 50%;
  animation: sc-spin 800ms linear infinite;
}

@keyframes sc-spin { to { transform: rotate(360deg); } }

.sc-summary {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 42px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.sc-summary strong { color: var(--text); font-size: 13px; }
.sc-summary-note { margin-left: auto; text-align: right; }

.sc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 12px;
}

.sc-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 36px;
  padding: 0 8px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 92%, var(--bg));
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  text-align: left;
}

.sc-table td {
  padding: 9px 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  vertical-align: middle;
}

.sc-table tbody tr { cursor: pointer; transition: background 130ms ease; }
.sc-table tbody tr:hover { background: rgba(239, 91, 54, .045); }
.sc-table tbody tr.selected { background: rgba(239, 91, 54, .085); }

.sc-check-cell { width: 42px; text-align: center !important; }
.sc-image-cell { width: 64px; }
.sc-product-cell { width: 220px; }
.sc-score-cell { width: 70px; }
.sc-person-cell { width: 118px; }
.sc-state-cell { width: 120px; }
.sc-reason-cell { width: auto; }

.sc-checkbox { width: 16px; height: 16px; accent-color: #e95332; cursor: pointer; }
.sc-image-button { display: block; width: 46px; height: 46px; border: 0; padding: 0; border-radius: 7px; overflow: hidden; background: var(--bg); cursor: zoom-in; }
.sc-image-button img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sc-image-placeholder { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 7px; color: var(--muted); background: var(--bg); font-size: 10px; }

.sc-sku { color: var(--text); font-size: 13px; font-weight: 700; }
.sc-product-name { overflow: hidden; margin-top: 2px; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.sc-score { display: inline-grid; place-items: center; min-width: 42px; height: 26px; border-radius: 7px; color: #a4371f; background: rgba(239, 91, 54, .12); font-size: 13px; font-weight: 750; }
.sc-meta-line { color: var(--text); font-size: 11px; }
.sc-meta-line + .sc-meta-line { margin-top: 3px; color: var(--muted); }
.sc-reasons { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.sc-reason { color: var(--muted); font-size: 11px; line-height: 1.35; }
.sc-reason::before { content: "·"; margin-right: 4px; color: #e95332; font-weight: 800; }

.sc-foot {
  grid-row: 5;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, var(--bg));
}

.sc-selected-count { color: var(--muted); font-size: 12px; }
.sc-foot-actions { display: flex; gap: 8px; }

.sc-toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 1300;
  padding: 9px 14px;
  border-radius: 8px;
  color: #fff;
  background: rgba(30, 30, 30, .92);
  font-size: 12px;
  transform: translateX(-50%);
  animation: sc-toast-in 180ms ease both;
}

@keyframes sc-toast-in { from { opacity: 0; transform: translateX(-50%) scale(.96); } }

@media (max-width: 760px) {
  #sample-candidate-overlay { padding: 8px; }
  .sc-dialog { width: 100%; height: 96vh; min-height: 0; border-radius: 12px; }
  .sc-controls { align-items: stretch; }
  .sc-field { flex: 1 1 46%; }
  .sc-field label { min-width: 52px; }
  .sc-select { width: 100%; min-width: 0; }
  #sc-target { min-width: 0; }
  .sc-controls > .sc-button { width: 100%; }
  .sc-current-routing { width: 100%; }
  .sc-routing-panel { padding: 12px; }
  .sc-routing-head { align-items: flex-start; }
  .sc-routing-head span { display: block; margin: 3px 0 0; }
  .sc-summary { overflow-x: auto; gap: 12px; }
  .sc-summary-note { display: none; }
  .sc-table { min-width: 880px; }
  .sc-foot { align-items: stretch; flex-direction: column; }
  .sc-foot-actions { display: grid; grid-template-columns: 1fr 1fr; }
  #sc-accept { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .sc-dialog,
  .sc-toast { animation: none; }
  .sc-button,
  .sc-close { transition: none; }
}
