:root {
  --source-card: color-mix(in srgb, var(--yomi-card-bg, #ffffff) 94%, transparent);
  --source-line: rgba(15, 23, 42, 0.1);
  --source-text: var(--yomi-table-body-text, #111827);
  --source-muted: var(--yomi-table-sub-text, #667085);
  --source-soft: #f7f8fa;
  --source-blue: #2563eb;
  --source-green: #22c55e;
  --source-danger: #ef4444;
}

.source-icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--source-line);
  border-radius: 12px;
  background-color: var(--yomi-detail-bg, #fff);
  background-image: var(--yomi-detail-bg-image, none);
  background-size: cover;
  background-position: center;
  color: var(--source-text);
}

.source-icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.source-icon-button:disabled {
  cursor: default;
  opacity: .4;
}

.order-sources-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 500px;
  gap: 14px;
  align-items: start;
  height: 100%;
  min-height: 0;
}

.source-card {
  border: 1px solid var(--source-line);
  border-radius: 18px;
  background-color: var(--source-card);
  background-image: var(--yomi-order-card-bg-image, none);
  background-size: cover;
  background-position: center;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.source-list-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  padding: 28px 24px;
}

.source-form-card {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.source-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.source-card h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.source-card p {
  margin: 8px 0 0;
  color: var(--source-muted);
  font-size: 14px;
}

.source-list {
  display: grid;
  align-content: start;
  gap: 14px;
  margin-top: 32px;
  min-height: 0;
  overflow: auto;
}

.source-row {
  display: grid;
  grid-template-columns: 42px 48px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 58px;
}

.return-tag-row {
  grid-template-columns: 48px minmax(0, 1fr) auto;
  padding: 10px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.order-source-row {
  grid-template-columns: 48px minmax(0, 1fr) auto;
  padding: 10px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.return-tag-row.is-selected,
.order-source-row.is-selected {
  background: var(--yomi-hover-bg, #f5f5f3);
}

.source-drag {
  color: #9ca3af;
  cursor: grab;
}

.source-avatar {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--source-line);
  border-radius: 12px;
  background-color: var(--yomi-detail-bg, #fff);
  background-image: var(--yomi-detail-bg-image, none);
  background-size: cover;
  background-position: center;
  color: #9a3412;
  font-size: 13px;
  font-weight: 800;
}

.source-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.source-info strong {
  display: block;
  color: var(--yomi-table-body-text, #111827);
  font-family: var(--yomi-table-body-text-font, Inter, Arial, sans-serif);
  font-size: var(--yomi-table-body-text-size, 14px);
  font-style: var(--yomi-table-body-text-style, normal);
  font-weight: var(--yomi-table-body-text-weight, 500);
}

.source-info span {
  display: block;
  margin-top: 2px;
  color: var(--source-muted);
  font-family: var(--yomi-table-sub-text-font, Inter, Arial, sans-serif);
  font-size: var(--yomi-table-sub-text-size, 13px);
  font-style: var(--yomi-table-sub-text-style, normal);
  font-weight: var(--yomi-table-sub-text-weight, 400);
}

.source-info small {
  display: block;
  margin-top: 2px;
  color: var(--source-muted);
  font-family: var(--yomi-table-sub-text-font, Inter, Arial, sans-serif);
  font-size: var(--yomi-table-sub-text-size, 13px);
  font-style: var(--yomi-table-sub-text-style, normal);
  font-weight: var(--yomi-table-sub-text-weight, 400);
}

.source-info b {
  display: block;
  margin-top: 2px;
  color: var(--yomi-table-sub-text, #667085);
  font-family: var(--yomi-table-sub-text-font, Inter, Arial, sans-serif);
  font-size: var(--yomi-table-sub-text-size, 13px);
  font-style: var(--yomi-table-sub-text-style, normal);
  font-weight: var(--yomi-table-sub-text-weight, 400);
}

.source-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.source-icon-button.is-default {
  border-color: #9ab8ff;
  background: #eff6ff;
  color: var(--source-blue);
}

.source-icon-button.is-danger {
  border: 0;
  background: #eef0f2;
  color: #9ca3af;
}

.source-switch {
  position: relative;
  display: inline-flex;
  width: 38px;
  height: 22px;
}

.source-switch input {
  position: absolute;
  opacity: 0;
}

.source-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #d1d5db;
}

.source-switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--yomi-detail-bg, #fff);
  background-image: var(--yomi-detail-bg-image, none);
  background-size: cover;
  background-position: center;
  transition: transform 0.16s ease;
}

.source-switch input:checked + span {
  background: var(--source-green);
}

.source-switch input:checked + span::after {
  transform: translateX(16px);
}

.source-form-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.source-form-actions {
  display: flex;
  gap: 10px;
}

.source-image-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.source-upload {
  display: inline-grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--source-line);
  border-radius: 12px;
  background: #fff;
}

.source-upload.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.source-upload svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.source-field {
  display: grid;
  gap: 8px;
}

.source-field span {
  color: var(--source-muted);
  font-family: var(--yomi-form-label-text-font, Inter, Arial, sans-serif);
  font-size: var(--yomi-form-label-text-size, 13px);
  font-style: var(--yomi-form-label-text-style, normal);
  font-weight: var(--yomi-form-label-text-weight, 600);
}

.source-input,
.source-textarea {
  width: 100%;
  border: 1px solid var(--source-line);
  border-radius: 12px;
  background-color: color-mix(in srgb, var(--yomi-form-bg, #fff) 88%, transparent);
  background-image: var(--yomi-form-bg-image, none);
  background-size: cover;
  background-position: center;
  color: var(--source-text);
  font-family: var(--yomi-form-input-text-font, Inter, Arial, sans-serif);
  font-size: var(--yomi-form-input-text-size, 14px);
  font-style: var(--yomi-form-input-text-style, normal);
  font-weight: var(--yomi-form-input-text-weight, 500);
  outline: none;
}

.source-input {
  height: 44px;
  padding: 0 14px;
}

.source-textarea {
  min-height: 90px;
  resize: vertical;
  padding: 13px 14px;
}

.source-input::placeholder,
.source-textarea::placeholder {
  color: var(--yomi-form-placeholder-text, #98a2b3);
  font-family: var(--yomi-form-placeholder-text-font, Inter, Arial, sans-serif);
  font-size: var(--yomi-form-placeholder-text-size, 14px);
  font-style: var(--yomi-form-placeholder-text-style, normal);
  font-weight: var(--yomi-form-placeholder-text-weight, 400);
}

.source-empty,
.source-status {
  color: var(--source-muted);
  font-size: 14px;
}

.source-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.25);
}

.source-toast[hidden] {
  display: none;
}

@media (max-width: 900px) {
  .order-sources-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .source-list-card { height: auto; min-height: 340px; }

  .return-tag-row,
  .order-source-row { grid-template-columns: 42px minmax(0, 1fr); }

  .source-row {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .source-drag,
  .source-avatar {
    grid-row: span 2;
  }

  .source-actions {
    grid-column: 2;
  }
}
