/* ═══════════════════════════════════════════════════════════
   pages.css — 登录页 / 任务工作台（列表面板、Tab、时序图）
   ═══════════════════════════════════════════════════════════ */

/* ═══ 登录页 ═══ */
.login-page {
  background-color: var(--bg-base);
  background-image: radial-gradient(circle at 18% -8%, rgba(14, 116, 144, 0.08), transparent 46%),
    radial-gradient(circle at 90% 110%, rgba(2, 132, 199, 0.06), transparent 40%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-page .main-content {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-overlay);
}

.login-header {
  text-align: center;
  margin-bottom: var(--space-5);
}

.login-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto var(--space-3);
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-hover);
}

.login-header h1 {
  margin-bottom: var(--space-1);
}

.login-header p {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.login-card .btn {
  width: 100%;
  padding: 0.6rem;
  font-size: var(--text-base);
}

/* ═══ 全局健康摘要条（列表面板顶部） ═══ */
.health-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.health-cell {
  background: var(--bg-raised);
  padding: var(--space-2) var(--space-3);
  text-align: center;
}

.health-cell-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}

.health-cell-value.ok {
  color: var(--ok);
}

.health-cell-value.err {
  color: var(--err);
}

.health-cell-value.run {
  color: var(--run);
}

.health-cell-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ═══ 列表面板：搜索与过滤 ═══ */
.list-toolbar {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.list-search {
  position: relative;
}

.list-search svg {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.list-search input {
  padding-left: 2rem;
}

.filter-chips {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.filter-chip {
  padding: 0.15rem 0.6rem;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}

.filter-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.filter-chip.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* ═══ 列表面板：任务项 ═══ */
.task-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}

.task-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  margin-bottom: 2px;
  position: relative;
}

.task-item:hover {
  background: var(--bg-inset);
}

.task-item.active {
  background: var(--accent-soft);
  border-color: rgba(14, 116, 144, 0.25);
}

.task-item-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 0.3rem;
}

.task-item-name {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.task-item-sub {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.task-item-sub .spacer {
  flex: 1;
}

/* 迷你趋势（最近 10 次运行的方块） */
.sparkline {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

.spark-cell {
  width: 6px;
  height: 10px;
  border-radius: 2px;
  background: var(--idle-soft);
}

.spark-cell.ok {
  background: var(--ok);
  opacity: 0.75;
}

.spark-cell.err {
  background: var(--err);
}

.spark-cell.run {
  background: var(--run);
  animation: pulse-dot 1.6s var(--ease) infinite;
}

/* 任务项快捷操作（hover 显示） */
.task-item-actions {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: none;
  align-items: center;
  gap: var(--space-1);
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  box-shadow: var(--shadow-card);
}

.task-item:hover .task-item-actions {
  display: inline-flex;
}

.quick-btn {
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.quick-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.quick-btn.danger:hover {
  color: var(--err);
  background: var(--err-soft);
}

.list-footer {
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ═══ 详情区：头部与 Tab ═══ */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.detail-entry {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  word-break: break-all;
}

.detail-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.tab-bar {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
}

.tab-btn {
  padding: 0.5rem 1rem;
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-btn .tab-count {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-left: 0.25rem;
}

/* ═══ 概览 Tab：指标卡 ═══ */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.metric-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-card);
}

.metric-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.25;
}

.metric-value.ok {
  color: var(--ok);
}

.metric-value.err {
  color: var(--err);
}

.metric-value.run {
  color: var(--run);
}

.metric-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ═══ 概览 Tab：运行时序图 ═══ */
.runchart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 96px;
  padding: var(--space-3);
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.runchart-bar {
  flex: 1;
  max-width: 26px;
  min-height: 8px;
  border-radius: 3px 3px 0 0;
  background: var(--idle);
  cursor: pointer;
  position: relative;
  transition: opacity var(--dur-fast) var(--ease);
}

.runchart-bar.ok {
  background: var(--ok);
  opacity: 0.7;
}

.runchart-bar.err {
  background: var(--err);
}

.runchart-bar.run {
  background: var(--run);
  animation: pulse-dot 1.6s var(--ease) infinite;
}

.runchart-bar:hover {
  opacity: 1;
}

.runchart-bar:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: #fff;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

.runchart-empty {
  width: 100%;
  text-align: center;
  align-self: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ═══ 历史 Tab：运行详情弹层 ═══ */
.run-detail-modal {
  max-width: 760px;
}

.run-detail-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  color: var(--text-secondary);
  padding: var(--space-3);
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.run-detail-error {
  font-size: var(--text-sm);
  color: var(--err);
  background: var(--err-soft);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  word-break: break-all;
}

.run-detail-block {
  margin-bottom: var(--space-4);
}

.run-detail-event {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}

.run-detail-event:last-child {
  border-bottom: none;
}

.run-detail-event-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.run-detail-time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-left: auto;
}

.run-detail-event-title {
  color: var(--text-primary);
}

.run-detail-event-line {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  word-break: break-all;
}

/* ═══ 日志 Tab ═══ */
.log-run-picker {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.log-run-picker select {
  max-width: 360px;
}

/* ═══ 移动端列表抽屉切换按钮 ═══ */
.list-toggle {
  display: none;
}

@media (max-width: 860px) {
  .list-toggle {
    display: inline-flex;
  }

  .detail-header {
    flex-direction: column;
  }
}

/* ── 流程节点时间线（flow-tab）── */
.flow-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.flow-total {
  color: var(--text-muted);
  font-size: var(--text-xs);
}
.flow-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.flow-node {
  display: flex;
  gap: 0.85rem;
  padding: 0 0 1.15rem;
  position: relative;
}
.flow-node::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 24px;
  bottom: -2px;
  width: 2px;
  background: var(--border-subtle);
}
.flow-node:last-child::before {
  display: none;
}
.flow-dot {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--bg-inset);
  color: var(--text-muted);
  border: 2px solid var(--border-subtle);
  z-index: 1;
}
.flow-body {
  flex: 1;
  padding-top: 1px;
  min-width: 0;
}
.flow-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.flow-label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--text-sm);
}
.flow-state {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.flow-ms {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-left: auto;
  font-family: var(--font-mono);
}
.flow-detail {
  margin-top: 0.3rem;
  font-size: var(--text-xs);
  color: var(--err);
  background: var(--err-soft);
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-sm);
  word-break: break-word;
}
.flow-success .flow-dot {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok);
}
.flow-success .flow-state {
  color: var(--ok);
}
.flow-failed .flow-dot {
  background: var(--err-soft);
  color: var(--err);
  border-color: var(--err);
}
.flow-failed .flow-state {
  color: var(--err);
}
.flow-running .flow-dot {
  background: var(--run-soft);
  color: var(--run);
  border-color: var(--run);
  animation: flow-pulse 1.1s ease-in-out infinite;
}
.flow-running .flow-state {
  color: var(--run);
  font-weight: 600;
}
@keyframes flow-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.9);
  }
}
@media (prefers-reduced-motion: reduce) {
  .flow-running .flow-dot {
    animation: none;
  }
}

/* ── 已缓存 PDF 列表（flow-tab 底部）── */
.pdf-cache-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}
.pdf-cache-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}
.pdf-cache-name {
  font-family: var(--font-mono);
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}
.pdf-cache-name:hover {
  text-decoration: underline;
}
.pdf-cache-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
