/* ==========================================================================
   FlowLink · Agent 任务执行层
   仅新增执行过程所需的动效与容器样式，颜色 / 圆角 / 间距全部复用 tokens.css
   ========================================================================== */

/* 挂载位：display:contents 让它不产生额外 flex 间距，空态不影响布局 */
.run-slot { display: contents; }

.agent-run [hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   1. 执行面板
   -------------------------------------------------------------------------- */
.agent-run {
  display: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
}
.agent-run.is-open { display: flex; flex-direction: column; animation: pop .26s ease-out; }

.agent-run__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-soft);
}
.agent-run__spark {
  width: 26px; height: 26px; flex: 0 0 26px;
  border-radius: 8px;
  background: var(--blue);
  color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  animation: spark-breathe 1.8s ease-in-out infinite;
}
.agent-run__head { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.agent-run__title { font-size: 13px; font-weight: 600; color: var(--ink); }
.agent-run__sub { font-size: 10px; color: var(--ink-3); }

.agent-run__count {
  margin-left: auto;
  font-family: var(--font-num);
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.agent-run__count b { color: var(--blue); font-weight: 600; }

.agent-run__track {
  width: 132px; height: 4px; flex: 0 0 132px;
  border-radius: var(--r-pill);
  background: var(--line-soft);
  overflow: hidden;
}
.agent-run__fill {
  display: block; height: 100%; width: 0;
  border-radius: var(--r-pill);
  background: var(--blue);
  transition: width .3s cubic-bezier(.4, 0, .2, 1);
}
.agent-run__clock {
  font-family: var(--font-num);
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: right;
}

.agent-run__body {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  height: 184px;
}
.agent-run__steps {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--line-soft);
  overflow: hidden;
}
.agent-run__log {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 5px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 26px);
  mask-image: linear-gradient(180deg, transparent, #000 26px);
}

/* 步骤 */
.run-step { display: flex; align-items: center; gap: 8px; font-size: 11.5px; min-height: 20px; }
.run-step__label {
  color: var(--ink-4);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.run-step__meta {
  margin-left: auto;
  font-family: var(--font-num);
  font-size: 10px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}
.run-step__dot {
  width: 14px; height: 14px; flex: 0 0 14px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: #FFFFFF;
  box-sizing: border-box;
}
.run-step.is-run .run-step__dot {
  border-color: var(--blue);
  border-top-color: transparent;
  animation: spin .7s linear infinite;
}
.run-step.is-run .run-step__label { color: var(--blue); font-weight: 500; }
.run-step.is-done .run-step__dot {
  border-color: var(--green);
  background: var(--green)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.6 8.4 6.4 11.2 12.4 5.2'/%3E%3C/svg%3E")
    center / 11px 11px no-repeat;
}
.run-step.is-done .run-step__label { color: var(--ink-2); }
.run-step.is-stopped .run-step__dot { border-color: var(--ink-4); border-style: dashed; }
.run-step.is-stopped .run-step__label { color: var(--ink-4); text-decoration: line-through; }

/* 日志流 */
.log-line {
  display: flex;
  gap: 10px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-2);
  animation: log-in .2s ease-out;
}
.log-line__t {
  flex: 0 0 52px;
  font-family: var(--font-num);
  font-size: 10px;
  color: var(--ink-5);
  padding-top: 1px;
  font-variant-numeric: tabular-nums;
}
.log-line.is-run { color: var(--blue); }
.log-line.is-warn { color: var(--amber); }
.log-line.is-done { color: var(--green); }

/* 收尾条 */
.agent-run__foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--fill);
  animation: pop .26s ease-out;
}
.run-foot__ok {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--green);
  flex: 0 0 auto;
}
.run-foot__txt { font-size: 11px; color: var(--ink-2); }
.run-foot__tri { margin-left: auto; display: flex; gap: 8px; flex: 0 0 auto; }

/* 横幅内任务按钮组 */
.banner__act { display: flex; gap: 8px; flex: 0 0 auto; }
.tri-chip {
  display: inline-flex; align-items: baseline; gap: 5px;
  height: 22px; padding: 0 9px;
  border-radius: var(--r-pill);
  background: #FFFFFF;
  border: 1px solid var(--line);
}
.tri-chip i { font-style: normal; font-size: 9px; color: var(--ink-4); }
.tri-chip b { font-family: var(--font-num); font-size: 11px; font-weight: 600; color: var(--blue); }

/* --------------------------------------------------------------------------
   2. 页面联动：端到端链路
   -------------------------------------------------------------------------- */
.e2e-step.is-run {
  background: rgba(0, 102, 204, .05);
  box-shadow: inset 0 0 0 1px rgba(0, 102, 204, .16);
  border-radius: var(--r-chip);
  animation: step-pulse 1.7s ease-in-out infinite;
}
.e2e-step.is-run .e2e-step__name { color: var(--blue); }
.e2e-step.is-run .e2e-step__no { background: var(--blue); color: #FFFFFF; }
.e2e-step.is-done .e2e-step__no { background: var(--green-bg); color: var(--green); }

/* --------------------------------------------------------------------------
   3. 页面联动：凭证图像扫描
   -------------------------------------------------------------------------- */
.photo-box { position: relative; }
.photo-box.is-scanning { box-shadow: inset 0 0 0 1px rgba(0, 102, 204, .35); }
.photo-box.is-scanning::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0, 102, 204, .12), rgba(0, 102, 204, 0) 55%);
  pointer-events: none;
}
.scan-line {
  position: absolute; left: 4%; right: 4%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--blue-bright) 22%, #FFFFFF 50%, var(--blue-bright) 78%, transparent);
  box-shadow: 0 0 12px 1px rgba(77, 163, 255, .85);
  animation: scan 1.8s cubic-bezier(.45, 0, .55, 1) infinite;
  pointer-events: none;
}
.scan-tag {
  position: absolute; top: 10px; left: 10px;
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px;
  border-radius: var(--r-pill);
  background: rgba(29, 29, 31, .78);
  color: #FFFFFF;
  font-size: 10px; font-weight: 500;
  backdrop-filter: blur(6px);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   4. 页面联动：字段抽取与冲突复核
   -------------------------------------------------------------------------- */
.field.is-reading .input { background: var(--fill); color: var(--ink-4); }
.field__hint.is-count { color: var(--blue); }
.field__hint.is-count b { font-family: var(--font-num); font-weight: 600; }
.field__hint.is-ok { color: var(--green); }
.input.is-corrected {
  border-color: var(--green) !important;
  box-shadow: 0 0 0 3px rgba(29, 138, 76, .14) !important;
}
.field.is-error-flash .input { animation: shake .44s ease-in-out; }

.cand-row { display: flex; gap: 6px; animation: pop .2s ease-out; }
.cand {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: #FFFFFF;
  font-size: 11px; font-weight: 500; color: var(--ink-2);
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.cand i { font-style: normal; font-size: 9px; color: var(--ink-4); }
.cand:hover { border-color: var(--blue); color: var(--blue); }
.cand.is-pick { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.cand.is-pick i { color: var(--blue); opacity: .8; }

/* --------------------------------------------------------------------------
   5. 页面联动：表格行入场与数值变更闪烁
   -------------------------------------------------------------------------- */
.is-new-row { animation: row-in .3s ease-out both; }
.flash-up { animation: flash-up 1.3s ease-out; }
.budget__metric b, .stat-cell__v { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   6. 关键帧
   -------------------------------------------------------------------------- */
@keyframes scan { 0% { top: 6%; } 50% { top: 92%; } 100% { top: 6%; } }
@keyframes step-pulse {
  0%, 100% { background: rgba(0, 102, 204, .05); }
  50% { background: rgba(0, 102, 204, .1); }
}
@keyframes spark-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 102, 204, .3); }
  50% { box-shadow: 0 0 0 5px rgba(0, 102, 204, 0); }
}
@keyframes row-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes flash-up { 0% { background: var(--blue-soft); } 100% { background: transparent; } }
@keyframes log-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

/* --------------------------------------------------------------------------
   7. 响应式与打印
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .agent-run__body { grid-template-columns: minmax(0, 1fr); height: auto; }
  .agent-run__steps { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .agent-run__log { height: 132px; }
  .agent-run__foot { flex-wrap: wrap; }
}
@media (max-width: 760px) {
  .agent-run__track { display: none; }
  .agent-run__sub { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .scan-line, .agent-run__spark, .e2e-step.is-run { animation: none; }
}
