/* Automation console — standalone page (no framework, zero build). */
:root {
  --brand: #1890ff;
  --brand-dark: #096dd9;
  --ok: #52c41a;
  --warn: #faad14;
  --err: #f5222d;
  --text: #1f2733;
  --muted: #7a8699;
  --line: #e8ecf1;
  --bg: #f4f6fa;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lift: 0 12px 32px rgba(15, 23, 42, .14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.back-link { color: var(--muted); text-decoration: none; font-size: 13px; }
.back-link:hover { color: var(--brand); }
.title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.operator { color: var(--muted); font-size: 13px; margin-right: 4px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid transparent; border-radius: 8px;
  padding: 7px 14px; font-size: 13px; cursor: pointer;
  transition: all .18s ease; white-space: nowrap;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn.danger { background: var(--err); color: #fff; }
.btn.danger:hover { background: #d81e06; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- page / filters ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 20px 24px 64px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 6px 16px; font-size: 13px; cursor: pointer;
  transition: all .15s ease;
}
.chip:hover { color: var(--brand); border-color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- job cards ---------- */
.job-list { display: flex; flex-direction: column; gap: 12px; }
.job-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; gap: 6px 16px;
  transition: box-shadow .18s ease, transform .18s ease;
  animation: fadeUp .25s ease;
}
.job-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.job-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.job-id { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.job-raw { font-weight: 600; font-size: 14px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.job-meta { color: var(--muted); font-size: 12.5px; grid-column: 1 / -1;
  display: flex; gap: 18px; flex-wrap: wrap; }
.job-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- status badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 2px 10px; font-size: 12px;
  font-weight: 500; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.run { background: #e8f4ff; color: var(--brand-dark); }
.badge.run .dot { animation: blink 1s infinite; }
.badge.ok { background: #ecffea; color: #2b8a0e; }
.badge.warn { background: #fff6e0; color: #b8770a; }
.badge.err { background: #ffeceb; color: #cf1318; }
.badge.review { background: #f1ecff; color: #6b3fc4; }

/* ---------- empty / loading ---------- */
.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }
.hidden { display: none !important; }

/* ---------- drawer ---------- */
.drawer-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 23, 42, .38);
  display: flex; justify-content: flex-end;
  animation: fadeIn .2s ease;
}
.drawer {
  width: min(680px, 94vw); height: 100%; background: #fff;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lift);
  animation: slideIn .25s ease;
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 15px;
}
.drawer-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.drawer-foot {
  padding: 14px 22px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 10px;
}
.icon-x { border: none; background: none; font-size: 22px; color: var(--muted);
  cursor: pointer; line-height: 1; }
.icon-x:hover { color: var(--text); }

/* ---------- form ---------- */
.field { display: block; margin-bottom: 18px; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; }
.field-label i { color: var(--err); font-style: normal; }
.field textarea, .field select, .field input[type="text"], .field input[type="number"] {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font-size: 14px; font-family: inherit; resize: vertical;
}
.field textarea:focus, .field select:focus { outline: none; border-color: var(--brand); }
.switch-field { display: flex; align-items: center; justify-content: space-between; }
.switch-field .field-label { margin: 0; }

/* ---------- detail sections ---------- */
.section { margin-bottom: 22px; }
.section h4 {
  margin: 0 0 10px; font-size: 13px; color: var(--muted);
  font-weight: 600; letter-spacing: .02em;
}
.raw-box {
  background: var(--bg); border-radius: 8px; padding: 12px 14px;
  line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }

/* timeline */
.timeline { display: flex; flex-wrap: wrap; gap: 0; }
.tl-step {
  flex: 1 1 auto; min-width: 78px; text-align: center; position: relative;
  padding-top: 22px; font-size: 11.5px; color: var(--muted);
}
.tl-step::before {
  content: ""; position: absolute; top: 6px; left: 50%;
  width: 12px; height: 12px; border-radius: 50%;
  background: #d7dde5; transform: translateX(-50%); z-index: 2;
}
.tl-step::after {
  content: ""; position: absolute; top: 11px; left: -50%;
  width: 100%; height: 2px; background: #d7dde5; z-index: 1;
}
.tl-step:first-child::after { display: none; }
.tl-step.done { color: #2b8a0e; }
.tl-step.done::before, .tl-step.done::after { background: var(--ok); }
.tl-step.current { color: var(--brand-dark); font-weight: 600; }
.tl-step.current::before { background: var(--brand);
  box-shadow: 0 0 0 4px rgba(24, 144, 255, .18); animation: pulse 1.2s infinite; }
.tl-step.fail { color: var(--err); }
.tl-step.fail::before { background: var(--err); }

/* combo tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 8px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.tab.active { border-color: var(--brand); color: var(--brand); background: #f0f8ff; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td {
  text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line);
}
table.grid th { color: var(--muted); font-weight: 500; background: #fafbfc; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.recommend-tag { color: var(--ok); font-weight: 600; }

/* ---------- confirm dialog / toast ---------- */
.mask {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(15, 23, 42, .38);
  display: flex; align-items: center; justify-content: center;
}
.dialog {
  width: min(420px, 92vw); background: #fff; border-radius: 14px;
  padding: 22px; box-shadow: var(--shadow-lift); animation: fadeUp .2s ease;
}
.dialog-title { font-weight: 600; font-size: 15px; margin-bottom: 10px; }
.dialog-body { color: var(--text); line-height: 1.6; margin-bottom: 18px; }
.dialog-body textarea {
  width: 100%; margin-top: 10px; border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 12px; font-family: inherit; min-height: 84px;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 100; padding: 10px 18px; border-radius: 8px;
  color: #fff; font-size: 13px; box-shadow: var(--shadow-lift);
  background: rgba(30, 40, 55, .92);
}
.toast.ok { background: #2b8a0e; }
.toast.err { background: var(--err); }

@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 3px rgba(24,144,255,.25); }
  70% { box-shadow: 0 0 0 8px rgba(24,144,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(24,144,255,0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }

@media (max-width: 720px) {
  .operator { display: none; }
  .page { padding: 14px; }
  .job-card { grid-template-columns: 1fr; }
  .job-actions { justify-content: flex-start; }
}
/* External marketplace reference products (JD / 1688) */
.ext-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 12px;
  line-height: 1.5;
  color: #b45309;
  background: #fef3c7;
  border-radius: 999px;
  vertical-align: middle;
}
.ext-link {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  color: var(--primary, #2563eb);
  text-decoration: none;
}
.ext-link:hover { text-decoration: underline; }
.row-external td { background: #fffbeb; }
.missing-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.missing-tag {
  padding: 3px 10px;
  font-size: 12px;
  color: #b91c1c;
  background: #fee2e2;
  border-radius: 999px;
}
