#modal-edit-sequence {
  top: 50%;
  left: auto;
  right: 2rem;
  width: min(1080px, calc(100vw - 3rem));
  max-width: min(1080px, calc(100vw - 3rem));
  max-height: calc(100vh - 2rem);
  transform: translateY(-50%) scale(0.94);
  border-radius: 22px;
}

#modal-edit-sequence.sp-modal--open {
  transform: translateY(-50%) scale(1);
}

#modal-edit-sequence .sp-modal-header {
  padding: 1.4rem 1.5rem 1rem;
}

#modal-edit-sequence .sp-modal-body {
  padding: 0 1.5rem 1.5rem;
  text-align: left;
}

#modal-edit-sequence .sp-modal-actions {
  align-items: center;
  gap: 0.8rem;
}

#form-edit-sequence {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.95rem 1rem;
  align-items: start;
}

#form-edit-sequence > .sp-form-field,
#form-edit-sequence > .sp-form-footnote,
#form-edit-sequence > button {
  margin: 0;
}

#form-edit-sequence .sp-sequence-repeat-toggle,
#sp-repeat-sequence-gate,
#daily-repeat-days-field,
#daily-contacts-field,
#daily-repeat-start-field,
#save-sequence-btn {
  grid-column: 1 / -1;
}

.sp-sequence-repeat-toggle {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 56px;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: var(--sp-card-border-strong);
  background: var(--sp-card-surface);
}

.sp-sequence-repeat-toggle span {
  margin: 0;
}

.sp-sequence-repeat-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: #ff7b29;
  border: none;
  background: transparent;
  box-shadow: none;
}

.sp-sequence-repeat-toggle input[type="checkbox"]:focus {
  box-shadow: 0 0 0 3px rgba(255, 123, 41, 0.16);
}

#save-sequence-btn {
  justify-self: start;
  min-width: min(320px, 100%);
}

@media (max-width: 768px) {
  #modal-edit-sequence {
    top: 50%;
    right: 1rem;
    width: calc(100vw - 2rem);
    max-width: calc(100vw - 2rem);
    transform: translateY(-50%) scale(0.96);
  }

  #modal-edit-sequence.sp-modal--open {
    transform: translateY(-50%) scale(1);
  }

  #modal-edit-sequence .sp-modal-header,
  #modal-edit-sequence .sp-modal-body {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  #form-edit-sequence {
    grid-template-columns: 1fr;
  }

  #save-sequence-btn {
    width: 100%;
    min-width: 0;
  }
}

.sp-sequence-steps-table {
  table-layout: fixed;
  min-width: 880px;
}

.sp-sequence-steps-table th,
.sp-sequence-steps-table td {
  vertical-align: middle;
  padding-top: var(--sp-table-cell-y);
  padding-bottom: var(--sp-table-cell-y);
}

.sp-sequence-steps-table th:nth-child(1),
.sp-sequence-steps-table td:nth-child(1) {
  width: 48px;
}

.sp-sequence-steps-table th:nth-child(2),
.sp-sequence-steps-table td:nth-child(2) {
  width: 120px;
  white-space: nowrap;
}

.sp-sequence-steps-table th:nth-child(3),
.sp-sequence-steps-table td:nth-child(3) {
  width: 190px;
  white-space: nowrap;
}

.sp-sequence-steps-table th:nth-child(6),
.sp-sequence-steps-table td:nth-child(6) {
  width: 150px;
  white-space: nowrap;
}

.sp-sequence-step-cell {
  min-width: 0;
}

.sp-sequence-step-subject,
.sp-sequence-step-preview {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

.sp-sequence-step-subject {
  font-weight: 500;
  color: var(--sp-text);
}

.sp-sequence-step-preview {
  color: var(--sp-text-muted);
}

.sp-sequence-step-actions-cell {
  white-space: normal;
}

.sp-sequence-step-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sp-sequence-step-editor-input,
.sp-sequence-step-editor-textarea {
  width: 100%;
}

.sp-sequence-step-editor-textarea {
  min-height: 120px;
  resize: vertical;
}

.sp-sequence-step-editor-actions {
  display: flex;
  gap: 0.45rem;
  justify-content: flex-end;
  margin-top: 0.6rem;
}

@media (max-width: 760px) {
  .sp-sequence-steps-table {
    min-width: 680px;
  }

  .sp-sequence-steps-table th:nth-child(3),
  .sp-sequence-steps-table td:nth-child(3) {
    width: 170px;
  }
}