.handoff-panel {
  display: none;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.handoff-panel.active {
  display: flex;
  flex-direction: column;
}

.director-handoff-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-height: 70vh;
  overflow-y: auto;
}

.director-handoff-dialog {
  position: relative;
  width: 750px;
  max-width: 95vw;
  min-width: min(520px, calc(100vw - 64px));
  height: 600px;
  max-height: calc(95vh - 2rem);
  overflow: auto;
  background: #fff;
}

.director-handoff-dialog.is-resizing {
  user-select: none;
  cursor: se-resize;
}

.handoff-result-dialog {
  width: 750px;
  max-width: 90vw;
  height: 600px;
  max-height: 85vh;
  overflow: auto;
}

.handoff-result-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.handoff-result-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  font-weight: 700;
}

.handoff-result-summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.handoff-result-table table {
  width: 100%;
  border-collapse: collapse;
}

.handoff-result-table th,
.handoff-result-table td {
  text-align: left;
  padding: var(--space-2);
  border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}

.handoff-result-table thead th {
  background: rgba(248, 250, 252, 0.8);
  position: sticky;
  top: 0;
  z-index: 1;
}

.handoff-result-status {
  font-weight: 700;
}

.handoff-result-status.success {
  color: #15803d;
}

.handoff-result-status.failed {
  color: #b91c1c;
}

.handoff-result-status.skipped {
  color: #475569;
}

.handoff-director-name {
  font-weight: 600;
}

.handoff-assignment-section {
  border: 1.25px solid var(--color-border-subtle, rgba(15, 23, 42, 0.08));
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: var(--color-surface-muted, rgba(248, 250, 252, 0.7));
}

.handoff-panel-note {
  margin: var(--space-2) 0 var(--space-3);
  padding: 0.75rem;
  background: rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.4;
}

.handoff-assignment-toolbar {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-bottom: var(--space-3);
}

.handoff-toggle-all {
  border: none;
  background: none;
  color: var(--color-primary, #2563eb);
  font-weight: 600;
  cursor: pointer;
  padding: 0.15rem 0.25rem;
}

.handoff-toggle-all:hover {
  text-decoration: underline;
}

.handoff-assignment-extra {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.handoff-assignment-extra textarea {
  min-height: 64px;
  font-size: 0.85rem;
}

.handoff-mode-tabs {
  display: inline-flex;
  border: 1.25px solid var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-3);
}

.handoff-mode-tab {
  border: none;
  background: transparent;
  padding: var(--space-2) var(--space-4);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--color-text-muted);
}

.handoff-mode-tab.active {
  background: var(--color-primary-soft, rgba(34, 197, 94, 0.12));
  color: var(--color-primary, #0f9f5f);
}

.handoff-select-all {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.35rem 0.85rem;
  background: rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-full, 999px);
  font-size: 0.85rem;
}

.handoff-select-all input {
  margin: 0;
}

.handoff-assignment-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.handoff-assignment-summary {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin: var(--space-2) 0 var(--space-3);
}

.handoff-summary-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full, 999px);
  font-weight: 600;
  font-size: 0.85rem;
  background: rgba(148, 163, 184, 0.15);
}

.handoff-summary-chip--info {
  background: rgba(59, 130, 246, 0.15);
  color: #1d4ed8;
}

.handoff-summary-chip--light {
  background: rgba(148, 163, 184, 0.12);
  font-weight: 500;
}

.handoff-stepper {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.handoff-stepper-item {
  border: 1.25px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  display: flex;
  gap: var(--space-3);
  align-items: center;
  background: var(--color-surface);
}

.handoff-stepper-item.active {
  border-color: var(--color-primary);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.12);
}

.handoff-stepper-index {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-neutral-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semibold);
}

.handoff-stepper-item.active .handoff-stepper-index {
  background: var(--color-primary);
  color: #fff;
}

.handoff-stepper-text strong {
  display: block;
}

.handoff-step {
  display: block;
}

.handoff-step[hidden] {
  display: none;
}

.handoff-assignment-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  align-items: stretch;
  min-height: 460px;
}

.handoff-assignment-column {
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.handoff-column-resize-vertical {
  width: 10px;
  cursor: col-resize;
  position: relative;
}

.handoff-column-resize-vertical::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  background: rgba(148, 163, 184, 0.6);
  border-radius: var(--radius-full, 999px);
}

.handoff-assignment-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.handoff-manual-list,
.handoff-assignment-list {
  flex: 1 1 auto;
  min-height: 320px;
  max-height: 480px;
  overflow-y: auto;
  border: 1.25px solid rgba(226, 232, 240, 0.8);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0;
  resize: vertical;
}

.handoff-assignment-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2);
  padding: 0.35rem 0;
  border-bottom: 1.25px solid rgba(226, 232, 240, 0.6);
}

.handoff-assignment-item:last-child {
  border-bottom: none;
}

.handoff-assignment-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.handoff-review-panel {
  border: 1.25px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.handoff-review-table {
  width: 100%;
  border-collapse: collapse;
}

.handoff-review-table th,
.handoff-review-table td {
  border: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-3);
  text-align: left;
}

.handoff-manual-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1.25px solid rgba(226, 232, 240, 0.6);
  font-weight: 600;
}

.handoff-manual-item:last-child {
  border-bottom: none;
}

.handoff-manual-item small {
  font-weight: 500;
  color: var(--color-text-muted, #64748b);
}

.handoff-assignment-details {
  display: flex;
  flex-direction: column;
}

.handoff-distribution-panel {
  border: 1.25px dashed var(--color-border, rgba(15, 23, 42, 0.2));
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: rgba(248, 250, 252, 0.6);
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.handoff-distribution-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.handoff-header-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-right: 10px;
}

.handoff-header-actions .toggle-switch {
  margin: 0;
}

/* Handoff cross-group toggle: label trước, track sau nhưng vẫn phản ánh trạng thái */
.handoff-cross-field input:checked ~ .toggle-switch-track {
  background: linear-gradient(120deg, #1e64f0, #4c8efd);
  box-shadow: inset 0 1px 5px rgba(15, 23, 42, 0.2);
}

.handoff-cross-field input:checked ~ .toggle-switch-track .toggle-switch-thumb {
  transform: translateX(28px);
  box-shadow: 0 6px 12px rgba(30, 100, 240, 0.4);
}

.handoff-distribution-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: var(--space-4);
  align-items: stretch;
  padding-top: var(--space-3);
  position: relative;
}

.handoff-distribution-layout.is-direct {
  grid-template-columns: 1fr;
}

.handoff-workload-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(520px, 90vw);
  max-height: 540px;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: var(--color-surface);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  z-index: 10;
}

.handoff-workload-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.handoff-workload-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 220px;
  overflow: auto;
}

.handoff-workload-item {
  padding: var(--space-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-subtle, rgba(15, 23, 42, 0.08));
  background: var(--color-surface-muted, rgba(248, 250, 252, 0.7));
}

.handoff-workload-item .title {
  font-weight: 600;
}

.handoff-workload-item .meta {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--color-text-muted, #64748b);
}

@media (max-width: 1024px) {
  .handoff-distribution-layout {
    grid-template-columns: 1fr;
  }
}

.handoff-distribution-config {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: rgba(148, 163, 184, 0.08);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}

.handoff-distribution-mode {
  display: flex;
  gap: var(--space-2);
}

.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  padding: 0.15rem 0.85rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.chip-toggle input {
  margin: 0;
  accent-color: var(--color-primary, #2563eb);
}

.chip-toggle input:checked + span {
  font-weight: 600;
  color: var(--color-text, #0f172a);
}

.chip-toggle input:checked ~ * {
  color: var(--color-text, #0f172a);
}

.handoff-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--space-2);
}

.handoff-config-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.85);
}

.handoff-config-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.8;
}

.handoff-config-field input,
.handoff-config-field select {
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.9);
  color: var(--color-text, #0f172a);
}

.handoff-min-chunk-field {
  background: rgba(148, 163, 184, 0.12);
}

.handoff-target-rate-field {
  background: rgba(148, 163, 184, 0.12);
}

.handoff-strategy-field {
  background: rgba(148, 163, 184, 0.12);
}

.handoff-cross-field {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
}

.handoff-cross-field input {
  margin: 0;
  width: auto;
}

.handoff-cross-field span {
  font-size: 0.95rem;
  font-weight: 600;
}

.handoff-suggest-button {
  justify-self: stretch;
  width: 100%;
}

.handoff-table-card {
  border: 1.25px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  background: #fff;
  max-height: none;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.handoff-distribution-table {
  flex: 1;
  overflow: auto;
}

.handoff-distribution-table table {
  width: 100%;
  border-collapse: collapse;
}

.director-handoff-actions {
  gap: var(--space-2);
  justify-content: flex-end;
}

.director-handoff-actions .handoff-action-spacer {
  flex: 1;
}

.handoff-distribution-table thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.handoff-status-row {
  margin-top: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.modal-resize-handle {
  position: absolute;
  right: 0.75rem;
  bottom: 0.5rem;
  width: 18px;
  height: 18px;
  border-right: 2px solid rgba(148, 163, 184, 0.8);
  border-bottom: 2px solid rgba(148, 163, 184, 0.8);
  border-radius: 2px;
  cursor: se-resize;
  display: none;
}

.modal-size-indicator {
  position: absolute;
  bottom: 0.75rem;
  left: 0.9rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-full, 999px);
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}

.handoff-lock-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full, 999px);
  background: rgba(59, 130, 246, 0.12);
  font-weight: 600;
}

.handoff-lock-toggle input {
  margin: 0;
}

.handoff-lock-toggle[hidden] {
  display: none !important;
}

.handoff-distribution-table th,
.handoff-distribution-table td {
  text-align: left;
  padding: var(--space-2);
  border-bottom: 1.25px solid rgba(226, 232, 240, 0.7);
}

.handoff-distribution-table thead th:nth-child(1),
.handoff-distribution-table tbody td:nth-child(1) {
  width: 50%;
}

.handoff-distribution-table thead th:nth-child(2),
.handoff-distribution-table tbody td:nth-child(2) {
  width: 18%;
}

.handoff-distribution-table thead th:nth-child(3),
.handoff-distribution-table tbody td:nth-child(3) {
  width: 12%;
}

.handoff-distribution-table thead th:nth-child(4),
.handoff-distribution-table tbody td:nth-child(4) {
  width: 9%;
}

.handoff-distribution-table thead th:nth-child(5),
.handoff-distribution-table tbody td:nth-child(5) {
  width: 11%;
}

.handoff-distribution-table tr:last-child td {
  border-bottom: none;
}

.handoff-distribution-table .capacity-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-2);
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  font-size: 0.85rem;
}

.handoff-distribution-table .distribution-input {
  width: 80px;
}

.handoff-direct-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.handoff-direct-controls .small-text {
  margin: 0;
}

.handoff-direct-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.handoff-direct-row {
  display: grid;
  grid-template-columns: auto 1fr minmax(220px, 320px);
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  border: 1.25px solid rgba(226, 232, 240, 0.9);
}

.handoff-direct-row .handoff-direct-meta strong {
  display: block;
}

.handoff-direct-row .handoff-direct-meta p {
  margin: 0.2rem 0 0;
}

.handoff-direct-row .handoff-direct-target {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.handoff-load-meter {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.handoff-load-bar {
  position: relative;
  flex: 1;
  height: 6px;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.handoff-load-bar .handoff-load-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #2563eb);
  border-radius: inherit;
}

.handoff-load-label {
  font-size: 0.85rem;
  color: var(--color-text-muted, #64748b);
  white-space: nowrap;
}

.handoff-direct-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.handoff-direct-actions .secondary-button {
  white-space: nowrap;
}

.handoff-direct-empty {
  padding: var(--space-3);
  background: rgba(226, 232, 240, 0.5);
  border-radius: var(--radius-md);
  color: var(--color-text-muted, #64748b);
}

.handoff-direct-note {
  margin: 0;
}

.handoff-warning {
  color: var(--color-danger, #dc2626);
  font-weight: 700;
}
