/* Màn Cài đặt: các thẻ nhóm cài đặt. Tiền tố st-. Màu cột/swatch lấy từ dữ liệu qua style nội tuyến. */

.st-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.st-col {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.st-wide {
  grid-column: 1 / -1;
  min-width: 0;
}
.st-card {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.st-note {
  font-size: 13px;
}
.st-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}
.st-add .btn {
  min-height: 44px;
}
.st-actions-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Cột pipeline ---------- */
.st-stage-list {
  display: grid;
  gap: 8px;
}
.st-stage {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.st-stage.is-new {
  animation: rise var(--duration-slide) var(--ease-out);
}
.st-stage-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
.st-dot {
  width: 24px;
  height: 24px;
  flex: none;
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
  transition: transform var(--duration-fast) var(--ease-out);
}
.st-dot:active {
  transform: scale(0.88);
}
@media (hover: hover) {
  .st-dot:hover {
    transform: scale(1.12);
  }
}
.st-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-weight: 600;
  transition:
    border-color var(--duration-base),
    background var(--duration-base),
    box-shadow var(--duration-base);
}
.st-input:focus,
.st-input[aria-invalid] {
  border-color: var(--accent);
  background: var(--surface);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.st-input[aria-invalid] {
  border-color: var(--danger);
  box-shadow: none;
}
@media (hover: hover) {
  .st-input:hover {
    border-color: var(--line);
    background: var(--surface);
  }
}
.st-actions {
  display: flex;
  gap: 2px;
}
.st-act.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.st-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 2px 34px;
  transform-origin: left top;
  animation: pop-in var(--duration-base) var(--ease-out);
}
.st-palette[hidden] {
  display: none;
}
.st-palette.is-leaving {
  opacity: 0;
  transform: scale(0.96);
  transition:
    opacity var(--duration-fast),
    transform var(--duration-fast);
}
.st-swatch {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
  color: #fff;
  transition: transform var(--duration-fast) var(--ease-out);
}
.st-swatch .i {
  width: 16px;
  height: 16px;
  stroke-width: 3;
}
.st-swatch:active {
  transform: scale(0.88);
}
@media (hover: hover) {
  .st-swatch:hover {
    transform: scale(1.12);
  }
}
.st-msg {
  min-height: 0;
  color: var(--muted);
  font-size: 12px;
}
.st-msg.is-error {
  padding: 6px 0 2px 34px;
  color: var(--danger);
  animation: fade-in var(--duration-base) var(--ease-out);
}

/* ---------- Chip nhãn, nguồn, lý do ---------- */
.st-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}
.st-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 500;
}
.st-chip.is-new {
  animation: pop var(--duration-slide) var(--ease-out);
}
.st-chip-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.st-chip-x {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  transition:
    background var(--duration-base),
    color var(--duration-base),
    transform var(--duration-fast) var(--ease-out);
}
.st-chip-x .i,
.st-chip-lock .i {
  width: 14px;
  height: 14px;
}
.st-chip-lock {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
}
.st-chip-x:active {
  transform: scale(0.85);
}
@media (hover: hover) {
  .st-chip-x:hover {
    background: var(--danger-soft);
    color: var(--danger);
  }
}

/* ---------- Mẫu email ---------- */
.st-mail {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.st-mail-side {
  display: grid;
  gap: 8px;
  justify-items: start;
}
.st-mail-list {
  display: grid;
  gap: 4px;
  width: 100%;
}
.st-mail-item {
  position: relative;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  text-align: left;
  transition:
    background var(--duration-base),
    border-color var(--duration-base),
    transform var(--duration-fast) var(--ease-out);
}
.st-mail-item:active {
  transform: scale(0.98);
}
.st-mail-item[aria-current='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
@media (hover: hover) {
  .st-mail-item:hover {
    background: var(--surface-2);
  }
  .st-mail-item[aria-current='true']:hover {
    background: var(--accent-soft);
  }
}
.st-mail-editor {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.st-mail-editor.st-enter {
  animation: rise var(--duration-slide) var(--ease-out);
}
.st-vars {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0 8px;
}
.st-var {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.st-preview {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.st-prev-subject {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.st-prev-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.st-sub {
  margin-top: 4px;
  font-size: 14px;
}
.st-block-msg {
  font-size: 12px;
}
.st-block-msg.is-error {
  color: var(--danger);
  animation: fade-in var(--duration-base) var(--ease-out);
}

/* ---------- Tỉ lệ chốt của cột ---------- */
.st-prob {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
}
.st-prob .st-prob-input {
  flex: none;
  width: 64px;
  text-align: right;
}
.st-prob-input:disabled {
  color: var(--muted);
  cursor: not-allowed;
}
.st-prob-unit {
  color: var(--muted);
  font-size: 13px;
}
.st-prob-bar {
  display: block;
  width: 48px;
  height: 6px;
  margin-left: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface);
}
.st-prob-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transform-origin: left center;
  transition: transform var(--duration-slide) var(--ease-out);
}

/* ---------- Chỉ tiêu & hoa hồng ---------- */
.st-q-rows {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}
.st-q-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.1fr) minmax(0, 1.4fr) minmax(0, 0.7fr) auto;
  gap: 4px 12px;
  align-items: start;
  padding: 10px 12px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.st-q-person,
.st-lead {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.st-q-person {
  min-height: 44px;
}
.st-q-name {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.st-q-money {
  display: grid;
  min-width: 0;
}
.st-q-preview {
  min-height: 18px;
  padding-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.st-q-lead {
  min-height: 44px;
}
.st-q-total {
  font-size: 15px;
}
.st-q-foot {
  display: grid;
  grid-template-columns: minmax(0, 260px) auto;
  justify-content: space-between;
  gap: 8px 16px;
  align-items: start;
}
.st-q-foot .btn {
  min-height: 44px;
}

/* ---------- Duyệt giảm giá ---------- */
.st-leads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.st-lead {
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  animation: pop-in var(--duration-base) var(--ease-out);
}

/* ---------- Kịch bản bám khách ---------- */
.st-seq-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.st-seq-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.st-seq-steps {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.st-seq-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px 10px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.st-seq-step.is-new {
  animation: st-slide-in var(--duration-slide) var(--ease-out);
}
.st-seq-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}
.st-seq-fields {
  display: grid;
  grid-template-columns: 130px 96px minmax(0, 1fr);
  gap: 0 8px;
  min-width: 0;
}
.st-seq-actions {
  padding-top: 6px;
}
.st-seq-empty {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  text-align: center;
  animation: fade-in var(--duration-base) var(--ease-out);
}
.st-seq-editor > .btn-sm {
  justify-self: start;
  margin: 4px 0 8px;
}

@keyframes st-slide-in {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
}

@media (max-width: 1100px) {
  .st-seq-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .st-seq-fields .field:last-child {
    grid-column: 1 / -1;
  }
}
@media (pointer: coarse) {
  .st-prob-bar {
    height: 8px;
  }
  .st-q-row .switch,
  .st-seq-actions .icon-btn {
    min-height: 44px;
  }
  .st-seq-actions .icon-btn {
    width: 44px;
  }
}

@media (max-width: 720px) {
  .st-grid,
  .st-mail {
    grid-template-columns: minmax(0, 1fr);
  }
  .st-stage-main {
    flex-wrap: wrap;
  }
  .st-input {
    flex-basis: calc(100% - 40px);
  }
  .st-add {
    grid-template-columns: minmax(0, 1fr);
  }
  .st-mail-side {
    justify-items: stretch;
  }
  .st-prob {
    margin-left: 34px;
  }
  /* Bảng chỉ tiêu thành thẻ từng người. */
  .st-q-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
  }
  .st-q-person {
    grid-column: 1 / -1;
  }
  .st-q-lead {
    grid-column: 1 / -1;
    margin-bottom: 10px;
  }
  .st-q-foot {
    grid-template-columns: minmax(0, 1fr);
  }
  .st-seq-step {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .st-seq-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding: 0 0 8px;
  }
  .st-seq-fields {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.7fr);
  }
  .st-palette,
  .st-msg.is-error {
    padding-left: 0;
  }
}
