.dispatch-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
}

.dispatch-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.dispatch-preview-content {
  position: relative;
  z-index: 1;
  width: min(980px, 96vw);
  height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.dispatch-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e9ecef;
  background: #f8f9fa;
}

.dispatch-preview-header h3 {
  margin: 0;
  color: var(--primary-color);
  font-size: 1.1rem;
  display: flex;
  gap: 8px;
  align-items: center;
}

.dispatch-preview-controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid #e9ecef;
  background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.dispatch-preview-controls label {
  display: grid;
  gap: 6px;
  color: #495057;
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 160px;
}

.dispatch-preview-controls select {
  border: 1px solid #ced4da;
  border-radius: 8px;
  background: #fff;
  color: #212529;
  font-size: 0.95rem;
  padding: 8px 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.dispatch-preview-inline-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dispatch-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #f1f3f5;
  color: #495057;
  font-size: 0.82rem;
}

.dispatch-stat-chip strong {
  color: #212529;
  font-size: 0.95rem;
}

.dispatch-stat-chip-total {
  background: #eef5ff;
  color: var(--primary-color);
}

.dispatch-stat-chip-total strong {
  color: var(--primary-color);
}

.dispatch-preview-close {
  border: none;
  background: transparent;
  color: #6c757d;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px;
}

.dispatch-preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
  background: #f6f8fa;
}

.dispatch-section-block {
  margin-bottom: 18px;
}

.dispatch-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 2px;
}

.dispatch-section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #343a40;
}

.dispatch-section-title i {
  color: var(--primary-color);
}

.dispatch-section-count {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #dee2e6;
  color: #6c757d;
  font-size: 0.82rem;
  font-weight: 600;
}

.dispatch-batch-card-list {
  display: grid;
  gap: 12px;
}

.dispatch-batch-card,
.dispatch-single-card {
  border: 1px solid #dee2e6;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.dispatch-batch-card {
  border-left: 4px solid var(--primary-color);
}

.dispatch-batch-card-blocked,
.dispatch-batch-card-muted {
  opacity: 0.96;
}

.dispatch-section-empty {
  padding: 16px;
  border: 1px dashed #dee2e6;
  border-radius: 10px;
  background: #fff;
  color: #6c757d;
  font-size: 0.88rem;
  text-align: center;
}

.dispatch-batch-card-header {
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, #fbfdff 0%, #fff 100%);
  border-bottom: 1px solid #eef2f6;
}

.dispatch-batch-card-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.dispatch-batch-index {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-color);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.dispatch-batch-card-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  line-height: 1.45;
  color: #212529;
  font-weight: 700;
}

.dispatch-batch-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dispatch-batch-bulk-edit {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 10px;
  padding: 10px 12px;
  border: 1px dashed #b6d4fe;
  border-radius: 10px;
  background: #f8fbff;
}

.dispatch-batch-bulk-label {
  flex: 0 0 auto;
  font-size: 0.84rem;
  font-weight: 700;
  color: #0d6efd;
  white-space: nowrap;
}

.dispatch-batch-writer-input {
  flex: 1 1 auto;
  min-width: 180px;
  border: 1px solid #b6d4fe;
  border-radius: 8px;
  padding: 8px 10px;
  color: #212529;
  font-size: 0.92rem;
  background: #fff;
}

.dispatch-batch-writer-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

.dispatch-channel-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e7f1ff;
  color: #0d6efd;
  font-size: 0.78rem;
  font-weight: 700;
}

.dispatch-batch-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: #f1f3f5;
  color: #495057;
  font-size: 0.78rem;
  font-weight: 700;
}

.dispatch-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.dispatch-status-badge-ready {
  background: #e8f5e9;
  color: #2e7d32;
}

.dispatch-status-badge-blocked {
  background: #fff8e1;
  color: #856404;
}

.dispatch-status-badge-muted {
  background: #f1f3f5;
  color: #6c757d;
}

.dispatch-status-badge-info {
  background: #eef5ff;
  color: #0d6efd;
}

.dispatch-item-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  color: #495057;
  font-size: 0.78rem;
  font-weight: 600;
}

.dispatch-item-badge-inline {
  white-space: nowrap;
}

.dispatch-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #e9ecef;
  color: #6c757d;
  font-size: 0.78rem;
}

.dispatch-meta-chip-writer {
  background: #f8fbff;
  border-color: #d7e7ff;
  color: #345;
}

.dispatch-meta-chip-muted {
  background: #f8f9fa;
  border-color: #e9ecef;
  color: #868e96;
}

.dispatch-confirm-writer-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dispatch-confirm-batch-list {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.dispatch-confirm-batch-card {
  margin-bottom: 12px;
}

.dispatch-confirm-batch-card:last-child {
  margin-bottom: 0;
}

.dispatch-confirm-error-list {
  margin-top: 12px;
}

.dispatch-meta-chip i {
  color: #adb5bd;
  font-size: 0.72rem;
}

.dispatch-card-warning {
  margin: 0 16px 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.84rem;
}

.dispatch-card-warning-info {
  background: #eef5ff;
  color: #0d6efd;
}

.dispatch-card-warning-warning {
  background: #fff8e1;
  color: #856404;
}

.dispatch-table-wrap-inset {
  border: none;
  border-radius: 0;
  border-top: 1px solid #eef2f6;
}

.dispatch-assignment-table-batch {
  min-width: 520px;
}

.dispatch-score-section {
  margin-top: 4px;
}

.dispatch-preview-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #e9ecef;
  background: #f8f9fa;
}

.dispatch-preview-footer-spacer {
  flex: 1;
}

.dispatch-preview-section {
  margin-bottom: 14px;
}

.dispatch-preview-section-title {
  font-weight: 700;
  color: #343a40;
  margin-bottom: 8px;
}

.dispatch-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.dispatch-summary-grid div,
.dispatch-candidate-card {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.dispatch-summary-grid span {
  display: block;
  color: #6c757d;
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.dispatch-summary-grid strong {
  color: #212529;
  font-size: 0.95rem;
}

.dispatch-candidate-list {
  display: grid;
  gap: 10px;
}

.dispatch-table-wrap {
  overflow-x: auto;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  background: #fff;
}

.dispatch-task-table,
.dispatch-candidate-table,
.dispatch-assignment-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.dispatch-task-table th,
.dispatch-task-table td,
.dispatch-candidate-table th,
.dispatch-candidate-table td,
.dispatch-assignment-table th,
.dispatch-assignment-table td {
  border-bottom: 1px solid #e9ecef;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 0.88rem;
}

.dispatch-col-id,
.dispatch-col-date {
  white-space: nowrap;
}

.dispatch-col-title {
  min-width: 180px;
  max-width: 280px;
}

.dispatch-row-blocked {
  opacity: 0.55;
}

.dispatch-task-table th,
.dispatch-candidate-table th,
.dispatch-assignment-table th {
  color: #495057;
  background: #f8f9fa;
  font-weight: 700;
  white-space: nowrap;
}

.dispatch-task-table tr:last-child td,
.dispatch-candidate-table tr:last-child td,
.dispatch-assignment-table tr:last-child td {
  border-bottom: none;
}

.dispatch-task-writer-input {
  width: 100%;
  min-width: 140px;
  border: 1px solid #ced4da;
  border-radius: 8px;
  padding: 8px 10px;
  color: #212529;
  font-size: 0.92rem;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dispatch-task-writer-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

.dispatch-task-writer-input:not(:placeholder-shown) {
  background: #f8fbff;
  border-color: #b6d4fe;
}

.dispatch-detail-panel {
  margin-top: 0;
  margin-bottom: 0;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  background: #fff;
  padding: 12px 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.dispatch-detail-panel summary {
  cursor: pointer;
  color: #343a40;
  font-weight: 700;
  margin-bottom: 0;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dispatch-detail-panel summary::-webkit-details-marker {
  display: none;
}

.dispatch-detail-panel[open] summary {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eef2f6;
}

.dispatch-candidate-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.dispatch-candidate-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--primary-color);
  font-weight: 700;
}

.dispatch-candidate-name {
  font-weight: 700;
  color: #212529;
}

.dispatch-candidate-sub,
.dispatch-preview-muted {
  color: #6c757d;
  font-size: 0.88rem;
}

.dispatch-candidate-reasons {
  display: grid;
  gap: 4px;
  color: #495057;
  font-size: 0.86rem;
  min-width: 180px;
}

.dispatch-candidate-risk {
  margin-top: 8px;
  font-size: 0.86rem;
  color: #856404;
}

.dispatch-candidate-score {
  margin-top: 8px;
}

.dispatch-candidate-score summary {
  color: var(--primary-color);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
}

.dispatch-manual-writers {
  width: 100%;
  border: 1px solid #ced4da;
  border-radius: 8px;
  padding: 10px 12px;
  color: #212529;
  font-size: 0.95rem;
  resize: vertical;
}

.dispatch-warning-list {
  display: grid;
  gap: 8px;
}

.dispatch-warning {
  display: flex;
  gap: 8px;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 10px 12px;
  color: #495057;
  background: #fff;
}

.dispatch-warning-warning,
.dispatch-warning-blocked {
  color: #856404;
  background: #fff8e1;
}

.dispatch-preview-loading,
.dispatch-preview-empty,
.dispatch-preview-error {
  padding: 48px 24px;
  text-align: center;
  color: #64748b;
  font-size: 18px;
  font-weight: 600;
}

.dispatch-preview-loading::before {
  content: '';
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 4px solid rgba(33, 150, 243, 0.18);
  border-top-color: #2196F3;
  animation: dispatch-preview-spin 0.85s linear infinite;
}

@keyframes dispatch-preview-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.dispatch-preview-error {
  color: #721c24;
}

@media (max-width: 768px) {
  .dispatch-preview-content {
    width: 100vw;
  }

  .dispatch-summary-grid,
  .dispatch-candidate-reasons {
    grid-template-columns: 1fr;
  }
}
