:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #dbe3ee;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #b45309;
  --radius: 16px;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 500px at 12% -10%, #dbeafe 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #ede9fe 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.page {
  max-width: 1420px;
  margin: 0 auto;
  padding: 20px 22px 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

.logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}

h1 { margin: 0; font-size: 21px; letter-spacing: -0.02em; }
.brand p { margin: 1px 0 0; color: var(--muted); font-size: 12px; }

.topbar-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.sys-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  color: #334155;
  font-size: 11px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.sys-stat .sys-name {
  color: var(--muted);
  font-weight: 600;
}

.sys-stat .sys-bar {
  width: 42px;
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
}

.sys-stat .sys-bar > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #2563eb;
  transition: width 0.35s ease, background 0.35s ease;
}

.sys-stat strong {
  min-width: 28px;
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
}

.sys-stat.warn .sys-bar > span { background: #f59e0b; }
.sys-stat.danger .sys-bar > span { background: #dc2626; }
.sys-stat.unavailable { opacity: 0.6; }
.sys-stat.unavailable .sys-bar > span { background: #94a3b8; }

.pill {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill.idle { background: #e2e8f0; color: #475569; }
.pill.starting { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.pill.running { background: #dcfce7; color: #166534; border-color: #86efac; }
.pill.stopping { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.pill.finished { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.pill.success { background: #dcfce7; color: #166534; border-color: #86efac; }
.pill.failed { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.pill.stopped { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.hidden { display: none !important; }

.view-badge {
  font-size: 11px;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 2px 8px;
}

.run-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 10px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 8px;
}

.run-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  color: #334155;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.run-tab:hover {
  border-color: #93c5fd;
  background: #f0f7ff;
}

.run-tab.active {
  border-color: var(--primary);
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.run-tab-id {
  font-family: var(--mono);
  font-weight: 700;
}

.run-tab-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-tab-progress {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.run-tab.active .run-tab-progress {
  color: #2563eb;
}

.task-error {
  margin-bottom: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.select-sm, .input-sm {
  width: auto;
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 12px;
}
.input-sm { width: 170px; }

.alert {
  margin-bottom: 14px;
  padding: 11px 14px;
  border-radius: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  white-space: pre-wrap;
  word-break: break-word;
}
.alert.hidden { display: none; }

.layout {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(219, 227, 238, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.panel { padding: 18px 18px 16px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 15px; letter-spacing: -0.01em; }

.muted { color: var(--muted); font-size: 12px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.hint { color: var(--muted); font-size: 11.5px; }
.hint code { background: #eff6ff; color: #1d4ed8; padding: 1px 5px; border-radius: 5px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.field { margin-bottom: 15px; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.field > label, .field-head label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 650;
  color: #334155;
}
.field-head label { margin-bottom: 0; }
.field > .hint { display: block; margin-top: 4px; }

input[type="text"], input[type="number"], input[type="password"], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
textarea {
  margin-top: 9px;
  resize: vertical;
  min-height: 82px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .field { margin-bottom: 15px; }

.dropzone {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1.5px dashed #c7d2e1;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.drag {
  border-color: var(--primary);
  background: #eff6ff;
}

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #475569;
  font-size: 12.5px;
  margin-bottom: 13px;
  user-select: none;
}
.check.inline { margin-bottom: 0; }
.check input { accent-color: var(--primary); width: 15px; height: 15px; }

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
#run-capacity { margin-left: 2px; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 650;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, opacity 0.15s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn.danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.btn.danger:hover:not(:disabled) { background: #fecaca; }
.btn.ghost { background: #fff; border-color: var(--border); color: #334155; }
.btn.ghost:hover:not(:disabled) { border-color: #bfdbfe; background: #f8fbff; }
.btn.tiny { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.danger-ghost { background: #fff; border-color: #fecaca; color: #b91c1c; }
.btn.danger-ghost:hover:not(:disabled) { background: #fef2f2; }

.console { display: flex; flex-direction: column; min-height: 620px; }

.log {
  flex: 1;
  min-height: 360px;
  max-height: 60vh;
  overflow: auto;
  padding: 10px 8px;
  border-radius: 12px;
  background: #0b1220;
  border: 1px solid #172033;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  scrollbar-color: #334155 transparent;
}
.log:empty::before {
  content: "等待任务启动…";
  display: block;
  padding: 18px;
  color: #475569;
}

.log-line {
  display: flex;
  gap: 9px;
  padding: 1px 7px;
  border-left: 2px solid transparent;
  white-space: pre-wrap;
  word-break: break-word;
  color: #cbd5e1;
}
.log-time { color: #64748b; flex: none; }
.log-text { min-width: 0; }
.log-line.info { color: #cbd5e1; }
.log-line.system { color: #93c5fd; border-left-color: #3b82f6; }
.log-line.success { color: #86efac; border-left-color: #22c55e; }
.log-line.warning { color: #fcd34d; border-left-color: #f59e0b; }
.log-line.error { color: #fca5a5; border-left-color: #ef4444; }

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.stat {
  min-width: 78px;
  padding: 7px 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  text-align: center;
}
.stat span { display: block; font-size: 18px; font-weight: 750; line-height: 1.2; }
.stat label { font-size: 11px; color: var(--muted); }
.stat.success span { color: var(--success); }
.stat.verify span { color: var(--warning); }
.stat.retry span { color: #2563eb; }
.stat.fail span { color: var(--danger); }
.stat.wide {
  flex: 1;
  min-width: 190px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}
.progress {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}
#progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #22c55e);
  transition: width 0.3s ease;
}
#progress-text { font-size: 12px; color: #475569; white-space: nowrap; }

.results {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: #7c8798;
  font-size: 11.5px;
  padding: 16px 4px 4px;
}

.history { margin-top: 16px; }
.history .panel-head { align-items: flex-start; }
.history .panel-head .row { flex-wrap: nowrap; }
.history .input-sm { width: 200px; }
.history-counts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.count-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px;
}
.count-chip b { color: var(--text); font-size: 12.5px; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 1000px;
}
.task-table th {
  text-align: left;
  padding: 9px 12px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 650;
  font-size: 11.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.task-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
}
.task-table tr:last-child td { border-bottom: 0; }
.task-table tbody tr:hover { background: #f8fbff; }
.task-table tbody tr.selected { background: #eff6ff; }
.task-table .mono { font-family: var(--mono); color: #475569; white-space: nowrap; }
.empty-cell { text-align: center; color: var(--muted); padding: 28px 12px !important; }
.row-actions { white-space: nowrap; }
.row-actions .btn { margin-right: 4px; }

.result-links { white-space: nowrap; }
.result-link {
  appearance: none;
  border: 0;
  background: none;
  padding: 2px 6px;
  color: #1d4ed8;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.result-link + .result-link { border-left: 1px solid #e5e7eb; }
.result-link:hover:not(:disabled) { text-decoration: underline; }
.result-link:disabled { color: #cbd5e1; cursor: not-allowed; }

.link-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  color: #1d4ed8;
  font: inherit;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.status-badge.running { background: #dcfce7; color: #166534; }
.status-badge.success { background: #dcfce7; color: #166534; }
.status-badge.failed { background: #fee2e2; color: #991b1b; }
.status-badge.stopped { background: #f1f5f9; color: #475569; }
.status-badge.pending { background: #fef3c7; color: #92400e; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
}
.modal.hidden { display: none; }
.modal-card {
  width: min(380px, 100%);
  padding: 22px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}
.modal-card h2 { margin: 0 0 6px; font-size: 18px; }
.modal-card p { margin: 0 0 14px; }
.modal-card input { margin-bottom: 10px; }
.modal-card .btn { width: 100%; }
.error-text { min-height: 18px; color: #b91c1c; font-size: 12px; margin: 0 0 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(560px, calc(100vw - 40px));
  padding: 10px 16px;
  border-radius: 10px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
  white-space: pre-wrap;
  word-break: break-word;
}
.toast.error { background: #991b1b; }
.toast.hidden { display: none; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .console { min-height: 520px; }
  .log { max-height: 50vh; }
}

@media (max-width: 560px) {
  .page { padding: 14px; }
  .topbar { align-items: flex-start; }
  .topbar-meta { justify-content: flex-start; }
  .grid2 { grid-template-columns: 1fr; }
  h1 { font-size: 19px; }
}
