/* v195 安装 / 维修调度看板（.dispatch- 前缀；仅本页使用，不改 app.css） */

/* ---------- 页面骨架 ---------- */
.dispatch-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50vh;
  color: var(--ink-3, #8b93a1);
  font-size: 14px;
}
.dispatch-loading-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line, #e6e9ee);
  border-top-color: var(--teal, #14a394);
  animation: dispatch-spin 0.8s linear infinite;
}
@keyframes dispatch-spin {
  to { transform: rotate(360deg); }
}

.dispatch-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.dispatch-range .btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.dispatch-range-label {
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-weight: 500;
}

.dispatch-kpis { margin-bottom: 14px; }

.dispatch-layout {
  display: grid;
  grid-template-columns: 318px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.dispatch-layout > * { min-width: 0; }

/* ---------- 待派池 ---------- */
.dispatch-pool-card .card-body { padding: 12px; }
.dispatch-pool-body { display: flex; flex-direction: column; gap: 10px; }
.dispatch-search {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line, #e6e9ee);
  border-radius: var(--radius-sm, 8px);
  background: var(--paper, #fff);
  color: var(--ink-3, #8b93a1);
}
.dispatch-search:focus-within {
  border-color: var(--teal, #14a394);
  box-shadow: 0 0 0 3px var(--teal-mist, rgba(20, 163, 148, 0.12));
}
.dispatch-search .input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  box-shadow: none;
  padding: 8px 0;
}
.dispatch-pool {
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: calc(100vh - 336px);
  overflow-y: auto;
  padding-right: 2px;
}
.dispatch-pool-unscheduled { max-height: calc(100vh - 520px); }
.dispatch-search-empty {
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3, #8b93a1);
}
.dispatch-search-empty.is-hidden { display: none; }
.dispatch-section {
  border-top: 1px dashed var(--line, #e6e9ee);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dispatch-section-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2, #4b5563);
}
.dispatch-section-head .muted {
  font-weight: 400;
  font-size: 11px;
  line-height: 1.4;
}

/* ---------- 工单卡片 ---------- */
.dispatch-job {
  position: relative;
  background: var(--paper, #fff);
  border: 1px solid var(--line, #e6e9ee);
  border-radius: var(--radius, 10px);
  padding: 10px 11px;
  cursor: grab;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.dispatch-job:hover {
  border-color: var(--teal, #14a394);
  box-shadow: var(--shadow-sm, 0 4px 12px rgba(15, 23, 42, 0.08));
}
.dispatch-job:active { cursor: grabbing; }
.dispatch-job.is-urgent { border-left: 3px solid var(--red, #e5484d); }
.dispatch-job.is-locked { cursor: not-allowed; opacity: 0.72; }
.dispatch-job.is-dragging { opacity: 0.45; }
.dispatch-job.is-hidden { display: none; }
.dispatch-job-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.dispatch-no {
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12px;
  color: var(--ink-2, #4b5563);
}
.dispatch-job-line {
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2, #4b5563);
}
.dispatch-job-cust { font-weight: 600; color: var(--ink, #1f2937); font-size: 13px; }
.dispatch-job-time {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-3, #8b93a1);
}
.dispatch-job-locked {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--red, #e5484d);
}
.dispatch-job-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}
.dispatch-money {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--teal, #14a394);
}
.dispatch-money-sm { font-size: 12px; font-weight: 600; color: var(--teal, #14a394); }
.dispatch-money.muted { color: var(--ink-4, #aab2bf); font-weight: 400; }
.dispatch-job-locked, .dispatch-job-foot .spacer { flex: 1; }
.dispatch-job-foot .spacer { flex: 1; }

/* ---------- 看板 ---------- */
.dispatch-board-card .card-head { flex-wrap: wrap; gap: 8px; }
.dispatch-board-hint { font-size: 12px; }
.dispatch-board-body { padding: 0; }
.dispatch-board-scroll {
  overflow: auto;
  max-height: calc(100vh - 300px);
  max-width: 100%;
  overscroll-behavior-x: contain;
  border-radius: 0 0 var(--radius, 10px) var(--radius, 10px);
}
.dispatch-grid {
  display: grid;
  grid-template-columns: 186px repeat(var(--dispatch-cols, 7), minmax(146px, 1fr));
  min-width: 100%;
  width: max-content;
  background: var(--paper, #fff);
}
.dispatch-cell {
  min-height: 44px;
  border-top: 1px solid var(--line-soft, #eef1f5);
  border-left: 1px solid var(--line-soft, #eef1f5);
  padding: 6px;
  background: var(--paper, #fff);
}
.dispatch-corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3, #8b93a1);
  background: var(--bg-2, #f6f8f8);
  border-top: 0;
}
.dispatch-day-head {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: center;
  justify-content: center;
  background: var(--bg-2, #f6f8f8);
  border-top: 0;
  text-align: center;
}
.dispatch-day-date {
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2, #4b5563);
}
.dispatch-day-week { font-size: 11px; color: var(--ink-3, #8b93a1); }
.dispatch-day-count { font-size: 11px; color: var(--teal, #14a394); }
.dispatch-day-head.is-today {
  background: var(--teal-soft, #e6f6f3);
}
.dispatch-day-head.is-today .dispatch-day-date,
.dispatch-day-head.is-today .dispatch-day-week { color: var(--teal, #14a394); }

/* 师傅行首列 */
.dispatch-installer {
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 10px;
  background: var(--paper, #fff);
  box-shadow: 1px 0 0 var(--line-soft, #eef1f5);
}
.dispatch-inst-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.dispatch-inst-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}
.dispatch-inst-name b {
  font-size: 13px;
  color: var(--ink, #1f2937);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dispatch-inst-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.dispatch-inst-load { font-size: 11px; color: var(--ink-3, #8b93a1); }
.dispatch-inst-block {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--ink-3, #8b93a1);
}
.dispatch-installer.is-blocked { background: var(--bg-2, #f6f8f8); }

/* 格子 */
.dispatch-slot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 118px;
  padding: 6px;
}
.dispatch-slot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--ink-4, #aab2bf);
  min-height: 14px;
}
.dispatch-today-flag {
  color: var(--teal, #14a394);
  font-weight: 600;
}
.dispatch-slot.is-today { background: var(--teal-mist, rgba(20, 163, 148, 0.06)); }
.dispatch-slot.is-blocked {
  background: repeating-linear-gradient(
    135deg,
    var(--bg-2, #f6f8f8) 0,
    var(--bg-2, #f6f8f8) 6px,
    var(--bg, #fbfcfc) 6px,
    var(--bg, #fbfcfc) 12px
  );
  cursor: not-allowed;
}
.dispatch-slot.is-blocked .dispatch-slot-head { opacity: 0.4; }
.dispatch-slot.is-full .dispatch-slot-head span:first-child { color: var(--orange, #f59e0b); font-weight: 600; }
.dispatch-drop-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-top: auto;
  padding: 7px 0;
  border: 1px dashed transparent;
  border-radius: var(--radius-sm, 8px);
  font-size: 11px;
  color: transparent;
  transition: all 0.12s ease;
}
.dispatch-slot:hover .dispatch-drop-hint {
  border-color: var(--line, #e6e9ee);
  color: var(--ink-4, #aab2bf);
}
.dispatch-slot.is-over {
  outline: 2px dashed var(--teal, #14a394);
  outline-offset: -3px;
  background: var(--teal-mist, rgba(20, 163, 148, 0.12));
}
.dispatch-slot.is-over .dispatch-drop-hint {
  border-color: var(--teal, #14a394);
  color: var(--teal, #14a394);
}

/* 看板小卡 */
.dispatch-job-mini {
  padding: 6px 8px;
  border-radius: var(--radius-sm, 8px);
  box-shadow: var(--shadow-xs, 0 1px 2px rgba(15, 23, 42, 0.06));
}
.dispatch-job-mini.is-urgent { border-left-width: 3px; }
.dispatch-mini-top {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.dispatch-mini-top b {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--ink, #1f2937);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dispatch-flag-urgent {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  color: var(--red, #e5484d);
  background: var(--red-soft, #fdecec);
  border-radius: 4px;
  padding: 1px 4px;
}
.dispatch-mini-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-3, #8b93a1);
  cursor: pointer;
}
.dispatch-mini-btn:hover {
  background: var(--bg-2, #f6f8f8);
  color: var(--teal, #14a394);
}
.dispatch-mini-line {
  font-size: 11px;
  color: var(--ink-3, #8b93a1);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dispatch-mini-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 16px;
}
.dispatch-mini-lock {
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-size: 10px;
  color: var(--red, #e5484d);
}

.dispatch-legend {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 12px;
  line-height: 1.6;
  font-size: 12px;
}

/* ---------- 派单确认弹层 ---------- */
.dispatch-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}
.dispatch-form-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.55;
}
.dispatch-form-row > span:first-child {
  flex: none;
  width: 62px;
  color: var(--ink-3, #8b93a1);
}
.dispatch-form-row b { color: var(--ink, #1f2937); font-weight: 600; }
.dispatch-form-field { margin-top: 4px; }
.dispatch-change-date { color: var(--orange, #f59e0b); }

/* ---------- 列表模式 ---------- */
.dispatch-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
}
.dispatch-list-day {
  border: 1px solid var(--line, #e6e9ee);
  border-radius: var(--radius, 10px);
  overflow: hidden;
}
.dispatch-list-day-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-2, #f6f8f8);
  font-size: 12px;
  color: var(--ink-2, #4b5563);
}
.dispatch-list-day-head b {
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 13px;
  color: var(--ink, #1f2937);
}
.dispatch-list-day.is-today .dispatch-list-day-head {
  background: var(--teal-soft, #e6f6f3);
  color: var(--teal, #14a394);
}
.dispatch-list-day.is-today .dispatch-list-day-head b { color: var(--teal, #14a394); }
.dispatch-list-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft, #eef1f5);
  cursor: grab;
  transition: background 0.12s ease;
}
.dispatch-list-row:hover { background: var(--bg-2, #f6f8f8); }
.dispatch-list-row.is-urgent { border-left: 3px solid var(--red, #e5484d); padding-left: 9px; }
.dispatch-list-row.is-locked { cursor: not-allowed; opacity: 0.72; }
.dispatch-list-row.is-hidden { display: none; }
.dispatch-list-time {
  flex: none;
  width: 42px;
  padding-top: 2px;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12px;
  color: var(--ink-2, #4b5563);
}
.dispatch-list-main { flex: 1; min-width: 0; }
.dispatch-list-addr {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dispatch-list-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.dispatch-list-actions { flex: none; padding-top: 1px; }
.dispatch-list-empty {
  padding: 12px;
  font-size: 12px;
  color: var(--ink-4, #aab2bf);
}

/* ---------- 响应式 ---------- */
@media (max-width: 1240px) {
  .dispatch-layout { grid-template-columns: 282px minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .dispatch-layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .dispatch-board-card { width: 100%; max-width: 100%; min-width: 0; overflow: hidden; }
  .dispatch-board-body { width: 100%; max-width: 100%; min-width: 0; overflow: hidden; }
  .dispatch-board-scroll { width: 100%; max-width: 100%; min-width: 0; }
  .dispatch-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dispatch-actions { width: 100%; }
  .dispatch-actions .btn { padding: 6px 9px; }
  .dispatch-range-label { order: 5; }
  .dispatch-pool { max-height: 340px; }
  .dispatch-pool-unscheduled { max-height: 300px; }
  .dispatch-board-scroll { max-height: none; }
  .dispatch-grid { grid-template-columns: 150px repeat(var(--dispatch-cols, 7), minmax(136px, 1fr)); }
  .dispatch-slot { min-height: 104px; }
  .dispatch-list { padding: 10px; }
  .dispatch-list-row { gap: 8px; padding: 9px 10px; }
  .dispatch-list-time { width: 36px; font-size: 11px; }
  .dispatch-legend { font-size: 11px; }
}

@media (max-width: 480px) {
  .dispatch-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dispatch-grid { grid-template-columns: 138px repeat(var(--dispatch-cols, 7), minmax(128px, 1fr)); }
}
